experimental-ash 0.2.0-alpha.20 → 0.2.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/channel/slack-channel.d.ts +7 -14
- package/dist/src/channel/slack-channel.d.ts.map +1 -1
- package/dist/src/channel/slack-channel.js +11 -21
- package/dist/src/channel/slack-channel.js.map +1 -1
- package/dist/src/channel/types.d.ts +9 -6
- package/dist/src/channel/types.d.ts.map +1 -1
- package/dist/src/channel/types.js.map +1 -1
- package/dist/src/context/accessors.d.ts +13 -12
- package/dist/src/context/accessors.d.ts.map +1 -1
- package/dist/src/context/accessors.js +16 -17
- package/dist/src/context/accessors.js.map +1 -1
- package/dist/src/context/container.d.ts +17 -19
- package/dist/src/context/container.d.ts.map +1 -1
- package/dist/src/context/container.js +21 -14
- package/dist/src/context/container.js.map +1 -1
- package/dist/src/context/durable-context.d.ts +18 -0
- package/dist/src/context/durable-context.d.ts.map +1 -0
- package/dist/src/context/durable-context.js +49 -0
- package/dist/src/context/durable-context.js.map +1 -0
- package/dist/src/context/key.d.ts +34 -82
- package/dist/src/context/key.d.ts.map +1 -1
- package/dist/src/context/key.js +58 -80
- package/dist/src/context/key.js.map +1 -1
- package/dist/src/context/keys.d.ts +6 -6
- package/dist/src/context/keys.d.ts.map +1 -1
- package/dist/src/context/keys.js +8 -6
- package/dist/src/context/keys.js.map +1 -1
- package/dist/src/context/provider.d.ts +2 -2
- package/dist/src/context/provider.d.ts.map +1 -1
- package/dist/src/context/run-step.d.ts +6 -8
- package/dist/src/context/run-step.d.ts.map +1 -1
- package/dist/src/context/run-step.js +13 -17
- package/dist/src/context/run-step.js.map +1 -1
- package/dist/src/context/seed-keys.d.ts +7 -7
- package/dist/src/context/seed-keys.d.ts.map +1 -1
- package/dist/src/context/seed-keys.js +19 -7
- package/dist/src/context/seed-keys.js.map +1 -1
- package/dist/src/context/serialize.d.ts +8 -9
- package/dist/src/context/serialize.d.ts.map +1 -1
- package/dist/src/context/serialize.js +28 -16
- package/dist/src/context/serialize.js.map +1 -1
- package/dist/src/execution/continuous-entry.d.ts +6 -8
- package/dist/src/execution/continuous-entry.d.ts.map +1 -1
- package/dist/src/execution/continuous-entry.js +25 -21
- package/dist/src/execution/continuous-entry.js.map +1 -1
- package/dist/src/execution/continuous-runtime.d.ts.map +1 -1
- package/dist/src/execution/continuous-runtime.js +4 -1
- package/dist/src/execution/continuous-runtime.js.map +1 -1
- package/dist/src/execution/step-context.d.ts +27 -0
- package/dist/src/execution/step-context.d.ts.map +1 -0
- package/dist/src/execution/step-context.js +54 -0
- package/dist/src/execution/step-context.js.map +1 -0
- package/dist/src/execution/tool-compaction.d.ts +1 -3
- package/dist/src/execution/tool-compaction.d.ts.map +1 -1
- package/dist/src/execution/tool-compaction.js +6 -17
- package/dist/src/execution/tool-compaction.js.map +1 -1
- package/dist/src/execution/workflow-entry.d.ts +4 -5
- package/dist/src/execution/workflow-entry.d.ts.map +1 -1
- package/dist/src/execution/workflow-entry.js.map +1 -1
- package/dist/src/execution/workflow-runtime.d.ts.map +1 -1
- package/dist/src/execution/workflow-runtime.js +3 -2
- package/dist/src/execution/workflow-runtime.js.map +1 -1
- package/dist/src/execution/workflow-steps.d.ts +2 -2
- package/dist/src/execution/workflow-steps.d.ts.map +1 -1
- package/dist/src/execution/workflow-steps.js +12 -20
- package/dist/src/execution/workflow-steps.js.map +1 -1
- package/dist/src/harness/emission.d.ts +1 -1
- package/dist/src/harness/emission.js +3 -3
- package/dist/src/harness/emission.js.map +1 -1
- package/dist/src/harness/input-requests.d.ts +22 -1
- package/dist/src/harness/input-requests.d.ts.map +1 -1
- package/dist/src/harness/input-requests.js +36 -32
- package/dist/src/harness/input-requests.js.map +1 -1
- package/dist/src/harness/types.d.ts +15 -3
- package/dist/src/harness/types.d.ts.map +1 -1
- package/dist/src/harness/types.js +6 -1
- package/dist/src/harness/types.js.map +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.d.ts +3 -3
- package/dist/src/internal/nitro/routes/runtime-stack.js +3 -3
- package/dist/src/public/channels/slack/index.d.ts +5 -0
- package/dist/src/public/channels/slack/index.d.ts.map +1 -1
- package/dist/src/public/channels/slack/index.js.map +1 -1
- package/dist/src/public/definitions/tool.d.ts +3 -4
- package/dist/src/public/definitions/tool.d.ts.map +1 -1
- package/dist/src/public/definitions/tool.js.map +1 -1
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/index.d.ts.map +1 -1
- package/dist/src/public/index.js +1 -1
- package/dist/src/public/index.js.map +1 -1
- package/dist/src/public/tools/defaults.d.ts +4 -4
- package/dist/src/public/tools/defaults.js +4 -4
- package/dist/src/runtime/framework-tools/connection-search.d.ts +2 -2
- package/dist/src/runtime/framework-tools/connection-search.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/connection-search.js +2 -2
- package/dist/src/runtime/framework-tools/connection-search.js.map +1 -1
- package/dist/src/runtime/framework-tools/file-state.d.ts +5 -5
- package/dist/src/runtime/framework-tools/file-state.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/file-state.js +6 -8
- package/dist/src/runtime/framework-tools/file-state.js.map +1 -1
- package/dist/src/runtime/framework-tools/skill.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/skill.js +1 -3
- package/dist/src/runtime/framework-tools/skill.js.map +1 -1
- package/dist/src/runtime/framework-tools/todo.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/todo.js +2 -4
- package/dist/src/runtime/framework-tools/todo.js.map +1 -1
- package/dist/src/runtime/sessions/auth.d.ts +1 -1
- package/docs/internals/context.md +81 -231
- package/docs/public/README.md +19 -17
- package/docs/public/channels/README.md +4 -0
- package/docs/public/migration-guide.md +71 -0
- package/docs/public/session-context.md +46 -17
- package/docs/public/tools.md +18 -27
- package/docs/public/typescript-api.md +5 -1
- package/package.json +1 -1
- package/dist/src/context/state.d.ts +0 -27
- package/dist/src/context/state.d.ts.map +0 -1
- package/dist/src/context/state.js +0 -53
- package/dist/src/context/state.js.map +0 -1
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options accepted by the {@link ContextKey} constructor.
|
|
3
|
-
*
|
|
4
|
-
* - `initial` — marks the key as **durable state**. The factory returns the
|
|
5
|
-
* default value used the first time the state is read on a session, and
|
|
6
|
-
* the framework persists subsequent writes back across `"use step"`
|
|
7
|
-
* boundaries. Read and mutate the value with
|
|
8
|
-
* {@link getState} / {@link setState} from `experimental-ash`.
|
|
9
|
-
* - `codec` — serialization hooks for values that are not JSON-safe (e.g.
|
|
10
|
-
* live class instances). Most app-authored state is plain JSON and does
|
|
11
|
-
* not need a codec.
|
|
12
|
-
*/
|
|
13
1
|
export interface ContextDecodeContext {
|
|
14
|
-
get<T>(key:
|
|
15
|
-
tryGet<T>(key:
|
|
2
|
+
get<T>(key: ContextStoreKey<T>): T;
|
|
3
|
+
tryGet<T>(key: ContextStoreKey<T>): T | undefined;
|
|
16
4
|
}
|
|
17
5
|
/**
|
|
18
6
|
* Serialization hooks for one context key.
|
|
19
7
|
*
|
|
20
8
|
* `deserialize` receives the already-hydrated context so codecs can depend on
|
|
21
|
-
* earlier
|
|
9
|
+
* earlier runtime values such as the compiled runtime bundle.
|
|
22
10
|
*/
|
|
23
11
|
export interface ContextKeyCodec<T> {
|
|
24
12
|
serialize(value: T): unknown;
|
|
@@ -26,83 +14,47 @@ export interface ContextKeyCodec<T> {
|
|
|
26
14
|
}
|
|
27
15
|
export interface ContextKeyOptions<T> {
|
|
28
16
|
readonly codec?: ContextKeyCodec<T>;
|
|
29
|
-
|
|
17
|
+
}
|
|
18
|
+
interface RuntimeContextKeyOptions<T> extends ContextKeyOptions<T> {
|
|
19
|
+
readonly serializable?: boolean;
|
|
30
20
|
}
|
|
31
21
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* Use a `ContextKey` to declare a piece of durable, per-session state that
|
|
35
|
-
* tools, steps, and model callbacks can read and write inside an Ash
|
|
36
|
-
* execution scope. The key is declared once at module top-level and reused
|
|
37
|
-
* everywhere — the value is stored on the active session, not on the key.
|
|
38
|
-
*
|
|
39
|
-
* @example Declare a durable state key and use it from a tool
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { ContextKey, getState, setState } from "experimental-ash";
|
|
42
|
-
* import { defineTool } from "experimental-ash/tools";
|
|
43
|
-
* import { z } from "zod";
|
|
44
|
-
*
|
|
45
|
-
* interface NoteListState {
|
|
46
|
-
* readonly notes: readonly string[];
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* // `initial` makes this a state key — its value survives across
|
|
50
|
-
* // workflow step boundaries and compaction. The name must be unique
|
|
51
|
-
* // across the whole agent process.
|
|
52
|
-
* const NoteListStateKey = new ContextKey<NoteListState>("notes", {
|
|
53
|
-
* initial: () => ({ notes: [] }),
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* export default defineTool({
|
|
57
|
-
* description: "Append a note, or read the running list.",
|
|
58
|
-
* inputSchema: z.object({ note: z.string().optional() }),
|
|
59
|
-
* async execute({ note }) {
|
|
60
|
-
* if (note) {
|
|
61
|
-
* setState(NoteListStateKey, (current) => ({
|
|
62
|
-
* notes: [...current.notes, note],
|
|
63
|
-
* }));
|
|
64
|
-
* }
|
|
65
|
-
* return getState(NoteListStateKey);
|
|
66
|
-
* },
|
|
67
|
-
* });
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* Keys with an `initial` factory are **state keys** — durable mutable values
|
|
71
|
-
* hydrated from the session at step start and persisted back at step end.
|
|
72
|
-
* Keys without `initial` are ephemeral and only live for the current step.
|
|
73
|
-
*
|
|
74
|
-
* State keys participate in compaction via tool-level `onCompact` hooks
|
|
75
|
-
* declared on a `ToolDefinition`, not on the key itself.
|
|
22
|
+
* Public durable context key.
|
|
76
23
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* Every key self-registers in a global registry so the serialization layer
|
|
82
|
-
* can resolve string names back to typed keys without an explicit list.
|
|
83
|
-
* Construct each key exactly once at module scope; constructing the same
|
|
84
|
-
* key name twice is a programmer error.
|
|
24
|
+
* Values stored under a `ContextKey` are session-durable. The runtime
|
|
25
|
+
* hydrates them from `session.context` before each step and commits them back
|
|
26
|
+
* after the step completes.
|
|
85
27
|
*/
|
|
86
28
|
export declare class ContextKey<T> {
|
|
87
|
-
readonly name: string;
|
|
88
29
|
readonly codec?: ContextKeyCodec<T>;
|
|
89
|
-
|
|
90
|
-
* When provided, this key stores durable state on the harness session
|
|
91
|
-
* across workflow step boundaries. The factory returns the default value
|
|
92
|
-
* used when no persisted state exists on the session yet.
|
|
93
|
-
*/
|
|
94
|
-
readonly initial?: () => T;
|
|
30
|
+
readonly name: string;
|
|
95
31
|
constructor(name: string, options?: ContextKeyOptions<T>);
|
|
96
32
|
}
|
|
97
33
|
/**
|
|
98
|
-
*
|
|
34
|
+
* Private runtime-only key used for seed values, providers, and other
|
|
35
|
+
* framework internals that must not be persisted on `session.context`.
|
|
99
36
|
*/
|
|
100
|
-
export declare
|
|
37
|
+
export declare class RuntimeContextKey<T> {
|
|
38
|
+
readonly codec?: ContextKeyCodec<T>;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly serializable: boolean;
|
|
41
|
+
constructor(name: string, options?: RuntimeContextKeyOptions<T>);
|
|
42
|
+
}
|
|
43
|
+
export type ContextStoreKey<T> = ContextKey<T> | RuntimeContextKey<T>;
|
|
44
|
+
export declare function isDurableContextKey(key: ContextStoreKey<unknown>): key is ContextKey<unknown>;
|
|
45
|
+
export declare function isRuntimeContextKey(key: ContextStoreKey<unknown>): key is RuntimeContextKey<unknown>;
|
|
101
46
|
/**
|
|
102
|
-
*
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
47
|
+
* Looks up one registered durable key by name.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveContextKey(name: string): ContextKey<unknown> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Looks up one registered runtime key by name.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveRuntimeContextKey(name: string): RuntimeContextKey<unknown> | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns all registered runtime keys that participate in runtime-seed
|
|
56
|
+
* serialization across durable workflow boundaries.
|
|
106
57
|
*/
|
|
107
|
-
export declare function
|
|
58
|
+
export declare function getSerializableRuntimeContextKeys(): Iterable<RuntimeContextKey<unknown>>;
|
|
59
|
+
export {};
|
|
108
60
|
//# sourceMappingURL=key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../src/context/key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../src/context/key.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CACnD;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAC7B,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,oBAAoB,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CACrC;AAED,UAAU,wBAAwB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAUD;;;;;;GAMG;AACH,qBAAa,UAA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|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Registry of state keys (keys with an {@link ContextKey.initial | initial}
|
|
9
|
-
* factory). Used by `runStep` to hydrate and commit durable state.
|
|
2
|
+
* Global registries mapping key names to instances.
|
|
3
|
+
*
|
|
4
|
+
* Durable context keys are public/authored keys persisted on `session.context`.
|
|
5
|
+
* Runtime context keys are private framework keys used for seed values,
|
|
6
|
+
* providers, and runtime-only bookkeeping inside one step.
|
|
10
7
|
*/
|
|
11
|
-
const
|
|
8
|
+
const durableKeyRegistry = new Map();
|
|
9
|
+
const runtimeKeyRegistry = new Map();
|
|
10
|
+
const serializableRuntimeKeyRegistry = new Map();
|
|
11
|
+
const registeredKeyNames = new Set();
|
|
12
|
+
function registerKeyName(name) {
|
|
13
|
+
if (registeredKeyNames.has(name)) {
|
|
14
|
+
throw new Error(`Context key "${name}" was registered more than once.`);
|
|
15
|
+
}
|
|
16
|
+
registeredKeyNames.add(name);
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Use a `ContextKey` to declare a piece of durable, per-session state that
|
|
16
|
-
* tools, steps, and model callbacks can read and write inside an Ash
|
|
17
|
-
* execution scope. The key is declared once at module top-level and reused
|
|
18
|
-
* everywhere — the value is stored on the active session, not on the key.
|
|
19
|
-
*
|
|
20
|
-
* @example Declare a durable state key and use it from a tool
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { ContextKey, getState, setState } from "experimental-ash";
|
|
23
|
-
* import { defineTool } from "experimental-ash/tools";
|
|
24
|
-
* import { z } from "zod";
|
|
19
|
+
* Public durable context key.
|
|
25
20
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* // `initial` makes this a state key — its value survives across
|
|
31
|
-
* // workflow step boundaries and compaction. The name must be unique
|
|
32
|
-
* // across the whole agent process.
|
|
33
|
-
* const NoteListStateKey = new ContextKey<NoteListState>("notes", {
|
|
34
|
-
* initial: () => ({ notes: [] }),
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* export default defineTool({
|
|
38
|
-
* description: "Append a note, or read the running list.",
|
|
39
|
-
* inputSchema: z.object({ note: z.string().optional() }),
|
|
40
|
-
* async execute({ note }) {
|
|
41
|
-
* if (note) {
|
|
42
|
-
* setState(NoteListStateKey, (current) => ({
|
|
43
|
-
* notes: [...current.notes, note],
|
|
44
|
-
* }));
|
|
45
|
-
* }
|
|
46
|
-
* return getState(NoteListStateKey);
|
|
47
|
-
* },
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* Keys with an `initial` factory are **state keys** — durable mutable values
|
|
52
|
-
* hydrated from the session at step start and persisted back at step end.
|
|
53
|
-
* Keys without `initial` are ephemeral and only live for the current step.
|
|
54
|
-
*
|
|
55
|
-
* State keys participate in compaction via tool-level `onCompact` hooks
|
|
56
|
-
* declared on a `ToolDefinition`, not on the key itself.
|
|
57
|
-
*
|
|
58
|
-
* Keys that hold values which are not JSON-safe (e.g. live class instances)
|
|
59
|
-
* must declare a `codec` so the framework can serialize/deserialize at step
|
|
60
|
-
* boundaries.
|
|
61
|
-
*
|
|
62
|
-
* Every key self-registers in a global registry so the serialization layer
|
|
63
|
-
* can resolve string names back to typed keys without an explicit list.
|
|
64
|
-
* Construct each key exactly once at module scope; constructing the same
|
|
65
|
-
* key name twice is a programmer error.
|
|
21
|
+
* Values stored under a `ContextKey` are session-durable. The runtime
|
|
22
|
+
* hydrates them from `session.context` before each step and commits them back
|
|
23
|
+
* after the step completes.
|
|
66
24
|
*/
|
|
67
25
|
export class ContextKey {
|
|
26
|
+
codec;
|
|
68
27
|
name;
|
|
28
|
+
constructor(name, options = {}) {
|
|
29
|
+
registerKeyName(name);
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.codec = options.codec;
|
|
32
|
+
durableKeyRegistry.set(name, this);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Private runtime-only key used for seed values, providers, and other
|
|
37
|
+
* framework internals that must not be persisted on `session.context`.
|
|
38
|
+
*/
|
|
39
|
+
export class RuntimeContextKey {
|
|
69
40
|
codec;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* across workflow step boundaries. The factory returns the default value
|
|
73
|
-
* used when no persisted state exists on the session yet.
|
|
74
|
-
*/
|
|
75
|
-
initial;
|
|
41
|
+
name;
|
|
42
|
+
serializable;
|
|
76
43
|
constructor(name, options = {}) {
|
|
44
|
+
registerKeyName(name);
|
|
77
45
|
this.name = name;
|
|
78
46
|
this.codec = options.codec;
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
if (this.
|
|
82
|
-
|
|
47
|
+
this.serializable = options.serializable ?? false;
|
|
48
|
+
runtimeKeyRegistry.set(name, this);
|
|
49
|
+
if (this.serializable) {
|
|
50
|
+
serializableRuntimeKeyRegistry.set(name, this);
|
|
83
51
|
}
|
|
84
52
|
}
|
|
85
53
|
}
|
|
54
|
+
export function isDurableContextKey(key) {
|
|
55
|
+
return key instanceof ContextKey;
|
|
56
|
+
}
|
|
57
|
+
export function isRuntimeContextKey(key) {
|
|
58
|
+
return key instanceof RuntimeContextKey;
|
|
59
|
+
}
|
|
86
60
|
/**
|
|
87
|
-
* Looks up
|
|
61
|
+
* Looks up one registered durable key by name.
|
|
88
62
|
*/
|
|
89
|
-
export function
|
|
90
|
-
return
|
|
63
|
+
export function resolveContextKey(name) {
|
|
64
|
+
return durableKeyRegistry.get(name);
|
|
91
65
|
}
|
|
92
66
|
/**
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
67
|
+
* Looks up one registered runtime key by name.
|
|
68
|
+
*/
|
|
69
|
+
export function resolveRuntimeContextKey(name) {
|
|
70
|
+
return runtimeKeyRegistry.get(name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns all registered runtime keys that participate in runtime-seed
|
|
74
|
+
* serialization across durable workflow boundaries.
|
|
97
75
|
*/
|
|
98
|
-
export function
|
|
99
|
-
return
|
|
76
|
+
export function getSerializableRuntimeContextKeys() {
|
|
77
|
+
return serializableRuntimeKeyRegistry.values();
|
|
100
78
|
}
|
|
101
79
|
//# sourceMappingURL=key.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/context/key.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/context/key.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAC;AAClE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAsC,CAAC;AACzE,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAAsC,CAAC;AACrF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;AA0B7C,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,kCAAkC,CAAC,CAAC;IAC1E,CAAC;IAED,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IACZ,KAAK,CAAsB;IAC3B,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,UAAgC,EAAE;QAC1D,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,IAA2B,CAAC,CAAC;IAC5D,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACnB,KAAK,CAAsB;IAC3B,IAAI,CAAS;IACb,YAAY,CAAU;IAE/B,YAAY,IAAY,EAAE,UAAuC,EAAE;QACjE,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,KAAK,CAAC;QAClD,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAkC,CAAC,CAAC;QAEjE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,8BAA8B,CAAC,GAAG,CAAC,IAAI,EAAE,IAAkC,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF;AAID,MAAM,UAAU,mBAAmB,CAAC,GAA6B;IAC/D,OAAO,GAAG,YAAY,UAAU,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,GAA6B;IAE7B,OAAO,GAAG,YAAY,iBAAiB,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAC/C,OAAO,8BAA8B,CAAC,MAAM,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { type Channel, type SessionAuthContext, type SessionParent, type Session
|
|
|
2
2
|
import type { SandboxAccess } from "../execution/sandboxes/types.js";
|
|
3
3
|
import type { SkillAccess } from "../execution/skills/types.js";
|
|
4
4
|
import { getCompiledRuntimeAgentBundle } from "../runtime/sessions/compiled-agent-cache.js";
|
|
5
|
-
import {
|
|
5
|
+
import { RuntimeContextKey } from "./key.js";
|
|
6
6
|
export type { SessionAuthContext, SessionParent, SessionTurn } from "../channel/types.js";
|
|
7
7
|
export { AuthKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionIdKey, } from "./seed-keys.js";
|
|
8
8
|
/**
|
|
@@ -25,14 +25,14 @@ export interface Session {
|
|
|
25
25
|
readonly sessionId: string;
|
|
26
26
|
readonly turn: SessionTurn;
|
|
27
27
|
}
|
|
28
|
-
export declare const ChannelKey:
|
|
28
|
+
export declare const ChannelKey: RuntimeContextKey<Channel>;
|
|
29
29
|
/**
|
|
30
30
|
* Bundle returned by the compiled-agent cache. Carries the resolved agent
|
|
31
31
|
* graph, registries, and the active node's turn agent.
|
|
32
32
|
*/
|
|
33
33
|
export type CompiledBundle = Awaited<ReturnType<typeof getCompiledRuntimeAgentBundle>>;
|
|
34
|
-
export declare const BundleKey:
|
|
35
|
-
export declare const SessionKey:
|
|
36
|
-
export declare const SandboxKey:
|
|
37
|
-
export declare const SkillKey:
|
|
34
|
+
export declare const BundleKey: RuntimeContextKey<import("../runtime/sessions/compiled-agent-cache.js").CompiledRuntimeAgentBundle>;
|
|
35
|
+
export declare const SessionKey: RuntimeContextKey<Session>;
|
|
36
|
+
export declare const SandboxKey: RuntimeContextKey<SandboxAccess>;
|
|
37
|
+
export declare const SkillKey: RuntimeContextKey<SkillAccess>;
|
|
38
38
|
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/context/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,6BAA6B,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,MAAM,UAAU,4BAAgD,CAAC;AACxE,eAAO,MAAM,UAAU,kCAAsD,CAAC;AAC9E,eAAO,MAAM,QAAQ,gCAAkD,CAAC"}
|
package/dist/src/context/keys.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getChannelClassKind, } from "../channel/types.js";
|
|
2
2
|
import { deserializeRuntimeChannel } from "../runtime/channels/registry.js";
|
|
3
3
|
import { getCompiledRuntimeAgentBundle } from "../runtime/sessions/compiled-agent-cache.js";
|
|
4
|
-
import {
|
|
4
|
+
import { RuntimeContextKey } from "./key.js";
|
|
5
5
|
// Re-export seed keys so existing consumers of `context/keys` keep working.
|
|
6
6
|
export { AuthKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionIdKey, } from "./seed-keys.js";
|
|
7
|
-
export const ChannelKey = new
|
|
7
|
+
export const ChannelKey = new RuntimeContextKey("ash.channel", {
|
|
8
8
|
codec: {
|
|
9
9
|
serialize(channel) {
|
|
10
10
|
return {
|
|
@@ -20,8 +20,9 @@ export const ChannelKey = new ContextKey("ash.channel", {
|
|
|
20
20
|
return deserializeRuntimeChannel(bundle.channelRegistry, data);
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
+
serializable: true,
|
|
23
24
|
});
|
|
24
|
-
export const BundleKey = new
|
|
25
|
+
export const BundleKey = new RuntimeContextKey("ash.bundle", {
|
|
25
26
|
codec: {
|
|
26
27
|
serialize: (bundle) => ({
|
|
27
28
|
nodeSelector: bundle.nodeSelector,
|
|
@@ -35,11 +36,12 @@ export const BundleKey = new ContextKey("ash.bundle", {
|
|
|
35
36
|
});
|
|
36
37
|
},
|
|
37
38
|
},
|
|
39
|
+
serializable: true,
|
|
38
40
|
});
|
|
39
41
|
// ---------------------------------------------------------------------------
|
|
40
42
|
// Derived keys — reconstructed by providers each step, never serialized
|
|
41
43
|
// ---------------------------------------------------------------------------
|
|
42
|
-
export const SessionKey = new
|
|
43
|
-
export const SandboxKey = new
|
|
44
|
-
export const SkillKey = new
|
|
44
|
+
export const SessionKey = new RuntimeContextKey("ash.session");
|
|
45
|
+
export const SandboxKey = new RuntimeContextKey("ash.sandbox");
|
|
46
|
+
export const SkillKey = new RuntimeContextKey("ash.skill");
|
|
45
47
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/context/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/context/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI7C,4EAA4E;AAC5E,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC;AAqCxB,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAU,aAAa,EAAE;IACtE,KAAK,EAAE;QACL,SAAS,CAAC,OAAO;YACf,OAAO;gBACL,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAA2B,CAAC;gBAC9D,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE;aAC3B,CAAC;QACJ,CAAC;QACD,WAAW,CAAC,IAAI,EAAE,GAAG;YACnB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAErC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;YACJ,CAAC;YAED,OAAO,yBAAyB,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACjE,CAAC;KACF;IACD,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AAaH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAiB,YAAY,EAAE;IAC3E,KAAK,EAAE;QACL,SAAS,EAAE,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC;YACxC,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,MAAM,EAAE,MAAM,CAAC,uBAAuB;SACvC,CAAC;QACF,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE;YACpB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAwB,CAAC;YAC1D,OAAO,6BAA6B,CAAC;gBACnC,uBAAuB,EAAE,MAAM;gBAC/B,YAAY;aACb,CAAC,CAAC;QACL,CAAC;KACF;IACD,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AAEH,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAU,aAAa,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAgB,aAAa,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAc,WAAW,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HarnessSession } from "../harness/types.js";
|
|
2
2
|
import type { AshContext } from "./container.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContextStoreKey } from "./key.js";
|
|
4
4
|
/**
|
|
5
5
|
* Value returned by a provider's `create` method.
|
|
6
6
|
*
|
|
@@ -17,7 +17,7 @@ export interface ProviderResult<T> {
|
|
|
17
17
|
* to persist changes back onto the harness session.
|
|
18
18
|
*/
|
|
19
19
|
export interface ContextProvider<T> {
|
|
20
|
-
readonly key:
|
|
20
|
+
readonly key: ContextStoreKey<T>;
|
|
21
21
|
create(ctx: AshContext, session: HarnessSession): ProviderResult<T> | undefined | Promise<ProviderResult<T> | undefined>;
|
|
22
22
|
commit?(value: T, session: HarnessSession): HarnessSession | Promise<HarnessSession>;
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/context/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/context/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAEjC,MAAM,CACJ,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,cAAc,GACtB,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAE1E,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACtF"}
|
|
@@ -3,14 +3,12 @@ import { type AshContext } from "./container.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Runs one step inside the unified context.
|
|
5
5
|
*
|
|
6
|
-
* 1.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* 4.
|
|
12
|
-
* state (sandbox snapshots, skill activations) back onto the session.
|
|
13
|
-
* 5. Commits modified state keys back to `session.state`.
|
|
6
|
+
* 1. Iterates framework providers in order — each may populate its runtime
|
|
7
|
+
* key on `ctx` and optionally modify the harness session.
|
|
8
|
+
* 2. Runs `callback` inside the ALS scope so authored code can read context.
|
|
9
|
+
* 3. After the step, runs each provider's `commit` hook to persist mutable
|
|
10
|
+
* runtime state back onto the session.
|
|
11
|
+
* 4. Commits the full durable context bag back to `session.context`.
|
|
14
12
|
*/
|
|
15
13
|
export declare function runStep(ctx: AshContext, harnessSession: HarnessSession, callback: (session: HarnessSession) => Promise<StepResult>): Promise<StepResult>;
|
|
16
14
|
//# sourceMappingURL=run-step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-step.d.ts","sourceRoot":"","sources":["../../../src/context/run-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AAsBjE
|
|
1
|
+
{"version":3,"file":"run-step.d.ts","sourceRoot":"","sources":["../../../src/context/run-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,gBAAgB,CAAC;AAsBjE;;;;;;;;;GASG;AACH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,UAAU,EACf,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,UAAU,CAAC,GACzD,OAAO,CAAC,UAAU,CAAC,CAiCrB"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { contextStorage } from "./container.js";
|
|
2
|
+
import { commitDurableContext } from "./durable-context.js";
|
|
2
3
|
import { connectionProvider } from "./providers/connection.js";
|
|
3
4
|
import { sandboxProvider } from "./providers/sandbox.js";
|
|
4
5
|
import { sessionProvider } from "./providers/session.js";
|
|
5
6
|
import { skillProvider } from "./providers/skill.js";
|
|
6
|
-
import { commitStateKeys, hydrateStateKeys } from "./state.js";
|
|
7
7
|
/**
|
|
8
8
|
* Framework providers in dependency order.
|
|
9
9
|
*
|
|
10
10
|
* Session runs first (depends only on seed keys). Sandbox and skill depend on
|
|
11
11
|
* `BundleKey` (a seed) and optionally `SessionKey`.
|
|
12
12
|
*/
|
|
13
|
-
// biome-ignore lint/suspicious/noExplicitAny: heterogeneous provider collection
|
|
13
|
+
// biome-ignore lint/suspicious/noExplicitAny: heterogeneous provider collection
|
|
14
14
|
const providers = [
|
|
15
15
|
sessionProvider,
|
|
16
16
|
connectionProvider,
|
|
@@ -20,20 +20,16 @@ const providers = [
|
|
|
20
20
|
/**
|
|
21
21
|
* Runs one step inside the unified context.
|
|
22
22
|
*
|
|
23
|
-
* 1.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* 4.
|
|
29
|
-
* state (sandbox snapshots, skill activations) back onto the session.
|
|
30
|
-
* 5. Commits modified state keys back to `session.state`.
|
|
23
|
+
* 1. Iterates framework providers in order — each may populate its runtime
|
|
24
|
+
* key on `ctx` and optionally modify the harness session.
|
|
25
|
+
* 2. Runs `callback` inside the ALS scope so authored code can read context.
|
|
26
|
+
* 3. After the step, runs each provider's `commit` hook to persist mutable
|
|
27
|
+
* runtime state back onto the session.
|
|
28
|
+
* 4. Commits the full durable context bag back to `session.context`.
|
|
31
29
|
*/
|
|
32
30
|
export async function runStep(ctx, harnessSession, callback) {
|
|
33
31
|
let session = harnessSession;
|
|
34
|
-
// 1.
|
|
35
|
-
const stateSnapshot = await hydrateStateKeys(ctx, session);
|
|
36
|
-
// 2. Run providers
|
|
32
|
+
// 1. Run providers
|
|
37
33
|
for (const p of providers) {
|
|
38
34
|
const result = await p.create(ctx, session);
|
|
39
35
|
if (result !== undefined) {
|
|
@@ -43,17 +39,17 @@ export async function runStep(ctx, harnessSession, callback) {
|
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
|
-
//
|
|
42
|
+
// 2. Run callback inside ALS scope
|
|
47
43
|
const stepResult = await contextStorage.run(ctx, () => callback(session));
|
|
48
|
-
//
|
|
44
|
+
// 3. Commit providers
|
|
49
45
|
let committed = stepResult.session;
|
|
50
46
|
for (const p of providers) {
|
|
51
47
|
if (p.commit && ctx.has(p.key)) {
|
|
52
48
|
committed = await p.commit(ctx.get(p.key), committed);
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
|
-
//
|
|
56
|
-
committed =
|
|
51
|
+
// 4. Commit durable context
|
|
52
|
+
committed = commitDurableContext(ctx, committed);
|
|
57
53
|
if (committed === stepResult.session) {
|
|
58
54
|
return stepResult;
|
|
59
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-step.js","sourceRoot":"","sources":["../../../src/context/run-step.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-step.js","sourceRoot":"","sources":["../../../src/context/run-step.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,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AG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,SAAS,GAAG,oBAAoB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAEjD,IAAI,SAAS,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { SessionAuthContext, SessionParent } from "../channel/types.js";
|
|
13
13
|
import type { RunMode } from "../run-mode.js";
|
|
14
|
-
import {
|
|
15
|
-
export declare const AuthKey:
|
|
16
|
-
export declare const InitiatorAuthKey:
|
|
17
|
-
export declare const SessionIdKey:
|
|
18
|
-
export declare const ContinuationTokenKey:
|
|
19
|
-
export declare const ModeKey:
|
|
20
|
-
export declare const ParentSessionKey:
|
|
14
|
+
import { RuntimeContextKey } from "./key.js";
|
|
15
|
+
export declare const AuthKey: RuntimeContextKey<SessionAuthContext | null>;
|
|
16
|
+
export declare const InitiatorAuthKey: RuntimeContextKey<SessionAuthContext | null>;
|
|
17
|
+
export declare const SessionIdKey: RuntimeContextKey<string>;
|
|
18
|
+
export declare const ContinuationTokenKey: RuntimeContextKey<string>;
|
|
19
|
+
export declare const ModeKey: RuntimeContextKey<RunMode>;
|
|
20
|
+
export declare const ParentSessionKey: RuntimeContextKey<SessionParent>;
|
|
21
21
|
//# sourceMappingURL=seed-keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed-keys.d.ts","sourceRoot":"","sources":["../../../src/context/seed-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"seed-keys.d.ts","sourceRoot":"","sources":["../../../src/context/seed-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,OAAO,8CAElB,CAAC;AACH,eAAO,MAAM,gBAAgB,8CAK5B,CAAC;AACF,eAAO,MAAM,YAAY,2BAEvB,CAAC;AACH,eAAO,MAAM,oBAAoB,2BAE/B,CAAC;AACH,eAAO,MAAM,OAAO,4BAElB,CAAC;AACH,eAAO,MAAM,gBAAgB,kCAE3B,CAAC"}
|
|
@@ -9,11 +9,23 @@
|
|
|
9
9
|
* ({@link import("./keys.js").SessionKey SessionKey}, etc.) live in
|
|
10
10
|
* `context/keys.ts` which re-exports everything from this module.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
export const AuthKey = new
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
import { RuntimeContextKey } from "./key.js";
|
|
13
|
+
export const AuthKey = new RuntimeContextKey("ash.auth", {
|
|
14
|
+
serializable: true,
|
|
15
|
+
});
|
|
16
|
+
export const InitiatorAuthKey = new RuntimeContextKey("ash.initiatorAuth", {
|
|
17
|
+
serializable: true,
|
|
18
|
+
});
|
|
19
|
+
export const SessionIdKey = new RuntimeContextKey("ash.sessionId", {
|
|
20
|
+
serializable: true,
|
|
21
|
+
});
|
|
22
|
+
export const ContinuationTokenKey = new RuntimeContextKey("ash.continuationToken", {
|
|
23
|
+
serializable: true,
|
|
24
|
+
});
|
|
25
|
+
export const ModeKey = new RuntimeContextKey("ash.mode", {
|
|
26
|
+
serializable: true,
|
|
27
|
+
});
|
|
28
|
+
export const ParentSessionKey = new RuntimeContextKey("ash.parentSession", {
|
|
29
|
+
serializable: true,
|
|
30
|
+
});
|
|
19
31
|
//# sourceMappingURL=seed-keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed-keys.js","sourceRoot":"","sources":["../../../src/context/seed-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"seed-keys.js","sourceRoot":"","sources":["../../../src/context/seed-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAA4B,UAAU,EAAE;IAClF,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CACnD,mBAAmB,EACnB;IACE,YAAY,EAAE,IAAI;CACnB,CACF,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,iBAAiB,CAAS,eAAe,EAAE;IACzE,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,iBAAiB,CAAS,uBAAuB,EAAE;IACzF,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAU,UAAU,EAAE;IAChE,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAgB,mBAAmB,EAAE;IACxF,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC"}
|