@tangle-network/sandbox 0.13.0-develop.20260726140131.65bdb24 → 0.13.0-develop.20260726161607.1f7da8b
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 +254 -1295
- package/dist/agent/index.d.ts +11 -11
- package/dist/auth/index.d.ts +1 -1
- package/dist/{client-BDejoJQR.d.ts → client-CdpU6vjj.d.ts} +23 -28
- package/dist/{client-DS8qSxCp.js → client-Cz6oQM1P.js} +86 -78
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/core.d.ts +5 -5
- package/dist/core.js +3 -3
- package/dist/{index-DwjU-4s_.d.ts → index-Cl5Vyyz7.d.ts} +2 -2
- package/dist/index.d.ts +3323 -516
- package/dist/index.js +271 -328
- package/dist/intelligence/index.d.ts +2 -2
- package/dist/intelligence/index.js +3 -3
- package/dist/local-cli-auth-DHBoF3wi.js +35 -0
- package/dist/openai/index.d.ts +1 -1
- package/dist/{runtime-api-BFtk4_HK.js → runtime-api-fZ4UDwOY.js} +30 -17
- package/dist/runtime.d.ts +2 -3
- package/dist/runtime.js +1 -1
- package/dist/{sandbox-CxflW4z4.d.ts → sandbox-Bz7kCFtN.d.ts} +11 -78
- package/dist/{sandbox-DXuuroty.js → sandbox-kHfb3J4x.js} +36 -217
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-46aLycNc.js → tangle-BdbEHJRy.js} +9 -31
- package/dist/{types-DFYV3JSL.d.ts → types-Ch78hv3k.d.ts} +218 -331
- package/package.json +5 -3
- /package/dist/{errors-C8HMx78o.d.ts → errors-BzMmpmqU.d.ts} +0 -0
- /package/dist/{index-DKzapw-9.d.ts → index-Cp1KYanB.d.ts} +0 -0
- /package/dist/{index-CyHojkuA.d.ts → index-DtRFVx5U.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as backendTypeSchema, u as normalizeRuntimeBackendConfig } from "./runtime-api-fZ4UDwOY.js";
|
|
2
2
|
import { a as NotFoundError, c as SandboxError, d as TimeoutError, f as ValidationError, i as NetworkError, l as ServerError, n as CapabilityError, o as PartialFailureError, r as EgressProxyRecoveryError, s as QuotaError, t as AuthError, u as StateError } from "./errors-D9fFOWX9.js";
|
|
3
|
-
import { _ as otelTraceIdForTangleTrace, a as TERMINAL_WS_ECHO_SUBPROTOCOL, c as SandboxTaskSession, d as applySandboxEventText, f as collectAgentResponseText, g as exportTraceBundle, h as buildTraceExportPayload, i as WorkspaceImages, l as SandboxSession, o as TerminalStream, p as getSandboxEventText, s as TerminalStreamError, t as SandboxInstance, u as InteractiveSessionHandle, v as toOtelJson, y as parseSSEStream } from "./sandbox-
|
|
4
|
-
import { a as splitInlineProfileSkills, c as SandboxFleetClient, i as splitInlineProfileFileMounts, n as
|
|
3
|
+
import { _ as otelTraceIdForTangleTrace, a as TERMINAL_WS_ECHO_SUBPROTOCOL, c as SandboxTaskSession, d as applySandboxEventText, f as collectAgentResponseText, g as exportTraceBundle, h as buildTraceExportPayload, i as WorkspaceImages, l as SandboxSession, o as TerminalStream, p as getSandboxEventText, s as TerminalStreamError, t as SandboxInstance, u as InteractiveSessionHandle, v as toOtelJson, y as parseSSEStream } from "./sandbox-kHfb3J4x.js";
|
|
4
|
+
import { a as splitInlineProfileSkills, c as SandboxFleetClient, i as splitInlineProfileFileMounts, n as Sandbox, o as validateDeferredProfileFileMounts, r as materializeProfileFileMounts, s as SandboxFleet, t as IntelligenceClient } from "./client-Cz6oQM1P.js";
|
|
5
5
|
import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-DdD_rFZQ.js";
|
|
6
|
-
import { t as TangleSandboxClient } from "./tangle-
|
|
7
|
-
import { SANDBOX_SIZE_PRESET_NAMES } from "@tangle-network/agent-interface";
|
|
6
|
+
import { t as TangleSandboxClient } from "./tangle-BdbEHJRy.js";
|
|
7
|
+
import { SANDBOX_SIZE_PRESET_NAMES, agentProfileConfidentialSchema, agentProfileSchema } from "@tangle-network/agent-interface";
|
|
8
|
+
import { z } from "zod";
|
|
8
9
|
//#region src/confidential.ts
|
|
9
10
|
function generateAttestationNonce(bytes = 32) {
|
|
10
11
|
const buffer = new Uint8Array(bytes);
|
|
@@ -612,86 +613,285 @@ const GPU_LEASE_PROVIDER_NAMES = [
|
|
|
612
613
|
//#endregion
|
|
613
614
|
//#region src/manage-sandboxes.ts
|
|
614
615
|
const MANAGE_SANDBOXES_TOOL_NAME = "manageSandboxes";
|
|
616
|
+
const nonEmptyStringSchema = z.string().min(1);
|
|
617
|
+
const fleetIdSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/);
|
|
618
|
+
const sandboxIdSchema = z.string().min(1).max(128);
|
|
619
|
+
const leaseIdSchema = z.string().min(1).max(128);
|
|
620
|
+
const envSchema = z.record(z.string(), z.string());
|
|
621
|
+
const metadataSchema = z.record(z.string(), z.unknown());
|
|
622
|
+
const acceleratorSchema = z.strictObject({
|
|
623
|
+
kind: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).describe("Accelerator kind such as gpu, nvidia, nvidia-l4, or nvidia-h100."),
|
|
624
|
+
count: z.number().int().min(1).max(16).optional(),
|
|
625
|
+
memoryMB: z.number().int().positive().optional()
|
|
626
|
+
});
|
|
627
|
+
const resourcesSchema = z.strictObject({
|
|
628
|
+
cpuCores: z.number().positive().optional(),
|
|
629
|
+
memoryMB: z.number().int().positive().optional(),
|
|
630
|
+
diskGB: z.number().int().positive().optional(),
|
|
631
|
+
accelerator: acceleratorSchema.optional()
|
|
632
|
+
});
|
|
633
|
+
const driverBaseShape = {
|
|
634
|
+
enableCriu: z.boolean().optional(),
|
|
635
|
+
preferredRegion: nonEmptyStringSchema.optional()
|
|
636
|
+
};
|
|
637
|
+
const driverSchema = z.discriminatedUnion("type", [z.strictObject({
|
|
638
|
+
type: z.literal("host-agent"),
|
|
639
|
+
runtimeBackend: z.enum(["docker", "firecracker"]).optional(),
|
|
640
|
+
...driverBaseShape
|
|
641
|
+
}), z.strictObject({
|
|
642
|
+
type: z.enum([
|
|
643
|
+
"docker",
|
|
644
|
+
"firecracker",
|
|
645
|
+
"tangle"
|
|
646
|
+
]),
|
|
647
|
+
...driverBaseShape
|
|
648
|
+
})]);
|
|
649
|
+
const backendModelSchema = z.strictObject({
|
|
650
|
+
provider: nonEmptyStringSchema.optional(),
|
|
651
|
+
model: nonEmptyStringSchema.optional(),
|
|
652
|
+
baseUrl: nonEmptyStringSchema.optional(),
|
|
653
|
+
maxThinkingTokens: z.number().int().nonnegative().optional(),
|
|
654
|
+
mode: z.enum(["api", "cli"]).optional(),
|
|
655
|
+
authMode: z.enum(["api-key", "oauth"]).optional()
|
|
656
|
+
});
|
|
657
|
+
const backendSchema = z.strictObject({
|
|
658
|
+
type: backendTypeSchema,
|
|
659
|
+
profile: agentProfileSchema.optional(),
|
|
660
|
+
model: backendModelSchema.optional(),
|
|
661
|
+
server: z.strictObject({
|
|
662
|
+
port: z.number().int().min(1).max(65535).optional(),
|
|
663
|
+
hostname: nonEmptyStringSchema.optional()
|
|
664
|
+
}).optional(),
|
|
665
|
+
interactions: z.strictObject({
|
|
666
|
+
permission: z.boolean().optional(),
|
|
667
|
+
question: z.boolean().optional(),
|
|
668
|
+
plan: z.boolean().optional()
|
|
669
|
+
}).optional(),
|
|
670
|
+
metadata: z.strictObject({
|
|
671
|
+
containerType: nonEmptyStringSchema.optional(),
|
|
672
|
+
traceAttributes: envSchema.optional()
|
|
673
|
+
}).optional()
|
|
674
|
+
});
|
|
675
|
+
const createFragmentSchema = z.strictObject({
|
|
676
|
+
environment: nonEmptyStringSchema.optional(),
|
|
677
|
+
bare: z.boolean().optional(),
|
|
678
|
+
agent: z.boolean().optional(),
|
|
679
|
+
driver: driverSchema.optional(),
|
|
680
|
+
backend: backendSchema.optional(),
|
|
681
|
+
confidential: agentProfileConfidentialSchema.optional(),
|
|
682
|
+
egressPolicy: z.strictObject({
|
|
683
|
+
mode: z.enum([
|
|
684
|
+
"open",
|
|
685
|
+
"strict",
|
|
686
|
+
"blocked"
|
|
687
|
+
]),
|
|
688
|
+
allowDomains: z.array(nonEmptyStringSchema).optional(),
|
|
689
|
+
includeImplicitDomains: z.boolean().optional()
|
|
690
|
+
}).optional(),
|
|
691
|
+
git: z.strictObject({
|
|
692
|
+
url: nonEmptyStringSchema,
|
|
693
|
+
ref: nonEmptyStringSchema.optional(),
|
|
694
|
+
depth: z.number().int().positive().optional(),
|
|
695
|
+
sparse: z.array(nonEmptyStringSchema).optional()
|
|
696
|
+
}).optional(),
|
|
697
|
+
resources: resourcesSchema.optional(),
|
|
698
|
+
env: envSchema.optional(),
|
|
699
|
+
maxLifetimeSeconds: z.number().int().positive().optional(),
|
|
700
|
+
idleTimeoutSeconds: z.number().int().positive().optional(),
|
|
701
|
+
ephemeral: z.boolean().optional(),
|
|
702
|
+
fromSnapshot: nonEmptyStringSchema.optional(),
|
|
703
|
+
fromSandboxId: sandboxIdSchema.optional(),
|
|
704
|
+
templateId: nonEmptyStringSchema.optional(),
|
|
705
|
+
publicTemplateId: nonEmptyStringSchema.optional(),
|
|
706
|
+
publicTemplateVersionId: nonEmptyStringSchema.optional(),
|
|
707
|
+
secrets: z.array(nonEmptyStringSchema).optional(),
|
|
708
|
+
teamId: nonEmptyStringSchema.optional(),
|
|
709
|
+
capabilities: z.array(z.literal("computer_use")).optional(),
|
|
710
|
+
privacy: z.strictObject({
|
|
711
|
+
egress: z.enum([
|
|
712
|
+
"redact",
|
|
713
|
+
"block",
|
|
714
|
+
"off"
|
|
715
|
+
]).optional(),
|
|
716
|
+
logs: z.enum(["on", "off"]).optional()
|
|
717
|
+
}).optional(),
|
|
718
|
+
idempotencyKey: nonEmptyStringSchema.optional(),
|
|
719
|
+
autoMaterializeProfileFiles: z.boolean().optional(),
|
|
720
|
+
autoDeferProfile: z.boolean().optional()
|
|
721
|
+
});
|
|
722
|
+
const fleetMachineSchema = createFragmentSchema.extend({
|
|
723
|
+
machineId: fleetIdSchema,
|
|
724
|
+
name: nonEmptyStringSchema.optional(),
|
|
725
|
+
metadata: metadataSchema.optional(),
|
|
726
|
+
role: z.enum(["coordinator", "worker"]).optional()
|
|
727
|
+
});
|
|
728
|
+
const fleetCoordinatorSchema = createFragmentSchema.extend({
|
|
729
|
+
machineId: fleetIdSchema.optional(),
|
|
730
|
+
name: nonEmptyStringSchema.optional(),
|
|
731
|
+
metadata: metadataSchema.optional()
|
|
732
|
+
});
|
|
733
|
+
const fleetWorkspaceSchema = z.strictObject({
|
|
734
|
+
mode: z.enum(["isolated", "shared"]),
|
|
735
|
+
id: nonEmptyStringSchema.optional(),
|
|
736
|
+
quotaMb: z.number().int().positive().optional(),
|
|
737
|
+
mountPath: nonEmptyStringSchema.optional(),
|
|
738
|
+
snapshotId: nonEmptyStringSchema.optional()
|
|
739
|
+
});
|
|
740
|
+
const fleetCommonShape = {
|
|
741
|
+
fleetId: fleetIdSchema.optional(),
|
|
742
|
+
defaults: createFragmentSchema.optional(),
|
|
743
|
+
metadata: metadataSchema.optional(),
|
|
744
|
+
workspace: fleetWorkspaceSchema.optional(),
|
|
745
|
+
cleanupOnFailure: z.boolean().optional(),
|
|
746
|
+
maxConcurrentCreates: z.number().int().positive().optional(),
|
|
747
|
+
idempotencyKey: nonEmptyStringSchema.optional()
|
|
748
|
+
};
|
|
749
|
+
const fleetCreateOptionsSchema = z.strictObject({
|
|
750
|
+
...fleetCommonShape,
|
|
751
|
+
machines: z.array(fleetMachineSchema).min(1)
|
|
752
|
+
});
|
|
753
|
+
const fleetCreateWithCoordinatorOptionsSchema = z.strictObject({
|
|
754
|
+
...fleetCommonShape,
|
|
755
|
+
coordinator: fleetCoordinatorSchema.optional(),
|
|
756
|
+
workers: z.array(fleetMachineSchema).min(1)
|
|
757
|
+
});
|
|
758
|
+
const driverTimingsSchema = z.strictObject({
|
|
759
|
+
queueMs: z.number().nonnegative().optional(),
|
|
760
|
+
placementMs: z.number().nonnegative().optional(),
|
|
761
|
+
provisionMs: z.number().nonnegative().optional(),
|
|
762
|
+
startupMs: z.number().nonnegative().optional(),
|
|
763
|
+
cleanupMs: z.number().nonnegative().optional()
|
|
764
|
+
});
|
|
765
|
+
const attachMachineSchema = z.strictObject({
|
|
766
|
+
machineId: fleetIdSchema,
|
|
767
|
+
sandboxId: sandboxIdSchema,
|
|
768
|
+
status: nonEmptyStringSchema.optional(),
|
|
769
|
+
role: z.enum(["coordinator", "worker"]).optional(),
|
|
770
|
+
driverType: z.enum([
|
|
771
|
+
"docker",
|
|
772
|
+
"firecracker",
|
|
773
|
+
"host-agent",
|
|
774
|
+
"tangle"
|
|
775
|
+
]).optional(),
|
|
776
|
+
environment: nonEmptyStringSchema.optional(),
|
|
777
|
+
templateId: nonEmptyStringSchema.optional(),
|
|
778
|
+
publicTemplateId: nonEmptyStringSchema.optional(),
|
|
779
|
+
acceleratorCount: z.number().int().nonnegative().optional(),
|
|
780
|
+
driverTimings: driverTimingsSchema.optional()
|
|
781
|
+
});
|
|
782
|
+
const gpuProviderSchema = z.enum(GPU_LEASE_PROVIDER_NAMES);
|
|
783
|
+
const gpuLeaseAttachOptionsSchema = z.strictObject({
|
|
784
|
+
provider: gpuProviderSchema.optional(),
|
|
785
|
+
accelerator: acceleratorSchema,
|
|
786
|
+
image: nonEmptyStringSchema.optional(),
|
|
787
|
+
env: envSchema.optional()
|
|
788
|
+
});
|
|
789
|
+
const gpuLeaseCommandSchema = z.strictObject({
|
|
790
|
+
command: nonEmptyStringSchema,
|
|
791
|
+
timeoutMs: z.number().int().min(1).max(36e5).optional(),
|
|
792
|
+
cwd: nonEmptyStringSchema.optional(),
|
|
793
|
+
env: envSchema.optional()
|
|
794
|
+
});
|
|
795
|
+
const fleetReadActionSchema = z.strictObject({
|
|
796
|
+
action: z.enum([
|
|
797
|
+
"list",
|
|
798
|
+
"delete",
|
|
799
|
+
"manifest",
|
|
800
|
+
"usage",
|
|
801
|
+
"trace",
|
|
802
|
+
"intelligence",
|
|
803
|
+
"cost",
|
|
804
|
+
"createWorkspaceSnapshot",
|
|
805
|
+
"reconcileWorkspace"
|
|
806
|
+
]),
|
|
807
|
+
fleetId: fleetIdSchema
|
|
808
|
+
});
|
|
809
|
+
const manageSandboxesInputSchema = z.discriminatedUnion("action", [
|
|
810
|
+
z.strictObject({ action: z.literal("capabilities") }),
|
|
811
|
+
z.strictObject({
|
|
812
|
+
action: z.literal("create"),
|
|
813
|
+
options: fleetCreateOptionsSchema
|
|
814
|
+
}),
|
|
815
|
+
z.strictObject({
|
|
816
|
+
action: z.literal("createWithCoordinator"),
|
|
817
|
+
options: fleetCreateWithCoordinatorOptionsSchema
|
|
818
|
+
}),
|
|
819
|
+
fleetReadActionSchema,
|
|
820
|
+
z.strictObject({
|
|
821
|
+
action: z.literal("attachMachine"),
|
|
822
|
+
fleetId: fleetIdSchema,
|
|
823
|
+
machine: attachMachineSchema
|
|
824
|
+
}),
|
|
825
|
+
z.strictObject({
|
|
826
|
+
action: z.literal("detachMachine"),
|
|
827
|
+
fleetId: fleetIdSchema,
|
|
828
|
+
machineId: fleetIdSchema
|
|
829
|
+
}),
|
|
830
|
+
z.strictObject({
|
|
831
|
+
action: z.literal("restoreWorkspaceSnapshot"),
|
|
832
|
+
fleetId: fleetIdSchema,
|
|
833
|
+
snapshotId: nonEmptyStringSchema
|
|
834
|
+
}),
|
|
835
|
+
z.strictObject({
|
|
836
|
+
action: z.literal("attachGpuLease"),
|
|
837
|
+
sandboxId: sandboxIdSchema,
|
|
838
|
+
options: gpuLeaseAttachOptionsSchema
|
|
839
|
+
}),
|
|
840
|
+
z.strictObject({
|
|
841
|
+
action: z.literal("listGpuLeases"),
|
|
842
|
+
sandboxId: sandboxIdSchema
|
|
843
|
+
}),
|
|
844
|
+
z.strictObject({
|
|
845
|
+
action: z.literal("execGpuLease"),
|
|
846
|
+
sandboxId: sandboxIdSchema,
|
|
847
|
+
leaseId: leaseIdSchema,
|
|
848
|
+
command: gpuLeaseCommandSchema
|
|
849
|
+
}),
|
|
850
|
+
z.strictObject({
|
|
851
|
+
action: z.literal("detachGpuLease"),
|
|
852
|
+
sandboxId: sandboxIdSchema,
|
|
853
|
+
leaseId: leaseIdSchema
|
|
854
|
+
})
|
|
855
|
+
]);
|
|
856
|
+
const MANAGE_SANDBOXES_PARAMETERS = z.toJSONSchema(manageSandboxesInputSchema, { unrepresentable: "any" });
|
|
615
857
|
function createManageSandboxesTool(client, options = {}) {
|
|
616
858
|
return {
|
|
617
859
|
name: MANAGE_SANDBOXES_TOOL_NAME,
|
|
618
860
|
description: "Create, inspect, and manage sandbox fleets for parallel agent workloads.",
|
|
619
861
|
parameters: MANAGE_SANDBOXES_PARAMETERS,
|
|
620
862
|
async execute(input) {
|
|
621
|
-
|
|
863
|
+
const parsed = manageSandboxesInputSchema.parse(input);
|
|
864
|
+
switch (parsed.action) {
|
|
622
865
|
case "capabilities": return client.fleets.capabilities();
|
|
623
|
-
case "create": return client.fleets.create(applyFleetGpuPolicy(applyToolPolicy(
|
|
624
|
-
case "createWithCoordinator": return client.fleets.createWithCoordinator(applyFleetGpuPolicyToCoordinator(applyToolPolicy(
|
|
625
|
-
case "list": return client.fleets.list({ fleetId:
|
|
626
|
-
case "delete": return client.fleets.delete(
|
|
627
|
-
case "attachMachine": return client.fleets.attachMachine(
|
|
628
|
-
case "detachMachine": return client.fleets.detachMachine(
|
|
629
|
-
case "manifest": return client.fleets.manifest(
|
|
630
|
-
case "usage": return client.fleets.usage(
|
|
631
|
-
case "trace": return client.fleets.trace(
|
|
632
|
-
case "intelligence": return client.fleets.intelligence(
|
|
633
|
-
case "cost": return client.fleets.cost(
|
|
634
|
-
case "createWorkspaceSnapshot": return client.fleets.createWorkspaceSnapshot(
|
|
635
|
-
case "restoreWorkspaceSnapshot": return client.fleets.restoreWorkspaceSnapshot(
|
|
636
|
-
case "reconcileWorkspace": return client.fleets.reconcileWorkspace(
|
|
866
|
+
case "create": return client.fleets.create(applyFleetGpuPolicy(applyToolPolicy(parsed.options, options.policy), options.gpuPolicy));
|
|
867
|
+
case "createWithCoordinator": return client.fleets.createWithCoordinator(applyFleetGpuPolicyToCoordinator(applyToolPolicy(parsed.options, options.policy), options.gpuPolicy));
|
|
868
|
+
case "list": return client.fleets.list({ fleetId: parsed.fleetId });
|
|
869
|
+
case "delete": return client.fleets.delete(parsed.fleetId);
|
|
870
|
+
case "attachMachine": return client.fleets.attachMachine(parsed.fleetId, parsed.machine);
|
|
871
|
+
case "detachMachine": return client.fleets.detachMachine(parsed.fleetId, parsed.machineId);
|
|
872
|
+
case "manifest": return client.fleets.manifest(parsed.fleetId);
|
|
873
|
+
case "usage": return client.fleets.usage(parsed.fleetId);
|
|
874
|
+
case "trace": return client.fleets.trace(parsed.fleetId);
|
|
875
|
+
case "intelligence": return client.fleets.intelligence(parsed.fleetId);
|
|
876
|
+
case "cost": return client.fleets.cost(parsed.fleetId);
|
|
877
|
+
case "createWorkspaceSnapshot": return client.fleets.createWorkspaceSnapshot(parsed.fleetId);
|
|
878
|
+
case "restoreWorkspaceSnapshot": return client.fleets.restoreWorkspaceSnapshot(parsed.fleetId, parsed.snapshotId);
|
|
879
|
+
case "reconcileWorkspace": return client.fleets.reconcileWorkspace(parsed.fleetId);
|
|
637
880
|
case "attachGpuLease": {
|
|
638
|
-
const attachOptions = applyGpuToolPolicy(
|
|
639
|
-
return (await requireSandbox(client,
|
|
881
|
+
const attachOptions = applyGpuToolPolicy(parsed.options, options.gpuPolicy);
|
|
882
|
+
return (await requireSandbox(client, parsed.sandboxId)).gpu.attach(attachOptions);
|
|
640
883
|
}
|
|
641
|
-
case "listGpuLeases": return (await requireSandbox(client,
|
|
642
|
-
case "execGpuLease": return (await requireSandbox(client,
|
|
643
|
-
case "detachGpuLease": return (await requireSandbox(client,
|
|
644
|
-
default: throw new Error(`Unsupported manageSandboxes action: ${String(input.action)}`);
|
|
884
|
+
case "listGpuLeases": return (await requireSandbox(client, parsed.sandboxId)).gpu.list();
|
|
885
|
+
case "execGpuLease": return (await requireSandbox(client, parsed.sandboxId)).gpu.exec(parsed.leaseId, parsed.command);
|
|
886
|
+
case "detachGpuLease": return (await requireSandbox(client, parsed.sandboxId)).gpu.detach(parsed.leaseId);
|
|
645
887
|
}
|
|
646
888
|
}
|
|
647
889
|
};
|
|
648
890
|
}
|
|
649
|
-
function
|
|
650
|
-
const value = input[key];
|
|
651
|
-
if (typeof value !== "string" || value.length === 0) throw new Error(`manageSandboxes requires ${key}`);
|
|
652
|
-
return value;
|
|
653
|
-
}
|
|
654
|
-
function requireCreateOptions(input) {
|
|
655
|
-
const value = input.options;
|
|
656
|
-
if (!value || typeof value !== "object") throw new Error("manageSandboxes requires options");
|
|
657
|
-
const createOptions = rejectUserPolicy(value);
|
|
658
|
-
rejectRemovedCreateFields(createOptions);
|
|
659
|
-
return createOptions;
|
|
660
|
-
}
|
|
661
|
-
function requireCreateWithCoordinatorOptions(input) {
|
|
662
|
-
const value = input.options;
|
|
663
|
-
if (!value || typeof value !== "object") throw new Error("manageSandboxes requires options");
|
|
664
|
-
const createOptions = rejectUserPolicy(value);
|
|
665
|
-
rejectRemovedCreateFields(createOptions);
|
|
666
|
-
return createOptions;
|
|
667
|
-
}
|
|
668
|
-
const REMOVED_CREATE_FIELDS = [
|
|
669
|
-
"image",
|
|
670
|
-
"tools",
|
|
671
|
-
"permissions",
|
|
672
|
-
"network"
|
|
673
|
-
];
|
|
674
|
-
function rejectRemovedCreateFields(options) {
|
|
675
|
-
const candidates = [["defaults", options.defaults], ["coordinator", options.coordinator]];
|
|
676
|
-
for (const collectionName of ["machines", "workers"]) {
|
|
677
|
-
const collection = options[collectionName];
|
|
678
|
-
if (Array.isArray(collection)) collection.forEach((value, index) => {
|
|
679
|
-
candidates.push([`${collectionName}[${index}]`, value]);
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
for (const [location, value] of candidates) {
|
|
683
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
684
|
-
for (const field of REMOVED_CREATE_FIELDS) if (Object.hasOwn(value, field)) throw new Error(`manageSandboxes ${location}.${field} is not a create option`);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
function rejectUserPolicy(options) {
|
|
688
|
-
if ("policy" in options && options.policy !== void 0) throw new Error("manageSandboxes policy must be supplied by the tool host");
|
|
689
|
-
return options;
|
|
690
|
-
}
|
|
691
|
-
function applyToolPolicy(options, policy) {
|
|
891
|
+
function applyToolPolicy(createOptions, policy) {
|
|
692
892
|
if (!policy) throw new Error("manageSandboxes create requires a host-owned policy");
|
|
693
893
|
return {
|
|
694
|
-
...
|
|
894
|
+
...createOptions,
|
|
695
895
|
policy
|
|
696
896
|
};
|
|
697
897
|
}
|
|
@@ -710,7 +910,6 @@ function applyFleetGpuPolicyToCoordinator(options, gpuPolicy) {
|
|
|
710
910
|
};
|
|
711
911
|
}
|
|
712
912
|
function applyGpuPolicyToCreateFragment(fragment, gpuPolicy, label) {
|
|
713
|
-
if (fragment.gpuLease !== void 0) throw new Error("manageSandboxes GPU lease budget fields must be supplied by the tool host");
|
|
714
913
|
if (!fragment.resources?.accelerator) return fragment;
|
|
715
914
|
if (!gpuPolicy) throw new Error(`manageSandboxes ${label} requested accelerators but no host-owned GPU policy was supplied`);
|
|
716
915
|
return {
|
|
@@ -731,20 +930,6 @@ async function requireSandbox(client, sandboxId) {
|
|
|
731
930
|
if (!box) throw new Error(`Sandbox not found: ${sandboxId}`);
|
|
732
931
|
return box;
|
|
733
932
|
}
|
|
734
|
-
function requireGpuAttachOptions(input) {
|
|
735
|
-
const value = input.options;
|
|
736
|
-
if (!value || typeof value !== "object") throw new Error("manageSandboxes requires options");
|
|
737
|
-
const options = value;
|
|
738
|
-
for (const key of [
|
|
739
|
-
"maxSpendUsd",
|
|
740
|
-
"maxLifetimeSeconds",
|
|
741
|
-
"idleTimeoutSeconds"
|
|
742
|
-
]) if (key in options && options[key] !== void 0) throw new Error("manageSandboxes GPU lease budget fields must be supplied by the tool host");
|
|
743
|
-
const acceleratorValue = options.accelerator;
|
|
744
|
-
if (!acceleratorValue || typeof acceleratorValue !== "object") throw new Error("manageSandboxes GPU lease attach requires accelerator");
|
|
745
|
-
requireString(acceleratorValue, "kind");
|
|
746
|
-
return value;
|
|
747
|
-
}
|
|
748
933
|
function applyGpuToolPolicy(options, policy) {
|
|
749
934
|
if (!policy) throw new Error("manageSandboxes GPU lease attach requires a host-owned policy");
|
|
750
935
|
const requestedProvider = options.provider;
|
|
@@ -760,248 +945,6 @@ function applyGpuToolPolicy(options, policy) {
|
|
|
760
945
|
...policy.idleTimeoutSeconds !== void 0 ? { idleTimeoutSeconds: policy.idleTimeoutSeconds } : {}
|
|
761
946
|
};
|
|
762
947
|
}
|
|
763
|
-
function requireGpuCommand(input) {
|
|
764
|
-
const value = input.command;
|
|
765
|
-
if (!value || typeof value !== "object") throw new Error("manageSandboxes requires command");
|
|
766
|
-
requireString(value, "command");
|
|
767
|
-
return value;
|
|
768
|
-
}
|
|
769
|
-
function requireMachine(input) {
|
|
770
|
-
const value = input.machine;
|
|
771
|
-
if (!value || typeof value !== "object") throw new Error("manageSandboxes requires machine");
|
|
772
|
-
const machine = value;
|
|
773
|
-
requireString(machine, "machineId");
|
|
774
|
-
requireString(machine, "sandboxId");
|
|
775
|
-
return value;
|
|
776
|
-
}
|
|
777
|
-
const fleetId = {
|
|
778
|
-
type: "string",
|
|
779
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"
|
|
780
|
-
};
|
|
781
|
-
const accelerator = {
|
|
782
|
-
type: "object",
|
|
783
|
-
additionalProperties: false,
|
|
784
|
-
required: ["kind"],
|
|
785
|
-
properties: {
|
|
786
|
-
kind: {
|
|
787
|
-
type: "string",
|
|
788
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]*$",
|
|
789
|
-
description: "Accelerator kind such as gpu, nvidia, nvidia-l4, or nvidia-h100."
|
|
790
|
-
},
|
|
791
|
-
count: {
|
|
792
|
-
type: "integer",
|
|
793
|
-
minimum: 1,
|
|
794
|
-
maximum: 16
|
|
795
|
-
},
|
|
796
|
-
memoryMB: {
|
|
797
|
-
type: "integer",
|
|
798
|
-
minimum: 1
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
const gpuLeaseAttachOptions = {
|
|
803
|
-
type: "object",
|
|
804
|
-
additionalProperties: false,
|
|
805
|
-
required: ["accelerator"],
|
|
806
|
-
properties: {
|
|
807
|
-
provider: {
|
|
808
|
-
type: "string",
|
|
809
|
-
enum: [...GPU_LEASE_PROVIDER_NAMES]
|
|
810
|
-
},
|
|
811
|
-
accelerator,
|
|
812
|
-
image: {
|
|
813
|
-
type: "string",
|
|
814
|
-
minLength: 1
|
|
815
|
-
},
|
|
816
|
-
env: {
|
|
817
|
-
type: "object",
|
|
818
|
-
additionalProperties: { type: "string" }
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
const gpuLeaseCommand = {
|
|
823
|
-
type: "object",
|
|
824
|
-
additionalProperties: false,
|
|
825
|
-
required: ["command"],
|
|
826
|
-
properties: {
|
|
827
|
-
command: {
|
|
828
|
-
type: "string",
|
|
829
|
-
minLength: 1
|
|
830
|
-
},
|
|
831
|
-
timeoutMs: {
|
|
832
|
-
type: "integer",
|
|
833
|
-
minimum: 1,
|
|
834
|
-
maximum: 36e5
|
|
835
|
-
},
|
|
836
|
-
cwd: {
|
|
837
|
-
type: "string",
|
|
838
|
-
minLength: 1
|
|
839
|
-
},
|
|
840
|
-
env: {
|
|
841
|
-
type: "object",
|
|
842
|
-
additionalProperties: { type: "string" }
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
};
|
|
846
|
-
const resources = {
|
|
847
|
-
type: "object",
|
|
848
|
-
additionalProperties: false,
|
|
849
|
-
properties: {
|
|
850
|
-
cpuCores: {
|
|
851
|
-
type: "number",
|
|
852
|
-
exclusiveMinimum: 0
|
|
853
|
-
},
|
|
854
|
-
memoryMB: {
|
|
855
|
-
type: "integer",
|
|
856
|
-
minimum: 1
|
|
857
|
-
},
|
|
858
|
-
diskGB: {
|
|
859
|
-
type: "integer",
|
|
860
|
-
minimum: 1
|
|
861
|
-
},
|
|
862
|
-
accelerator
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
const driver = {
|
|
866
|
-
type: "object",
|
|
867
|
-
additionalProperties: true,
|
|
868
|
-
properties: {
|
|
869
|
-
type: {
|
|
870
|
-
type: "string",
|
|
871
|
-
enum: [
|
|
872
|
-
"docker",
|
|
873
|
-
"firecracker",
|
|
874
|
-
"host-agent",
|
|
875
|
-
"tangle"
|
|
876
|
-
]
|
|
877
|
-
},
|
|
878
|
-
runtimeBackend: {
|
|
879
|
-
type: "string",
|
|
880
|
-
enum: ["docker", "firecracker"]
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
};
|
|
884
|
-
const fleetMachineSpec = {
|
|
885
|
-
type: "object",
|
|
886
|
-
additionalProperties: true,
|
|
887
|
-
required: ["machineId"],
|
|
888
|
-
properties: {
|
|
889
|
-
machineId: fleetId,
|
|
890
|
-
name: {
|
|
891
|
-
type: "string",
|
|
892
|
-
minLength: 1
|
|
893
|
-
},
|
|
894
|
-
role: {
|
|
895
|
-
type: "string",
|
|
896
|
-
enum: ["coordinator", "worker"]
|
|
897
|
-
},
|
|
898
|
-
environment: {
|
|
899
|
-
type: "string",
|
|
900
|
-
minLength: 1
|
|
901
|
-
},
|
|
902
|
-
resources,
|
|
903
|
-
driver
|
|
904
|
-
}
|
|
905
|
-
};
|
|
906
|
-
const MANAGE_SANDBOXES_PARAMETERS = {
|
|
907
|
-
type: "object",
|
|
908
|
-
additionalProperties: false,
|
|
909
|
-
required: ["action"],
|
|
910
|
-
properties: {
|
|
911
|
-
action: {
|
|
912
|
-
type: "string",
|
|
913
|
-
enum: [
|
|
914
|
-
"capabilities",
|
|
915
|
-
"create",
|
|
916
|
-
"createWithCoordinator",
|
|
917
|
-
"list",
|
|
918
|
-
"delete",
|
|
919
|
-
"attachMachine",
|
|
920
|
-
"detachMachine",
|
|
921
|
-
"manifest",
|
|
922
|
-
"usage",
|
|
923
|
-
"trace",
|
|
924
|
-
"intelligence",
|
|
925
|
-
"cost",
|
|
926
|
-
"createWorkspaceSnapshot",
|
|
927
|
-
"restoreWorkspaceSnapshot",
|
|
928
|
-
"reconcileWorkspace",
|
|
929
|
-
"attachGpuLease",
|
|
930
|
-
"listGpuLeases",
|
|
931
|
-
"execGpuLease",
|
|
932
|
-
"detachGpuLease"
|
|
933
|
-
]
|
|
934
|
-
},
|
|
935
|
-
fleetId,
|
|
936
|
-
machineId: fleetId,
|
|
937
|
-
sandboxId: {
|
|
938
|
-
type: "string",
|
|
939
|
-
minLength: 1,
|
|
940
|
-
maxLength: 128
|
|
941
|
-
},
|
|
942
|
-
leaseId: {
|
|
943
|
-
type: "string",
|
|
944
|
-
minLength: 1,
|
|
945
|
-
maxLength: 128
|
|
946
|
-
},
|
|
947
|
-
snapshotId: {
|
|
948
|
-
type: "string",
|
|
949
|
-
minLength: 1
|
|
950
|
-
},
|
|
951
|
-
options: { anyOf: [{
|
|
952
|
-
type: "object",
|
|
953
|
-
additionalProperties: true,
|
|
954
|
-
properties: {
|
|
955
|
-
fleetId,
|
|
956
|
-
defaults: {
|
|
957
|
-
type: "object",
|
|
958
|
-
additionalProperties: true,
|
|
959
|
-
properties: {
|
|
960
|
-
environment: {
|
|
961
|
-
type: "string",
|
|
962
|
-
minLength: 1
|
|
963
|
-
},
|
|
964
|
-
resources,
|
|
965
|
-
driver
|
|
966
|
-
}
|
|
967
|
-
},
|
|
968
|
-
machines: {
|
|
969
|
-
type: "array",
|
|
970
|
-
items: fleetMachineSpec,
|
|
971
|
-
minItems: 1
|
|
972
|
-
},
|
|
973
|
-
workers: {
|
|
974
|
-
type: "array",
|
|
975
|
-
items: fleetMachineSpec,
|
|
976
|
-
minItems: 1
|
|
977
|
-
},
|
|
978
|
-
coordinator: fleetMachineSpec,
|
|
979
|
-
workspace: {
|
|
980
|
-
type: "object",
|
|
981
|
-
additionalProperties: true,
|
|
982
|
-
properties: { mode: {
|
|
983
|
-
type: "string",
|
|
984
|
-
enum: ["isolated", "shared"]
|
|
985
|
-
} }
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}, gpuLeaseAttachOptions] },
|
|
989
|
-
command: gpuLeaseCommand,
|
|
990
|
-
machine: {
|
|
991
|
-
type: "object",
|
|
992
|
-
required: ["machineId", "sandboxId"],
|
|
993
|
-
additionalProperties: true,
|
|
994
|
-
properties: {
|
|
995
|
-
machineId: fleetId,
|
|
996
|
-
sandboxId: {
|
|
997
|
-
type: "string",
|
|
998
|
-
minLength: 1,
|
|
999
|
-
maxLength: 128
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
948
|
//#endregion
|
|
1006
949
|
//#region src/mcp.ts
|
|
1007
950
|
/**
|
|
@@ -1530,4 +1473,4 @@ function stripUndefined(value) {
|
|
|
1530
1473
|
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0).map(([k, v]) => [k, stripUndefined(v)]));
|
|
1531
1474
|
}
|
|
1532
1475
|
//#endregion
|
|
1533
|
-
export { AuthError, CONTROL_PLANE_MCP_SERVER_NAME, CapabilityError, CollaborationClient, CollaborationFileBridge, DEFAULT_SANDBOX_SIZE, EgressProxyRecoveryError, GPU_LEASE_PROVIDER_NAMES, Image, ImageBuilder, IntelligenceClient, InteractiveSessionHandle, MANAGE_SANDBOXES_PARAMETERS, MANAGE_SANDBOXES_TOOL_NAME, NetworkError, NotFoundError, PartialFailureError, QuotaError, SANDBOX_MCP_SERVER_NAME, SANDBOX_SIZE_PRESETS, SANDBOX_SIZE_PRESET_NAMES,
|
|
1476
|
+
export { AuthError, CONTROL_PLANE_MCP_SERVER_NAME, CapabilityError, CollaborationClient, CollaborationFileBridge, DEFAULT_SANDBOX_SIZE, EgressProxyRecoveryError, GPU_LEASE_PROVIDER_NAMES, Image, ImageBuilder, IntelligenceClient, InteractiveSessionHandle, MANAGE_SANDBOXES_PARAMETERS, MANAGE_SANDBOXES_TOOL_NAME, NetworkError, NotFoundError, PartialFailureError, QuotaError, SANDBOX_MCP_SERVER_NAME, SANDBOX_SIZE_PRESETS, SANDBOX_SIZE_PRESET_NAMES, Sandbox, SandboxError, SandboxFleet, SandboxFleetClient, SandboxInstance, SandboxSession, SandboxTaskSession, ServerError, StateError, TERMINAL_WS_ECHO_SUBPROTOCOL, TangleSandboxClient, TerminalStream, TerminalStreamError, TimeoutError, ValidationError, WorkspaceImages, applySandboxEventText, buildCollaborationDocumentId, buildControlPlaneMcpConfig, buildSandboxMcpConfig, buildTangleRouterEvalMatrixRequest, buildTangleRouterResponsesWebSearchRequest, buildTangleRouterSearchBackend, buildTangleRouterSearchProfile, buildTraceExportPayload, collectAgentResponseText, createConfidentialSandbox, createManageSandboxesTool, exportTraceBundle, fetchTangleRouterSearchConfig, generateAttestationNonce, generateDockerfile, getSandboxEventText, manageSandboxesInputSchema, materializeProfileFileMounts, normalizeCollaborationPath, normalizeRuntimeBackendConfig, otelTraceIdForTangleTrace, parseCollaborationDocumentId, parseSSEStream, resolveSandboxResources, runTangleRouterEvalMatrixInSandbox, sandboxResourcesForSize, splitInlineProfileFileMounts, splitInlineProfileSkills, startTeeAttestationHeartbeat, toOtelJson, validateDeferredProfileFileMounts };
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This is a SEPARATE host from the Sandbox API. The SDK's `IntelligenceClient`
|
|
8
8
|
* (exposed as `client.intelligence`) routes intelligence-*report* calls through
|
|
9
|
-
* `
|
|
9
|
+
* `Sandbox.fetch` against the **sandbox** `baseUrl` — that is the
|
|
10
10
|
* sandbox-api intelligence-report surface, a different service. The trace-read
|
|
11
11
|
* routes (`/v1/traces`, `/v1/runs*`, `/v1/sessions*`) live on intelligence-api
|
|
12
12
|
* and are tenant-scoped by the customer key, so this client does NOT reuse
|
|
13
|
-
* `
|
|
13
|
+
* `Sandbox.fetch`; it carries its own intelligence-host base URL.
|
|
14
14
|
*
|
|
15
15
|
* Auth is the customer key (`sk-tan-*`) sent as `Authorization: Bearer ...`;
|
|
16
16
|
* the platform resolves it to the caller's tenant and filters `tenant_id`
|
|
@@ -7,11 +7,11 @@ import { d as TimeoutError, i as NetworkError, p as parseErrorResponse } from ".
|
|
|
7
7
|
*
|
|
8
8
|
* This is a SEPARATE host from the Sandbox API. The SDK's `IntelligenceClient`
|
|
9
9
|
* (exposed as `client.intelligence`) routes intelligence-*report* calls through
|
|
10
|
-
* `
|
|
10
|
+
* `Sandbox.fetch` against the **sandbox** `baseUrl` — that is the
|
|
11
11
|
* sandbox-api intelligence-report surface, a different service. The trace-read
|
|
12
12
|
* routes (`/v1/traces`, `/v1/runs*`, `/v1/sessions*`) live on intelligence-api
|
|
13
13
|
* and are tenant-scoped by the customer key, so this client does NOT reuse
|
|
14
|
-
* `
|
|
14
|
+
* `Sandbox.fetch`; it carries its own intelligence-host base URL.
|
|
15
15
|
*
|
|
16
16
|
* Auth is the customer key (`sk-tan-*`) sent as `Authorization: Bearer ...`;
|
|
17
17
|
* the platform resolves it to the caller's tenant and filters `tenant_id`
|
|
@@ -63,7 +63,7 @@ function createIntelligenceClient(config) {
|
|
|
63
63
|
const baseUrl = (config.baseUrl ?? "https://intelligence.tangle.tools").replace(/\/$/, "");
|
|
64
64
|
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
65
65
|
/**
|
|
66
|
-
* One authenticated request. Mirrors `
|
|
66
|
+
* One authenticated request. Mirrors `Sandbox.fetch`: Bearer auth,
|
|
67
67
|
* an `AbortController` timeout that surfaces as `TimeoutError`, and a
|
|
68
68
|
* transport failure wrapped as `NetworkError`. Never reuses the sandbox
|
|
69
69
|
* `baseUrl` — this is the intelligence host.
|