dsh-lcx-codex 0.4.2 → 0.4.3-pre.13
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/README.md +75 -224
- package/THIRD_PARTY_NOTICES.md +64 -0
- package/cordis.patch.yml +3 -20
- package/lib/auxiliary-usage.js +63 -0
- package/lib/client.js +1398 -167
- package/lib/compact-v2.js +218 -199
- package/lib/dsh-compat.js +294 -100
- package/lib/dsh-responses.js +512 -277
- package/lib/grok-native-search.js +391 -0
- package/lib/index.js +1066 -758
- package/lib/invocation-policy-scope.js +261 -0
- package/lib/json-store.js +57 -31
- package/lib/native-checkpoint.js +520 -194
- package/lib/pi-responses-runtime.js +1571 -0
- package/lib/responses-request.js +109 -121
- package/lib/responses-stream.js +1280 -447
- package/lib/route.js +425 -369
- package/lib/search-accounting.js +86 -0
- package/lib/search-usage.js +86 -0
- package/lib/service-mutex.js +73 -64
- package/lib/token-budget.js +176 -108
- package/lib/transport.js +308 -68
- package/lib/types/client/index.d.ts +18 -0
- package/lib/types/client/search-media.d.ts +16 -0
- package/lib/types/index.d.ts +83 -0
- package/lib/web-run-output.js +189 -18
- package/lib/web-search-alpha.js +1067 -163
- package/lib/web-search-capability.js +80 -65
- package/lib/web-search-hosted.js +321 -33
- package/lib/web-search-ref-store.js +145 -60
- package/package.json +112 -32
- package/ARCHITECTURE.md +0 -117
- package/CHANGELOG.md +0 -224
- package/README_EN.md +0 -277
- package/assets/dsh-lcx-codex-banner.jpg +0 -0
- package/lib/legacy-v3.js +0 -20
- package/lib/responses-replay.js +0 -68
- package/scripts/probe-alpha.mjs +0 -43
- package/scripts/validate-dsh-schema.mjs +0 -31
package/CHANGELOG.md
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 0.4.2-pre.1 - candidate under runtime acceptance
|
|
4
|
-
|
|
5
|
-
### Architecture
|
|
6
|
-
|
|
7
|
-
- Make the LCX master switch the GPT Responses lifecycle ownership switch: when enabled, the first ordinary Agent turn, tools, Native V2 compaction, native replay and portable GPT-model migration share one LCX final-wire path.
|
|
8
|
-
- Upgrade only the plugin's direct Pi dependency to `0.84.3`; DSH 0.1.1-rc.2 and its host Pi 0.82.x remain isolated and unchanged.
|
|
9
|
-
- Reuse Pi 0.84 canonical Responses serializers and stream semantics for strict/grammar/custom tools, deferred `additional_tools` / `tool_search`, namespace, reasoning, IDs and cache behavior.
|
|
10
|
-
- Add one standard Responses request builder and shared LCX HTTP/SSE transport/parser bridge; remove the old portable recursive bypass back to the DSH adapter.
|
|
11
|
-
- Preserve checkpoint v5, DSH compaction transactions, Native-first pressure coordination, first-checkpoint Basic fallback, restart/resume and Search/#20 architecture.
|
|
12
|
-
- Normalize ordinary/replay failures into DSH terminal taxonomy and keep DSH as the visible retry owner.
|
|
13
|
-
|
|
14
|
-
### Validation state
|
|
15
|
-
|
|
16
|
-
- Engineering gates pass on the private work branch; exact commit-bound DSH + Sub2API runtime acceptance remains mandatory before integration, publication or a `VERIFIED` compatibility claim.
|
|
17
|
-
|
|
18
|
-
## 0.4.1 - 2026-08-25
|
|
19
|
-
|
|
20
|
-
### Stable promotion
|
|
21
|
-
|
|
22
|
-
- Promote the fully QA-passed `0.4.1-pre.1` runtime to stable `0.4.1` with **zero functional/runtime code changes**.
|
|
23
|
-
- Make Alpha stateful continuation/fail-closed fixes, DSH compatibility-seam isolation, typed protocol hardening, conservative token budgeting, and the installed Settings lifecycle fix part of the default stable line.
|
|
24
|
-
- Publish stable `0.4.1` to npm dist-tag `latest`; the prior `prelatest=0.4.1-pre.1` remains historical prerelease state.
|
|
25
|
-
|
|
26
|
-
### Validation basis
|
|
27
|
-
|
|
28
|
-
- `0.4.1-pre.1` passed Installed Candidate + Cross-feature QA before publication.
|
|
29
|
-
- Public promotion preserved runtime/source parity with the frozen prerelease candidate.
|
|
30
|
-
- Stable promotion requires package/version, typecheck, tests, schema, package/import boundary and zero-runtime-diff checks before publication.
|
|
31
|
-
|
|
32
|
-
## 0.4.1-pre.1 - 2026-08-25
|
|
33
|
-
|
|
34
|
-
### Released prerelease
|
|
35
|
-
|
|
36
|
-
- Published as `dsh-lcx-codex@0.4.1-pre.1` on npm dist-tag `prelatest`; stable `latest` remained `0.4.0` at prerelease publication time.
|
|
37
|
-
- Integrates the accepted Alpha stateful continuation and fail-closed capability work from #20, #21, and #22.
|
|
38
|
-
- Includes accepted compatibility seam isolation (#24), typed protocol-core hardening (#25), unified conservative token budgeting (#26), and the installed-plugin settings lifecycle fix (#36).
|
|
39
|
-
- Passed installed-candidate and cross-feature QA before publication, including ordinary/Advanced Hosted Search, Native compaction/replay, restart/resume, model continuation, fork isolation, and fail-closed Alpha behavior where unsupported.
|
|
40
|
-
- Public promotion preserved source/runtime parity with the frozen private candidate; package, schema, typecheck, import, install-chain, and publication gates passed.
|
|
41
|
-
- Post-release registry installation and Loader/client/settings-chain verification passed. The final provider-gated ordinary `web_search` recheck was not covered because the temporary authorized upstream credential returned HTTP 401; this was recorded as an external-auth verification gap rather than a package/source/runtime defect.
|
|
42
|
-
- Superseded as the recommended release by stable `0.4.1` after zero-functional-change promotion.
|
|
43
|
-
|
|
44
|
-
## 0.4.0 - 2026-08-23
|
|
45
|
-
|
|
46
|
-
### Stable promotion
|
|
47
|
-
|
|
48
|
-
- Promote the fully validated `0.4.0-rc.13` runtime to the stable `0.4.0` line with no functional/runtime code changes.
|
|
49
|
-
- Make the rc.13 Native V2 hardening, canonical Responses replay/serialization fixes, session isolation, cache continuity, and concurrency/lifecycle fixes the recommended stable release.
|
|
50
|
-
- Preserve `0.3.4` only as historical stable state; `0.4.0` becomes the default npm `latest` after publication.
|
|
51
|
-
|
|
52
|
-
### Validation
|
|
53
|
-
|
|
54
|
-
- Runtime-sensitive source is required to remain content-identical to the already live-tested rc.13 release.
|
|
55
|
-
- Full suite: 58/58 passed; DSH schema validation: 4/4 passed.
|
|
56
|
-
- Real rc.13 DSH acceptance already covers automatic Native pressure Compact, replay/cache re-warm, restart/resume, real GUI `/compact`, parent/child opaque isolation, and dual-session same-preset ServiceMutex failure cleanup.
|
|
57
|
-
- Stable promotion adds no new runtime behavior; publication is a version/documentation promotion only.
|
|
58
|
-
|
|
59
|
-
## 0.4.0-rc.13 - 2026-08-23
|
|
60
|
-
|
|
61
|
-
### Fixed
|
|
62
|
-
|
|
63
|
-
- Restrict opaque Native checkpoint replay to the exact source DSH session. Parent/child ancestry remains valid only for portable migration, so a fork never sends the parent session's opaque Native state.
|
|
64
|
-
- Reconcile Responses replay deltas and terminal output by stable item/call identity instead of `output_index` alone, preventing changed-index duplicate/empty text blocks and keeping terminal-only function calls balanced.
|
|
65
|
-
- Replace the simplified Native message/tool serializer with the public `@earendil-works/pi-ai@0.82.1` OpenAI Responses converters, preserving reasoning/message identities, tool linkage, constrained-tool semantics, deferred-tool transcript semantics, and DSH image boundaries.
|
|
66
|
-
- Match ordinary Pi `openai-responses` system-prompt placement: Native compact/replay now carries the developer/system prelude inside the canonical input prefix rather than introducing a separate top-level `instructions` prefix difference.
|
|
67
|
-
- Restore strict validation of DSH Pi replay-state envelopes before reusing native signatures; mismatched replay metadata degrades to a portable foreign-assistant projection instead of injecting stale provider-native identity.
|
|
68
|
-
- Treat Pi canonical role-only developer/user items as durable retained history and keep image persistence on `dsh_image_attachment` references rather than request image payloads.
|
|
69
|
-
- Use Pi/model or explicitly configured DSH Responses compatibility only; unknown custom routes no longer assume strict tools, grammar tools, or tool-search support.
|
|
70
|
-
- Mirror DSH/OpenAI Responses generation controls into Native compact/replay (`reasoning` + encrypted-reasoning include, temperature, and max output tokens), preventing the real Terra `xhigh` compact path from dropping the envelope used by ordinary Pi requests.
|
|
71
|
-
- Source automatic-compaction generation controls from the matching session request header rather than the Basic compaction summarizer request, so the selected conversation effort (for example Terra `xhigh`) reaches the Native provider request.
|
|
72
|
-
- Declare the DSH `sessions` service as an explicit Cordis runtime injection because checkpoint/replay and automatic-compaction generation parity read the live session/request header.
|
|
73
|
-
- Maintain a deterministic per-session request-header cache from DSH `session/event`; `compaction/start` synchronously refreshes it from the live Session before the Native request, avoiding reliance on async-context propagation for generation parity.
|
|
74
|
-
- Register that cross-session `session/event` observer with Cordis `{ global: true }`, matching DSH system-wide observers so Agent-carrier session events reach the standing plugin scope.
|
|
75
|
-
- Snapshot the exact `agentArg.session.requestHeader()` inside the Native-first pressure wrapper immediately before delegating to Basic compaction; this is the deterministic pressure-path source of generation controls, with the global session-event cache retained only as a secondary path.
|
|
76
|
-
- Seed the request-header cache from already-live sessions at plugin installation, seed newly announced resume/fork sessions, and evict disposed session entries so manual/non-pressure compaction remains restart-safe without retaining stale headers.
|
|
77
|
-
- Match the explicit Remote V2 tool-control contract used by current Codex and mature Responses compaction implementations: Native compact/replay send `tool_choice: "auto"` and `parallel_tool_calls: true` on the plain `openai-responses` route.
|
|
78
|
-
- Preserve only bounded provider machine diagnostics (`code`, `type`, `param`) from `response.failed`; the safe identifiers are included in the generic failure message/log so DSH compaction history can diagnose failures, while provider messages/bodies remain excluded.
|
|
79
|
-
- Persist Pi replay envelope v2 on successful Native replay finish so DSH retains response id/stop reason plus text/reasoning native metadata across post-compact turns.
|
|
80
|
-
- Preserve normal Pi OpenAI function-call identity as `call_id|item_id` for replay deltas and completed tool-call blocks, preventing loss of the provider `fc_*` item id on the next canonical request.
|
|
81
|
-
- Treat the session header `config` as the effective ordinary-request envelope even when DSH marks a value in `adapterDefaults`; those materialized defaults (for example Terra `xhigh` and `maxTokens`) are still sent by normal Pi and therefore must be mirrored by Native compact/replay.
|
|
82
|
-
|
|
83
|
-
### Validation
|
|
84
|
-
|
|
85
|
-
- `tests/rc13-regressions.test.mjs`: 15/15 passed.
|
|
86
|
-
- Full local suite: 58/58 passed; DSH schema validation: 4/4 passed; `git diff --check` passed.
|
|
87
|
-
- Installed DSH/NewAPI acceptance passed on Terra xhigh: automatic 90% Native V2 compact, continuous replay/cache re-warm, DSH Web restart/resume, real GUI `/compact` plus continuation, and parent→child fork portable isolation all completed without pre-Native stock prune or cross-session opaque replay.
|
|
88
|
-
- This remains a local release candidate only; no npm/GitHub publication or tag is implied.
|
|
89
|
-
|
|
90
|
-
## 0.4.0-rc.12 - 2026-08-22
|
|
91
|
-
|
|
92
|
-
### Fixed
|
|
93
|
-
|
|
94
|
-
- Serialize every `compactIfNeeded()` call per concrete preset compaction service so same-generation sessions cannot observe each other’s temporary Native-first pruner/config state; queued calls are abortable and plugin cleanup drains active owners before restoring the original method.
|
|
95
|
-
- Align Native `openai-responses` session affinity with the active Pi adapter: default OpenAI-format routes use `session_id` plus `x-client-request-id`, while OpenRouter-format routes use `x-session-id`; explicit affinity headers remain authoritative.
|
|
96
|
-
- Restrict Basic fallback to allowlisted retryable first-checkpoint failures and fail closed once a Native/legacy checkpoint already exists.
|
|
97
|
-
- Require a real `response.completed` terminal event with `status=completed` for Native compaction/replay and reject orphan `function_call_output` items.
|
|
98
|
-
- Set credential-bearing fetches to `redirect: error` and keep provider response bodies/messages out of surfaced/logged transport errors.
|
|
99
|
-
|
|
100
|
-
## 0.4.0-rc.11 - 2026-08-22
|
|
101
|
-
|
|
102
|
-
### Fixed
|
|
103
|
-
|
|
104
|
-
- Restore ERR-051 cache/session affinity semantics that regressed in the rc.8 refactor: Native V2 compaction and same-route replay now use the DSH/Pi conversation session id as the clamped `prompt_cache_key` instead of a route fingerprint, inherit the active provider `cacheRetention`, emit `prompt_cache_retention: 24h` only for supported `long` retention, and omit Native cache affinity when retention is `none`.
|
|
105
|
-
- Keep ordinary Hosted Search on its intentionally separate `dsh-lcx-search:<route hash>` namespace.
|
|
106
|
-
|
|
107
|
-
## 0.4.0-rc.10 - 2026-08-22
|
|
108
|
-
|
|
109
|
-
### Fixed
|
|
110
|
-
|
|
111
|
-
- Fix Native-first pressure coordination for DSH 0.1.1-rc.2 Agent presets by using the public `agentPresets.serviceFor(agent, name)` resolver for preset-local `compaction` and `toolResultPruner` instances. This replaces the rc.9 assumption that ordinary `agent.ctx` lookup could see entry-local isolated services.
|
|
112
|
-
|
|
113
|
-
## 0.4.0-rc.9 - 2026-08-22
|
|
114
|
-
|
|
115
|
-
### Fixed
|
|
116
|
-
|
|
117
|
-
- Restore the Alpha capability/ref-store interfaces consumed by `lib/index.js`; the rc.8 release package could pass its unit tests but fail immediately at module import with missing `AlphaCapabilityStore` / `AlphaRefStore` exports.
|
|
118
|
-
- Add package-entry import regression coverage so CI fails when the server entry point and internal module exports drift out of sync.
|
|
119
|
-
- Restore Native-first pressure coordination for isolated agent presets using DSH 0.1.1-rc.2's public `agentPresets.serviceFor(agent, name)` resolver. Preset-local `compaction` / `toolResultPruner` services are not visible through ordinary host or `agent.ctx` lookup; the plugin now addresses the actual per-Agent instances before applying the 90% Native / 95% emergency policy. A root service-lifecycle hook remains for non-preset deployments.
|
|
120
|
-
|
|
121
|
-
## 0.4.0-rc.8
|
|
122
|
-
|
|
123
|
-
- Rebase the plugin on DSH `0.1.1-rc.2`; older DSH releases are no longer a supported runtime target.
|
|
124
|
-
- Native V2 compaction image replay now uses DSH `attachments.readImageRequest()` with the active `llm-pi-ai` route's request-image pixel/byte policy instead of reading normalized master bytes directly.
|
|
125
|
-
- Native image requests use DSH's deterministic `offloadRequestImagesWithPolicy()` projection before serialization, matching the current request-size behavior for long image-heavy sessions.
|
|
126
|
-
- Keep rc.7 active-Agent Hosted Search routing, isolated search cache namespace, 240s search timeout, rc.5 conversation-fidelity checkpointing, and rc.6 90% Native-first / 95% emergency pressure policy unchanged.
|
|
127
|
-
- CI installs against current declared DSH packages instead of enforcing the stale rc.8 lockfile.
|
|
128
|
-
|
|
129
|
-
## 0.4.0-rc.7 - 2026-08-22
|
|
130
|
-
|
|
131
|
-
### Fixed
|
|
132
|
-
|
|
133
|
-
- Ordinary DSH `web_search` now follows the active Agent `provider/model` instead of always using the plugin fallback GPT model. A Luna conversation now searches with Luna; a Sol conversation now searches with Sol.
|
|
134
|
-
- Added an AsyncLocalStorage route bridge at the DSH `tools/execute` boundary so the provider-only `ctx.web.search()` seam can receive Agent route context without changing the model-visible `web_search` schema.
|
|
135
|
-
- Hosted Search now uses a separate stable `dsh-lcx-search:<route hash>` `prompt_cache_key`, avoiding intentional cache-key sharing with Native conversation replay.
|
|
136
|
-
- The settings UI now labels the configured Responses endpoint/model as **fallback** values, matching their actual rc.7 role.
|
|
137
|
-
|
|
138
|
-
### Kept from rc.6
|
|
139
|
-
|
|
140
|
-
- 240-second default DSH `web_search` deadline.
|
|
141
|
-
- Native-first automatic pressure policy: 90% Native V2, 95% emergency DSH prune.
|
|
142
|
-
- rc.5 conversation-fidelity checkpoints and restart-safe DSH session-log persistence.
|
|
143
|
-
|
|
144
|
-
### Docs / release
|
|
145
|
-
|
|
146
|
-
- Reworked the README around the current architecture and real cache observations.
|
|
147
|
-
- Added a blue/white DSH-LCX-CODEX hero banner for GitHub/npm.
|
|
148
|
-
- GitHub trusted publishing is wired through `.github/workflows/publish.yml`: pre-release tags publish to npm dist-tag `next`; stable tags publish to `latest`.
|
|
149
|
-
|
|
150
|
-
## 0.4.0-rc.6
|
|
151
|
-
|
|
152
|
-
- Added Native-first automatic pressure coordination for GPT Responses sessions: below the configured Native threshold the plugin suppresses DSH's stock 80% pressure compaction/prune path; at the default 90% threshold it lets compaction proceed while temporarily suppressing tool-result pruning so Native V2 runs first.
|
|
153
|
-
- Added a separate emergency prune threshold (default 95%). At or above this zone, DSH's replay-safe tool-result pruner is allowed to run before compaction as overflow protection.
|
|
154
|
-
- Added adjustable `web_search` tool deadline, default 240 seconds (30–600s). This mutates only DSH's non-model-visible `ToolDefinition.timeoutMs`, so the model tool schema and prompt-cache prefix do not change.
|
|
155
|
-
- Added Settings UI controls for automatic compaction, Native threshold, emergency prune threshold, and web search timeout.
|
|
156
|
-
- Kept the rc.5 checkpoint/fidelity format unchanged (`lcx-native-compaction-v5`); rc.6 is a pressure/timeout coordination release, not another checkpoint migration.
|
|
157
|
-
|
|
158
|
-
## 0.4.0-rc.5
|
|
159
|
-
|
|
160
|
-
- Adds a bounded conversation-fidelity layer after real DSH testing showed assistant-only facts could be lost by opaque Native V2 compaction.
|
|
161
|
-
- New `lcx-native-compaction-v5` checkpoints retain selected user/developer/system messages plus user-visible assistant final answers before the opaque compaction item.
|
|
162
|
-
- Keeps explicit retained history within an estimated 64k-token ceiling; defaults reserve at most 24k for assistant answers and cap one retained assistant answer at about 3k tokens.
|
|
163
|
-
- Does not copy reasoning, tool calls/results, raw search payloads, or telemetry into the fidelity prefix.
|
|
164
|
-
- Repairs rc.3/rc.4 v4 checkpoints from append-only `shadowedSeqs`, including assistant-visible answers when the original DSH events still exist.
|
|
165
|
-
- Stores only the single opaque compaction output item, ignoring unrelated terminal output items from nonstandard proxies.
|
|
166
|
-
- Route compatibility now accepts both native checkpoint versions 4 and 5.
|
|
167
|
-
- Adds regression coverage for the exact assistant-only anchor failure (`Cobalt-Sparrow-604` / `81736`) and the 64k retention ceiling.
|
|
168
|
-
|
|
169
|
-
## 0.4.0-rc.4
|
|
170
|
-
|
|
171
|
-
- Fixes a Native V2 replay fidelity bug found by real DSH session-log testing.
|
|
172
|
-
- Native checkpoints now persist the retained client-authored Responses messages before the opaque `compaction` item, matching current OpenAI Codex remote-compaction V2 replacement-history semantics.
|
|
173
|
-
- Existing rc.3 opaque-only v4 checkpoints are repaired on replay by reconstructing the missing shadowed user history from the DSH append-only session log.
|
|
174
|
-
- Adds replay/retention regression coverage and an explicit Native success diagnostic.
|
|
175
|
-
- Keeps the rc.3 search-provider, remote-first fallback, and session-log-native checkpoint architecture unchanged.
|
|
176
|
-
|
|
177
|
-
## 0.4.0-rc.3
|
|
178
|
-
|
|
179
|
-
- Fix Cordis external-package loading: all `ctx.web`/`ctx.llm` service access now occurs inside an explicit `ctx.inject(['llm', 'web'], ...)` scope.
|
|
180
|
-
- This fixes `cannot get property "web" without inject` when DSH loads the plugin from a profile-installed `.tgz`.
|
|
181
|
-
- No protocol or checkpoint-format changes from rc.2.
|
|
182
|
-
|
|
183
|
-
## 0.4.0-rc.2 - 2026-08-21
|
|
184
|
-
|
|
185
|
-
- Packaging-only fix over rc.1: remove unnecessary `@deepseek-ai/dsh-compaction-basic` and `@deepseek-ai/dsh-web` peer declarations.
|
|
186
|
-
- The plugin consumes DSH runtime services through injected `ctx.*` seams and does not import or mount either package directly.
|
|
187
|
-
- Avoids misleading pnpm "missing peer" warnings and, importantly, avoids encouraging users to install a second compaction backend.
|
|
188
|
-
|
|
189
|
-
## 0.4.0-rc.1 - 2026-08-21
|
|
190
|
-
|
|
191
|
-
### Architecture
|
|
192
|
-
|
|
193
|
-
- Keep DSH `compaction-basic` as the sole compaction service owner; use only its documented/interceptable `purpose=compaction` `llm/stream` summarizer seam.
|
|
194
|
-
- Replace parallel local+remote compaction with remote-first fallback.
|
|
195
|
-
- Persist new Native V2 opaque state in DSH `compaction/summary.rawOutput` using `lcx-native-compaction-v4`; the model-visible replacement stays short.
|
|
196
|
-
- Remove new-checkpoint writes to the v3 JSON sidecar. The v3 sidecar is now read-only compatibility for old sessions.
|
|
197
|
-
- Reconstruct portable history for route migration from DSH append-only `shadowedSeqs` instead of duplicating every checkpoint's portable history.
|
|
198
|
-
- Preserve same-route fork replay through DSH session ancestry.
|
|
199
|
-
- Centralize the remaining direct Responses-native transport in `compact-v2.js` and `responses-replay.js`.
|
|
200
|
-
|
|
201
|
-
### Search
|
|
202
|
-
|
|
203
|
-
- Make `ctx.web` / DSH `web_search` the ordinary Hosted Search entry point.
|
|
204
|
-
- Remove the ambiguous ordinary `websearch_gpt` tool.
|
|
205
|
-
- Add opt-in `websearch_gpt_advanced` for Hosted-only controls that DSH `WebSearchRequest` cannot express.
|
|
206
|
-
- Keep `websearch_alpha` independent and capability-gated.
|
|
207
|
-
- Isolate the DSH rc.8 runtime SearchProvider-selection compatibility shim.
|
|
208
|
-
|
|
209
|
-
### Reliability
|
|
210
|
-
|
|
211
|
-
- Rehydrate DSH image attachment references when replaying legacy v3 checkpoints.
|
|
212
|
-
- Resolve startup settings into runtime route config immediately instead of waiting for the first settings change.
|
|
213
|
-
- Do not assume `events[seq]` is always the event whose `event.seq === seq`; use a safe fallback lookup.
|
|
214
|
-
- Add protocol, session persistence, migration and architecture regression tests.
|
|
215
|
-
|
|
216
|
-
### Compatibility
|
|
217
|
-
|
|
218
|
-
- Node.js >= 20.
|
|
219
|
-
- Target DSH `0.1.1-rc.2` only.
|
|
220
|
-
- Existing 0.3.x v3 marker sessions remain best-effort readable through the old sidecar.
|
|
221
|
-
|
|
222
|
-
## 0.3.1
|
|
223
|
-
|
|
224
|
-
- Previous Hosted/Alpha Search and Native V2 checkpoint-v3 implementation.
|
package/README_EN.md
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
# dsh-lcx-codex
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/dsh-lcx-codex)
|
|
4
|
-
[](https://github.com/kk3ya03-star/dsh-lcx-codex/actions/workflows/publish.yml)
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-

|
|
9
|
-
|
|
10
|
-
[简体中文](README.md) · **English** · [Architecture](ARCHITECTURE.md) · [Changelog](CHANGELOG.md) · [Releases](https://github.com/kk3ya03-star/dsh-lcx-codex/releases)
|
|
11
|
-
|
|
12
|
-
> **Keep a DSH GPT Responses conversation on one final Responses wire owner from the first ordinary turn through tools, Native V2 Compact / Replay, restart recovery, and GPT model switching.**
|
|
13
|
-
|
|
14
|
-
`dsh-lcx-codex` does not replace DSH. DSH still owns the Agent, Session, model selection, tool execution, attachments, and compaction policy. When **LCX is ON**, LCX owns the final request / SSE wire for the selected GPT Responses conversation.
|
|
15
|
-
|
|
16
|
-
## Current stable release
|
|
17
|
-
|
|
18
|
-
**`0.4.2`** is the current stable release and a **zero-functional-change stable promotion** of the fully validated `0.4.2-pre.1` runtime.
|
|
19
|
-
|
|
20
|
-
```powershell
|
|
21
|
-
dsh plugin --profile web add dsh-lcx-codex
|
|
22
|
-
dsh web
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
- npm dist-tag: `latest`
|
|
26
|
-
- DSH: `0.1.1-rc.2`
|
|
27
|
-
- Plugin Pi: `0.84.3`
|
|
28
|
-
- Node.js: `^22.19.0 || >=24.0.0`
|
|
29
|
-
|
|
30
|
-
`0.4.2-pre.1` remains a historical prerelease; new users should install `latest`.
|
|
31
|
-
|
|
32
|
-
## Product contract
|
|
33
|
-
|
|
34
|
-
```text
|
|
35
|
-
LCX OFF
|
|
36
|
-
= use the native DSH LLM path
|
|
37
|
-
|
|
38
|
-
LCX ON
|
|
39
|
-
= LCX owns the final Responses request / SSE wire
|
|
40
|
-
for the selected GPT Responses conversation starting at ordinary turn 1
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Turn LCX off before switching to Claude, Gemini, DeepSeek, or another non-GPT model. Model switching itself does not require a DSH restart.
|
|
44
|
-
|
|
45
|
-
## Why LCX exists
|
|
46
|
-
|
|
47
|
-
DSH already owns the Agent, Session, tools, and compaction lifecycle. LCX addresses the final provider-native GPT Responses layer: ordinary requests, tools, Native Compact, Replay, restart/resume, and GPT route migration no longer switch final wire owners inside one conversation.
|
|
48
|
-
|
|
49
|
-
```text
|
|
50
|
-
DSH
|
|
51
|
-
Agent / Session / Tools
|
|
52
|
-
│
|
|
53
|
-
llm / stream seam
|
|
54
|
-
│
|
|
55
|
-
┌──────────┴──────────┐
|
|
56
|
-
│ │
|
|
57
|
-
LCX OFF LCX ON
|
|
58
|
-
│ │
|
|
59
|
-
native DSH adapter LCX Responses Core
|
|
60
|
-
│
|
|
61
|
-
ordinary turn 1
|
|
62
|
-
↓
|
|
63
|
-
tools
|
|
64
|
-
↓
|
|
65
|
-
Native V2 Compact
|
|
66
|
-
↓
|
|
67
|
-
Replay
|
|
68
|
-
↓
|
|
69
|
-
Restart / Resume
|
|
70
|
-
↓
|
|
71
|
-
GPT Model Migration
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Compact therefore changes history representation without also changing request ownership.
|
|
75
|
-
|
|
76
|
-
## Core capabilities
|
|
77
|
-
|
|
78
|
-
### 1. Full GPT Responses lifecycle ownership
|
|
79
|
-
|
|
80
|
-
With LCX ON, ordinary requests, tool continuations, Native Compact, Native Replay, restart/resume, and portable GPT migration use one LCX Responses request-builder / transport owner.
|
|
81
|
-
|
|
82
|
-
DSH remains the canonical session/history owner. LCX does not create a second conversation database or replace the DSH Tool Executor.
|
|
83
|
-
|
|
84
|
-
### 2. GPT-5.6 Prompt Cache
|
|
85
|
-
|
|
86
|
-
`0.4.2` uses the current GPT-5.6 cache-options path and maintains stable cache identity inside a session:
|
|
87
|
-
|
|
88
|
-
- implicit caching by default;
|
|
89
|
-
- the supported route sends `prompt_cache_options.ttl = 30m`;
|
|
90
|
-
- ordinary consecutive turns and tool-heavy workloads can reuse warm prefixes;
|
|
91
|
-
- Native Compact intentionally creates a new history/cache epoch, so the old uncompressed prefix is not promised to remain reusable;
|
|
92
|
-
- real long-session validation repeatedly observed near-complete prefix reuse while request topology remained stable.
|
|
93
|
-
|
|
94
|
-
Cache reuse depends on provider behavior, model, request prefix, tool schemas, and session state; it is not a fixed performance guarantee.
|
|
95
|
-
|
|
96
|
-
One confirmed boundary: activating a skill at runtime can change the top-level tool schema and cause a one-time cache reset. The new topology warms again on the next request. The currently supported route rejects content-level `prompt_cache_breakpoint`, and DSH `0.1.1-rc.2` does not expose authoritative dynamic-tool provenance, so `0.4.2` preserves the safe one-time reset instead of guessing tool history.
|
|
97
|
-
|
|
98
|
-
### 3. Native V2 Compact + Replay
|
|
99
|
-
|
|
100
|
-
DSH still decides **when to compact, what range to compact, transaction boundaries, and recovery**. LCX owns only the provider-native Responses V2 wire.
|
|
101
|
-
|
|
102
|
-
Default pressure coordination:
|
|
103
|
-
|
|
104
|
-
```text
|
|
105
|
-
0% ─────────────────── 90% ───── 95% ───── 100%
|
|
106
|
-
normal Native emergency hard cap
|
|
107
|
-
V2 DSH prune
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
- `90%`: prefer Native V2;
|
|
111
|
-
- `95%`: allow emergency DSH tool-result pruning;
|
|
112
|
-
- provider-confirmed overflow stays with DSH recovery;
|
|
113
|
-
- manual `/compact` keeps the native DSH compaction transaction.
|
|
114
|
-
|
|
115
|
-
Native checkpoint v5 persists provider-native compaction state plus the portable retained history needed for fidelity. Compatible same-session routes can use Native replay; incompatible routes never reuse unsafe opaque state.
|
|
116
|
-
|
|
117
|
-
### 4. Restart / Resume + hot GPT switching
|
|
118
|
-
|
|
119
|
-
A single DSH session can continue through:
|
|
120
|
-
|
|
121
|
-
```text
|
|
122
|
-
Terra
|
|
123
|
-
→ Compact
|
|
124
|
-
→ Replay
|
|
125
|
-
→ Restart DSH
|
|
126
|
-
→ Resume same session
|
|
127
|
-
→ Switch to Sol
|
|
128
|
-
→ Continue
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Compatible route/model resumes may restore Native opaque state. An incompatible GPT model / route drops unsafe opaque state and reconstructs portable history while remaining on LCX Responses transport.
|
|
132
|
-
|
|
133
|
-
### 5. Hosted Search + stateful Web Actions
|
|
134
|
-
|
|
135
|
-
Ordinary web search still uses DSH's native `web_search`. LCX can map its SearchProvider to the active GPT Hosted Search route instead of exposing a second ordinary-search tool.
|
|
136
|
-
|
|
137
|
-
| Need | Entry |
|
|
138
|
-
|---|---|
|
|
139
|
-
| Ordinary web search | DSH `web_search` |
|
|
140
|
-
| Advanced Hosted Search controls | `websearch_gpt_advanced` |
|
|
141
|
-
| Stateful page / PDF actions | `websearch_alpha` |
|
|
142
|
-
|
|
143
|
-
Alpha supports:
|
|
144
|
-
|
|
145
|
-
```text
|
|
146
|
-
search → open → find / click → screenshot
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Alpha is off by default and is registered only after the current endpoint / provider / model / schema passes a capability probe. Unknown deployments fail closed.
|
|
150
|
-
|
|
151
|
-
### 6. Isolated Pi 0.84.3 upgrade
|
|
152
|
-
|
|
153
|
-
The plugin uses `@earendil-works/pi-ai 0.84.3` without overriding the DSH host dependency:
|
|
154
|
-
|
|
155
|
-
```text
|
|
156
|
-
DSH 0.1.1-rc.2
|
|
157
|
-
└─ host Pi 0.82.1 ← unchanged
|
|
158
|
-
|
|
159
|
-
dsh-lcx-codex 0.4.2
|
|
160
|
-
└─ plugin Pi 0.84.3 ← isolated plugin dependency
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Pi owns canonical Responses message/tool serialization, reasoning, IDs, strict/grammar/custom tools, `additional_tools`, `tool_search`, namespace, and stream semantics. LCX does not maintain a second generic provider framework.
|
|
164
|
-
|
|
165
|
-
## Configure in 30 seconds
|
|
166
|
-
|
|
167
|
-
### Requirements
|
|
168
|
-
|
|
169
|
-
- Node.js `^22.19.0 || >=24.0.0`
|
|
170
|
-
- DSH `0.1.1-rc.2`
|
|
171
|
-
- a working GPT Responses route in DSH
|
|
172
|
-
- actual upstream support for the Hosted Search / Native V2 / Alpha capabilities you enable
|
|
173
|
-
|
|
174
|
-
### Suggested first-run settings
|
|
175
|
-
|
|
176
|
-
| Setting | Suggested | Notes |
|
|
177
|
-
|---|---:|---|
|
|
178
|
-
| Enable LCX | **On** | Own the current GPT Responses conversation |
|
|
179
|
-
| Use GPT Hosted Search | As needed | Use GPT Hosted Search behind DSH `web_search` |
|
|
180
|
-
| Advanced Hosted Search | Off | Enable only for advanced Hosted parameters |
|
|
181
|
-
| Alpha Search | Off | Enable after capability validation |
|
|
182
|
-
| Native-first auto compaction | On | Use Native-first pressure coordination |
|
|
183
|
-
| Native threshold | `90%` | Proactive Native V2 threshold |
|
|
184
|
-
| Emergency DSH prune | `95%` | Emergency prune threshold |
|
|
185
|
-
| Fallback to Basic Compaction | On | Allow bounded fallback after Native failure |
|
|
186
|
-
| `web_search` timeout | `240s` | Avoid premature timeout on slower Hosted Search |
|
|
187
|
-
|
|
188
|
-
### Verify observable behavior
|
|
189
|
-
|
|
190
|
-
| Capability | Expected behavior |
|
|
191
|
-
|---|---|
|
|
192
|
-
| LCX ownership | With LCX ON, the first GPT ordinary request already uses the LCX Responses path |
|
|
193
|
-
| Prompt Cache | Stable warm turns may report provider `cached_tokens` |
|
|
194
|
-
| Hosted Search | Ordinary entry remains DSH `web_search` |
|
|
195
|
-
| Advanced Hosted | `websearch_gpt_advanced` appears when enabled |
|
|
196
|
-
| Alpha | `websearch_alpha` appears only after capability validation |
|
|
197
|
-
| Native V2 | Compact produces provider-native checkpoint behavior rather than relabeling Basic Compaction |
|
|
198
|
-
| Replay | The same DSH session continues after Compact and remains resumable after restart |
|
|
199
|
-
|
|
200
|
-
## DSH / LCX responsibility boundary
|
|
201
|
-
|
|
202
|
-
| Component | Owns |
|
|
203
|
-
|---|---|
|
|
204
|
-
| **DSH** | Agent loop, Session/history, GenerateOptions, model/credential selection, tool execution, AttachmentStore, pressure policy, compaction transaction |
|
|
205
|
-
| **DSH compatibility seam** | Projects DSH messages / GenerateOptions into Pi Context and bridges results back to DSH |
|
|
206
|
-
| **Plugin Pi 0.84.3** | Canonical Responses serialization / parser semantics |
|
|
207
|
-
| **LCX** | ON/OFF ownership, final Responses body + HTTP/SSE wire, ordinary/compact/replay orchestration, Native opaque state, Search capabilities |
|
|
208
|
-
|
|
209
|
-
See [ARCHITECTURE.md](ARCHITECTURE.md) for checkpoint, portable replay, cache identity, RefStore, pressure coordination, and protocol details.
|
|
210
|
-
|
|
211
|
-
## Compatibility
|
|
212
|
-
|
|
213
|
-
| Plugin | DSH | DSH host Pi | Plugin Pi | Status |
|
|
214
|
-
|---|---|---|---|---|
|
|
215
|
-
| `0.4.2` | `0.1.1-rc.2` | `0.82.1` | `0.84.3` | **VERIFIED STABLE** |
|
|
216
|
-
| `0.4.1` | `0.1.1-rc.2` | `0.82.1` | `0.82.1` | historical stable |
|
|
217
|
-
|
|
218
|
-
DSH `0.1.2-alpha.1` and newer Pi versions are not part of the formal `0.4.2` compatibility claim. They will be validated by affected seam rather than assumed compatible automatically.
|
|
219
|
-
|
|
220
|
-
## Current boundaries
|
|
221
|
-
|
|
222
|
-
- The supported route uses implicit Prompt Cache. Content-level explicit breakpoints are rejected on that route and are not exposed as a product setting.
|
|
223
|
-
- Dynamic skills/plugins that change the top-level tool schema can trigger a one-time prompt-cache reset; functionality remains correct and the new topology warms again.
|
|
224
|
-
- `reasoning.context` / `reasoning.mode` remain host/Pi exposure boundaries; LCX does not invent a second control surface.
|
|
225
|
-
- The normal operational context profile remains in the ~`262K` class; 1.05M long context is not enabled by default.
|
|
226
|
-
- Credentialed `ALPHA-004` runtime coverage remains `NOT_COVERED`, while fail-closed behavior is covered by tests.
|
|
227
|
-
- Programmatic Tool Calling is not currently advertised as supported.
|
|
228
|
-
|
|
229
|
-
## FAQ
|
|
230
|
-
|
|
231
|
-
<details>
|
|
232
|
-
<summary><strong>Why do I need to turn LCX off before switching to a non-GPT model?</strong></summary>
|
|
233
|
-
|
|
234
|
-
LCX ON is a GPT Responses lifecycle ownership switch, not a universal multi-model proxy. Non-GPT models continue through native DSH adapters.
|
|
235
|
-
|
|
236
|
-
</details>
|
|
237
|
-
|
|
238
|
-
<details>
|
|
239
|
-
<summary><strong>Why is web_search still the same tool?</strong></summary>
|
|
240
|
-
|
|
241
|
-
By design. LCX changes the SearchProvider behind DSH `web_search` instead of exposing two ordinary search tools to the model.
|
|
242
|
-
|
|
243
|
-
</details>
|
|
244
|
-
|
|
245
|
-
<details>
|
|
246
|
-
<summary><strong>Why is Alpha sometimes missing?</strong></summary>
|
|
247
|
-
|
|
248
|
-
That is fail-closed behavior. `websearch_alpha` is not registered until the active route/schema passes capability probing.
|
|
249
|
-
|
|
250
|
-
</details>
|
|
251
|
-
|
|
252
|
-
<details>
|
|
253
|
-
<summary><strong>Why can a skill load cause the cache to warm again?</strong></summary>
|
|
254
|
-
|
|
255
|
-
Some skills dynamically register new top-level tools. Tool schemas are part of the cacheable prompt prefix, so a topology change can establish a new cache epoch. `0.4.2` prioritizes correct tool definitions instead of guessing provenance to force reuse of an old cache.
|
|
256
|
-
|
|
257
|
-
</details>
|
|
258
|
-
|
|
259
|
-
## Development and verification
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
npm run typecheck
|
|
263
|
-
npm test
|
|
264
|
-
npm run test:schema
|
|
265
|
-
npm pack --ignore-scripts
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
- Architecture: [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
269
|
-
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
270
|
-
- GitHub Releases: [Releases](https://github.com/kk3ya03-star/dsh-lcx-codex/releases)
|
|
271
|
-
- npm: [`dsh-lcx-codex`](https://www.npmjs.com/package/dsh-lcx-codex)
|
|
272
|
-
|
|
273
|
-
## License
|
|
274
|
-
|
|
275
|
-
MIT
|
|
276
|
-
|
|
277
|
-
> `LCX` is only the project name. This is a community project and is not affiliated with OpenAI, DeepSeek, Sub2API, or NewAPI.
|
|
Binary file
|
package/lib/legacy-v3.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs'
|
|
2
|
-
import { baseURLFingerprint, sessionAncestry } from './route.js'
|
|
3
|
-
|
|
4
|
-
const PATTERN = /\[dsh-lcx-codex-v3-checkpoint:([0-9a-f-]{36})\]/iu
|
|
5
|
-
function textOf(message) { return (message?.content ?? []).filter((b) => b?.type === 'text').map((b) => b.text).join('') }
|
|
6
|
-
export function legacyV3Id(message) { return textOf(message).match(PATTERN)?.[1]?.toLowerCase() }
|
|
7
|
-
export function loadLegacyRecord(file, id) {
|
|
8
|
-
if (!file || !id) return undefined
|
|
9
|
-
try {
|
|
10
|
-
const parsed = JSON.parse(readFileSync(file, 'utf8'))
|
|
11
|
-
const record = parsed?.version === 3 ? parsed.checkpoints?.[id] : undefined
|
|
12
|
-
if (!record || record.version !== 3 || !Array.isArray(record.nativeOutput)) return undefined
|
|
13
|
-
return structuredClone(record)
|
|
14
|
-
} catch { return undefined }
|
|
15
|
-
}
|
|
16
|
-
export function legacyRouteCompatible(record, route, ctx) {
|
|
17
|
-
if (!record || record.provider !== route.provider || record.model !== route.model) return false
|
|
18
|
-
if (record.baseURLFingerprint !== baseURLFingerprint(route.baseURL)) return false
|
|
19
|
-
return sessionAncestry(ctx, route.sessionId).includes(record.sourceSessionId ?? record.lineageId)
|
|
20
|
-
}
|
package/lib/responses-replay.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { mergeFeatureHeader } from './compact-v2.js'
|
|
2
|
-
import { resolvePiResponsesModel } from './dsh-responses.js'
|
|
3
|
-
import { buildResponsesBody } from './responses-request.js'
|
|
4
|
-
import { streamResponsesRequest } from './responses-stream.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Backward-compatible body helper retained for protocol tests and downstream imports.
|
|
8
|
-
* Production managed replay already carries the DSH system prompt in canonical input;
|
|
9
|
-
* `system` remains only as a low-level compatibility field.
|
|
10
|
-
*/
|
|
11
|
-
export function replayBody({ model, modelDescriptor, input, system, tools, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens }) {
|
|
12
|
-
const descriptor = modelDescriptor ?? resolvePiResponsesModel({
|
|
13
|
-
route: { provider: 'lcx', model, baseURL: '' },
|
|
14
|
-
model: { id: model, provider: 'lcx', baseUrl: '', api: 'openai-responses', reasoning: true, input: ['text'] },
|
|
15
|
-
})
|
|
16
|
-
const body = buildResponsesBody({
|
|
17
|
-
model: descriptor,
|
|
18
|
-
input,
|
|
19
|
-
instructions: system,
|
|
20
|
-
tools,
|
|
21
|
-
promptCacheKey,
|
|
22
|
-
promptCacheRetention,
|
|
23
|
-
cacheRetention: cacheRetention ?? (promptCacheKey ? (promptCacheRetention ? 'long' : 'short') : 'none'),
|
|
24
|
-
reasoningEffort,
|
|
25
|
-
temperature,
|
|
26
|
-
maxTokens,
|
|
27
|
-
})
|
|
28
|
-
// Opaque Native replay stays on the Remote V2 wire contract while sharing the standard builder.
|
|
29
|
-
body.tool_choice = 'auto'
|
|
30
|
-
body.parallel_tool_calls = true
|
|
31
|
-
return body
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Compatibility wrapper: Native replay now uses the same builder/transport/parser as ordinary turns.
|
|
36
|
-
*/
|
|
37
|
-
export async function* requestNativeReplay({ baseURL, provider, model, modelDescriptor, input, system, tools, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, grammarToolInputProperties, headers, signal, timeoutMs, maxAttempts = 1, maxResponseBytes }) {
|
|
38
|
-
const descriptor = modelDescriptor ?? resolvePiResponsesModel({
|
|
39
|
-
route: { provider, model, baseURL },
|
|
40
|
-
model: { id: model, provider, baseUrl: baseURL, api: 'openai-responses', reasoning: true, input: ['text'] },
|
|
41
|
-
})
|
|
42
|
-
const body = replayBody({
|
|
43
|
-
model,
|
|
44
|
-
modelDescriptor: descriptor,
|
|
45
|
-
input,
|
|
46
|
-
system,
|
|
47
|
-
tools,
|
|
48
|
-
promptCacheKey,
|
|
49
|
-
promptCacheRetention,
|
|
50
|
-
cacheRetention,
|
|
51
|
-
reasoningEffort,
|
|
52
|
-
temperature,
|
|
53
|
-
maxTokens,
|
|
54
|
-
})
|
|
55
|
-
yield* streamResponsesRequest({
|
|
56
|
-
baseURL,
|
|
57
|
-
provider,
|
|
58
|
-
model,
|
|
59
|
-
piModel: descriptor,
|
|
60
|
-
body,
|
|
61
|
-
grammarToolInputProperties,
|
|
62
|
-
headers: mergeFeatureHeader(headers),
|
|
63
|
-
signal,
|
|
64
|
-
timeoutMs,
|
|
65
|
-
maxAttempts,
|
|
66
|
-
maxResponseBytes,
|
|
67
|
-
})
|
|
68
|
-
}
|
package/scripts/probe-alpha.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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 { ALPHA_SCHEMA_FINGERPRINT, buildAlphaSearchBody, normalizeAlphaSearchArgs, parseAlphaSearchResponse, probeAlphaCapabilities } from '../lib/web-search-alpha.js'
|
|
6
|
-
import { AlphaCapabilityStore, alphaCapabilityFingerprint } from '../lib/web-search-capability.js'
|
|
7
|
-
|
|
8
|
-
const baseURL = String(process.env.LCX_BASE_URL ?? 'https://api.lcxbot.com/v1').replace(/\/+$/u, '')
|
|
9
|
-
const model = String(process.env.LCX_MODEL ?? '').trim()
|
|
10
|
-
const provider = String(process.env.LCX_PROVIDER ?? 'lcx').trim()
|
|
11
|
-
const profile = String(process.env.LCX_ALPHA_PROFILE ?? '')
|
|
12
|
-
const group = String(process.env.LCX_ALPHA_GROUP ?? '')
|
|
13
|
-
const keyFile = String(process.env.LCX_API_KEY_FILE ?? '').trim()
|
|
14
|
-
if (!model) throw new Error('Set LCX_MODEL to the exact GPT model id')
|
|
15
|
-
if (!keyFile) throw new Error('Set LCX_API_KEY_FILE to a local file containing the bearer key')
|
|
16
|
-
const apiKey = readFileSync(keyFile, 'utf8').trim()
|
|
17
|
-
if (!apiKey) throw new Error('LCX_API_KEY_FILE is empty')
|
|
18
|
-
const storeFile = process.env.LCX_ALPHA_CAPABILITY_PATH ?? join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), 'storages', 'lcx-codex', 'web-alpha-capabilities.json')
|
|
19
|
-
const sessionId = `lcx-probe-${randomUUID()}`
|
|
20
|
-
|
|
21
|
-
async function invoke(rawArgs) {
|
|
22
|
-
const args = normalizeAlphaSearchArgs(rawArgs)
|
|
23
|
-
const requestId = randomUUID()
|
|
24
|
-
const response = await fetch(`${baseURL}/alpha/search`, {
|
|
25
|
-
method: 'POST',
|
|
26
|
-
headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}`, 'x-client-request-id': requestId, 'session-id': sessionId },
|
|
27
|
-
body: JSON.stringify(buildAlphaSearchBody(args, model, sessionId, true, 2500)),
|
|
28
|
-
})
|
|
29
|
-
const text = await response.text()
|
|
30
|
-
let body
|
|
31
|
-
try { body = text ? JSON.parse(text) : {} } catch { body = { output: text, results: [] } }
|
|
32
|
-
if (!response.ok) { const e = new Error(body?.error?.message ?? body?.message ?? `HTTP ${response.status}`); e.status = response.status; throw e }
|
|
33
|
-
return parseAlphaSearchResponse(body, { action: args.action, capability: 'command-capable', requestId })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const structured = process.env.LCX_ALPHA_PROBE_STRUCTURED === '1'
|
|
37
|
-
const actionProbes = structured ? {
|
|
38
|
-
image_query: { query: 'OpenAI logo' }, finance: { ticker: 'MSFT', assetType: 'equity', market: 'USA' }, weather: { location: 'San Francisco, CA' }, sports: { fn: 'standings', league: 'nba' }, time: { utcOffset: '+00:00' },
|
|
39
|
-
} : {}
|
|
40
|
-
const result = await probeAlphaCapabilities({ invoke, schemaFingerprint: ALPHA_SCHEMA_FINGERPRINT, trustedNativeProvenance: process.env.LCX_ALPHA_TRUST_NATIVE === '1', actionProbes, clickProbeRef: process.env.LCX_ALPHA_CLICK_PROBE_REF, screenshotProbeRef: process.env.LCX_ALPHA_SCREENSHOT_PROBE_REF })
|
|
41
|
-
const fingerprint = alphaCapabilityFingerprint({ baseURL, provider, model, profile, group, schemaFingerprint: ALPHA_SCHEMA_FINGERPRINT })
|
|
42
|
-
new AlphaCapabilityStore(storeFile).put(fingerprint, result)
|
|
43
|
-
console.log(JSON.stringify({ fingerprint, storeFile, classification: result.classification, actions: result.actions, probedAt: result.probedAt, provenance: result.provenance }, null, 2))
|