kiokuko-dsh 0.1.18 → 0.1.20
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/dist/client.cjs +228 -0
- package/dist/client.d.ts +40 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/dsh/boundary-worker.d.ts +26 -0
- package/dist/dsh/boundary-worker.d.ts.map +1 -0
- package/dist/dsh/boundary-worker.js +111 -0
- package/dist/dsh/boundary-worker.js.map +1 -0
- package/dist/dsh/composition.d.ts +12 -0
- package/dist/dsh/composition.d.ts.map +1 -1
- package/dist/dsh/composition.js +56 -6
- package/dist/dsh/composition.js.map +1 -1
- package/dist/dsh/host-adapter.d.ts +1 -0
- package/dist/dsh/host-adapter.d.ts.map +1 -1
- package/dist/dsh/host-adapter.js +682 -123
- package/dist/dsh/host-adapter.js.map +1 -1
- package/dist/dsh/index.d.ts +7 -0
- package/dist/dsh/index.d.ts.map +1 -1
- package/dist/dsh/index.js +24 -1
- package/dist/dsh/index.js.map +1 -1
- package/dist/dsh/input-claim.d.ts +34 -0
- package/dist/dsh/input-claim.d.ts.map +1 -0
- package/dist/dsh/input-claim.js +119 -0
- package/dist/dsh/input-claim.js.map +1 -0
- package/dist/dsh/intake-gate.d.ts +2 -0
- package/dist/dsh/intake-gate.d.ts.map +1 -1
- package/dist/dsh/intake-gate.js +13 -6
- package/dist/dsh/intake-gate.js.map +1 -1
- package/dist/dsh/paths.d.ts +2 -0
- package/dist/dsh/paths.d.ts.map +1 -1
- package/dist/dsh/paths.js +6 -0
- package/dist/dsh/paths.js.map +1 -1
- package/dist/dsh/prompt-cache.d.ts +40 -0
- package/dist/dsh/prompt-cache.d.ts.map +1 -0
- package/dist/dsh/prompt-cache.js +64 -0
- package/dist/dsh/prompt-cache.js.map +1 -0
- package/dist/dsh/session-log-export.d.ts +33 -0
- package/dist/dsh/session-log-export.d.ts.map +1 -0
- package/dist/dsh/session-log-export.js +196 -0
- package/dist/dsh/session-log-export.js.map +1 -0
- package/dist/dsh/session-log-mirror.d.ts +104 -0
- package/dist/dsh/session-log-mirror.d.ts.map +1 -0
- package/dist/dsh/session-log-mirror.js +895 -0
- package/dist/dsh/session-log-mirror.js.map +1 -0
- package/dist/dsh/session-log-surface.d.ts +7 -0
- package/dist/dsh/session-log-surface.d.ts.map +1 -0
- package/dist/dsh/session-log-surface.js +70 -0
- package/dist/dsh/session-log-surface.js.map +1 -0
- package/dist/dsh/session-memory-finalizer.d.ts +31 -3
- package/dist/dsh/session-memory-finalizer.d.ts.map +1 -1
- package/dist/dsh/session-memory-finalizer.js +157 -35
- package/dist/dsh/session-memory-finalizer.js.map +1 -1
- package/dist/dsh/tool-policy.d.ts +7 -1
- package/dist/dsh/tool-policy.d.ts.map +1 -1
- package/dist/dsh/tool-policy.js +52 -5
- package/dist/dsh/tool-policy.js.map +1 -1
- package/dist/dsh/tools.d.ts.map +1 -1
- package/dist/dsh/tools.js +15 -10
- package/dist/dsh/tools.js.map +1 -1
- package/dist/dsh/turn-process.d.ts +126 -0
- package/dist/dsh/turn-process.d.ts.map +1 -0
- package/dist/dsh/turn-process.js +415 -0
- package/dist/dsh/turn-process.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/docs/architecture.md +28 -14
- package/docs/dsh-plugin.md +23 -23
- package/docs/execution-ledger.md +4 -3
- package/docs/store-evidence.md +9 -5
- package/dsh/cordis.patch.yml +7 -4
- package/migrations/003_dsh_turn_process.sql +225 -0
- package/package.json +21 -2
- package/skills/kiokuko-enno-oduno/SKILL.md +1 -1
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "kiokuko-dsh",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
const { createSnapshotStore } = require("@deepseek-ai/dsh-client-store");
|
|
7
|
+
const { jsx, jsxs, Fragment } = require("react/jsx-runtime");
|
|
8
|
+
const { Modal, Button, IconDownloadOutline16 } = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
|
+
const SESSION_EXPORT_PATH = '/api/session.export';
|
|
10
|
+
const LOCALE_NAMESPACE = 'kiokuko-session-log-download';
|
|
11
|
+
const INITIAL_DOWNLOAD_STATE = { bySession: {} };
|
|
12
|
+
const en = {
|
|
13
|
+
'header.action': 'Session log',
|
|
14
|
+
'dialog.preparingTitle': 'Exporting Session',
|
|
15
|
+
'dialog.preparingDescription': 'Streaming this Session, its sub-Sessions, and attachments to a ZIP file.',
|
|
16
|
+
'dialog.successTitle': 'Session export complete',
|
|
17
|
+
'dialog.successDescription': 'The Session ZIP has been saved or handed to the browser download manager.',
|
|
18
|
+
'dialog.errorTitle': 'Session export failed',
|
|
19
|
+
'dialog.close': 'Close',
|
|
20
|
+
'dialog.commandFailed': 'Could not export the Session log.',
|
|
21
|
+
};
|
|
22
|
+
const ja = {
|
|
23
|
+
'header.action': 'Session log',
|
|
24
|
+
'dialog.preparingTitle': 'Sessionをエクスポート中',
|
|
25
|
+
'dialog.preparingDescription': 'このSession、子Session、添付ファイルをZIPへストリーミングしています。',
|
|
26
|
+
'dialog.successTitle': 'Sessionのエクスポート完了',
|
|
27
|
+
'dialog.successDescription': 'Session ZIPを保存、またはブラウザのダウンロード処理へ渡しました。',
|
|
28
|
+
'dialog.errorTitle': 'Sessionのエクスポートに失敗',
|
|
29
|
+
'dialog.close': '閉じる',
|
|
30
|
+
'dialog.commandFailed': 'Session logをエクスポートできませんでした。',
|
|
31
|
+
};
|
|
32
|
+
const zh = {
|
|
33
|
+
'header.action': 'Session 日志',
|
|
34
|
+
'dialog.preparingTitle': '正在导出 Session',
|
|
35
|
+
'dialog.preparingDescription': '正在将当前 Session、子 Session 和附件流式写入 ZIP 文件。',
|
|
36
|
+
'dialog.successTitle': 'Session 导出完成',
|
|
37
|
+
'dialog.successDescription': 'Session ZIP 已保存或交给浏览器下载管理器。',
|
|
38
|
+
'dialog.errorTitle': 'Session 导出失败',
|
|
39
|
+
'dialog.close': '关闭',
|
|
40
|
+
'dialog.commandFailed': '无法导出 Session 日志。',
|
|
41
|
+
};
|
|
42
|
+
function hostBase() {
|
|
43
|
+
const origin = globalThis.location?.origin;
|
|
44
|
+
return origin !== undefined && origin !== 'null' ? origin : 'http://dsh.internal';
|
|
45
|
+
}
|
|
46
|
+
function messageOf(error) {
|
|
47
|
+
return error instanceof Error ? error.message : String(error);
|
|
48
|
+
}
|
|
49
|
+
function isAbortError(error) {
|
|
50
|
+
return typeof DOMException !== 'undefined' && error instanceof DOMException && error.name === 'AbortError';
|
|
51
|
+
}
|
|
52
|
+
function sessionLogZipFilename(sessionId) {
|
|
53
|
+
return `dsh-session-${String(sessionId).replace(/[^A-Za-z0-9_-]/gu, '_')}.zip`;
|
|
54
|
+
}
|
|
55
|
+
async function responseFailure(response) {
|
|
56
|
+
const detail = await response.text().catch(() => '');
|
|
57
|
+
return new Error(`Session export failed: HTTP ${response.status}${detail === '' ? '' : ` ${detail}`}`);
|
|
58
|
+
}
|
|
59
|
+
/** Browser helper that never builds a whole-log Blob in application memory. */
|
|
60
|
+
async function downloadDshSessionLog(options) {
|
|
61
|
+
const url = new URL(options.endpoint);
|
|
62
|
+
url.searchParams.set('sessionId', options.sessionId);
|
|
63
|
+
url.searchParams.set('includeDescendants', 'true');
|
|
64
|
+
const browser = options.window ?? globalThis.window;
|
|
65
|
+
if (browser?.showSaveFilePicker === undefined) {
|
|
66
|
+
if (browser === undefined)
|
|
67
|
+
throw new Error('browser download surface is unavailable');
|
|
68
|
+
url.searchParams.set('download', '1');
|
|
69
|
+
browser.location.assign(url.toString());
|
|
70
|
+
return 'navigated';
|
|
71
|
+
}
|
|
72
|
+
const handle = await browser.showSaveFilePicker({
|
|
73
|
+
suggestedName: sessionLogZipFilename(options.sessionId),
|
|
74
|
+
types: [{ description: 'ZIP archive', accept: { 'application/zip': ['.zip'] } }],
|
|
75
|
+
});
|
|
76
|
+
const response = await (options.fetch ?? globalThis.fetch)(url, options.signal === undefined ? {} : { signal: options.signal });
|
|
77
|
+
if (!response.ok)
|
|
78
|
+
throw await responseFailure(response);
|
|
79
|
+
if (response.body === null)
|
|
80
|
+
throw new Error('Session export returned no response stream');
|
|
81
|
+
const writable = await handle.createWritable();
|
|
82
|
+
await response.body.pipeTo(writable);
|
|
83
|
+
return 'streamed';
|
|
84
|
+
}
|
|
85
|
+
class SessionLogDownloadController {
|
|
86
|
+
store = createSnapshotStore({ ...INITIAL_DOWNLOAD_STATE, bySession: {} });
|
|
87
|
+
active = new Map();
|
|
88
|
+
disposed = false;
|
|
89
|
+
download(sessionId) {
|
|
90
|
+
const existing = this.active.get(sessionId);
|
|
91
|
+
if (existing !== undefined)
|
|
92
|
+
return existing.done;
|
|
93
|
+
if (this.disposed)
|
|
94
|
+
return Promise.resolve();
|
|
95
|
+
const abort = new AbortController();
|
|
96
|
+
const done = this.run(sessionId, abort.signal).finally(() => this.active.delete(sessionId));
|
|
97
|
+
this.active.set(sessionId, { abort, done });
|
|
98
|
+
return done;
|
|
99
|
+
}
|
|
100
|
+
dismiss(sessionId) {
|
|
101
|
+
const current = this.store.getSnapshot().bySession[sessionId];
|
|
102
|
+
if (current === undefined || !current.open)
|
|
103
|
+
return;
|
|
104
|
+
this.publish(sessionId, { ...current, open: false });
|
|
105
|
+
}
|
|
106
|
+
async dispose() {
|
|
107
|
+
this.disposed = true;
|
|
108
|
+
const active = [...this.active.values()];
|
|
109
|
+
for (const operation of active)
|
|
110
|
+
operation.abort.abort();
|
|
111
|
+
await Promise.allSettled(active.map(operation => operation.done));
|
|
112
|
+
}
|
|
113
|
+
async run(sessionId, signal) {
|
|
114
|
+
this.publish(sessionId, { open: true, status: 'downloading', error: null });
|
|
115
|
+
try {
|
|
116
|
+
const endpoint = new URL(SESSION_EXPORT_PATH, hostBase()).toString();
|
|
117
|
+
const browser = globalThis.window;
|
|
118
|
+
if (browser?.showSaveFilePicker === undefined) {
|
|
119
|
+
const probe = await fetch(`${endpoint}?sessionId=${encodeURIComponent(sessionId)}&includeDescendants=true`, {
|
|
120
|
+
method: 'HEAD',
|
|
121
|
+
signal,
|
|
122
|
+
});
|
|
123
|
+
if (!probe.ok)
|
|
124
|
+
throw await responseFailure(probe);
|
|
125
|
+
}
|
|
126
|
+
await downloadDshSessionLog({
|
|
127
|
+
endpoint,
|
|
128
|
+
sessionId,
|
|
129
|
+
signal,
|
|
130
|
+
...(browser === undefined ? {} : { window: browser }),
|
|
131
|
+
});
|
|
132
|
+
const open = this.store.getSnapshot().bySession[sessionId]?.open ?? true;
|
|
133
|
+
this.publish(sessionId, { open, status: 'success', error: null });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (signal.aborted || isAbortError(error))
|
|
137
|
+
return;
|
|
138
|
+
const open = this.store.getSnapshot().bySession[sessionId]?.open ?? true;
|
|
139
|
+
this.publish(sessionId, { open, status: 'error', error: messageOf(error) });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
publish(sessionId, entry) {
|
|
143
|
+
this.store.update(state => {
|
|
144
|
+
state.bySession = { ...state.bySession, [sessionId]: entry };
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function SessionLogDownloadDialog(props) {
|
|
149
|
+
const sessionId = String(props.sessionId);
|
|
150
|
+
const useSessionLogDownload = props.useSessionLogDownload;
|
|
151
|
+
const dismiss = props.dismiss;
|
|
152
|
+
const t = props.t;
|
|
153
|
+
const entry = useSessionLogDownload(state => state.bySession[sessionId]);
|
|
154
|
+
const status = entry?.status;
|
|
155
|
+
const error = status === 'error' ? entry?.error || t('dialog.commandFailed') : null;
|
|
156
|
+
return jsx(Modal, {
|
|
157
|
+
open: entry?.open === true,
|
|
158
|
+
onClose: () => dismiss(sessionId),
|
|
159
|
+
title: status === 'downloading'
|
|
160
|
+
? t('dialog.preparingTitle')
|
|
161
|
+
: status === 'success' ? t('dialog.successTitle') : t('dialog.errorTitle'),
|
|
162
|
+
description: status === 'downloading'
|
|
163
|
+
? t('dialog.preparingDescription')
|
|
164
|
+
: status === 'success' ? t('dialog.successDescription') : error ?? t('dialog.commandFailed'),
|
|
165
|
+
closeLabel: t('dialog.close'),
|
|
166
|
+
footer: jsx(Button, { variant: 'primary', onClick: () => dismiss(sessionId), children: t('dialog.close') }),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function SessionLogDownloadHeaderAction(props) {
|
|
170
|
+
const sessionId = String(props.sessionId);
|
|
171
|
+
const useSessionLogDownload = props.useSessionLogDownload;
|
|
172
|
+
const request = props.request;
|
|
173
|
+
const t = props.t;
|
|
174
|
+
const busy = useSessionLogDownload(state => state.bySession[sessionId])?.status === 'downloading';
|
|
175
|
+
return jsxs(Fragment, {
|
|
176
|
+
children: [
|
|
177
|
+
jsxs('button', {
|
|
178
|
+
type: 'button',
|
|
179
|
+
className: 'kiokuko-session-log-button',
|
|
180
|
+
disabled: busy,
|
|
181
|
+
'aria-busy': busy,
|
|
182
|
+
onClick: () => request(sessionId),
|
|
183
|
+
children: [jsx('span', { children: t('header.action') }), jsx(IconDownloadOutline16, { size: 12 })],
|
|
184
|
+
}),
|
|
185
|
+
jsx(SessionLogDownloadDialog, props),
|
|
186
|
+
],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function installStyle() {
|
|
190
|
+
const styleId = 'kiokuko-session-log-download-style';
|
|
191
|
+
const existing = document.querySelector(`style[data-plugin-css="${styleId}"]`);
|
|
192
|
+
if (existing !== null)
|
|
193
|
+
return () => undefined;
|
|
194
|
+
const style = document.createElement('style');
|
|
195
|
+
style.dataset.plugin = 'kiokuko-dsh';
|
|
196
|
+
style.dataset.pluginCss = styleId;
|
|
197
|
+
style.textContent = '.kiokuko-session-log-button{border:.5px solid var(--dsw-alias-border-l4);min-width:111px;height:32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);cursor:pointer;background:transparent;border-radius:18px;justify-content:center;align-items:center;gap:4px;padding:6px 12px;font-size:13px;font-weight:400;line-height:20px;display:inline-flex}.kiokuko-session-log-button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.kiokuko-session-log-button:disabled{color:var(--dsw-alias-label-dimmed);cursor:wait}.kiokuko-session-log-button span,.kiokuko-session-log-button svg{flex:none}.kiokuko-session-log-button span{white-space:nowrap}';
|
|
198
|
+
document.head.appendChild(style);
|
|
199
|
+
return () => style.remove();
|
|
200
|
+
}
|
|
201
|
+
const inject = ['slots', 'locale'];
|
|
202
|
+
/** Register Kiokuko's streaming Session-export browser surface. */
|
|
203
|
+
function apply(ctx) {
|
|
204
|
+
const controller = new SessionLogDownloadController();
|
|
205
|
+
ctx.effect(() => async () => controller.dispose(), 'kiokuko-dsh: browser download lifecycle');
|
|
206
|
+
ctx.effect(installStyle, 'kiokuko-dsh: browser download style');
|
|
207
|
+
ctx.effect(() => ctx.locale.register(LOCALE_NAMESPACE, { en, ja, zh }), 'kiokuko-dsh: browser dictionaries');
|
|
208
|
+
ctx.on('command/executed', (sessionId, commandName, result) => {
|
|
209
|
+
if (commandName === 'export' && result.kind === 'success')
|
|
210
|
+
void controller.download(sessionId);
|
|
211
|
+
});
|
|
212
|
+
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
|
213
|
+
name: 'conversation.session.header.utilities',
|
|
214
|
+
id: 'kiokuko-session-log-download',
|
|
215
|
+
locale: LOCALE_NAMESPACE,
|
|
216
|
+
inject: () => ({
|
|
217
|
+
hooks: { sessionLogDownload: controller.store },
|
|
218
|
+
request: (sessionId) => controller.download(sessionId),
|
|
219
|
+
dismiss: (sessionId) => controller.dismiss(sessionId),
|
|
220
|
+
}),
|
|
221
|
+
}, SessionLogDownloadHeaderAction));
|
|
222
|
+
}
|
|
223
|
+
exports.apply = apply;
|
|
224
|
+
exports.downloadDshSessionLog = downloadDshSessionLog;
|
|
225
|
+
exports.inject = inject;
|
|
226
|
+
return module.exports;
|
|
227
|
+
}
|
|
228
|
+
});
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface DshSessionDownloadWindow {
|
|
2
|
+
showSaveFilePicker?: (options: unknown) => Promise<{
|
|
3
|
+
createWritable(): Promise<WritableStream<Uint8Array>>;
|
|
4
|
+
}>;
|
|
5
|
+
location: {
|
|
6
|
+
assign(url: string): void;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface DshSessionDownloadOptions {
|
|
10
|
+
readonly endpoint: string;
|
|
11
|
+
readonly sessionId: string;
|
|
12
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
13
|
+
readonly signal?: AbortSignal;
|
|
14
|
+
readonly window?: DshSessionDownloadWindow;
|
|
15
|
+
}
|
|
16
|
+
interface DshClientContext {
|
|
17
|
+
readonly locale: {
|
|
18
|
+
register(namespace: string, dictionaries: Record<string, Record<string, string>>): unknown;
|
|
19
|
+
};
|
|
20
|
+
readonly slots: {
|
|
21
|
+
inject(name: string, register: () => unknown): unknown;
|
|
22
|
+
register(definition: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
readonly inject: () => Record<string, unknown>;
|
|
27
|
+
}, component: (props: Record<string, unknown>) => unknown): unknown;
|
|
28
|
+
};
|
|
29
|
+
effect(setup: () => void | (() => void | Promise<void>), label: string): unknown;
|
|
30
|
+
on(event: 'command/executed', listener: (sessionId: string, commandName: string, result: {
|
|
31
|
+
readonly kind: string;
|
|
32
|
+
}) => void): unknown;
|
|
33
|
+
}
|
|
34
|
+
/** Browser helper that never builds a whole-log Blob in application memory. */
|
|
35
|
+
export declare function downloadDshSessionLog(options: DshSessionDownloadOptions): Promise<'streamed' | 'navigated'>;
|
|
36
|
+
export declare const inject: readonly ["slots", "locale"];
|
|
37
|
+
/** Register Kiokuko's streaming Session-export browser surface. */
|
|
38
|
+
export declare function apply(ctx: DshCl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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAC/C,EACD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GACrD,OAAO,CAAA;KACX,CAAA;IACD,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;IAChF,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAA;CACtI;AAuED,+EAA+E;AAC/E,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,CAqBjH;AAuHD,eAAO,MAAM,MAAM,8BAA+B,CAAA;AAElD,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAkBjD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DshRuntime } from './runtime.js';
|
|
2
|
+
import { type DshBoundaryCompletion, type DshBoundaryJob, type DshContinuationOutboxItem } from './turn-process.js';
|
|
3
|
+
export interface DshBoundaryWorkerOptions {
|
|
4
|
+
readonly runtime: Pick<DshRuntime, 'withDatabase'>;
|
|
5
|
+
/** One bounded job stage. It must be idempotent under lease recovery. */
|
|
6
|
+
readonly process: (job: DshBoundaryJob) => DshBoundaryCompletion | PromiseLike<DshBoundaryCompletion>;
|
|
7
|
+
/** Native durability barrier. Failure is fail-closed for delivery only. */
|
|
8
|
+
readonly flush: (job: DshBoundaryJob) => void | PromiseLike<void>;
|
|
9
|
+
/** Enqueue one deterministic plugin-owned message into the native Agent. */
|
|
10
|
+
readonly dispatch: (job: DshBoundaryJob, item: DshContinuationOutboxItem) => void | PromiseLike<void>;
|
|
11
|
+
readonly bindNativeAgent?: (sessionId: string, nativeAgent: object) => void;
|
|
12
|
+
readonly now?: () => string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Durable, no-idle outbox driver. `agent/turn-stopping` only calls `kick`;
|
|
16
|
+
* confirmation, verification, advisory, context, and delivery run as separate
|
|
17
|
+
* leased stages outside that callback.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DshBoundaryWorker {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(options: DshBoundaryWorkerOptions);
|
|
22
|
+
kick(sessionId?: string, nativeAgent?: object): void;
|
|
23
|
+
whenIdle(): Promise<void>;
|
|
24
|
+
dispose(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=boundary-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary-worker.d.ts","sourceRoot":"","sources":["../../src/dsh/boundary-worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;IAClD,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAA;IACrG,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IACjE,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,yBAAyB,KAAK,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IACrG,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAC5B;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;;gBAWhB,OAAO,EAAE,wBAAwB;IAS7C,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAqE9C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { withImmediateTransaction } from '../db/transaction.js';
|
|
3
|
+
import { claimBoundaryJobInTransaction, completeBoundaryJobInTransaction, failBoundaryJobInTransaction, markOutboxDispatchedInTransaction, readPendingOutbox, } from './turn-process.js';
|
|
4
|
+
/**
|
|
5
|
+
* Durable, no-idle outbox driver. `agent/turn-stopping` only calls `kick`;
|
|
6
|
+
* confirmation, verification, advisory, context, and delivery run as separate
|
|
7
|
+
* leased stages outside that callback.
|
|
8
|
+
*/
|
|
9
|
+
export class DshBoundaryWorker {
|
|
10
|
+
#runtime;
|
|
11
|
+
#process;
|
|
12
|
+
#flush;
|
|
13
|
+
#dispatch;
|
|
14
|
+
#now;
|
|
15
|
+
#bindNativeAgent;
|
|
16
|
+
#tail = Promise.resolve();
|
|
17
|
+
#disposed = false;
|
|
18
|
+
#retryTimers = new Map();
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.#runtime = options.runtime;
|
|
21
|
+
this.#process = options.process;
|
|
22
|
+
this.#flush = options.flush;
|
|
23
|
+
this.#dispatch = options.dispatch;
|
|
24
|
+
this.#bindNativeAgent = options.bindNativeAgent;
|
|
25
|
+
this.#now = options.now ?? (() => new Date().toISOString());
|
|
26
|
+
}
|
|
27
|
+
kick(sessionId, nativeAgent) {
|
|
28
|
+
if (this.#disposed)
|
|
29
|
+
return;
|
|
30
|
+
if (sessionId !== undefined && nativeAgent !== undefined)
|
|
31
|
+
this.#bindNativeAgent?.(sessionId, nativeAgent);
|
|
32
|
+
if (sessionId === undefined)
|
|
33
|
+
return;
|
|
34
|
+
const timer = this.#retryTimers.get(sessionId);
|
|
35
|
+
if (timer !== undefined) {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
this.#retryTimers.delete(sessionId);
|
|
38
|
+
}
|
|
39
|
+
this.#tail = this.#tail.then(() => this.#drain(sessionId)).catch(() => undefined);
|
|
40
|
+
}
|
|
41
|
+
#scheduleRetry(sessionId, retryAt) {
|
|
42
|
+
if (this.#disposed)
|
|
43
|
+
return;
|
|
44
|
+
const delay = Math.max(0, Date.parse(retryAt) - Date.parse(this.#now()));
|
|
45
|
+
const existing = this.#retryTimers.get(sessionId);
|
|
46
|
+
if (existing !== undefined)
|
|
47
|
+
clearTimeout(existing);
|
|
48
|
+
const timer = setTimeout(() => {
|
|
49
|
+
this.#retryTimers.delete(sessionId);
|
|
50
|
+
this.kick(sessionId);
|
|
51
|
+
}, Math.min(delay, 60_000));
|
|
52
|
+
timer.unref?.();
|
|
53
|
+
this.#retryTimers.set(sessionId, timer);
|
|
54
|
+
}
|
|
55
|
+
async #drain(sessionId) {
|
|
56
|
+
while (!this.#disposed) {
|
|
57
|
+
const ownerNonce = randomUUID();
|
|
58
|
+
const job = await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => (claimBoundaryJobInTransaction(database, ownerNonce, this.#now(), sessionId))));
|
|
59
|
+
if (job === undefined)
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
let completion;
|
|
63
|
+
if (job.kind === 'delivery') {
|
|
64
|
+
const outbox = await this.#runtime.withDatabase((database) => readPendingOutbox(database, job.dshSessionId)
|
|
65
|
+
.find((item) => item.receiptId === job.receiptId));
|
|
66
|
+
if (outbox === undefined || outbox.status === 'observed' || outbox.status === 'superseded') {
|
|
67
|
+
completion = { kind: 'superseded' };
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
await this.#flush(job);
|
|
71
|
+
await this.#dispatch(job, outbox);
|
|
72
|
+
await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
73
|
+
markOutboxDispatchedInTransaction(database, outbox.continuationId, this.#now());
|
|
74
|
+
}));
|
|
75
|
+
completion = { kind: 'completed' };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
completion = await this.#process(job);
|
|
80
|
+
}
|
|
81
|
+
await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
82
|
+
completeBoundaryJobInTransaction(database, job, completion, this.#now());
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
let retryAt;
|
|
87
|
+
try {
|
|
88
|
+
await this.#runtime.withDatabase((database) => withImmediateTransaction(database, () => {
|
|
89
|
+
retryAt = failBoundaryJobInTransaction(database, job, error, this.#now());
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// A Core DB failure cannot be repaired in-memory. The expired lease
|
|
94
|
+
// is the recovery mechanism on the next kick/startup.
|
|
95
|
+
}
|
|
96
|
+
if (retryAt !== undefined)
|
|
97
|
+
this.#scheduleRetry(job.dshSessionId, retryAt);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async whenIdle() { await this.#tail; }
|
|
103
|
+
async dispose() {
|
|
104
|
+
this.#disposed = true;
|
|
105
|
+
for (const timer of this.#retryTimers.values())
|
|
106
|
+
clearTimeout(timer);
|
|
107
|
+
this.#retryTimers.clear();
|
|
108
|
+
await this.#tail;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
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AC,CAAC;IAEpD,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QACrB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAAE,YAAY,CAAC,KAAK,CAAC,CAAA;QACnE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,MAAM,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;CACF"}
|
|
@@ -10,6 +10,9 @@ import { mountSoulPrompt } from './prompt-policy.js';
|
|
|
10
10
|
import type { DshUserQuestions } from './user-interaction.js';
|
|
11
11
|
import type { DshRuntime } from './runtime.js';
|
|
12
12
|
import type { DshMemoryFinalizer } from './session-memory-finalizer.js';
|
|
13
|
+
import type { DshMirrorCheckpoint } from './session-log-mirror.js';
|
|
14
|
+
import type { DshBoundaryWorker } from './boundary-worker.js';
|
|
15
|
+
import type { DshSessionLogExportService } from './session-log-export.js';
|
|
13
16
|
/** The optional, explicit host adapter supplied by a dsh profile. */
|
|
14
17
|
export declare const KIOKUKO_DSH_HOST_SERVICE = "kiokukoDsh";
|
|
15
18
|
export interface DshNativePreStepPayload {
|
|
@@ -58,7 +61,16 @@ export interface DshCompositionHost {
|
|
|
58
61
|
}) => string | undefined;
|
|
59
62
|
readonly memoryFinalizer?: Pick<DshMemoryFinalizer, 'start' | 'dispose' | 'whenIdle'>;
|
|
60
63
|
readonly memoryFinalizerOwner?: 'composition' | 'host';
|
|
64
|
+
readonly sessionMirror?: {
|
|
65
|
+
readonly start: () => Promise<void>;
|
|
66
|
+
readonly close: () => Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
readonly sessionMirrorOwner?: 'composition' | 'host';
|
|
69
|
+
readonly sessionExport?: DshSessionLogExportService;
|
|
70
|
+
readonly checkpointSessionMirror?: (session: DshNativeSession) => PromiseLike<DshMirrorCheckpoint>;
|
|
61
71
|
readonly ennoController?: DshEnnoController;
|
|
72
|
+
readonly boundaryWorker?: Pick<DshBoundaryWorker, 'kick' | 'dispose' | 'whenIdle'>;
|
|
73
|
+
readonly boundaryWorkerOwner?: 'composition' | 'host';
|
|
62
74
|
readonly lifecycle?: DshRunLifecycle;
|
|
63
75
|
readonly lifecycleOwner?: 'composition' | 'host';
|
|
64
76
|
readonly resolveIdleClose?: (agentId: string, sessionId?: string, nativeSession?: object, nativeAgent?: object) => DshCloseIntent | PromiseLike<DshCloseIntent | undefined> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/dsh/composition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAA0D,MAAM,sBAAsB,CAAA;AAChH,OAAO,EAAE,aAAa,EAA2B,KAAK,eAAe,EAA0B,MAAM,kBAAkB,CAAA;AACvH,OAAO,EAAmD,KAAK,cAAc,EAAgC,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAmC,MAAM,qBAAqB,CAAA;AACtN,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,gBAAgB,EAA2B,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAA;AACzG,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/dsh/composition.ts"],"names":[],"mappings":"AACA,O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MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,CAAA;IAClF,QAAQ,CAAC,mBAAmB,CAAC,EAAE,aAAa,GAAG,MAAM,CAAA;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,GAAG,MAAM,CAAA;IAChD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,cAAc,GAAG,WAAW,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;IACvL,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,cAAc,GAAG,WAAW,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;CAClJ;AAED,KAAK,uBAAuB,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAA;AAS9E,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;AA6DD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6I/G"}
|
package/dist/dsh/composition.js
CHANGED
|
@@ -21,8 +21,14 @@ async function mountRuntime(runtime) {
|
|
|
21
21
|
await runtime.close();
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function mountNativeIntakeGate(ctx, gate, mapPreStep) {
|
|
25
|
-
return ctx.on('agent/pre-step', async (payload, next) =>
|
|
24
|
+
function mountNativeIntakeGate(ctx, gate, mapPreStep, worker) {
|
|
25
|
+
return ctx.on('agent/pre-step', async (payload, next) => {
|
|
26
|
+
const decision = await gate.preStep(await mapPreStep(payload), next);
|
|
27
|
+
// CapturingGate has now applied human-input precedence and stale-outbox
|
|
28
|
+
// supersession. Only after that point may recovery work be kicked.
|
|
29
|
+
worker?.kick(payload.agent.session?.id ?? payload.agent.sessionId, payload.agent);
|
|
30
|
+
return decision;
|
|
31
|
+
}, { prepend: true });
|
|
26
32
|
}
|
|
27
33
|
function mountNativeEnnoController(ctx, controller) {
|
|
28
34
|
return ctx.on('agent/turn-stopping', async (payload) => {
|
|
@@ -42,6 +48,17 @@ function mountNativeEnnoController(ctx, controller) {
|
|
|
42
48
|
await controller.handle({ agent, turn: payload.turn, signal: payload.signal });
|
|
43
49
|
}, { prepend: true });
|
|
44
50
|
}
|
|
51
|
+
function mountNativeBoundaryKick(ctx, worker) {
|
|
52
|
+
const kick = (payload) => {
|
|
53
|
+
// No validation, LLM call, context construction, or delivery is allowed
|
|
54
|
+
// inside the native turn-stopping callback. The durable worker owns it.
|
|
55
|
+
worker.kick(payload.agent.session?.id ?? payload.agent.sessionId, payload.agent);
|
|
56
|
+
};
|
|
57
|
+
return [
|
|
58
|
+
ctx.on('agent/turn-stopping', kick, { prepend: true }),
|
|
59
|
+
ctx.on('agent/idle', kick),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
45
62
|
/**
|
|
46
63
|
* Mount every seam for which the profile supplied a real host adapter. The
|
|
47
64
|
* adapter is deliberately explicit: a generic Cordis context cannot invent a
|
|
@@ -104,6 +121,13 @@ export async function mountDshComposition(ctx, host) {
|
|
|
104
121
|
if (host.runtimeOwner !== 'host')
|
|
105
122
|
cleanupDisposers.push(disposer);
|
|
106
123
|
}
|
|
124
|
+
if (host.sessionMirror !== undefined) {
|
|
125
|
+
await host.sessionMirror.start();
|
|
126
|
+
const closeMirror = async () => host.sessionMirror.close();
|
|
127
|
+
setupResourceDisposers.push(closeMirror);
|
|
128
|
+
if (host.sessionMirrorOwner !== 'host')
|
|
129
|
+
cleanupDisposers.push(closeMirror);
|
|
130
|
+
}
|
|
107
131
|
if (host.memoryFinalizer !== undefined) {
|
|
108
132
|
await host.memoryFinalizer.start();
|
|
109
133
|
const closeFinalizer = async () => host.memoryFinalizer.dispose();
|
|
@@ -111,6 +135,13 @@ export async function mountDshComposition(ctx, host) {
|
|
|
111
135
|
if (host.memoryFinalizerOwner !== 'host')
|
|
112
136
|
cleanupDisposers.push(closeFinalizer);
|
|
113
137
|
}
|
|
138
|
+
if (host.boundaryWorker !== undefined) {
|
|
139
|
+
host.boundaryWorker.kick();
|
|
140
|
+
const closeBoundaryWorker = async () => host.boundaryWorker.dispose();
|
|
141
|
+
setupResourceDisposers.push(closeBoundaryWorker);
|
|
142
|
+
if (host.boundaryWorkerOwner !== 'host')
|
|
143
|
+
cleanupDisposers.push(closeBoundaryWorker);
|
|
144
|
+
}
|
|
114
145
|
if (host.skills !== undefined) {
|
|
115
146
|
const disposer = mountStandardSkillProvider({ skills: host.skills });
|
|
116
147
|
setupResourceDisposers.push(disposer);
|
|
@@ -149,19 +180,38 @@ export async function mountDshComposition(ctx, host) {
|
|
|
149
180
|
if (host.intakeGate !== undefined) {
|
|
150
181
|
if (host.mapPreStep === undefined)
|
|
151
182
|
throw new Error('kiokuko-dsh intake gate requires a native task projection');
|
|
152
|
-
ingressDisposers.push(mountNativeIntakeGate(ctx, host.intakeGate, host.mapPreStep));
|
|
183
|
+
ingressDisposers.push(mountNativeIntakeGate(ctx, host.intakeGate, host.mapPreStep, host.boundaryWorker));
|
|
184
|
+
}
|
|
185
|
+
if (host.boundaryWorker !== undefined && host.ennoController !== undefined) {
|
|
186
|
+
throw new Error('kiokuko-dsh must not mount both the durable boundary worker and the legacy turn-stopping controller');
|
|
153
187
|
}
|
|
154
|
-
if (host.
|
|
188
|
+
if (host.boundaryWorker !== undefined) {
|
|
189
|
+
ingressDisposers.push(...mountNativeBoundaryKick(ctx, host.boundaryWorker));
|
|
190
|
+
}
|
|
191
|
+
else if (host.ennoController !== undefined) {
|
|
155
192
|
ingressDisposers.push(mountNativeEnnoController(ctx, host.ennoController));
|
|
193
|
+
}
|
|
156
194
|
if (host.lifecycle !== undefined) {
|
|
157
195
|
if (host.resolveIdleClose === undefined)
|
|
158
196
|
throw new Error('kiokuko-dsh idle lifecycle requires a close resolver');
|
|
159
197
|
const nativeSessions = ctx.get('sessions', false);
|
|
160
198
|
if (nativeSessions?.flush === undefined)
|
|
161
199
|
throw new Error('kiokuko-dsh lifecycle requires the native DSH session flush service');
|
|
162
|
-
ingressDisposers.push(mountDshIdleLifecycle(ctx, host.lifecycle, host.resolveIdleClose, async (session) => {
|
|
200
|
+
ingressDisposers.push(mountDshIdleLifecycle(ctx, host.lifecycle, host.resolveIdleClose, async (session) => {
|
|
201
|
+
await nativeSessions.flush(session);
|
|
202
|
+
try {
|
|
203
|
+
await host.checkpointSessionMirror?.(session);
|
|
204
|
+
}
|
|
205
|
+
catch { /* cache is non-vetoing */ }
|
|
206
|
+
}));
|
|
163
207
|
if (host.resolveSessionClose !== undefined) {
|
|
164
|
-
ingressDisposers.push(mountDshSessionLifecycle(ctx, host.lifecycle, host.resolveSessionClose, async (session) => {
|
|
208
|
+
ingressDisposers.push(mountDshSessionLifecycle(ctx, host.lifecycle, host.resolveSessionClose, async (session) => {
|
|
209
|
+
await nativeSessions.flush(session);
|
|
210
|
+
try {
|
|
211
|
+
await host.checkpointSessionMirror?.(session);
|
|
212
|
+
}
|
|
213
|
+
catch { /* cache is non-vetoing */ }
|
|
214
|
+
}));
|
|
165
215
|
}
|
|
166
216
|
if (host.lifecycleOwner !== 'host')
|
|
167
217
|
cleanupDisposers.push(() => host.lifecycle.dispose());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../../src/dsh/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,OAAO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WAAW,EAAE,CAAA;QACb,IAAI,CAAC;YAAC,MAAM,eAAe,EAAE,CAAA;QAAC,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YAAC,MAAM,IAAI,cAAc,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,sCAAsC,CAAC,CAAA;QAAC,CAAC;QAChJ,MAAM,KAAK,CAAA;IACb,CAAC;IAED,MAAM,OAAO,GAAG,GAAkB,EAAE;QAClC,IAAI,cAAc,KAAK,SAAS;YAAE,OAAO,cAAc,CAAA;QACvD,WAAW,EAAE,CAAA;QACb,cAAc,GAAG,UAAU,EAAE,CAAA;QAC7B,OAAO,cAAc,CAAA;IACvB,CAAC,CAAA;IACD,OAAO,EAAE,WAAW,EAAE,OAAO,EAA0B,CAAA;AACzD,CAAC"}
|
|
@@ -15,6 +15,7 @@ export interface DshHostAdapterOptions {
|
|
|
15
15
|
readonly sessionQuery?: DshSessionQuery;
|
|
16
16
|
/** Test/custom host override; the normal DSH bundle injects llm. */
|
|
17
17
|
readonly llm?: DshLlm;
|
|
18
|
+
readonly sessionCachePath?: string;
|
|
18
19
|
/** Optional host-owned isolated, read-only advisory execution surface. */
|
|
19
20
|
readonly advisory?: DshAdvisoryHost;
|
|
20
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-adapter.d.ts","sourceRoot":"","sources":["../../src/dsh/host-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EAExB,MAAM,kBAAkB,CAAA;AAkBzB,OAAO,EAA0C,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"host-adapter.d.ts","sourceRoot":"","sources":["../../src/dsh/host-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EA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