experimental-ash 0.2.0-alpha.21 → 0.2.0-alpha.23
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 +14 -7
- package/dist/src/channel/slack-channel.d.ts.map +1 -1
- package/dist/src/channel/slack-channel.js +21 -11
- package/dist/src/channel/slack-channel.js.map +1 -1
- package/dist/src/channel/types.d.ts +14 -14
- package/dist/src/channel/types.d.ts.map +1 -1
- package/dist/src/channel/types.js +6 -0
- package/dist/src/channel/types.js.map +1 -1
- package/dist/src/context/accessors.d.ts +24 -10
- package/dist/src/context/accessors.d.ts.map +1 -1
- package/dist/src/context/accessors.js +34 -16
- package/dist/src/context/accessors.js.map +1 -1
- package/dist/src/context/container.d.ts +43 -20
- package/dist/src/context/container.d.ts.map +1 -1
- package/dist/src/context/container.js +54 -22
- package/dist/src/context/container.js.map +1 -1
- package/dist/src/context/key.d.ts +68 -39
- package/dist/src/context/key.d.ts.map +1 -1
- package/dist/src/context/key.js +49 -62
- 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 +7 -9
- package/dist/src/context/keys.js.map +1 -1
- package/dist/src/context/node.d.ts +2 -2
- package/dist/src/context/node.d.ts.map +1 -1
- package/dist/src/context/node.js +1 -1
- package/dist/src/context/node.js.map +1 -1
- package/dist/src/context/provider.d.ts +24 -11
- package/dist/src/context/provider.d.ts.map +1 -1
- package/dist/src/context/providers/connection.d.ts +2 -2
- package/dist/src/context/providers/connection.d.ts.map +1 -1
- package/dist/src/context/providers/connection.js +1 -1
- package/dist/src/context/providers/connection.js.map +1 -1
- package/dist/src/context/providers/sandbox.d.ts +2 -2
- package/dist/src/context/providers/sandbox.d.ts.map +1 -1
- package/dist/src/context/providers/sandbox.js +2 -2
- package/dist/src/context/providers/sandbox.js.map +1 -1
- package/dist/src/context/providers/session.d.ts +2 -2
- package/dist/src/context/providers/session.d.ts.map +1 -1
- package/dist/src/context/providers/session.js +4 -4
- package/dist/src/context/providers/session.js.map +1 -1
- package/dist/src/context/providers/skill.d.ts +2 -2
- package/dist/src/context/providers/skill.d.ts.map +1 -1
- package/dist/src/context/providers/skill.js +2 -2
- package/dist/src/context/providers/skill.js.map +1 -1
- package/dist/src/context/run-step.d.ts +9 -8
- package/dist/src/context/run-step.d.ts.map +1 -1
- package/dist/src/context/run-step.js +32 -22
- 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 +7 -19
- package/dist/src/context/seed-keys.js.map +1 -1
- package/dist/src/context/serialize.d.ts +10 -9
- package/dist/src/context/serialize.d.ts.map +1 -1
- package/dist/src/context/serialize.js +18 -30
- package/dist/src/context/serialize.js.map +1 -1
- package/dist/src/execution/continuous-entry.d.ts +8 -6
- package/dist/src/execution/continuous-entry.d.ts.map +1 -1
- package/dist/src/execution/continuous-entry.js +27 -25
- 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 +1 -4
- package/dist/src/execution/continuous-runtime.js.map +1 -1
- package/dist/src/execution/node-step.js +1 -0
- package/dist/src/execution/node-step.js.map +1 -1
- package/dist/src/execution/runtime-context.d.ts +3 -3
- package/dist/src/execution/runtime-context.d.ts.map +1 -1
- package/dist/src/execution/runtime-context.js +3 -3
- package/dist/src/execution/runtime-context.js.map +1 -1
- package/dist/src/execution/sandboxes/read-file-tool.js +2 -2
- package/dist/src/execution/sandboxes/read-file-tool.js.map +1 -1
- package/dist/src/execution/sandboxes/require-sandbox.js +2 -2
- package/dist/src/execution/sandboxes/require-sandbox.js.map +1 -1
- package/dist/src/execution/sandboxes/write-file-tool.d.ts.map +1 -1
- package/dist/src/execution/sandboxes/write-file-tool.js +3 -3
- package/dist/src/execution/sandboxes/write-file-tool.js.map +1 -1
- package/dist/src/execution/subagent-tool.js +6 -6
- package/dist/src/execution/subagent-tool.js.map +1 -1
- package/dist/src/execution/tool-compaction.d.ts +3 -1
- package/dist/src/execution/tool-compaction.d.ts.map +1 -1
- package/dist/src/execution/tool-compaction.js +19 -8
- package/dist/src/execution/tool-compaction.js.map +1 -1
- package/dist/src/execution/types.d.ts +1 -0
- package/dist/src/execution/types.d.ts.map +1 -1
- package/dist/src/execution/workflow-entry.d.ts +5 -4
- package/dist/src/execution/workflow-entry.d.ts.map +1 -1
- package/dist/src/execution/workflow-entry.js +8 -3
- 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 +2 -3
- 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 +42 -17
- 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/execute-tool.d.ts +1 -0
- package/dist/src/harness/execute-tool.d.ts.map +1 -1
- package/dist/src/harness/execute-tool.js.map +1 -1
- package/dist/src/harness/input-requests.d.ts +2 -22
- package/dist/src/harness/input-requests.d.ts.map +1 -1
- package/dist/src/harness/input-requests.js +47 -41
- package/dist/src/harness/input-requests.js.map +1 -1
- package/dist/src/harness/tool-loop.d.ts.map +1 -1
- package/dist/src/harness/tool-loop.js +19 -1
- package/dist/src/harness/tool-loop.js.map +1 -1
- package/dist/src/harness/tools.js +5 -1
- package/dist/src/harness/tools.js.map +1 -1
- package/dist/src/harness/types.d.ts +3 -15
- package/dist/src/harness/types.d.ts.map +1 -1
- package/dist/src/harness/types.js +1 -6
- package/dist/src/harness/types.js.map +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/connection.d.ts.map +1 -1
- package/dist/src/internal/authored-definition/connection.js +14 -1
- package/dist/src/internal/authored-definition/connection.js.map +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 +0 -5
- 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/context/index.d.ts +17 -0
- package/dist/src/public/context/index.d.ts.map +1 -0
- package/dist/src/public/context/index.js +15 -0
- package/dist/src/public/context/index.js.map +1 -0
- package/dist/src/public/definitions/connections/mcp.d.ts +13 -0
- package/dist/src/public/definitions/connections/mcp.d.ts.map +1 -1
- package/dist/src/public/definitions/connections/mcp.js.map +1 -1
- package/dist/src/public/definitions/tool.d.ts +10 -6
- 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 -6
- package/dist/src/public/index.d.ts.map +1 -1
- package/dist/src/public/index.js +0 -3
- package/dist/src/public/index.js.map +1 -1
- package/dist/src/public/sandboxes/index.d.ts +1 -0
- package/dist/src/public/sandboxes/index.d.ts.map +1 -1
- package/dist/src/public/sandboxes/index.js +1 -0
- package/dist/src/public/sandboxes/index.js.map +1 -1
- package/dist/src/public/skills/index.d.ts +24 -0
- package/dist/src/public/skills/index.d.ts.map +1 -0
- package/dist/src/public/skills/index.js +23 -0
- package/dist/src/public/skills/index.js.map +1 -0
- package/dist/src/public/tools/defaults.d.ts +4 -4
- package/dist/src/public/tools/defaults.js +4 -4
- package/dist/src/runtime/connections/registry.d.ts +6 -0
- package/dist/src/runtime/connections/registry.d.ts.map +1 -1
- package/dist/src/runtime/connections/registry.js +8 -0
- package/dist/src/runtime/connections/registry.js.map +1 -1
- package/dist/src/runtime/connections/types.d.ts +2 -0
- package/dist/src/runtime/connections/types.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/connection-execute.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/connection-execute.js +17 -6
- package/dist/src/runtime/framework-tools/connection-execute.js.map +1 -1
- 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 +4 -4
- package/dist/src/runtime/framework-tools/connection-search.js.map +1 -1
- package/dist/src/runtime/framework-tools/file-state.d.ts +5 -7
- package/dist/src/runtime/framework-tools/file-state.d.ts.map +1 -1
- package/dist/src/runtime/framework-tools/file-state.js +4 -6
- package/dist/src/runtime/framework-tools/file-state.js.map +1 -1
- package/dist/src/runtime/framework-tools/skill.js +3 -3
- package/dist/src/runtime/framework-tools/skill.js.map +1 -1
- package/dist/src/runtime/framework-tools/todo.js +3 -3
- package/dist/src/runtime/framework-tools/todo.js.map +1 -1
- package/dist/src/runtime/prompt/connections.d.ts.map +1 -1
- package/dist/src/runtime/prompt/connections.js +3 -2
- package/dist/src/runtime/prompt/connections.js.map +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +3 -2
- package/dist/src/runtime/resolve-agent-graph.js.map +1 -1
- package/dist/src/runtime/resolve-connection.d.ts.map +1 -1
- package/dist/src/runtime/resolve-connection.js +3 -0
- package/dist/src/runtime/resolve-connection.js.map +1 -1
- package/dist/src/runtime/sessions/auth.d.ts +1 -1
- package/dist/src/runtime/types.d.ts +13 -0
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/docs/internals/context.md +257 -81
- package/docs/public/README.md +17 -19
- package/docs/public/channels/README.md +9 -3
- package/docs/public/sandboxes.md +1 -1
- package/docs/public/session-context.md +97 -51
- package/docs/public/skills.md +2 -2
- package/docs/public/tools.md +26 -18
- package/docs/public/typescript-api.md +34 -29
- package/package.json +11 -1
- package/dist/src/context/durable-context.d.ts +0 -18
- package/dist/src/context/durable-context.d.ts.map +0 -1
- package/dist/src/context/durable-context.js +0 -49
- package/dist/src/context/durable-context.js.map +0 -1
- package/dist/src/execution/step-context.d.ts +0 -27
- package/dist/src/execution/step-context.d.ts.map +0 -1
- package/dist/src/execution/step-context.js +0 -54
- package/dist/src/execution/step-context.js.map +0 -1
- package/docs/public/migration-guide.md +0 -71
|
@@ -1,39 +1,63 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { resolveKey } from "./key.js";
|
|
2
3
|
/**
|
|
3
4
|
* Default mutable implementation of {@link AshContext}.
|
|
4
5
|
*/
|
|
5
|
-
export class
|
|
6
|
-
|
|
6
|
+
export class ContextContainer {
|
|
7
|
+
_durableValues = new Map();
|
|
8
|
+
_virtualValues = new Map();
|
|
7
9
|
get(key) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
throw new Error(`Context key "${key.name}" is not set.`);
|
|
10
|
+
if (this._virtualValues.has(key.name)) {
|
|
11
|
+
return this._virtualValues.get(key.name);
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return this._durableValues.get(key.name);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
require(key) {
|
|
16
|
+
if (!this.has(key)) {
|
|
17
|
+
throw new Error(`Context key "${key.name}" is not set.`);
|
|
18
|
+
}
|
|
19
|
+
return this.get(key);
|
|
16
20
|
}
|
|
17
21
|
has(key) {
|
|
18
|
-
return this.
|
|
22
|
+
return this._virtualValues.has(key.name) || this._durableValues.has(key.name);
|
|
19
23
|
}
|
|
20
|
-
set(key,
|
|
21
|
-
const value = typeof
|
|
22
|
-
?
|
|
23
|
-
:
|
|
24
|
-
this.
|
|
24
|
+
set(key, valueOrUpdater) {
|
|
25
|
+
const value = typeof valueOrUpdater === "function"
|
|
26
|
+
? valueOrUpdater(this.get(key))
|
|
27
|
+
: valueOrUpdater;
|
|
28
|
+
this._durableValues.set(key.name, value);
|
|
25
29
|
return value;
|
|
26
30
|
}
|
|
27
|
-
ensure(key,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return entry.value;
|
|
31
|
+
ensure(key, create) {
|
|
32
|
+
if (this.has(key)) {
|
|
33
|
+
return this.require(key);
|
|
31
34
|
}
|
|
32
|
-
return this.set(key,
|
|
35
|
+
return this.set(key, create());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Clears all step-local provider values from the context.
|
|
39
|
+
*
|
|
40
|
+
* The runtime calls this before rebuilding context providers for a new
|
|
41
|
+
* step.
|
|
42
|
+
*/
|
|
43
|
+
clearVirtualContext() {
|
|
44
|
+
this._virtualValues.clear();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Stores a step-local provider value for one key.
|
|
48
|
+
*
|
|
49
|
+
* Virtual values shadow durable values for the lifetime of the current
|
|
50
|
+
* step and are excluded from serialization.
|
|
51
|
+
*/
|
|
52
|
+
setVirtualContext(key, value) {
|
|
53
|
+
this._virtualValues.set(key.name, value);
|
|
33
54
|
}
|
|
34
55
|
*entries() {
|
|
35
|
-
for (const
|
|
36
|
-
|
|
56
|
+
for (const [name, value] of this._durableValues) {
|
|
57
|
+
const key = resolveKey(name);
|
|
58
|
+
if (key !== undefined) {
|
|
59
|
+
yield [key, value];
|
|
60
|
+
}
|
|
37
61
|
}
|
|
38
62
|
}
|
|
39
63
|
}
|
|
@@ -41,7 +65,7 @@ export const contextStorage = new AsyncLocalStorage();
|
|
|
41
65
|
/**
|
|
42
66
|
* Returns the active context, throwing when called outside a managed scope.
|
|
43
67
|
*/
|
|
44
|
-
export function
|
|
68
|
+
export function loadContext() {
|
|
45
69
|
const ctx = contextStorage.getStore();
|
|
46
70
|
if (ctx === undefined) {
|
|
47
71
|
throw new Error("No active Ash context. " +
|
|
@@ -49,4 +73,12 @@ export function requireContext() {
|
|
|
49
73
|
}
|
|
50
74
|
return ctx;
|
|
51
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Narrows a {@link ContextContainer} to the {@link ContextAccessor}
|
|
78
|
+
* interface. Used by runtime entry points to pass the context to channel
|
|
79
|
+
* `onDeliver` callbacks without exposing implementation details.
|
|
80
|
+
*/
|
|
81
|
+
export function toContextAccessor(ctx) {
|
|
82
|
+
return ctx;
|
|
83
|
+
}
|
|
52
84
|
//# sourceMappingURL=container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/context/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/context/container.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,60 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Read-only view over the active context.
|
|
3
|
+
*
|
|
4
|
+
* Used by context providers and codec deserialization to read values
|
|
5
|
+
* without mutating durable context.
|
|
6
|
+
*/
|
|
7
|
+
export interface ContextReader {
|
|
8
|
+
get<T>(key: ContextKey<T>): T | undefined;
|
|
9
|
+
require<T>(key: ContextKey<T>): T;
|
|
10
|
+
has<T>(key: ContextKey<T>): boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read/write view over the active context.
|
|
14
|
+
*
|
|
15
|
+
* Extends {@link ContextReader} with durable write operations. This is
|
|
16
|
+
* the narrow contract shared by {@link AshContext} and the channel-facing
|
|
17
|
+
* `ContextAccessor`.
|
|
18
|
+
*/
|
|
19
|
+
export interface ContextAccessor extends ContextReader {
|
|
20
|
+
set<T>(key: ContextKey<T>, updater: T | ((current: T | undefined) => T)): T;
|
|
21
|
+
ensure<T>(key: ContextKey<T>, create: () => T): T;
|
|
4
22
|
}
|
|
5
23
|
/**
|
|
6
24
|
* Serialization hooks for one context key.
|
|
7
25
|
*
|
|
8
|
-
* `deserialize` receives the already-hydrated context so codecs can
|
|
9
|
-
* earlier
|
|
26
|
+
* `deserialize` receives the already-hydrated durable context so codecs can
|
|
27
|
+
* depend on earlier durable keys such as the compiled runtime bundle.
|
|
10
28
|
*/
|
|
11
29
|
export interface ContextKeyCodec<T> {
|
|
12
30
|
serialize(value: T): unknown;
|
|
13
|
-
deserialize(data: unknown, ctx:
|
|
31
|
+
deserialize(data: unknown, ctx: ContextReader): T | Promise<T>;
|
|
14
32
|
}
|
|
15
33
|
export interface ContextKeyOptions<T> {
|
|
16
34
|
readonly codec?: ContextKeyCodec<T>;
|
|
17
35
|
}
|
|
18
|
-
interface RuntimeContextKeyOptions<T> extends ContextKeyOptions<T> {
|
|
19
|
-
readonly serializable?: boolean;
|
|
20
|
-
}
|
|
21
36
|
/**
|
|
22
|
-
*
|
|
37
|
+
* Typed key that identifies a named context slot.
|
|
38
|
+
*
|
|
39
|
+
* `ContextKey` is the single authored lookup identity for Ash context.
|
|
40
|
+
* Durable values are written explicitly through `set()` / `ensure()`.
|
|
41
|
+
* Virtual values may also be derived each step by a `ContextProvider` and
|
|
42
|
+
* read through the same key.
|
|
43
|
+
*
|
|
44
|
+
* When a key stores a durable value that is not already JSON-safe, declare a
|
|
45
|
+
* `codec` so the runtime can serialize and deserialize that durable value at
|
|
46
|
+
* step boundaries.
|
|
47
|
+
*
|
|
48
|
+
* @example Declare a durable context key and use it from a tool
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { ContextKey, getContext, setContext } from "experimental-ash/context";
|
|
51
|
+
* import { defineTool } from "experimental-ash/tools";
|
|
52
|
+
* import { z } from "zod";
|
|
53
|
+
*
|
|
54
|
+
* interface NoteListContext {
|
|
55
|
+
* readonly notes: readonly string[];
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* const NoteListKey = new ContextKey<NoteListContext>("notes");
|
|
23
59
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
60
|
+
* export default defineTool({
|
|
61
|
+
* description: "Append a note, or read the running list.",
|
|
62
|
+
* inputSchema: z.object({ note: z.string().optional() }),
|
|
63
|
+
* async execute({ note }) {
|
|
64
|
+
* if (note) {
|
|
65
|
+
* setContext(NoteListKey, (current) => ({
|
|
66
|
+
* notes: [...(current?.notes ?? []), note],
|
|
67
|
+
* }));
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* return getContext(NoteListKey);
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Every key self-registers in a global registry so the serialization layer
|
|
76
|
+
* can resolve string names back to typed keys without an explicit list.
|
|
77
|
+
* Construct each key exactly once at module scope; constructing the same
|
|
78
|
+
* key name twice is a programmer error.
|
|
27
79
|
*/
|
|
28
80
|
export declare class ContextKey<T> {
|
|
29
|
-
readonly codec?: ContextKeyCodec<T>;
|
|
30
81
|
readonly name: string;
|
|
31
|
-
constructor(name: string, options?: ContextKeyOptions<T>);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Private runtime-only key used for seed values, providers, and other
|
|
35
|
-
* framework internals that must not be persisted on `session.context`.
|
|
36
|
-
*/
|
|
37
|
-
export declare class RuntimeContextKey<T> {
|
|
38
82
|
readonly codec?: ContextKeyCodec<T>;
|
|
39
|
-
|
|
40
|
-
readonly serializable: boolean;
|
|
41
|
-
constructor(name: string, options?: RuntimeContextKeyOptions<T>);
|
|
83
|
+
constructor(name: string, options?: ContextKeyOptions<T>);
|
|
42
84
|
}
|
|
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>;
|
|
46
|
-
/**
|
|
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
85
|
/**
|
|
55
|
-
*
|
|
56
|
-
* serialization across durable workflow boundaries.
|
|
86
|
+
* Looks up a registered key by name. Returns `undefined` for unknown names.
|
|
57
87
|
*/
|
|
58
|
-
export declare function
|
|
59
|
-
export {};
|
|
88
|
+
export declare function resolveKey(name: string): ContextKey<unknown> | undefined;
|
|
60
89
|
//# 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":"AAOA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC1C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAClC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACrC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IAC5E,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,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,aAAa,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,UAAU,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;gBAExB,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAiB,CAAC,CAAC,CAAM;CAK7D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,CAExE"}
|
package/dist/src/context/key.js
CHANGED
|
@@ -1,79 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Global
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Runtime context keys are private framework keys used for seed values,
|
|
6
|
-
* providers, and runtime-only bookkeeping inside one step.
|
|
2
|
+
* Global registry mapping key names to instances. Populated automatically
|
|
3
|
+
* by the {@link ContextKey} constructor so `deserializeContext` can resolve
|
|
4
|
+
* string names back to typed keys without an explicit list.
|
|
7
5
|
*/
|
|
8
|
-
const
|
|
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
|
-
}
|
|
6
|
+
const keyRegistry = new Map();
|
|
18
7
|
/**
|
|
19
|
-
*
|
|
8
|
+
* Typed key that identifies a named context slot.
|
|
9
|
+
*
|
|
10
|
+
* `ContextKey` is the single authored lookup identity for Ash context.
|
|
11
|
+
* Durable values are written explicitly through `set()` / `ensure()`.
|
|
12
|
+
* Virtual values may also be derived each step by a `ContextProvider` and
|
|
13
|
+
* read through the same key.
|
|
14
|
+
*
|
|
15
|
+
* When a key stores a durable value that is not already JSON-safe, declare a
|
|
16
|
+
* `codec` so the runtime can serialize and deserialize that durable value at
|
|
17
|
+
* step boundaries.
|
|
18
|
+
*
|
|
19
|
+
* @example Declare a durable context key and use it from a tool
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { ContextKey, getContext, setContext } from "experimental-ash/context";
|
|
22
|
+
* import { defineTool } from "experimental-ash/tools";
|
|
23
|
+
* import { z } from "zod";
|
|
24
|
+
*
|
|
25
|
+
* interface NoteListContext {
|
|
26
|
+
* readonly notes: readonly string[];
|
|
27
|
+
* }
|
|
20
28
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
29
|
+
* const NoteListKey = new ContextKey<NoteListContext>("notes");
|
|
30
|
+
*
|
|
31
|
+
* export default defineTool({
|
|
32
|
+
* description: "Append a note, or read the running list.",
|
|
33
|
+
* inputSchema: z.object({ note: z.string().optional() }),
|
|
34
|
+
* async execute({ note }) {
|
|
35
|
+
* if (note) {
|
|
36
|
+
* setContext(NoteListKey, (current) => ({
|
|
37
|
+
* notes: [...(current?.notes ?? []), note],
|
|
38
|
+
* }));
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* return getContext(NoteListKey);
|
|
42
|
+
* },
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Every key self-registers in a global registry so the serialization layer
|
|
47
|
+
* can resolve string names back to typed keys without an explicit list.
|
|
48
|
+
* Construct each key exactly once at module scope; constructing the same
|
|
49
|
+
* key name twice is a programmer error.
|
|
24
50
|
*/
|
|
25
51
|
export class ContextKey {
|
|
26
|
-
codec;
|
|
27
52
|
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 {
|
|
40
53
|
codec;
|
|
41
|
-
name;
|
|
42
|
-
serializable;
|
|
43
54
|
constructor(name, options = {}) {
|
|
44
|
-
registerKeyName(name);
|
|
45
55
|
this.name = name;
|
|
46
56
|
this.codec = options.codec;
|
|
47
|
-
|
|
48
|
-
runtimeKeyRegistry.set(name, this);
|
|
49
|
-
if (this.serializable) {
|
|
50
|
-
serializableRuntimeKeyRegistry.set(name, this);
|
|
51
|
-
}
|
|
57
|
+
keyRegistry.set(name, this);
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
|
-
export function isDurableContextKey(key) {
|
|
55
|
-
return key instanceof ContextKey;
|
|
56
|
-
}
|
|
57
|
-
export function isRuntimeContextKey(key) {
|
|
58
|
-
return key instanceof RuntimeContextKey;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Looks up one registered durable key by name.
|
|
62
|
-
*/
|
|
63
|
-
export function resolveContextKey(name) {
|
|
64
|
-
return durableKeyRegistry.get(name);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Looks up one registered runtime key by name.
|
|
68
|
-
*/
|
|
69
|
-
export function resolveRuntimeContextKey(name) {
|
|
70
|
-
return runtimeKeyRegistry.get(name);
|
|
71
|
-
}
|
|
72
60
|
/**
|
|
73
|
-
*
|
|
74
|
-
* serialization across durable workflow boundaries.
|
|
61
|
+
* Looks up a registered key by name. Returns `undefined` for unknown names.
|
|
75
62
|
*/
|
|
76
|
-
export function
|
|
77
|
-
return
|
|
63
|
+
export function resolveKey(name) {
|
|
64
|
+
return keyRegistry.get(name);
|
|
78
65
|
}
|
|
79
66
|
//# 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;;;;GAIG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;AAyC3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,UAAU;IACZ,IAAI,CAAS;IACb,KAAK,CAAsB;IAEpC,YAAY,IAAY,EAAE,UAAgC,EAAE;QAC1D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAA2B,CAAC,CAAC;IACrD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/B,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 { ContextKey } 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: ContextKey<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: ContextKey<import("../runtime/sessions/compiled-agent-cache.js").CompiledRuntimeAgentBundle>;
|
|
35
|
+
export declare const SessionKey: ContextKey<Session>;
|
|
36
|
+
export declare const SandboxKey: ContextKey<SandboxAccess>;
|
|
37
|
+
export declare const SkillKey: ContextKey<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,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,
|
|
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,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE1F,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAC;AAMxB;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAWD,eAAO,MAAM,UAAU,qBAoBrB,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC;AAOvF,eAAO,MAAM,SAAS,8FAcpB,CAAC;AAMH,eAAO,MAAM,UAAU,qBAAyC,CAAC;AACjE,eAAO,MAAM,UAAU,2BAA+C,CAAC;AACvE,eAAO,MAAM,QAAQ,yBAA2C,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 { ContextKey } 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 ContextKey("ash.channel", {
|
|
8
8
|
codec: {
|
|
9
9
|
serialize(channel) {
|
|
10
10
|
return {
|
|
@@ -13,16 +13,15 @@ export const ChannelKey = new RuntimeContextKey("ash.channel", {
|
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
15
|
deserialize(data, ctx) {
|
|
16
|
-
const bundle = ctx.
|
|
16
|
+
const bundle = ctx.get(BundleKey);
|
|
17
17
|
if (bundle === undefined) {
|
|
18
18
|
throw new Error('Cannot deserialize "ash.channel" before "ash.bundle". The runtime bundle must be present in context.');
|
|
19
19
|
}
|
|
20
20
|
return deserializeRuntimeChannel(bundle.channelRegistry, data);
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
-
serializable: true,
|
|
24
23
|
});
|
|
25
|
-
export const BundleKey = new
|
|
24
|
+
export const BundleKey = new ContextKey("ash.bundle", {
|
|
26
25
|
codec: {
|
|
27
26
|
serialize: (bundle) => ({
|
|
28
27
|
nodeSelector: bundle.nodeSelector,
|
|
@@ -36,12 +35,11 @@ export const BundleKey = new RuntimeContextKey("ash.bundle", {
|
|
|
36
35
|
});
|
|
37
36
|
},
|
|
38
37
|
},
|
|
39
|
-
serializable: true,
|
|
40
38
|
});
|
|
41
39
|
// ---------------------------------------------------------------------------
|
|
42
40
|
// Derived keys — reconstructed by providers each step, never serialized
|
|
43
41
|
// ---------------------------------------------------------------------------
|
|
44
|
-
export const SessionKey = new
|
|
45
|
-
export const SandboxKey = new
|
|
46
|
-
export const SkillKey = new
|
|
42
|
+
export const SessionKey = new ContextKey("ash.session");
|
|
43
|
+
export const SandboxKey = new ContextKey("ash.sandbox");
|
|
44
|
+
export const SkillKey = new ContextKey("ash.skill");
|
|
47
45
|
//# 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,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,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,UAAU,CAAU,aAAa,EAAE;IAC/D,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,GAAG,CAAC,SAAS,CAAC,CAAC;YAElC,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;CACF,CAAC,CAAC;AAaH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,UAAU,CAAiB,YAAY,EAAE;IACpE,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;CACF,CAAC,CAAC;AAEH,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAU,aAAa,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAgB,aAAa,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAc,WAAW,CAAC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContextReader } from "./provider.js";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the active runtime node from the compiled bundle on the
|
|
4
4
|
* context. The bundle is already resolved to the correct node (root or
|
|
5
5
|
* subagent) at run start.
|
|
6
6
|
*/
|
|
7
|
-
export declare function getActiveRuntimeNode(ctx:
|
|
7
|
+
export declare function getActiveRuntimeNode(ctx: ContextReader): import("../runtime/graph.js").ResolvedRuntimeAgentNode;
|
|
8
8
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/context/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/context/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,0DAEtD"}
|
package/dist/src/context/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/context/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/context/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AAC3C,CAAC"}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import type { HarnessSession } from "../harness/types.js";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { ContextKey, ContextReader } from "./key.js";
|
|
3
|
+
export type { ContextReader } from "./key.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Public derive-only provider that rebuilds one virtual value each step.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Provider output is available through `require(key)` for the current
|
|
8
|
+
* step and is never serialized.
|
|
9
|
+
*/
|
|
10
|
+
export interface ContextProvider<T> {
|
|
11
|
+
readonly key: ContextKey<T>;
|
|
12
|
+
create(ctx: ContextReader): T | undefined | Promise<T | undefined>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Value returned by a framework provider's `create` method.
|
|
16
|
+
*
|
|
17
|
+
* `value` is the live step-local instance stored on the context. `session`
|
|
18
|
+
* carries an optional harness session patch produced while deriving that
|
|
19
|
+
* value.
|
|
9
20
|
*/
|
|
10
21
|
export interface ProviderResult<T> {
|
|
11
22
|
readonly value: T;
|
|
12
23
|
readonly session?: HarnessSession;
|
|
13
24
|
}
|
|
14
25
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
26
|
+
* Framework-only provider contract.
|
|
27
|
+
*
|
|
28
|
+
* Framework providers may derive virtual values from context, observe the
|
|
29
|
+
* current harness session, and optionally commit mutable provider-owned state
|
|
30
|
+
* back onto the harness session after the authored step completes.
|
|
18
31
|
*/
|
|
19
|
-
export interface
|
|
20
|
-
readonly key:
|
|
21
|
-
create(ctx:
|
|
32
|
+
export interface FrameworkContextProvider<T> {
|
|
33
|
+
readonly key: ContextKey<T>;
|
|
34
|
+
create(ctx: ContextReader, session: HarnessSession): ProviderResult<T> | undefined | Promise<ProviderResult<T> | undefined>;
|
|
22
35
|
commit?(value: T, session: HarnessSession): HarnessSession | Promise<HarnessSession>;
|
|
23
36
|
}
|
|
24
37
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -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,
|
|
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,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1D,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAE5B,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACpE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAE5B,MAAM,CACJ,GAAG,EAAE,aAAa,EAClB,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ConnectionRegistry } from "../../runtime/connections/types.js";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const connectionProvider:
|
|
2
|
+
import type { FrameworkContextProvider } from "../provider.js";
|
|
3
|
+
export declare const connectionProvider: FrameworkContextProvider<ConnectionRegistry>;
|
|
4
4
|
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/context/providers/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/context/providers/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,kBAAkB,EAAE,wBAAwB,CAAC,kBAAkB,CAY3E,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { getActiveRuntimeNode } from "../node.js";
|
|
|
5
5
|
export const connectionProvider = {
|
|
6
6
|
key: ConnectionRegistryKey,
|
|
7
7
|
create(ctx, _session) {
|
|
8
|
-
const bundle = ctx.
|
|
8
|
+
const bundle = ctx.get(BundleKey);
|
|
9
9
|
if (bundle === undefined)
|
|
10
10
|
return undefined;
|
|
11
11
|
const node = getActiveRuntimeNode(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../src/context/providers/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,CAAC,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../src/context/providers/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,CAAC,MAAM,kBAAkB,GAAiD;IAC9E,GAAG,EAAE,qBAAqB;IAE1B,MAAM,CAAC,GAAG,EAAE,QAAQ;QAClB,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC3C,MAAM,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC;QAC5C,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE/D,OAAO,EAAE,KAAK,EAAE,IAAI,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;IAC5D,CAAC;CACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SandboxAccess } from "../../execution/sandboxes/types.js";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const sandboxProvider:
|
|
2
|
+
import type { FrameworkContextProvider } from "../provider.js";
|
|
3
|
+
export declare const sandboxProvider: FrameworkContextProvider<SandboxAccess>;
|
|
4
4
|
//# sourceMappingURL=sandbox.d.ts.map
|