dsh-lcx-codex 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/cordis.patch.yml +18 -0
- package/lib/checkpoint-store-v3.js +459 -0
- package/lib/client.js +248 -0
- package/lib/compact-v2.js +305 -0
- package/lib/compact.js +653 -0
- package/lib/dsh-pi-responses.js +339 -0
- package/lib/index.js +1757 -0
- package/lib/private-file.js +18 -0
- package/lib/session-lease.js +70 -0
- package/lib/transport.js +396 -0
- package/lib/web-run-output.js +157 -0
- package/lib/web-search-alpha.js +451 -0
- package/lib/web-search-capability.js +78 -0
- package/lib/web-search-hosted.js +383 -0
- package/lib/web-search-ref-store.js +70 -0
- package/lib/web-search-store.js +181 -0
- package/package.json +99 -0
- package/scripts/probe-alpha.mjs +91 -0
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-lcx-codex",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "DSH web search and Responses native V2 compaction for Sub2API-proxied or NewAPI-relayed GPT models",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./lib/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./client": {
|
|
12
|
+
"default": "./lib/client.js"
|
|
13
|
+
},
|
|
14
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib/*.js",
|
|
19
|
+
"scripts/probe-alpha.mjs",
|
|
20
|
+
"cordis.patch.yml",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"README.md",
|
|
23
|
+
"CHANGELOG.md"
|
|
24
|
+
],
|
|
25
|
+
"dsh": {
|
|
26
|
+
"bundle": {
|
|
27
|
+
"patch": "./cordis.patch.yml"
|
|
28
|
+
},
|
|
29
|
+
"client": {
|
|
30
|
+
"platform": "web"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"dshhub": {
|
|
34
|
+
"schemaVersion": 1,
|
|
35
|
+
"displayName": "dsh-lcx-codex",
|
|
36
|
+
"summary": "Sub2API/NewAPI GPT web search, capability-gated Alpha, and Responses native V2 compact",
|
|
37
|
+
"surfaces": [
|
|
38
|
+
"host",
|
|
39
|
+
"web"
|
|
40
|
+
],
|
|
41
|
+
"capabilities": {
|
|
42
|
+
"provides": [
|
|
43
|
+
"hosted-web-search",
|
|
44
|
+
"capability-gated-alpha-search",
|
|
45
|
+
"native-responses-compaction"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"compatibility": {
|
|
49
|
+
"dsh": ">=0.1.0-rc.8",
|
|
50
|
+
"node": ">=20"
|
|
51
|
+
},
|
|
52
|
+
"permissions": {
|
|
53
|
+
"network": [
|
|
54
|
+
"https://api.lcxbot.com"
|
|
55
|
+
],
|
|
56
|
+
"credentials": [
|
|
57
|
+
"LCX_API_KEY"
|
|
58
|
+
],
|
|
59
|
+
"storage": [
|
|
60
|
+
"$DSH_HOME/storages/lcx-codex/checkpoints-v3.json",
|
|
61
|
+
"$DSH_HOME/storages/lcx-codex/web-alpha-capabilities.json",
|
|
62
|
+
"$DSH_HOME/storages/lcx-codex/web-alpha-refs.json"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@earendil-works/pi-ai": "0.82.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@deepseek-ai/dsh-settings": "0.1.0-rc.8",
|
|
71
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
75
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
|
|
78
|
+
"@deepseek-ai/dsh-compaction-basic": "^0.1.0-rc.8",
|
|
79
|
+
"@deepseek-ai/dsh-credentials": "^0.1.0-rc.8",
|
|
80
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.8",
|
|
81
|
+
"@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
|
|
82
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.8",
|
|
83
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
84
|
+
"react": "^18.2.0"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"test": "node --test tests/*.test.mjs",
|
|
88
|
+
"test:schema": "node scripts/validate-dsh-schema.mjs",
|
|
89
|
+
"test:e2e": "node --test tests/sub2api.e2e.test.mjs",
|
|
90
|
+
"probe:alpha": "node scripts/probe-alpha.mjs"
|
|
91
|
+
},
|
|
92
|
+
"engines": {
|
|
93
|
+
"node": ">=20"
|
|
94
|
+
},
|
|
95
|
+
"publishConfig": {
|
|
96
|
+
"access": "public"
|
|
97
|
+
},
|
|
98
|
+
"license": "MIT"
|
|
99
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { randomUUID } from 'node:crypto'
|
|
5
|
+
import {
|
|
6
|
+
ALPHA_SCHEMA_FINGERPRINT,
|
|
7
|
+
buildAlphaSearchBody,
|
|
8
|
+
normalizeAlphaSearchArgs,
|
|
9
|
+
parseAlphaSearchResponse,
|
|
10
|
+
probeAlphaCapabilities,
|
|
11
|
+
} from '../lib/web-search-alpha.js'
|
|
12
|
+
import { AlphaCapabilityStore, alphaCapabilityFingerprint } from '../lib/web-search-capability.js'
|
|
13
|
+
import { fetchJsonWithRetry } from '../lib/transport.js'
|
|
14
|
+
|
|
15
|
+
function required(name, value) {
|
|
16
|
+
const normalized = String(value ?? '').trim()
|
|
17
|
+
if (!normalized) throw new Error(`${name} is required`)
|
|
18
|
+
return normalized
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function apiKey() {
|
|
22
|
+
const file = String(process.env.LCX_API_KEY_FILE ?? '').trim()
|
|
23
|
+
if (file) return required('LCX_API_KEY_FILE content', readFileSync(file, 'utf8'))
|
|
24
|
+
return required('LCX_API_KEY or LCX_API_KEY_FILE', process.env.LCX_API_KEY)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const key = apiKey()
|
|
28
|
+
const baseURL = String(process.env.LCX_BASE_URL ?? 'https://api.lcxbot.com/v1').replace(/\/+$/u, '')
|
|
29
|
+
const model = required('LCX_MODEL', process.env.LCX_MODEL)
|
|
30
|
+
const provider = String(process.env.LCX_PROVIDER ?? 'lcx')
|
|
31
|
+
const profile = String(process.env.LCX_ALPHA_PROFILE ?? '')
|
|
32
|
+
const group = String(process.env.LCX_ALPHA_GROUP ?? '')
|
|
33
|
+
const sessionId = `dsh-lcx-codex-alpha-probe-${Date.now()}`
|
|
34
|
+
const timeoutMs = Number(process.env.LCX_E2E_TIMEOUT_MS ?? 120000)
|
|
35
|
+
const capabilityPath = String(process.env.LCX_ALPHA_CAPABILITY_PATH ?? join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), 'storages', 'lcx-codex', 'web-alpha-capabilities.json'))
|
|
36
|
+
const trustedNativeProvenance = process.env.LCX_ALPHA_TRUSTED_NATIVE === '1'
|
|
37
|
+
const clickProbeRef = String(process.env.LCX_ALPHA_CLICK_PROBE_REF ?? 'https://en.wikipedia.org/wiki/OpenAI').trim()
|
|
38
|
+
const screenshotProbeRef = String(process.env.LCX_ALPHA_SCREENSHOT_PROBE_REF ?? 'https://arxiv.org/pdf/1706.03762').trim()
|
|
39
|
+
|
|
40
|
+
const invoke = async (input) => {
|
|
41
|
+
const args = normalizeAlphaSearchArgs(input)
|
|
42
|
+
const requestId = randomUUID()
|
|
43
|
+
const response = await fetchJsonWithRetry(
|
|
44
|
+
`${baseURL}/alpha/search`,
|
|
45
|
+
buildAlphaSearchBody(args, model, sessionId, true),
|
|
46
|
+
{
|
|
47
|
+
authorization: `Bearer ${key}`,
|
|
48
|
+
'content-type': 'application/json',
|
|
49
|
+
'x-client-request-id': requestId,
|
|
50
|
+
'session-id': sessionId,
|
|
51
|
+
},
|
|
52
|
+
AbortSignal.timeout(timeoutMs),
|
|
53
|
+
timeoutMs,
|
|
54
|
+
{ maxAttempts: 1, maxResponseBytes: 4 * 1024 * 1024 },
|
|
55
|
+
)
|
|
56
|
+
return parseAlphaSearchResponse(response, { action: args.action, capability: 'unknown', requestId })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const actionProbes = process.env.LCX_ALPHA_PROBE_STRUCTURED === '1' ? {
|
|
60
|
+
image_query: { query: 'OpenAI logo' },
|
|
61
|
+
finance: { ticker: 'AAPL', assetType: 'equity', market: 'USA' },
|
|
62
|
+
weather: { location: 'United States, California, San Francisco', duration: 1 },
|
|
63
|
+
sports: { fn: 'schedule', league: 'nba', numberOfGames: 1 },
|
|
64
|
+
time: { utcOffset: '+00:00' },
|
|
65
|
+
} : {}
|
|
66
|
+
|
|
67
|
+
const record = await probeAlphaCapabilities({
|
|
68
|
+
invoke,
|
|
69
|
+
schemaFingerprint: ALPHA_SCHEMA_FINGERPRINT,
|
|
70
|
+
trustedNativeProvenance,
|
|
71
|
+
actionProbes,
|
|
72
|
+
clickProbeRef,
|
|
73
|
+
screenshotProbeRef,
|
|
74
|
+
})
|
|
75
|
+
const fingerprint = alphaCapabilityFingerprint({ baseURL, provider, model, profile, group, schemaFingerprint: ALPHA_SCHEMA_FINGERPRINT })
|
|
76
|
+
new AlphaCapabilityStore(capabilityPath).put(fingerprint, record)
|
|
77
|
+
|
|
78
|
+
const endpoint = new URL(baseURL)
|
|
79
|
+
process.stdout.write(`${JSON.stringify({
|
|
80
|
+
endpoint: endpoint.host,
|
|
81
|
+
provider,
|
|
82
|
+
model,
|
|
83
|
+
profile,
|
|
84
|
+
group,
|
|
85
|
+
fingerprint: fingerprint.slice(0, 12),
|
|
86
|
+
classification: record.classification,
|
|
87
|
+
provenance: record.provenance,
|
|
88
|
+
actions: record.actions,
|
|
89
|
+
probedAt: record.probedAt,
|
|
90
|
+
capabilityPath,
|
|
91
|
+
}, null, 2)}\n`)
|