@springbrand/agent-runtime 0.2.0-alpha.39 → 0.2.0-alpha.41

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.
@@ -30,7 +30,6 @@ import {
30
30
  } from "./lib/execution-level";
31
31
  import {
32
32
  createPiRuntimeAssembly,
33
- type FinalizedPiToolSurface,
34
33
  type PiToolSurface,
35
34
  type PiRuntimeAssembly,
36
35
  } from "./pi/assembly/snapshot";
@@ -44,7 +43,6 @@ import type {
44
43
  RuntimeSkillContribution,
45
44
  RuntimeToolSurfacePolicy,
46
45
  } from "./runtime-definition";
47
- import type { RuntimeCodeExecutionFactory } from "./kernel/bindings";
48
46
  import {
49
47
  basePiToolCandidates,
50
48
  memoryPiToolCandidate,
@@ -52,7 +50,6 @@ import {
52
50
  import {
53
51
  BROWSER_EXECUTE_TOOL_NAME,
54
52
  browserExecutionPiToolCandidate,
55
- codeExecutionPiToolCandidate,
56
53
  } from "./pi/tool/core";
57
54
  import { skillPiToolCandidates } from "./pi/tool/skill";
58
55
  import { createWebSearch } from "./pi/tool/web-search";
@@ -83,7 +80,6 @@ export interface RuntimeAssemblyInput {
83
80
  readonly provider: RuntimeProviderPort;
84
81
  readonly platform: RuntimePlatformPort;
85
82
  readonly workspace?: WorkspacePort;
86
- readonly codeExecution?: RuntimeCodeExecutionFactory;
87
83
  readonly sandbox?: RuntimeSandboxPort;
88
84
  readonly memory?: RuntimeMemoryPort;
89
85
  readonly hostTools: readonly PiToolCandidate[];
@@ -157,7 +153,6 @@ function assertMemoryProfile(profile: RuntimeMemoryProfile): void {
157
153
  }
158
154
 
159
155
  interface ToolSurfaceInput {
160
- readonly codeExecution?: RuntimeCodeExecutionFactory;
161
156
  readonly platform: RuntimePlatformPort;
162
157
  readonly workspace?: WorkspacePort;
163
158
  readonly memory?: {
@@ -203,15 +198,10 @@ async function createToolSurface(
203
198
  });
204
199
  // 平台没有浏览器能力时注册空集:宁可没有这个 Tool,也不注册一个必然失败的 Tool 误导模型。
205
200
  // `create()` 推迟到确认这个名字真的可见之后,被 deny 的装配不白建一个浏览器连接器。
206
- // `direct` 使它只走 Direct 调用,不再被并进 `execute` 的工具集——两个 Code Mode 类工具互相嵌套
207
- // 会让「哪次执行被记录、被重放」变得无法解释,而它们的分工本就由 System Prompt 划清。
208
201
  const browserVisible = !deny.has(BROWSER_EXECUTE_TOOL_NAME) &&
209
202
  allowsTool?.(BROWSER_EXECUTE_TOOL_NAME) !== false;
210
203
  const browserCandidates = input.platform.browser && browserVisible
211
- ? [{
212
- ...browserExecutionPiToolCandidate(input.platform.browser.create()),
213
- direct: true as const,
214
- }]
204
+ ? [browserExecutionPiToolCandidate(input.platform.browser.create())]
215
205
  : [];
216
206
  const baseCandidates = basePiToolCandidates(input.webSearch);
217
207
  const memoryCandidates = input.memory
@@ -248,87 +238,16 @@ async function createToolSurface(
248
238
  if (!EXECUTION_LEVELS.includes(candidate.requiredExecutionLevel)) {
249
239
  throw new Error(`SpringBrand Tool ${name} execution level is invalid`);
250
240
  }
241
+ if (name === "execute") {
242
+ throw new Error("SpringBrand reserved Runtime Tool name: execute");
243
+ }
251
244
  if (tools.has(name)) {
252
245
  throw new Error(`Duplicate Runtime SpringBrand Tool: ${name}`);
253
246
  }
254
- tools.set(name, Object.freeze({ ...candidate }));
247
+ tools.set(name, classify(candidate));
255
248
  }
256
249
 
257
- const finalized = [...tools.values()];
258
- const directVisible = finalized.filter(
259
- (candidate) => !candidate.codeExecutionOnly,
260
- );
261
- if (tools.has("execute")) {
262
- throw new Error("SpringBrand reserved Runtime Tool name: execute");
263
- }
264
- if (
265
- !input.codeExecution ||
266
- deny.has("execute") ||
267
- allowsTool?.("execute") === false
268
- ) {
269
- return Object.freeze({
270
- candidates: Object.freeze(directVisible.map(classify)),
271
- codeExecutionCandidates: Object.freeze([]),
272
- }) satisfies FinalizedPiToolSurface;
273
- }
274
- const mergeable = finalized.filter(
275
- (candidate) =>
276
- !candidate.direct &&
277
- !candidate.interaction &&
278
- typeof candidate.tool.execute === "function",
279
- );
280
- const codeExecutionCandidates = Object.freeze([...mergeable]);
281
- const codeExecutionToolNames = new Set(
282
- codeExecutionCandidates.map(({ tool }) => tool.name),
283
- );
284
- const codeExecution = input.codeExecution.create(
285
- codeExecutionCandidates,
286
- );
287
- const topLevelOnly = directVisible.filter(
288
- ({ tool }) => !codeExecutionToolNames.has(tool.name),
289
- );
290
- const routeList = (deferred: boolean) => {
291
- const matches = topLevelOnly.filter((candidate) =>
292
- (defersTool?.(candidate.tool.name) === true) === deferred
293
- );
294
- return matches.length > 0
295
- ? matches.map(({ tool }) =>
296
- `- \`${tool.name}\` — ${(tool.label ?? tool.name)
297
- .replaceAll(/\s+/g, " ").trim().replaceAll("`", "'")}`
298
- ).join("\n")
299
- : "- None.";
300
- };
301
- const routeGuidance = [
302
- "## Tool routing",
303
- "Top-level deferred Tools are not callable through `tools.*`. Use Provider Tool Search with their exact name, then call them directly.",
304
- "Top-level immediate Tools are already available outside execute; call them directly.",
305
- "",
306
- "## Top-level deferred Tools",
307
- routeList(true),
308
- "",
309
- "## Top-level immediate Tools",
310
- routeList(false),
311
- "",
312
- ].join("\n");
313
- const materializeGuidance = codeExecutionCandidates.some(
314
- ({ tool }) => tool.name === "materialize_skill_resource",
315
- )
316
- ? "Skill resource copying is available only inside execute through " +
317
- "`tools.materialize_skill_resource({ name, path, destination })`; " +
318
- "no Direct Tool is registered for it. " +
319
- "Use a loop or Promise.all when copying multiple resources.\n\n"
320
- : "";
321
- return Object.freeze({
322
- candidates: Object.freeze([
323
- classify(codeExecutionPiToolCandidate({
324
- ...codeExecution,
325
- description:
326
- routeGuidance + "\n" + materializeGuidance + codeExecution.description,
327
- })),
328
- ...directVisible.map(classify),
329
- ]),
330
- codeExecutionCandidates,
331
- }) satisfies FinalizedPiToolSurface;
250
+ return Object.freeze([...tools.values()]);
332
251
  },
333
252
  }),
334
253
  extensions: input.extensions.filter(
@@ -356,7 +275,6 @@ class RuntimeBuilder {
356
275
  private platform?: RuntimePlatformPort;
357
276
  private gateway?: RuntimeGatewayPort;
358
277
  private workspace?: WorkspacePort;
359
- private codeExecution?: RuntimeCodeExecutionFactory;
360
278
  private sandbox?: RuntimeSandboxPort;
361
279
  private schedule?: RuntimeSchedulePort;
362
280
  private memoryProfile: RuntimeMemoryProfile = DISABLED_MEMORY;
@@ -392,7 +310,6 @@ class RuntimeBuilder {
392
310
  this.provider = input.provider;
393
311
  this.platform = input.platform;
394
312
  this.workspace = input.workspace;
395
- this.codeExecution = input.codeExecution;
396
313
  this.sandbox = input.sandbox;
397
314
  this.memoryProfile = input.memoryProfile;
398
315
  this.memory = input.memory;
@@ -532,9 +449,6 @@ class RuntimeBuilder {
532
449
  if (!this.platform.loader) {
533
450
  throw new Error("Runtime platform loader is required");
534
451
  }
535
- if (typeof this.platform.outbound !== "function") {
536
- throw new Error("Runtime platform outbound port is required");
537
- }
538
452
 
539
453
  assertMemoryProfile(this.memoryProfile);
540
454
  if (this.memoryProfile.enabled && (!this.workspace || !this.memory)) {
@@ -584,7 +498,6 @@ class RuntimeBuilder {
584
498
  });
585
499
  const skillSources = [...this.skillSources.values()];
586
500
  const toolSurface = await createToolSurface({
587
- ...(this.codeExecution ? { codeExecution: this.codeExecution } : {}),
588
501
  platform: this.platform,
589
502
  ...(this.workspace ? { workspace: this.workspace } : {}),
590
503
  ...(this.memoryProfile.enabled && this.memory
@@ -609,7 +522,6 @@ class RuntimeBuilder {
609
522
  const bindings: RuntimeBindings = Object.freeze({
610
523
  provider,
611
524
  platform: Object.freeze({ ...this.platform }),
612
- ...(this.codeExecution ? { codeExecution: this.codeExecution } : {}),
613
525
  ...(this.gateway ? { gateway: this.gateway } : {}),
614
526
  ...(this.workspace ? { workspace: this.workspace } : {}),
615
527
  ...(this.memoryProfile.enabled && this.memory
@@ -754,9 +666,6 @@ export async function assembleRuntimeSnapshot<
754
666
  ...(toolAssembly.bindings?.workspace
755
667
  ? { workspace: toolAssembly.bindings.workspace }
756
668
  : {}),
757
- ...(toolAssembly.bindings?.codeExecution
758
- ? { codeExecution: toolAssembly.bindings.codeExecution }
759
- : {}),
760
669
  ...(memoryProfile.enabled && toolAssembly.bindings?.memory
761
670
  ? { memory: toolAssembly.bindings.memory }
762
671
  : {}),
@@ -33,7 +33,6 @@ export interface ToolSurfaceSelectionPolicy {
33
33
  /** Kernel 绑定仍需要的执行后端;不出现在 Definition 公开类型里。 */
34
34
  export interface RuntimeToolBindings {
35
35
  readonly workspace?: import("./kernel/bindings").WorkspacePort;
36
- readonly codeExecution?: import("./kernel/bindings").RuntimeCodeExecutionFactory;
37
36
  readonly memory?: import("./kernel/bindings").RuntimeMemoryPort;
38
37
  readonly subagents?: import("./kernel/bindings").RuntimeSubagentPort;
39
38
  }
package/src/runtime.ts CHANGED
@@ -975,28 +975,6 @@ export abstract class AgentRuntimeKernel<
975
975
  occurredAt: event.timestamp,
976
976
  });
977
977
  },
978
- onNestedToolStarted: (event) => {
979
- this.telemetry.capture("toolStarted", {
980
- submissionId: submission.submissionId,
981
- ...event,
982
- });
983
- },
984
- onNestedToolFinished: (event) => {
985
- this.telemetry.capture("toolFinished", {
986
- submissionId: submission.submissionId,
987
- parentToolCallId: event.parentToolCallId,
988
- toolCallId: event.toolCallId,
989
- toolName: event.toolName,
990
- outcome: event.outcome,
991
- durationMs: event.durationMs,
992
- ...(event.output ? {
993
- output: event.output,
994
- outputBytes: json(event.output).length,
995
- } : {}),
996
- ...(event.error ? { error: errorText(event.error) } : {}),
997
- occurredAt: event.occurredAt,
998
- });
999
- },
1000
978
  ...(toolExecutors && Object.keys(toolExecutors).length > 0
1001
979
  ? { toolExecutors }
1002
980
  : {}),