@geminixiang/mikan 1.0.0-beta.23 → 1.0.0-beta.24

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/node_modules/agentic-sandbox-client/dist/commands/command-executor.d.ts +13 -0
  3. package/node_modules/agentic-sandbox-client/dist/commands/command-executor.d.ts.map +1 -0
  4. package/node_modules/agentic-sandbox-client/dist/commands/command-executor.js +88 -0
  5. package/node_modules/agentic-sandbox-client/dist/commands/command-executor.js.map +1 -0
  6. package/node_modules/agentic-sandbox-client/dist/commands/index.d.ts +2 -0
  7. package/node_modules/agentic-sandbox-client/dist/commands/index.d.ts.map +1 -0
  8. package/node_modules/agentic-sandbox-client/dist/commands/index.js +15 -0
  9. package/node_modules/agentic-sandbox-client/dist/commands/index.js.map +1 -0
  10. package/node_modules/agentic-sandbox-client/dist/constants.d.ts +28 -0
  11. package/node_modules/agentic-sandbox-client/dist/constants.d.ts.map +1 -0
  12. package/node_modules/agentic-sandbox-client/dist/constants.js +65 -0
  13. package/node_modules/agentic-sandbox-client/dist/constants.js.map +1 -0
  14. package/node_modules/agentic-sandbox-client/dist/exceptions.d.ts +67 -0
  15. package/node_modules/agentic-sandbox-client/dist/exceptions.d.ts.map +1 -0
  16. package/node_modules/agentic-sandbox-client/dist/exceptions.js +91 -0
  17. package/node_modules/agentic-sandbox-client/dist/exceptions.js.map +1 -0
  18. package/node_modules/agentic-sandbox-client/dist/extensions/computer-use.d.ts +18 -0
  19. package/node_modules/agentic-sandbox-client/dist/extensions/computer-use.d.ts.map +1 -0
  20. package/node_modules/agentic-sandbox-client/dist/extensions/computer-use.js +61 -0
  21. package/node_modules/agentic-sandbox-client/dist/extensions/computer-use.js.map +1 -0
  22. package/node_modules/agentic-sandbox-client/dist/extensions/index.d.ts +2 -0
  23. package/node_modules/agentic-sandbox-client/dist/extensions/index.d.ts.map +1 -0
  24. package/node_modules/agentic-sandbox-client/dist/extensions/index.js +15 -0
  25. package/node_modules/agentic-sandbox-client/dist/extensions/index.js.map +1 -0
  26. package/node_modules/agentic-sandbox-client/dist/files/filesystem.d.ts +14 -0
  27. package/node_modules/agentic-sandbox-client/dist/files/filesystem.d.ts.map +1 -0
  28. package/node_modules/agentic-sandbox-client/dist/files/filesystem.js +229 -0
  29. package/node_modules/agentic-sandbox-client/dist/files/filesystem.js.map +1 -0
  30. package/node_modules/agentic-sandbox-client/dist/files/index.d.ts +2 -0
  31. package/node_modules/agentic-sandbox-client/dist/files/index.d.ts.map +1 -0
  32. package/node_modules/agentic-sandbox-client/dist/files/index.js +15 -0
  33. package/node_modules/agentic-sandbox-client/dist/files/index.js.map +1 -0
  34. package/node_modules/agentic-sandbox-client/dist/index.d.ts +8 -0
  35. package/node_modules/agentic-sandbox-client/dist/index.d.ts.map +1 -0
  36. package/node_modules/agentic-sandbox-client/dist/index.js +20 -0
  37. package/node_modules/agentic-sandbox-client/dist/index.js.map +1 -0
  38. package/node_modules/agentic-sandbox-client/dist/response-utils.d.ts +34 -0
  39. package/node_modules/agentic-sandbox-client/dist/response-utils.d.ts.map +1 -0
  40. package/node_modules/agentic-sandbox-client/dist/response-utils.js +173 -0
  41. package/node_modules/agentic-sandbox-client/dist/response-utils.js.map +1 -0
  42. package/node_modules/agentic-sandbox-client/dist/sandbox-client.d.ts +100 -0
  43. package/node_modules/agentic-sandbox-client/dist/sandbox-client.d.ts.map +1 -0
  44. package/node_modules/agentic-sandbox-client/dist/sandbox-client.js +951 -0
  45. package/node_modules/agentic-sandbox-client/dist/sandbox-client.js.map +1 -0
  46. package/node_modules/agentic-sandbox-client/dist/sandbox.d.ts +144 -0
  47. package/node_modules/agentic-sandbox-client/dist/sandbox.d.ts.map +1 -0
  48. package/node_modules/agentic-sandbox-client/dist/sandbox.js +892 -0
  49. package/node_modules/agentic-sandbox-client/dist/sandbox.js.map +1 -0
  50. package/node_modules/agentic-sandbox-client/dist/trace-manager.d.ts +44 -0
  51. package/node_modules/agentic-sandbox-client/dist/trace-manager.d.ts.map +1 -0
  52. package/node_modules/agentic-sandbox-client/dist/trace-manager.js +185 -0
  53. package/node_modules/agentic-sandbox-client/dist/trace-manager.js.map +1 -0
  54. package/node_modules/agentic-sandbox-client/dist/types.d.ts +62 -0
  55. package/node_modules/agentic-sandbox-client/dist/types.d.ts.map +1 -0
  56. package/node_modules/agentic-sandbox-client/dist/types.js +15 -0
  57. package/node_modules/agentic-sandbox-client/dist/types.js.map +1 -0
  58. package/node_modules/agentic-sandbox-client/package.json +73 -0
  59. package/package.json +4 -1
package/CHANGELOG.md CHANGED
@@ -9,6 +9,17 @@ any release.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [1.0.0-beta.24]
13
+
14
+ ### Fixed
15
+
16
+ - Bundle the vendored Agent Sandbox SDK in the npm package so global installs no longer fail on a missing repository-local tarball.
17
+ - Reuse mikan's direct Kubernetes client dependency as an SDK peer instead of recursively bundling a duplicate dependency tree, keeping the published tarball under 1 MiB.
18
+
19
+ ### Tests
20
+
21
+ - Add a pack-install smoke test that imports the bundled SDK, runs the packed CLI, enforces a 2 MiB size ceiling, and gates both CI and npm publishing.
22
+
12
23
  ## [1.0.0-beta.23]
13
24
 
14
25
  ### Added
@@ -0,0 +1,13 @@
1
+ import type { Tracer } from "../trace-manager.js";
2
+ import type { CallOptions, ExecutionResult, RequestFn } from "../types.js";
3
+ /** @internal — exported for unit testing only; not part of the public API. */
4
+ export declare function extractExecutable(command: string): string;
5
+ export declare class CommandExecutor {
6
+ private requestFn;
7
+ private getTracer;
8
+ private getParentContext;
9
+ private traceServiceName;
10
+ constructor(requestFn: RequestFn, getTracer: () => Tracer | null, traceServiceName: string, getParentContext?: () => unknown);
11
+ run(command: string, options?: number | CallOptions): Promise<ExecutionResult>;
12
+ }
13
+ //# sourceMappingURL=command-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-executor.d.ts","sourceRoot":"","sources":["../../src/commands/command-executor.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkB3E,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQzD;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAS;gBAG/B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,EAC9B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,GAAE,MAAM,OAAoB;IAQxC,GAAG,CACP,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAC7B,OAAO,CAAC,eAAe,CAAC;CAmD5B"}
@@ -0,0 +1,88 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { posix } from "node:path";
15
+ import { MAX_ERROR_BODY_BYTES, MAX_EXECUTION_RESPONSE_SIZE, } from "../constants.js";
16
+ import { SandboxRequestError } from "../exceptions.js";
17
+ import { parseExecutionResult, readBoundedText } from "../response-utils.js";
18
+ import { withSpan } from "../trace-manager.js";
19
+ function normalizeCallOptions(arg, defaultTimeoutSec) {
20
+ if (typeof arg === "number") {
21
+ return { timeout: arg };
22
+ }
23
+ if (arg === undefined) {
24
+ return { timeout: defaultTimeoutSec };
25
+ }
26
+ return {
27
+ timeout: arg.timeout ?? defaultTimeoutSec,
28
+ signal: arg.signal,
29
+ };
30
+ }
31
+ /** @internal — exported for unit testing only; not part of the public API. */
32
+ export function extractExecutable(command) {
33
+ if (!command)
34
+ return "";
35
+ for (const field of command.split(/\s+/)) {
36
+ if (!field || (field.includes("=") && !field.split("=")[0].includes("/")))
37
+ continue;
38
+ return posix.basename(field);
39
+ }
40
+ return "";
41
+ }
42
+ export class CommandExecutor {
43
+ requestFn;
44
+ getTracer;
45
+ getParentContext;
46
+ traceServiceName;
47
+ constructor(requestFn, getTracer, traceServiceName, getParentContext = () => null) {
48
+ this.requestFn = requestFn;
49
+ this.getTracer = getTracer;
50
+ this.getParentContext = getParentContext;
51
+ this.traceServiceName = traceServiceName;
52
+ }
53
+ async run(command, options) {
54
+ const { timeout, signal } = normalizeCallOptions(options, 60);
55
+ return withSpan(this.getTracer(), this.traceServiceName, "run", async (span) => {
56
+ if (span.isRecording()) {
57
+ const executable = extractExecutable(command);
58
+ if (executable) {
59
+ span.setAttribute("sandbox.command.executable", executable);
60
+ }
61
+ }
62
+ const response = await this.requestFn("POST", "execute", {
63
+ body: JSON.stringify({ command }),
64
+ headers: { "Content-Type": "application/json" },
65
+ timeout,
66
+ signal,
67
+ maxRetries: 1, // command execution is non-idempotent; never retry
68
+ });
69
+ const rawText = await readBoundedText(response, MAX_EXECUTION_RESPONSE_SIZE, "execute");
70
+ let data;
71
+ try {
72
+ data = JSON.parse(rawText);
73
+ }
74
+ catch (err) {
75
+ const preview = rawText.length > MAX_ERROR_BODY_BYTES
76
+ ? `${[...rawText].slice(0, MAX_ERROR_BODY_BYTES).join("")}…`
77
+ : rawText;
78
+ throw new SandboxRequestError(`Failed to decode JSON response from sandbox: ${preview}`, { cause: err, operation: "execute" });
79
+ }
80
+ const result = parseExecutionResult(data);
81
+ if (span.isRecording()) {
82
+ span.setAttribute("sandbox.exit_code", result.exitCode);
83
+ }
84
+ return result;
85
+ }, this.getParentContext());
86
+ }
87
+ }
88
+ //# sourceMappingURL=command-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-executor.js","sourceRoot":"","sources":["../../src/commands/command-executor.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,SAAS,oBAAoB,CAC3B,GAAqC,EACrC,iBAAyB;IAEzB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACxC,CAAC;IACD,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,iBAAiB;QACzC,MAAM,EAAE,GAAG,CAAC,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC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AAE;gBACvD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;gBACjC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,OAAO;gBACP,MAAM;gBACN,UAAU,EAAE,CAAC,EAAE,mDAAmD;aACnE,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,eAAe,CACnC,QAAQ,EACR,2BAA2B,EAC3B,SAAS,CACV,CAAC;YACF,IAAI,IAAa,CAAC;YAClB,IAAI,CAAC;gBACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,OAAO,GACX,OAAO,CAAC,MAAM,GAAG,oBAAoB;oBACnC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG;oBAC5D,CAAC,CAAC,OAAO,CAAC;gBACd,MAAM,IAAI,mBAAmB,CAC3B,gDAAgD,OAAO,EAAE,EACzD,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CACrC,CAAC;YACJ,CAAC;YACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAE1C,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACvB,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,IAAI,CAAC,gBAAgB,EAAE,CACxB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export { CommandExecutor } from "./command-executor.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export { CommandExecutor } from "./command-executor.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,28 @@
1
+ export declare const GATEWAY_API_GROUP = "gateway.networking.k8s.io";
2
+ export declare const GATEWAY_API_VERSION = "v1";
3
+ export declare const GATEWAY_PLURAL = "gateways";
4
+ export declare const CLAIM_API_GROUP = "extensions.agents.x-k8s.io";
5
+ export declare const CLAIM_API_VERSION = "v1beta1";
6
+ export declare const CLAIM_PLURAL_NAME = "sandboxclaims";
7
+ export declare const SANDBOX_API_GROUP = "agents.x-k8s.io";
8
+ export declare const SANDBOX_API_VERSION = "v1beta1";
9
+ export declare const SANDBOX_PLURAL_NAME = "sandboxes";
10
+ export declare const POD_NAME_ANNOTATION = "agents.x-k8s.io/pod-name";
11
+ export declare const MAX_RETRIES = 6;
12
+ export declare const BACKOFF_FACTOR = 0.5;
13
+ export declare const MAX_BACKOFF_MS = 8000;
14
+ export declare const RETRY_STATUS_CODES: number[];
15
+ export declare const MAX_DRAIN_BYTES = 4096;
16
+ export declare const MAX_ERROR_BODY_BYTES = 512;
17
+ export declare const MAX_RECONNECT_ATTEMPTS = 3;
18
+ export declare const PER_ATTEMPT_TIMEOUT_MS = 60000;
19
+ export declare const HEADER_REQUEST_ID = "X-Request-ID";
20
+ export declare const MAX_GATEWAY_REWATCH = 10;
21
+ export declare const GATEWAY_PROBE_TIMEOUT_MS = 30000;
22
+ export declare const GATEWAY_PROBE_INTERVAL_MS = 500;
23
+ export declare const CLEANUP_TIMEOUT_MS = 5000;
24
+ export declare const MAX_EXECUTION_RESPONSE_SIZE: number;
25
+ export declare const MAX_METADATA_RESPONSE_SIZE: number;
26
+ export declare const MAX_DOWNLOAD_SIZE: number;
27
+ export declare const MAX_UPLOAD_SIZE: number;
28
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAC5D,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AACnD,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAM9D,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,cAAc,MAAM,CAAC;AAQlC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,kBAAkB,UAAuB,CAAC;AAGvD,eAAO,MAAM,eAAe,OAAO,CAAC;AAGpC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAGxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAKxC,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAG7C,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAGhD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAItC,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAG/C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAG7C,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAGxC,eAAO,MAAM,2BAA2B,QAAmB,CAAC;AAC5D,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,QAAoB,CAAC;AACnD,eAAO,MAAM,eAAe,QAAoB,CAAC"}
@@ -0,0 +1,65 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export const GATEWAY_API_GROUP = "gateway.networking.k8s.io";
15
+ export const GATEWAY_API_VERSION = "v1";
16
+ export const GATEWAY_PLURAL = "gateways";
17
+ export const CLAIM_API_GROUP = "extensions.agents.x-k8s.io";
18
+ export const CLAIM_API_VERSION = "v1beta1";
19
+ export const CLAIM_PLURAL_NAME = "sandboxclaims";
20
+ export const SANDBOX_API_GROUP = "agents.x-k8s.io";
21
+ export const SANDBOX_API_VERSION = "v1beta1";
22
+ export const SANDBOX_PLURAL_NAME = "sandboxes";
23
+ export const POD_NAME_ANNOTATION = "agents.x-k8s.io/pod-name";
24
+ // Total attempt count for idempotent operations (matches Go client's maxAttempts=6).
25
+ // With the loop `for (let attempt = 0; attempt < MAX_RETRIES; attempt++)` this gives
26
+ // attempts 0–5, i.e. up to 5 retries after the first attempt.
27
+ // Non-idempotent callers (POST /execute, /upload, /agent) pass maxRetries: 1 explicitly.
28
+ export const MAX_RETRIES = 6;
29
+ export const BACKOFF_FACTOR = 0.5;
30
+ // Upper cap for per-retry backoff delay. Without this clamp the delay would
31
+ // grow unbounded as attempt increases (0.5s, 1s, 2s, 4s, 8s, 16s, ...).
32
+ // Matches the Go client's maxBackoff (clients/go/sandbox/connector.go).
33
+ // Kept intentionally below the Python client's urllib3 default (120s) because
34
+ // a 60s per-attempt timeout means any single retry delay > ~8s is already
35
+ // comparable in duration to a full attempt, at which point additional waiting
36
+ // rarely helps and exceeds most callers' overall timeout budget.
37
+ export const MAX_BACKOFF_MS = 8000;
38
+ export const RETRY_STATUS_CODES = [500, 502, 503, 504];
39
+ // Maximum bytes to drain from a response body before retrying (allows TCP connection reuse)
40
+ export const MAX_DRAIN_BYTES = 4096;
41
+ // Maximum bytes of response body to include in SandboxRequestError.body
42
+ export const MAX_ERROR_BODY_BYTES = 512;
43
+ // Number of port-forward reconnect attempts before giving up
44
+ export const MAX_RECONNECT_ATTEMPTS = 3;
45
+ // Default per-attempt timeout in milliseconds (independent of the overall request timeout).
46
+ // Matches Go client's defaultPerAttemptTimeout = 60s. Overridable via
47
+ // SandboxClientOptions.perAttemptTimeoutMs or per-request options.
48
+ export const PER_ATTEMPT_TIMEOUT_MS = 60_000;
49
+ // Header name used to propagate a per-request correlation ID (matches Go client).
50
+ export const HEADER_REQUEST_ID = "X-Request-ID";
51
+ // Maximum number of gateway watch reconnects within a single waitForGatewayIp call
52
+ export const MAX_GATEWAY_REWATCH = 10;
53
+ // Maximum time (ms) for the TCP connectivity probe after gateway IP resolution.
54
+ // The gateway may report an IP before the proxy (e.g. Envoy) is ready to accept connections.
55
+ export const GATEWAY_PROBE_TIMEOUT_MS = 30_000;
56
+ // Interval (ms) between TCP connectivity probe attempts.
57
+ export const GATEWAY_PROBE_INTERVAL_MS = 500;
58
+ // Maximum time (ms) allowed for cleanup operations (claim deletion, in-flight drain)
59
+ export const CLEANUP_TIMEOUT_MS = 5_000;
60
+ // Response / request size limits (matches Go client constants)
61
+ export const MAX_EXECUTION_RESPONSE_SIZE = 16 * 1024 * 1024; // 16 MB: run/agent stdout+stderr
62
+ export const MAX_METADATA_RESPONSE_SIZE = 8 * 1024 * 1024; // 8 MB: list/exists JSON
63
+ export const MAX_DOWNLOAD_SIZE = 256 * 1024 * 1024; // 256 MB: file download
64
+ export const MAX_UPLOAD_SIZE = 256 * 1024 * 1024; // 256 MB: file upload (pre-check)
65
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,4BAA4B,CAAC;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AA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BAA0B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,0BAA0B;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,wBAAwB;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,kCAAkC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Base class for all sandbox-related errors.
3
+ */
4
+ export declare class SandboxError extends Error {
5
+ constructor(message: string, options?: ErrorOptions);
6
+ }
7
+ /**
8
+ * Raised when the sandbox is not ready for communication.
9
+ */
10
+ export declare class SandboxNotReadyError extends SandboxError {
11
+ }
12
+ /**
13
+ * Raised when the sandbox or sandbox claim cannot be found or was deleted.
14
+ */
15
+ export declare class SandboxNotFoundError extends SandboxError {
16
+ }
17
+ /**
18
+ * Raised when the port-forward process crashes.
19
+ */
20
+ export declare class SandboxPortForwardError extends SandboxError {
21
+ }
22
+ /**
23
+ * Raised when the sandbox object is missing expected metadata.
24
+ */
25
+ export declare class SandboxMetadataError extends SandboxError {
26
+ }
27
+ /**
28
+ * Raised when an operation times out waiting for a sandbox resource.
29
+ */
30
+ export declare class SandboxTimeoutError extends SandboxError {
31
+ }
32
+ /**
33
+ * Raised when the SandboxTemplate referenced by the WarmPool does not exist.
34
+ */
35
+ export declare class SandboxTemplateNotFoundError extends SandboxError {
36
+ }
37
+ /**
38
+ * Raised when the referenced SandboxWarmPool does not exist.
39
+ */
40
+ export declare class SandboxWarmPoolNotFoundError extends SandboxError {
41
+ }
42
+ /**
43
+ * Raised when an HTTP request to the sandbox fails.
44
+ */
45
+ export declare class SandboxRequestError extends SandboxError {
46
+ readonly statusCode: number | undefined;
47
+ readonly response: Response | undefined;
48
+ readonly body: string | undefined;
49
+ readonly operation: string | undefined;
50
+ constructor(message: string, options?: ErrorOptions & {
51
+ statusCode?: number;
52
+ response?: Response;
53
+ body?: string;
54
+ operation?: string;
55
+ });
56
+ }
57
+ /**
58
+ * Raised when a response body exceeds the configured size limit.
59
+ */
60
+ export declare class SandboxResponseTooLargeError extends SandboxRequestError {
61
+ }
62
+ /**
63
+ * Returns true if the error is a Kubernetes 404 (Not Found).
64
+ * Handles both @kubernetes/client-node ApiException (.code / .statusCode).
65
+ */
66
+ export declare function isK8s404(err: unknown): boolean;
67
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;CAAG;AAE5D;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;CAAG;AAExD;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,YAAY;CAAG;AAEjE;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,YAAY;CAAG;AAEjE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;gBAGrC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,GAAG;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;CAQJ;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,mBAAmB;CAAG;AAExE;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM9C"}
@@ -0,0 +1,91 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Base class for all sandbox-related errors.
16
+ */
17
+ export class SandboxError extends Error {
18
+ constructor(message, options) {
19
+ super(message, options);
20
+ this.name = this.constructor.name;
21
+ }
22
+ }
23
+ /**
24
+ * Raised when the sandbox is not ready for communication.
25
+ */
26
+ export class SandboxNotReadyError extends SandboxError {
27
+ }
28
+ /**
29
+ * Raised when the sandbox or sandbox claim cannot be found or was deleted.
30
+ */
31
+ export class SandboxNotFoundError extends SandboxError {
32
+ }
33
+ /**
34
+ * Raised when the port-forward process crashes.
35
+ */
36
+ export class SandboxPortForwardError extends SandboxError {
37
+ }
38
+ /**
39
+ * Raised when the sandbox object is missing expected metadata.
40
+ */
41
+ export class SandboxMetadataError extends SandboxError {
42
+ }
43
+ /**
44
+ * Raised when an operation times out waiting for a sandbox resource.
45
+ */
46
+ export class SandboxTimeoutError extends SandboxError {
47
+ }
48
+ /**
49
+ * Raised when the SandboxTemplate referenced by the WarmPool does not exist.
50
+ */
51
+ export class SandboxTemplateNotFoundError extends SandboxError {
52
+ }
53
+ /**
54
+ * Raised when the referenced SandboxWarmPool does not exist.
55
+ */
56
+ export class SandboxWarmPoolNotFoundError extends SandboxError {
57
+ }
58
+ /**
59
+ * Raised when an HTTP request to the sandbox fails.
60
+ */
61
+ export class SandboxRequestError extends SandboxError {
62
+ statusCode;
63
+ response;
64
+ body;
65
+ operation;
66
+ constructor(message, options) {
67
+ super(message, options);
68
+ this.statusCode = options?.statusCode;
69
+ this.response = options?.response;
70
+ this.body = options?.body;
71
+ this.operation = options?.operation;
72
+ }
73
+ }
74
+ /**
75
+ * Raised when a response body exceeds the configured size limit.
76
+ */
77
+ export class SandboxResponseTooLargeError extends SandboxRequestError {
78
+ }
79
+ /**
80
+ * Returns true if the error is a Kubernetes 404 (Not Found).
81
+ * Handles both @kubernetes/client-node ApiException (.code / .statusCode).
82
+ */
83
+ export function isK8s404(err) {
84
+ if (typeof err === "object" && err !== null) {
85
+ const candidate = err;
86
+ if (candidate.code === 404 || candidate.statusCode === 404)
87
+ return true;
88
+ }
89
+ return false;
90
+ }
91
+ //# sourceMappingURL=exceptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;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 import type { ExecutionResult } from "../types.js";
5
+ /**
6
+ * Sandbox handle with computer-use agent support.
7
+ * Use ComputerUseSandboxClient to create instances.
8
+ */
9
+ export declare class ComputerUseSandbox extends Sandbox {
10
+ agent(query: string, timeout?: number): Promise<ExecutionResult>;
11
+ }
12
+ /**
13
+ * Registry client that creates ComputerUseSandbox handles.
14
+ */
15
+ export declare class ComputerUseSandboxClient extends SandboxClient<ComputerUseSandbox> {
16
+ protected readonly sandboxClass: new (init: SandboxInit) => ComputerUseSandbox;
17
+ }
18
+ //# sourceMappingURL=computer-use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computer-use.d.ts","sourceRoot":"","sources":["../../src/extensions/computer-use.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,OAAO;IACvC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAgD3E;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IAC7E,mBAA4B,YAAY,EACL,KAC/B,IAAI,EAAE,WAAW,KACd,kBAAkB,CAAC;CAC3B"}
@@ -0,0 +1,61 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { MAX_ERROR_BODY_BYTES, MAX_EXECUTION_RESPONSE_SIZE, } from "../constants.js";
15
+ import { SandboxNotReadyError, SandboxRequestError } from "../exceptions.js";
16
+ import { parseExecutionResult, readBoundedText } from "../response-utils.js";
17
+ import { Sandbox } from "../sandbox.js";
18
+ import { SandboxClient } from "../sandbox-client.js";
19
+ import { withSpan } from "../trace-manager.js";
20
+ /**
21
+ * Sandbox handle with computer-use agent support.
22
+ * Use ComputerUseSandboxClient to create instances.
23
+ */
24
+ export class ComputerUseSandbox extends Sandbox {
25
+ async agent(query, timeout = 60) {
26
+ return withSpan(this.tracer, this.traceServiceName, "agent", async (span) => {
27
+ if (!this.isActive) {
28
+ throw new SandboxNotReadyError("Sandbox is not ready. Cannot execute agent queries.");
29
+ }
30
+ const response = await this.request("POST", "agent", {
31
+ body: JSON.stringify({ query }),
32
+ headers: { "Content-Type": "application/json" },
33
+ timeout,
34
+ maxRetries: 1, // agent invocation is non-idempotent; never retry
35
+ });
36
+ const rawText = await readBoundedText(response, MAX_EXECUTION_RESPONSE_SIZE, "agent");
37
+ let data;
38
+ try {
39
+ data = JSON.parse(rawText);
40
+ }
41
+ catch (err) {
42
+ const preview = rawText.length > MAX_ERROR_BODY_BYTES
43
+ ? `${[...rawText].slice(0, MAX_ERROR_BODY_BYTES).join("")}…`
44
+ : rawText;
45
+ throw new SandboxRequestError(`Failed to decode JSON response from sandbox: ${preview}`, { cause: err, operation: "agent" });
46
+ }
47
+ const result = parseExecutionResult(data);
48
+ if (span.isRecording()) {
49
+ span.setAttribute("sandbox.exit_code", result.exitCode);
50
+ }
51
+ return result;
52
+ }, this.tracingManager?.parentContext);
53
+ }
54
+ }
55
+ /**
56
+ * Registry client that creates ComputerUseSandbox handles.
57
+ */
58
+ export class ComputerUseSandboxClient extends SandboxClient {
59
+ sandboxClass = ComputerUseSandbox;
60
+ }
61
+ //# sourceMappingURL=computer-use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computer-use.js","sourceRoot":"","sources":["../../src/extensions/computer-use.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,OAAO;IAC7C,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,UAAkB,EAAE;QAC7C,OAAO,QAAQ,CACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,gBAAgB,EACrB,OAAO,EACP,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,MAAM,IAAI,oBAAoB,CAC5B,qDAAqD,CACtD,CAAC;YACJ,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE;gBACnD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;gBAC/B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,OAAO;gBACP,UAAU,EAAE,CAAC,EAAE,kDAAkD;aAClE,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,eAAe,CACnC,QAAQ,EACR,2BAA2B,EAC3B,OAAO,CACR,CAAC;YACF,IAAI,IAAa,CAAC;YAClB,IAAI,CAAC;gBACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,OAAO,GACX,OAAO,CAAC,MAAM,GAAG,oBAAoB;oBACnC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG;oBAC5D,CAAC,CAAC,OAAO,CAAC;gBACd,MAAM,IAAI,mBAAmB,CAC3B,gDAAgD,OAAO,EAAE,EACzD,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CACnC,CAAC;YACJ,CAAC;YACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAE1C,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACvB,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,IAAI,CAAC,cAAc,EAAE,aAAa,CACnC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAiC;IACjD,YAAY,GACtC,kBAEuB,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export { ComputerUseSandbox, ComputerUseSandboxClient, } from "./computer-use.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2025 The Kubernetes Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ export { ComputerUseSandbox, ComputerUseSandboxClient, } from "./computer-use.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CallOptions, FileEntry, RequestFn } from "../types.js";
2
+ import type { Tracer } from "../trace-manager.js";
3
+ export declare class Filesystem {
4
+ private requestFn;
5
+ private getTracer;
6
+ private getParentContext;
7
+ private traceServiceName;
8
+ constructor(requestFn: RequestFn, getTracer: () => Tracer | null, traceServiceName: string, getParentContext?: () => unknown);
9
+ write(filePath: string, content: Buffer | string, options?: number | CallOptions): Promise<void>;
10
+ read(filePath: string, options?: number | CallOptions): Promise<Buffer>;
11
+ list(dirPath: string, options?: number | CallOptions): Promise<FileEntry[]>;
12
+ exists(filePath: string, options?: number | CallOptions): Promise<boolean>;
13
+ }
14
+ //# sourceMappingURL=filesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/files/filesystem.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkGrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAS;gBAG/B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,EAC9B,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,GAAE,MAAM,OAAoB;IAQxC,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAC7B,OAAO,CAAC,IAAI,CAAC;IA0DV,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAC7B,OAAO,CAAC,MAAM,CAAC;IAkDZ,IAAI,CACR,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAC7B,OAAO,CAAC,SAAS,EAAE,CAAC;IA4DjB,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAC7B,OAAO,CAAC,OAAO,CAAC;CA6DpB"}