@dsh-cc/subagent-resume-pins 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +48 -0
- package/lib/fingerprint.d.ts +25 -0
- package/lib/fingerprint.d.ts.map +1 -0
- package/lib/fingerprint.js +49 -0
- package/lib/fingerprint.js.map +1 -0
- package/lib/gate.d.ts +98 -0
- package/lib/gate.d.ts.map +1 -0
- package/lib/gate.js +218 -0
- package/lib/gate.js.map +1 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/overlay.d.ts +37 -0
- package/lib/overlay.d.ts.map +1 -0
- package/lib/overlay.js +80 -0
- package/lib/overlay.js.map +1 -0
- package/lib/pin.d.ts +129 -0
- package/lib/pin.d.ts.map +1 -0
- package/lib/pin.js +211 -0
- package/lib/pin.js.map +1 -0
- package/lib/plugin.d.ts +67 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +354 -0
- package/lib/plugin.js.map +1 -0
- package/lib/policy.d.ts +41 -0
- package/lib/policy.d.ts.map +1 -0
- package/lib/policy.js +45 -0
- package/lib/policy.js.map +1 -0
- package/lib/serialize.d.ts +27 -0
- package/lib/serialize.d.ts.map +1 -0
- package/lib/serialize.js +38 -0
- package/lib/serialize.js.map +1 -0
- package/lib/store.d.ts +62 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +133 -0
- package/lib/store.js.map +1 -0
- package/package.json +78 -0
package/lib/gate.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAgFH,gFAAgF;AAChF,SAAS,UAAU,CAAC,MAAoB,EAAE,OAA2B;IACnE,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ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AC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,MAAM,EAAE,CAAA;IAEf,SAAS,MAAM,CAAC,QAAoC,EAAE;QACpD,OAAO;YACL,MAAM,EAAE,MAAM;YACd,OAAO;YACP,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;YACtE,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;SACjE,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned resume descriptors for continuable background subagents.
|
|
3
|
+
*
|
|
4
|
+
* This unit ships the pin schema + tolerant reader/writer, the per-child
|
|
5
|
+
* {@link PinStore}, the definition fingerprint utilities, the pure gate and
|
|
6
|
+
* overlay layers, the `subagents-resume` policy namespace, and the cordis
|
|
7
|
+
* plugin (gate + overlay + notices + settings). The spawn capture lives in
|
|
8
|
+
* `@dsh-cc/subagent-task` (it is cordis-facing on the Task tool side).
|
|
9
|
+
*
|
|
10
|
+
* @module @dsh-cc/subagent-resume-pins
|
|
11
|
+
*/
|
|
12
|
+
export { PinParseError, parsePin, writePin, canonicalJson, PIN_VERSION } from './pin.ts';
|
|
13
|
+
export type { ResumePin, ResumePinDraft, PinDefinition, PinDefinitionSource, PinEffective, PinModelSelector, PinMode, PinResume, PinToolFilter, PinWorkspace, ModelSelectorVia, } from './pin.ts';
|
|
14
|
+
export { PinStore, type CorruptPin } from './store.ts';
|
|
15
|
+
export { definitionFingerprint, personaHash, sha256Prefixed } from './fingerprint.ts';
|
|
16
|
+
export { RESUME_POLICY_DEFAULTS, RESUME_POLICY_NAMESPACE, readResumePolicy, type OnDefinitionChanged, type OnUnavailableModel, type OnWorkspaceChanged, type ResumePolicy, } from './policy.ts';
|
|
17
|
+
export { evaluateGate, type DenyCode, type GateDecision, type GateDetailedRoute, type GateEnv, type GateResolvedConfig, } from './gate.ts';
|
|
18
|
+
export { PinBlockedError, applyPinOverlay } from './overlay.ts';
|
|
19
|
+
export { RESUME_PIN_STORE, ResumePolicySchema, apply as applyResumePinsPlugin, name as resumePinsPluginName, type ResumePinsPluginConfig, } from './plugin.ts';
|
|
20
|
+
export { apply, name } from './plugin.ts';
|
|
21
|
+
export type { OverlayTuple } from './pin.ts';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACxF,YAAY,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,IAAI,qBAAqB,EAC9B,IAAI,IAAI,oBAAoB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinned resume descriptors for continuable background subagents.
|
|
3
|
+
*
|
|
4
|
+
* This unit ships the pin schema + tolerant reader/writer, the per-child
|
|
5
|
+
* {@link PinStore}, the definition fingerprint utilities, the pure gate and
|
|
6
|
+
* overlay layers, the `subagents-resume` policy namespace, and the cordis
|
|
7
|
+
* plugin (gate + overlay + notices + settings). The spawn capture lives in
|
|
8
|
+
* `@dsh-cc/subagent-task` (it is cordis-facing on the Task tool side).
|
|
9
|
+
*
|
|
10
|
+
* @module @dsh-cc/subagent-resume-pins
|
|
11
|
+
*/
|
|
12
|
+
export { PinParseError, parsePin, writePin, canonicalJson, PIN_VERSION } from "./pin.js";
|
|
13
|
+
export { PinStore } from "./store.js";
|
|
14
|
+
export { definitionFingerprint, personaHash, sha256Prefixed } from "./fingerprint.js";
|
|
15
|
+
export { RESUME_POLICY_DEFAULTS, RESUME_POLICY_NAMESPACE, readResumePolicy, } from "./policy.js";
|
|
16
|
+
export { evaluateGate, } from "./gate.js";
|
|
17
|
+
export { PinBlockedError, applyPinOverlay } from "./overlay.js";
|
|
18
|
+
export { RESUME_PIN_STORE, ResumePolicySchema, apply as applyResumePinsPlugin, name as resumePinsPluginName, } from "./plugin.js";
|
|
19
|
+
// cordis-plugin-loader unwrapExports mounts the package root: it needs the
|
|
20
|
+
// canonical `apply`/`name`, not just the aliases above.
|
|
21
|
+
export { apply, name } from "./plugin.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAcxF,OAAO,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,GAKjB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,YAAY,GAMb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,IAAI,qBAAqB,EAC9B,IAAI,IAAI,oBAAoB,GAE7B,MAAM,aAAa,CAAA;AACpB,2EAA2E;AAC3E,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA"}
|
package/lib/overlay.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request-time overlay (plan §4.8): apply one pin's pinned runtime tuple onto
|
|
3
|
+
* a resolved request config AFTER the waterfall's `next()`, with explicit
|
|
4
|
+
* presence semantics — a pinned non-`null` field is SET, a pinned `null`
|
|
5
|
+
* field's key is REMOVED (assigning `null` is not absence: `prepareCall`
|
|
6
|
+
* would keep filling its adapter default), and a degraded pin touches only
|
|
7
|
+
* explicitly-present fields.
|
|
8
|
+
*
|
|
9
|
+
* Pure: no cordis, no IO. The `agent/request` listener calls this per turn of
|
|
10
|
+
* a pinned child, so options cannot revert to current defaults on any resume
|
|
11
|
+
* path, including ones that bypass the gate.
|
|
12
|
+
*
|
|
13
|
+
* @module @dsh-cc/subagent-resume-pins/overlay
|
|
14
|
+
*/
|
|
15
|
+
import type { ResumePin } from './pin.ts';
|
|
16
|
+
/** Thrown when a request is built for a blocked child (defense-in-depth). */
|
|
17
|
+
export declare class PinBlockedError extends Error {
|
|
18
|
+
constructor(reason: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Overlay the pin onto one resolved request config.
|
|
22
|
+
* - `resume.state === 'blocked'` → throws {@link PinBlockedError}: an
|
|
23
|
+
* unmonitored resume of a blocked child fails visibly instead of silently
|
|
24
|
+
* substituting.
|
|
25
|
+
* - `resume.overlay` present (gate-evaluated route-current) → applied with
|
|
26
|
+
* the same presence semantics; it is a cache recomputed on every gate
|
|
27
|
+
* evaluation, never authoritative on its own.
|
|
28
|
+
* - Complete pin → the whole pinned tuple, absence included (a pinned-`null`
|
|
29
|
+
* key is removed, not nulled).
|
|
30
|
+
* - Degraded pin (`complete:false`) → only explicitly-present pinned fields.
|
|
31
|
+
* @param resolved - the resolved request config.
|
|
32
|
+
* @param pin - the child's pin.
|
|
33
|
+
* @returns a shallow copy carrying the pin (input untouched — the seed may be
|
|
34
|
+
* frozen), or the input object when the pin contributes nothing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyPinOverlay<T extends Record<string, unknown>>(resolved: T, pin: ResumePin): T;
|
|
37
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,UAAU,CAAA;AAEvD,6EAA6E;AAC7E,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,MAAM,EAAE,MAAM;CAI3B;AA0BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,CAAC,CAajG"}
|
package/lib/overlay.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request-time overlay (plan §4.8): apply one pin's pinned runtime tuple onto
|
|
3
|
+
* a resolved request config AFTER the waterfall's `next()`, with explicit
|
|
4
|
+
* presence semantics — a pinned non-`null` field is SET, a pinned `null`
|
|
5
|
+
* field's key is REMOVED (assigning `null` is not absence: `prepareCall`
|
|
6
|
+
* would keep filling its adapter default), and a degraded pin touches only
|
|
7
|
+
* explicitly-present fields.
|
|
8
|
+
*
|
|
9
|
+
* Pure: no cordis, no IO. The `agent/request` listener calls this per turn of
|
|
10
|
+
* a pinned child, so options cannot revert to current defaults on any resume
|
|
11
|
+
* path, including ones that bypass the gate.
|
|
12
|
+
*
|
|
13
|
+
* @module @dsh-cc/subagent-resume-pins/overlay
|
|
14
|
+
*/
|
|
15
|
+
/** Thrown when a request is built for a blocked child (defense-in-depth). */
|
|
16
|
+
export class PinBlockedError extends Error {
|
|
17
|
+
constructor(reason) {
|
|
18
|
+
super(`resume pin blocked: ${reason}`);
|
|
19
|
+
this.name = 'PinBlockedError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Apply one tuple with presence semantics onto a shallow copy of `resolved`.
|
|
24
|
+
* @param resolved - the config produced by the `agent/request` waterfall.
|
|
25
|
+
* @param tuple - the pinned (or gate-evaluated route-current) tuple.
|
|
26
|
+
*/
|
|
27
|
+
function applyTuple(resolved, tuple) {
|
|
28
|
+
const out = { ...resolved };
|
|
29
|
+
for (const [key, value] of Object.entries(tuple)) {
|
|
30
|
+
if (value === null)
|
|
31
|
+
delete out[key];
|
|
32
|
+
else
|
|
33
|
+
out[key] = value;
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** The pinned tuple a complete pin contributes (its `effective`, verbatim). */
|
|
38
|
+
function pinnedTuple(pin) {
|
|
39
|
+
return {
|
|
40
|
+
provider: pin.effective.provider,
|
|
41
|
+
model: pin.effective.model,
|
|
42
|
+
reasoningEffort: pin.effective.reasoningEffort,
|
|
43
|
+
maxTokens: pin.effective.maxTokens,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Overlay the pin onto one resolved request config.
|
|
48
|
+
* - `resume.state === 'blocked'` → throws {@link PinBlockedError}: an
|
|
49
|
+
* unmonitored resume of a blocked child fails visibly instead of silently
|
|
50
|
+
* substituting.
|
|
51
|
+
* - `resume.overlay` present (gate-evaluated route-current) → applied with
|
|
52
|
+
* the same presence semantics; it is a cache recomputed on every gate
|
|
53
|
+
* evaluation, never authoritative on its own.
|
|
54
|
+
* - Complete pin → the whole pinned tuple, absence included (a pinned-`null`
|
|
55
|
+
* key is removed, not nulled).
|
|
56
|
+
* - Degraded pin (`complete:false`) → only explicitly-present pinned fields.
|
|
57
|
+
* @param resolved - the resolved request config.
|
|
58
|
+
* @param pin - the child's pin.
|
|
59
|
+
* @returns a shallow copy carrying the pin (input untouched — the seed may be
|
|
60
|
+
* frozen), or the input object when the pin contributes nothing.
|
|
61
|
+
*/
|
|
62
|
+
export function applyPinOverlay(resolved, pin) {
|
|
63
|
+
if (pin.resume.state === 'blocked') {
|
|
64
|
+
throw new PinBlockedError(pin.resume.reason ?? 'blocked by the resume gate');
|
|
65
|
+
}
|
|
66
|
+
if (pin.resume.overlay !== undefined)
|
|
67
|
+
return applyTuple(resolved, pin.resume.overlay);
|
|
68
|
+
if (pin.effective.complete)
|
|
69
|
+
return applyTuple(resolved, pinnedTuple(pin));
|
|
70
|
+
// Degraded: set only the fields the spawn explicitly carried.
|
|
71
|
+
const out = { ...resolved };
|
|
72
|
+
out['provider'] = pin.effective.provider;
|
|
73
|
+
out['model'] = pin.effective.model;
|
|
74
|
+
if (pin.effective.reasoningEffort !== null)
|
|
75
|
+
out['reasoningEffort'] = pin.effective.reasoningEffort;
|
|
76
|
+
if (pin.effective.maxTokens !== null)
|
|
77
|
+
out['maxTokens'] = pin.effective.maxTokens;
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,6EAA6E;AAC7E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,MAAc;QACxB,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAoC,QAAW,EAAE,KAAmB;IACrF,MAAM,GAAG,GAA4B,EAAE,GAAG,QAAQ,EAAE,CAAA;IACpD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;;YAC9B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACvB,CAAC;IACD,OAAO,GAAQ,CAAA;AACjB,CAAC;AAED,+EAA+E;AAC/E,SAAS,WAAW,CAAC,GAAc;IACjC,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,QAAQ;QAChC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK;QAC1B,eAAe,EAAE,GAAG,CAAC,SAAS,CAAC,eAAe;QAC9C,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,SAAS;KACnC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAAoC,QAAW,EAAE,GAAc;IAC5F,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,4BAA4B,CAAC,CAAA;IAC9E,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACrF,IAAI,GAAG,CAAC,SAAS,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IACzE,8DAA8D;IAC9D,MAAM,GAAG,GAA4B,EAAE,GAAG,QAAQ,EAAE,CAAA;IACpD,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAA;IACxC,GAAG,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAA;IAClC,IAAI,GAAG,CAAC,SAAS,CAAC,eAAe,KAAK,IAAI;QAAE,GAAG,CAAC,iBAAiB,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,eAAe,CAAA;IAClG,IAAI,GAAG,CAAC,SAAS,CAAC,SAAS,KAAK,IAAI;QAAE,GAAG,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,CAAA;IAChF,OAAO,GAAQ,CAAA;AACjB,CAAC"}
|
package/lib/pin.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume-pin schema v1: the descriptor persisted per continuable background
|
|
3
|
+
* child, plus a tolerant reader and a canonical writer.
|
|
4
|
+
*
|
|
5
|
+
* The pin lives outside the harness's closed descriptor schema and records
|
|
6
|
+
* exactly what a cold resume must restore instead of re-guessing: definition
|
|
7
|
+
* identity, the complete effective request tuple (with explicit `null`
|
|
8
|
+
* presence semantics — a pinned `null` means ABSENT, and absence must be
|
|
9
|
+
* preserved), the model selector provenance, workspace identity, and the
|
|
10
|
+
* derived resume state.
|
|
11
|
+
*
|
|
12
|
+
* Reader contract: unknown fields are ignored (forward compatibility);
|
|
13
|
+
* an unsupported `version`, malformed JSON, or a missing required field
|
|
14
|
+
* throws {@link PinParseError} — callers treat that as fail-closed.
|
|
15
|
+
*
|
|
16
|
+
* @module @dsh-cc/subagent-resume-pins/pin
|
|
17
|
+
*/
|
|
18
|
+
/** The only pin schema version this reader accepts. */
|
|
19
|
+
export declare const PIN_VERSION = 1;
|
|
20
|
+
/** Error thrown for a malformed, incomplete, or unsupported-version pin. */
|
|
21
|
+
export declare class PinParseError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/** The layer a named definition was discovered under. */
|
|
25
|
+
export type PinDefinitionSource = 'project' | 'user' | 'bundled';
|
|
26
|
+
/** How the spawn-time model selector was resolved. */
|
|
27
|
+
export type ModelSelectorVia = 'alias' | 'literal' | 'inherit';
|
|
28
|
+
/** Background mode of the pinned child; constant `continuable-background` today. */
|
|
29
|
+
export type PinMode = 'continuable-background';
|
|
30
|
+
/** Deriving, non-authoritative resume state persisted for the overlay listener. */
|
|
31
|
+
export interface PinResume {
|
|
32
|
+
readonly state: 'ok' | 'blocked';
|
|
33
|
+
readonly reason?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Gate-evaluated route-current tuple (§4.6 step 5): present only while the
|
|
36
|
+
* latest gate evaluation routed the child to a current default route per
|
|
37
|
+
* policy. A cache, never authoritative on its own — every gate evaluation
|
|
38
|
+
* recomputes or clears it.
|
|
39
|
+
*/
|
|
40
|
+
readonly overlay?: OverlayTuple | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** A complete resolved request tuple; `null` means explicitly ABSENT. */
|
|
43
|
+
export interface OverlayTuple {
|
|
44
|
+
readonly provider: string;
|
|
45
|
+
readonly model: string;
|
|
46
|
+
readonly reasoningEffort: string | null;
|
|
47
|
+
readonly maxTokens: number | null;
|
|
48
|
+
}
|
|
49
|
+
/** Discriminated definition identity: `plain` for general-purpose spawns. */
|
|
50
|
+
export type PinDefinition = {
|
|
51
|
+
readonly kind: 'plain';
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'named';
|
|
54
|
+
readonly agentType: string;
|
|
55
|
+
readonly source: PinDefinitionSource;
|
|
56
|
+
/** Canonical fingerprint over parsed frontmatter + persona (§4.4). */
|
|
57
|
+
readonly fingerprint: string;
|
|
58
|
+
/** sha256 of the persona string forwarded at spawn. */
|
|
59
|
+
readonly personaHash: string;
|
|
60
|
+
/** Discovery location for gate-time re-fingerprinting, when file-backed. */
|
|
61
|
+
readonly baseDir?: string | undefined;
|
|
62
|
+
readonly filename?: string | undefined;
|
|
63
|
+
};
|
|
64
|
+
/** Provenance of the spawn-time model selector, atomically resolved. */
|
|
65
|
+
export interface PinModelSelector {
|
|
66
|
+
readonly raw: string;
|
|
67
|
+
readonly via: ModelSelectorVia;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The complete resolved request config. `null` means explicitly ABSENT and
|
|
71
|
+
* absence must be preserved on resume; `complete: false` degrades the pin to
|
|
72
|
+
* explicit-fields-only mode (spawn-time preflight could not resolve the route).
|
|
73
|
+
*/
|
|
74
|
+
export interface PinEffective {
|
|
75
|
+
readonly provider: string;
|
|
76
|
+
readonly model: string;
|
|
77
|
+
readonly reasoningEffort: string | null;
|
|
78
|
+
readonly maxTokens: number | null;
|
|
79
|
+
readonly complete: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Sanitized tool filter as forwarded at spawn. */
|
|
82
|
+
export interface PinToolFilter {
|
|
83
|
+
readonly allow: readonly string[];
|
|
84
|
+
readonly deny: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
/** Workspace/worktree identity captured at spawn. */
|
|
87
|
+
export interface PinWorkspace {
|
|
88
|
+
readonly cwd: string;
|
|
89
|
+
readonly gitDir: string;
|
|
90
|
+
readonly gitCommonDir: string;
|
|
91
|
+
readonly branch: string;
|
|
92
|
+
}
|
|
93
|
+
/** A persisted resume pin, schema version 1. */
|
|
94
|
+
export interface ResumePin {
|
|
95
|
+
readonly version: typeof PIN_VERSION;
|
|
96
|
+
/** Preallocated child id; becomes the child's session id. */
|
|
97
|
+
readonly childId: string;
|
|
98
|
+
readonly parentSessionId: string;
|
|
99
|
+
readonly label: string;
|
|
100
|
+
readonly mode: PinMode;
|
|
101
|
+
readonly createdAt: string;
|
|
102
|
+
readonly definition: PinDefinition;
|
|
103
|
+
readonly modelSelector: PinModelSelector;
|
|
104
|
+
readonly effective: PinEffective;
|
|
105
|
+
readonly toolFilter: PinToolFilter;
|
|
106
|
+
/** Audit metadata only — never enforced at spawn or resume. */
|
|
107
|
+
readonly maxTurns?: number | undefined;
|
|
108
|
+
readonly workspace: PinWorkspace;
|
|
109
|
+
readonly resume: PinResume;
|
|
110
|
+
readonly lastNotice?: string | undefined;
|
|
111
|
+
}
|
|
112
|
+
/** A structural clone of a pin draft mutable by {@link PinStore.update}. */
|
|
113
|
+
export type ResumePinDraft = {
|
|
114
|
+
-readonly [K in keyof ResumePin]: ResumePin[K];
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Parse a pin from its JSON text. Tolerant of unknown fields on the pin and
|
|
118
|
+
* its nested objects; throws {@link PinParseError} for malformed JSON, an
|
|
119
|
+
* unsupported `version`, or a missing required field.
|
|
120
|
+
*/
|
|
121
|
+
export declare function parsePin(text: string): ResumePin;
|
|
122
|
+
/** Stable JSON.stringify: object keys in sorted order, recursively. */
|
|
123
|
+
export declare function canonicalJson(value: unknown): string;
|
|
124
|
+
/**
|
|
125
|
+
* Serialize a pin to its canonical JSON form (sorted keys), matching what the
|
|
126
|
+
* store writes atomically to `<pinsRoot>/<childId>.json`.
|
|
127
|
+
*/
|
|
128
|
+
export declare function writePin(pin: ResumePin): string;
|
|
129
|
+
//# sourceMappingURL=pin.d.ts.map
|
package/lib/pin.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E,MAAM,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAA;IAClC,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAA;IACxC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;IAChC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAA;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACzC;AAED,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,UAAU,CAAC,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC;CAC/C,CAAA;AA0ID;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CA6BhD;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWpD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAE/C"}
|
package/lib/pin.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume-pin schema v1: the descriptor persisted per continuable background
|
|
3
|
+
* child, plus a tolerant reader and a canonical writer.
|
|
4
|
+
*
|
|
5
|
+
* The pin lives outside the harness's closed descriptor schema and records
|
|
6
|
+
* exactly what a cold resume must restore instead of re-guessing: definition
|
|
7
|
+
* identity, the complete effective request tuple (with explicit `null`
|
|
8
|
+
* presence semantics — a pinned `null` means ABSENT, and absence must be
|
|
9
|
+
* preserved), the model selector provenance, workspace identity, and the
|
|
10
|
+
* derived resume state.
|
|
11
|
+
*
|
|
12
|
+
* Reader contract: unknown fields are ignored (forward compatibility);
|
|
13
|
+
* an unsupported `version`, malformed JSON, or a missing required field
|
|
14
|
+
* throws {@link PinParseError} — callers treat that as fail-closed.
|
|
15
|
+
*
|
|
16
|
+
* @module @dsh-cc/subagent-resume-pins/pin
|
|
17
|
+
*/
|
|
18
|
+
/** The only pin schema version this reader accepts. */
|
|
19
|
+
export const PIN_VERSION = 1;
|
|
20
|
+
/** Error thrown for a malformed, incomplete, or unsupported-version pin. */
|
|
21
|
+
export class PinParseError extends Error {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(`resume pin parse error: ${message}`);
|
|
24
|
+
this.name = 'PinParseError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function asRecord(value) {
|
|
28
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
29
|
+
throw new PinParseError('expected an object');
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function requiredString(record, field) {
|
|
34
|
+
const value = record[field];
|
|
35
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
36
|
+
throw new PinParseError(`missing required string field "${field}"`);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function requiredNumber(record, field) {
|
|
41
|
+
const value = record[field];
|
|
42
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
43
|
+
throw new PinParseError(`missing required number field "${field}"`);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function optionalString(record, field) {
|
|
48
|
+
const value = record[field];
|
|
49
|
+
if (value === undefined)
|
|
50
|
+
return undefined;
|
|
51
|
+
if (typeof value !== 'string')
|
|
52
|
+
throw new PinParseError(`field "${field}" must be a string`);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function requiredEnum(record, field, values) {
|
|
56
|
+
const value = record[field];
|
|
57
|
+
if (typeof value !== 'string' || !values.includes(value)) {
|
|
58
|
+
throw new PinParseError(`field "${field}" must be one of ${values.join('|')}`);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function stringArray(record, field) {
|
|
63
|
+
const value = record[field];
|
|
64
|
+
if (value === undefined)
|
|
65
|
+
return [];
|
|
66
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string')) {
|
|
67
|
+
throw new PinParseError(`field "${field}" must be an array of strings`);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
function parseDefinition(value) {
|
|
72
|
+
const record = asRecord(value);
|
|
73
|
+
const kind = requiredEnum(record, 'kind', ['plain', 'named']);
|
|
74
|
+
if (kind === 'plain')
|
|
75
|
+
return { kind: 'plain' };
|
|
76
|
+
const source = requiredEnum(record, 'source', ['project', 'user', 'bundled']);
|
|
77
|
+
return {
|
|
78
|
+
kind: 'named',
|
|
79
|
+
agentType: requiredString(record, 'agentType'),
|
|
80
|
+
source,
|
|
81
|
+
fingerprint: requiredString(record, 'fingerprint'),
|
|
82
|
+
personaHash: requiredString(record, 'personaHash'),
|
|
83
|
+
baseDir: optionalString(record, 'baseDir'),
|
|
84
|
+
filename: optionalString(record, 'filename'),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function requiredBoolean(record, field) {
|
|
88
|
+
const value = record[field];
|
|
89
|
+
if (typeof value !== 'boolean') {
|
|
90
|
+
throw new PinParseError(`missing required boolean field "${field}"`);
|
|
91
|
+
}
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
function parseEffective(value) {
|
|
95
|
+
const record = asRecord(value);
|
|
96
|
+
// Presence is contractual (plan §4.2): a missing knob is a parse error,
|
|
97
|
+
// only an explicit `null` records absence.
|
|
98
|
+
if (!('reasoningEffort' in record))
|
|
99
|
+
throw new PinParseError('missing required field "reasoningEffort"');
|
|
100
|
+
if (!('maxTokens' in record))
|
|
101
|
+
throw new PinParseError('missing required field "maxTokens"');
|
|
102
|
+
return {
|
|
103
|
+
provider: requiredString(record, 'provider'),
|
|
104
|
+
model: requiredString(record, 'model'),
|
|
105
|
+
reasoningEffort: record.reasoningEffort === null ? null : requiredString(record, 'reasoningEffort'),
|
|
106
|
+
maxTokens: record.maxTokens === null ? null : requiredNumber(record, 'maxTokens'),
|
|
107
|
+
complete: requiredBoolean(record, 'complete'),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function parseModelSelector(value) {
|
|
111
|
+
const record = asRecord(value);
|
|
112
|
+
return {
|
|
113
|
+
raw: requiredString(record, 'raw'),
|
|
114
|
+
via: requiredEnum(record, 'via', ['alias', 'literal', 'inherit']),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function parseToolFilter(value) {
|
|
118
|
+
const record = asRecord(value);
|
|
119
|
+
return { allow: stringArray(record, 'allow'), deny: stringArray(record, 'deny') };
|
|
120
|
+
}
|
|
121
|
+
function parseWorkspace(value) {
|
|
122
|
+
const record = asRecord(value);
|
|
123
|
+
return {
|
|
124
|
+
cwd: requiredString(record, 'cwd'),
|
|
125
|
+
gitDir: requiredString(record, 'gitDir'),
|
|
126
|
+
gitCommonDir: requiredString(record, 'gitCommonDir'),
|
|
127
|
+
branch: requiredString(record, 'branch'),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function parseOverlayTuple(value) {
|
|
131
|
+
if (value === undefined)
|
|
132
|
+
return undefined;
|
|
133
|
+
const record = asRecord(value);
|
|
134
|
+
if (!('reasoningEffort' in record))
|
|
135
|
+
throw new PinParseError('missing required field "reasoningEffort"');
|
|
136
|
+
if (!('maxTokens' in record))
|
|
137
|
+
throw new PinParseError('missing required field "maxTokens"');
|
|
138
|
+
return {
|
|
139
|
+
provider: requiredString(record, 'provider'),
|
|
140
|
+
model: requiredString(record, 'model'),
|
|
141
|
+
reasoningEffort: record.reasoningEffort === null ? null : requiredString(record, 'reasoningEffort'),
|
|
142
|
+
maxTokens: record.maxTokens === null ? null : requiredNumber(record, 'maxTokens'),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function parseResume(value) {
|
|
146
|
+
const record = asRecord(value);
|
|
147
|
+
const state = requiredEnum(record, 'state', ['ok', 'blocked']);
|
|
148
|
+
const overlay = parseOverlayTuple(record['overlay']);
|
|
149
|
+
if (state === 'blocked') {
|
|
150
|
+
return { state, reason: requiredString(record, 'reason'), overlay };
|
|
151
|
+
}
|
|
152
|
+
return { state, overlay };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Parse a pin from its JSON text. Tolerant of unknown fields on the pin and
|
|
156
|
+
* its nested objects; throws {@link PinParseError} for malformed JSON, an
|
|
157
|
+
* unsupported `version`, or a missing required field.
|
|
158
|
+
*/
|
|
159
|
+
export function parsePin(text) {
|
|
160
|
+
let raw;
|
|
161
|
+
try {
|
|
162
|
+
raw = JSON.parse(text);
|
|
163
|
+
}
|
|
164
|
+
catch (cause) {
|
|
165
|
+
throw new PinParseError(`invalid JSON (${String(cause)})`);
|
|
166
|
+
}
|
|
167
|
+
const record = asRecord(raw);
|
|
168
|
+
const version = record['version'];
|
|
169
|
+
if (version !== PIN_VERSION) {
|
|
170
|
+
throw new PinParseError(`unsupported pin version ${JSON.stringify(version)}`);
|
|
171
|
+
}
|
|
172
|
+
const pin = {
|
|
173
|
+
version: PIN_VERSION,
|
|
174
|
+
childId: requiredString(record, 'childId'),
|
|
175
|
+
parentSessionId: requiredString(record, 'parentSessionId'),
|
|
176
|
+
label: requiredString(record, 'label'),
|
|
177
|
+
mode: requiredEnum(record, 'mode', ['continuable-background']),
|
|
178
|
+
createdAt: requiredString(record, 'createdAt'),
|
|
179
|
+
definition: parseDefinition(record['definition']),
|
|
180
|
+
modelSelector: parseModelSelector(record['modelSelector']),
|
|
181
|
+
effective: parseEffective(record['effective']),
|
|
182
|
+
toolFilter: parseToolFilter(record['toolFilter']),
|
|
183
|
+
maxTurns: record['maxTurns'] === undefined ? undefined : requiredNumber(record, 'maxTurns'),
|
|
184
|
+
workspace: parseWorkspace(record['workspace']),
|
|
185
|
+
resume: parseResume(record['resume']),
|
|
186
|
+
lastNotice: optionalString(record, 'lastNotice'),
|
|
187
|
+
};
|
|
188
|
+
return pin;
|
|
189
|
+
}
|
|
190
|
+
/** Stable JSON.stringify: object keys in sorted order, recursively. */
|
|
191
|
+
export function canonicalJson(value) {
|
|
192
|
+
if (Array.isArray(value))
|
|
193
|
+
return `[${value.map(entry => canonicalJson(entry)).join(',')}]`;
|
|
194
|
+
if (typeof value === 'object' && value !== null) {
|
|
195
|
+
const keys = Object.keys(value).sort();
|
|
196
|
+
const body = keys
|
|
197
|
+
.filter(key => value[key] !== undefined)
|
|
198
|
+
.map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
199
|
+
.join(',');
|
|
200
|
+
return `{${body}}`;
|
|
201
|
+
}
|
|
202
|
+
return JSON.stringify(value) ?? 'null';
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Serialize a pin to its canonical JSON form (sorted keys), matching what the
|
|
206
|
+
* store writes atomically to `<pinsRoot>/<childId>.json`.
|
|
207
|
+
*/
|
|
208
|
+
export function writePin(pin) {
|
|
209
|
+
return `${canonicalJson(pin)}\n`;
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=pin.js.map
|
package/lib/pin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.js","sourceRoot":"","sources":["../src/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAE5B,4EAA4E;AAC5E,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAA;QAC3C,I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AAO,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IAC1F,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC,IAAI,EAAE,CAAA;QACjE,MAAM,IAAI,GAAG,IAAI;aACd,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,KAAiC,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;aACpE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,aAAa,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAC9F,IAAI,CAAC,GAAG,CAAC,CAAA;QACZ,OAAO,IAAI,IAAI,GAAG,CAAA;IACpB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAA;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAc;IACrC,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAA;AAClC,CAAC"}
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resume-pins cordis plugin (plan §4.6-§4.10): one `PinStore`, the
|
|
3
|
+
* `subagents-resume` settings namespace, the `tools/pre-execute` resume gate,
|
|
4
|
+
* the `tools/post-execute` notice/annotation listeners, and the
|
|
5
|
+
* `agent/request` runtime overlay.
|
|
6
|
+
*
|
|
7
|
+
* Zero-op when unmounted: pins are simply unread and behavior is today's
|
|
8
|
+
* legacy behavior. When mounted, only pinned children are affected — a
|
|
9
|
+
* missing pin is a legacy/foreign child (pass-through), and a same-epoch
|
|
10
|
+
* followup to a live Activation is untouched.
|
|
11
|
+
*
|
|
12
|
+
* Durability ordering: every deny persists `resume.state='blocked'` (reason)
|
|
13
|
+
* through the shared store — an atomic disk rewrite plus synchronous cache
|
|
14
|
+
* publication — BEFORE the deny decision returns, so the overlay listener
|
|
15
|
+
* fails any unmonitored resume of that child visibly. An all-passing gate
|
|
16
|
+
* clears the stored blocked state. Gate and overlay share the ONE store
|
|
17
|
+
* exposed as the `resumePinStore` service (spawn capture prefers it too).
|
|
18
|
+
*
|
|
19
|
+
* @module @dsh-cc/subagent-resume-pins/plugin
|
|
20
|
+
*/
|
|
21
|
+
import z from '@deepseek-ai/schemastery';
|
|
22
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
23
|
+
import { PinStore } from './store.ts';
|
|
24
|
+
import type { ResumePin } from './pin.ts';
|
|
25
|
+
/** Plugin configuration. */
|
|
26
|
+
export interface ResumePinsPluginConfig {
|
|
27
|
+
/** Directory holding one `<childId>.json` pin file per child. */
|
|
28
|
+
readonly pinsRoot: string;
|
|
29
|
+
/** Test seam / shared-store injection: use this store instead of a new one. */
|
|
30
|
+
readonly store?: PinStore;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The settings section schema (plan §4.9): one constrained enum field per
|
|
34
|
+
* knob with explicit defaults, mirroring how `cc-model-aliases` registers its
|
|
35
|
+
* schema — invalid spellings are rejected at write time by the settings
|
|
36
|
+
* service; `readResumePolicy` keeps tolerating hand-edited documents.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ResumePolicySchema: z<Schemastery.ObjectS<{
|
|
39
|
+
onUnavailableModel: z<"block" | "route-current", "block" | "route-current">;
|
|
40
|
+
onDefinitionChanged: z<"block" | "resume-with-notice", "block" | "resume-with-notice">;
|
|
41
|
+
onWorkspaceChanged: z<"block" | "resume-with-notice", "block" | "resume-with-notice">;
|
|
42
|
+
}>, Schemastery.ObjectT<{
|
|
43
|
+
onUnavailableModel: z<"block" | "route-current", "block" | "route-current">;
|
|
44
|
+
onDefinitionChanged: z<"block" | "resume-with-notice", "block" | "resume-with-notice">;
|
|
45
|
+
onWorkspaceChanged: z<"block" | "resume-with-notice", "block" | "resume-with-notice">;
|
|
46
|
+
}>>;
|
|
47
|
+
/** Cordis plugin id. */
|
|
48
|
+
export declare const name = "cc-subagent-resume-pins";
|
|
49
|
+
/** The service key the spawn capture resolves to share the store. */
|
|
50
|
+
export declare const RESUME_PIN_STORE = "resumePinStore";
|
|
51
|
+
/**
|
|
52
|
+
* Re-fingerprint a named definition OUTSIDE the registry cache (§4.4).
|
|
53
|
+
* Bundled pins re-fingerprint from the CURRENT in-package bundled registry.
|
|
54
|
+
* Project/user pins re-read the EXACT recorded `baseDir`+`filename`, falling
|
|
55
|
+
* back to an `agentType` lookup only when the recorded file is gone (that is
|
|
56
|
+
* the changed-by-replacement class). `'missing'` for a gone/unreadable
|
|
57
|
+
* definition; `null` when no current information exists (a pin without a
|
|
58
|
+
* file location).
|
|
59
|
+
*/
|
|
60
|
+
export declare function refingerprintDefinition(pin: ResumePin): Promise<string | 'missing' | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Mount the resume-pin gate, overlay, notices, and policy namespace.
|
|
63
|
+
* @param ctx - the plug context.
|
|
64
|
+
* @param config - pins root (or an injected store).
|
|
65
|
+
*/
|
|
66
|
+
export declare function apply(ctx: Context, config: ResumePinsPluginConfig): void;
|
|
67
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAoBlD,OAAO,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,4BAA4B;AAC5B,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;GAI7B,CAAA;AAEF,wBAAwB;AACxB,eAAO,MAAM,IAAI,4BAA4B,CAAA;AAE7C,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,mBAAmB,CAAA;AA8ChD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAoBhG;AAOD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAsNxE"}
|