operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +8 -7
- package/dist/agent/compose-hooks.d.ts +10 -1
- package/dist/agent/compose-hooks.js +61 -6
- package/dist/agent/concurrency.js +1 -1
- package/dist/agent/context-report.d.ts +2 -2
- package/dist/agent/durable-state.d.ts +22 -0
- package/dist/agent/durable-state.js +54 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/instruction-context.d.ts +6 -6
- package/dist/agent/instruction-context.js +23 -23
- package/dist/agent/profile-builtins.js +1 -1
- package/dist/agent/run-support.d.ts +1 -1
- package/dist/agent/run-support.js +6 -5
- package/dist/agent/runner.d.ts +25 -22
- package/dist/agent/runner.js +217 -121
- package/dist/agent/session.d.ts +262 -156
- package/dist/agent/session.js +590 -418
- package/dist/agent/subagent-tools.js +3 -3
- package/dist/agent/subagent.js +28 -13
- package/dist/agent/toolset.d.ts +1 -0
- package/dist/agent/toolset.js +13 -7
- package/dist/agent/workflow/journal.d.ts +2 -2
- package/dist/agent/workflow/journal.js +2 -2
- package/dist/agent/workflow/manager.d.ts +1 -1
- package/dist/agent/workflow/manager.js +1 -1
- package/dist/agent/workflow/prompt.js +2 -2
- package/dist/agent/workflow/sandbox.d.ts +1 -1
- package/dist/agent/workflow/sandbox.js +1 -1
- package/dist/agent/workflow/tool.js +30 -43
- package/dist/agent/worktree.d.ts +8 -8
- package/dist/agent/worktree.js +15 -15
- package/dist/capabilities/assembler.d.ts +29 -5
- package/dist/capabilities/assembler.js +85 -9
- package/dist/capabilities/background/code-task.d.ts +43 -0
- package/dist/capabilities/background/code-task.js +75 -0
- package/dist/capabilities/background/command-task.d.ts +9 -2
- package/dist/capabilities/background/command-task.js +22 -6
- package/dist/capabilities/background/index.d.ts +6 -1
- package/dist/capabilities/background/index.js +26 -20
- package/dist/capabilities/background/manager.d.ts +57 -1
- package/dist/capabilities/background/manager.js +210 -45
- package/dist/capabilities/background/persist-disk.d.ts +1 -1
- package/dist/capabilities/background/persist-disk.js +1 -1
- package/dist/capabilities/background/persist.js +4 -2
- package/dist/capabilities/background/projections.d.ts +16 -0
- package/dist/capabilities/background/projections.js +86 -0
- package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
- package/dist/capabilities/background/stall-watchdog.js +85 -0
- package/dist/capabilities/background/task.d.ts +8 -7
- package/dist/capabilities/background/tools.js +33 -7
- package/dist/capabilities/capability-data.d.ts +52 -0
- package/dist/capabilities/capability-data.js +88 -0
- package/dist/capabilities/capability-state.d.ts +2 -4
- package/dist/capabilities/capability-state.js +5 -23
- package/dist/capabilities/capability.d.ts +203 -38
- package/dist/capabilities/compaction/index.js +10 -4
- package/dist/capabilities/compaction/service.d.ts +20 -5
- package/dist/capabilities/compaction/service.js +27 -11
- package/dist/capabilities/goal/goal-store.d.ts +76 -12
- package/dist/capabilities/goal/goal-store.js +137 -53
- package/dist/capabilities/goal/index.d.ts +1 -1
- package/dist/capabilities/goal/index.js +30 -7
- package/dist/capabilities/index.d.ts +9 -6
- package/dist/capabilities/index.js +4 -3
- package/dist/capabilities/plan/index.js +22 -5
- package/dist/capabilities/plan/plan-mode.d.ts +30 -9
- package/dist/capabilities/plan/plan-mode.js +57 -32
- package/dist/capabilities/plan/tools.js +1 -1
- package/dist/capabilities/skills/flow-provider.js +3 -3
- package/dist/capabilities/skills/index.d.ts +13 -1
- package/dist/capabilities/skills/index.js +30 -21
- package/dist/capabilities/skills/parser.d.ts +2 -2
- package/dist/capabilities/skills/parser.js +3 -3
- package/dist/capabilities/skills/registry.d.ts +5 -6
- package/dist/capabilities/skills/registry.js +6 -9
- package/dist/capabilities/skills/scanner.d.ts +3 -3
- package/dist/capabilities/skills/scanner.js +14 -14
- package/dist/capabilities/skills/service.d.ts +2 -1
- package/dist/capabilities/skills/service.js +3 -3
- package/dist/capabilities/skills/skill-tool.d.ts +2 -0
- package/dist/capabilities/skills/skill-tool.js +1 -1
- package/dist/capabilities/task/index.js +2 -1
- package/dist/capabilities/task/persist-disk.d.ts +1 -1
- package/dist/capabilities/task/persist-disk.js +1 -1
- package/dist/capabilities/task/persist.js +1 -1
- package/dist/capabilities/todo/index.js +11 -6
- package/dist/capabilities/todo/injector.js +2 -1
- package/dist/capabilities/todo/todo-store.d.ts +28 -7
- package/dist/capabilities/todo/todo-store.js +44 -11
- package/dist/capabilities/todo/tools.js +8 -3
- package/dist/capabilities/tool-provider.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.js +7 -7
- package/dist/capabilities/user-hooks/index.js +2 -1
- package/dist/capabilities/workflow/index.d.ts +5 -3
- package/dist/capabilities/workflow/index.js +3 -2
- package/dist/commands/index.js +34 -32
- package/dist/config/index.d.ts +1 -1
- package/dist/config/provider-manager.js +0 -28
- package/dist/config/schema.d.ts +53 -4
- package/dist/config/schema.js +53 -1
- package/dist/events/events.d.ts +43 -11
- package/dist/events/events.js +1 -0
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/projection.d.ts +49 -1
- package/dist/events/projection.js +144 -19
- package/dist/events/publisher.js +2 -21
- package/dist/home.d.ts +1 -1
- package/dist/home.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.js +5 -2
- package/dist/llm/define-model.d.ts +4 -0
- package/dist/llm/define-model.js +63 -25
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/model.d.ts +2 -0
- package/dist/llm/provider.d.ts +17 -0
- package/dist/llm/provider.js +14 -0
- package/dist/llm/retry.js +1 -1
- package/dist/loop/context.d.ts +21 -1
- package/dist/loop/context.js +47 -9
- package/dist/loop/events.d.ts +5 -1
- package/dist/loop/index.d.ts +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/interruption.d.ts +9 -4
- package/dist/loop/interruption.js +11 -25
- package/dist/loop/run-turn.d.ts +16 -3
- package/dist/loop/run-turn.js +13 -4
- package/dist/loop/steer.d.ts +78 -12
- package/dist/loop/steer.js +101 -38
- package/dist/loop/tool-call.d.ts +13 -2
- package/dist/loop/tool-call.js +135 -5
- package/dist/loop/turn-step.d.ts +13 -2
- package/dist/loop/turn-step.js +29 -7
- package/dist/loop/types.d.ts +6 -0
- package/dist/mcp/auth-tool.d.ts +3 -1
- package/dist/mcp/auth-tool.js +2 -2
- package/dist/mcp/capability.d.ts +13 -0
- package/dist/mcp/capability.js +36 -17
- package/dist/mcp/config-loader.d.ts +5 -5
- package/dist/mcp/config-loader.js +17 -17
- package/dist/mcp/credentials.d.ts +35 -0
- package/dist/mcp/credentials.js +2 -0
- package/dist/mcp/filter.d.ts +2 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +108 -6
- package/dist/mcp/manager.js +262 -18
- package/dist/mcp/oauth/callback-server.d.ts +10 -1
- package/dist/mcp/oauth/callback-server.js +82 -16
- package/dist/mcp/oauth/index.d.ts +2 -2
- package/dist/mcp/oauth/provider.d.ts +18 -0
- package/dist/mcp/oauth/provider.js +31 -1
- package/dist/mcp/oauth/service.d.ts +9 -3
- package/dist/mcp/oauth/service.js +29 -4
- package/dist/mcp/sdk-transport.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
- package/dist/permission/auto-approver/prompts-data.js +1 -1
- package/dist/permission/manager.d.ts +5 -3
- package/dist/permission/manager.js +7 -3
- package/dist/permission/policies.d.ts +2 -2
- package/dist/permission/policies.js +4 -4
- package/dist/plugins/fields.d.ts +14 -0
- package/dist/plugins/fields.js +30 -0
- package/dist/plugins/hooks.d.ts +2 -2
- package/dist/plugins/hooks.js +12 -12
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/manager.d.ts +8 -3
- package/dist/plugins/manager.js +18 -7
- package/dist/plugins/manifest.d.ts +2 -2
- package/dist/plugins/manifest.js +101 -91
- package/dist/plugins/marketplace.js +76 -57
- package/dist/plugins/store.d.ts +3 -3
- package/dist/plugins/store.js +6 -6
- package/dist/protocol/index.d.ts +1 -1
- package/dist/store/catalog-store.d.ts +4 -1
- package/dist/store/catalog-store.js +5 -1
- package/dist/store/checkpointing-store.d.ts +41 -0
- package/dist/store/checkpointing-store.js +86 -0
- package/dist/store/disk-store.d.ts +8 -0
- package/dist/store/disk-store.js +127 -5
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +2 -1
- package/dist/store/log-store.d.ts +9 -1
- package/dist/store/log-store.js +68 -4
- package/dist/store/migrate.d.ts +8 -2
- package/dist/store/migrate.js +9 -2
- package/dist/store/origin.d.ts +31 -6
- package/dist/store/origin.js +0 -14
- package/dist/store/pg.d.ts +1 -0
- package/dist/store/pg.js +37 -2
- package/dist/store/redis.d.ts +1 -0
- package/dist/store/redis.js +30 -0
- package/dist/store/repository.d.ts +13 -1
- package/dist/store/repository.js +45 -2
- package/dist/store/session-catalog.d.ts +4 -0
- package/dist/store/session-catalog.js +6 -0
- package/dist/store/storage.js +3 -0
- package/dist/store/store.d.ts +97 -34
- package/dist/store/store.js +64 -10
- package/dist/telemetry/appender.d.ts +43 -0
- package/dist/telemetry/appender.js +46 -0
- package/dist/telemetry/events.d.ts +142 -0
- package/dist/telemetry/events.js +141 -0
- package/dist/telemetry/index.d.ts +10 -0
- package/dist/telemetry/index.js +6 -0
- package/dist/telemetry/projection.d.ts +23 -0
- package/dist/telemetry/projection.js +185 -0
- package/dist/telemetry/redact.d.ts +20 -0
- package/dist/telemetry/redact.js +40 -0
- package/dist/telemetry/service.d.ts +49 -0
- package/dist/telemetry/service.js +137 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +123 -0
- package/dist/tool/background.d.ts +9 -6
- package/dist/tool/background.js +7 -1
- package/dist/tool/builtin/ask-user-question.js +6 -5
- package/dist/tool/builtin/bash.d.ts +6 -0
- package/dist/tool/builtin/bash.js +79 -42
- package/dist/tool/builtin/edit.js +82 -109
- package/dist/tool/builtin/glob.js +13 -13
- package/dist/tool/builtin/grep.js +13 -13
- package/dist/tool/builtin/read.js +25 -15
- package/dist/tool/builtin/write.js +49 -33
- package/dist/tool/define.d.ts +14 -8
- package/dist/tool/define.js +8 -2
- package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
- package/dist/tool/{machine-base.js → environment-base.js} +45 -119
- package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
- package/dist/tool/{machine-local.js → environment-local.js} +60 -81
- package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
- package/dist/tool/{machine-null.js → environment-null.js} +9 -9
- package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
- package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
- package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
- package/dist/tool/environment.js +2 -0
- package/dist/tool/file-freshness.d.ts +33 -19
- package/dist/tool/file-freshness.js +39 -30
- package/dist/tool/filesystem-tools.d.ts +1 -1
- package/dist/tool/filesystem-tools.js +1 -1
- package/dist/tool/git-context.d.ts +2 -2
- package/dist/tool/git-context.js +8 -8
- package/dist/tool/index.d.ts +12 -12
- package/dist/tool/index.js +12 -10
- package/dist/tool/policies/path-access.d.ts +4 -4
- package/dist/tool/policies/path-access.js +12 -12
- package/dist/tool/questions.d.ts +8 -0
- package/dist/tool/search/catalog.d.ts +37 -0
- package/dist/tool/search/catalog.js +182 -0
- package/dist/tool/search/deferral.d.ts +3 -2
- package/dist/tool/search/loaded.d.ts +32 -0
- package/dist/tool/search/loaded.js +96 -0
- package/dist/tool/search/search-tool.d.ts +2 -6
- package/dist/tool/search/search-tool.js +16 -15
- package/dist/tool/shell-env.js +4 -0
- package/dist/tool/support/bash-paths.js +38 -7
- package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
- package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
- package/dist/tool/support/git-worktree.d.ts +3 -3
- package/dist/tool/support/git-worktree.js +6 -6
- package/dist/tool/support/rg-locator.d.ts +6 -6
- package/dist/tool/support/rg-locator.js +6 -6
- package/dist/tool/support/ripgrep-run.d.ts +5 -5
- package/dist/tool/support/ripgrep-run.js +3 -3
- package/dist/tool/support/tool-path.d.ts +3 -3
- package/dist/tool/support/tool-path.js +7 -7
- package/dist/tool/types.d.ts +54 -10
- package/dist/tool/web/fetch-url.js +1 -1
- package/dist/tool/web/web-search.js +1 -1
- package/dist/tool/workspace-spec.d.ts +3 -3
- package/dist/tool/workspace-spec.js +27 -27
- package/dist/tracing/bridge.d.ts +9 -1
- package/dist/tracing/bridge.js +307 -77
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/otel.d.ts +28 -1
- package/dist/tracing/otel.js +150 -38
- package/dist/tracing/processor.d.ts +22 -0
- package/dist/tracing/processor.js +2 -0
- package/dist/tracing/spans.d.ts +54 -0
- package/dist/tracing/spans.js +5 -0
- package/package.json +6 -2
- package/dist/tool/machine.js +0 -15
- package/dist/tool/search/activation.d.ts +0 -13
- package/dist/tool/search/activation.js +0 -31
package/dist/tracing/otel.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ROOT_CONTEXT, SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
|
|
2
|
+
import { redactDeep } from "../logging/redact.js";
|
|
3
|
+
const DEFAULT_CONTENT_MAX_CHARS = 32_000;
|
|
2
4
|
export class OTelTracingProcessor {
|
|
3
5
|
tracer;
|
|
4
6
|
tracerProvider;
|
|
@@ -6,15 +8,21 @@ export class OTelTracingProcessor {
|
|
|
6
8
|
includeFrameworkIds;
|
|
7
9
|
recordException;
|
|
8
10
|
shutdownProvider;
|
|
11
|
+
content;
|
|
12
|
+
contentMaxChars;
|
|
13
|
+
redactOptions;
|
|
9
14
|
activeTraces = new Map();
|
|
10
15
|
activeSpans = new Map();
|
|
11
16
|
constructor(options = {}) {
|
|
12
|
-
this.tracer = options.tracer ?? trace.getTracer(options.tracerName ?? "
|
|
17
|
+
this.tracer = options.tracer ?? trace.getTracer(options.tracerName ?? "operon-agents", options.tracerVersion);
|
|
13
18
|
this.tracerProvider = options.tracerProvider;
|
|
14
19
|
this.providerName = options.providerName;
|
|
15
20
|
this.includeFrameworkIds = options.includeFrameworkIds ?? true;
|
|
16
21
|
this.recordException = options.recordException ?? true;
|
|
17
22
|
this.shutdownProvider = options.shutdownProvider ?? false;
|
|
23
|
+
this.content = options.content ?? "none";
|
|
24
|
+
this.contentMaxChars = options.contentMaxChars ?? DEFAULT_CONTENT_MAX_CHARS;
|
|
25
|
+
this.redactOptions = options.redact === undefined || options.redact === false ? undefined : options.redact === true ? {} : options.redact;
|
|
18
26
|
}
|
|
19
27
|
onTraceStart(traceRecord) {
|
|
20
28
|
this.activeTraces.set(traceRecord.traceId, {
|
|
@@ -48,6 +56,9 @@ export class OTelTracingProcessor {
|
|
|
48
56
|
const traceRecord = this.activeTraces.get(span.traceId);
|
|
49
57
|
active.span.setAttributes(this.attributesFor(span, traceRecord, "end"));
|
|
50
58
|
active.span.updateName(this.nameFor(span.data));
|
|
59
|
+
for (const event of span.events) {
|
|
60
|
+
active.span.addEvent(event.name, event.data === undefined ? undefined : this.primitiveAttributes("", event.data), event.timestamp);
|
|
61
|
+
}
|
|
51
62
|
if (span.error !== null) {
|
|
52
63
|
active.span.setStatus({ code: SpanStatusCode.ERROR, message: span.error.message });
|
|
53
64
|
active.span.setAttribute("error.type", span.error.data?.type === undefined ? "Error" : String(span.error.data.type));
|
|
@@ -86,21 +97,22 @@ export class OTelTracingProcessor {
|
|
|
86
97
|
return {
|
|
87
98
|
...(this.includeFrameworkIds
|
|
88
99
|
? {
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
...(span.parentId === null ? {} : { "
|
|
100
|
+
"operon_agents.trace_id": span.traceId,
|
|
101
|
+
"operon_agents.span_id": span.spanId,
|
|
102
|
+
...(span.parentId === null ? {} : { "operon_agents.parent_id": span.parentId }),
|
|
92
103
|
}
|
|
93
104
|
: {}),
|
|
94
105
|
...(traceRecord === undefined
|
|
95
106
|
? {}
|
|
96
107
|
: {
|
|
97
|
-
"
|
|
108
|
+
"operon_agents.trace.name": traceRecord.name,
|
|
98
109
|
...(traceRecord.groupId === null ? {} : { "gen_ai.conversation.id": traceRecord.groupId }),
|
|
99
|
-
...
|
|
110
|
+
...this.primitiveAttributes("operon_agents.trace.metadata", traceRecord.metadata),
|
|
100
111
|
}),
|
|
101
|
-
"
|
|
102
|
-
"
|
|
112
|
+
"operon_agents.span.type": span.data.type,
|
|
113
|
+
"operon_agents.span.phase": phase,
|
|
103
114
|
...this.genAiAttributes(span.data),
|
|
115
|
+
...(this.content === "none" ? {} : this.contentAttributes(span.data)),
|
|
104
116
|
};
|
|
105
117
|
}
|
|
106
118
|
genAiAttributes(data) {
|
|
@@ -111,13 +123,15 @@ export class OTelTracingProcessor {
|
|
|
111
123
|
...provider,
|
|
112
124
|
"gen_ai.operation.name": "invoke_agent",
|
|
113
125
|
"gen_ai.agent.name": data.name,
|
|
114
|
-
...(data.handoffs === undefined ? {} : { "
|
|
115
|
-
...(data.tools === undefined ? {} : { "
|
|
126
|
+
...(data.handoffs === undefined ? {} : { "operon_agents.agent.handoffs": [...data.handoffs] }),
|
|
127
|
+
...(data.tools === undefined ? {} : { "operon_agents.agent.tools": [...data.tools] }),
|
|
128
|
+
...(data.prompt === undefined ? {} : { "operon_agents.agent.prompt": data.prompt }),
|
|
116
129
|
};
|
|
117
130
|
case "turn":
|
|
118
131
|
return {
|
|
119
132
|
...provider,
|
|
120
|
-
"
|
|
133
|
+
"operon_agents.turn.id": data.turnId,
|
|
134
|
+
...(data.reason === undefined ? {} : { "operon_agents.turn.reason": data.reason }),
|
|
121
135
|
};
|
|
122
136
|
case "generation":
|
|
123
137
|
return {
|
|
@@ -134,51 +148,120 @@ export class OTelTracingProcessor {
|
|
|
134
148
|
? {}
|
|
135
149
|
: {
|
|
136
150
|
"gen_ai.response.finish_reasons": [data.stopReason],
|
|
137
|
-
"
|
|
151
|
+
"operon_agents.generation.stop_reason": data.stopReason,
|
|
138
152
|
}),
|
|
139
153
|
...(data.usage?.input_tokens === undefined ? {} : { "gen_ai.usage.input_tokens": data.usage.input_tokens }),
|
|
140
154
|
...(data.usage?.output_tokens === undefined ? {} : { "gen_ai.usage.output_tokens": data.usage.output_tokens }),
|
|
141
|
-
...(data.usage?.total_tokens === undefined ? {} : { "
|
|
155
|
+
...(data.usage?.total_tokens === undefined ? {} : { "operon_agents.usage.total_tokens": data.usage.total_tokens }),
|
|
156
|
+
...(data.usage?.cache_read_tokens === undefined ? {} : { "gen_ai.usage.cache_read.input_tokens": data.usage.cache_read_tokens }),
|
|
157
|
+
...(data.usage?.cache_write_tokens === undefined ? {} : { "gen_ai.usage.cache_creation.input_tokens": data.usage.cache_write_tokens }),
|
|
158
|
+
...(data.usage?.reasoning_tokens === undefined ? {} : { "operon_agents.usage.reasoning_tokens": data.usage.reasoning_tokens }),
|
|
159
|
+
...(data.usage?.cost_usd === undefined ? {} : { "operon_agents.usage.cost_usd": data.usage.cost_usd }),
|
|
160
|
+
...(data.toolNames === undefined ? {} : { "operon_agents.generation.tools": [...data.toolNames] }),
|
|
161
|
+
...(data.params?.temperature === undefined ? {} : { "gen_ai.request.temperature": data.params.temperature }),
|
|
162
|
+
...(data.params?.maxTokens === undefined ? {} : { "gen_ai.request.max_tokens": data.params.maxTokens }),
|
|
163
|
+
...(data.params?.thinking === undefined ? {} : { "operon_agents.generation.thinking": String(data.params.thinking) }),
|
|
142
164
|
};
|
|
143
165
|
case "tool":
|
|
144
166
|
return {
|
|
145
167
|
...provider,
|
|
146
168
|
"gen_ai.operation.name": "execute_tool",
|
|
147
169
|
"gen_ai.tool.name": data.name,
|
|
148
|
-
"
|
|
149
|
-
...(data.isError === undefined ? {} : { "
|
|
170
|
+
"operon_agents.tool.call_id": data.toolCallId,
|
|
171
|
+
...(data.isError === undefined ? {} : { "operon_agents.tool.is_error": data.isError }),
|
|
172
|
+
};
|
|
173
|
+
case "message":
|
|
174
|
+
return {
|
|
175
|
+
...provider,
|
|
176
|
+
"operon_agents.message.role": data.role,
|
|
177
|
+
...(data.origin === undefined ? {} : { "operon_agents.message.origin": data.origin }),
|
|
150
178
|
};
|
|
151
179
|
case "handoff":
|
|
152
180
|
return {
|
|
153
181
|
...provider,
|
|
154
182
|
"gen_ai.operation.name": "invoke_agent",
|
|
155
|
-
...(data.from === undefined ? {} : { "
|
|
156
|
-
...(data.to === undefined ? {} : { "
|
|
183
|
+
...(data.from === undefined ? {} : { "operon_agents.handoff.from": data.from }),
|
|
184
|
+
...(data.to === undefined ? {} : { "operon_agents.handoff.to": data.to }),
|
|
157
185
|
};
|
|
158
186
|
case "compaction":
|
|
159
187
|
return {
|
|
160
|
-
"
|
|
161
|
-
...(data.tokensBefore === undefined ? {} : { "
|
|
162
|
-
...(data.tokensAfter === undefined ? {} : { "
|
|
163
|
-
...(data.compactedCount === undefined ? {} : { "
|
|
188
|
+
"operon_agents.compaction.trigger": data.trigger ?? "unknown",
|
|
189
|
+
...(data.tokensBefore === undefined ? {} : { "operon_agents.compaction.tokens_before": data.tokensBefore }),
|
|
190
|
+
...(data.tokensAfter === undefined ? {} : { "operon_agents.compaction.tokens_after": data.tokensAfter }),
|
|
191
|
+
...(data.compactedCount === undefined ? {} : { "operon_agents.compaction.compacted_count": data.compactedCount }),
|
|
164
192
|
};
|
|
165
193
|
case "custom":
|
|
166
194
|
return {
|
|
167
|
-
"
|
|
168
|
-
...
|
|
195
|
+
"operon_agents.custom.name": data.name,
|
|
196
|
+
...this.primitiveAttributes("operon_agents.custom.data", data.data),
|
|
169
197
|
};
|
|
170
198
|
}
|
|
171
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Content attributes, named after the OTel GenAI semantic conventions where one exists
|
|
202
|
+
* (`gen_ai.system_instructions`, `gen_ai.input.messages`, `gen_ai.output.messages`,
|
|
203
|
+
* `gen_ai.tool.call.arguments` / `.result`). Values are JSON strings, capped at
|
|
204
|
+
* `contentMaxChars`; images are reduced to `{ type, mimeType, bytes }`.
|
|
205
|
+
*/
|
|
206
|
+
contentAttributes(data) {
|
|
207
|
+
switch (data.type) {
|
|
208
|
+
case "generation":
|
|
209
|
+
return {
|
|
210
|
+
...(data.system === undefined ? {} : { "gen_ai.system_instructions": this.text(data.system) }),
|
|
211
|
+
...(data.input === undefined ? {} : { "gen_ai.input.messages": this.json(data.input.map(serializeMessage)) }),
|
|
212
|
+
...(data.inputMode === undefined ? {} : { "operon_agents.generation.input_mode": data.inputMode }),
|
|
213
|
+
...(data.output === undefined ? {} : { "gen_ai.output.messages": this.json(data.output.map(serializePart)) }),
|
|
214
|
+
};
|
|
215
|
+
case "tool":
|
|
216
|
+
return {
|
|
217
|
+
...(data.args === undefined ? {} : { "gen_ai.tool.call.arguments": this.json(data.args) }),
|
|
218
|
+
...(data.result === undefined ? {} : { "gen_ai.tool.call.result": this.json(serializeToolResult(data.result)) }),
|
|
219
|
+
};
|
|
220
|
+
case "message":
|
|
221
|
+
return data.content === undefined
|
|
222
|
+
? {}
|
|
223
|
+
: { "operon_agents.message.content": this.json(typeof data.content === "string" ? data.content : data.content.map(serializePart)) };
|
|
224
|
+
default:
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
text(value) {
|
|
229
|
+
const redacted = this.redactOptions === undefined ? value : String(redactDeep(value, this.redactOptions));
|
|
230
|
+
return truncate(redacted, this.contentMaxChars);
|
|
231
|
+
}
|
|
232
|
+
json(value) {
|
|
233
|
+
const redacted = this.redactOptions === undefined ? value : redactDeep(value, this.redactOptions);
|
|
234
|
+
let serialized;
|
|
235
|
+
try {
|
|
236
|
+
serialized = typeof redacted === "string" ? redacted : JSON.stringify(redacted);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
serialized = String(redacted);
|
|
240
|
+
}
|
|
241
|
+
return truncate(serialized ?? "null", this.contentMaxChars);
|
|
242
|
+
}
|
|
243
|
+
primitiveAttributes(prefix, data) {
|
|
244
|
+
if (data === undefined)
|
|
245
|
+
return {};
|
|
246
|
+
const attributes = {};
|
|
247
|
+
for (const [key, value] of Object.entries(data)) {
|
|
248
|
+
if (isAttributeValue(value))
|
|
249
|
+
attributes[prefix === "" ? key : `${prefix}.${key}`] = value;
|
|
250
|
+
}
|
|
251
|
+
return attributes;
|
|
252
|
+
}
|
|
172
253
|
nameFor(data) {
|
|
173
254
|
switch (data.type) {
|
|
174
255
|
case "agent":
|
|
175
|
-
return `agent ${data.name}`;
|
|
256
|
+
return data.prompt === undefined ? `agent ${data.name}` : `agent ${data.name}: ${data.prompt}`;
|
|
176
257
|
case "turn":
|
|
177
258
|
return `turn ${data.turnId}`;
|
|
178
259
|
case "generation":
|
|
179
260
|
return data.model === undefined ? "gen_ai chat" : `gen_ai chat ${data.model}`;
|
|
180
261
|
case "tool":
|
|
181
262
|
return `tool ${data.name}`;
|
|
263
|
+
case "message":
|
|
264
|
+
return `${data.role} message`;
|
|
182
265
|
case "handoff":
|
|
183
266
|
return data.to === undefined ? "handoff" : `handoff ${data.to}`;
|
|
184
267
|
case "compaction":
|
|
@@ -188,23 +271,52 @@ export class OTelTracingProcessor {
|
|
|
188
271
|
}
|
|
189
272
|
}
|
|
190
273
|
}
|
|
191
|
-
function
|
|
192
|
-
if (
|
|
193
|
-
return
|
|
194
|
-
return
|
|
274
|
+
function truncate(value, maxChars) {
|
|
275
|
+
if (value.length <= maxChars)
|
|
276
|
+
return value;
|
|
277
|
+
return `${value.slice(0, maxChars)}…[truncated ${value.length - maxChars} chars]`;
|
|
195
278
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
279
|
+
function serializePart(part) {
|
|
280
|
+
switch (part.type) {
|
|
281
|
+
case "text":
|
|
282
|
+
return { type: "text", text: part.text };
|
|
283
|
+
case "thinking":
|
|
284
|
+
return { type: "thinking", thinking: part.thinking, ...(part.redacted === true ? { redacted: true } : {}) };
|
|
285
|
+
case "toolCall":
|
|
286
|
+
return { type: "toolCall", id: part.id, name: part.name, arguments: part.arguments };
|
|
287
|
+
case "image":
|
|
288
|
+
return { type: "image", mimeType: part.mimeType, bytes: Math.floor((part.data.length * 3) / 4) };
|
|
289
|
+
}
|
|
200
290
|
}
|
|
201
|
-
function
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
291
|
+
function serializeMessage(message) {
|
|
292
|
+
switch (message.role) {
|
|
293
|
+
case "user":
|
|
294
|
+
return { role: "user", content: typeof message.content === "string" ? message.content : message.content.map(serializePart) };
|
|
295
|
+
case "assistant":
|
|
296
|
+
return {
|
|
297
|
+
role: "assistant",
|
|
298
|
+
model: message.model,
|
|
299
|
+
content: message.content.map(serializePart),
|
|
300
|
+
...(message.stopReason === undefined ? {} : { stopReason: message.stopReason }),
|
|
301
|
+
};
|
|
302
|
+
case "toolResult":
|
|
303
|
+
return {
|
|
304
|
+
role: "toolResult",
|
|
305
|
+
toolCallId: message.toolCallId,
|
|
306
|
+
toolName: message.toolName,
|
|
307
|
+
isError: message.isError,
|
|
308
|
+
content: message.content.map(serializePart),
|
|
309
|
+
};
|
|
310
|
+
case "system":
|
|
311
|
+
return { role: "system", content: typeof message.content === "string" ? message.content : message.content.map(serializePart) };
|
|
206
312
|
}
|
|
207
|
-
|
|
313
|
+
}
|
|
314
|
+
function serializeToolResult(result) {
|
|
315
|
+
return {
|
|
316
|
+
content: result.content.map(serializePart),
|
|
317
|
+
...(result.isError === undefined ? {} : { isError: result.isError }),
|
|
318
|
+
...(result.details === undefined ? {} : { details: result.details }),
|
|
319
|
+
};
|
|
208
320
|
}
|
|
209
321
|
function isAttributeValue(value) {
|
|
210
322
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { type RedactOptions } from "../logging/redact.ts";
|
|
2
2
|
import type { Span, SpanRecord, Trace, TraceRecord } from "./spans.ts";
|
|
3
3
|
export type TraceOrSpan = Trace | Span;
|
|
4
|
+
/**
|
|
5
|
+
* How much conversation CONTENT the bridge attaches to spans, on top of names / timings / usage.
|
|
6
|
+
*
|
|
7
|
+
* - `"none"` (default): metadata only — the span tree, model ids, token counts, tool names,
|
|
8
|
+
* error flags. Safe to ship anywhere.
|
|
9
|
+
* - `"delta"`: plus the system prompt, tool list, model params, the request messages the model
|
|
10
|
+
* had not yet answered (everything after the previous assistant message: the new user prompt
|
|
11
|
+
* on step 1, the tool results on later steps), the model's output parts, tool call args and
|
|
12
|
+
* results, and user-message spans. Enough to replay a conversation in a trace viewer without
|
|
13
|
+
* repeating the whole context on every step.
|
|
14
|
+
* - `"full"`: like `delta`, but every generation carries the ENTIRE request context. Trace size
|
|
15
|
+
* grows with steps × context length; for local debugging of prompt assembly only.
|
|
16
|
+
*
|
|
17
|
+
* Content is attached by REFERENCE on `SpanData`; it is the exporter's job to serialize and cap
|
|
18
|
+
* it (`OTelTracingProcessor` does, `contentMaxChars`).
|
|
19
|
+
*/
|
|
20
|
+
export type TracingContentMode = "none" | "delta" | "full";
|
|
4
21
|
export interface TracingProcessor {
|
|
5
22
|
onTraceStart(trace: Trace): void | Promise<void>;
|
|
6
23
|
onTraceEnd(trace: Trace): void | Promise<void>;
|
|
@@ -8,6 +25,8 @@ export interface TracingProcessor {
|
|
|
8
25
|
onSpanEnd(span: Span): void | Promise<void>;
|
|
9
26
|
forceFlush(): Promise<void>;
|
|
10
27
|
shutdown(): Promise<void>;
|
|
28
|
+
/** Read by `eventSinkTracingBridge` when the caller passes no explicit mode. Absent = `"none"`. */
|
|
29
|
+
readonly content?: TracingContentMode;
|
|
11
30
|
}
|
|
12
31
|
export interface TracingExporter {
|
|
13
32
|
export(items: readonly (TraceRecord | SpanRecord)[]): void | Promise<void>;
|
|
@@ -22,6 +41,8 @@ export interface BatchTracingProcessorOptions {
|
|
|
22
41
|
readonly maxBatchSize?: number;
|
|
23
42
|
readonly scheduleDelayMs?: number;
|
|
24
43
|
readonly redact?: boolean | RedactOptions;
|
|
44
|
+
/** Content mode the bridge should use for this processor (see `TracingContentMode`). */
|
|
45
|
+
readonly content?: TracingContentMode;
|
|
25
46
|
}
|
|
26
47
|
export declare class BatchTracingProcessor implements TracingProcessor {
|
|
27
48
|
private readonly exporter;
|
|
@@ -29,6 +50,7 @@ export declare class BatchTracingProcessor implements TracingProcessor {
|
|
|
29
50
|
private readonly maxBatchSize;
|
|
30
51
|
private readonly scheduleDelayMs;
|
|
31
52
|
private readonly redactOptions;
|
|
53
|
+
readonly content: TracingContentMode;
|
|
32
54
|
private buffer;
|
|
33
55
|
private timer;
|
|
34
56
|
private droppedCount;
|
|
@@ -23,6 +23,7 @@ export class BatchTracingProcessor {
|
|
|
23
23
|
maxBatchSize;
|
|
24
24
|
scheduleDelayMs;
|
|
25
25
|
redactOptions;
|
|
26
|
+
content;
|
|
26
27
|
buffer = [];
|
|
27
28
|
timer;
|
|
28
29
|
droppedCount = 0;
|
|
@@ -32,6 +33,7 @@ export class BatchTracingProcessor {
|
|
|
32
33
|
this.maxBatchSize = options.maxBatchSize ?? 100;
|
|
33
34
|
this.scheduleDelayMs = options.scheduleDelayMs ?? 5000;
|
|
34
35
|
this.redactOptions = options.redact === false ? undefined : typeof options.redact === "object" ? options.redact : {};
|
|
36
|
+
this.content = options.content ?? "none";
|
|
35
37
|
if (this.scheduleDelayMs > 0) {
|
|
36
38
|
this.timer = setInterval(() => void this.forceFlush().catch(() => { }), this.scheduleDelayMs);
|
|
37
39
|
this.timer.unref?.();
|
package/dist/tracing/spans.d.ts
CHANGED
|
@@ -1,27 +1,72 @@
|
|
|
1
|
+
import type { ImageContent, Message, TextContent, ThinkingContent, ToolCall } from "../protocol/index.ts";
|
|
2
|
+
import type { ModelSettings } from "../llm/model.ts";
|
|
3
|
+
import type { ToolResult } from "../tool/types.ts";
|
|
1
4
|
export interface GenerationUsage {
|
|
2
5
|
readonly input_tokens?: number;
|
|
3
6
|
readonly output_tokens?: number;
|
|
4
7
|
readonly total_tokens?: number;
|
|
8
|
+
readonly cache_read_tokens?: number;
|
|
9
|
+
readonly cache_write_tokens?: number;
|
|
10
|
+
readonly reasoning_tokens?: number;
|
|
11
|
+
readonly cost_usd?: number;
|
|
5
12
|
}
|
|
13
|
+
/** Which request messages a generation span carries (see `TracingContentMode`). */
|
|
14
|
+
export type GenerationInputMode = "delta" | "full";
|
|
15
|
+
/**
|
|
16
|
+
* The content parts a generation produced. Same shape as `AssistantMessage.content` — text,
|
|
17
|
+
* thinking and tool calls, in model order.
|
|
18
|
+
*/
|
|
19
|
+
export type GenerationOutputPart = TextContent | ThinkingContent | ToolCall;
|
|
20
|
+
/**
|
|
21
|
+
* Span payloads. The `type` discriminates; everything else is what the exporter needs to name,
|
|
22
|
+
* measure and (with content enabled) replay the span. Content fields (`system`, `input`,
|
|
23
|
+
* `output`, `args`, `result`, `content`) hold RAW references — the bridge attaches them only
|
|
24
|
+
* when the processor opts in via `content`, and exporters serialize/cap them on the way out.
|
|
25
|
+
*/
|
|
6
26
|
export type SpanData = {
|
|
7
27
|
readonly type: "agent";
|
|
8
28
|
readonly name: string;
|
|
9
29
|
readonly handoffs?: readonly string[];
|
|
10
30
|
readonly tools?: readonly string[];
|
|
31
|
+
/** First user prompt of the run, trimmed to a line — names the root span in a trace list (content only). */
|
|
32
|
+
readonly prompt?: string;
|
|
11
33
|
} | {
|
|
12
34
|
readonly type: "turn";
|
|
13
35
|
readonly turnId: string;
|
|
36
|
+
/** From `turn.ended`. */
|
|
37
|
+
readonly reason?: string;
|
|
38
|
+
readonly error?: string;
|
|
14
39
|
} | {
|
|
15
40
|
readonly type: "generation";
|
|
16
41
|
readonly model?: string;
|
|
17
42
|
readonly responseId?: string;
|
|
18
43
|
readonly stopReason?: string;
|
|
19
44
|
readonly usage?: GenerationUsage;
|
|
45
|
+
/** System prompt as the model received it (after every hook). */
|
|
46
|
+
readonly system?: string;
|
|
47
|
+
/** Tool names offered on this request. */
|
|
48
|
+
readonly toolNames?: readonly string[];
|
|
49
|
+
readonly params?: ModelSettings;
|
|
50
|
+
/** Request messages: everything since the previous assistant message (`delta`) or the whole context (`full`). */
|
|
51
|
+
readonly input?: readonly Message[];
|
|
52
|
+
readonly inputMode?: GenerationInputMode;
|
|
53
|
+
/** What the model produced this step. */
|
|
54
|
+
readonly output?: readonly GenerationOutputPart[];
|
|
20
55
|
} | {
|
|
21
56
|
readonly type: "tool";
|
|
22
57
|
readonly name: string;
|
|
23
58
|
readonly toolCallId: string;
|
|
24
59
|
readonly isError?: boolean;
|
|
60
|
+
readonly args?: unknown;
|
|
61
|
+
readonly result?: ToolResult;
|
|
62
|
+
}
|
|
63
|
+
/** A non-model message entering the transcript (user prompt, injection, cron…). Instant span. */
|
|
64
|
+
| {
|
|
65
|
+
readonly type: "message";
|
|
66
|
+
readonly role: "user";
|
|
67
|
+
/** `PromptOrigin.kind` when the event carried one. */
|
|
68
|
+
readonly origin?: string;
|
|
69
|
+
readonly content?: string | readonly (TextContent | ImageContent)[];
|
|
25
70
|
} | {
|
|
26
71
|
readonly type: "handoff";
|
|
27
72
|
readonly from?: string;
|
|
@@ -42,6 +87,12 @@ export interface SpanError {
|
|
|
42
87
|
readonly message: string;
|
|
43
88
|
readonly data?: Record<string, unknown>;
|
|
44
89
|
}
|
|
90
|
+
/** A point-in-time annotation on a span (a retry, a reset) — OTel span events, Jaeger "logs". */
|
|
91
|
+
export interface SpanEvent {
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly timestamp: number;
|
|
94
|
+
readonly data?: Record<string, unknown>;
|
|
95
|
+
}
|
|
45
96
|
export interface SpanRecord {
|
|
46
97
|
readonly object: "trace.span";
|
|
47
98
|
readonly id: string;
|
|
@@ -51,6 +102,7 @@ export interface SpanRecord {
|
|
|
51
102
|
readonly ended_at: number | null;
|
|
52
103
|
readonly span_data: SpanData;
|
|
53
104
|
readonly error: SpanError | null;
|
|
105
|
+
readonly events?: readonly SpanEvent[];
|
|
54
106
|
}
|
|
55
107
|
export interface TraceRecord {
|
|
56
108
|
readonly object: "trace";
|
|
@@ -69,6 +121,7 @@ export declare class Span<T extends SpanData = SpanData> {
|
|
|
69
121
|
endedAt: number | null;
|
|
70
122
|
error: SpanError | null;
|
|
71
123
|
data: T;
|
|
124
|
+
events: SpanEvent[];
|
|
72
125
|
constructor(args: {
|
|
73
126
|
traceId: string;
|
|
74
127
|
spanId: string;
|
|
@@ -76,6 +129,7 @@ export declare class Span<T extends SpanData = SpanData> {
|
|
|
76
129
|
data: T;
|
|
77
130
|
});
|
|
78
131
|
get type(): SpanType;
|
|
132
|
+
addEvent(name: string, timestamp: number, data?: Record<string, unknown>): void;
|
|
79
133
|
toJSON(): SpanRecord;
|
|
80
134
|
}
|
|
81
135
|
export declare class Trace {
|
package/dist/tracing/spans.js
CHANGED
|
@@ -16,6 +16,7 @@ export class Span {
|
|
|
16
16
|
endedAt = null;
|
|
17
17
|
error = null;
|
|
18
18
|
data;
|
|
19
|
+
events = [];
|
|
19
20
|
constructor(args) {
|
|
20
21
|
this.traceId = args.traceId;
|
|
21
22
|
this.spanId = args.spanId;
|
|
@@ -25,6 +26,9 @@ export class Span {
|
|
|
25
26
|
get type() {
|
|
26
27
|
return this.data.type;
|
|
27
28
|
}
|
|
29
|
+
addEvent(name, timestamp, data) {
|
|
30
|
+
this.events.push(data === undefined ? { name, timestamp } : { name, timestamp, data });
|
|
31
|
+
}
|
|
28
32
|
toJSON() {
|
|
29
33
|
return {
|
|
30
34
|
object: "trace.span",
|
|
@@ -35,6 +39,7 @@ export class Span {
|
|
|
35
39
|
ended_at: this.endedAt,
|
|
36
40
|
span_data: this.data,
|
|
37
41
|
error: this.error,
|
|
42
|
+
...(this.events.length > 0 ? { events: this.events } : {}),
|
|
38
43
|
};
|
|
39
44
|
}
|
|
40
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "operon-agents-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.21",
|
|
4
4
|
"description": "Internal engine for operon-agents. Prefer operon-agents for application code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"types": "./dist/tracing/index.d.ts",
|
|
56
56
|
"import": "./dist/tracing/index.js"
|
|
57
57
|
},
|
|
58
|
+
"./telemetry": {
|
|
59
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
60
|
+
"import": "./dist/telemetry/index.js"
|
|
61
|
+
},
|
|
58
62
|
"./ui": {
|
|
59
63
|
"types": "./dist/ui/index.d.ts",
|
|
60
64
|
"import": "./dist/ui/index.js"
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
"README.md"
|
|
68
72
|
],
|
|
69
73
|
"dependencies": {
|
|
70
|
-
"@earendil-works/pi-ai": "
|
|
74
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
71
75
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
72
76
|
"@opentelemetry/api": "^1.9.0",
|
|
73
77
|
"acorn": "^8.17.0",
|
package/dist/tool/machine.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export class StaleFileError extends Error {
|
|
2
|
-
code = "FILE_MODIFIED_SINCE_READ";
|
|
3
|
-
constructor(message = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.") {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = "StaleFileError";
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export class FileExistsError extends Error {
|
|
9
|
-
code = "FILE_ALREADY_EXISTS";
|
|
10
|
-
constructor(message = "Cannot create new file - file already exists.") {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "FileExistsError";
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=machine.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Message } from "../../protocol/index.ts";
|
|
2
|
-
import type { Tool } from "../types.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Project a complete execution registry to the tools currently available to
|
|
5
|
-
* the model. A load point is structural transcript state, not summary text:
|
|
6
|
-
*
|
|
7
|
-
* - `addedToolNames` activates newly searched tools.
|
|
8
|
-
* - a surviving assistant tool call keeps an already-used tool immediate.
|
|
9
|
-
* - full compaction unloads evidence removed with the compacted prefix.
|
|
10
|
-
* - micro compaction keeps these fields while replacing only result content.
|
|
11
|
-
*/
|
|
12
|
-
export declare function activeDeferredTools(tools: readonly Tool[], deferredToolNames: ReadonlySet<string>, messages: readonly Message[]): Tool[];
|
|
13
|
-
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project a complete execution registry to the tools currently available to
|
|
3
|
-
* the model. A load point is structural transcript state, not summary text:
|
|
4
|
-
*
|
|
5
|
-
* - `addedToolNames` activates newly searched tools.
|
|
6
|
-
* - a surviving assistant tool call keeps an already-used tool immediate.
|
|
7
|
-
* - full compaction unloads evidence removed with the compacted prefix.
|
|
8
|
-
* - micro compaction keeps these fields while replacing only result content.
|
|
9
|
-
*/
|
|
10
|
-
export function activeDeferredTools(tools, deferredToolNames, messages) {
|
|
11
|
-
if (deferredToolNames.size === 0)
|
|
12
|
-
return [...tools];
|
|
13
|
-
const activeDeferred = new Set();
|
|
14
|
-
for (const message of messages) {
|
|
15
|
-
if (message.role === "assistant") {
|
|
16
|
-
for (const part of message.content) {
|
|
17
|
-
if (part.type === "toolCall" && deferredToolNames.has(part.name)) {
|
|
18
|
-
activeDeferred.add(part.name);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (message.role === "toolResult") {
|
|
23
|
-
for (const name of message.addedToolNames ?? []) {
|
|
24
|
-
if (deferredToolNames.has(name))
|
|
25
|
-
activeDeferred.add(name);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return tools.filter((tool) => !deferredToolNames.has(tool.schema.name) || activeDeferred.has(tool.schema.name));
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=activation.js.map
|