@hy-sde-org/dsh-pi-durable 0.2.0-rc.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hy-sde
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # @hy-sde-org/dsh-pi-durable — the durable-agent engine, delivered as ONE
2
+ # self-contained host-plane row.
3
+ #
4
+ # The plugin publishes the `piDurableAgent` service (a Harness over
5
+ # ~/.dsh/storages/pi-agent.sqlite with an OpenAI-compatible relay provider).
6
+ # It injects nothing from the host: pi-durable owns its storage medium, so the
7
+ # row sits at HOST plane (a durable process-wide service), not inside a preset.
8
+ # The model-facing tools live in @hy-sde-org/dsh-tool-pi-durable and resolve
9
+ # this service by name from any agent preset.
10
+ #
11
+ # All row ids carry the `hy-sde-` prefix to avoid clashing with any shipped
12
+ # row of the same name (a duplicate loader id fails the boot).
13
+ #
14
+ # `baseUrl` left unset starts the engine in WRITE-ONLY mode: durable writes,
15
+ # documents, and tasks work, but `input` submissions fail with a config error
16
+ # naming this knob. Point `baseUrl` at any OpenAI-compatible endpoint and set
17
+ # `apiKeyEnv` (default PI_DURABLE_API_KEY) to enable generation.
18
+ #
19
+ # Override per deployment by patching the row by id:
20
+ #
21
+ # - id: hy-sde-pi-durable
22
+ # config:
23
+ # path: /var/lib/dsh/pi-agent.sqlite
24
+ # baseUrl: https://relay.internal/v1
25
+ # apiKeyEnv: MY_RELAY_KEY
26
+ # modelId: my-model
27
+ - insert:
28
+ - id: hy-sde-pi-durable
29
+ name: '@hy-sde-org/dsh-pi-durable'
30
+ config: {}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The durable-agent runtime: one pi-durable {@link Harness} over SQLite
3
+ * storage with the relay provider registered, plus the narrow facade the
4
+ * model-facing tools consume. The harness opens eagerly on construction
5
+ * (failures surface to every caller) and the root conversation is created
6
+ * idempotently on first use, so a host restart resumes in place.
7
+ * @module
8
+ */
9
+ import { type JsonValue } from '@earendil-works/chord';
10
+ import { type Cursor, type EntryRecord, type HarnessInspection, type Page, type SubmissionRecord } from '@earendil-works/pi-durable';
11
+ import type { ResolvedPiDurableConfig } from './config.ts';
12
+ /** Result of admitting one root submission. */
13
+ export interface RootSubmissionOutcome {
14
+ readonly submissionId: string;
15
+ readonly record: SubmissionRecord;
16
+ }
17
+ /** Point-in-time status of the engine. */
18
+ export interface PiDurableStatus {
19
+ readonly rootConversationId: string;
20
+ readonly inspection: HarnessInspection;
21
+ readonly generationConfigured: boolean;
22
+ }
23
+ /**
24
+ * The engine facade published under the `piDurableAgent` service key.
25
+ * Every method awaits the eager open, so a failed init rejects loudly at
26
+ * call time with the original error.
27
+ */
28
+ export declare class PiDurableAgent {
29
+ private readonly config;
30
+ private readonly openPromise;
31
+ private harness;
32
+ private rootPromise;
33
+ constructor(config: ResolvedPiDurableConfig);
34
+ private open;
35
+ /** Resolves once the harness is open; rejections carry the init error. */
36
+ ready(): Promise<void>;
37
+ private harnessOf;
38
+ private root;
39
+ private openRoot;
40
+ private findExistingRoot;
41
+ private assertGenerationConfigured;
42
+ /**
43
+ * Submit user input to the root conversation. Exactly-once per `requestId`
44
+ * (scoped to the conversation); the run continues in the background.
45
+ */
46
+ submitInput(input: string, options?: {
47
+ requestId?: string;
48
+ whenBusy?: 'steer' | 'followUp' | 'reject';
49
+ }): Promise<RootSubmissionOutcome>;
50
+ /**
51
+ * Admit a passive entry write to the root conversation — durable
52
+ * bookkeeping that never triggers a generation run.
53
+ */
54
+ writeEntry(kind: string, data: JsonValue, requestId?: string): Promise<RootSubmissionOutcome>;
55
+ /** Resolve one submission record by id (undefined when unknown). */
56
+ submissionRecord(id: string): Promise<SubmissionRecord | undefined>;
57
+ /** Newest-first fork-aware page of the root conversation's history. */
58
+ history(limit: number, cursor?: Cursor): Promise<Page<EntryRecord, Cursor>>;
59
+ /** Newest-first page of any conversation's history (used for forks). */
60
+ historyOf(conversationId: string, limit: number, cursor?: Cursor): Promise<Page<EntryRecord, Cursor>>;
61
+ /** Fork the root conversation at an entry; history up to `entryId` is inherited. */
62
+ forkFrom(entryId: string, options?: {
63
+ instructions?: string;
64
+ }): Promise<{
65
+ conversationId: string;
66
+ }>;
67
+ /** Abort the root conversation's ordinary scope and resolve when idle. */
68
+ abortRoot(): Promise<void>;
69
+ /** Point-in-time status of the engine. */
70
+ status(): Promise<PiDurableStatus>;
71
+ /** Seal admission, settle commits, close storage. Idempotent. */
72
+ close(): Promise<void>;
73
+ }
74
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,OAAO,EAML,KAAK,MAAM,EAEX,KAAK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OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAOzE,uEAAuE;IACjE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAKjF,wEAAwE;IAClE,SAAS,CACb,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IASrC,oFAAoF;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IAS7G,0EAA0E;IACpE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKhC,0CAA0C;IACpC,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;IAWxC,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAa7B"}
package/dist/agent.js ADDED
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The durable-agent runtime: one pi-durable {@link Harness} over SQLite
3
+ * storage with the relay provider registered, plus the narrow facade the
4
+ * model-facing tools consume. The harness opens eagerly on construction
5
+ * (failures surface to every caller) and the root conversation is created
6
+ * idempotently on first use, so a host restart resumes in place.
7
+ * @module
8
+ */
9
+ import { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';
10
+ import { createModels } from '@earendil-works/pi-ai';
11
+ import { createRegistry, Harness, ROOT_CONVERSATION_ID, } from '@earendil-works/pi-durable';
12
+ import { CodingTools } from '@earendil-works/pi-durable/tools';
13
+ import { openNodeSqliteStorage } from '@earendil-works/pi-durable/storage/sqlite/node';
14
+ import { NodeExecutionEnv } from '@earendil-works/pi-durable/env/node';
15
+ import { createRelayProvider } from "./provider.js";
16
+ const BUSY_TIMEOUT_MS = 5_000;
17
+ /**
18
+ * The engine facade published under the `piDurableAgent` service key.
19
+ * Every method awaits the eager open, so a failed init rejects loudly at
20
+ * call time with the original error.
21
+ */
22
+ export class PiDurableAgent {
23
+ config;
24
+ openPromise;
25
+ harness;
26
+ rootPromise;
27
+ constructor(config) {
28
+ this.config = config;
29
+ this.openPromise = this.open();
30
+ }
31
+ async open() {
32
+ const storage = await openNodeSqliteStorage(this.config.path, { busyTimeoutMs: BUSY_TIMEOUT_MS });
33
+ const models = createModels();
34
+ if (this.config.baseUrl !== undefined) {
35
+ models.setProvider(createRelayProvider(this.config));
36
+ }
37
+ const harness = await Harness.open(storage, {
38
+ models,
39
+ registry: createEngineRegistry(),
40
+ env: (target) => new NodeExecutionEnv({ cwd: target.cwd ?? this.config.cwd }),
41
+ }, BACKGROUND_CONTEXT);
42
+ this.harness = harness;
43
+ await harness.resume();
44
+ }
45
+ /** Resolves once the harness is open; rejections carry the init error. */
46
+ async ready() {
47
+ await this.openPromise;
48
+ }
49
+ async harnessOf() {
50
+ await this.openPromise;
51
+ const harness = this.harness;
52
+ if (harness === undefined)
53
+ throw new Error('[pi-durable] harness failed to open');
54
+ return harness;
55
+ }
56
+ async root() {
57
+ const harness = await this.harnessOf();
58
+ this.rootPromise ??= this.openRoot(harness);
59
+ return await this.rootPromise;
60
+ }
61
+ async openRoot(harness) {
62
+ const existing = await this.findExistingRoot(harness);
63
+ if (existing !== undefined)
64
+ return existing;
65
+ const agent = {
66
+ extensions: [CodingTools],
67
+ ...(this.config.baseUrl !== undefined
68
+ ? { model: { provider: this.config.providerId, modelId: this.config.modelId } }
69
+ : {}),
70
+ ...(this.config.thinkingLevel !== undefined ? { thinkingLevel: this.config.thinkingLevel } : {}),
71
+ ...(this.config.instructions !== undefined ? { instructions: this.config.instructions } : {}),
72
+ };
73
+ return await harness.root(BACKGROUND_CONTEXT, { agent });
74
+ }
75
+ async findExistingRoot(harness) {
76
+ try {
77
+ return await harness.conversation(ROOT_CONVERSATION_ID, BACKGROUND_CONTEXT) ?? undefined;
78
+ }
79
+ catch {
80
+ return undefined;
81
+ }
82
+ }
83
+ assertGenerationConfigured() {
84
+ if (this.config.baseUrl === undefined) {
85
+ throw new Error('[pi-durable-not-configured] no baseUrl configured — generation is unavailable. '
86
+ + 'Set config.baseUrl (and apiKeyEnv) on the hy-sde-pi-durable row; passive writes and tasks still work.');
87
+ }
88
+ }
89
+ /**
90
+ * Submit user input to the root conversation. Exactly-once per `requestId`
91
+ * (scoped to the conversation); the run continues in the background.
92
+ */
93
+ async submitInput(input, options = {}) {
94
+ this.assertGenerationConfigured();
95
+ const root = await this.root();
96
+ const draft = {
97
+ type: 'input',
98
+ content: input,
99
+ ...(options.requestId !== undefined ? { requestId: options.requestId } : {}),
100
+ ...(options.whenBusy !== undefined ? { whenBusy: options.whenBusy } : {}),
101
+ };
102
+ const submission = await root.submit(draft, BACKGROUND_CONTEXT);
103
+ const record = await submission.status(BACKGROUND_CONTEXT);
104
+ return { submissionId: String(submission.id), record };
105
+ }
106
+ /**
107
+ * Admit a passive entry write to the root conversation — durable
108
+ * bookkeeping that never triggers a generation run.
109
+ */
110
+ async writeEntry(kind, data, requestId) {
111
+ const root = await this.root();
112
+ const draft = {
113
+ type: 'write',
114
+ entry: { kind, data },
115
+ ...(requestId !== undefined ? { requestId } : {}),
116
+ };
117
+ const submission = await root.submit(draft, BACKGROUND_CONTEXT);
118
+ const record = await submission.status(BACKGROUND_CONTEXT);
119
+ return { submissionId: String(submission.id), record };
120
+ }
121
+ /** Resolve one submission record by id (undefined when unknown). */
122
+ async submissionRecord(id) {
123
+ const harness = await this.harnessOf();
124
+ const submission = await harness.submission(Number(id), BACKGROUND_CONTEXT);
125
+ if (submission === undefined)
126
+ return undefined;
127
+ return await submission.status(BACKGROUND_CONTEXT);
128
+ }
129
+ /** Newest-first fork-aware page of the root conversation's history. */
130
+ async history(limit, cursor) {
131
+ const root = await this.root();
132
+ return await root.entries({}, limit, cursor, BACKGROUND_CONTEXT);
133
+ }
134
+ /** Newest-first page of any conversation's history (used for forks). */
135
+ async historyOf(conversationId, limit, cursor) {
136
+ const harness = await this.harnessOf();
137
+ const conversation = await harness.conversation(Number(conversationId), BACKGROUND_CONTEXT);
138
+ if (conversation === undefined) {
139
+ throw new Error(`[pi-durable-unknown-conversation] no conversation ${conversationId}`);
140
+ }
141
+ return await conversation.entries({}, limit, cursor, BACKGROUND_CONTEXT);
142
+ }
143
+ /** Fork the root conversation at an entry; history up to `entryId` is inherited. */
144
+ async forkFrom(entryId, options = {}) {
145
+ const root = await this.root();
146
+ const conversation = await root.fork(Number(entryId), {
147
+ ownership: { kind: 'ownerless' },
148
+ ...(options.instructions !== undefined ? { agent: { instructions: options.instructions } } : {}),
149
+ }, BACKGROUND_CONTEXT);
150
+ return { conversationId: String(conversation.id) };
151
+ }
152
+ /** Abort the root conversation's ordinary scope and resolve when idle. */
153
+ async abortRoot() {
154
+ const root = await this.root();
155
+ await root.abort(BACKGROUND_CONTEXT);
156
+ }
157
+ /** Point-in-time status of the engine. */
158
+ async status() {
159
+ const harness = await this.harnessOf();
160
+ const root = await this.root();
161
+ const inspection = await harness.inspect(BACKGROUND_CONTEXT);
162
+ return {
163
+ rootConversationId: String(root.id),
164
+ inspection,
165
+ generationConfigured: this.config.baseUrl !== undefined,
166
+ };
167
+ }
168
+ /** Seal admission, settle commits, close storage. Idempotent. */
169
+ async close() {
170
+ try {
171
+ await this.openPromise;
172
+ }
173
+ catch {
174
+ return; // init failed: nothing to close
175
+ }
176
+ const harness = this.harness;
177
+ this.harness = undefined;
178
+ this.rootPromise = undefined;
179
+ if (harness !== undefined) {
180
+ await harness.close(BACKGROUND_CONTEXT);
181
+ }
182
+ }
183
+ }
184
+ /** The engine's registry: the CodingTools toolset installed by default. */
185
+ function createEngineRegistry() {
186
+ const registry = createRegistry();
187
+ registry.install(CodingTools);
188
+ return registry;
189
+ }
190
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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O,CAAC,WAAW,CAAC,CAAA;IAC7B,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Configuration resolution for the pi-durable engine plugin.
3
+ * @module
4
+ */
5
+ /** Thinking levels accepted on the row (`AgentChange.thinkingLevel`). */
6
+ export type PiDurableThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
7
+ /** Raw plugin configuration as accepted from the cordis row. */
8
+ export interface PiDurablePluginConfig {
9
+ /** SQLite database path (default: `<DSH_HOME|~/.dsh>/storages/pi-agent.sqlite`). */
10
+ path?: string;
11
+ /** OpenAI-compatible endpoint base URL; unset = write-only mode (no generation). */
12
+ baseUrl?: string;
13
+ /** Environment variable carrying the relay API key (default `PI_DURABLE_API_KEY`). */
14
+ apiKeyEnv?: string;
15
+ /** Inline API key (development only; prefer `apiKeyEnv`). */
16
+ apiKey?: string;
17
+ /** Provider id registered into the pi-ai model registry (default `dsh-relay`). */
18
+ providerId?: string;
19
+ /** Provider display name (default `DSH Relay`). */
20
+ providerName?: string;
21
+ /** Model id sent to the relay (default `default`). */
22
+ modelId?: string;
23
+ /** Model display name (default: the model id). */
24
+ modelName?: string;
25
+ /** Wire API: `openai-completions` (default) or `openai-responses`. */
26
+ api?: 'openai-completions' | 'openai-responses';
27
+ /** Advertised context window (default 200000). */
28
+ contextWindow?: number;
29
+ /** Advertised max output tokens (default 8192). */
30
+ maxTokens?: number;
31
+ /** Working directory for the durable agent's coding tools (default: process cwd). */
32
+ cwd?: string;
33
+ /** Instructions applied when the root conversation is first created. */
34
+ instructions?: string;
35
+ /** Thinking level for the root agent (default unset → provider default). */
36
+ thinkingLevel?: PiDurableThinkingLevel;
37
+ }
38
+ /** Fully resolved engine configuration. */
39
+ export interface ResolvedPiDurableConfig {
40
+ readonly path: string;
41
+ readonly baseUrl: string | undefined;
42
+ readonly apiKeyEnv: string;
43
+ readonly apiKey: string | undefined;
44
+ readonly providerId: string;
45
+ readonly providerName: string;
46
+ readonly modelId: string;
47
+ readonly modelName: string;
48
+ readonly api: 'openai-completions' | 'openai-responses';
49
+ readonly contextWindow: number;
50
+ readonly maxTokens: number;
51
+ readonly cwd: string;
52
+ readonly instructions: string | undefined;
53
+ readonly thinkingLevel: PiDurableThinkingLevel | undefined;
54
+ }
55
+ /** Default database path under the DSH home (env `DSH_HOME`, else `~/.dsh`). */
56
+ export declare function defaultPiDurableDbPath(): string;
57
+ /** Resolve row defaults into the immutable runtime config. */
58
+ export declare function resolvePiDurableConfig(config: PiDurablePluginConfig): ResolvedPiDurableConfig;
59
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,yEAAyE;AACzE,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAA;AAEpG,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,GAAG,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IAC/C,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,sBAAsB,CAAA;CACvC;AAED,2CAA2C;AAC3C,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,aAAa,EAAE,sBAAsB,GAAG,SAAS,CAAA;CAC3D;AAED,gFAAgF;AAChF,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAQD,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,uBAAuB,CAmB7F"}
package/dist/config.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Configuration resolution for the pi-durable engine plugin.
3
+ * @module
4
+ */
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ /** Default database path under the DSH home (env `DSH_HOME`, else `~/.dsh`). */
8
+ export function defaultPiDurableDbPath() {
9
+ const dshHome = process.env.DSH_HOME ?? path.join(os.homedir(), '.dsh');
10
+ return path.join(dshHome, 'storages', 'pi-agent.sqlite');
11
+ }
12
+ /** Trim a configured URL; empty/whitespace counts as unset. */
13
+ function normalizeBaseUrl(baseUrl) {
14
+ const trimmed = baseUrl?.trim();
15
+ return trimmed === undefined || trimmed === '' ? undefined : trimmed;
16
+ }
17
+ /** Resolve row defaults into the immutable runtime config. */
18
+ export function resolvePiDurableConfig(config) {
19
+ const api = config.api === 'openai-responses' ? 'openai-responses' : 'openai-completions';
20
+ const modelId = config.modelId ?? 'default';
21
+ return {
22
+ path: config.path ?? defaultPiDurableDbPath(),
23
+ baseUrl: normalizeBaseUrl(config.baseUrl),
24
+ apiKeyEnv: config.apiKeyEnv ?? 'PI_DURABLE_API_KEY',
25
+ apiKey: config.apiKey,
26
+ providerId: config.providerId ?? 'dsh-relay',
27
+ providerName: config.providerName ?? 'DSH Relay',
28
+ modelId,
29
+ modelName: config.modelName ?? modelId,
30
+ api,
31
+ contextWindow: config.contextWindow ?? 200_000,
32
+ maxTokens: config.maxTokens ?? 8_192,
33
+ cwd: config.cwd ?? process.cwd(),
34
+ instructions: config.instructions,
35
+ thinkingLevel: config.thinkingLevel,
36
+ };
37
+ }
38
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAuD5B,gFAAgF;AAChF,MAAM,UAAU,sBAAsB;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAA;IACvE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAA;AAC1D,CAAC;AAED,+DAA+D;AAC/D,SAAS,gBAAgB,CAAC,OAA2B;IACnD,MAAM,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,CAAA;IAC/B,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAA;AACtE,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,sBAAsB,CAAC,MAA6B;IAClE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAA;IACzF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,SAAS,CAAA;IAC3C,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,sBAAsB,EAAE;QAC7C,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC;QACzC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,oBAAoB;QACnD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,WAAW;QAC5C,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,WAAW;QAChD,OAAO;QACP,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,OAAO;QACtC,GAAG;QACH,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,OAAO;QAC9C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;QACpC,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;QAChC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAA;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @hy-sde-org/dsh-pi-durable — the durable-agent engine plugin for DeepSeek
3
+ * Harness. Publishes the `piDurableAgent` service: a pi-durable Harness over
4
+ * a SQLite storage backend with an OpenAI-compatible relay provider, plus a
5
+ * narrow facade (submit / write / history / fork / abort / status) that the
6
+ * model-facing tools in @hy-sde-org/dsh-tool-pi-durable consume.
7
+ * @module @hy-sde-org/dsh-pi-durable
8
+ */
9
+ export { SERVICE_PI_DURABLE, default as plugin } from './plugin.ts';
10
+ export type { Config } from './plugin.ts';
11
+ export { defaultPiDurableDbPath, resolvePiDurableConfig, type PiDurablePluginConfig, type PiDurableThinkingLevel, type ResolvedPiDurableConfig, } from './config.ts';
12
+ export { createRelayProvider } from './provider.ts';
13
+ export { PiDurableAgent, type PiDurableStatus, type RootSubmissionOutcome } from './agent.ts';
14
+ export type { JsonValue } from '@earendil-works/chord';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AACnE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAC7F,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @hy-sde-org/dsh-pi-durable — the durable-agent engine plugin for DeepSeek
3
+ * Harness. Publishes the `piDurableAgent` service: a pi-durable Harness over
4
+ * a SQLite storage backend with an OpenAI-compatible relay provider, plus a
5
+ * narrow facade (submit / write / history / fork / abort / status) that the
6
+ * model-facing tools in @hy-sde-org/dsh-tool-pi-durable consume.
7
+ * @module @hy-sde-org/dsh-pi-durable
8
+ */
9
+ export { SERVICE_PI_DURABLE, default as plugin } from "./plugin.js";
10
+ export { defaultPiDurableDbPath, resolvePiDurableConfig, } from "./config.js";
11
+ export { createRelayProvider } from "./provider.js";
12
+ export { PiDurableAgent } from "./agent.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAIvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,cAAc,EAAoD,MAAM,YAAY,CAAA"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Cordis host-plane plugin publishing the `piDurableAgent` service: the
3
+ * durable-agent engine over @earendil-works/pi-durable. The service is
4
+ * provided synchronously (a facade whose first use awaits the eager open),
5
+ * so agent presets resolve it at apply time without racing the SQLite init.
6
+ * @module
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ import z from '@deepseek-ai/schemastery';
10
+ import { type PiDurablePluginConfig } from './config.ts';
11
+ /** Name of the published service (consumed by @hy-sde-org/dsh-tool-pi-durable). */
12
+ export declare const SERVICE_PI_DURABLE = "piDurableAgent";
13
+ /** Cordis plugin name. */
14
+ export declare const name = "pi-durable";
15
+ /** No host services injected: the engine owns its storage medium outright. */
16
+ export declare const inject: readonly string[];
17
+ /** Plugin configuration (see the row comments in cordis.patch.yml). */
18
+ export type Config = PiDurablePluginConfig;
19
+ /** Plugin config schema; every field is optional with engine defaults. */
20
+ export declare const Config: z<Config>;
21
+ /**
22
+ * Provide the engine facade and tie its teardown to the plugin fiber, so an
23
+ * unload (HMR included) closes the harness and storage with it.
24
+ * @param ctx - host-plane plugin context.
25
+ * @param config - validated row configuration.
26
+ */
27
+ export declare function apply(ctx: Context, config: Config): void;
28
+ declare const _default: {
29
+ name: string;
30
+ inject: readonly string[];
31
+ apply: typeof apply;
32
+ };
33
+ export default _default;
34
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEhF,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,eAAe,CAAA;AAEhC,8EAA8E;AAC9E,eAAO,MAAM,MAAM,EAAE,SAAS,MAAM,EAAO,CAAA;AAE3C,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,qBAAqB,CAAA;AAE1C,0EAA0E;AAC1E,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAuB3B,CAAA;AAEF;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAOxD;;;;;;AAED,wBAAsC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Cordis host-plane plugin publishing the `piDurableAgent` service: the
3
+ * durable-agent engine over @earendil-works/pi-durable. The service is
4
+ * provided synchronously (a facade whose first use awaits the eager open),
5
+ * so agent presets resolve it at apply time without racing the SQLite init.
6
+ * @module
7
+ */
8
+ import z from '@deepseek-ai/schemastery';
9
+ import { PiDurableAgent } from "./agent.js";
10
+ import { resolvePiDurableConfig } from "./config.js";
11
+ /** Name of the published service (consumed by @hy-sde-org/dsh-tool-pi-durable). */
12
+ export const SERVICE_PI_DURABLE = 'piDurableAgent';
13
+ /** Cordis plugin name. */
14
+ export const name = 'pi-durable';
15
+ /** No host services injected: the engine owns its storage medium outright. */
16
+ export const inject = [];
17
+ /** Plugin config schema; every field is optional with engine defaults. */
18
+ export const Config = z.object({
19
+ path: z.string(),
20
+ baseUrl: z.string(),
21
+ apiKeyEnv: z.string().default('PI_DURABLE_API_KEY'),
22
+ apiKey: z.string(),
23
+ providerId: z.string().default('dsh-relay'),
24
+ providerName: z.string(),
25
+ modelId: z.string().default('default'),
26
+ modelName: z.string(),
27
+ api: z.union(['openai-completions', 'openai-responses']),
28
+ contextWindow: z.number().step(1).min(1),
29
+ maxTokens: z.number().step(1).min(1),
30
+ cwd: z.string(),
31
+ instructions: z.string(),
32
+ thinkingLevel: z.union([
33
+ 'off',
34
+ 'minimal',
35
+ 'low',
36
+ 'medium',
37
+ 'high',
38
+ 'xhigh',
39
+ 'max',
40
+ ]),
41
+ });
42
+ /**
43
+ * Provide the engine facade and tie its teardown to the plugin fiber, so an
44
+ * unload (HMR included) closes the harness and storage with it.
45
+ * @param ctx - host-plane plugin context.
46
+ * @param config - validated row configuration.
47
+ */
48
+ export function apply(ctx, config) {
49
+ const resolved = resolvePiDurableConfig(config);
50
+ const agent = new PiDurableAgent(resolved);
51
+ ctx.provide(SERVICE_PI_DURABLE, agent);
52
+ ctx.effect(() => async () => {
53
+ await agent.close();
54
+ }, 'pi-durable.close()');
55
+ }
56
+ export default { name, inject, apply };
57
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAA8B,MAAM,aAAa,CAAA;AAEhF,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KG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAC/C,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAA;IAC1C,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;IACtC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE;QAC1B,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC,EAAE,oBAAoB,CAAC,CAAA;AAC1B,CAAC;AAED,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The OpenAI-compatible relay provider registered into the pi-ai model
3
+ * registry. Auth resolves lazily at request time from the configured env
4
+ * variable (or inline key), so rotating the secret needs no remount.
5
+ * @module
6
+ */
7
+ import { type Api, type Provider } from '@earendil-works/pi-ai';
8
+ import type { ResolvedPiDurableConfig } from './config.ts';
9
+ /** Build the relay provider from resolved config (only called with a `baseUrl`). */
10
+ export declare function createRelayProvider(config: ResolvedPiDurableConfig): Provider<Api>;
11
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,GAAG,EAGR,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAiB1D,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,GAAG,QAAQ,CAAC,GAAG,CAAC,CA6BlF"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The OpenAI-compatible relay provider registered into the pi-ai model
3
+ * registry. Auth resolves lazily at request time from the configured env
4
+ * variable (or inline key), so rotating the secret needs no remount.
5
+ * @module
6
+ */
7
+ import { createProvider, } from '@earendil-works/pi-ai';
8
+ import { openAICompletionsApi } from '@earendil-works/pi-ai/api/openai-completions.lazy';
9
+ import { openAIResponsesApi } from '@earendil-works/pi-ai/api/openai-responses.lazy';
10
+ /**
11
+ * An {@link ApiKeyAuth} that resolves from config/env at request time. No
12
+ * credential store is consulted: the row's env var is the single source.
13
+ */
14
+ function configApiKeyAuth(name, resolve) {
15
+ return {
16
+ name,
17
+ async resolve() {
18
+ const key = resolve();
19
+ if (key === undefined || key === '')
20
+ return undefined;
21
+ return { auth: { apiKey: key }, source: name };
22
+ },
23
+ };
24
+ }
25
+ /** Build the relay provider from resolved config (only called with a `baseUrl`). */
26
+ export function createRelayProvider(config) {
27
+ if (config.baseUrl === undefined) {
28
+ throw new Error('[pi-durable-not-configured] createRelayProvider requires a baseUrl');
29
+ }
30
+ const model = {
31
+ id: config.modelId,
32
+ name: config.modelName,
33
+ api: config.api,
34
+ provider: config.providerId,
35
+ baseUrl: config.baseUrl,
36
+ input: ['text'],
37
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
38
+ reasoning: true,
39
+ contextWindow: config.contextWindow,
40
+ maxTokens: config.maxTokens,
41
+ };
42
+ return createProvider({
43
+ id: config.providerId,
44
+ name: config.providerName,
45
+ baseUrl: config.baseUrl,
46
+ auth: {
47
+ apiKey: configApiKeyAuth(`${config.providerName} API key`, () => config.apiKey ?? process.env[config.apiKeyEnv]),
48
+ },
49
+ models: [model],
50
+ api: config.api === 'openai-responses' ? openAIResponsesApi() : openAICompletionsApi(),
51
+ });
52
+ }
53
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,GAKf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MA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E,gBAAgB,CACtB,GAAG,MAAM,CAAC,YAAY,UAAU,EAChC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CACrD;SACF;QACD,MAAM,EAAE,CAAC,KAAK,CAAC;QACf,GAAG,EAAE,MAAM,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,EAAE;KACvF,CAAC,CAAA;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@hy-sde-org/dsh-pi-durable",
3
+ "version": "0.2.0-rc.2",
4
+ "description": "The durable-agent engine for DeepSeek Harness: a host-plane cordis service mounting @earendil-works/pi-durable (conversations, exactly-once submissions, fork-at-entry, tasks) over a SQLite storage backend with an OpenAI-compatible relay provider.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./cordis.patch.yml": "./cordis.patch.yml",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "cordis.patch.yml",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "engines": {
23
+ "node": "^22.19.0 || >=24.0.0"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/hy-sde/dsh-plugins.git",
31
+ "directory": "dsh-pi-durable/packages/pi-durable"
32
+ },
33
+ "license": "MIT",
34
+ "dsh": {
35
+ "bundle": {
36
+ "patch": "./cordis.patch.yml"
37
+ }
38
+ },
39
+ "dependencies": {
40
+ "@earendil-works/chord": "^1.0.0",
41
+ "@earendil-works/pi-ai": "^1.0.0",
42
+ "@earendil-works/pi-durable": "^1.0.0",
43
+ "@deepseek-ai/schemastery": "~3.18.4"
44
+ },
45
+ "peerDependencies": {
46
+ "@deepseek-ai/cordis": "~4.0.4"
47
+ },
48
+ "devDependencies": {
49
+ "@deepseek-ai/cordis": "~4.0.4",
50
+ "@deepseek-ai/schemastery": "~3.18.4",
51
+ "@types/node": "^24.13.3",
52
+ "typescript": "^5.9.3",
53
+ "vitest": "^3.2.7"
54
+ },
55
+ "keywords": [
56
+ "deepseek",
57
+ "agent",
58
+ "harness",
59
+ "dsh-plugin",
60
+ "pi-durable",
61
+ "durable",
62
+ "durable-agent"
63
+ ],
64
+ "scripts": {
65
+ "clean": "rm -rf dist",
66
+ "build": "tsc -p tsconfig.build.json",
67
+ "check": "tsc -p tsconfig.json --noEmit",
68
+ "test": "vitest run"
69
+ }
70
+ }