@graphorin/core 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -1
- package/README.md +12 -9
- package/dist/channels/channels.d.ts +3 -3
- package/dist/channels/channels.js.map +1 -1
- package/dist/channels/directive.d.ts +8 -3
- package/dist/channels/directive.d.ts.map +1 -1
- package/dist/channels/directive.js +8 -3
- package/dist/channels/directive.js.map +1 -1
- package/dist/channels/dispatch.d.ts +9 -1
- package/dist/channels/dispatch.d.ts.map +1 -1
- package/dist/channels/dispatch.js +9 -1
- package/dist/channels/dispatch.js.map +1 -1
- package/dist/channels/durable.d.ts +94 -0
- package/dist/channels/durable.d.ts.map +1 -0
- package/dist/channels/durable.js +106 -0
- package/dist/channels/durable.js.map +1 -0
- package/dist/channels/index.d.ts +2 -1
- package/dist/channels/index.js +2 -1
- package/dist/channels/pause.d.ts +4 -4
- package/dist/channels/pause.js +4 -4
- package/dist/channels/pause.js.map +1 -1
- package/dist/contracts/auth-token-store.d.ts +2 -2
- package/dist/contracts/checkpoint-store.d.ts +41 -5
- package/dist/contracts/checkpoint-store.d.ts.map +1 -1
- package/dist/contracts/checkpoint-store.js +25 -0
- package/dist/contracts/checkpoint-store.js.map +1 -0
- package/dist/contracts/embedder.d.ts +1 -1
- package/dist/contracts/index.d.ts +4 -4
- package/dist/contracts/index.js +2 -1
- package/dist/contracts/local-provider-trust.d.ts +4 -4
- package/dist/contracts/logger.d.ts +1 -1
- package/dist/contracts/logger.js.map +1 -1
- package/dist/contracts/memory-store.d.ts +1 -1
- package/dist/contracts/memory-store.d.ts.map +1 -1
- package/dist/contracts/oauth-server-store.d.ts +1 -1
- package/dist/contracts/preferred-model.d.ts +4 -4
- package/dist/contracts/preferred-model.js.map +1 -1
- package/dist/contracts/provider.d.ts +31 -5
- package/dist/contracts/provider.d.ts.map +1 -1
- package/dist/contracts/reasoning-retention.d.ts +3 -3
- package/dist/contracts/redaction-validator.d.ts +1 -1
- package/dist/contracts/sandbox.d.ts +1 -1
- package/dist/contracts/secret-value.d.ts +1 -1
- package/dist/contracts/secret-value.js.map +1 -1
- package/dist/contracts/secrets-store.d.ts +3 -3
- package/dist/contracts/session-store.d.ts +9 -7
- package/dist/contracts/session-store.d.ts.map +1 -1
- package/dist/contracts/tool.d.ts +20 -7
- package/dist/contracts/tool.d.ts.map +1 -1
- package/dist/contracts/tracer.d.ts +1 -1
- package/dist/contracts/tracer.d.ts.map +1 -1
- package/dist/contracts/tracer.js.map +1 -1
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/types/agent-event.d.ts +24 -10
- package/dist/types/agent-event.d.ts.map +1 -1
- package/dist/types/handoff.d.ts +9 -9
- package/dist/types/index.d.ts +5 -5
- package/dist/types/memory.d.ts +66 -23
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/message.d.ts +2 -2
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/run.d.ts +57 -4
- package/dist/types/run.d.ts.map +1 -1
- package/dist/types/run.js +1 -1
- package/dist/types/run.js.map +1 -1
- package/dist/types/sensitivity.d.ts +3 -3
- package/dist/types/sensitivity.js.map +1 -1
- package/dist/types/stop-condition.d.ts +1 -1
- package/dist/types/stop-condition.js.map +1 -1
- package/dist/types/tool.d.ts +49 -24
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/types/usage.d.ts +25 -1
- package/dist/types/usage.d.ts.map +1 -1
- package/dist/types/usage.js.map +1 -1
- package/dist/types/workflow-event.d.ts +8 -1
- package/dist/types/workflow-event.d.ts.map +1 -1
- package/dist/utils/assert-never.d.ts +1 -1
- package/dist/utils/assert-never.js +1 -1
- package/dist/utils/assert-never.js.map +1 -1
- package/dist/utils/hash.d.ts +9 -7
- package/dist/utils/hash.d.ts.map +1 -1
- package/dist/utils/hash.js +9 -7
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +1 -1
package/dist/channels/pause.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const PAUSE_SIGNAL_BRAND: unique symbol;
|
|
|
12
12
|
* catches it, persists state with a pending pause, and suspends the
|
|
13
13
|
* thread until `Workflow.resume(threadId, directive)` is called.
|
|
14
14
|
*
|
|
15
|
-
* Application code should never construct or catch this directly
|
|
15
|
+
* Application code should never construct or catch this directly -
|
|
16
16
|
* always go through `pause(...)`.
|
|
17
17
|
*
|
|
18
18
|
* @stable
|
|
@@ -46,12 +46,12 @@ interface PauseResumeScope {
|
|
|
46
46
|
* {@link PauseSignal} (WF-2: a node body re-executes from the top on
|
|
47
47
|
* every resume, so earlier pauses must replay their already-delivered
|
|
48
48
|
* values and only the FIRST unsatisfied `pause()` suspends again). An
|
|
49
|
-
* empty `values` array behaves exactly like no scope
|
|
50
|
-
* suspends
|
|
49
|
+
* empty `values` array behaves exactly like no scope - every `pause()`
|
|
50
|
+
* suspends - which is what a static-gate resume needs so a programmatic
|
|
51
51
|
* `pause()` inside the node is never silently satisfied.
|
|
52
52
|
*
|
|
53
53
|
* This helper is the contract between the runtime and `pause(...)`.
|
|
54
|
-
* Consumers of `pause(...)` never call it directly
|
|
54
|
+
* Consumers of `pause(...)` never call it directly - only the workflow
|
|
55
55
|
* engine wires it up around the resumed node body.
|
|
56
56
|
*
|
|
57
57
|
* @internal
|
package/dist/channels/pause.js
CHANGED
|
@@ -14,7 +14,7 @@ const PAUSE_SIGNAL_BRAND = Symbol.for("graphorin.PauseSignal");
|
|
|
14
14
|
* catches it, persists state with a pending pause, and suspends the
|
|
15
15
|
* thread until `Workflow.resume(threadId, directive)` is called.
|
|
16
16
|
*
|
|
17
|
-
* Application code should never construct or catch this directly
|
|
17
|
+
* Application code should never construct or catch this directly -
|
|
18
18
|
* always go through `pause(...)`.
|
|
19
19
|
*
|
|
20
20
|
* @stable
|
|
@@ -35,12 +35,12 @@ const pauseResumeStorage = new AsyncLocalStorage();
|
|
|
35
35
|
* {@link PauseSignal} (WF-2: a node body re-executes from the top on
|
|
36
36
|
* every resume, so earlier pauses must replay their already-delivered
|
|
37
37
|
* values and only the FIRST unsatisfied `pause()` suspends again). An
|
|
38
|
-
* empty `values` array behaves exactly like no scope
|
|
39
|
-
* suspends
|
|
38
|
+
* empty `values` array behaves exactly like no scope - every `pause()`
|
|
39
|
+
* suspends - which is what a static-gate resume needs so a programmatic
|
|
40
40
|
* `pause()` inside the node is never silently satisfied.
|
|
41
41
|
*
|
|
42
42
|
* This helper is the contract between the runtime and `pause(...)`.
|
|
43
|
-
* Consumers of `pause(...)` never call it directly
|
|
43
|
+
* Consumers of `pause(...)` never call it directly - only the workflow
|
|
44
44
|
* engine wires it up around the resumed node body.
|
|
45
45
|
*
|
|
46
46
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pause.js","names":["PAUSE_SIGNAL_BRAND: unique symbol","scope: PauseResumeScope"],"sources":["../../src/channels/pause.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\n/**\n * Brand attached to the signal thrown by `pause(value)` so that the\n * workflow runtime can recognise it across realms (Worker threads,\n * sandboxes, …) without `instanceof`.\n *\n * @stable\n */\nexport const PAUSE_SIGNAL_BRAND: unique symbol = Symbol.for('graphorin.PauseSignal');\n\n/**\n * Thrown by `pause(value)` from inside a workflow node. The runtime\n * catches it, persists state with a pending pause, and suspends the\n * thread until `Workflow.resume(threadId, directive)` is called.\n *\n * Application code should never construct or catch this directly
|
|
1
|
+
{"version":3,"file":"pause.js","names":["PAUSE_SIGNAL_BRAND: unique symbol","scope: PauseResumeScope"],"sources":["../../src/channels/pause.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\n/**\n * Brand attached to the signal thrown by `pause(value)` so that the\n * workflow runtime can recognise it across realms (Worker threads,\n * sandboxes, …) without `instanceof`.\n *\n * @stable\n */\nexport const PAUSE_SIGNAL_BRAND: unique symbol = Symbol.for('graphorin.PauseSignal');\n\n/**\n * Thrown by `pause(value)` from inside a workflow node. The runtime\n * catches it, persists state with a pending pause, and suspends the\n * thread until `Workflow.resume(threadId, directive)` is called.\n *\n * Application code should never construct or catch this directly -\n * always go through `pause(...)`.\n *\n * @stable\n */\nexport class PauseSignal<TValue = unknown> extends Error {\n readonly [PAUSE_SIGNAL_BRAND]: true = true;\n readonly value: TValue;\n\n constructor(value: TValue) {\n super('graphorin: workflow paused');\n this.name = 'PauseSignal';\n this.value = value;\n }\n}\n\n/**\n * Resume-injection scope set by the workflow runtime around the second\n * (and later) invocations of a paused node body. When the scope is\n * present, `pause(...)` consults it to decide whether to throw a fresh\n * {@link PauseSignal} or return the injected value the runtime supplied\n * via `Workflow.resume(threadId, new Directive({ resume }))`.\n *\n * This is the storage mechanism that gives `pause()` its symmetric\n * pair semantics (`pause` ↔ `resume`) without forcing every node body\n * to be re-architected as a state machine.\n *\n * @internal\n */\nexport interface PauseResumeScope {\n /** Ordered resume values replayed to successive `pause()` calls (WF-2). */\n readonly values: ReadonlyArray<unknown>;\n cursor: number;\n}\n\nconst pauseResumeStorage = new AsyncLocalStorage<PauseResumeScope>();\n\n/**\n * Run `fn` inside a scope where successive `pause(...)` calls return the\n * supplied `values` in order instead of throwing a fresh\n * {@link PauseSignal} (WF-2: a node body re-executes from the top on\n * every resume, so earlier pauses must replay their already-delivered\n * values and only the FIRST unsatisfied `pause()` suspends again). An\n * empty `values` array behaves exactly like no scope - every `pause()`\n * suspends - which is what a static-gate resume needs so a programmatic\n * `pause()` inside the node is never silently satisfied.\n *\n * This helper is the contract between the runtime and `pause(...)`.\n * Consumers of `pause(...)` never call it directly - only the workflow\n * engine wires it up around the resumed node body.\n *\n * @internal\n */\nexport function runWithPauseResume<R>(\n values: ReadonlyArray<unknown>,\n fn: () => R | Promise<R>,\n): Promise<R> {\n const scope: PauseResumeScope = { values, cursor: 0 };\n return pauseResumeStorage.run(scope, async () => fn());\n}\n\n/**\n * Programmatically suspend the current workflow node. The `value` is\n * surfaced to callers via the `WorkflowSuspendedEvent.value` field; the\n * eventual `Directive({ resume })` is delivered as the return value of\n * this call once the runtime resumes the thread.\n *\n * Implementation note: when the call is made outside a runtime-managed\n * resume scope, `pause(...)` throws a fresh {@link PauseSignal} so the\n * engine can catch it, persist state, and suspend. When the runtime\n * later resumes the node body, it wraps the second invocation in\n * {@link runWithPauseResume}, which causes the same `pause(...)` call to\n * return the operator-supplied resume value instead of throwing.\n *\n * @stable\n */\nexport function pause<TValue, TResume = unknown>(value: TValue): TResume {\n const scope = pauseResumeStorage.getStore();\n if (scope !== undefined && scope.cursor < scope.values.length) {\n const next = scope.values[scope.cursor];\n scope.cursor += 1;\n return next as TResume;\n }\n throw new PauseSignal<TValue>(value);\n}\n\n/**\n * Cross-realm safe type guard for `PauseSignal`.\n *\n * @stable\n */\nexport function isPauseSignal(err: unknown): err is PauseSignal {\n return (\n typeof err === 'object' &&\n err !== null &&\n (err as Record<symbol, unknown>)[PAUSE_SIGNAL_BRAND] === true\n );\n}\n"],"mappings":";;;;;;;;;;AASA,MAAaA,qBAAoC,OAAO,IAAI,wBAAwB;;;;;;;;;;;AAYpF,IAAa,cAAb,cAAmD,MAAM;CACvD,CAAU,sBAA4B;CACtC,AAAS;CAET,YAAY,OAAe;AACzB,QAAM,6BAA6B;AACnC,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAuBjB,MAAM,qBAAqB,IAAI,mBAAqC;;;;;;;;;;;;;;;;;AAkBpE,SAAgB,mBACd,QACA,IACY;CACZ,MAAMC,QAA0B;EAAE;EAAQ,QAAQ;EAAG;AACrD,QAAO,mBAAmB,IAAI,OAAO,YAAY,IAAI,CAAC;;;;;;;;;;;;;;;;;AAkBxD,SAAgB,MAAiC,OAAwB;CACvE,MAAM,QAAQ,mBAAmB,UAAU;AAC3C,KAAI,UAAU,UAAa,MAAM,SAAS,MAAM,OAAO,QAAQ;EAC7D,MAAM,OAAO,MAAM,OAAO,MAAM;AAChC,QAAM,UAAU;AAChB,SAAO;;AAET,OAAM,IAAI,YAAoB,MAAM;;;;;;;AAQtC,SAAgB,cAAc,KAAkC;AAC9D,QACE,OAAO,QAAQ,YACf,QAAQ,QACP,IAAgC,wBAAwB"}
|
|
@@ -13,7 +13,7 @@ interface AuthTokenRecord {
|
|
|
13
13
|
readonly hashHex: string;
|
|
14
14
|
/** Optional human-readable label rendered in CLI listings. */
|
|
15
15
|
readonly label?: string;
|
|
16
|
-
/** Scope grammar
|
|
16
|
+
/** Scope grammar - opaque strings of the form `<resource>:<action>[:<id-or-glob>]`. */
|
|
17
17
|
readonly scopes: ReadonlyArray<string>;
|
|
18
18
|
readonly createdAt: string;
|
|
19
19
|
readonly expiresAt?: string;
|
|
@@ -35,7 +35,7 @@ interface AuthTokenStore {
|
|
|
35
35
|
recordUse(id: string, usedAt: string): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Indexed lookup by HMAC hash (SPL-19). When present, the verifier
|
|
38
|
-
* uses it on cache-miss instead of walking `list()`
|
|
38
|
+
* uses it on cache-miss instead of walking `list()` - O(1) instead of
|
|
39
39
|
* an O(n) full-table scan per verification.
|
|
40
40
|
*/
|
|
41
41
|
getByHash?(hashHex: string): Promise<AuthTokenRecord | null>;
|
|
@@ -18,7 +18,7 @@ interface Checkpoint {
|
|
|
18
18
|
readonly threadId: string;
|
|
19
19
|
readonly namespace: string;
|
|
20
20
|
readonly parentId?: CheckpointId;
|
|
21
|
-
/** Serialized state blob
|
|
21
|
+
/** Serialized state blob - adapter-specific encoding (JSON / superjson / …). */
|
|
22
22
|
readonly state: unknown;
|
|
23
23
|
/** Per-channel monotonic versions used by the workflow scheduler. */
|
|
24
24
|
readonly channelVersions: Readonly<Record<string, number>>;
|
|
@@ -32,7 +32,13 @@ interface Checkpoint {
|
|
|
32
32
|
* @stable
|
|
33
33
|
*/
|
|
34
34
|
interface CheckpointMetadata {
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Durability mode that produced this write. The legacy `'async'`
|
|
37
|
+
* value was removed (workflow-14 / WF-7 - it was byte-identical to
|
|
38
|
+
* `'sync'`); adapters normalize legacy persisted rows to `'sync'` at
|
|
39
|
+
* read time.
|
|
40
|
+
*/
|
|
41
|
+
readonly source: 'sync' | 'exit';
|
|
36
42
|
readonly status: 'running' | 'suspended' | 'completed' | 'failed' | 'aborted';
|
|
37
43
|
readonly nodeName?: string;
|
|
38
44
|
readonly tags?: ReadonlyArray<string>;
|
|
@@ -59,7 +65,7 @@ interface PendingWrite {
|
|
|
59
65
|
readonly taskId: string;
|
|
60
66
|
readonly index: number;
|
|
61
67
|
readonly channel: string;
|
|
62
|
-
/** Serialized value blob
|
|
68
|
+
/** Serialized value blob - adapter-specific encoding. */
|
|
63
69
|
readonly value: unknown;
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
@@ -72,6 +78,36 @@ interface ListOptions {
|
|
|
72
78
|
readonly before?: CheckpointId;
|
|
73
79
|
readonly status?: CheckpointMetadata['status'];
|
|
74
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Optional atomicity contract for {@link CheckpointStore.put} (D1 /
|
|
83
|
+
* workflow-01). When `expectedLatestId` is supplied, the store MUST
|
|
84
|
+
* perform the latest-checkpoint comparison and the insert atomically
|
|
85
|
+
* (single transaction / synchronous critical section) and throw
|
|
86
|
+
* {@link CheckpointConflictError} on mismatch - closing the TOCTOU
|
|
87
|
+
* window an engine-level read-then-write cannot. `null` means "expect
|
|
88
|
+
* no checkpoint for this thread yet"; `undefined` (or a store that
|
|
89
|
+
* ignores the argument) preserves the unguarded legacy behaviour, which
|
|
90
|
+
* the engine backstops with its own pre-check.
|
|
91
|
+
*
|
|
92
|
+
* @stable
|
|
93
|
+
*/
|
|
94
|
+
interface CheckpointPutOptions {
|
|
95
|
+
readonly expectedLatestId?: CheckpointId | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown by a {@link CheckpointStore.put} honouring
|
|
99
|
+
* {@link CheckpointPutOptions.expectedLatestId} when another writer
|
|
100
|
+
* advanced the thread in between. The workflow engine maps it to its
|
|
101
|
+
* `checkpoint-version-conflict` error.
|
|
102
|
+
*
|
|
103
|
+
* @stable
|
|
104
|
+
*/
|
|
105
|
+
declare class CheckpointConflictError extends Error {
|
|
106
|
+
readonly threadId: string;
|
|
107
|
+
readonly expectedLatestId: CheckpointId | null;
|
|
108
|
+
readonly actualLatestId: CheckpointId | null;
|
|
109
|
+
constructor(threadId: string, expected: CheckpointId | null, actual: CheckpointId | null);
|
|
110
|
+
}
|
|
75
111
|
/**
|
|
76
112
|
* Pluggable checkpoint storage interface. The default implementation
|
|
77
113
|
* lives in `@graphorin/store-sqlite`.
|
|
@@ -79,12 +115,12 @@ interface ListOptions {
|
|
|
79
115
|
* @stable
|
|
80
116
|
*/
|
|
81
117
|
interface CheckpointStore {
|
|
82
|
-
put(threadId: string, namespace: string, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise<CheckpointId>;
|
|
118
|
+
put(threadId: string, namespace: string, checkpoint: Checkpoint, metadata: CheckpointMetadata, opts?: CheckpointPutOptions): Promise<CheckpointId>;
|
|
83
119
|
putWrites(threadId: string, namespace: string, checkpointId: CheckpointId, writes: ReadonlyArray<PendingWrite>, taskId: string): Promise<void>;
|
|
84
120
|
getTuple(threadId: string, namespace: string, checkpointId?: CheckpointId): Promise<CheckpointTuple | null>;
|
|
85
121
|
list(threadId: string, namespace: string, opts?: ListOptions): AsyncIterable<CheckpointTuple>;
|
|
86
122
|
deleteThread(threadId: string): Promise<void>;
|
|
87
123
|
}
|
|
88
124
|
//#endregion
|
|
89
|
-
export { Checkpoint, CheckpointId, CheckpointMetadata, CheckpointStore, CheckpointTuple, ListOptions, PendingWrite };
|
|
125
|
+
export { Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointTuple, ListOptions, PendingWrite };
|
|
90
126
|
//# sourceMappingURL=checkpoint-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-store.d.ts","names":[],"sources":["../../src/contracts/checkpoint-store.ts"],"sourcesContent":[],"mappings":";;AAOA;AAQA;;;;;AAQoC,KAhBxB,YAAA,GAgBwB,MAAA;AAWpC;
|
|
1
|
+
{"version":3,"file":"checkpoint-store.d.ts","names":[],"sources":["../../src/contracts/checkpoint-store.ts"],"sourcesContent":[],"mappings":";;AAOA;AAQA;;;;;AAQoC,KAhBxB,YAAA,GAgBwB,MAAA;AAWpC;AAmBA;;;;;AAGwC,UAzCvB,UAAA,CAyCuB;EAUvB,SAAA,EAAA,EAlDF,YAkDc;EAaZ,SAAA,QAAW,EAAA,MAER;EAiBH,SAAA,SAAA,EAAA,MAAoB;EAYxB,SAAA,QAAA,CAAA,EA3FS,YA2Fe;EAER;EACF,SAAA,KAAA,EAAA,OAAA;EAEe;EAA6B,SAAA,eAAA,EA5F3C,QA4F2C,CA5FlC,MA4FkC,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;EAL1B,SAAA,UAAA,EAAA,MAAA;EAAK,SAAA,SAAA,EAAA,MAAA;AAsBlD;;;;;;;AAa0B,UA/GT,kBAAA,CA+GS;EAAd;;;;;;EAUmE,SAAA,MAAA,EAAA,MAAA,GAAA,MAAA;EAAd,SAAA,MAAA,EAAA,SAAA,GAAA,WAAA,GAAA,WAAA,GAAA,QAAA,GAAA,SAAA;EAE/B,SAAA,QAAA,CAAA,EAAA,MAAA;EAAO,SAAA,IAAA,CAAA,EAjHvB,aAiHuB,CAAA,MAAA,CAAA;;;;;;;;UAxGxB,eAAA;uBACM;qBACF;2BACM,cAAc;;;;;;;;;UAUxB,YAAA;;;;;;;;;;;;UAaA,WAAA;;oBAEG;oBACA;;;;;;;;;;;;;;;UAgBH,oBAAA;8BACa;;;;;;;;;;cAWjB,uBAAA,SAAgC,KAAA;;6BAEhB;2BACF;0CAEe,6BAA6B;;;;;;;;UAiBtD,eAAA;uDAID,sBACF,2BACH,uBACN,QAAQ;+DAKK,sBACN,cAAc,gCAErB;+DAKc,eACd,QAAQ;mDAEsC,cAAc,cAAc;kCAE7C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/contracts/checkpoint-store.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by a {@link CheckpointStore.put} honouring
|
|
4
|
+
* {@link CheckpointPutOptions.expectedLatestId} when another writer
|
|
5
|
+
* advanced the thread in between. The workflow engine maps it to its
|
|
6
|
+
* `checkpoint-version-conflict` error.
|
|
7
|
+
*
|
|
8
|
+
* @stable
|
|
9
|
+
*/
|
|
10
|
+
var CheckpointConflictError = class extends Error {
|
|
11
|
+
threadId;
|
|
12
|
+
expectedLatestId;
|
|
13
|
+
actualLatestId;
|
|
14
|
+
constructor(threadId, expected, actual) {
|
|
15
|
+
super(`checkpoint conflict on thread "${threadId}": expected latest ${expected ?? "<none>"}, found ${actual ?? "<none>"}`);
|
|
16
|
+
this.name = "CheckpointConflictError";
|
|
17
|
+
this.threadId = threadId;
|
|
18
|
+
this.expectedLatestId = expected;
|
|
19
|
+
this.actualLatestId = actual;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { CheckpointConflictError };
|
|
25
|
+
//# sourceMappingURL=checkpoint-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint-store.js","names":[],"sources":["../../src/contracts/checkpoint-store.ts"],"sourcesContent":["/**\n * Opaque identifier for a single workflow checkpoint. Treated as a string\n * by every consumer so adapters can pick whatever encoding they prefer\n * (ULID, UUID, snowflake-like, …).\n *\n * @stable\n */\nexport type CheckpointId = string;\n\n/**\n * Serialized snapshot of workflow state, written after every execution\n * step.\n *\n * @stable\n */\nexport interface Checkpoint {\n readonly id: CheckpointId;\n readonly threadId: string;\n readonly namespace: string;\n readonly parentId?: CheckpointId;\n /** Serialized state blob - adapter-specific encoding (JSON / superjson / …). */\n readonly state: unknown;\n /** Per-channel monotonic versions used by the workflow scheduler. */\n readonly channelVersions: Readonly<Record<string, number>>;\n readonly stepNumber: number;\n readonly createdAt: string;\n}\n\n/**\n * Metadata associated with a checkpoint write. Adapters store this in a\n * sidecar table for efficient listing.\n *\n * @stable\n */\nexport interface CheckpointMetadata {\n /**\n * Durability mode that produced this write. The legacy `'async'`\n * value was removed (workflow-14 / WF-7 - it was byte-identical to\n * `'sync'`); adapters normalize legacy persisted rows to `'sync'` at\n * read time.\n */\n readonly source: 'sync' | 'exit';\n readonly status: 'running' | 'suspended' | 'completed' | 'failed' | 'aborted';\n readonly nodeName?: string;\n readonly tags?: ReadonlyArray<string>;\n}\n\n/**\n * A checkpoint paired with its sidecar metadata. Returned by\n * `CheckpointStore.getTuple(...)` and the `list(...)` iterator.\n *\n * @stable\n */\nexport interface CheckpointTuple {\n readonly checkpoint: Checkpoint;\n readonly metadata: CheckpointMetadata;\n readonly pendingWrites?: ReadonlyArray<PendingWrite>;\n}\n\n/**\n * Per-task pending write. Captured when a task in an execution step\n * succeeds while a sibling task fails: the next resume attempt skips the\n * already-completed work.\n *\n * @stable\n */\nexport interface PendingWrite {\n readonly taskId: string;\n readonly index: number;\n readonly channel: string;\n /** Serialized value blob - adapter-specific encoding. */\n readonly value: unknown;\n}\n\n/**\n * Optional listing range for `CheckpointStore.list(...)`.\n *\n * @stable\n */\nexport interface ListOptions {\n readonly limit?: number;\n readonly before?: CheckpointId;\n readonly status?: CheckpointMetadata['status'];\n}\n\n/**\n * Optional atomicity contract for {@link CheckpointStore.put} (D1 /\n * workflow-01). When `expectedLatestId` is supplied, the store MUST\n * perform the latest-checkpoint comparison and the insert atomically\n * (single transaction / synchronous critical section) and throw\n * {@link CheckpointConflictError} on mismatch - closing the TOCTOU\n * window an engine-level read-then-write cannot. `null` means \"expect\n * no checkpoint for this thread yet\"; `undefined` (or a store that\n * ignores the argument) preserves the unguarded legacy behaviour, which\n * the engine backstops with its own pre-check.\n *\n * @stable\n */\nexport interface CheckpointPutOptions {\n readonly expectedLatestId?: CheckpointId | null;\n}\n\n/**\n * Thrown by a {@link CheckpointStore.put} honouring\n * {@link CheckpointPutOptions.expectedLatestId} when another writer\n * advanced the thread in between. The workflow engine maps it to its\n * `checkpoint-version-conflict` error.\n *\n * @stable\n */\nexport class CheckpointConflictError extends Error {\n readonly threadId: string;\n readonly expectedLatestId: CheckpointId | null;\n readonly actualLatestId: CheckpointId | null;\n\n constructor(threadId: string, expected: CheckpointId | null, actual: CheckpointId | null) {\n super(\n `checkpoint conflict on thread \"${threadId}\": expected latest ${expected ?? '<none>'}, found ${actual ?? '<none>'}`,\n );\n this.name = 'CheckpointConflictError';\n this.threadId = threadId;\n this.expectedLatestId = expected;\n this.actualLatestId = actual;\n }\n}\n\n/**\n * Pluggable checkpoint storage interface. The default implementation\n * lives in `@graphorin/store-sqlite`.\n *\n * @stable\n */\nexport interface CheckpointStore {\n put(\n threadId: string,\n namespace: string,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata,\n opts?: CheckpointPutOptions,\n ): Promise<CheckpointId>;\n\n putWrites(\n threadId: string,\n namespace: string,\n checkpointId: CheckpointId,\n writes: ReadonlyArray<PendingWrite>,\n taskId: string,\n ): Promise<void>;\n\n getTuple(\n threadId: string,\n namespace: string,\n checkpointId?: CheckpointId,\n ): Promise<CheckpointTuple | null>;\n\n list(threadId: string, namespace: string, opts?: ListOptions): AsyncIterable<CheckpointTuple>;\n\n deleteThread(threadId: string): Promise<void>;\n}\n"],"mappings":";;;;;;;;;AA8GA,IAAa,0BAAb,cAA6C,MAAM;CACjD,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,UAAkB,UAA+B,QAA6B;AACxF,QACE,kCAAkC,SAAS,qBAAqB,YAAY,SAAS,UAAU,UAAU,WAC1G;AACD,OAAK,OAAO;AACZ,OAAK,WAAW;AAChB,OAAK,mBAAmB;AACxB,OAAK,iBAAiB"}
|
|
@@ -33,7 +33,7 @@ interface EmbedOptions {
|
|
|
33
33
|
readonly requestId?: string;
|
|
34
34
|
/**
|
|
35
35
|
* Asymmetric retrieval role of the input (PS-10). Embedders for models that
|
|
36
|
-
* require asymmetric prefixes
|
|
36
|
+
* require asymmetric prefixes - the E5 family's `query:` / `passage:` - apply
|
|
37
37
|
* the matching prefix; embedders for symmetric models ignore it. Memory tiers
|
|
38
38
|
* pass `'query'` when embedding a search query and `'passage'` when embedding
|
|
39
39
|
* content for storage.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthTokenRecord, AuthTokenStore } from "./auth-token-store.js";
|
|
2
|
-
import { Checkpoint, CheckpointId, CheckpointMetadata, CheckpointStore, CheckpointTuple, ListOptions, PendingWrite } from "./checkpoint-store.js";
|
|
2
|
+
import { Checkpoint, CheckpointConflictError, CheckpointId, CheckpointMetadata, CheckpointPutOptions, CheckpointStore, CheckpointTuple, ListOptions, PendingWrite } from "./checkpoint-store.js";
|
|
3
3
|
import { EmbedOptions, EmbedderProvider } from "./embedder.js";
|
|
4
4
|
import { EvalSample, EvalScore, EvalScorer } from "./eval-scorer.js";
|
|
5
5
|
import { LocalProviderTrust, OllamaTrust } from "./local-provider-trust.js";
|
|
@@ -7,8 +7,9 @@ import { LogFields, LogLevel, Logger, NOOP_LOGGER } from "./logger.js";
|
|
|
7
7
|
import { EpisodicMemoryStore, MemoryStore, MessageRef, ProceduralMemoryStore, SemanticMemoryStore, SessionListOptions, SessionMemoryStore, SessionMessageWithMetadata, SharedMemoryStore, WorkingMemoryStore } from "./memory-store.js";
|
|
8
8
|
import { OAuthServerRecord, OAuthServerStore } from "./oauth-server-store.js";
|
|
9
9
|
import { MODEL_HINTS, ModelHint, ModelSpec, ProviderLike } from "./preferred-model.js";
|
|
10
|
+
import { AISpan, NOOP_TRACER, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, Tracer } from "./tracer.js";
|
|
10
11
|
import { ReasoningContract, ReasoningRetention } from "./reasoning-retention.js";
|
|
11
|
-
import { ComposeProviderMiddleware, FinishReason, OutputSpec, Provider, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ResponseMetadata, ToolChoice, ToolDefinition, ToolDefinitionExample } from "./provider.js";
|
|
12
|
+
import { ComposeProviderMiddleware, FinishReason, OutputSpec, Provider, ProviderCachePolicy, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ResponseMetadata, ToolChoice, ToolDefinition, ToolDefinitionExample } from "./provider.js";
|
|
12
13
|
import { RedactionInput, RedactionOutput, RedactionValidator } from "./redaction-validator.js";
|
|
13
14
|
import { Sandbox, SandboxCode, SandboxResult, SandboxRunOptions } from "./sandbox.js";
|
|
14
15
|
import { SecretRef } from "./secret-ref.js";
|
|
@@ -16,7 +17,6 @@ import { NODEJS_INSPECT_CUSTOM, SECRET_VALUE_BRAND, SecretValue, SecretValueOpti
|
|
|
16
17
|
import { SecretMetadata, SecretResolver, SecretResolverContext, SecretsSetOptions, SecretsStore } from "./secrets-store.js";
|
|
17
18
|
import { AgentRegistryEntry, SessionAuditEntry, SessionMetadata, SessionStore, SessionStoreExt, SessionWorkflowRun } from "./session-store.js";
|
|
18
19
|
import { TokenCounter } from "./token-counter.js";
|
|
19
|
-
import { AISpan, NOOP_TRACER, SpanAttributeValue, SpanAttributes, SpanStatus, SpanType, StartSpanOptions, Tracer } from "./tracer.js";
|
|
20
20
|
import { ResolvedTool, Tool, ToolExample, ToolExecutionContext, ToolReturn, ToolSecretsAccessor } from "./tool.js";
|
|
21
21
|
import { TriggerState, TriggerStore } from "./trigger-store.js";
|
|
22
|
-
export { type AISpan, type AgentRegistryEntry, type AuthTokenRecord, type AuthTokenStore, type Checkpoint, type CheckpointId, type CheckpointMetadata, type CheckpointStore, type CheckpointTuple, type ComposeProviderMiddleware, type EmbedOptions, type EmbedderProvider, type EpisodicMemoryStore, type EvalSample, type EvalScore, type EvalScorer, type FinishReason, type ListOptions, type LocalProviderTrust, type LogFields, type LogLevel, type Logger, MODEL_HINTS, type MemoryStore, type MessageRef, type ModelHint, type ModelSpec, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, type OAuthServerRecord, type OAuthServerStore, type OllamaTrust, type OutputSpec, type PendingWrite, type ProceduralMemoryStore, type Provider, type ProviderCapabilities, type ProviderError, type ProviderErrorKind, type ProviderEvent, type ProviderLike, type ProviderMiddleware, type ProviderRequest, type ProviderRequestMetadata, type ProviderResponse, type ReasoningContract, type ReasoningRetention, type RedactionInput, type RedactionOutput, type RedactionValidator, type ResolvedTool, type ResponseMetadata, SECRET_VALUE_BRAND, type Sandbox, type SandboxCode, type SandboxResult, type SandboxRunOptions, type SecretMetadata, type SecretRef, type SecretResolver, type SecretResolverContext, type SecretValue, type SecretValueOptions, type SecretValueStatic, type SecretsSetOptions, type SecretsStore, type SemanticMemoryStore, type SessionAuditEntry, type SessionListOptions, type SessionMemoryStore, type SessionMessageWithMetadata, type SessionMetadata, type SessionStore, type SessionStoreExt, type SessionWorkflowRun, type SharedMemoryStore, type SpanAttributeValue, type SpanAttributes, type SpanStatus, type SpanType, type StartSpanOptions, type TokenCounter, type Tool, type ToolChoice, type ToolDefinition, type ToolDefinitionExample, type ToolExample, type ToolExecutionContext, type ToolReturn, type ToolSecretsAccessor, type Tracer, type TriggerState, type TriggerStore, type WorkingMemoryStore };
|
|
22
|
+
export { type AISpan, type AgentRegistryEntry, type AuthTokenRecord, type AuthTokenStore, type Checkpoint, CheckpointConflictError, type CheckpointId, type CheckpointMetadata, type CheckpointPutOptions, type CheckpointStore, type CheckpointTuple, type ComposeProviderMiddleware, type EmbedOptions, type EmbedderProvider, type EpisodicMemoryStore, type EvalSample, type EvalScore, type EvalScorer, type FinishReason, type ListOptions, type LocalProviderTrust, type LogFields, type LogLevel, type Logger, MODEL_HINTS, type MemoryStore, type MessageRef, type ModelHint, type ModelSpec, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, type OAuthServerRecord, type OAuthServerStore, type OllamaTrust, type OutputSpec, type PendingWrite, type ProceduralMemoryStore, type Provider, type ProviderCachePolicy, type ProviderCapabilities, type ProviderError, type ProviderErrorKind, type ProviderEvent, type ProviderLike, type ProviderMiddleware, type ProviderRequest, type ProviderRequestMetadata, type ProviderResponse, type ReasoningContract, type ReasoningRetention, type RedactionInput, type RedactionOutput, type RedactionValidator, type ResolvedTool, type ResponseMetadata, SECRET_VALUE_BRAND, type Sandbox, type SandboxCode, type SandboxResult, type SandboxRunOptions, type SecretMetadata, type SecretRef, type SecretResolver, type SecretResolverContext, type SecretValue, type SecretValueOptions, type SecretValueStatic, type SecretsSetOptions, type SecretsStore, type SemanticMemoryStore, type SessionAuditEntry, type SessionListOptions, type SessionMemoryStore, type SessionMessageWithMetadata, type SessionMetadata, type SessionStore, type SessionStoreExt, type SessionWorkflowRun, type SharedMemoryStore, type SpanAttributeValue, type SpanAttributes, type SpanStatus, type SpanType, type StartSpanOptions, type TokenCounter, type Tool, type ToolChoice, type ToolDefinition, type ToolDefinitionExample, type ToolExample, type ToolExecutionContext, type ToolReturn, type ToolSecretsAccessor, type Tracer, type TriggerState, type TriggerStore, type WorkingMemoryStore };
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CheckpointConflictError } from "./checkpoint-store.js";
|
|
1
2
|
import { NOOP_LOGGER } from "./logger.js";
|
|
2
3
|
import { MODEL_HINTS } from "./preferred-model.js";
|
|
3
4
|
import { NODEJS_INSPECT_CUSTOM, SECRET_VALUE_BRAND } from "./secret-value.js";
|
|
4
5
|
import { NOOP_TRACER } from "./tracer.js";
|
|
5
6
|
|
|
6
|
-
export { MODEL_HINTS, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, SECRET_VALUE_BRAND };
|
|
7
|
+
export { CheckpointConflictError, MODEL_HINTS, NODEJS_INSPECT_CUSTOM, NOOP_LOGGER, NOOP_TRACER, SECRET_VALUE_BRAND };
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Tier semantics:
|
|
11
11
|
*
|
|
12
|
-
* - `'loopback'`
|
|
12
|
+
* - `'loopback'` - `localhost` / `127.0.0.0/8` / `::1` /
|
|
13
13
|
* `unix:///path` (or any in-process adapter that has no `baseUrl`).
|
|
14
14
|
* Same trust boundary as the host process.
|
|
15
|
-
* - `'private'`
|
|
15
|
+
* - `'private'` - RFC 1918 (`10/8`, `172.16/12`,
|
|
16
16
|
* `192.168/16`); RFC 6598 CGNAT (`100.64/10`); link-local
|
|
17
17
|
* (`169.254/16`, `fe80::/10`); `*.local` / `*.lan` / `*.internal` /
|
|
18
18
|
* `*.home.arpa`.
|
|
19
|
-
* - `'public-tls'`
|
|
20
|
-
* - `'public-cleartext'`
|
|
19
|
+
* - `'public-tls'` - public IP / hostname AND `https://`.
|
|
20
|
+
* - `'public-cleartext'` - public IP / hostname AND `http://`. Adapters
|
|
21
21
|
* refuse to start unless explicitly overridden.
|
|
22
22
|
*
|
|
23
23
|
* @stable
|
|
@@ -18,7 +18,7 @@ type LogFields = Readonly<Record<string, unknown>>;
|
|
|
18
18
|
/**
|
|
19
19
|
* Pluggable logger contract consumed by every `@graphorin/*` runtime
|
|
20
20
|
* package. The concrete implementation lives in `@graphorin/observability`
|
|
21
|
-
*
|
|
21
|
+
* - declaring the interface here keeps level-zero packages free of an
|
|
22
22
|
* observability dependency.
|
|
23
23
|
*
|
|
24
24
|
* Loggers are intentionally **structured** and **side-effect-free** in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":["NOOP_LOGGER: Logger"],"sources":["../../src/contracts/logger.ts"],"sourcesContent":["/**\n * Severity levels supported by the project logger. Mirrors the canonical\n * `trace < debug < info < warn < error` hierarchy used by every common\n * structured logger.\n *\n * @stable\n */\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Free-form structured fields that accompany a log record. Values must be\n * JSON-serializable; concrete loggers redact `SecretValue` and other\n * sensitive shapes per the framework's redaction policy.\n *\n * @stable\n */\nexport type LogFields = Readonly<Record<string, unknown>>;\n\n/**\n * Pluggable logger contract consumed by every `@graphorin/*` runtime\n * package. The concrete implementation lives in `@graphorin/observability`\n *
|
|
1
|
+
{"version":3,"file":"logger.js","names":["NOOP_LOGGER: Logger"],"sources":["../../src/contracts/logger.ts"],"sourcesContent":["/**\n * Severity levels supported by the project logger. Mirrors the canonical\n * `trace < debug < info < warn < error` hierarchy used by every common\n * structured logger.\n *\n * @stable\n */\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * Free-form structured fields that accompany a log record. Values must be\n * JSON-serializable; concrete loggers redact `SecretValue` and other\n * sensitive shapes per the framework's redaction policy.\n *\n * @stable\n */\nexport type LogFields = Readonly<Record<string, unknown>>;\n\n/**\n * Pluggable logger contract consumed by every `@graphorin/*` runtime\n * package. The concrete implementation lives in `@graphorin/observability`\n * - declaring the interface here keeps level-zero packages free of an\n * observability dependency.\n *\n * Loggers are intentionally **structured** and **side-effect-free** in the\n * type contract: the `info(msg, fields?)` signature is a hint, not a\n * mandate to actually emit anything. Implementations may sample, drop, or\n * batch.\n *\n * @stable\n */\nexport interface Logger {\n trace(message: string, fields?: LogFields): void;\n debug(message: string, fields?: LogFields): void;\n info(message: string, fields?: LogFields): void;\n warn(message: string, fields?: LogFields): void;\n error(message: string, fields?: LogFields): void;\n /**\n * Return a child logger with `fields` merged into every record's\n * structured payload. Useful for binding `runId` / `sessionId` /\n * `agentId` once at the top of a request.\n */\n child(fields: LogFields): Logger;\n}\n\n/**\n * Minimal no-op logger. Useful as a typed default when downstream code\n * needs a non-null `Logger` without taking the observability dependency.\n *\n * @stable\n */\nexport const NOOP_LOGGER: Logger = {\n trace(): void {},\n debug(): void {},\n info(): void {},\n warn(): void {},\n error(): void {},\n child(): Logger {\n return NOOP_LOGGER;\n },\n};\n"],"mappings":";;;;;;;AAmDA,MAAaA,cAAsB;CACjC,QAAc;CACd,QAAc;CACd,OAAa;CACb,OAAa;CACb,QAAc;CACd,QAAgB;AACd,SAAO;;CAEV"}
|
|
@@ -11,7 +11,7 @@ import { SessionScope } from "../types/session-scope.js";
|
|
|
11
11
|
*
|
|
12
12
|
* Sub-namespaces map 1:1 to the six tiers so each implementation can
|
|
13
13
|
* pick its own physical layout (one big table, six tables, mixed) while
|
|
14
|
-
* preserving append-only semantics
|
|
14
|
+
* preserving append-only semantics - soft-delete only.
|
|
15
15
|
*
|
|
16
16
|
* @stable
|
|
17
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-store.d.ts","names":[],"sources":["../../src/contracts/memory-store.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAuBA;;;;;;;;;AAWkB,UAXD,WAAA,CAWC;EAID,SAAA,OAAA,EAdG,kBAce;EACrB,SAAA,OAAA,EAdM,kBAcN;EAAqC,SAAA,QAAA,EAb9B,mBAa8B;EAAd,SAAA,QAAA,EAZhB,mBAYgB;EAAR,SAAA,UAAA,EAXN,qBAWM;EAChB,SAAA,MAAA,EAXM,iBAWN;EAAsC;EAAR,IAAA,EAAA,EARjC,OAQiC,CAAA,IAAA,CAAA;EAC3B;EAAqB,KAAA,EAAA,EAP1B,OAO0B,CAAA,IAAA,CAAA;;;AAC0B,UAJ9C,kBAAA,CAI8C;EAAO,IAAA,CAAA,KAAA,EAHxD,YAGwD,CAAA,EAHzC,OAGyC,CAHjC,aAGiC,CAHnB,KAGmB,CAAA,CAAA;EASrD,GAAA,CAAA,KAAA,EAXJ,YAWc,EAAA,KAAA,EAAA,MAAA,CAAA,EAXgB,OAWhB,CAXwB,KAWxB,GAAA,IAAA,CAAA;EAaV,MAAA,CAAA,KAAA,EAvBD,YAuBC,EAAA,KAA0B,EAvBN,KAuBM,
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","names":[],"sources":["../../src/contracts/memory-store.ts"],"sourcesContent":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/contracts/oauth-server-store.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Persisted metadata for an OAuth server registration. The framework
|
|
4
|
-
* never stores raw token material here
|
|
4
|
+
* never stores raw token material here - the access, refresh, id, and
|
|
5
5
|
* client-secret tokens live in the {@link SecretsStore} and this
|
|
6
6
|
* record only holds the {@link SecretRef} URIs that resolve them.
|
|
7
7
|
*
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
* The three tiers describe canonical cloud-provider price-quality
|
|
9
9
|
* envelopes circa 2026:
|
|
10
10
|
*
|
|
11
|
-
* - `'fast'`
|
|
11
|
+
* - `'fast'` - low-cost / low-latency / file-navigation /
|
|
12
12
|
* parameter-extraction / low-stakes calls.
|
|
13
|
-
* - `'balanced'`
|
|
13
|
+
* - `'balanced'` - median cost-quality; the default tier for most
|
|
14
14
|
* tools.
|
|
15
|
-
* - `'smart'`
|
|
15
|
+
* - `'smart'` - high-quality / high-stakes / reasoning-heavy /
|
|
16
16
|
* summarization / code-review calls.
|
|
17
17
|
*
|
|
18
|
-
* The vocabulary is Graphorin's own design
|
|
18
|
+
* The vocabulary is Graphorin's own design - no third-party routing-
|
|
19
19
|
* guide attribution leaks into the public surface. Per-provider
|
|
20
20
|
* dispatch lives in `@graphorin/provider/model-tier/classify.ts`.
|
|
21
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferred-model.js","names":["MODEL_HINTS: readonly ModelHint[]"],"sources":["../../src/contracts/preferred-model.ts"],"sourcesContent":["/**\n * Cost-tier vocabulary for declaring a preferred model on a tool or\n * agent. Provider-agnostic at the tool-author level; the operator-side\n * `Agent.modelTierMap?: Partial<Record<ModelHint, ModelSpec>>` mapping\n * resolves the hint to a concrete provider per agent.\n *\n * The three tiers describe canonical cloud-provider price-quality\n * envelopes circa 2026:\n *\n * - `'fast'`
|
|
1
|
+
{"version":3,"file":"preferred-model.js","names":["MODEL_HINTS: readonly ModelHint[]"],"sources":["../../src/contracts/preferred-model.ts"],"sourcesContent":["/**\n * Cost-tier vocabulary for declaring a preferred model on a tool or\n * agent. Provider-agnostic at the tool-author level; the operator-side\n * `Agent.modelTierMap?: Partial<Record<ModelHint, ModelSpec>>` mapping\n * resolves the hint to a concrete provider per agent.\n *\n * The three tiers describe canonical cloud-provider price-quality\n * envelopes circa 2026:\n *\n * - `'fast'` - low-cost / low-latency / file-navigation /\n * parameter-extraction / low-stakes calls.\n * - `'balanced'` - median cost-quality; the default tier for most\n * tools.\n * - `'smart'` - high-quality / high-stakes / reasoning-heavy /\n * summarization / code-review calls.\n *\n * The vocabulary is Graphorin's own design - no third-party routing-\n * guide attribution leaks into the public surface. Per-provider\n * dispatch lives in `@graphorin/provider/model-tier/classify.ts`.\n *\n * @stable\n */\nexport type ModelHint = 'fast' | 'balanced' | 'smart';\n\n/**\n * Discriminated string-literal triple for type-level work.\n *\n * @stable\n */\nexport const MODEL_HINTS: readonly ModelHint[] = ['fast', 'balanced', 'smart'] as const;\n\n/**\n * Forward-declared shape of `Provider`. Re-declared here as a minimal\n * structural type so this module stays cycle-free with respect to\n * `./provider.ts` and downstream consumers can use `ModelSpec` without\n * importing the heavier `Provider` interface.\n *\n * @internal\n */\nexport interface ProviderLike {\n readonly name: string;\n readonly modelId: string;\n}\n\n/**\n * Concrete provider declaration used at site of the per-tool hint\n * override (Phase 07), the per-tier mapping\n * (`Agent.modelTierMap`, Phase 12), and the agent-level fallback chain\n * (`Agent.fallbackModels`, Phase 12).\n *\n * The shape is unified deliberately so operators learn one thing and\n * use it three places.\n *\n * @stable\n */\nexport type ModelSpec = ProviderLike | { readonly provider: ProviderLike; readonly model: string };\n"],"mappings":";;;;;;AA6BA,MAAaA,cAAoC;CAAC;CAAQ;CAAY;CAAQ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Sensitivity } from "../types/sensitivity.js";
|
|
2
2
|
import { Message } from "../types/message.js";
|
|
3
|
+
import { AISpan } from "./tracer.js";
|
|
3
4
|
import { Usage } from "../types/usage.js";
|
|
4
5
|
import { ReasoningContract, ReasoningRetention } from "./reasoning-retention.js";
|
|
5
6
|
|
|
@@ -61,6 +62,23 @@ interface ProviderCapabilities {
|
|
|
61
62
|
*/
|
|
62
63
|
readonly reasoningContract?: ReasoningContract;
|
|
63
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Opt-in prompt-cache breakpoint policy (core-provider-02).
|
|
67
|
+
*
|
|
68
|
+
* `breakpoints: 'auto'` asks the adapter to place provider-native cache
|
|
69
|
+
* anchors around the stable request prefix: the Anthropic path (via the
|
|
70
|
+
* vercel adapter) marks the first and last conversation messages with
|
|
71
|
+
* `cache_control: { type: 'ephemeral' }` so tools + system + the stable
|
|
72
|
+
* prefix are written once and read at ~0.1x input price on subsequent
|
|
73
|
+
* steps. Providers with automatic caching (OpenAI) or no cache concept
|
|
74
|
+
* ignore the policy. `ttl` maps to Anthropic's extended cache TTL.
|
|
75
|
+
*
|
|
76
|
+
* @stable
|
|
77
|
+
*/
|
|
78
|
+
interface ProviderCachePolicy {
|
|
79
|
+
readonly breakpoints: 'auto' | 'none';
|
|
80
|
+
readonly ttl?: '5m' | '1h';
|
|
81
|
+
}
|
|
64
82
|
/**
|
|
65
83
|
* Provider-call request payload.
|
|
66
84
|
*
|
|
@@ -76,6 +94,14 @@ interface ProviderRequest {
|
|
|
76
94
|
readonly maxTokens?: number;
|
|
77
95
|
readonly signal?: AbortSignal;
|
|
78
96
|
readonly providerOptions?: Readonly<Record<string, unknown>>;
|
|
97
|
+
readonly cachePolicy?: ProviderCachePolicy;
|
|
98
|
+
/**
|
|
99
|
+
* C7: live parent span for the provider call. Like `signal`, this is a
|
|
100
|
+
* runtime handle (never serialized): `withTracing` parents its
|
|
101
|
+
* provider.generate/stream span under it so a run's traces form one
|
|
102
|
+
* tree instead of disconnected fragments.
|
|
103
|
+
*/
|
|
104
|
+
readonly parentSpan?: AISpan;
|
|
79
105
|
readonly metadata?: ProviderRequestMetadata;
|
|
80
106
|
/**
|
|
81
107
|
* Per-request override of the provider's auto-detected
|
|
@@ -123,7 +149,7 @@ interface ProviderResponse {
|
|
|
123
149
|
type FinishReason = 'stop' | 'length' | 'tool-calls' | 'content-filter' | 'error' | 'aborted';
|
|
124
150
|
/**
|
|
125
151
|
* Streamed provider event. Shape matches the wire-stable subset of the
|
|
126
|
-
* provider event union
|
|
152
|
+
* provider event union - adapters hide vendor specifics.
|
|
127
153
|
*
|
|
128
154
|
* @stable
|
|
129
155
|
*/
|
|
@@ -214,7 +240,7 @@ interface ToolDefinition {
|
|
|
214
240
|
readonly examples?: ReadonlyArray<ToolDefinitionExample>;
|
|
215
241
|
}
|
|
216
242
|
/**
|
|
217
|
-
* A single worked example as projected onto the provider wire contract
|
|
243
|
+
* A single worked example as projected onto the provider wire contract -
|
|
218
244
|
* a serializable, schema-agnostic view of a `ToolExample`. `input` /
|
|
219
245
|
* `output` carry the example's already-parsed values; `comment` is the
|
|
220
246
|
* optional rationale shown to the model.
|
|
@@ -259,8 +285,8 @@ type ProviderMiddleware = (next: Provider) => Provider;
|
|
|
259
285
|
* Type signature for the canonical middleware composer (the runtime
|
|
260
286
|
* implementation lives in `@graphorin/provider`).
|
|
261
287
|
*
|
|
262
|
-
* The concrete composer guarantees a deterministic ordering
|
|
263
|
-
* arguments mirrors order of execution from outermost to innermost
|
|
288
|
+
* The concrete composer guarantees a deterministic ordering - order of
|
|
289
|
+
* arguments mirrors order of execution from outermost to innermost - and
|
|
264
290
|
* is the only blessed entry point for chaining middleware in
|
|
265
291
|
* `@graphorin/*` code (per the security-first ordering rule).
|
|
266
292
|
*
|
|
@@ -268,5 +294,5 @@ type ProviderMiddleware = (next: Provider) => Provider;
|
|
|
268
294
|
*/
|
|
269
295
|
type ComposeProviderMiddleware = (middlewares: ReadonlyArray<ProviderMiddleware>) => ProviderMiddleware;
|
|
270
296
|
//#endregion
|
|
271
|
-
export { ComposeProviderMiddleware, FinishReason, OutputSpec, Provider, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ResponseMetadata, ToolChoice, ToolDefinition, ToolDefinitionExample };
|
|
297
|
+
export { ComposeProviderMiddleware, FinishReason, OutputSpec, Provider, ProviderCachePolicy, ProviderCapabilities, ProviderError, ProviderErrorKind, ProviderEvent, ProviderMiddleware, ProviderRequest, ProviderRequestMetadata, ProviderResponse, ResponseMetadata, ToolChoice, ToolDefinition, ToolDefinitionExample };
|
|
272
298
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","names":[],"sources":["../../src/contracts/provider.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","names":[],"sources":["../../src/contracts/provider.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAgBA;;;;;;;;AAYoB,UAZH,QAAA,CAYG;EAAkB,SAAA,IAAA,EAAA,MAAA;EAOQ,SAAA,OAAA,EAAA,MAAA;EAAd,SAAA,YAAA,EAhBP,oBAgBO;EAAa;EAQ5B,MAAA,CAAA,GAAA,EArBH,eAqBuB,CAAA,EArBL,aA0CD,CA1Ce,aA0CE,CAAA;EAgB/B;EAUA,QAAA,CAAA,GAAA,EAjED,eAiEgB,CAAA,EAjEE,OAiEF,CAjEU,gBAiEV,CAAA;EACG;EAAd,WAAA,EAAA,GAAA,EA/DD,eA+DC,CAAA,EA/DiB,OA+DjB,CAAA,MAAA,CAAA;EACY;;;;;EAOK,SAAA,kBAAA,CAAA,EAhEN,aAgEM,CAhEQ,WAgER,CAAA;;;;;;;AA0BrB,UAlFA,oBAAA,CAkFuB;EAavB,SAAA,SAAA,EAAgB,OAAA;EAEV,SAAA,WAAA,EAAA,OAAA;EAKL,SAAA,iBAAA,EAAA,OAAA;EACO,SAAA,UAAA,EAAA,OAAA;EACc,SAAA,gBAAA,EAAA,OAAA;EAAT,SAAA,SAAA,EAAA,OAAA;EAAQ;EAQ1B,SAAA,aAAY,EAAA,MAAA;EAcZ;EAC4C,SAAA,SAAA,EAAA,MAAA;EAUe;;;;;AAUvE;AAYA;AAOA;AAgBA;;EAGwB,SAAA,iBAAA,CAAA,EApKO,iBAoKP;;;;;;AA0BxB;AAWA;AAQA;AAeA;AAaA;;;;;UA7NiB,mBAAA;;;;;;;;;UAUA,eAAA;qBACI,cAAc;mBAChB,cAAc;wBACT;wBACA;;;;oBAIJ;6BACS,SAAS;yBACb;;;;;;;wBAAmB;sBAQtB;;;;;;;;;gCASU;;;;;;;UAQf,uBAAA;;;;;;;;;;;;UAaA,gBAAA;;uBAEM;;;;;kBAKL;yBACO;8BACK,SAAS;;;;;;;KAQ3B,YAAA;;;;;;;KAcA,aAAA;;qBAC4C;;;;;;;;;;;;;;;;;;;;;;iBAUe;;;;;;;yBAEjB;kBAA8B;;;kBACtC;;;;;;;UAO7B,gBAAA;;;;;;;;;;;UAYA,aAAA;iBACA;;;;;KAML,iBAAA;;;;;;;UAgBK,cAAA;;;wBAGO,SAAS;;;;;;;0BAOP,SAAS;;;;;;;;sBAQb,cAAc;;;;;;;;;;UAWnB,qBAAA;;;;;;;;;;KAWL,UAAA;;;;;;;;;UAQK,UAAA;;;wBAGO,SAAS;;;;;;;;;;;KAYrB,kBAAA,UAA4B,aAAa;;;;;;;;;;;;KAazC,yBAAA,iBACG,cAAc,wBACxB"}
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
* Three independent lifecycle operations exist for reasoning content
|
|
8
8
|
* in the provider layer:
|
|
9
9
|
*
|
|
10
|
-
* 1. **Intra-loop transmission**
|
|
10
|
+
* 1. **Intra-loop transmission** - controlled by this enum. Default is
|
|
11
11
|
* auto-detected per provider:
|
|
12
12
|
* - Hidden chain-of-thought providers (e.g. OpenAI o1/o3, Google
|
|
13
13
|
* Gemini reasoning): `'strip'`.
|
|
14
14
|
* - Round-trip-required providers (e.g. Anthropic Claude tool-use
|
|
15
15
|
* with thinking blocks): `'pass-through-claude'`.
|
|
16
|
-
* 2. **Sub-agent handoff transmission**
|
|
16
|
+
* 2. **Sub-agent handoff transmission** - always strips reasoning
|
|
17
17
|
* regardless of this setting; lives in
|
|
18
18
|
* `@graphorin/sessions` handoff filters.
|
|
19
|
-
* 3. **Prompt-cache key calculation**
|
|
19
|
+
* 3. **Prompt-cache key calculation** - reasoning blocks are excluded
|
|
20
20
|
* from cache-key hashes but included in outbound transmission.
|
|
21
21
|
*
|
|
22
22
|
* @stable
|
|
@@ -42,7 +42,7 @@ interface RedactionInput {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Result of `RedactionValidator.validate(...)`
|
|
45
|
+
* Result of `RedactionValidator.validate(...)` - either the sanitized
|
|
46
46
|
* payload (possibly equal to the input) or `null` if the value must be
|
|
47
47
|
* dropped entirely.
|
|
48
48
|
*
|
|
@@ -50,7 +50,7 @@ interface SandboxRunOptions<TInput = unknown> {
|
|
|
50
50
|
readonly signal?: AbortSignal;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Result of a sandboxed run. The shape mirrors the `ToolOutcome` union
|
|
53
|
+
* Result of a sandboxed run. The shape mirrors the `ToolOutcome` union -
|
|
54
54
|
* the runtime maps `SandboxResult` to `ToolOutcome` after the call.
|
|
55
55
|
*
|
|
56
56
|
* @stable
|
|
@@ -26,7 +26,7 @@ declare const NODEJS_INSPECT_CUSTOM: unique symbol;
|
|
|
26
26
|
* a parameter as `SecretValue` therefore avoid taking a security
|
|
27
27
|
* dependency.
|
|
28
28
|
*
|
|
29
|
-
* Note: `SecretValue` is **not** a TypeScript branded primitive
|
|
29
|
+
* Note: `SecretValue` is **not** a TypeScript branded primitive - it is
|
|
30
30
|
* a full wrapper class with explicit leakage barriers
|
|
31
31
|
* (`Symbol.toPrimitive`, `toJSON`, `[nodejs.util.inspect.custom]`, …).
|
|
32
32
|
* Any conforming implementation must ensure that:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-value.js","names":["SECRET_VALUE_BRAND: unique symbol","NODEJS_INSPECT_CUSTOM: unique symbol"],"sources":["../../src/contracts/secret-value.ts"],"sourcesContent":["/**\n * Cross-realm symbol used to brand `SecretValue` instances. Implementations\n * (e.g. the wrapper class shipped from `@graphorin/security`) attach this\n * symbol so that `isSecretValue(...)` works across realms (Worker threads,\n * sandboxes, etc.).\n *\n * @stable\n */\nexport const SECRET_VALUE_BRAND: unique symbol = Symbol.for('graphorin.SecretValue');\n\n/**\n * Well-known symbol used by `node:util.inspect()` to format the wrapper.\n * Re-exported here so downstream packages can reference it without taking\n * an unconditional dependency on `node:util`.\n *\n * Equivalent to `Symbol.for('nodejs.util.inspect.custom')`.\n *\n * @stable\n */\nexport const NODEJS_INSPECT_CUSTOM: unique symbol = Symbol.for('nodejs.util.inspect.custom');\n\n/**\n * Runtime-safe wrapper around an opaque secret (API key, token, password).\n *\n * The shape declared here is the **interface contract**: the concrete\n * wrapper class lives in `@graphorin/security`. Downstream packages typing\n * a parameter as `SecretValue` therefore avoid taking a security\n * dependency.\n *\n * Note: `SecretValue` is **not** a TypeScript branded primitive
|
|
1
|
+
{"version":3,"file":"secret-value.js","names":["SECRET_VALUE_BRAND: unique symbol","NODEJS_INSPECT_CUSTOM: unique symbol"],"sources":["../../src/contracts/secret-value.ts"],"sourcesContent":["/**\n * Cross-realm symbol used to brand `SecretValue` instances. Implementations\n * (e.g. the wrapper class shipped from `@graphorin/security`) attach this\n * symbol so that `isSecretValue(...)` works across realms (Worker threads,\n * sandboxes, etc.).\n *\n * @stable\n */\nexport const SECRET_VALUE_BRAND: unique symbol = Symbol.for('graphorin.SecretValue');\n\n/**\n * Well-known symbol used by `node:util.inspect()` to format the wrapper.\n * Re-exported here so downstream packages can reference it without taking\n * an unconditional dependency on `node:util`.\n *\n * Equivalent to `Symbol.for('nodejs.util.inspect.custom')`.\n *\n * @stable\n */\nexport const NODEJS_INSPECT_CUSTOM: unique symbol = Symbol.for('nodejs.util.inspect.custom');\n\n/**\n * Runtime-safe wrapper around an opaque secret (API key, token, password).\n *\n * The shape declared here is the **interface contract**: the concrete\n * wrapper class lives in `@graphorin/security`. Downstream packages typing\n * a parameter as `SecretValue` therefore avoid taking a security\n * dependency.\n *\n * Note: `SecretValue` is **not** a TypeScript branded primitive - it is\n * a full wrapper class with explicit leakage barriers\n * (`Symbol.toPrimitive`, `toJSON`, `[nodejs.util.inspect.custom]`, …).\n * Any conforming implementation must ensure that:\n *\n * - String coercion (`String(s)`, `` `${s}` ``, `s + ''`, …) yields a\n * redacted placeholder, **not** the underlying value.\n * - JSON serialization (`JSON.stringify({ apiKey: s })`) yields a\n * redacted placeholder.\n * - Inspector output (`util.inspect(s)`) yields\n * `'SecretValue([REDACTED])'`.\n * - The underlying value is only reachable through `.use(fn)`,\n * `.useBuffer(fn)` or the audited `.reveal()` escape hatch.\n *\n * @stable\n */\nexport interface SecretValue {\n /** Number of bytes in the wrapped value. Safe to log. */\n readonly length: number;\n\n /**\n * Run `fn` with the unwrapped string and return its result. Preferred\n * over `.reveal()` because it scopes the unwrapped value to a single\n * synchronous / asynchronous turn.\n */\n use<T>(fn: (raw: string) => T | Promise<T>): Promise<T>;\n\n /**\n * Run `fn` with the unwrapped value as a `Buffer`. Useful for binary\n * secrets (encryption keys, HMAC keys) where round-tripping through a\n * V8 string would defeat the wrapper's hygiene.\n */\n useBuffer<T>(fn: (buf: Buffer) => T | Promise<T>): Promise<T>;\n\n /**\n * One-shot reveal as a string. Audited by the implementation. Prefer\n * `.use(fn)` whenever possible.\n */\n reveal(): string;\n\n /**\n * Best-effort zeroization of the underlying buffer. Does not affect\n * derived V8 strings already created via `.use(fn)` / `.reveal()`.\n */\n dispose(): void;\n\n /** Cross-realm brand. Implementations set this to `SECRET_VALUE_BRAND`. */\n readonly [SECRET_VALUE_BRAND]: true;\n\n /** Leakage barrier for ToPrimitive coercion. Returns the placeholder. */\n [Symbol.toPrimitive](hint: string): string | number;\n\n /** Leakage barrier for `JSON.stringify(...)`. Returns the placeholder. */\n toJSON(): string;\n\n /**\n * Leakage barrier for `node:util.inspect(...)`. Returns the placeholder\n * (`'SecretValue([REDACTED])'`) so that REPL / `console.log` /\n * structured-logger output never reveals the underlying value.\n */\n [NODEJS_INSPECT_CUSTOM](depth?: number, opts?: unknown, inspect?: unknown): string;\n}\n\n/**\n * Static helpers expected on every concrete `SecretValue` constructor.\n *\n * @stable\n */\nexport interface SecretValueStatic {\n /** Cross-realm safe type guard. */\n isSecretValue(value: unknown): value is SecretValue;\n /** Constant-time equality. */\n timingSafeEquals(a: SecretValue, b: SecretValue): boolean;\n /** Construct from a plain string. */\n fromString(raw: string, opts?: SecretValueOptions): SecretValue;\n /** Construct from a Node.js `Buffer`. */\n fromBuffer(buf: Buffer, opts?: SecretValueOptions): SecretValue;\n}\n\n/**\n * Optional metadata attached to a freshly constructed `SecretValue`.\n *\n * @stable\n */\nexport interface SecretValueOptions {\n /** Free-form provenance string for the audit log. */\n readonly source?: { readonly resolver?: string; readonly ref?: string };\n}\n"],"mappings":";;;;;;;;;AAQA,MAAaA,qBAAoC,OAAO,IAAI,wBAAwB;;;;;;;;;;AAWpF,MAAaC,wBAAuC,OAAO,IAAI,6BAA6B"}
|
|
@@ -5,7 +5,7 @@ import { SecretValue } from "./secret-value.js";
|
|
|
5
5
|
//#region src/contracts/secrets-store.d.ts
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Pluggable secret resolver
|
|
8
|
+
* Pluggable secret resolver - turns a parsed `SecretRef` into a live
|
|
9
9
|
* `SecretValue`. Concrete resolvers live in `@graphorin/security` (env,
|
|
10
10
|
* keyring, file, encrypted-file, literal, ref, vault) and in optional
|
|
11
11
|
* adapter packages (`@graphorin/secret-1password`, …).
|
|
@@ -55,7 +55,7 @@ interface SecretsStore {
|
|
|
55
55
|
*/
|
|
56
56
|
set(key: string, value: string | SecretValue, opts?: SecretsSetOptions): Promise<void>;
|
|
57
57
|
delete(key: string, scope?: SessionScope): Promise<void>;
|
|
58
|
-
/** Returns metadata about every key
|
|
58
|
+
/** Returns metadata about every key - never the values themselves. */
|
|
59
59
|
list(scope?: SessionScope): Promise<ReadonlyArray<SecretMetadata>>;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -69,7 +69,7 @@ interface SecretsSetOptions {
|
|
|
69
69
|
readonly tags?: ReadonlyArray<string>;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Public metadata about a stored secret. Safe to log
|
|
72
|
+
* Public metadata about a stored secret. Safe to log - never carries the
|
|
73
73
|
* value itself.
|
|
74
74
|
*
|
|
75
75
|
* @stable
|