@noetic-tools/core 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -11
- package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
- package/dist/adapters/in-memory-fs-adapter.js +1 -1
- package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
- package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +8 -0
- package/dist/adapters/in-memory-subprocess/manifest-persistence.js +56 -0
- package/dist/adapters/in-memory-subprocess/metadata.d.ts +12 -0
- package/dist/adapters/in-memory-subprocess/metadata.js +58 -0
- package/dist/adapters/in-memory-subprocess/step-completion.d.ts +3 -0
- package/dist/adapters/in-memory-subprocess/step-completion.js +86 -0
- package/dist/adapters/in-memory-subprocess/types.d.ts +88 -0
- package/dist/adapters/in-memory-subprocess/types.js +2 -0
- package/dist/adapters/in-memory-subprocess-adapter.d.ts +12 -4
- package/dist/adapters/in-memory-subprocess-adapter.js +164 -55
- package/dist/adapters/openrouter.d.ts +16 -7
- package/dist/adapters/openrouter.js +68 -7
- package/dist/builders/channel-builder.d.ts +1 -1
- package/dist/builders/control-flow-builders.d.ts +3 -3
- package/dist/builders/control-flow-builders.js +9 -4
- package/dist/builders/every.d.ts +3 -3
- package/dist/builders/every.js +5 -2
- package/dist/builders/layer-provides-builders.d.ts +1 -32
- package/dist/builders/layer-provides-builders.js +1 -33
- package/dist/builders/loop-builder.d.ts +2 -2
- package/dist/builders/loop-builder.js +5 -2
- package/dist/builders/memory-builder.d.ts +1 -1
- package/dist/builders/memory-builder.js +1 -1
- package/dist/builders/provide-builder.d.ts +2 -2
- package/dist/builders/provide-builder.js +5 -2
- package/dist/builders/spawn-builder.d.ts +22 -9
- package/dist/builders/spawn-builder.js +17 -3
- package/dist/builders/step-builders.d.ts +51 -30
- package/dist/builders/step-builders.js +31 -12
- package/dist/builders/tool-builder.d.ts +7 -3
- package/dist/builders/tool-builder.js +3 -1
- package/dist/builders/workflow-hydrator.d.ts +38 -0
- package/dist/builders/workflow-hydrator.js +336 -0
- package/dist/conditions/conditions.d.ts +4 -4
- package/dist/conditions/conditions.js +2 -2
- package/dist/errors/noetic-error.d.ts +1 -1
- package/dist/errors/noetic-error.js +2 -0
- package/dist/{runtime → harness}/agent-harness.d.ts +65 -45
- package/dist/harness/agent-harness.js +576 -0
- package/dist/harness/deps/adapters.d.ts +4 -0
- package/dist/harness/deps/adapters.js +4 -0
- package/dist/harness/deps/interpreter.d.ts +5 -0
- package/dist/harness/deps/interpreter.js +4 -0
- package/dist/harness/deps/memory.d.ts +5 -0
- package/dist/harness/deps/memory.js +4 -0
- package/dist/harness/deps/runtime.d.ts +10 -0
- package/dist/harness/deps/runtime.js +7 -0
- package/dist/harness/deps/types.d.ts +17 -0
- package/dist/harness/deps/types.js +1 -0
- package/dist/harness/model-call.d.ts +50 -0
- package/dist/harness/model-call.js +694 -0
- package/dist/harness/model-schema.d.ts +19 -0
- package/dist/harness/model-schema.js +46 -0
- package/dist/harness/step-bootstrap.d.ts +25 -0
- package/dist/harness/step-bootstrap.js +170 -0
- package/dist/index.d.ts +114 -76
- package/dist/index.js +74 -50
- package/dist/internal-test.d.ts +4 -4
- package/dist/internal-test.js +4 -4
- package/dist/interpreter/action-deps.d.ts +12 -0
- package/dist/interpreter/action-deps.js +10 -0
- package/dist/interpreter/action-types.d.ts +8 -0
- package/dist/interpreter/action-types.js +1 -0
- package/dist/interpreter/collect-tools.d.ts +2 -2
- package/dist/interpreter/collect-tools.js +6 -2
- package/dist/interpreter/execute-action.d.ts +22 -0
- package/dist/interpreter/execute-action.js +527 -0
- package/dist/interpreter/{execute-every.d.ts → execute-control.d.ts} +8 -2
- package/dist/interpreter/execute-control.js +530 -0
- package/dist/interpreter/execute.d.ts +16 -3
- package/dist/interpreter/execute.js +154 -51
- package/dist/interpreter/message-helpers.d.ts +1 -9
- package/dist/interpreter/message-helpers.js +1 -42
- package/dist/interpreter/step-dispatcher.d.ts +61 -0
- package/dist/interpreter/step-dispatcher.js +67 -0
- package/dist/interpreter/typeguards.d.ts +8 -15
- package/dist/interpreter/typeguards.js +4 -21
- package/dist/memory/budget.d.ts +2 -2
- package/dist/memory/budget.js +1 -1
- package/dist/{runtime → memory}/exec-context-factory.d.ts +2 -2
- package/dist/{runtime → memory}/exec-context-factory.js +1 -1
- package/dist/memory/flow-schema.d.ts +52 -0
- package/dist/memory/flow-schema.js +102 -0
- package/dist/memory/function-call-utils.d.ts +1 -1
- package/dist/memory/function-call-utils.js +4 -2
- package/dist/memory/layer-api.d.ts +4 -4
- package/dist/memory/layer-api.js +2 -2
- package/dist/memory/layer-lifecycle.d.ts +6 -6
- package/dist/memory/layer-lifecycle.js +6 -6
- package/dist/memory/layer-provides.d.ts +32 -0
- package/dist/memory/layer-provides.js +33 -0
- package/dist/memory/layer-usage.d.ts +4 -3
- package/dist/memory/layer-usage.js +9 -3
- package/dist/memory/layers/durable-task-state.d.ts +8 -8
- package/dist/memory/layers/durable-task-state.js +2 -2
- package/dist/memory/layers/file-reference.d.ts +1 -1
- package/dist/memory/layers/file-reference.js +303 -247
- package/dist/memory/layers/history-window.d.ts +1 -1
- package/dist/memory/layers/history-window.js +4 -4
- package/dist/memory/layers/observational-memory.d.ts +5 -5
- package/dist/memory/layers/observational-memory.js +2 -3
- package/dist/memory/layers/plan.d.ts +2 -2
- package/dist/memory/layers/plan.js +15 -10
- package/dist/memory/layers/static-content.d.ts +2 -2
- package/dist/memory/layers/static-content.js +1 -1
- package/dist/memory/layers/steering.d.ts +7 -7
- package/dist/memory/layers/steering.js +5 -5
- package/dist/memory/layers/tool-memory-layer.d.ts +2 -2
- package/dist/memory/layers/tool-memory-layer.js +1 -1
- package/dist/memory/layers/working-memory.d.ts +7 -7
- package/dist/memory/layers/working-memory.js +4 -4
- package/dist/memory/projector.d.ts +2 -2
- package/dist/memory/scope.d.ts +1 -1
- package/dist/memory/strip-unresolved.d.ts +1 -1
- package/dist/observability/span-impl.d.ts +1 -1
- package/dist/observability/trace-exporter.d.ts +2 -2
- package/dist/observability/trace-exporter.js +1 -1
- package/dist/patterns/dynamic-workflow.d.ts +55 -0
- package/dist/patterns/dynamic-workflow.js +194 -0
- package/dist/patterns/flow.d.ts +2 -52
- package/dist/patterns/flow.js +1 -103
- package/dist/patterns/interview.d.ts +2 -2
- package/dist/patterns/interview.js +5 -5
- package/dist/patterns/plans.d.ts +6 -6
- package/dist/patterns/plans.js +4 -4
- package/dist/patterns/ralph-wiggum.d.ts +4 -4
- package/dist/patterns/ralph-wiggum.js +5 -5
- package/dist/patterns/react.d.ts +3 -3
- package/dist/patterns/react.js +5 -5
- package/dist/portable/adapters.d.ts +6 -0
- package/dist/portable/adapters.js +6 -0
- package/dist/portable/ask-user.d.ts +4 -0
- package/dist/portable/ask-user.js +2 -0
- package/dist/portable/builders.d.ts +12 -0
- package/dist/portable/builders.js +12 -0
- package/dist/portable/memory-layers.d.ts +12 -0
- package/dist/portable/memory-layers.js +12 -0
- package/dist/portable/runtime.d.ts +4 -0
- package/dist/portable/runtime.js +4 -0
- package/dist/portable/until.d.ts +4 -0
- package/dist/portable/until.js +4 -0
- package/dist/portable.d.ts +8 -26
- package/dist/portable.js +8 -34
- package/dist/runtime/broadcaster-utils.d.ts +7 -3
- package/dist/runtime/broadcaster-utils.js +11 -6
- package/dist/runtime/channel-store.d.ts +1 -1
- package/dist/runtime/channel-store.js +2 -2
- package/dist/runtime/context-deps.d.ts +4 -0
- package/dist/runtime/context-deps.js +2 -0
- package/dist/runtime/context-impl.d.ts +42 -12
- package/dist/runtime/context-impl.js +52 -5
- package/dist/runtime/context-type-deps.d.ts +14 -0
- package/dist/runtime/context-type-deps.js +1 -0
- package/dist/runtime/cwd-helpers.d.ts +1 -1
- package/dist/runtime/detached-handle.d.ts +52 -4
- package/dist/runtime/detached-handle.js +218 -14
- package/dist/runtime/durable/checkpoint-store.d.ts +38 -0
- package/dist/runtime/durable/checkpoint-store.js +101 -0
- package/dist/runtime/durable/detached-signal.d.ts +37 -0
- package/dist/runtime/durable/detached-signal.js +52 -0
- package/dist/runtime/durable/harness-checkpoints.d.ts +51 -0
- package/dist/runtime/durable/harness-checkpoints.js +104 -0
- package/dist/runtime/durable/index.d.ts +10 -0
- package/dist/runtime/durable/index.js +5 -0
- package/dist/runtime/durable/runnable-loop.d.ts +100 -0
- package/dist/runtime/durable/runnable-loop.js +90 -0
- package/dist/runtime/durable/session-seed.d.ts +28 -0
- package/dist/runtime/durable/session-seed.js +27 -0
- package/dist/runtime/durable/stall-nudge.d.ts +82 -0
- package/dist/runtime/durable/stall-nudge.js +87 -0
- package/dist/runtime/event-broadcaster.d.ts +1 -1
- package/dist/runtime/in-memory-storage.d.ts +1 -1
- package/dist/runtime/in-memory-storage.js +1 -1
- package/dist/runtime/item-log-impl.d.ts +3 -3
- package/dist/runtime/item-log-impl.js +1 -1
- package/dist/runtime/message-queue.d.ts +2 -2
- package/dist/runtime/session-runner.d.ts +7 -7
- package/dist/runtime/session-runner.js +3 -3
- package/dist/runtime/session-streams.d.ts +3 -3
- package/dist/runtime/session-streams.js +1 -1
- package/dist/runtime/step-registry.d.ts +42 -0
- package/dist/runtime/step-registry.js +77 -0
- package/dist/runtime/tool-memory.d.ts +3 -3
- package/dist/schemas/item.d.ts +1 -1
- package/dist/schemas/workflow.d.ts +139 -0
- package/dist/schemas/workflow.js +232 -0
- package/dist/types/ask-user-types.d.ts +57 -0
- package/dist/types/ask-user-types.js +74 -0
- package/dist/types/checkpoint.d.ts +98 -0
- package/dist/types/checkpoint.js +81 -0
- package/dist/types/common.d.ts +1 -50
- package/dist/types/context-parts/item-log.d.ts +6 -0
- package/dist/types/context-parts/item-log.js +1 -0
- package/dist/types/context-parts/layer-usage.d.ts +18 -0
- package/dist/types/context-parts/layer-usage.js +1 -0
- package/dist/types/context.d.ts +140 -31
- package/dist/types/error.d.ts +15 -0
- package/dist/types/harness-result.d.ts +2 -2
- package/dist/types/items.d.ts +18 -2
- package/dist/types/memory-context.d.ts +39 -0
- package/dist/types/memory-context.js +1 -0
- package/dist/types/memory.d.ts +38 -68
- package/dist/types/mutable-context.d.ts +3 -3
- package/dist/types/runtime.d.ts +14 -13
- package/dist/types/steering.d.ts +2 -2
- package/dist/types/step-registrar.d.ts +46 -0
- package/dist/types/step-registrar.js +56 -0
- package/dist/types/step.d.ts +34 -9
- package/dist/types/subprocess-adapter.d.ts +119 -3
- package/dist/types/subprocess-adapter.js +2 -0
- package/dist/types/tool-context.d.ts +6 -6
- package/dist/types/tool.d.ts +64 -0
- package/dist/types/tool.js +1 -0
- package/dist/unstable.d.ts +9 -9
- package/dist/unstable.js +7 -7
- package/dist/until/combinators.d.ts +1 -1
- package/dist/until/never.d.ts +1 -1
- package/dist/until/predicates.d.ts +13 -4
- package/dist/until/predicates.js +16 -2
- package/dist/util/message-helpers.d.ts +17 -0
- package/dist/util/message-helpers.js +64 -0
- package/package.json +6 -4
- package/dist/adapters/local-fs-adapter.d.ts +0 -3
- package/dist/adapters/local-fs-adapter.js +0 -43
- package/dist/adapters/local-shell-adapter.d.ts +0 -51
- package/dist/adapters/local-shell-adapter.js +0 -167
- package/dist/adapters/local-subprocess-adapter.d.ts +0 -16
- package/dist/adapters/local-subprocess-adapter.js +0 -187
- package/dist/conditions/index.d.ts +0 -3
- package/dist/conditions/index.js +0 -2
- package/dist/interpreter/execute-branch.d.ts +0 -3
- package/dist/interpreter/execute-branch.js +0 -10
- package/dist/interpreter/execute-every.js +0 -143
- package/dist/interpreter/execute-fork.d.ts +0 -3
- package/dist/interpreter/execute-fork.js +0 -215
- package/dist/interpreter/execute-llm.d.ts +0 -4
- package/dist/interpreter/execute-llm.js +0 -217
- package/dist/interpreter/execute-loop.d.ts +0 -3
- package/dist/interpreter/execute-loop.js +0 -171
- package/dist/interpreter/execute-provide.d.ts +0 -10
- package/dist/interpreter/execute-provide.js +0 -64
- package/dist/interpreter/execute-run.d.ts +0 -3
- package/dist/interpreter/execute-run.js +0 -39
- package/dist/interpreter/execute-spawn.d.ts +0 -11
- package/dist/interpreter/execute-spawn.js +0 -113
- package/dist/interpreter/execute-tool.d.ts +0 -5
- package/dist/interpreter/execute-tool.js +0 -81
- package/dist/runtime/agent-harness.js +0 -1170
- /package/dist/{interpreter → util}/framework-cast.d.ts +0 -0
- /package/dist/{interpreter → util}/framework-cast.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZodType } from 'zod';
|
|
2
|
-
import type { ContextMemory } from '../types/memory';
|
|
3
|
-
import type { Step } from '../types/step';
|
|
2
|
+
import type { ContextMemory } from '../types/memory.js';
|
|
3
|
+
import type { Step } from '../types/step.js';
|
|
4
4
|
/** @public Answer captured by the host for a single interview question. */
|
|
5
5
|
export interface InterviewQuestionAnswer {
|
|
6
6
|
questionId: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { loop } from '../builders/loop-builder';
|
|
3
|
-
import { step } from '../builders/step-builders';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { loop } from '../builders/loop-builder.js';
|
|
3
|
+
import { step } from '../builders/step-builders.js';
|
|
4
|
+
import { any } from '../until/combinators.js';
|
|
5
|
+
import { until } from '../until/predicates.js';
|
|
6
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region Helpers
|
|
9
9
|
const DEFAULT_MAX_QUESTIONS = 8;
|
package/dist/patterns/plans.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { Context } from '../types/context';
|
|
3
|
-
import type { ContextMemory } from '../types/memory';
|
|
4
|
-
import type { ExecuteStepFn, Step } from '../types/step';
|
|
2
|
+
import type { Context } from '../types/context.js';
|
|
3
|
+
import type { ContextMemory } from '../types/memory.js';
|
|
4
|
+
import type { ExecuteStepFn, Step } from '../types/step.js';
|
|
5
5
|
export interface PlanNode {
|
|
6
6
|
id: string;
|
|
7
7
|
description: string;
|
|
@@ -27,7 +27,7 @@ export interface PlanConstraints {
|
|
|
27
27
|
* @param executeStep - Optional step executor for non-run step kinds.
|
|
28
28
|
* @returns A compiled `Step` ready for execution.
|
|
29
29
|
*/
|
|
30
|
-
export declare function compilePlan<O>(plan: PlanNode, agents: Record<string, (prompt: string) => Step<ContextMemory, string,
|
|
30
|
+
export declare function compilePlan<O, A = unknown>(plan: PlanNode, agents: Record<string, (prompt: string) => Step<ContextMemory, string, A>>, constraints?: PlanConstraints, executeStep?: ExecuteStepFn): Step<ContextMemory, string, O>;
|
|
31
31
|
/**
|
|
32
32
|
* Creates a step that dynamically generates a plan via a planner step and executes it,
|
|
33
33
|
* retrying with error feedback up to `maxRevisions` times on failure.
|
|
@@ -36,9 +36,9 @@ export declare function compilePlan<O>(plan: PlanNode, agents: Record<string, (p
|
|
|
36
36
|
* @param opts - Planner step, agent factories, optional constraints, max revision count, and step executor.
|
|
37
37
|
* @returns A `Step` that adaptively plans and executes.
|
|
38
38
|
*/
|
|
39
|
-
export declare function adaptivePlan<O>(opts: {
|
|
39
|
+
export declare function adaptivePlan<O, A = unknown>(opts: {
|
|
40
40
|
planner: Step<ContextMemory, string, PlanNode>;
|
|
41
|
-
agents: Record<string, (prompt: string) => Step<ContextMemory, string,
|
|
41
|
+
agents: Record<string, (prompt: string) => Step<ContextMemory, string, A>>;
|
|
42
42
|
constraints?: PlanConstraints;
|
|
43
43
|
maxRevisions: number;
|
|
44
44
|
executeStep?: ExecuteStepFn;
|
package/dist/patterns/plans.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { fork } from '../builders/control-flow-builders';
|
|
3
|
-
import { frameworkCast } from '../
|
|
2
|
+
import { fork } from '../builders/control-flow-builders.js';
|
|
3
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
4
4
|
// PlanNode schema — the variable annotation provides the recursive type;
|
|
5
5
|
// z.lazy() returns a compatible type that TypeScript checks against it.
|
|
6
6
|
/** @public Zod schema for recursive `PlanNode` validation. */
|
|
@@ -47,7 +47,7 @@ function compileNode(node, opts) {
|
|
|
47
47
|
id: `plan-fork-${node.id}`,
|
|
48
48
|
mode: 'all',
|
|
49
49
|
paths: () => childSteps,
|
|
50
|
-
merge: (results) => results[results.length - 1],
|
|
50
|
+
merge: (results) => frameworkCast(results[results.length - 1]),
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
// Sequential - chain steps via a run step that uses executeStep
|
|
@@ -68,7 +68,7 @@ function compileNode(node, opts) {
|
|
|
68
68
|
throw new Error(`No executeStep provided and child step kind '${child.kind}' cannot be executed directly`);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
return currentOutput;
|
|
71
|
+
return frameworkCast(currentOutput);
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { VerifyFn } from '../until/predicates';
|
|
1
|
+
import type { ContextMemory } from '../types/memory.js';
|
|
2
|
+
import type { StepLoop } from '../types/step.js';
|
|
3
|
+
import type { Tool } from '../types/tool.js';
|
|
4
|
+
import type { VerifyFn } from '../until/predicates.js';
|
|
5
5
|
/**
|
|
6
6
|
* Creates a retry-with-feedback loop wrapping a ReAct agent. Each iteration spawns an inner agent
|
|
7
7
|
* and retries with verification feedback until the verifier passes or max iterations is reached.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { loop } from '../builders/loop-builder';
|
|
2
|
-
import { spawn } from '../builders/spawn-builder';
|
|
3
|
-
import { any } from '../until/combinators';
|
|
4
|
-
import { until } from '../until/predicates';
|
|
5
|
-
import { react } from './react';
|
|
1
|
+
import { loop } from '../builders/loop-builder.js';
|
|
2
|
+
import { spawn } from '../builders/spawn-builder.js';
|
|
3
|
+
import { any } from '../until/combinators.js';
|
|
4
|
+
import { until } from '../until/predicates.js';
|
|
5
|
+
import { react } from './react.js';
|
|
6
6
|
/**
|
|
7
7
|
* Creates a retry-with-feedback loop wrapping a ReAct agent. Each iteration spawns an inner agent
|
|
8
8
|
* and retries with verification feedback until the verifier passes or max iterations is reached.
|
package/dist/patterns/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ContextMemory, MemoryConfig, MemoryLayer } from '../types/memory.js';
|
|
2
|
+
import type { StepLoop, StepSpawn } from '../types/step.js';
|
|
3
|
+
import type { Tool } from '../types/tool.js';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a ReAct (Reason + Act) agent loop: an LLM step with tools iterated until no tool calls or limits are hit.
|
|
6
6
|
*
|
package/dist/patterns/react.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { loop } from '../builders/loop-builder';
|
|
2
|
-
import { spawn } from '../builders/spawn-builder';
|
|
3
|
-
import { step } from '../builders/step-builders';
|
|
4
|
-
import { any } from '../until/combinators';
|
|
5
|
-
import { until } from '../until/predicates';
|
|
1
|
+
import { loop } from '../builders/loop-builder.js';
|
|
2
|
+
import { spawn } from '../builders/spawn-builder.js';
|
|
3
|
+
import { step } from '../builders/step-builders.js';
|
|
4
|
+
import { any } from '../until/combinators.js';
|
|
5
|
+
import { until } from '../until/predicates.js';
|
|
6
6
|
/**
|
|
7
7
|
* Creates a ReAct (Reason + Act) agent loop: an LLM step with tools iterated until no tool calls or limits are hit.
|
|
8
8
|
*
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { createInMemoryFsAdapter } from '../adapters/in-memory-fs-adapter.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { createInMemoryShellAdapter } from '../adapters/in-memory-shell-adapter.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { createInMemorySubprocessAdapter } from '../adapters/in-memory-subprocess-adapter.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { createInMemoryFsAdapter } from '../adapters/in-memory-fs-adapter.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { createInMemoryShellAdapter } from '../adapters/in-memory-shell-adapter.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { createInMemorySubprocessAdapter } from '../adapters/in-memory-subprocess-adapter.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export type { AskUserAnnotation, AskUserInput, AskUserOption, AskUserOutput, AskUserQuestion, } from '../types/ask-user-types.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { AskUserAnnotationSchema, AskUserInputSchema, AskUserOptionSchema, AskUserOutputSchema, AskUserQuestionSchema, } from '../types/ask-user-types.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { branch, fork } from '../builders/control-flow-builders.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { layerData, layerFn } from '../builders/layer-provides-builders.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { loop } from '../builders/loop-builder.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { spawn } from '../builders/spawn-builder.js';
|
|
9
|
+
/** @public */
|
|
10
|
+
export { step } from '../builders/step-builders.js';
|
|
11
|
+
/** @public */
|
|
12
|
+
export { tool, toolWithGenerator } from '../builders/tool-builder.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { branch, fork } from '../builders/control-flow-builders.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { layerData, layerFn } from '../builders/layer-provides-builders.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { loop } from '../builders/loop-builder.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { spawn } from '../builders/spawn-builder.js';
|
|
9
|
+
/** @public */
|
|
10
|
+
export { step } from '../builders/step-builders.js';
|
|
11
|
+
/** @public */
|
|
12
|
+
export { tool, toolWithGenerator } from '../builders/tool-builder.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { durableTaskState } from '../memory/layers/durable-task-state.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { historyWindow } from '../memory/layers/history-window.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { observationalMemory } from '../memory/layers/observational-memory.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { planMemory } from '../memory/layers/plan.js';
|
|
9
|
+
/** @public */
|
|
10
|
+
export { toolMemoryLayer } from '../memory/layers/tool-memory-layer.js';
|
|
11
|
+
/** @public */
|
|
12
|
+
export { workingMemory } from '../memory/layers/working-memory.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { durableTaskState } from '../memory/layers/durable-task-state.js';
|
|
3
|
+
/** @public */
|
|
4
|
+
export { historyWindow } from '../memory/layers/history-window.js';
|
|
5
|
+
/** @public */
|
|
6
|
+
export { observationalMemory } from '../memory/layers/observational-memory.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { planMemory } from '../memory/layers/plan.js';
|
|
9
|
+
/** @public */
|
|
10
|
+
export { toolMemoryLayer } from '../memory/layers/tool-memory-layer.js';
|
|
11
|
+
/** @public */
|
|
12
|
+
export { workingMemory } from '../memory/layers/working-memory.js';
|
package/dist/portable.d.ts
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
/** @public */
|
|
8
|
-
export {
|
|
9
|
-
/** @public */
|
|
10
|
-
export { tool, toolWithGenerator } from './builders/tool-builder';
|
|
11
|
-
/** @public */
|
|
12
|
-
export { durableTaskState } from './memory/layers/durable-task-state';
|
|
13
|
-
/** @public */
|
|
14
|
-
export { historyWindow } from './memory/layers/history-window';
|
|
15
|
-
/** @public */
|
|
16
|
-
export { observationalMemory } from './memory/layers/observational-memory';
|
|
17
|
-
/** @public */
|
|
18
|
-
export { planMemory } from './memory/layers/plan';
|
|
19
|
-
/** @public */
|
|
20
|
-
export { toolMemoryLayer } from './memory/layers/tool-memory-layer';
|
|
21
|
-
/** @public */
|
|
22
|
-
export { workingMemory } from './memory/layers/working-memory';
|
|
23
|
-
/** @public */
|
|
24
|
-
export { AgentHarness } from './runtime/agent-harness';
|
|
25
|
-
/** @public */
|
|
26
|
-
export { createInMemoryStorage } from './runtime/in-memory-storage';
|
|
1
|
+
export * from './portable/adapters.js';
|
|
2
|
+
export * from './portable/ask-user.js';
|
|
3
|
+
export * from './portable/builders.js';
|
|
4
|
+
export * from './portable/memory-layers.js';
|
|
5
|
+
export * from './portable/runtime.js';
|
|
6
|
+
export * from './portable/until.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { Slot } from './types/memory.js';
|
package/dist/portable.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//#region Builders
|
|
10
|
-
/** @public */
|
|
11
|
-
export { step } from './builders/step-builders';
|
|
12
|
-
/** @public */
|
|
13
|
-
export { tool, toolWithGenerator } from './builders/tool-builder';
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region Memory Layers
|
|
16
|
-
/** @public */
|
|
17
|
-
export { durableTaskState } from './memory/layers/durable-task-state';
|
|
18
|
-
/** @public */
|
|
19
|
-
export { historyWindow } from './memory/layers/history-window';
|
|
20
|
-
/** @public */
|
|
21
|
-
export { observationalMemory } from './memory/layers/observational-memory';
|
|
22
|
-
/** @public */
|
|
23
|
-
export { planMemory } from './memory/layers/plan';
|
|
24
|
-
/** @public */
|
|
25
|
-
export { toolMemoryLayer } from './memory/layers/tool-memory-layer';
|
|
26
|
-
/** @public */
|
|
27
|
-
export { workingMemory } from './memory/layers/working-memory';
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region Runtime
|
|
30
|
-
/** @public */
|
|
31
|
-
export { AgentHarness } from './runtime/agent-harness';
|
|
32
|
-
/** @public */
|
|
33
|
-
export { createInMemoryStorage } from './runtime/in-memory-storage';
|
|
34
|
-
//#endregion
|
|
1
|
+
export * from './portable/adapters.js';
|
|
2
|
+
export * from './portable/ask-user.js';
|
|
3
|
+
export * from './portable/builders.js';
|
|
4
|
+
export * from './portable/memory-layers.js';
|
|
5
|
+
export * from './portable/runtime.js';
|
|
6
|
+
export * from './portable/until.js';
|
|
7
|
+
/** @public */
|
|
8
|
+
export { Slot } from './types/memory.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Context } from '../types/context';
|
|
2
|
-
import type { EventBroadcaster } from './event-broadcaster';
|
|
1
|
+
import type { Context } from '../types/context.js';
|
|
2
|
+
import type { EventBroadcaster } from './event-broadcaster.js';
|
|
3
3
|
/** @internal Option controlling framework event emission on a step or callModel request. */
|
|
4
4
|
export type EmitOption = boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
|
|
5
5
|
/**
|
|
@@ -13,7 +13,11 @@ export type EmitOption = boolean | ((eventType: string, data: Record<string, unk
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function shouldEmit(emit: EmitOption | undefined, eventType: string, data: Record<string, unknown>): boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Get the EventBroadcaster from a context if available.
|
|
16
|
+
* Get the EventBroadcaster from a context if available. Walks up the parent
|
|
17
|
+
* chain so spawned child contexts inherit the session-level broadcaster — the
|
|
18
|
+
* interpreter never re-installs `_broadcaster` on spawn children, so without
|
|
19
|
+
* this traversal every LLM call inside a `spawn()` step would be invisible to
|
|
20
|
+
* the UI stream.
|
|
17
21
|
* Uses property check rather than instanceof to support mock contexts in tests.
|
|
18
22
|
* @internal
|
|
19
23
|
*/
|
|
@@ -26,16 +26,21 @@ function hasBroadcaster(ctx) {
|
|
|
26
26
|
return typeof ctx._broadcaster === 'object' && ctx._broadcaster !== null;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Get the EventBroadcaster from a context if available.
|
|
29
|
+
* Get the EventBroadcaster from a context if available. Walks up the parent
|
|
30
|
+
* chain so spawned child contexts inherit the session-level broadcaster — the
|
|
31
|
+
* interpreter never re-installs `_broadcaster` on spawn children, so without
|
|
32
|
+
* this traversal every LLM call inside a `spawn()` step would be invisible to
|
|
33
|
+
* the UI stream.
|
|
30
34
|
* Uses property check rather than instanceof to support mock contexts in tests.
|
|
31
35
|
* @internal
|
|
32
36
|
*/
|
|
33
37
|
export function getBroadcaster(ctx) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
let current = ctx;
|
|
39
|
+
while (current) {
|
|
40
|
+
if (hasBroadcaster(current)) {
|
|
41
|
+
return current._broadcaster;
|
|
42
|
+
}
|
|
43
|
+
current = current.parent ?? null;
|
|
39
44
|
}
|
|
40
45
|
return undefined;
|
|
41
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NoeticErrorImpl } from '../errors/noetic-error';
|
|
2
|
-
import { frameworkCast } from '../
|
|
1
|
+
import { NoeticErrorImpl } from '../errors/noetic-error.js';
|
|
2
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
3
3
|
function isExternalChannel(ch) {
|
|
4
4
|
return 'external' in ch && ch.external === true;
|
|
5
5
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildContextMemory } from '../memory/layer-api.js';
|
|
2
|
+
export type { ItemSchemaRegistry } from '../schemas/item.js';
|
|
3
|
+
export { defaultItemSchemaRegistry } from '../schemas/item.js';
|
|
4
|
+
export type { AgentHarnessContract, Channel, ChannelStore, Context, ContextMemory, CwdState, EventBroadcaster, FrontierFrame, FsAdapter, Item, ItemLog, LastLayerUsage, MemoryLayer, Span, StepMeta, TokenUsage, Tool, } from './context-type-deps.js';
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import type { ItemSchemaRegistry } from '
|
|
2
|
-
import type { Channel } from '../types/channel';
|
|
3
|
-
import type { StepMeta, TokenUsage, Tool } from '../types/common';
|
|
4
|
-
import type { Context, CwdState, ItemLog, LastLayerUsage } from '../types/context';
|
|
5
|
-
import type { FsAdapter } from '../types/fs-adapter';
|
|
6
|
-
import type { Item } from '../types/items';
|
|
7
|
-
import type { ContextMemory, MemoryLayer } from '../types/memory';
|
|
8
|
-
import type { Span } from '../types/observability';
|
|
9
|
-
import type { AgentHarnessContract } from '../types/runtime';
|
|
10
|
-
import type { ChannelStore } from './channel-store';
|
|
11
|
-
import type { EventBroadcaster } from './event-broadcaster';
|
|
1
|
+
import type { AgentHarnessContract, Channel, ChannelStore, Context, ContextMemory, CwdState, EventBroadcaster, FrontierFrame, FsAdapter, Item, ItemLog, ItemSchemaRegistry, LastLayerUsage, MemoryLayer, Span, StepMeta, TokenUsage, Tool } from './context-deps.js';
|
|
12
2
|
export declare class ContextImpl implements Context<ContextMemory> {
|
|
13
3
|
readonly id: string;
|
|
14
4
|
stepCount: number;
|
|
@@ -34,7 +24,8 @@ export declare class ContextImpl implements Context<ContextMemory> {
|
|
|
34
24
|
/**
|
|
35
25
|
* Shared channel store for cross-context communication. Inherited by
|
|
36
26
|
* `fork` / `spawn` children so channels published by a sibling are visible
|
|
37
|
-
* to peers — see `
|
|
27
|
+
* to peers — see `executeFork` and `executeSpawn` in `interpreter/execute-action.ts`
|
|
28
|
+
* and `interpreter/execute-control.ts`.
|
|
38
29
|
* @internal
|
|
39
30
|
*/
|
|
40
31
|
readonly channelStore?: ChannelStore;
|
|
@@ -44,6 +35,15 @@ export declare class ContextImpl implements Context<ContextMemory> {
|
|
|
44
35
|
private _aborted;
|
|
45
36
|
private _abortReason?;
|
|
46
37
|
private _memory?;
|
|
38
|
+
/**
|
|
39
|
+
* Stack of steps currently in flight on this context, most-recent last.
|
|
40
|
+
* Pushed by `enterStep` at the top of `execute()` and popped by
|
|
41
|
+
* `leaveStep` when the step resolves (success or failure). The harness'
|
|
42
|
+
* checkpoint writer serialises this stack as the execution frontier so
|
|
43
|
+
* a restart can identify which step the context was paused inside.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
private readonly _frontier;
|
|
47
47
|
constructor(opts: {
|
|
48
48
|
harness: AgentHarnessContract;
|
|
49
49
|
parent?: Context;
|
|
@@ -59,6 +59,14 @@ export declare class ContextImpl implements Context<ContextMemory> {
|
|
|
59
59
|
itemSchemas?: ItemSchemaRegistry;
|
|
60
60
|
cwdState?: CwdState;
|
|
61
61
|
_broadcaster?: EventBroadcaster;
|
|
62
|
+
/**
|
|
63
|
+
* Pre-chosen context id. When set, the ContextImpl adopts this id instead
|
|
64
|
+
* of generating a fresh UUID. Used by `executeSpawn` so the child's
|
|
65
|
+
* `ctx.id` matches the `executionId` keyed into the layer-state store —
|
|
66
|
+
* otherwise writes via `ctx.memory[layerId].state` land on one id while
|
|
67
|
+
* spawn's `onReturn` reads from another, silently losing the update.
|
|
68
|
+
*/
|
|
69
|
+
id?: string;
|
|
62
70
|
});
|
|
63
71
|
get elapsed(): number;
|
|
64
72
|
get aborted(): boolean;
|
|
@@ -77,4 +85,26 @@ export declare class ContextImpl implements Context<ContextMemory> {
|
|
|
77
85
|
get completionValue(): unknown;
|
|
78
86
|
get abortReason(): string | undefined;
|
|
79
87
|
abort(reason?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
* Push a frame onto the execution frontier. Called by `execute()` at the
|
|
91
|
+
* top of every step dispatch so that the frontier reflects exactly the
|
|
92
|
+
* stack of steps currently in-flight on this context.
|
|
93
|
+
*/
|
|
94
|
+
enterStep(frame: FrontierFrame): void;
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
* Pop the top frame. Called when a step resolves (success or failure)
|
|
98
|
+
* so that the frontier unwinds cleanly. The value of `expectedStepId`
|
|
99
|
+
* is used as a consistency check — if it does not match the top frame
|
|
100
|
+
* the pop is still performed, but a best-effort warning is surfaced to
|
|
101
|
+
* stderr rather than swallowed silently.
|
|
102
|
+
*/
|
|
103
|
+
leaveStep(expectedStepId: string): void;
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
* Return a defensive copy of the current frontier. Consumed by the
|
|
107
|
+
* checkpoint writer — see `AgentHarness.checkpoint`.
|
|
108
|
+
*/
|
|
109
|
+
serialiseFrontier(): FrontierFrame[];
|
|
80
110
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { buildContextMemory } from '
|
|
2
|
-
import {
|
|
3
|
-
import { ItemLogImpl } from './item-log-impl';
|
|
1
|
+
import { buildContextMemory, defaultItemSchemaRegistry } from './context-deps.js';
|
|
2
|
+
import { ItemLogImpl } from './item-log-impl.js';
|
|
4
3
|
const EMPTY_MEMORY = Object.freeze({});
|
|
5
4
|
class NoopSpan {
|
|
6
5
|
traceId = crypto.randomUUID();
|
|
@@ -39,7 +38,8 @@ export class ContextImpl {
|
|
|
39
38
|
/**
|
|
40
39
|
* Shared channel store for cross-context communication. Inherited by
|
|
41
40
|
* `fork` / `spawn` children so channels published by a sibling are visible
|
|
42
|
-
* to peers — see `
|
|
41
|
+
* to peers — see `executeFork` and `executeSpawn` in `interpreter/execute-action.ts`
|
|
42
|
+
* and `interpreter/execute-control.ts`.
|
|
43
43
|
* @internal
|
|
44
44
|
*/
|
|
45
45
|
channelStore;
|
|
@@ -49,8 +49,17 @@ export class ContextImpl {
|
|
|
49
49
|
_aborted = false;
|
|
50
50
|
_abortReason;
|
|
51
51
|
_memory;
|
|
52
|
+
/**
|
|
53
|
+
* Stack of steps currently in flight on this context, most-recent last.
|
|
54
|
+
* Pushed by `enterStep` at the top of `execute()` and popped by
|
|
55
|
+
* `leaveStep` when the step resolves (success or failure). The harness'
|
|
56
|
+
* checkpoint writer serialises this stack as the execution frontier so
|
|
57
|
+
* a restart can identify which step the context was paused inside.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
_frontier = [];
|
|
52
61
|
constructor(opts) {
|
|
53
|
-
this.id = crypto.randomUUID();
|
|
62
|
+
this.id = opts.id ?? crypto.randomUUID();
|
|
54
63
|
this._createdAt = Date.now();
|
|
55
64
|
this.harness = opts.harness;
|
|
56
65
|
this.state = opts.state ?? {};
|
|
@@ -137,4 +146,42 @@ export class ContextImpl {
|
|
|
137
146
|
this._aborted = true;
|
|
138
147
|
this._abortReason = reason;
|
|
139
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
* Push a frame onto the execution frontier. Called by `execute()` at the
|
|
152
|
+
* top of every step dispatch so that the frontier reflects exactly the
|
|
153
|
+
* stack of steps currently in-flight on this context.
|
|
154
|
+
*/
|
|
155
|
+
enterStep(frame) {
|
|
156
|
+
this._frontier.push(frame);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @internal
|
|
160
|
+
* Pop the top frame. Called when a step resolves (success or failure)
|
|
161
|
+
* so that the frontier unwinds cleanly. The value of `expectedStepId`
|
|
162
|
+
* is used as a consistency check — if it does not match the top frame
|
|
163
|
+
* the pop is still performed, but a best-effort warning is surfaced to
|
|
164
|
+
* stderr rather than swallowed silently.
|
|
165
|
+
*/
|
|
166
|
+
leaveStep(expectedStepId) {
|
|
167
|
+
const top = this._frontier[this._frontier.length - 1];
|
|
168
|
+
if (top && top.stepId !== expectedStepId) {
|
|
169
|
+
// A mismatch indicates bookkeeping drift. We unwind best-effort and
|
|
170
|
+
// let the caller observe via `serialiseFrontier()` if needed.
|
|
171
|
+
console.warn(`ContextImpl.leaveStep: expected "${expectedStepId}" on top of frontier but saw "${top.stepId}".`);
|
|
172
|
+
}
|
|
173
|
+
this._frontier.pop();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @internal
|
|
177
|
+
* Return a defensive copy of the current frontier. Consumed by the
|
|
178
|
+
* checkpoint writer — see `AgentHarness.checkpoint`.
|
|
179
|
+
*/
|
|
180
|
+
serialiseFrontier() {
|
|
181
|
+
return this._frontier.map((frame) => ({
|
|
182
|
+
stepId: frame.stepId,
|
|
183
|
+
input: frame.input,
|
|
184
|
+
state: frame.state,
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
140
187
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { Channel } from '../types/channel.js';
|
|
2
|
+
export type { FrontierFrame } from '../types/checkpoint.js';
|
|
3
|
+
export type { StepMeta, TokenUsage } from '../types/common.js';
|
|
4
|
+
export type { Context, CwdState } from '../types/context.js';
|
|
5
|
+
export type { ItemLog } from '../types/context-parts/item-log.js';
|
|
6
|
+
export type { LastLayerUsage } from '../types/context-parts/layer-usage.js';
|
|
7
|
+
export type { FsAdapter } from '../types/fs-adapter.js';
|
|
8
|
+
export type { Item } from '../types/items.js';
|
|
9
|
+
export type { ContextMemory, MemoryLayer } from '../types/memory.js';
|
|
10
|
+
export type { Span } from '../types/observability.js';
|
|
11
|
+
export type { AgentHarnessContract } from '../types/runtime.js';
|
|
12
|
+
export type { Tool } from '../types/tool.js';
|
|
13
|
+
export type { ChannelStore } from './channel-store.js';
|
|
14
|
+
export type { EventBroadcaster } from './event-broadcaster.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context, CwdState } from '../types/context';
|
|
1
|
+
import type { Context, CwdState } from '../types/context.js';
|
|
2
2
|
/**
|
|
3
3
|
* @public Resolve the live cwd for a tool execution. Falls back to the
|
|
4
4
|
* tool's factory-time cwd (then `process.cwd()`) so partial test contexts
|