@tangle-network/sandbox 0.65.3 → 0.65.5
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/index.d.ts +96 -172
- package/dist/agent/index.js +60 -123
- package/dist/agent/preview.d.ts +1 -1
- package/dist/{agent-run-outcome-D8Riqf7N.d.ts → agent-run-outcome-Dw8qj2dA.d.ts} +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/{chunked-upload-file-Ci5dxctW.js → chunked-upload-file-BpfpPCsE.js} +1 -1
- package/dist/{client-DV1SbwZK.d.ts → client-BYo1PDBA.d.ts} +259 -252
- package/dist/{client-CmoTway8.js → client-CUYXXFJB.js} +170 -170
- package/dist/collaboration/index.js +1 -1
- package/dist/{select-seat-BSEdpAMq.js → core-DnrLA0im.js} +9 -2
- package/dist/core.d.ts +6 -14
- package/dist/core.js +4 -11
- package/dist/{direct-http2-B7Uw2o-9.js → direct-http2-6fHIO7eF.js} +1 -1
- package/dist/{index-DpsISCBX.d.ts → index-3ssvFNHp.d.ts} +3 -3
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/{interactive-controller-DLrI-UvT.js → interactive-controller-DoYo8Kq5.js} +1 -1
- package/dist/{interactive-controller-BtdROvsm.d.ts → interactive-controller-JmNWnJGV.d.ts} +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-DViw4KHn.d.ts → lines-CrpK5B93.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{local-cli-auth-BO2sfVoW.js → local-cli-auth--crCWGcG.js} +1 -1
- package/dist/{preview-DRZnmu5V.d.ts → preview-v6cnh4Wq.d.ts} +3 -3
- package/dist/{public-templates-ursM1K2F.d.ts → public-templates-De-zuxAd.d.ts} +1 -1
- package/dist/public-templates.d.ts +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +2 -2
- package/dist/{sandbox-DiigN_DB.js → sandbox-D-AOea4t.js} +8 -8
- package/dist/select-seat-command.d.ts +1 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-Ci5No-40.js → tangle-D-h2SpVO.js} +1 -1
- package/dist/{types-D_RvPPTq.d.ts → types-8xXvGZNO.d.ts} +1 -29
- package/package.json +5 -5
- /package/dist/{chunked-upload-DC2b4-t5.js → chunked-upload-D1DL0f88.js} +0 -0
- /package/dist/{cli-auth-bundle-BBuXynrM.js → cli-auth-bundle-Ymv99-5G.js} +0 -0
- /package/dist/{collaboration-CPU10E5p.js → collaboration-Tn2ygatK.js} +0 -0
- /package/dist/{keep-alive-fetch-BOEM_9nC.js → keep-alive-fetch-_KZcsAS_.js} +0 -0
- /package/dist/{lines-DBaAhcFv.js → lines-BdF6b46c.js} +0 -0
- /package/dist/{prepared-process-Bj6Ly6R2.js → prepared-process-DNX-AVJ3.js} +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-
|
|
2
|
-
import { Di as CodeResultPart, Ei as CodeExecutionResult, Ha as CodeLanguage, Ti as CodeExecutionOptions, bn as SandboxFleetParent, vo as BackendType, xa as BackendConfig, xt as SessionListOptions, yt as SessionInfo } from "../types-
|
|
3
|
-
import { t as Sandbox } from "../client-
|
|
4
|
-
import { u as PreviewAuthorizer } from "../preview-
|
|
1
|
+
import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-3ssvFNHp.js";
|
|
2
|
+
import { Di as CodeResultPart, Ei as CodeExecutionResult, Ha as CodeLanguage, Ti as CodeExecutionOptions, bn as SandboxFleetParent, vo as BackendType, xa as BackendConfig, xt as SessionListOptions, yt as SessionInfo } from "../types-8xXvGZNO.js";
|
|
3
|
+
import { t as Sandbox } from "../client-BYo1PDBA.js";
|
|
4
|
+
import { u as PreviewAuthorizer } from "../preview-v6cnh4Wq.js";
|
|
5
5
|
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
6
|
import { JSONSchema } from "zod/v4/core";
|
|
7
7
|
import { ToolSet } from "ai";
|
|
@@ -401,43 +401,8 @@ declare const FLEET_TOOL_SPECS: {
|
|
|
401
401
|
type FleetToolName = keyof typeof FLEET_TOOL_SPECS;
|
|
402
402
|
declare const ALL_FLEET_TOOL_SPECS: FleetToolSpec[];
|
|
403
403
|
//#endregion
|
|
404
|
-
//#region src/agent/tools/
|
|
405
|
-
interface
|
|
406
|
-
/** Which fleet tools to expose. Defaults to all of them. */
|
|
407
|
-
allow?: FleetToolName[];
|
|
408
|
-
/**
|
|
409
|
-
* The fleet and agent this tool pack acts for. Fleets it spawns record it
|
|
410
|
-
* as their parent, so their cap is carved from the parent's and deleting or
|
|
411
|
-
* cancelling the parent reaches them.
|
|
412
|
-
*/
|
|
413
|
-
parent?: SandboxFleetParent;
|
|
414
|
-
}
|
|
415
|
-
interface AnthropicFleetTool {
|
|
416
|
-
name: string;
|
|
417
|
-
description: string;
|
|
418
|
-
input_schema: {
|
|
419
|
-
type: "object";
|
|
420
|
-
properties: Record<string, unknown>;
|
|
421
|
-
required?: string[];
|
|
422
|
-
additionalProperties?: boolean;
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
interface AnthropicFleetToolPack {
|
|
426
|
-
tools: AnthropicFleetTool[];
|
|
427
|
-
handleToolUse(block: {
|
|
428
|
-
type: "tool_use";
|
|
429
|
-
id: string;
|
|
430
|
-
name: string;
|
|
431
|
-
input: Record<string, unknown>;
|
|
432
|
-
}): Promise<{
|
|
433
|
-
type: "tool_result";
|
|
434
|
-
tool_use_id: string;
|
|
435
|
-
content: string;
|
|
436
|
-
is_error?: boolean;
|
|
437
|
-
}>;
|
|
438
|
-
}
|
|
439
|
-
declare function anthropicFleetTools(client: Sandbox, options?: FleetToolPackOptions): AnthropicFleetToolPack;
|
|
440
|
-
interface OpenAIFleetTool {
|
|
404
|
+
//#region src/agent/tools/openai.d.ts
|
|
405
|
+
interface OpenAITool {
|
|
441
406
|
type: "function";
|
|
442
407
|
function: {
|
|
443
408
|
name: string;
|
|
@@ -450,21 +415,97 @@ interface OpenAIFleetTool {
|
|
|
450
415
|
};
|
|
451
416
|
};
|
|
452
417
|
}
|
|
453
|
-
interface
|
|
454
|
-
|
|
455
|
-
|
|
418
|
+
interface OpenAIToolCall {
|
|
419
|
+
id: string;
|
|
420
|
+
type?: "function";
|
|
421
|
+
function: {
|
|
422
|
+
name: string;
|
|
423
|
+
arguments: string;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
interface OpenAIToolResultMessage {
|
|
427
|
+
role: "tool";
|
|
428
|
+
tool_call_id: string;
|
|
429
|
+
content: string;
|
|
430
|
+
}
|
|
431
|
+
interface OpenAIToolPackOptions {
|
|
432
|
+
allow?: ToolName[];
|
|
433
|
+
sessionId?: string;
|
|
434
|
+
previewAuthorize?: PreviewAuthorizer;
|
|
435
|
+
signal?: AbortSignal;
|
|
436
|
+
}
|
|
437
|
+
interface OpenAIToolPack {
|
|
438
|
+
tools: OpenAITool[];
|
|
439
|
+
/** Dispatch a single tool call into a Chat Completions tool message. */
|
|
440
|
+
handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
|
|
441
|
+
/**
|
|
442
|
+
* Convenience: dispatch every tool_call on an assistant message in parallel.
|
|
443
|
+
*/
|
|
444
|
+
handleAssistantMessage(message: {
|
|
445
|
+
tool_calls?: OpenAIToolCall[];
|
|
446
|
+
}): Promise<OpenAIToolResultMessage[]>;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Build an OpenAI tool pack bound to one sandbox.
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```ts
|
|
453
|
+
* import OpenAI from "openai";
|
|
454
|
+
* import { openaiTools } from "@tangle-network/sandbox/agent";
|
|
455
|
+
*
|
|
456
|
+
* const openai = new OpenAI();
|
|
457
|
+
* const { tools, handleAssistantMessage } = openaiTools(box, { sessionId: "s1" });
|
|
458
|
+
*
|
|
459
|
+
* const messages: any[] = [{ role: "user", content: "Plot sin(x) for x in [0, 2π]." }];
|
|
460
|
+
* for (let i = 0; i < 6; i++) {
|
|
461
|
+
* const r = await openai.chat.completions.create({
|
|
462
|
+
* model: "gpt-5.4", tools, messages,
|
|
463
|
+
* });
|
|
464
|
+
* const m = r.choices[0].message;
|
|
465
|
+
* messages.push(m);
|
|
466
|
+
* if (!m.tool_calls?.length) break;
|
|
467
|
+
* messages.push(...(await handleAssistantMessage(m)));
|
|
468
|
+
* }
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
declare function openaiTools(box: SandboxInstance, options?: OpenAIToolPackOptions): OpenAIToolPack;
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/agent/tools/_client-packs.d.ts
|
|
474
|
+
interface AnthropicClientToolPack {
|
|
475
|
+
tools: AnthropicTool[];
|
|
476
|
+
handleToolUse(block: {
|
|
477
|
+
type: "tool_use";
|
|
456
478
|
id: string;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
name: string;
|
|
460
|
-
arguments: string;
|
|
461
|
-
};
|
|
479
|
+
name: string;
|
|
480
|
+
input: Record<string, unknown>;
|
|
462
481
|
}): Promise<{
|
|
463
|
-
|
|
464
|
-
|
|
482
|
+
type: "tool_result";
|
|
483
|
+
tool_use_id: string;
|
|
465
484
|
content: string;
|
|
485
|
+
is_error?: boolean;
|
|
466
486
|
}>;
|
|
467
487
|
}
|
|
488
|
+
interface OpenAIClientToolPack {
|
|
489
|
+
tools: OpenAITool[];
|
|
490
|
+
handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/agent/tools/fleet/index.d.ts
|
|
494
|
+
interface FleetToolPackOptions {
|
|
495
|
+
/** Which fleet tools to expose. Defaults to all of them. */
|
|
496
|
+
allow?: FleetToolName[];
|
|
497
|
+
/**
|
|
498
|
+
* The fleet and agent this tool pack acts for. Fleets it spawns record it
|
|
499
|
+
* as their parent, so their cap is carved from the parent's and deleting or
|
|
500
|
+
* cancelling the parent reaches them.
|
|
501
|
+
*/
|
|
502
|
+
parent?: SandboxFleetParent;
|
|
503
|
+
}
|
|
504
|
+
type AnthropicFleetTool = AnthropicTool;
|
|
505
|
+
type AnthropicFleetToolPack = AnthropicClientToolPack;
|
|
506
|
+
type OpenAIFleetTool = OpenAITool;
|
|
507
|
+
type OpenAIFleetToolPack = OpenAIClientToolPack;
|
|
508
|
+
declare function anthropicFleetTools(client: Sandbox, options?: FleetToolPackOptions): AnthropicFleetToolPack;
|
|
468
509
|
declare function openaiFleetTools(client: Sandbox, options?: FleetToolPackOptions): OpenAIFleetToolPack;
|
|
469
510
|
declare function vercelAiFleetTools(client: Sandbox, options?: FleetToolPackOptions): Promise<Record<string, unknown>>;
|
|
470
511
|
declare function mastraFleetTools(client: Sandbox, options?: FleetToolPackOptions): Promise<Record<string, unknown>>;
|
|
@@ -502,59 +543,11 @@ interface LifecycleToolPackOptions {
|
|
|
502
543
|
/** Which lifecycle tools to expose. Defaults to all three. */
|
|
503
544
|
allow?: LifecycleToolName[];
|
|
504
545
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
type: "object";
|
|
510
|
-
properties: Record<string, unknown>;
|
|
511
|
-
required?: string[];
|
|
512
|
-
additionalProperties?: boolean;
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
interface AnthropicLifecycleToolPack {
|
|
516
|
-
tools: AnthropicLifecycleTool[];
|
|
517
|
-
handleToolUse(block: {
|
|
518
|
-
type: "tool_use";
|
|
519
|
-
id: string;
|
|
520
|
-
name: string;
|
|
521
|
-
input: Record<string, unknown>;
|
|
522
|
-
}): Promise<{
|
|
523
|
-
type: "tool_result";
|
|
524
|
-
tool_use_id: string;
|
|
525
|
-
content: string;
|
|
526
|
-
is_error?: boolean;
|
|
527
|
-
}>;
|
|
528
|
-
}
|
|
546
|
+
type AnthropicLifecycleTool = AnthropicTool;
|
|
547
|
+
type AnthropicLifecycleToolPack = AnthropicClientToolPack;
|
|
548
|
+
type OpenAILifecycleTool = OpenAITool;
|
|
549
|
+
type OpenAILifecycleToolPack = OpenAIClientToolPack;
|
|
529
550
|
declare function anthropicLifecycleTools(client: Sandbox, options?: LifecycleToolPackOptions): AnthropicLifecycleToolPack;
|
|
530
|
-
interface OpenAILifecycleTool {
|
|
531
|
-
type: "function";
|
|
532
|
-
function: {
|
|
533
|
-
name: string;
|
|
534
|
-
description: string;
|
|
535
|
-
parameters: {
|
|
536
|
-
type: "object";
|
|
537
|
-
properties: Record<string, unknown>;
|
|
538
|
-
required?: string[];
|
|
539
|
-
additionalProperties?: boolean;
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
interface OpenAILifecycleToolPack {
|
|
544
|
-
tools: OpenAILifecycleTool[];
|
|
545
|
-
handleToolCall(call: {
|
|
546
|
-
id: string;
|
|
547
|
-
type?: "function";
|
|
548
|
-
function: {
|
|
549
|
-
name: string;
|
|
550
|
-
arguments: string;
|
|
551
|
-
};
|
|
552
|
-
}): Promise<{
|
|
553
|
-
role: "tool";
|
|
554
|
-
tool_call_id: string;
|
|
555
|
-
content: string;
|
|
556
|
-
}>;
|
|
557
|
-
}
|
|
558
551
|
declare function openaiLifecycleTools(client: Sandbox, options?: LifecycleToolPackOptions): OpenAILifecycleToolPack;
|
|
559
552
|
//#endregion
|
|
560
553
|
//#region src/agent/tools/mastra.d.ts
|
|
@@ -579,75 +572,6 @@ interface MastraToolPackOptions {
|
|
|
579
572
|
*/
|
|
580
573
|
declare function mastraTools(box: SandboxInstance, options?: MastraToolPackOptions): Promise<Record<string, unknown>>;
|
|
581
574
|
//#endregion
|
|
582
|
-
//#region src/agent/tools/openai.d.ts
|
|
583
|
-
interface OpenAITool {
|
|
584
|
-
type: "function";
|
|
585
|
-
function: {
|
|
586
|
-
name: string;
|
|
587
|
-
description: string;
|
|
588
|
-
parameters: {
|
|
589
|
-
type: "object";
|
|
590
|
-
properties: Record<string, unknown>;
|
|
591
|
-
required?: string[];
|
|
592
|
-
additionalProperties?: boolean;
|
|
593
|
-
};
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
interface OpenAIToolCall {
|
|
597
|
-
id: string;
|
|
598
|
-
type?: "function";
|
|
599
|
-
function: {
|
|
600
|
-
name: string;
|
|
601
|
-
arguments: string;
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
interface OpenAIToolResultMessage {
|
|
605
|
-
role: "tool";
|
|
606
|
-
tool_call_id: string;
|
|
607
|
-
content: string;
|
|
608
|
-
}
|
|
609
|
-
interface OpenAIToolPackOptions {
|
|
610
|
-
allow?: ToolName[];
|
|
611
|
-
sessionId?: string;
|
|
612
|
-
previewAuthorize?: PreviewAuthorizer;
|
|
613
|
-
signal?: AbortSignal;
|
|
614
|
-
}
|
|
615
|
-
interface OpenAIToolPack {
|
|
616
|
-
tools: OpenAITool[];
|
|
617
|
-
/** Dispatch a single tool call into a Chat Completions tool message. */
|
|
618
|
-
handleToolCall(call: OpenAIToolCall): Promise<OpenAIToolResultMessage>;
|
|
619
|
-
/**
|
|
620
|
-
* Convenience: dispatch every tool_call on an assistant message in parallel.
|
|
621
|
-
*/
|
|
622
|
-
handleAssistantMessage(message: {
|
|
623
|
-
tool_calls?: OpenAIToolCall[];
|
|
624
|
-
}): Promise<OpenAIToolResultMessage[]>;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Build an OpenAI tool pack bound to one sandbox.
|
|
628
|
-
*
|
|
629
|
-
* @example
|
|
630
|
-
* ```ts
|
|
631
|
-
* import OpenAI from "openai";
|
|
632
|
-
* import { openaiTools } from "@tangle-network/sandbox/agent";
|
|
633
|
-
*
|
|
634
|
-
* const openai = new OpenAI();
|
|
635
|
-
* const { tools, handleAssistantMessage } = openaiTools(box, { sessionId: "s1" });
|
|
636
|
-
*
|
|
637
|
-
* const messages: any[] = [{ role: "user", content: "Plot sin(x) for x in [0, 2π]." }];
|
|
638
|
-
* for (let i = 0; i < 6; i++) {
|
|
639
|
-
* const r = await openai.chat.completions.create({
|
|
640
|
-
* model: "gpt-5.4", tools, messages,
|
|
641
|
-
* });
|
|
642
|
-
* const m = r.choices[0].message;
|
|
643
|
-
* messages.push(m);
|
|
644
|
-
* if (!m.tool_calls?.length) break;
|
|
645
|
-
* messages.push(...(await handleAssistantMessage(m)));
|
|
646
|
-
* }
|
|
647
|
-
* ```
|
|
648
|
-
*/
|
|
649
|
-
declare function openaiTools(box: SandboxInstance, options?: OpenAIToolPackOptions): OpenAIToolPack;
|
|
650
|
-
//#endregion
|
|
651
575
|
//#region src/agent/tools/vercel-ai.d.ts
|
|
652
576
|
interface VercelAiToolPackOptions {
|
|
653
577
|
allow?: ToolName[];
|
package/dist/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-CjcoVT7f.js";
|
|
2
|
-
import { D as assertCurrentBackendType } from "../interactive-controller-
|
|
2
|
+
import { D as assertCurrentBackendType } from "../interactive-controller-DoYo8Kq5.js";
|
|
3
3
|
import { S as StateError, T as ValidationError, h as NotFoundError } from "../errors-CfQHPcLX.js";
|
|
4
|
-
import { t as Sandbox } from "../client-
|
|
5
|
-
import { t as SandboxInstance } from "../sandbox-
|
|
4
|
+
import { t as Sandbox } from "../client-CUYXXFJB.js";
|
|
5
|
+
import { t as SandboxInstance } from "../sandbox-D-AOea4t.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/agent/instances.ts
|
|
8
8
|
const managers = /* @__PURE__ */ new WeakMap();
|
|
@@ -498,30 +498,22 @@ function selectFleetSpecs(allow) {
|
|
|
498
498
|
return Object.keys(FLEET_TOOL_SPECS).filter((name) => set.has(name)).map((name) => FLEET_TOOL_SPECS[name]);
|
|
499
499
|
}
|
|
500
500
|
//#endregion
|
|
501
|
-
//#region src/agent/tools/
|
|
501
|
+
//#region src/agent/tools/_client-packs.ts
|
|
502
502
|
/**
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* instead of a single SandboxInstance because fleet lifecycle is multi-
|
|
506
|
-
* machine and outlives any one sandbox handle.
|
|
507
|
-
*
|
|
508
|
-
* Fleet tools default-OFF in the agent's allow-list discipline: the
|
|
509
|
-
* operator passes `allow: ["sandbox_fleet_spawn", "sandbox_fleet_dispatch", ...]`
|
|
510
|
-
* to opt in. This is a cost gate — a single `sandbox_fleet_spawn({workers: 16})`
|
|
511
|
-
* provisions 17 sandboxes (16 workers + 1 coordinator) and bills linearly.
|
|
512
|
-
*
|
|
513
|
-
* Operationally: the agent threads `fleetId` through its tool-use history.
|
|
514
|
-
* After a `sandbox_fleet_spawn` returns `{fleetId, machineIds}`, every
|
|
515
|
-
* subsequent fleet call carries that `fleetId`. The agent is also
|
|
516
|
-
* responsible for calling `sandbox_fleet_destroy` when the campaign ends;
|
|
517
|
-
* orphaned fleets keep accruing cost.
|
|
503
|
+
* Anthropic and OpenAI tool packs for specs bound to a Sandbox client rather
|
|
504
|
+
* than one SandboxInstance: the fleet and lifecycle packs share this dispatch.
|
|
518
505
|
*/
|
|
519
|
-
function
|
|
520
|
-
const
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
506
|
+
function buildClientToolHandlers(specs, ctx) {
|
|
507
|
+
const handlers = /* @__PURE__ */ new Map();
|
|
508
|
+
for (const spec of specs) handlers.set(spec.name, spec.makeHandler(ctx));
|
|
509
|
+
return handlers;
|
|
510
|
+
}
|
|
511
|
+
function errorMessage(err) {
|
|
512
|
+
return err instanceof Error ? err.message : String(err);
|
|
513
|
+
}
|
|
514
|
+
/** `kind` names the pack in unknown-tool errors ("fleet", "lifecycle"). */
|
|
515
|
+
function anthropicClientToolPack(kind, specs, ctx) {
|
|
516
|
+
const handlers = buildClientToolHandlers(specs, ctx);
|
|
525
517
|
return {
|
|
526
518
|
tools: specs.map((s) => ({
|
|
527
519
|
name: s.name,
|
|
@@ -533,33 +525,28 @@ function anthropicFleetTools(client, options = {}) {
|
|
|
533
525
|
if (!h) return {
|
|
534
526
|
type: "tool_result",
|
|
535
527
|
tool_use_id: block.id,
|
|
536
|
-
content: `Unknown
|
|
528
|
+
content: `Unknown ${kind} tool: ${block.name}`,
|
|
537
529
|
is_error: true
|
|
538
530
|
};
|
|
539
531
|
try {
|
|
540
|
-
const result = await h(block.input);
|
|
541
532
|
return {
|
|
542
533
|
type: "tool_result",
|
|
543
534
|
tool_use_id: block.id,
|
|
544
|
-
content: serializeToolResult(
|
|
535
|
+
content: serializeToolResult(await h(block.input))
|
|
545
536
|
};
|
|
546
537
|
} catch (err) {
|
|
547
538
|
return {
|
|
548
539
|
type: "tool_result",
|
|
549
540
|
tool_use_id: block.id,
|
|
550
|
-
content:
|
|
541
|
+
content: errorMessage(err),
|
|
551
542
|
is_error: true
|
|
552
543
|
};
|
|
553
544
|
}
|
|
554
545
|
}
|
|
555
546
|
};
|
|
556
547
|
}
|
|
557
|
-
function
|
|
558
|
-
const
|
|
559
|
-
const handlers = buildFleetHandlers(specs, {
|
|
560
|
-
client,
|
|
561
|
-
parent: options.parent
|
|
562
|
-
});
|
|
548
|
+
function openaiClientToolPack(kind, specs, ctx) {
|
|
549
|
+
const handlers = buildClientToolHandlers(specs, ctx);
|
|
563
550
|
return {
|
|
564
551
|
tools: specs.map((s) => ({
|
|
565
552
|
type: "function",
|
|
@@ -574,7 +561,7 @@ function openaiFleetTools(client, options = {}) {
|
|
|
574
561
|
if (!h) return {
|
|
575
562
|
role: "tool",
|
|
576
563
|
tool_call_id: call.id,
|
|
577
|
-
content: JSON.stringify({ error: `Unknown
|
|
564
|
+
content: JSON.stringify({ error: `Unknown ${kind} tool: ${call.function.name}` })
|
|
578
565
|
};
|
|
579
566
|
let args = {};
|
|
580
567
|
try {
|
|
@@ -582,22 +569,52 @@ function openaiFleetTools(client, options = {}) {
|
|
|
582
569
|
if (v && typeof v === "object") args = v;
|
|
583
570
|
} catch {}
|
|
584
571
|
try {
|
|
585
|
-
const result = await h(args);
|
|
586
572
|
return {
|
|
587
573
|
role: "tool",
|
|
588
574
|
tool_call_id: call.id,
|
|
589
|
-
content: serializeToolResult(
|
|
575
|
+
content: serializeToolResult(await h(args))
|
|
590
576
|
};
|
|
591
577
|
} catch (err) {
|
|
592
578
|
return {
|
|
593
579
|
role: "tool",
|
|
594
580
|
tool_call_id: call.id,
|
|
595
|
-
content: JSON.stringify({ error:
|
|
581
|
+
content: JSON.stringify({ error: errorMessage(err) })
|
|
596
582
|
};
|
|
597
583
|
}
|
|
598
584
|
}
|
|
599
585
|
};
|
|
600
586
|
}
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/agent/tools/fleet/index.ts
|
|
589
|
+
/**
|
|
590
|
+
* Fleet tool packs — one per framework. The shape mirrors the per-box
|
|
591
|
+
* packs (`anthropicTools`, `openaiTools`, etc.), bound to a Sandbox
|
|
592
|
+
* instead of a single SandboxInstance because fleet lifecycle is multi-
|
|
593
|
+
* machine and outlives any one sandbox handle.
|
|
594
|
+
*
|
|
595
|
+
* Fleet tools default-OFF in the agent's allow-list discipline: the
|
|
596
|
+
* operator passes `allow: ["sandbox_fleet_spawn", "sandbox_fleet_dispatch", ...]`
|
|
597
|
+
* to opt in. This is a cost gate — a single `sandbox_fleet_spawn({workers: 16})`
|
|
598
|
+
* provisions 17 sandboxes (16 workers + 1 coordinator) and bills linearly.
|
|
599
|
+
*
|
|
600
|
+
* Operationally: the agent threads `fleetId` through its tool-use history.
|
|
601
|
+
* After a `sandbox_fleet_spawn` returns `{fleetId, machineIds}`, every
|
|
602
|
+
* subsequent fleet call carries that `fleetId`. The agent is also
|
|
603
|
+
* responsible for calling `sandbox_fleet_destroy` when the campaign ends;
|
|
604
|
+
* orphaned fleets keep accruing cost.
|
|
605
|
+
*/
|
|
606
|
+
function anthropicFleetTools(client, options = {}) {
|
|
607
|
+
return anthropicClientToolPack("fleet", selectFleetSpecs(options.allow), {
|
|
608
|
+
client,
|
|
609
|
+
parent: options.parent
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function openaiFleetTools(client, options = {}) {
|
|
613
|
+
return openaiClientToolPack("fleet", selectFleetSpecs(options.allow), {
|
|
614
|
+
client,
|
|
615
|
+
parent: options.parent
|
|
616
|
+
});
|
|
617
|
+
}
|
|
601
618
|
async function vercelAiFleetTools(client, options = {}) {
|
|
602
619
|
let ai;
|
|
603
620
|
try {
|
|
@@ -606,7 +623,7 @@ async function vercelAiFleetTools(client, options = {}) {
|
|
|
606
623
|
throw new Error("vercelAiFleetTools(): the `ai` package is not installed. Install via `pnpm add ai`.");
|
|
607
624
|
}
|
|
608
625
|
const specs = selectFleetSpecs(options.allow);
|
|
609
|
-
const handlers =
|
|
626
|
+
const handlers = buildClientToolHandlers(specs, {
|
|
610
627
|
client,
|
|
611
628
|
parent: options.parent
|
|
612
629
|
});
|
|
@@ -630,7 +647,7 @@ async function mastraFleetTools(client, options = {}) {
|
|
|
630
647
|
throw new Error("mastraFleetTools(): the `@mastra/core` package is not installed. Install via `pnpm add @mastra/core`.");
|
|
631
648
|
}
|
|
632
649
|
const specs = selectFleetSpecs(options.allow);
|
|
633
|
-
const handlers =
|
|
650
|
+
const handlers = buildClientToolHandlers(specs, {
|
|
634
651
|
client,
|
|
635
652
|
parent: options.parent
|
|
636
653
|
});
|
|
@@ -647,11 +664,6 @@ async function mastraFleetTools(client, options = {}) {
|
|
|
647
664
|
});
|
|
648
665
|
return result;
|
|
649
666
|
}
|
|
650
|
-
function buildFleetHandlers(specs, ctx) {
|
|
651
|
-
const m = /* @__PURE__ */ new Map();
|
|
652
|
-
for (const spec of specs) m.set(spec.name, spec.makeHandler(ctx));
|
|
653
|
-
return m;
|
|
654
|
-
}
|
|
655
667
|
const LIFECYCLE_TOOL_SPECS = {
|
|
656
668
|
sandbox_create: {
|
|
657
669
|
name: "sandbox_create",
|
|
@@ -757,85 +769,10 @@ function selectLifecycleSpecs(allow) {
|
|
|
757
769
|
//#endregion
|
|
758
770
|
//#region src/agent/tools/lifecycle/index.ts
|
|
759
771
|
function anthropicLifecycleTools(client, options = {}) {
|
|
760
|
-
|
|
761
|
-
const handlers = buildLifecycleHandlers(specs, { client });
|
|
762
|
-
return {
|
|
763
|
-
tools: specs.map((s) => ({
|
|
764
|
-
name: s.name,
|
|
765
|
-
description: s.description,
|
|
766
|
-
input_schema: s.inputSchema
|
|
767
|
-
})),
|
|
768
|
-
async handleToolUse(block) {
|
|
769
|
-
const h = handlers.get(block.name);
|
|
770
|
-
if (!h) return {
|
|
771
|
-
type: "tool_result",
|
|
772
|
-
tool_use_id: block.id,
|
|
773
|
-
content: `Unknown lifecycle tool: ${block.name}`,
|
|
774
|
-
is_error: true
|
|
775
|
-
};
|
|
776
|
-
try {
|
|
777
|
-
const result = await h(block.input);
|
|
778
|
-
return {
|
|
779
|
-
type: "tool_result",
|
|
780
|
-
tool_use_id: block.id,
|
|
781
|
-
content: serializeToolResult(result)
|
|
782
|
-
};
|
|
783
|
-
} catch (err) {
|
|
784
|
-
return {
|
|
785
|
-
type: "tool_result",
|
|
786
|
-
tool_use_id: block.id,
|
|
787
|
-
content: err instanceof Error ? err.message : String(err),
|
|
788
|
-
is_error: true
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
};
|
|
772
|
+
return anthropicClientToolPack("lifecycle", selectLifecycleSpecs(options.allow), { client });
|
|
793
773
|
}
|
|
794
774
|
function openaiLifecycleTools(client, options = {}) {
|
|
795
|
-
|
|
796
|
-
const handlers = buildLifecycleHandlers(specs, { client });
|
|
797
|
-
return {
|
|
798
|
-
tools: specs.map((s) => ({
|
|
799
|
-
type: "function",
|
|
800
|
-
function: {
|
|
801
|
-
name: s.name,
|
|
802
|
-
description: s.description,
|
|
803
|
-
parameters: s.inputSchema
|
|
804
|
-
}
|
|
805
|
-
})),
|
|
806
|
-
async handleToolCall(call) {
|
|
807
|
-
const h = handlers.get(call.function.name);
|
|
808
|
-
if (!h) return {
|
|
809
|
-
role: "tool",
|
|
810
|
-
tool_call_id: call.id,
|
|
811
|
-
content: JSON.stringify({ error: `Unknown lifecycle tool: ${call.function.name}` })
|
|
812
|
-
};
|
|
813
|
-
let args = {};
|
|
814
|
-
try {
|
|
815
|
-
const v = JSON.parse(call.function.arguments || "{}");
|
|
816
|
-
if (v && typeof v === "object") args = v;
|
|
817
|
-
} catch {}
|
|
818
|
-
try {
|
|
819
|
-
const result = await h(args);
|
|
820
|
-
return {
|
|
821
|
-
role: "tool",
|
|
822
|
-
tool_call_id: call.id,
|
|
823
|
-
content: serializeToolResult(result)
|
|
824
|
-
};
|
|
825
|
-
} catch (err) {
|
|
826
|
-
return {
|
|
827
|
-
role: "tool",
|
|
828
|
-
tool_call_id: call.id,
|
|
829
|
-
content: JSON.stringify({ error: err instanceof Error ? err.message : String(err) })
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
function buildLifecycleHandlers(specs, ctx) {
|
|
836
|
-
const m = /* @__PURE__ */ new Map();
|
|
837
|
-
for (const spec of specs) m.set(spec.name, spec.makeHandler(ctx));
|
|
838
|
-
return m;
|
|
775
|
+
return openaiClientToolPack("lifecycle", selectLifecycleSpecs(options.allow), { client });
|
|
839
776
|
}
|
|
840
777
|
//#endregion
|
|
841
778
|
//#region src/agent/tools/mastra.ts
|
package/dist/agent/preview.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-
|
|
1
|
+
import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-v6cnh4Wq.js";
|
|
2
2
|
export { AgentPreviewError, AgentPreviewOptions, PREVIEW_MCP_ALIAS, PREVIEW_TOOLS, PreviewAuthorizationRequest, PreviewAuthorizer, PreviewExecutionContext, PreviewTool, PublishAgentPreviewOptions, assertPreviewId, ensureAgentPreview, getAgentPreview, listAgentPreviews, previewOperationTool, previewToolsForProfile, publishAgentPreview, removeAgentPreview, resolveSelfSandbox, servePreviewMcp };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ji as AgentQuestionRequest, Xi as AgentToolInvocation, Yi as AgentRunStatus, fa as SandboxEvent, na as DurablePlanSnapshot, qi as AgentApprovalRequirement } from "./types-
|
|
1
|
+
import { Ji as AgentQuestionRequest, Xi as AgentToolInvocation, Yi as AgentRunStatus, fa as SandboxEvent, na as DurablePlanSnapshot, qi as AgentApprovalRequirement } from "./types-8xXvGZNO.js";
|
|
2
2
|
import { InteractionRequest } from "@tangle-network/agent-interface";
|
|
3
3
|
|
|
4
4
|
//#region src/agent-run-outcome.d.ts
|
package/dist/auth/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema } from "../cli-auth-bundle-
|
|
1
|
+
import { i as materializeCliAuthBundle, n as assertCliAuthReferenceSupported, r as cliAuthReferenceSchema } from "../cli-auth-bundle-Ymv99-5G.js";
|
|
2
2
|
//#region src/auth/tokens.ts
|
|
3
3
|
const textEncoder = new TextEncoder();
|
|
4
4
|
const textDecoder = new TextDecoder();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { O as FILE_UPLOAD_SESSION_MAX_BYTES } from "./errors-CfQHPcLX.js";
|
|
2
|
-
import { a as planCompression, i as partCount, n as commitSession, o as putPart, r as initUploadSession, t as abortSession } from "./chunked-upload-
|
|
2
|
+
import { a as planCompression, i as partCount, n as commitSession, o as putPart, r as initUploadSession, t as abortSession } from "./chunked-upload-D1DL0f88.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { open } from "node:fs/promises";
|
|
5
5
|
//#region src/lib/chunked-upload-file.ts
|