@noetic-tools/core 5.3.0 → 5.4.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 +8 -6
- package/dist/adapters/in-memory-subprocess/step-completion.js +1 -1
- package/dist/adapters/openrouter.d.ts +12 -1
- package/dist/adapters/openrouter.js +79 -5
- package/dist/builders/acp-agent-tool.d.ts +67 -0
- package/dist/builders/acp-agent-tool.js +87 -0
- 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 +20 -14
- 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 +103 -92
- package/dist/builders/step-builders.js +146 -163
- package/dist/builders/tool-builder.d.ts +18 -22
- package/dist/builders/tool-builder.js +6 -4
- package/dist/builders/workflow-hydrator.d.ts +11 -7
- package/dist/builders/workflow-hydrator.js +75 -87
- package/dist/builders/workflow-step.d.ts +15 -27
- package/dist/builders/workflow-step.js +14 -19
- package/dist/conditions/conditions.d.ts +2 -2
- package/dist/conditions/conditions.js +1 -1
- package/dist/harness/agent-harness.d.ts +89 -46
- package/dist/harness/agent-harness.js +93 -39
- package/dist/harness/deps/types.d.ts +1 -1
- package/dist/harness/model-call.d.ts +1 -1
- package/dist/harness/model-call.js +23 -18
- package/dist/index.d.ts +27 -35
- package/dist/index.js +13 -29
- package/dist/interpreter/acp-events.d.ts +67 -0
- package/dist/interpreter/acp-events.js +256 -0
- package/dist/interpreter/acp-history.d.ts +22 -0
- package/dist/interpreter/acp-history.js +58 -0
- package/dist/interpreter/action-types.d.ts +1 -1
- package/dist/interpreter/collect-tools.js +10 -13
- package/dist/interpreter/execute-acp-agent.d.ts +10 -0
- package/dist/interpreter/execute-acp-agent.js +505 -0
- package/dist/interpreter/execute-action.d.ts +5 -5
- package/dist/interpreter/execute-action.js +284 -218
- package/dist/interpreter/execute-control.d.ts +9 -9
- package/dist/interpreter/execute-control.js +27 -27
- package/dist/interpreter/execute.d.ts +1 -1
- package/dist/interpreter/execute.js +29 -35
- 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/portable/builders.d.ts +5 -3
- package/dist/portable/builders.js +8 -5
- package/dist/portable/context-layers.d.ts +1 -1
- package/dist/portable/context-layers.js +1 -1
- package/dist/runtime/acp-session-store.d.ts +75 -0
- package/dist/runtime/acp-session-store.js +0 -0
- 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 +239 -260
- 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/interpreter/execute-sub-harness.d.ts +0 -8
- package/dist/interpreter/execute-sub-harness.js +0 -241
- package/dist/interpreter/sub-harness-events.d.ts +0 -48
- package/dist/interpreter/sub-harness-events.js +0 -208
- 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
package/dist/index.d.ts
CHANGED
|
@@ -7,35 +7,43 @@ export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export { createOpenRouterEmbed } from './adapters/openrouter.js';
|
|
9
9
|
/** @public */
|
|
10
|
+
export type { AcpAgentToolOptions } from './builders/acp-agent-tool.js';
|
|
11
|
+
/** @public */
|
|
12
|
+
export { acpAgentTool } from './builders/acp-agent-tool.js';
|
|
13
|
+
/** @public */
|
|
10
14
|
export { channel } from './builders/channel-builder.js';
|
|
11
15
|
/** @public */
|
|
12
16
|
export { context } from './builders/context-builder.js';
|
|
13
17
|
/** @public */
|
|
14
|
-
export {
|
|
18
|
+
export { conditional, inParallel } from './builders/control-flow-builders.js';
|
|
15
19
|
/** @public */
|
|
16
|
-
export type {
|
|
20
|
+
export type { ScheduleOptions } from './builders/every.js';
|
|
17
21
|
/** @public */
|
|
18
|
-
export {
|
|
22
|
+
export { schedule } from './builders/every.js';
|
|
19
23
|
/** @public */
|
|
20
|
-
export { layerData,
|
|
24
|
+
export { layerData, layerFunction } from './builders/layer-provides-builders.js';
|
|
21
25
|
/** @public */
|
|
22
26
|
export type { LoopConfig } from './builders/loop-builder.js';
|
|
23
27
|
/** @public */
|
|
24
28
|
export { loop } from './builders/loop-builder.js';
|
|
25
29
|
/** @public */
|
|
26
|
-
export {
|
|
30
|
+
export { withContext } from './builders/provide-builder.js';
|
|
27
31
|
/** @public */
|
|
28
32
|
export { spawn } from './builders/spawn-builder.js';
|
|
29
33
|
/** @public */
|
|
34
|
+
export type { CallModelOpts, InvokeToolOpts, RunCodeOpts } from './builders/step-builders.js';
|
|
35
|
+
/** @public */
|
|
36
|
+
export { callModel, invokeTool, runCode, step } from './builders/step-builders.js';
|
|
37
|
+
/** @public */
|
|
30
38
|
export { tool, toolWithGenerator } from './builders/tool-builder.js';
|
|
31
39
|
/** @public */
|
|
32
40
|
export type { HydrationContext } from './builders/workflow-hydrator.js';
|
|
33
41
|
/** @public */
|
|
34
42
|
export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
|
|
35
43
|
/** @public */
|
|
36
|
-
export type {
|
|
44
|
+
export type { WorkflowOpts } from './builders/workflow-step.js';
|
|
37
45
|
/** @public */
|
|
38
|
-
export {
|
|
46
|
+
export { workflow } from './builders/workflow-step.js';
|
|
39
47
|
/** @public */
|
|
40
48
|
export type { Condition, OtherwiseClause, WhenClause } from './conditions/conditions.js';
|
|
41
49
|
/** @public */
|
|
@@ -57,7 +65,7 @@ export { execute } from './interpreter/execute.js';
|
|
|
57
65
|
/** @public */
|
|
58
66
|
/** @public */
|
|
59
67
|
/** @public */
|
|
60
|
-
export type {
|
|
68
|
+
export type { FactExtractor, FactSearcher, HistoryConfig, ObservationsConfig, ObservationsState, PlanConfig, PlanEnterSessionCallback, PlanExecutionEntry, PlanExitCallback, PlanState, ScratchpadConfig, ScratchpadState, TaskState, TemporalConfig, TemporalFact, TemporalSearchResult, } from '@noetic-tools/context';
|
|
61
69
|
/** @public */
|
|
62
70
|
/** @public */
|
|
63
71
|
/** @public */
|
|
@@ -70,7 +78,7 @@ export type { DurableTaskState, FactExtractor, FactSearcher, HistoryWindowConfig
|
|
|
70
78
|
/** @public */
|
|
71
79
|
/** @public */
|
|
72
80
|
/** @public */
|
|
73
|
-
export {
|
|
81
|
+
export { filesystem, findFunctionCall, history, instructions, observations, PlanPhase, PlanStyle, plan, scratchpad, steering, storageGetMany, stripUnresolvedToolCalls, taskState, temporal, toolCalls, } from '@noetic-tools/context';
|
|
74
82
|
/** @public */
|
|
75
83
|
export { createMessage, estimateTokens } from '@noetic-tools/types';
|
|
76
84
|
/** @public */
|
|
@@ -80,21 +88,11 @@ export { InMemoryExporter, NoopExporter } from './observability/trace-exporter.j
|
|
|
80
88
|
/** @public */
|
|
81
89
|
export { createInMemoryStorage } from './runtime/in-memory-storage.js';
|
|
82
90
|
/** @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';
|
|
91
|
+
export type { DynamicWorkflowOpts, ParseAndRunWorkflowOpts } from './builders/dynamic-workflow.js';
|
|
94
92
|
/** @public */
|
|
95
|
-
export {
|
|
93
|
+
export { dynamicWorkflow, parseAndRunWorkflow } from './builders/dynamic-workflow.js';
|
|
96
94
|
/** @public */
|
|
97
|
-
export {
|
|
95
|
+
export type { AgentEnvironmentConfig, StorageEnvironmentConfig, } from './harness/agent-harness.js';
|
|
98
96
|
/** @public */
|
|
99
97
|
export { AgentHarness } from './harness/agent-harness.js';
|
|
100
98
|
/** @public */
|
|
@@ -106,16 +104,16 @@ export { getRegistry, lookupStep, registerStep } from './runtime/step-registry.j
|
|
|
106
104
|
/** @public */
|
|
107
105
|
export { defaultItemSchemaRegistry, ItemSchema, ItemSchemaRegistry } from '@noetic-tools/types';
|
|
108
106
|
/** @public */
|
|
109
|
-
export type {
|
|
107
|
+
export type { AcpAgentWorkflowNode, CallModelWorkflowNode, ConditionalRoute, ConditionalWorkflowNode, InParallelWorkflowNode, InvokeToolWorkflowNode, LoopWorkflowNode, MergeStrategy, ScheduleWorkflowNode, SequenceWorkflowNode, SpawnWorkflowNode, SubflowWorkflowNode, UntilPredicate, WithContextWorkflowNode, WorkflowDocument, WorkflowNode, } from './schemas/workflow.js';
|
|
110
108
|
/** @public */
|
|
111
109
|
export { MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, } from './schemas/workflow.js';
|
|
112
110
|
/** @public */
|
|
113
111
|
export type { Channel, ChannelHandle, ExternalChannel } from '@noetic-tools/types';
|
|
114
112
|
/** @public */
|
|
115
113
|
/** @public */
|
|
116
|
-
export type { LLMResponse, LlmProviderConfig, ModelParams, RetryPolicy, RoundUsage, ServerToolSpec, StepMeta, TokenUsage, Tool, ToolContextDeclaration, } from '@noetic-tools/types';
|
|
114
|
+
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
115
|
/** @public */
|
|
118
|
-
export { isServerToolSpec } from '@noetic-tools/types';
|
|
116
|
+
export { isServerToolSpec, isStandardJsonSchema, isZodSchema, standardIssuesToZodError, validateSchema, } from '@noetic-tools/types';
|
|
119
117
|
/** @public */
|
|
120
118
|
/** @public */
|
|
121
119
|
/** @public */
|
|
@@ -147,17 +145,17 @@ export type { LayerTraceSpan, Span, TraceExporter } from '@noetic-tools/types';
|
|
|
147
145
|
/** @public */
|
|
148
146
|
export type { FrameworkStreamEvent, HarnessResponse, SdkStreamEvent, StreamEvent, StreamingItem, } from '@noetic-tools/types';
|
|
149
147
|
/** @public */
|
|
150
|
-
export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, ContextCacheConfig, ContextCacheStore, ContextEpoch, DeliveryMode, ExecuteOptions, HarnessStatus, ReanchorReason, RecallLayerOutput, SessionScope, } from '@noetic-tools/types';
|
|
148
|
+
export type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, ContextCacheConfig, ContextCacheStore, ContextEpoch, DeliveryMode, ExecuteOptions, HarnessStatus, ItemSchemaConfig, ReanchorReason, RecallLayerOutput, SessionScope, SessionUsage, } from '@noetic-tools/types';
|
|
151
149
|
/** @public */
|
|
152
150
|
export type { AfterModelCallParams, AfterModelCallResult, BeforeToolCallParams, BeforeToolCallResult, LedgerEntry, SteeringConfig, SteeringDecision, SteeringRule, SteeringState, } from '@noetic-tools/types';
|
|
153
151
|
/** @public */
|
|
154
152
|
export { LedgerEntryKind, SteeringAction } from '@noetic-tools/types';
|
|
155
153
|
/** @public */
|
|
156
|
-
export type { ExecuteStepFn, SettleResult, Snapshot, Step,
|
|
154
|
+
export type { ExecuteStepFn, SettleResult, Snapshot, Step, StepAcpAgent, StepCallModel, StepConditional, StepInParallel, StepInParallelAll, StepInParallelRace, StepInParallelSettle, StepInvokeTool, StepLoop, StepRunCode, StepSpawn, StepWithContext, Until, Verdict, } from '@noetic-tools/types';
|
|
157
155
|
/** @public */
|
|
158
|
-
export type {
|
|
156
|
+
export type { AcpAgent, AcpAgentCapabilities, AcpAgentConnection, AcpAuthMethod, AcpAvailableCommand, AcpBoundPermissionHandler, AcpClientCapabilityConfig, AcpClientHost, AcpConnectOptions, AcpContentBlock, AcpKeepAlive, AcpLiveSession, AcpLoadSessionOptions, AcpMcpServer, AcpNewSessionOptions, AcpPermissionHandler, AcpPermissionOption, AcpPermissionOutcome, AcpPermissionPolicy, AcpPermissionRequestInfo, AcpPermissionRule, AcpPermissionSteerer, AcpPlanEntry, AcpPromptCapabilities, AcpPromptOptions, AcpRequestPermissionRequest, AcpSession, AcpSessionDisposer, AcpSessionInfo, AcpSessionMode, AcpSessionModeState, AcpSessionNotification, AcpSessionPolicy, AcpStopReason, AcpToolCallContent, AcpToolCallStatus, AcpToolKind, AcpTransport, AcpTransportFactory, AcpTransportOptions, AcpTurnResult, } from '@noetic-tools/types';
|
|
159
157
|
/** @public */
|
|
160
|
-
export {
|
|
158
|
+
export { ACP_AGENT_STEP_KIND, AcpCapabilityError, AcpConnectError, AcpPermissionDecision, isAcpCapabilityError, isAcpConnectError, } from '@noetic-tools/types';
|
|
161
159
|
/** @public */
|
|
162
160
|
export type { FsAdapter, FsStats } from '@noetic-tools/types';
|
|
163
161
|
/** @public */
|
|
@@ -175,9 +173,3 @@ export { all, any } from './until/combinators.js';
|
|
|
175
173
|
export type { ConvergeConfig, VerifyFn } from './until/predicates.js';
|
|
176
174
|
/** @public */
|
|
177
175
|
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
|
@@ -7,30 +7,32 @@ export { createInMemoryShellAdapter } from './adapters/in-memory-shell-adapter.j
|
|
|
7
7
|
export { createInMemorySubprocessAdapter } from './adapters/in-memory-subprocess-adapter.js';
|
|
8
8
|
/** @public */
|
|
9
9
|
export { createOpenRouterEmbed } from './adapters/openrouter.js';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** @public */
|
|
11
|
+
export { acpAgentTool } from './builders/acp-agent-tool.js';
|
|
12
12
|
/** @public */
|
|
13
13
|
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 */
|
|
@@ -108,7 +100,7 @@ export { Slot } from '@noetic-tools/context';
|
|
|
108
100
|
/** @public */
|
|
109
101
|
export { LedgerEntryKind, SteeringAction } from '@noetic-tools/types';
|
|
110
102
|
/** @public */
|
|
111
|
-
export {
|
|
103
|
+
export { ACP_AGENT_STEP_KIND, AcpCapabilityError, AcpConnectError, AcpPermissionDecision, isAcpCapabilityError, isAcpConnectError, } from '@noetic-tools/types';
|
|
112
104
|
/** @public */
|
|
113
105
|
export { TIMEOUT_ERROR_PREFIX } from '@noetic-tools/types';
|
|
114
106
|
/** @public Reusable error-serialiser used by custom SubprocessAdapter implementations. */
|
|
@@ -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
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps an ACP turn's `session/update` notifications onto the harness's
|
|
3
|
+
* observable event surface.
|
|
4
|
+
*
|
|
5
|
+
* Every one of the protocol's eight update variants is translated into the same
|
|
6
|
+
* `source: 'sdk'` broadcaster events the model-call path emits, so a coding
|
|
7
|
+
* agent's text, reasoning, and tool calls flow through `getTextStream()` /
|
|
8
|
+
* `getReasoningStream()` / `getItemStream()` / `getFullStream()` exactly like an
|
|
9
|
+
* LLM step's output. Each notification is *also* re-emitted raw as an
|
|
10
|
+
* `acp_event` framework event for consumers that want the protocol payload.
|
|
11
|
+
*
|
|
12
|
+
* `finalize()` guarantees a turn always emits its output: if an agent returns a
|
|
13
|
+
* stop reason without streaming any text or tool calls, the result's content is
|
|
14
|
+
* synthesized into events.
|
|
15
|
+
*/
|
|
16
|
+
import type { AcpClientActivity, AcpSessionNotification, AcpTurnResult, Context, ContextData, StepAcpAgent } from '@noetic-tools/types';
|
|
17
|
+
export declare class AcpEventBridge {
|
|
18
|
+
private readonly broadcaster?;
|
|
19
|
+
private readonly agentName;
|
|
20
|
+
private readonly stepId;
|
|
21
|
+
private readonly agentId;
|
|
22
|
+
private readonly emitOption;
|
|
23
|
+
private started;
|
|
24
|
+
private completed;
|
|
25
|
+
private nextOutputIndex;
|
|
26
|
+
private messageOutputIndex;
|
|
27
|
+
private sawText;
|
|
28
|
+
/** Tool call ids already announced, so a `tool_call_update` never re-opens one. */
|
|
29
|
+
private readonly announcedToolCalls;
|
|
30
|
+
constructor(step: Pick<StepAcpAgent, 'id' | 'emit'>, agentId: string, ctx: Context<ContextData>);
|
|
31
|
+
/**
|
|
32
|
+
* Open the turn on the event surface. Emits `response.created` so every turn
|
|
33
|
+
* brackets with a lifecycle marker — even an agent that streams nothing.
|
|
34
|
+
*/
|
|
35
|
+
begin(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Record one client-side operation the agent performed. Unlike a `tool_call`
|
|
38
|
+
* update — which is the agent's own account of what it did — this is what it
|
|
39
|
+
* actually asked us to do, refusals included.
|
|
40
|
+
*/
|
|
41
|
+
forwardActivity(activity: AcpClientActivity): void;
|
|
42
|
+
/** Forward one notification: a structured framework event + the mapped sdk events. */
|
|
43
|
+
forward(notification: AcpSessionNotification): void;
|
|
44
|
+
/**
|
|
45
|
+
* Ensure the turn's output reached the event surface. For an agent that
|
|
46
|
+
* returns a result without streaming, synthesize events from the result.
|
|
47
|
+
*/
|
|
48
|
+
finalize(result: AcpTurnResult): void;
|
|
49
|
+
/**
|
|
50
|
+
* Close a turn that failed. The bracket a consumer waits on must be honoured
|
|
51
|
+
* even when the turn dies mid-stream, so an open message is closed and the
|
|
52
|
+
* response completes with an error rather than the stream simply stopping.
|
|
53
|
+
*/
|
|
54
|
+
abort(cause: unknown): void;
|
|
55
|
+
/**
|
|
56
|
+
* Emit one framework event under this step's envelope. The `sdk` sibling
|
|
57
|
+
* below does the same job for the model-stream surface; both gate on
|
|
58
|
+
* `emitOption` so `emit: false` silences every surface at once.
|
|
59
|
+
*/
|
|
60
|
+
private framework;
|
|
61
|
+
private sdk;
|
|
62
|
+
private start;
|
|
63
|
+
private openMessage;
|
|
64
|
+
private closeMessage;
|
|
65
|
+
private emitToolCall;
|
|
66
|
+
private translate;
|
|
67
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps an ACP turn's `session/update` notifications onto the harness's
|
|
3
|
+
* observable event surface.
|
|
4
|
+
*
|
|
5
|
+
* Every one of the protocol's eight update variants is translated into the same
|
|
6
|
+
* `source: 'sdk'` broadcaster events the model-call path emits, so a coding
|
|
7
|
+
* agent's text, reasoning, and tool calls flow through `getTextStream()` /
|
|
8
|
+
* `getReasoningStream()` / `getItemStream()` / `getFullStream()` exactly like an
|
|
9
|
+
* LLM step's output. Each notification is *also* re-emitted raw as an
|
|
10
|
+
* `acp_event` framework event for consumers that want the protocol payload.
|
|
11
|
+
*
|
|
12
|
+
* `finalize()` guarantees a turn always emits its output: if an agent returns a
|
|
13
|
+
* stop reason without streaming any text or tool calls, the result's content is
|
|
14
|
+
* synthesized into events.
|
|
15
|
+
*/
|
|
16
|
+
import { emitFrameworkEvent, getBroadcaster, shouldEmit } from '../runtime/broadcaster-utils.js';
|
|
17
|
+
import { isFunctionCall } from './typeguards.js';
|
|
18
|
+
/** Flatten an ACP content block for the text event surface. */
|
|
19
|
+
function blockText(block) {
|
|
20
|
+
if (block.type === 'text') {
|
|
21
|
+
return block.text;
|
|
22
|
+
}
|
|
23
|
+
if (block.type === 'resource_link') {
|
|
24
|
+
return `[resource: ${block.uri}]`;
|
|
25
|
+
}
|
|
26
|
+
if (block.type === 'resource') {
|
|
27
|
+
return 'text' in block.resource ? block.resource.text : `[resource: ${block.resource.uri}]`;
|
|
28
|
+
}
|
|
29
|
+
return `[${block.type}: ${block.mimeType}]`;
|
|
30
|
+
}
|
|
31
|
+
export class AcpEventBridge {
|
|
32
|
+
broadcaster;
|
|
33
|
+
agentName;
|
|
34
|
+
stepId;
|
|
35
|
+
agentId;
|
|
36
|
+
emitOption;
|
|
37
|
+
started = false;
|
|
38
|
+
completed = false;
|
|
39
|
+
nextOutputIndex = 0;
|
|
40
|
+
messageOutputIndex = null;
|
|
41
|
+
sawText = false;
|
|
42
|
+
/** Tool call ids already announced, so a `tool_call_update` never re-opens one. */
|
|
43
|
+
announcedToolCalls = new Set();
|
|
44
|
+
constructor(step, agentId, ctx) {
|
|
45
|
+
this.broadcaster = getBroadcaster(ctx);
|
|
46
|
+
this.agentName = ctx.harness.config.name;
|
|
47
|
+
this.stepId = step.id;
|
|
48
|
+
this.agentId = agentId;
|
|
49
|
+
this.emitOption = step.emit;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Open the turn on the event surface. Emits `response.created` so every turn
|
|
53
|
+
* brackets with a lifecycle marker — even an agent that streams nothing.
|
|
54
|
+
*/
|
|
55
|
+
begin() {
|
|
56
|
+
this.start();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Record one client-side operation the agent performed. Unlike a `tool_call`
|
|
60
|
+
* update — which is the agent's own account of what it did — this is what it
|
|
61
|
+
* actually asked us to do, refusals included.
|
|
62
|
+
*/
|
|
63
|
+
forwardActivity(activity) {
|
|
64
|
+
this.framework('acp_client_activity', {
|
|
65
|
+
...activity,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Forward one notification: a structured framework event + the mapped sdk events. */
|
|
69
|
+
forward(notification) {
|
|
70
|
+
if (!this.broadcaster) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.framework('acp_event', {
|
|
74
|
+
sessionId: notification.sessionId,
|
|
75
|
+
update: notification.update,
|
|
76
|
+
});
|
|
77
|
+
this.translate(notification.update);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Ensure the turn's output reached the event surface. For an agent that
|
|
81
|
+
* returns a result without streaming, synthesize events from the result.
|
|
82
|
+
*/
|
|
83
|
+
finalize(result) {
|
|
84
|
+
if (!this.broadcaster) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!this.sawText && result.text.length > 0) {
|
|
88
|
+
this.openMessage();
|
|
89
|
+
this.sdk('response.output_text.delta', {
|
|
90
|
+
delta: result.text,
|
|
91
|
+
}, this.messageOutputIndex ?? 0);
|
|
92
|
+
this.sawText = true;
|
|
93
|
+
}
|
|
94
|
+
// Close the message before synthesizing tool calls, so output items finish
|
|
95
|
+
// in index order. Emitting them first left item 0 closing after items 1..n,
|
|
96
|
+
// which reads as interleaved output to a consumer tracking `outputIndex`.
|
|
97
|
+
this.closeMessage();
|
|
98
|
+
for (const item of result.items) {
|
|
99
|
+
if (isFunctionCall(item) && !this.announcedToolCalls.has(item.callId)) {
|
|
100
|
+
this.emitToolCall(item.callId, item.name, item.arguments);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!this.completed) {
|
|
104
|
+
this.start();
|
|
105
|
+
this.sdk('response.completed', {
|
|
106
|
+
stopReason: result.stopReason,
|
|
107
|
+
});
|
|
108
|
+
this.completed = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Close a turn that failed. The bracket a consumer waits on must be honoured
|
|
113
|
+
* even when the turn dies mid-stream, so an open message is closed and the
|
|
114
|
+
* response completes with an error rather than the stream simply stopping.
|
|
115
|
+
*/
|
|
116
|
+
abort(cause) {
|
|
117
|
+
if (!this.broadcaster || this.completed) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.closeMessage();
|
|
121
|
+
this.start();
|
|
122
|
+
this.sdk('response.completed', {
|
|
123
|
+
stopReason: 'error',
|
|
124
|
+
error: cause instanceof Error ? cause.message : String(cause),
|
|
125
|
+
});
|
|
126
|
+
this.completed = true;
|
|
127
|
+
}
|
|
128
|
+
//#region internals
|
|
129
|
+
/**
|
|
130
|
+
* Emit one framework event under this step's envelope. The `sdk` sibling
|
|
131
|
+
* below does the same job for the model-stream surface; both gate on
|
|
132
|
+
* `emitOption` so `emit: false` silences every surface at once.
|
|
133
|
+
*/
|
|
134
|
+
framework(eventType, payload) {
|
|
135
|
+
if (!this.broadcaster) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const data = {
|
|
139
|
+
stepId: this.stepId,
|
|
140
|
+
agentId: this.agentId,
|
|
141
|
+
...payload,
|
|
142
|
+
};
|
|
143
|
+
if (!shouldEmit(this.emitOption, eventType, data)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
emitFrameworkEvent({
|
|
147
|
+
broadcaster: this.broadcaster,
|
|
148
|
+
agentName: this.agentName,
|
|
149
|
+
eventType,
|
|
150
|
+
data,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
sdk(type, data, outputIndex) {
|
|
154
|
+
if (!this.broadcaster) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!shouldEmit(this.emitOption, type, data)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.broadcaster.emit({
|
|
161
|
+
source: 'sdk',
|
|
162
|
+
type,
|
|
163
|
+
data,
|
|
164
|
+
outputIndex,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
start() {
|
|
168
|
+
if (this.started) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.started = true;
|
|
172
|
+
this.sdk('response.created', {});
|
|
173
|
+
}
|
|
174
|
+
openMessage() {
|
|
175
|
+
if (this.messageOutputIndex !== null) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.start();
|
|
179
|
+
const id = `acp-msg-${crypto.randomUUID()}`;
|
|
180
|
+
this.messageOutputIndex = this.nextOutputIndex++;
|
|
181
|
+
this.sdk('response.output_item.added', {
|
|
182
|
+
item: {
|
|
183
|
+
id,
|
|
184
|
+
type: 'message',
|
|
185
|
+
role: 'assistant',
|
|
186
|
+
status: 'in_progress',
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
type: 'output_text',
|
|
190
|
+
text: '',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
}, this.messageOutputIndex);
|
|
195
|
+
}
|
|
196
|
+
closeMessage() {
|
|
197
|
+
if (this.messageOutputIndex === null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const index = this.messageOutputIndex;
|
|
201
|
+
this.sdk('response.output_text.done', {}, index);
|
|
202
|
+
this.sdk('response.output_item.done', {}, index);
|
|
203
|
+
this.messageOutputIndex = null;
|
|
204
|
+
}
|
|
205
|
+
emitToolCall(toolCallId, name, input) {
|
|
206
|
+
this.start();
|
|
207
|
+
const index = this.nextOutputIndex++;
|
|
208
|
+
const args = typeof input === 'string' ? input : JSON.stringify(input ?? {});
|
|
209
|
+
this.sdk('response.output_item.added', {
|
|
210
|
+
item: {
|
|
211
|
+
id: toolCallId,
|
|
212
|
+
type: 'function_call',
|
|
213
|
+
status: 'in_progress',
|
|
214
|
+
callId: toolCallId,
|
|
215
|
+
name,
|
|
216
|
+
arguments: '',
|
|
217
|
+
},
|
|
218
|
+
}, index);
|
|
219
|
+
this.sdk('response.function_call_arguments.delta', {
|
|
220
|
+
delta: args,
|
|
221
|
+
}, index);
|
|
222
|
+
this.sdk('response.function_call_arguments.done', {
|
|
223
|
+
arguments: args,
|
|
224
|
+
}, index);
|
|
225
|
+
this.sdk('response.output_item.done', {}, index);
|
|
226
|
+
this.announcedToolCalls.add(toolCallId);
|
|
227
|
+
}
|
|
228
|
+
translate(update) {
|
|
229
|
+
if (update.sessionUpdate === 'agent_message_chunk') {
|
|
230
|
+
this.openMessage();
|
|
231
|
+
this.sdk('response.output_text.delta', {
|
|
232
|
+
delta: blockText(update.content),
|
|
233
|
+
}, this.messageOutputIndex ?? 0);
|
|
234
|
+
this.sawText = true;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (update.sessionUpdate === 'agent_thought_chunk') {
|
|
238
|
+
this.start();
|
|
239
|
+
this.sdk('response.reasoning.delta', {
|
|
240
|
+
delta: blockText(update.content),
|
|
241
|
+
});
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (update.sessionUpdate === 'tool_call') {
|
|
245
|
+
this.closeMessage();
|
|
246
|
+
this.emitToolCall(update.toolCallId, update.title, update.rawInput);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// `user_message_chunk` (replayed history), `tool_call_update`, `plan`,
|
|
250
|
+
// `available_commands_update`, and `current_mode_update` have no model-stream
|
|
251
|
+
// analogue; they surface on the full stream under their protocol names.
|
|
252
|
+
this.sdk(`acp.${update.sessionUpdate}`, {
|
|
253
|
+
update,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gives an ACP agent the prior conversation.
|
|
3
|
+
*
|
|
4
|
+
* ACP sessions own their own history on the agent side, but a freshly opened
|
|
5
|
+
* session knows nothing about the Noetic steps that ran before it. Seeding the
|
|
6
|
+
* first prompt with a transcript of the conversation so far means a coding agent
|
|
7
|
+
* running after a chain of `callModel` steps understands what was already
|
|
8
|
+
* established instead of answering out of context.
|
|
9
|
+
*/
|
|
10
|
+
import type { Item } from '@noetic-tools/types';
|
|
11
|
+
/** @public Render conversation history as a plain-text transcript. */
|
|
12
|
+
export declare function formatConversation(items: ReadonlyArray<Item>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Fold the conversation so far into a turn's prompt. Returns the prompt
|
|
15
|
+
* unchanged when there is no history, so the very first step of a run is not
|
|
16
|
+
* padded with an empty preamble.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function withHistoryPrompt(input: {
|
|
20
|
+
prompt: string;
|
|
21
|
+
history: ReadonlyArray<Item>;
|
|
22
|
+
}): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gives an ACP agent the prior conversation.
|
|
3
|
+
*
|
|
4
|
+
* ACP sessions own their own history on the agent side, but a freshly opened
|
|
5
|
+
* session knows nothing about the Noetic steps that ran before it. Seeding the
|
|
6
|
+
* first prompt with a transcript of the conversation so far means a coding agent
|
|
7
|
+
* running after a chain of `callModel` steps understands what was already
|
|
8
|
+
* established instead of answering out of context.
|
|
9
|
+
*/
|
|
10
|
+
function roleLabel(role) {
|
|
11
|
+
if (role === 'assistant') {
|
|
12
|
+
return 'Assistant';
|
|
13
|
+
}
|
|
14
|
+
if (role === 'user') {
|
|
15
|
+
return 'User';
|
|
16
|
+
}
|
|
17
|
+
return 'System';
|
|
18
|
+
}
|
|
19
|
+
function messageText(item) {
|
|
20
|
+
if (item.type !== 'message') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const text = item.content
|
|
24
|
+
.map((part) => ('text' in part && typeof part.text === 'string' ? part.text : ''))
|
|
25
|
+
.join('');
|
|
26
|
+
return text.length > 0 ? `${roleLabel(item.role)}: ${text}` : null;
|
|
27
|
+
}
|
|
28
|
+
/** @public Render conversation history as a plain-text transcript. */
|
|
29
|
+
export function formatConversation(items) {
|
|
30
|
+
const lines = [];
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
const line = messageText(item);
|
|
33
|
+
if (line) {
|
|
34
|
+
lines.push(line);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (item.type === 'function_call') {
|
|
38
|
+
lines.push(`Assistant called ${item.name}(${item.arguments})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return lines.join('\n');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fold the conversation so far into a turn's prompt. Returns the prompt
|
|
45
|
+
* unchanged when there is no history, so the very first step of a run is not
|
|
46
|
+
* padded with an empty preamble.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export function withHistoryPrompt(input) {
|
|
50
|
+
if (input.history.length === 0) {
|
|
51
|
+
return input.prompt;
|
|
52
|
+
}
|
|
53
|
+
const transcript = formatConversation(input.history);
|
|
54
|
+
if (transcript.length === 0) {
|
|
55
|
+
return input.prompt;
|
|
56
|
+
}
|
|
57
|
+
return `Conversation so far:\n${transcript}\n\nCurrent request:\n${input.prompt}`;
|
|
58
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { ContextConfig, ContextData, ContextLayer, ExecutionContext, } from '@noetic-tools/context';
|
|
2
|
-
export type { AgentHarnessContract, Context, ContextRerenderRequest, ExecuteStepFn, FunctionCallItem, InputMessageItem, 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';
|