@agentrouter-top/relay-dsh-plugin-codex 0.2.2-agentrouter.1
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/AGENTROUTER-FORK.md +7 -0
- package/LICENSE +21 -0
- package/README.md +419 -0
- package/README.zh.md +429 -0
- package/codex-activity-wire.mjs +16 -0
- package/cordis.patch.yml +5 -0
- package/docs/dsh-0.1.2-alpha.3.md +37 -0
- package/docs/images/dsh-new-session-backends.jpg +0 -0
- package/docs/reliability-acceptance.md +85 -0
- package/docs/reliability-spec.md +305 -0
- package/docs/spec/dsh-interaction-bridge.md +168 -0
- package/docs/spec/execution-presentation.md +103 -0
- package/dsh-client-compat.d.mts +4 -0
- package/dsh-client-compat.mjs +26 -0
- package/dsh-compat.mjs +92 -0
- package/lib/client.js +37202 -0
- package/lib/client.js.map +1 -0
- package/lib/host-plugin.js +5142 -0
- package/lib/host-plugin.js.map +1 -0
- package/lib/typert.host.js +16 -0
- package/lib/typert.host.js.map +1 -0
- package/package.json +157 -0
- package/presets/relay-codex/.relay-managed +1 -0
- package/presets/relay-codex/agent.cordis.yml +3 -0
- package/presets/relay-codex/preset.yml +3 -0
- package/scripts/repair-activity-history.mjs +123 -0
package/dsh-compat.mjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as llm from '@deepseek-ai/dsh-llm';
|
|
2
|
+
|
|
3
|
+
// Keep namespace access: a named import fails before this adapter can run on
|
|
4
|
+
// the other official DSH generation. Both constructors have the same contract.
|
|
5
|
+
export function toolCallId(value) {
|
|
6
|
+
const create = Reflect.get(llm, 'ToolCallId') ?? Reflect.get(llm, 'CallId');
|
|
7
|
+
if (typeof create !== 'function') throw new Error('DSH does not provide a tool call ID constructor');
|
|
8
|
+
return create(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// DSH alpha.3 exposed an immutable `events` snapshot. rc.1 replaced that
|
|
12
|
+
// accessor with `snapshotEvents()` and branded `seq`. Keep all runtime
|
|
13
|
+
// branching at this boundary so the same Relay artifact works on both hosts.
|
|
14
|
+
export function sessionEvents(session, from = 0) {
|
|
15
|
+
if (!Number.isSafeInteger(from) || from < 0) throw new RangeError('session event offset must be a non-negative integer');
|
|
16
|
+
const snapshot = Reflect.get(session, 'snapshotEvents');
|
|
17
|
+
if (typeof snapshot === 'function') {
|
|
18
|
+
return from === 0 ? Reflect.apply(snapshot, session, []) : Reflect.apply(snapshot, session, [from]);
|
|
19
|
+
}
|
|
20
|
+
const events = Reflect.get(session, 'events');
|
|
21
|
+
if (!Array.isArray(events)) throw new TypeError('DSH Session exposes neither snapshotEvents() nor events');
|
|
22
|
+
return from === 0 ? events : events.slice(from);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function sessionEventCount(session) {
|
|
26
|
+
const seq = Reflect.get(session, 'seq');
|
|
27
|
+
return Number.isSafeInteger(seq) && seq >= 0 ? Number(seq) : sessionEvents(session).length;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function loadPersistedSession(persistence, id) {
|
|
31
|
+
const load = Reflect.get(persistence, 'load');
|
|
32
|
+
if (typeof load === 'function') return Reflect.apply(load, persistence, [id]);
|
|
33
|
+
|
|
34
|
+
const open = Reflect.get(persistence, 'open');
|
|
35
|
+
if (typeof open !== 'function') throw new TypeError('DSH persistence exposes neither load() nor open()');
|
|
36
|
+
const handle = await Reflect.apply(open, persistence, [id, 'read']);
|
|
37
|
+
try {
|
|
38
|
+
return {
|
|
39
|
+
meta: structuredClone(handle.header),
|
|
40
|
+
inheritedEventCount: handle.inheritedEventCount,
|
|
41
|
+
events: await handle.read(),
|
|
42
|
+
};
|
|
43
|
+
} finally {
|
|
44
|
+
await handle.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function appendPersistedEvents(persistence, id, events) {
|
|
49
|
+
if (events.length === 0) return;
|
|
50
|
+
const append = Reflect.get(persistence, 'append');
|
|
51
|
+
if (typeof append === 'function') {
|
|
52
|
+
await Reflect.apply(append, persistence, [id, events]);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const open = Reflect.get(persistence, 'open');
|
|
57
|
+
if (typeof open !== 'function') throw new TypeError('DSH persistence exposes neither append() nor open()');
|
|
58
|
+
const handle = await Reflect.apply(open, persistence, [id, 'write']);
|
|
59
|
+
try {
|
|
60
|
+
await handle.append(events);
|
|
61
|
+
await handle.flush();
|
|
62
|
+
} finally {
|
|
63
|
+
await handle.close();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function writePersistedSession(persistence, header, events, inheritedEventCount = 0) {
|
|
68
|
+
const create = Reflect.get(persistence, 'create');
|
|
69
|
+
if (typeof create !== 'function') throw new TypeError('DSH persistence does not expose create()');
|
|
70
|
+
|
|
71
|
+
// alpha.3 and rc.1 expose a service API whose second argument is the
|
|
72
|
+
// numeric inherited offset. Newer DSH builds return a write handle and use
|
|
73
|
+
// an options object. The presence of append() distinguishes the services.
|
|
74
|
+
const append = Reflect.get(persistence, 'append');
|
|
75
|
+
if (typeof append === 'function') {
|
|
76
|
+
await Reflect.apply(create, persistence, [header, inheritedEventCount]);
|
|
77
|
+
await appendPersistedEvents(persistence, header.id, events);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handle = await Reflect.apply(create, persistence, [header, { inheritedEventCount }]);
|
|
82
|
+
if (handle && typeof handle.append === 'function') {
|
|
83
|
+
try {
|
|
84
|
+
if (events.length > 0) await handle.append(events);
|
|
85
|
+
await handle.flush();
|
|
86
|
+
} finally {
|
|
87
|
+
await handle.close();
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
throw new TypeError('DSH persistence create() did not return a write handle');
|
|
92
|
+
}
|