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,54 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
import { hydrateDurableContext } from "../context/durable-context.js";
|
|
3
|
-
import { AuthKey, ChannelKey } from "../context/keys.js";
|
|
4
|
-
import { runStep } from "../context/run-step.js";
|
|
5
|
-
import { deserializeRuntimeContext } from "../context/serialize.js";
|
|
6
|
-
import { seedPendingInputRequestsContext } from "../harness/input-requests.js";
|
|
7
|
-
export async function prepareStepContext(input) {
|
|
8
|
-
const ctx = await deserializeRuntimeContext(input.serializedRuntimeContext);
|
|
9
|
-
await hydrateDurableContext(ctx, input.session);
|
|
10
|
-
seedPendingInputRequestsContext(ctx, input.session);
|
|
11
|
-
if (input.delivery?.auth !== undefined) {
|
|
12
|
-
ctx.set(AuthKey, input.delivery.auth ?? null);
|
|
13
|
-
}
|
|
14
|
-
const channel = ctx.get(ChannelKey);
|
|
15
|
-
const channelStateSnapshot = channel.serialize();
|
|
16
|
-
const resolved = input.delivery !== undefined ? await channel.onDeliver(ctx, input.delivery.payload) : undefined;
|
|
17
|
-
assertChannelStateIsStable({
|
|
18
|
-
channel,
|
|
19
|
-
phase: "onDeliver",
|
|
20
|
-
serializedState: channelStateSnapshot,
|
|
21
|
-
});
|
|
22
|
-
return {
|
|
23
|
-
channel,
|
|
24
|
-
channelStateSnapshot,
|
|
25
|
-
ctx,
|
|
26
|
-
input: resolved,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Runs one step inside the provider lifecycle and asserts that the
|
|
31
|
-
* channel's serialized state was not mutated during execution.
|
|
32
|
-
*
|
|
33
|
-
* Combines {@link runStep} with a post-step channel stability check so
|
|
34
|
-
* callers do not need to repeat the three-call sequence themselves.
|
|
35
|
-
*/
|
|
36
|
-
export async function runStepWithChannelGuard(prepared, session, callback) {
|
|
37
|
-
const stepResult = await runStep(prepared.ctx, session, callback);
|
|
38
|
-
assertChannelStateIsStable({
|
|
39
|
-
channel: prepared.channel,
|
|
40
|
-
phase: "step execution",
|
|
41
|
-
serializedState: prepared.channelStateSnapshot,
|
|
42
|
-
});
|
|
43
|
-
return stepResult;
|
|
44
|
-
}
|
|
45
|
-
function assertChannelStateIsStable(input) {
|
|
46
|
-
const currentState = input.channel.serialize();
|
|
47
|
-
if (isDeepStrictEqual(currentState, input.serializedState)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
throw new Error(`Channel "${input.channel.kind}" mutated its serialized state during ${input.phase}. ` +
|
|
51
|
-
"Channel constructor state must stay immutable after the run starts. " +
|
|
52
|
-
"Move per-session mutable data into durable context or session.internal instead.");
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=step-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step-context.js","sourceRoot":"","sources":["../../../src/execution/step-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAe/E,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAIxC;IACC,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5E,MAAM,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAChD,+BAA+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Y,EAAE,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAC3D,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CACb,YAAY,KAAK,CAAC,OAAO,CAAC,IAAI,yCAAyC,KAAK,CAAC,KAAK,IAAI;QACpF,sEAAsE;QACtE,iFAAiF,CACpF,CAAC;AACJ,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Migration Guide
|
|
2
|
-
|
|
3
|
-
Ash now has one durable authored-context model.
|
|
4
|
-
|
|
5
|
-
## Breaking Changes
|
|
6
|
-
|
|
7
|
-
- `getState(key)` is now `getContext(key)`.
|
|
8
|
-
- `setState(key, value)` is now `setContext(key, value)`.
|
|
9
|
-
- `ensureContext(key, valueOrFactory)` replaces `ContextKey({ initial })`.
|
|
10
|
-
- `ContextKeyOptions.initial` was removed.
|
|
11
|
-
- Public `ContextKey` values are session-durable by default.
|
|
12
|
-
- `HarnessSession.state` is now split into `session.context` and internal `session.internal`.
|
|
13
|
-
- Tool compaction hooks no longer return `sessionPatch`. Mutate durable context through `ctx` instead.
|
|
14
|
-
|
|
15
|
-
## Before
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { ContextKey, getState, setState } from "experimental-ash";
|
|
19
|
-
|
|
20
|
-
const NotesKey = new ContextKey("myapp.notes", {
|
|
21
|
-
initial: () => ({ notes: [] }),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
setState(NotesKey, (current) => ({
|
|
25
|
-
notes: [...current.notes, "hello"],
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
return getState(NotesKey);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## After
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
import { ContextKey, ensureContext, getContext, setContext } from "experimental-ash";
|
|
35
|
-
|
|
36
|
-
const NotesKey = new ContextKey("myapp.notes");
|
|
37
|
-
|
|
38
|
-
const current = ensureContext(NotesKey, () => ({ notes: [] }));
|
|
39
|
-
|
|
40
|
-
setContext(NotesKey, {
|
|
41
|
-
notes: [...current.notes, "hello"],
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return getContext(NotesKey);
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Channel Guidance
|
|
48
|
-
|
|
49
|
-
- Use `channel.onDeliver(ctx, payload)` to seed or extend durable context on every turn.
|
|
50
|
-
- Treat serialized channel state as immutable after the run starts.
|
|
51
|
-
- Move mutable per-session data into durable context or `session.internal`, not onto the channel instance.
|
|
52
|
-
|
|
53
|
-
## Compaction Hooks
|
|
54
|
-
|
|
55
|
-
Before:
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
onCompact() {
|
|
59
|
-
return {
|
|
60
|
-
sessionPatch: { state: {} },
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
After:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
onCompact({ ctx }) {
|
|
69
|
-
ctx.set(NotesKey, { notes: [] });
|
|
70
|
-
}
|
|
71
|
-
```
|