@noetic-tools/core 5.2.0 → 5.4.0
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 +8 -6
- package/dist/adapters/in-memory-subprocess/step-completion.js +1 -1
- package/dist/adapters/openrouter.d.ts +20 -2
- package/dist/adapters/openrouter.js +102 -6
- package/dist/builders/control-flow-builders.d.ts +13 -13
- package/dist/builders/control-flow-builders.js +11 -11
- package/dist/{patterns → builders}/dynamic-workflow.d.ts +1 -1
- package/dist/{patterns → builders}/dynamic-workflow.js +18 -12
- package/dist/builders/every.d.ts +14 -14
- package/dist/builders/every.js +16 -16
- package/dist/builders/layer-provides-builders.d.ts +1 -1
- package/dist/builders/layer-provides-builders.js +1 -1
- package/dist/builders/provide-builder.d.ts +5 -12
- package/dist/builders/provide-builder.js +9 -10
- package/dist/builders/spawn-builder.d.ts +0 -2
- package/dist/builders/spawn-builder.js +2 -3
- package/dist/builders/step-builders.d.ts +66 -55
- package/dist/builders/step-builders.js +118 -111
- package/dist/builders/tool-builder.d.ts +18 -22
- package/dist/builders/tool-builder.js +6 -4
- package/dist/builders/workflow-hydrator.d.ts +3 -3
- package/dist/builders/workflow-hydrator.js +59 -63
- package/dist/builders/workflow-step.d.ts +13 -25
- package/dist/builders/workflow-step.js +13 -18
- package/dist/conditions/conditions.d.ts +2 -2
- package/dist/conditions/conditions.js +1 -1
- package/dist/harness/agent-harness.d.ts +58 -40
- package/dist/harness/agent-harness.js +125 -51
- package/dist/harness/deps/context.d.ts +1 -1
- package/dist/harness/deps/context.js +1 -1
- package/dist/harness/deps/interpreter.d.ts +1 -0
- package/dist/harness/deps/interpreter.js +1 -0
- package/dist/harness/deps/types.d.ts +2 -2
- package/dist/harness/model-call.d.ts +1 -1
- package/dist/harness/model-call.js +45 -23
- package/dist/index.d.ts +23 -35
- package/dist/index.js +10 -26
- package/dist/interpreter/action-deps.d.ts +2 -2
- package/dist/interpreter/action-deps.js +1 -1
- package/dist/interpreter/action-types.d.ts +1 -1
- package/dist/interpreter/collect-tools.js +7 -7
- package/dist/interpreter/context-assembly.d.ts +50 -0
- package/dist/interpreter/context-assembly.js +547 -0
- package/dist/interpreter/execute-action.d.ts +5 -5
- package/dist/interpreter/execute-action.js +337 -208
- package/dist/interpreter/execute-control.d.ts +9 -9
- package/dist/interpreter/execute-control.js +27 -27
- package/dist/interpreter/execute-sub-harness.d.ts +1 -1
- package/dist/interpreter/execute-sub-harness.js +7 -26
- package/dist/interpreter/execute.d.ts +1 -1
- package/dist/interpreter/execute.js +26 -25
- package/dist/interpreter/step-dispatcher.d.ts +1 -1
- package/dist/interpreter/step-dispatcher.js +3 -3
- package/dist/interpreter/structured-output.d.ts +14 -0
- package/dist/interpreter/structured-output.js +40 -0
- package/dist/interpreter/typeguards.d.ts +1 -1
- package/dist/interpreter/typeguards.js +1 -1
- package/dist/observability/genai-attributes.d.ts +20 -0
- package/dist/observability/genai-attributes.js +20 -0
- package/dist/portable/builders.d.ts +3 -3
- package/dist/portable/builders.js +6 -5
- package/dist/portable/context-layers.d.ts +1 -1
- package/dist/portable/context-layers.js +1 -1
- package/dist/runtime/broadcaster-utils.d.ts +1 -1
- package/dist/runtime/broadcaster-utils.js +1 -1
- package/dist/runtime/context-impl.d.ts +8 -10
- package/dist/runtime/context-impl.js +8 -12
- package/dist/runtime/durable/step-ledger.d.ts +2 -2
- package/dist/runtime/durable/step-ledger.js +3 -3
- package/dist/runtime/session-runner.d.ts +12 -1
- package/dist/runtime/session-runner.js +33 -1
- package/dist/runtime/tool-context.js +0 -2
- package/dist/schemas/workflow.d.ts +3 -3
- package/dist/schemas/workflow.js +2 -2
- package/dist/types/checkpoint.d.ts +11 -2
- package/dist/types/checkpoint.js +10 -1
- package/dist/{runtime → util}/detached-handle.js +1 -1
- package/package.json +6 -4
- package/schema/noetic-workflow.schema.json +24 -11
- package/dist/builders/context-option.d.ts +0 -23
- package/dist/builders/context-option.js +0 -22
- package/dist/deprecated.d.ts +0 -30
- package/dist/deprecated.js +0 -28
- package/dist/patterns/interview.d.ts +0 -53
- package/dist/patterns/interview.js +0 -113
- package/dist/patterns/plans.d.ts +0 -44
- package/dist/patterns/plans.js +0 -125
- package/dist/patterns/ralph-wiggum.d.ts +0 -19
- package/dist/patterns/ralph-wiggum.js +0 -37
- package/dist/patterns/react.d.ts +0 -19
- package/dist/patterns/react.js +0 -41
- /package/dist/{runtime → util}/detached-handle.d.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { frameworkCast, NoeticConfigError } from '@noetic-tools/types';
|
|
2
2
|
import { serverTool } from '@openrouter/agent';
|
|
3
|
-
import {
|
|
4
|
-
import { convertTools, executeToolCall, extractOutputItems, extractSystemInstruction, extractUsage, itemsToInput, sanitizeToolNameForWire, } from '../adapters/openrouter.js';
|
|
3
|
+
import { convertTools, executeToolCall, extractOutputItems, extractSystemInstruction, extractUsage, itemsToInput, resolveWireJsonSchema, sanitizeToolNameForWire, } from '../adapters/openrouter.js';
|
|
5
4
|
import { isFunctionCall } from '../interpreter/typeguards.js';
|
|
6
5
|
import { GenAI, NoeticAttr, ToolAttr } from '../observability/genai-attributes.js';
|
|
7
6
|
import { emitFrameworkEvent, getBroadcaster, shouldEmit } from '../runtime/broadcaster-utils.js';
|
|
@@ -9,8 +8,12 @@ import { buildItemSchemaRegistry, createToolResultItem } from './model-schema.js
|
|
|
9
8
|
const MAX_TOOL_ROUNDS = 32;
|
|
10
9
|
const MAX_RECOVERY_CONTINUATIONS = 3;
|
|
11
10
|
const EPHEMERAL_CONTINUE_INPUT = 'continue';
|
|
12
|
-
function buildTextFormat(schema) {
|
|
13
|
-
const jsonSchema =
|
|
11
|
+
function buildTextFormat(schema, explicitJsonSchema) {
|
|
12
|
+
const jsonSchema = resolveWireJsonSchema({
|
|
13
|
+
schema,
|
|
14
|
+
explicitJsonSchema,
|
|
15
|
+
what: 'structured output schema',
|
|
16
|
+
});
|
|
14
17
|
return {
|
|
15
18
|
format: {
|
|
16
19
|
type: 'json_schema',
|
|
@@ -133,7 +136,7 @@ async function pipeStreamEventsToBroadcaster(opts) {
|
|
|
133
136
|
/** @internal Create a watchdog that aborts `controller` when no
|
|
134
137
|
* {@link StreamIdleWatchdog.reset reset} is called within `timeoutMs`. When
|
|
135
138
|
* `timeoutMs <= 0`, returns an inert no-op so callers can always call `.reset()`
|
|
136
|
-
* / `.stop()` without
|
|
139
|
+
* / `.stop()` without branching. Starts armed: the caller is responsible for
|
|
137
140
|
* `.stop()` in a `finally`. `onTimeout` runs before the abort so observers can
|
|
138
141
|
* emit a framework event with the original cause. Exported only for unit tests. */
|
|
139
142
|
export function createStreamIdleWatchdog(timeoutMs, controller, onTimeout) {
|
|
@@ -150,7 +153,7 @@ export function createStreamIdleWatchdog(timeoutMs, controller, onTimeout) {
|
|
|
150
153
|
if (stopped) {
|
|
151
154
|
return;
|
|
152
155
|
}
|
|
153
|
-
const reason = new Error(`
|
|
156
|
+
const reason = new Error(`model stream idle timeout after ${timeoutMs}ms`);
|
|
154
157
|
onTimeout?.();
|
|
155
158
|
controller.abort(reason);
|
|
156
159
|
}, timeoutMs);
|
|
@@ -272,6 +275,12 @@ class CallSpanCollector {
|
|
|
272
275
|
finishModelSpan(span, usage, cost) {
|
|
273
276
|
span.setAttribute(GenAI.USAGE_INPUT_TOKENS, usage.inputTokens);
|
|
274
277
|
span.setAttribute(GenAI.USAGE_OUTPUT_TOKENS, usage.outputTokens);
|
|
278
|
+
if (usage.cachedTokens !== undefined) {
|
|
279
|
+
span.setAttribute(GenAI.USAGE_CACHED_INPUT_TOKENS, usage.cachedTokens);
|
|
280
|
+
}
|
|
281
|
+
if (usage.cacheWriteTokens !== undefined) {
|
|
282
|
+
span.setAttribute(GenAI.USAGE_CACHE_WRITE_TOKENS, usage.cacheWriteTokens);
|
|
283
|
+
}
|
|
275
284
|
if (cost !== undefined) {
|
|
276
285
|
span.setAttribute(GenAI.COST, cost);
|
|
277
286
|
}
|
|
@@ -348,7 +357,7 @@ export class AgentHarnessModelCaller {
|
|
|
348
357
|
throw new NoeticConfigError({
|
|
349
358
|
code: 'NO_LLM_PROVIDER',
|
|
350
359
|
message: 'No LLM provider configured on this harness.',
|
|
351
|
-
hint: 'Pass `
|
|
360
|
+
hint: 'Pass `callModelDefaults: { apiKey: "..." }` (defaults to the Noetic platform) or set NOETIC_API_KEY. For direct OpenRouter, use `callModelDefaults: { provider: "openrouter", apiKey: "..." }` or set OPENROUTER_API_KEY.',
|
|
352
361
|
});
|
|
353
362
|
}
|
|
354
363
|
async callModel(request) {
|
|
@@ -372,9 +381,15 @@ export class AgentHarnessModelCaller {
|
|
|
372
381
|
outputTokens: 0,
|
|
373
382
|
cachedTokens: 0,
|
|
374
383
|
};
|
|
384
|
+
// Rounds after the first replay the same prefix and so hit the prompt cache
|
|
385
|
+
// whatever the first round did. Keep them apart: only round 0 says whether
|
|
386
|
+
// the assembled view was cached (see `noteCacheOutcome`).
|
|
387
|
+
const rounds = [];
|
|
375
388
|
let totalCost = 0;
|
|
376
389
|
const conversationInput = itemsToInput(prepared.remaining);
|
|
377
|
-
const textFormat = request.outputSchema
|
|
390
|
+
const textFormat = request.outputSchema
|
|
391
|
+
? buildTextFormat(request.outputSchema, request.outputJsonSchema)
|
|
392
|
+
: undefined;
|
|
378
393
|
let round = 0;
|
|
379
394
|
let invalidRecoveryContinuations = 0;
|
|
380
395
|
let toolLimitRecoveryContinuations = 0;
|
|
@@ -396,7 +411,7 @@ export class AgentHarnessModelCaller {
|
|
|
396
411
|
let idleStalled = false;
|
|
397
412
|
const watchdog = createStreamIdleWatchdog(this.opts.streamIdleTimeoutMs, roundController, () => {
|
|
398
413
|
idleStalled = true;
|
|
399
|
-
prepared.emitIfAllowed('
|
|
414
|
+
prepared.emitIfAllowed('model_call_stalled', {
|
|
400
415
|
round,
|
|
401
416
|
idleTimeoutMs: this.opts.streamIdleTimeoutMs,
|
|
402
417
|
});
|
|
@@ -404,7 +419,7 @@ export class AgentHarnessModelCaller {
|
|
|
404
419
|
const modelInput = recoveryContinuation
|
|
405
420
|
? withEphemeralContinueInput(conversationInput)
|
|
406
421
|
: frameworkCast(conversationInput);
|
|
407
|
-
prepared.emitIfAllowed('
|
|
422
|
+
prepared.emitIfAllowed('model_call_started', {
|
|
408
423
|
round,
|
|
409
424
|
messageCount: modelInput.length,
|
|
410
425
|
toolCount: prepared.sdkTools?.length ?? 0,
|
|
@@ -436,7 +451,7 @@ export class AgentHarnessModelCaller {
|
|
|
436
451
|
watchdog.reset();
|
|
437
452
|
if (!firstEventSeen) {
|
|
438
453
|
firstEventSeen = true;
|
|
439
|
-
prepared.emitIfAllowed('
|
|
454
|
+
prepared.emitIfAllowed('model_call_first_event', {
|
|
440
455
|
round,
|
|
441
456
|
});
|
|
442
457
|
}
|
|
@@ -452,7 +467,7 @@ export class AgentHarnessModelCaller {
|
|
|
452
467
|
if (idleStalled) {
|
|
453
468
|
throw roundSignal.reason instanceof Error
|
|
454
469
|
? roundSignal.reason
|
|
455
|
-
: new Error(`
|
|
470
|
+
: new Error(`model stream idle timeout after ${this.opts.streamIdleTimeoutMs}ms`);
|
|
456
471
|
}
|
|
457
472
|
if (request.signal?.aborted) {
|
|
458
473
|
break;
|
|
@@ -497,16 +512,14 @@ export class AgentHarnessModelCaller {
|
|
|
497
512
|
continue;
|
|
498
513
|
}
|
|
499
514
|
invalidRecoveryContinuations = 0;
|
|
500
|
-
prepared.emitIfAllowed('
|
|
515
|
+
prepared.emitIfAllowed('model_call_completed', {
|
|
501
516
|
round,
|
|
502
517
|
itemCount: sdkResponse.output?.length ?? 0,
|
|
503
518
|
});
|
|
504
519
|
const roundUsage = extractUsage(sdkResponse.usage);
|
|
505
520
|
const roundCost = sdkResponse.usage?.cost ?? 0;
|
|
506
|
-
spans.finishModelSpan(modelSpan,
|
|
507
|
-
|
|
508
|
-
outputTokens: roundUsage.outputTokens,
|
|
509
|
-
}, roundCost > 0 ? roundCost : undefined);
|
|
521
|
+
spans.finishModelSpan(modelSpan, roundUsage, roundCost > 0 ? roundCost : undefined);
|
|
522
|
+
rounds.push(roundUsage);
|
|
510
523
|
totalUsage.inputTokens += roundUsage.inputTokens;
|
|
511
524
|
totalUsage.outputTokens += roundUsage.outputTokens;
|
|
512
525
|
totalUsage.cachedTokens += roundUsage.cachedTokens ?? 0;
|
|
@@ -539,7 +552,16 @@ export class AgentHarnessModelCaller {
|
|
|
539
552
|
}
|
|
540
553
|
return {
|
|
541
554
|
items: allItems,
|
|
542
|
-
usage:
|
|
555
|
+
usage: {
|
|
556
|
+
inputTokens: totalUsage.inputTokens,
|
|
557
|
+
outputTokens: totalUsage.outputTokens,
|
|
558
|
+
// Stay `undefined` when no round reported a figure, so callers can tell
|
|
559
|
+
// "this provider says nothing about caching" from "nothing was cached".
|
|
560
|
+
cachedTokens: rounds.some((r) => r.cachedTokens !== undefined)
|
|
561
|
+
? totalUsage.cachedTokens
|
|
562
|
+
: undefined,
|
|
563
|
+
},
|
|
564
|
+
rounds,
|
|
543
565
|
cost: totalCost > 0 ? totalCost : undefined,
|
|
544
566
|
};
|
|
545
567
|
}
|
|
@@ -588,7 +610,7 @@ export class AgentHarnessModelCaller {
|
|
|
588
610
|
kind: 'ok',
|
|
589
611
|
};
|
|
590
612
|
}
|
|
591
|
-
params.emitIfAllowed('
|
|
613
|
+
params.emitIfAllowed('model_call_failed', {
|
|
592
614
|
round: params.round,
|
|
593
615
|
status: terminalError.status,
|
|
594
616
|
error: terminalError.message,
|
|
@@ -598,7 +620,7 @@ export class AgentHarnessModelCaller {
|
|
|
598
620
|
throw new Error(terminalError.message);
|
|
599
621
|
}
|
|
600
622
|
const next = params.invalidRecoveryContinuations + 1;
|
|
601
|
-
params.emitIfAllowed('
|
|
623
|
+
params.emitIfAllowed('model_call_recovery_continue', {
|
|
602
624
|
round: params.round,
|
|
603
625
|
status: terminalError.status,
|
|
604
626
|
attempt: next,
|
|
@@ -616,7 +638,7 @@ export class AgentHarnessModelCaller {
|
|
|
616
638
|
};
|
|
617
639
|
}
|
|
618
640
|
const message = 'LLM response completed with no output items';
|
|
619
|
-
params.emitIfAllowed('
|
|
641
|
+
params.emitIfAllowed('model_call_failed', {
|
|
620
642
|
round: params.round,
|
|
621
643
|
status: 'completed',
|
|
622
644
|
error: message,
|
|
@@ -626,7 +648,7 @@ export class AgentHarnessModelCaller {
|
|
|
626
648
|
throw new Error(message);
|
|
627
649
|
}
|
|
628
650
|
const next = params.invalidRecoveryContinuations + 1;
|
|
629
|
-
params.emitIfAllowed('
|
|
651
|
+
params.emitIfAllowed('model_call_recovery_continue', {
|
|
630
652
|
round: params.round,
|
|
631
653
|
status: 'completed',
|
|
632
654
|
attempt: next,
|
|
@@ -733,7 +755,7 @@ export class AgentHarnessModelCaller {
|
|
|
733
755
|
recordMalformedToolCall(params) {
|
|
734
756
|
const { fc, request, allItems, conversationInput } = params;
|
|
735
757
|
const errorOutput = `Error: malformed JSON in tool arguments: ${fc.arguments}`;
|
|
736
|
-
const toolForCall = request.tools?.find((tool) => tool.name === fc.name);
|
|
758
|
+
const toolForCall = request.tools?.find((tool) => tool.name === fc.name || sanitizeToolNameForWire(tool.name) === fc.name);
|
|
737
759
|
// Owner-scoped result validation (see executeFunctionCall).
|
|
738
760
|
const outputItem = createToolResultItem({
|
|
739
761
|
output: errorOutput,
|
package/dist/index.d.ts
CHANGED
|
@@ -11,31 +11,35 @@ export { channel } from './builders/channel-builder.js';
|
|
|
11
11
|
/** @public */
|
|
12
12
|
export { context } from './builders/context-builder.js';
|
|
13
13
|
/** @public */
|
|
14
|
-
export {
|
|
14
|
+
export { conditional, inParallel } from './builders/control-flow-builders.js';
|
|
15
15
|
/** @public */
|
|
16
|
-
export type {
|
|
16
|
+
export type { ScheduleOptions } from './builders/every.js';
|
|
17
17
|
/** @public */
|
|
18
|
-
export {
|
|
18
|
+
export { schedule } from './builders/every.js';
|
|
19
19
|
/** @public */
|
|
20
|
-
export { layerData,
|
|
20
|
+
export { layerData, layerFunction } from './builders/layer-provides-builders.js';
|
|
21
21
|
/** @public */
|
|
22
22
|
export type { LoopConfig } from './builders/loop-builder.js';
|
|
23
23
|
/** @public */
|
|
24
24
|
export { loop } from './builders/loop-builder.js';
|
|
25
25
|
/** @public */
|
|
26
|
-
export {
|
|
26
|
+
export { withContext } from './builders/provide-builder.js';
|
|
27
27
|
/** @public */
|
|
28
28
|
export { spawn } from './builders/spawn-builder.js';
|
|
29
29
|
/** @public */
|
|
30
|
+
export type { CallModelOpts, InvokeToolOpts, RunCodeOpts } from './builders/step-builders.js';
|
|
31
|
+
/** @public */
|
|
32
|
+
export { callModel, invokeTool, runCode, step } from './builders/step-builders.js';
|
|
33
|
+
/** @public */
|
|
30
34
|
export { tool, toolWithGenerator } from './builders/tool-builder.js';
|
|
31
35
|
/** @public */
|
|
32
36
|
export type { HydrationContext } from './builders/workflow-hydrator.js';
|
|
33
37
|
/** @public */
|
|
34
38
|
export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
|
|
35
39
|
/** @public */
|
|
36
|
-
export type {
|
|
40
|
+
export type { WorkflowOpts } from './builders/workflow-step.js';
|
|
37
41
|
/** @public */
|
|
38
|
-
export {
|
|
42
|
+
export { workflow } from './builders/workflow-step.js';
|
|
39
43
|
/** @public */
|
|
40
44
|
export type { Condition, OtherwiseClause, WhenClause } from './conditions/conditions.js';
|
|
41
45
|
/** @public */
|
|
@@ -57,7 +61,7 @@ export { execute } from './interpreter/execute.js';
|
|
|
57
61
|
/** @public */
|
|
58
62
|
/** @public */
|
|
59
63
|
/** @public */
|
|
60
|
-
export type {
|
|
64
|
+
export type { FactExtractor, FactSearcher, HistoryConfig, ObservationsConfig, ObservationsState, PlanConfig, PlanEnterSessionCallback, PlanExecutionEntry, PlanExitCallback, PlanState, ScratchpadConfig, ScratchpadState, TaskState, TemporalConfig, TemporalFact, TemporalSearchResult, } from '@noetic-tools/context';
|
|
61
65
|
/** @public */
|
|
62
66
|
/** @public */
|
|
63
67
|
/** @public */
|
|
@@ -70,7 +74,7 @@ export type { DurableTaskState, FactExtractor, FactSearcher, HistoryWindowConfig
|
|
|
70
74
|
/** @public */
|
|
71
75
|
/** @public */
|
|
72
76
|
/** @public */
|
|
73
|
-
export {
|
|
77
|
+
export { filesystem, findFunctionCall, history, instructions, observations, PlanPhase, PlanStyle, plan, scratchpad, steering, storageGetMany, stripUnresolvedToolCalls, taskState, temporal, toolCalls, } from '@noetic-tools/context';
|
|
74
78
|
/** @public */
|
|
75
79
|
export { createMessage, estimateTokens } from '@noetic-tools/types';
|
|
76
80
|
/** @public */
|
|
@@ -80,21 +84,11 @@ export { InMemoryExporter, NoopExporter } from './observability/trace-exporter.j
|
|
|
80
84
|
/** @public */
|
|
81
85
|
export { createInMemoryStorage } from './runtime/in-memory-storage.js';
|
|
82
86
|
/** @public */
|
|
83
|
-
export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './
|
|
84
|
-
/** @public */
|
|
85
|
-
export { dynamicWorkflow, parseAndRunWorkflow } from './patterns/dynamic-workflow.js';
|
|
86
|
-
/** @public */
|
|
87
|
-
export type { InterviewOpts, InterviewQuestionAnswer, InterviewResult } from './patterns/interview.js';
|
|
88
|
-
/** @public */
|
|
89
|
-
export { interview } from './patterns/interview.js';
|
|
90
|
-
/** @public */
|
|
91
|
-
export type { PlanConstraints, PlanNode } from './patterns/plans.js';
|
|
92
|
-
/** @public */
|
|
93
|
-
export { adaptivePlan, compilePlan, PlanNodeSchema } from './patterns/plans.js';
|
|
87
|
+
export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './builders/dynamic-workflow.js';
|
|
94
88
|
/** @public */
|
|
95
|
-
export {
|
|
89
|
+
export { dynamicWorkflow, parseAndRunWorkflow } from './builders/dynamic-workflow.js';
|
|
96
90
|
/** @public */
|
|
97
|
-
export {
|
|
91
|
+
export type { AgentEnvironmentConfig, StorageEnvironmentConfig, } from './harness/agent-harness.js';
|
|
98
92
|
/** @public */
|
|
99
93
|
export { AgentHarness } from './harness/agent-harness.js';
|
|
100
94
|
/** @public */
|
|
@@ -106,20 +100,20 @@ export { getRegistry, lookupStep, registerStep } from './runtime/step-registry.j
|
|
|
106
100
|
/** @public */
|
|
107
101
|
export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from '@noetic-tools/types';
|
|
108
102
|
/** @public */
|
|
109
|
-
export type {
|
|
103
|
+
export type { CallModelWorkflowNode, ConditionalRoute, ConditionalWorkflowNode, InParallelWorkflowNode, InvokeToolWorkflowNode, LoopWorkflowNode, MergeStrategy, ScheduleWorkflowNode, SequenceWorkflowNode, SpawnWorkflowNode, SubflowWorkflowNode, SubHarnessWorkflowNode, UntilPredicate, WithContextWorkflowNode, WorkflowDocument, WorkflowNode, } from './schemas/workflow.js';
|
|
110
104
|
/** @public */
|
|
111
105
|
export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow.js';
|
|
112
106
|
/** @public */
|
|
113
107
|
export type { Channel, ChannelHandle, ExternalChannel } from '@noetic-tools/types';
|
|
114
108
|
/** @public */
|
|
115
109
|
/** @public */
|
|
116
|
-
export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, ServerToolSpec, StepMeta, TokenUsage, Tool, ToolContextDeclaration, } from '@noetic-tools/types';
|
|
110
|
+
export type { InferSchemaInput, InferSchemaOutput, InputSchemaConfig, LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, RoundUsage, SchemaValidationFailure, SchemaValidationResult, SchemaValidationSuccess, ServerToolSpec, StandardJSONSchemaV1, StandardSchemaV1, StepMeta, TokenUsage, Tool, ToolContextDeclaration, } from '@noetic-tools/types';
|
|
117
111
|
/** @public */
|
|
118
|
-
export { isServerToolSpec } from '@noetic-tools/types';
|
|
112
|
+
export { isServerToolSpec, isStandardJsonSchema, isZodSchema, standardIssuesToZodError, validateSchema, } from '@noetic-tools/types';
|
|
119
113
|
/** @public */
|
|
120
114
|
/** @public */
|
|
121
115
|
/** @public */
|
|
122
|
-
export type { Context, ContextHarness, CwdState, ItemLog, LastLayerUsage, LayerUsageEntry, RestoreContextOptions, } from '@noetic-tools/types';
|
|
116
|
+
export type { Context, ContextHarness, CwdState, EpochUsage, ItemLog, LastLayerUsage, LayerUsageEntry, RestoreContextOptions, } from '@noetic-tools/types';
|
|
123
117
|
/** @public */
|
|
124
118
|
export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers.js';
|
|
125
119
|
/** @public */
|
|
@@ -137,7 +131,7 @@ export type { NoeticError } from '@noetic-tools/types';
|
|
|
137
131
|
/** @public */
|
|
138
132
|
export type { ContentPart, DeveloperMessageExtensionItem, ExecuteInput, ExtendedItem, ExtensionItem, FileSearchItem, FunctionCallItem, FunctionCallOutputItem, ImageGenerationItem, InferExtendedItem, InputContentPart, InputFilePart, InputImagePart, InputMessageItem, InputTextPart, Item, ItemBase, ItemSchemaExtensions, MessageItem, OutputItem, OutputTextPart, ReasoningItem, ReasoningTextPart, RefusalPart, ServerToolItem, SummaryTextPart, WebSearchItem, } from '@noetic-tools/types';
|
|
139
133
|
/** @public */
|
|
140
|
-
export type { BudgetConfig, CompleteParams, ContextConfig, ContextData, ContextLayer, ContextLayerHooks, DisposeParams, InferContext, InferContextShape, InitParams, InitResult, LayerDataDecl, LayerFunctionDecl, LayerProvides, LayerTimeouts, ProjectionPolicy, RecallParams, RecallResult, ReturnParams, ReturnResult, ScopedStorage, SpawnParams, SpawnResult, StorageAdapter, StoreParams, StoreResult, } from '@noetic-tools/context';
|
|
134
|
+
export type { BudgetConfig, CompleteParams, ContextConfig, ContextData, ContextLayer, ContextLayerHooks, DisposeParams, InferContext, InferContextShape, InitParams, InitResult, LayerDataDecl, LayerFunctionDecl, LayerPlacement, LayerProvides, LayerTimeouts, ProjectionPolicy, RecallParams, RecallResult, RenderDeltaParams, ReturnParams, ReturnResult, ScopedStorage, SpawnParams, SpawnResult, StorageAdapter, StoreParams, StoreResult, } from '@noetic-tools/context';
|
|
141
135
|
/** @public */
|
|
142
136
|
export { Slot } from '@noetic-tools/context';
|
|
143
137
|
/** @public */
|
|
@@ -147,13 +141,13 @@ export type { LayerTraceSpan, Span, TraceExporter } from '@noetic-tools/types';
|
|
|
147
141
|
/** @public */
|
|
148
142
|
export type { FrameworkStreamEvent, HarnessResponse, SdkStreamEvent, StreamEvent, StreamingItem, } from '@noetic-tools/types';
|
|
149
143
|
/** @public */
|
|
150
|
-
export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, DeliveryMode, ExecuteOptions, HarnessStatus, RecallLayerOutput, SessionScope, } from '@noetic-tools/types';
|
|
144
|
+
export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, ContextCacheConfig, ContextCacheStore, ContextEpoch, DeliveryMode, ExecuteOptions, HarnessStatus, ItemSchemaConfig, ReanchorReason, RecallLayerOutput, SessionScope, SessionUsage, } from '@noetic-tools/types';
|
|
151
145
|
/** @public */
|
|
152
146
|
export type { AfterModelCallParams, AfterModelCallResult, BeforeToolCallParams, BeforeToolCallResult, LedgerEntry, SteeringConfig, SteeringDecision, SteeringRule, SteeringState, } from '@noetic-tools/types';
|
|
153
147
|
/** @public */
|
|
154
148
|
export { LedgerEntryKind, SteeringAction } from '@noetic-tools/types';
|
|
155
149
|
/** @public */
|
|
156
|
-
export type { ExecuteStepFn, SettleResult, Snapshot, Step,
|
|
150
|
+
export type { ExecuteStepFn, SettleResult, Snapshot, Step, StepCallModel, StepConditional, StepInParallel, StepInParallelAll, StepInParallelRace, StepInParallelSettle, StepInvokeTool, StepLoop, StepRunCode, StepSpawn, StepSubHarness, StepWithContext, Until, Verdict, } from '@noetic-tools/types';
|
|
157
151
|
/** @public */
|
|
158
152
|
export type { SubHarness, SubHarnessBuiltinTool, SubHarnessContinueState, SubHarnessContinueTurnOptions, SubHarnessFinishReason, SubHarnessPromptTurnOptions, SubHarnessResumeState, SubHarnessRunContext, SubHarnessSession, SubHarnessSessionPolicy, SubHarnessSettings, SubHarnessStartOptions, SubHarnessStreamPart, SubHarnessTurnResult, } from '@noetic-tools/types';
|
|
159
153
|
/** @public */
|
|
@@ -175,9 +169,3 @@ export { all, any } from './until/combinators.js';
|
|
|
175
169
|
export type { ConvergeConfig, VerifyFn } from './until/predicates.js';
|
|
176
170
|
/** @public */
|
|
177
171
|
export { until } from './until/predicates.js';
|
|
178
|
-
/**
|
|
179
|
-
* Pre-rename names for the context layer system — `MemoryLayer`, `memory()`,
|
|
180
|
-
* `workingMemory`, and friends. Each carries its own `@deprecated` pointer to
|
|
181
|
-
* its replacement in `./deprecated`. Removed in the next major.
|
|
182
|
-
*/
|
|
183
|
-
export * from './deprecated.js';
|
package/dist/index.js
CHANGED
|
@@ -14,23 +14,25 @@ export { channel } from './builders/channel-builder.js';
|
|
|
14
14
|
/** @public */
|
|
15
15
|
export { context } from './builders/context-builder.js';
|
|
16
16
|
/** @public */
|
|
17
|
-
export {
|
|
17
|
+
export { conditional, inParallel } from './builders/control-flow-builders.js';
|
|
18
18
|
/** @public */
|
|
19
|
-
export {
|
|
19
|
+
export { schedule } from './builders/every.js';
|
|
20
20
|
/** @public */
|
|
21
|
-
export { layerData,
|
|
21
|
+
export { layerData, layerFunction } from './builders/layer-provides-builders.js';
|
|
22
22
|
/** @public */
|
|
23
23
|
export { loop } from './builders/loop-builder.js';
|
|
24
24
|
/** @public */
|
|
25
|
-
export {
|
|
25
|
+
export { withContext } from './builders/provide-builder.js';
|
|
26
26
|
/** @public */
|
|
27
27
|
export { spawn } from './builders/spawn-builder.js';
|
|
28
28
|
/** @public */
|
|
29
|
+
export { callModel, invokeTool, runCode, step } from './builders/step-builders.js';
|
|
30
|
+
/** @public */
|
|
29
31
|
export { tool, toolWithGenerator } from './builders/tool-builder.js';
|
|
30
32
|
/** @public */
|
|
31
33
|
export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
|
|
32
34
|
/** @public */
|
|
33
|
-
export {
|
|
35
|
+
export { workflow } from './builders/workflow-step.js';
|
|
34
36
|
/** @public */
|
|
35
37
|
export { aiCondition, allCondition, anyCondition, embeddingMatch, otherwise, semanticRoute, semanticSwitch, when, } from './conditions/conditions.js';
|
|
36
38
|
/** @public */
|
|
@@ -58,7 +60,7 @@ export { execute } from './interpreter/execute.js';
|
|
|
58
60
|
/** @public */
|
|
59
61
|
/** @public */
|
|
60
62
|
/** @public */
|
|
61
|
-
export {
|
|
63
|
+
export { filesystem, findFunctionCall, history, instructions, observations, PlanPhase, PlanStyle, plan, scratchpad, steering, storageGetMany, stripUnresolvedToolCalls, taskState, temporal, toolCalls, } from '@noetic-tools/context';
|
|
62
64
|
//#endregion
|
|
63
65
|
//#region Message Utilities
|
|
64
66
|
/** @public */
|
|
@@ -72,17 +74,7 @@ export { InMemoryExporter, NoopExporter } from './observability/trace-exporter.j
|
|
|
72
74
|
/** @public */
|
|
73
75
|
export { createInMemoryStorage } from './runtime/in-memory-storage.js';
|
|
74
76
|
/** @public */
|
|
75
|
-
export { dynamicWorkflow, parseAndRunWorkflow } from './
|
|
76
|
-
/** @public */
|
|
77
|
-
export { interview } from './patterns/interview.js';
|
|
78
|
-
/** @public */
|
|
79
|
-
export { adaptivePlan, compilePlan, PlanNodeSchema } from './patterns/plans.js';
|
|
80
|
-
/** @public */
|
|
81
|
-
export { ralphWiggum } from './patterns/ralph-wiggum.js';
|
|
82
|
-
/** @public */
|
|
83
|
-
export { react } from './patterns/react.js';
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region Runtime
|
|
77
|
+
export { dynamicWorkflow, parseAndRunWorkflow } from './builders/dynamic-workflow.js';
|
|
86
78
|
/** @public */
|
|
87
79
|
export { AgentHarness } from './harness/agent-harness.js';
|
|
88
80
|
/** @public */
|
|
@@ -96,7 +88,7 @@ export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from '@noet
|
|
|
96
88
|
/** @public */
|
|
97
89
|
export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow.js';
|
|
98
90
|
/** @public */
|
|
99
|
-
export { isServerToolSpec } from '@noetic-tools/types';
|
|
91
|
+
export { isServerToolSpec, isStandardJsonSchema, isZodSchema, standardIssuesToZodError, validateSchema, } from '@noetic-tools/types';
|
|
100
92
|
/** @public */
|
|
101
93
|
export { getToolCwd, setToolCwd, snapshotCwdState } from './runtime/cwd-helpers.js';
|
|
102
94
|
/** @public */
|
|
@@ -120,11 +112,3 @@ export { all, any } from './until/combinators.js';
|
|
|
120
112
|
/** @public */
|
|
121
113
|
export { until } from './until/predicates.js';
|
|
122
114
|
//#endregion
|
|
123
|
-
//#region Deprecated aliases
|
|
124
|
-
/**
|
|
125
|
-
* Pre-rename names for the context layer system — `MemoryLayer`, `memory()`,
|
|
126
|
-
* `workingMemory`, and friends. Each carries its own `@deprecated` pointer to
|
|
127
|
-
* its replacement in `./deprecated`. Removed in the next major.
|
|
128
|
-
*/
|
|
129
|
-
export * from './deprecated.js';
|
|
130
|
-
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { LayerStateStore } from '@noetic-tools/context';
|
|
2
|
-
export { allocateBudgets, assembleView, commitLayerUsage, computeLayerUsage, contextToExecCtx, DEFAULT_PROJECTION, resolveLayerTools, returnLayers, spawnLayers, } from '@noetic-tools/context';
|
|
1
|
+
export type { LayerServeInfo, LayerStateStore } from '@noetic-tools/context';
|
|
2
|
+
export { allocateBudgets, assembleView, churnFor, churnRate, commitLayerUsage, computeLayerUsage, contextToExecCtx, createContextCacheStore, DEFAULT_PROJECTION, lineageKey, noteCacheOutcome, openEpoch, pin, pinKey, reanchorReason, resolveCacheConfig, resolveLayerTools, returnLayers, spawnLayers, } from '@noetic-tools/context';
|
|
3
3
|
export type { ItemSchemaRegistry } from '@noetic-tools/types';
|
|
4
4
|
export { defaultItemSchemaRegistry } from '@noetic-tools/types';
|
|
5
5
|
export { emitFrameworkEvent, getBroadcaster, shouldEmit } from '../runtime/broadcaster-utils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { allocateBudgets, assembleView, commitLayerUsage, computeLayerUsage, contextToExecCtx, DEFAULT_PROJECTION, resolveLayerTools, returnLayers, spawnLayers, } from '@noetic-tools/context';
|
|
1
|
+
export { allocateBudgets, assembleView, churnFor, churnRate, commitLayerUsage, computeLayerUsage, contextToExecCtx, createContextCacheStore, DEFAULT_PROJECTION, lineageKey, noteCacheOutcome, openEpoch, pin, pinKey, reanchorReason, resolveCacheConfig, resolveLayerTools, returnLayers, spawnLayers, } from '@noetic-tools/context';
|
|
2
2
|
export { defaultItemSchemaRegistry } from '@noetic-tools/types';
|
|
3
3
|
export { emitFrameworkEvent, getBroadcaster, shouldEmit } from '../runtime/broadcaster-utils.js';
|
|
4
4
|
export { ContextImpl } from '../runtime/context-impl.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { ContextConfig, ContextData, ContextLayer, ExecutionContext, } from '@noetic-tools/context';
|
|
2
|
-
export type { AgentHarnessContract, Context, ContextRerenderRequest, ExecuteStepFn, FunctionCallItem, Item, ProjectionPolicy, RecallLayerOutput, RetryPolicy, ServerToolSpec,
|
|
2
|
+
export type { AgentHarnessContract, CallModelRequest, Context, ContextRerenderRequest, ExecuteStepFn, FunctionCallItem, InputMessageItem, Item, LLMResponse, ProjectionPolicy, RecallLayerOutput, RetryPolicy, ServerToolSpec, StepCallModel, StepInvokeTool, StepMeta, StepRunCode, StepSpawn, StepWithContext, Tool, } from '@noetic-tools/types';
|
|
3
3
|
export { isServerToolSpec, SteeringAction } from '@noetic-tools/types';
|
|
@@ -27,7 +27,7 @@ export function deduplicateTools(tools) {
|
|
|
27
27
|
}
|
|
28
28
|
function walkStep(step, out) {
|
|
29
29
|
switch (step.kind) {
|
|
30
|
-
case '
|
|
30
|
+
case 'callModel':
|
|
31
31
|
// Skip function-form tools: they're resolved per execution from `ctx`
|
|
32
32
|
// and cannot contribute to the pre-computed unified set. Consumers that
|
|
33
33
|
// need those tools in the pool should register them via
|
|
@@ -41,8 +41,8 @@ function walkStep(step, out) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return;
|
|
44
|
-
case '
|
|
45
|
-
case '
|
|
44
|
+
case 'runCode':
|
|
45
|
+
case 'invokeTool':
|
|
46
46
|
// SubHarness steps run their own built-in tools inside the external agent;
|
|
47
47
|
// they contribute nothing to the host unified tool set.
|
|
48
48
|
case 'claude-code':
|
|
@@ -50,21 +50,21 @@ function walkStep(step, out) {
|
|
|
50
50
|
case 'opencode':
|
|
51
51
|
case 'pi':
|
|
52
52
|
return;
|
|
53
|
-
case '
|
|
53
|
+
case 'conditional':
|
|
54
54
|
if (step._optimizable) {
|
|
55
55
|
for (const child of step._optimizable) {
|
|
56
56
|
walkStep(child, out);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
return;
|
|
60
|
-
case '
|
|
60
|
+
case 'inParallel':
|
|
61
61
|
if (step._optimizable) {
|
|
62
62
|
for (const child of step._optimizable) {
|
|
63
63
|
walkStep(child, out);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
return;
|
|
67
|
-
case '
|
|
67
|
+
case 'withContext':
|
|
68
68
|
walkStep(step.child, out);
|
|
69
69
|
return;
|
|
70
70
|
case 'spawn':
|
|
@@ -75,7 +75,7 @@ function walkStep(step, out) {
|
|
|
75
75
|
walkStep(child, out);
|
|
76
76
|
}
|
|
77
77
|
return;
|
|
78
|
-
case '
|
|
78
|
+
case 'schedule':
|
|
79
79
|
walkStep(step.step, out);
|
|
80
80
|
return;
|
|
81
81
|
default:
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ContextCacheConfig, ContextCacheStore, ContextLayer, EpochUsage, ExecutionContext, Item, ProjectionPolicy, RecallLayerOutput, Span } from '@noetic-tools/types';
|
|
2
|
+
import type { LayerServeInfo } from './action-deps.js';
|
|
3
|
+
/** What the layer bands contributed to one assembly, and how the epoch fared. */
|
|
4
|
+
export interface BandedView {
|
|
5
|
+
/** Layer output rendered before history — pinned bytes where a pin exists. */
|
|
6
|
+
anchorItems: Item[];
|
|
7
|
+
/** Layer output rendered after history. */
|
|
8
|
+
liveItems: Item[];
|
|
9
|
+
/** At most one developer message superseding stale anchors. */
|
|
10
|
+
deltaItems: Item[];
|
|
11
|
+
/** Per-layer output as actually served, for the usage breakdown. */
|
|
12
|
+
servedPerLayer: RecallLayerOutput[];
|
|
13
|
+
serveInfo: Map<string, LayerServeInfo>;
|
|
14
|
+
epoch: EpochUsage | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface PrepareBandedViewParams {
|
|
17
|
+
/** Recall output, already slot-sorted and merged with any re-render. */
|
|
18
|
+
recallResults: ReadonlyArray<RecallLayerOutput>;
|
|
19
|
+
layers: ReadonlyArray<ContextLayer>;
|
|
20
|
+
execCtx: ExecutionContext;
|
|
21
|
+
store: ContextCacheStore;
|
|
22
|
+
config?: ContextCacheConfig;
|
|
23
|
+
/** Resolved instructions — a change to them invalidates the prefix anyway. */
|
|
24
|
+
instructions: string | undefined;
|
|
25
|
+
policy: ProjectionPolicy;
|
|
26
|
+
systemPromptItems: ReadonlyArray<Item>;
|
|
27
|
+
/** Budget per layer id, used to size a `renderDelta`. */
|
|
28
|
+
budgets: ReadonlyMap<string, number>;
|
|
29
|
+
/**
|
|
30
|
+
* When true, read pins without writing: no new pins, no churn, no epoch
|
|
31
|
+
* ageing. For preview paths that must not disturb a live conversation.
|
|
32
|
+
*/
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Split recall output into the anchor and live bands, replay pinned anchors, and
|
|
37
|
+
* gather everything that changed into a single supersede message.
|
|
38
|
+
*
|
|
39
|
+
* Runs once per LLM step, before the steering retry loop — a retry replays the
|
|
40
|
+
* same view, so re-pinning or re-counting churn there would distort both.
|
|
41
|
+
*/
|
|
42
|
+
export declare function prepareBandedView(params: PrepareBandedViewParams): Promise<BandedView>;
|
|
43
|
+
/**
|
|
44
|
+
* Record how the view was banded on the step's span, so a slow or expensive run
|
|
45
|
+
* can be traced back to the layer that keeps invalidating the prefix.
|
|
46
|
+
*/
|
|
47
|
+
export declare function stampAnchoringAttributes(span: Span | undefined, view: BandedView): void;
|
|
48
|
+
/** Tokens the prompt prefix was expected to have cached — what `noteCacheOutcome` judges against. */
|
|
49
|
+
export declare function expectedCachedTokens(systemPromptItems: ReadonlyArray<Item>, view: BandedView): number;
|
|
50
|
+
export {};
|