feat: dsh-geek2api 0.1.0, a Geek2API route for DeepSeek Harness
Derived from dsh-packycode-api 1.1.7 (MIT) and rebuilt for the Geek2API (sub2api) gateway: multi-endpoint failover, /v1/usage balances with wallet dedupe, per-key coverage from /v1/models, sub2api failure wording, a Claude runtime switch (HTTP or local CLI), and Claude/GPT web search backends. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
ed5154c042
94 files changed
+28617
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { Geek2APIKeyRing } from '../src/key-ring.js'
|
||||
import { createGeek2APIRpc } from '../src/rpc.js'
|
||||
import { createSearchController } from '../src/search-controller.js'
|
||||
import { createHostPool } from '../src/hosts.js'
|
||||
import { fakeCredentials, stubHostPool } from './helpers.mjs'
|
||||
import { Config } from '../src/index.js'
|
||||
|
||||
test('search settings declare volatile fields accepted by DSH 0.2', () => {
|
||||
for (const field of ['searchProvider', 'searchBackend', 'hiddenModels', 'apiHosts', 'claudeRuntime']) {
|
||||
assert.equal(Config.dict[field].meta.volatile, true, `${field}: DSH 0.2 otherwise rejects settings.update with no volatile fields`)
|
||||
}
|
||||
})
|
||||
|
||||
/** DSH 0.2 Connection's failure contract, after a JSON wire round trip. */
|
||||
function connectionFailure(result) {
|
||||
const wire = JSON.parse(JSON.stringify(result))
|
||||
assert.equal(wire.ok, false)
|
||||
assert.equal(typeof wire.error.code, 'string', 'DSH requires error.code; otherwise invalid server-response failure')
|
||||
assert.equal(typeof wire.error.message, 'string')
|
||||
assert.deepEqual(wire.error.details, {}, 'DSH requires error.details; diagnostics must carry no secrets')
|
||||
return wire.error
|
||||
}
|
||||
|
||||
test('a failed Auto search setting is a valid Connection failure, preserving its safe explanation', async () => {
|
||||
const search = createSearchController({
|
||||
ring: new Geek2APIKeyRing(fakeCredentials()),
|
||||
hosts: stubHostPool(createHostPool),
|
||||
readPreference: () => ({}),
|
||||
isWritable: () => true,
|
||||
writePreference: async () => { throw new Error('storage fixture refused the write') },
|
||||
})
|
||||
const rpc = createGeek2APIRpc({ search })
|
||||
const error = connectionFailure(await rpc('search/update', { searchProvider: 'auto' }))
|
||||
assert.equal(error.message, 'Geek2API could not save the web search preference')
|
||||
})
|
||||
|
||||
test('unknown endpoints and unavailable services also satisfy the Connection failure contract', async () => {
|
||||
const rpc = createGeek2APIRpc({})
|
||||
for (const endpoint of ['unknown', 'search/status', 'models/status', 'plugin/version', 'status']) {
|
||||
connectionFailure(await rpc(endpoint))
|
||||
}
|
||||
})
|
||||
|
||||
test('an unexpected storage failure never places upstream diagnostics in the envelope', async () => {
|
||||
const secret = 'sk-fixture-secret-not-a-real-key'
|
||||
const rpc = createGeek2APIRpc({ ring: { list: async () => { throw new Error(secret) } } })
|
||||
const result = await rpc('status')
|
||||
assert.equal(connectionFailure(result).message, 'Geek2API request failed')
|
||||
assert.equal(JSON.stringify(result).includes(secret), false)
|
||||
})
|
||||
Reference in new issue
Block a user