@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,5 +1,7 @@
|
|
|
1
|
-
import { frameworkCast } from '../
|
|
2
|
-
|
|
1
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
2
|
+
function isFunctionCall(item) {
|
|
3
|
+
return item.type === 'function_call' && 'callId' in item && 'name' in item;
|
|
4
|
+
}
|
|
3
5
|
/**
|
|
4
6
|
* Finds the first function_call item matching `name`, parses its JSON arguments,
|
|
5
7
|
* and returns the result as a record. Returns null if no match or invalid data.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { Context } from '../types/context.js';
|
|
2
|
+
import type { ContextMemory, MemoryLayer } from '../types/memory.js';
|
|
3
|
+
import type { AgentHarnessContract } from '../types/runtime.js';
|
|
4
|
+
import type { Tool } from '../types/tool.js';
|
|
5
5
|
/**
|
|
6
6
|
* Build the `ctx.memory` object — a readonly map of layer ID → resolved handle.
|
|
7
7
|
* Handles use getters for data (live reads) and closures for functions (lazy state).
|
package/dist/memory/layer-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { frameworkCast } from '../
|
|
2
|
-
import { contextToExecCtx } from '
|
|
1
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
2
|
+
import { contextToExecCtx } from './exec-context-factory.js';
|
|
3
3
|
function executeLayerFn(params) {
|
|
4
4
|
const { fn, args, layerId, harness, ctx } = params;
|
|
5
5
|
const validated = fn.input.parse(args);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ItemSchemaRegistry } from '../schemas/item';
|
|
2
|
-
import type { LLMResponse } from '../types/common';
|
|
3
|
-
import type { ItemLog } from '../types/context';
|
|
4
|
-
import type { Item } from '../types/items';
|
|
5
|
-
import type { ExecutionContext, MemoryLayer, StorageAdapter } from '../types/memory';
|
|
6
|
-
import type { SteeringDecision } from '../types/steering';
|
|
1
|
+
import type { ItemSchemaRegistry } from '../schemas/item.js';
|
|
2
|
+
import type { LLMResponse } from '../types/common.js';
|
|
3
|
+
import type { ItemLog } from '../types/context-parts/item-log.js';
|
|
4
|
+
import type { Item } from '../types/items.js';
|
|
5
|
+
import type { ExecutionContext, MemoryLayer, StorageAdapter } from '../types/memory.js';
|
|
6
|
+
import type { SteeringDecision } from '../types/steering.js';
|
|
7
7
|
export interface LayerStateStore {
|
|
8
8
|
get<T>(executionId: string, layerId: string): T | undefined;
|
|
9
9
|
set<T>(executionId: string, layerId: string, state: T): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NoeticConfigError } from '../errors/noetic-config-error';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { createScopedStorage, resolveScopeKey } from './scope';
|
|
1
|
+
import { NoeticConfigError } from '../errors/noetic-config-error.js';
|
|
2
|
+
import { defaultItemSchemaRegistry } from '../schemas/item.js';
|
|
3
|
+
import { SteeringAction } from '../types/steering.js';
|
|
4
|
+
import { frameworkCast } from '../util/framework-cast.js';
|
|
5
|
+
import { createMessage, estimateTokens } from '../util/message-helpers.js';
|
|
6
|
+
import { createScopedStorage, resolveScopeKey } from './scope.js';
|
|
7
7
|
/** Maximum allowed re-render depth to prevent infinite loops */
|
|
8
8
|
const MAX_RERENDER_DEPTH = 3;
|
|
9
9
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
import type { ExecutionContext, LayerDataDecl, LayerFunctionDecl } from '../types/memory.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a read-only data declaration for a memory layer's `provides` map.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @param opts.read - Function that projects a value from the layer's current state.
|
|
8
|
+
* @returns A `LayerDataDecl` to include in a layer's `provides`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function layerData<T, TState>(opts: {
|
|
11
|
+
read: (state: TState) => T;
|
|
12
|
+
}): LayerDataDecl<T, TState>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a callable function declaration for a memory layer's `provides` map.
|
|
15
|
+
* Functions are accessible via `ctx.memory['layerId'].fn()` and automatically exposed as LLM tools.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @param opts.description - Human-readable description used as tool description for LLM.
|
|
19
|
+
* @param opts.input - Zod schema validating input arguments.
|
|
20
|
+
* @param opts.output - Zod schema validating the return value.
|
|
21
|
+
* @param opts.execute - Async function receiving args, current state, and execution context.
|
|
22
|
+
* @returns A `LayerFunctionDecl` to include in a layer's `provides`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function layerFn<TInput, TOutput, TState>(opts: {
|
|
25
|
+
description: string;
|
|
26
|
+
input: ZodType<TInput>;
|
|
27
|
+
output: ZodType<TOutput>;
|
|
28
|
+
execute: (args: TInput, state: TState, ctx: ExecutionContext) => Promise<{
|
|
29
|
+
result: TOutput;
|
|
30
|
+
state?: TState;
|
|
31
|
+
}>;
|
|
32
|
+
}): LayerFunctionDecl<TInput, TOutput, TState>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a read-only data declaration for a memory layer's `provides` map.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @param opts.read - Function that projects a value from the layer's current state.
|
|
6
|
+
* @returns A `LayerDataDecl` to include in a layer's `provides`.
|
|
7
|
+
*/
|
|
8
|
+
export function layerData(opts) {
|
|
9
|
+
return {
|
|
10
|
+
kind: 'data',
|
|
11
|
+
read: opts.read,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a callable function declaration for a memory layer's `provides` map.
|
|
16
|
+
* Functions are accessible via `ctx.memory['layerId'].fn()` and automatically exposed as LLM tools.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @param opts.description - Human-readable description used as tool description for LLM.
|
|
20
|
+
* @param opts.input - Zod schema validating input arguments.
|
|
21
|
+
* @param opts.output - Zod schema validating the return value.
|
|
22
|
+
* @param opts.execute - Async function receiving args, current state, and execution context.
|
|
23
|
+
* @returns A `LayerFunctionDecl` to include in a layer's `provides`.
|
|
24
|
+
*/
|
|
25
|
+
export function layerFn(opts) {
|
|
26
|
+
return {
|
|
27
|
+
kind: 'function',
|
|
28
|
+
description: opts.description,
|
|
29
|
+
input: opts.input,
|
|
30
|
+
output: opts.output,
|
|
31
|
+
execute: opts.execute,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { RecallLayerOutput } from '../types/runtime';
|
|
1
|
+
import type { Context } from '../types/context.js';
|
|
2
|
+
import type { LastLayerUsage } from '../types/context-parts/layer-usage.js';
|
|
3
|
+
import type { RecallLayerOutput } from '../types/runtime.js';
|
|
4
|
+
import type { Tool } from '../types/tool.js';
|
|
4
5
|
interface ComputeLayerUsageParams {
|
|
5
6
|
ctx: Context;
|
|
6
7
|
modelId: string;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { estimateTokens } from '../
|
|
2
|
-
|
|
1
|
+
import { estimateTokens } from '../util/message-helpers.js';
|
|
2
|
+
function canWriteLayerUsage(ctx) {
|
|
3
|
+
const desc = Object.getOwnPropertyDescriptor(ctx, 'lastLayerUsage');
|
|
4
|
+
if (desc === undefined) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return desc.writable !== false;
|
|
8
|
+
}
|
|
3
9
|
//#endregion
|
|
4
10
|
//#region Helpers
|
|
5
11
|
function estimateJsonTokens(value) {
|
|
@@ -40,7 +46,7 @@ export function computeLayerUsage({ ctx, modelId, instructions, tools, recallRes
|
|
|
40
46
|
}
|
|
41
47
|
/** Commit computed usage to the Context, replacing any prior snapshot. */
|
|
42
48
|
export function commitLayerUsage(ctx, usage) {
|
|
43
|
-
if (!
|
|
49
|
+
if (!canWriteLayerUsage(ctx)) {
|
|
44
50
|
return;
|
|
45
51
|
}
|
|
46
52
|
ctx.lastLayerUsage = usage;
|
|
@@ -37,21 +37,21 @@ export declare function durableTaskState(_config?: DurableTaskStateConfig): {
|
|
|
37
37
|
store: number;
|
|
38
38
|
};
|
|
39
39
|
hooks: {
|
|
40
|
-
init({ storage }: import("
|
|
40
|
+
init({ storage }: import("../../index.js").InitParams): Promise<{
|
|
41
41
|
state: DurableTaskState;
|
|
42
42
|
}>;
|
|
43
|
-
recall({ state }: import("
|
|
44
|
-
items: import("
|
|
43
|
+
recall({ state }: import("../../index.js").RecallParams<DurableTaskState>): Promise<{
|
|
44
|
+
items: import("../../index.js").InputMessageItem[];
|
|
45
45
|
tokenCount: number;
|
|
46
46
|
} | null>;
|
|
47
|
-
store({ state, ctx }: import("
|
|
47
|
+
store({ state, ctx }: import("../../index.js").StoreParams<DurableTaskState>): Promise<{
|
|
48
48
|
state: DurableTaskState;
|
|
49
49
|
}>;
|
|
50
|
-
onSpawn({ parentState }: import("
|
|
50
|
+
onSpawn({ parentState }: import("../../index.js").SpawnParams<DurableTaskState>): Promise<{
|
|
51
51
|
childState: DurableTaskState;
|
|
52
52
|
items: never[];
|
|
53
53
|
}>;
|
|
54
|
-
onReturn({ childState, parentState }: import("
|
|
54
|
+
onReturn({ childState, parentState }: import("../../index.js").ReturnParams<DurableTaskState>): Promise<{
|
|
55
55
|
parentState: {
|
|
56
56
|
checkpoints: {
|
|
57
57
|
timestamp: number;
|
|
@@ -63,10 +63,10 @@ export declare function durableTaskState(_config?: DurableTaskStateConfig): {
|
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
}>;
|
|
66
|
-
onComplete({ state, outcome }: import("
|
|
66
|
+
onComplete({ state, outcome }: import("../../index.js").CompleteParams<DurableTaskState>): Promise<{
|
|
67
67
|
state: {
|
|
68
68
|
data: {
|
|
69
|
-
__outcome: import("
|
|
69
|
+
__outcome: import("../../index.js").ExecutionOutcome;
|
|
70
70
|
};
|
|
71
71
|
checkpoints: {
|
|
72
72
|
timestamp: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Slot } from '../../types/memory.js';
|
|
2
|
+
import { createMessage, estimateTokens } from '../../util/message-helpers.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a memory layer that persists task checkpoints, files, and arbitrary data across iterations.
|
|
5
5
|
*
|