@workbench-ai/workbench-core 0.0.46

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 (72) hide show
  1. package/dist/adapter-auth.d.ts +63 -0
  2. package/dist/adapter-auth.d.ts.map +1 -0
  3. package/dist/adapter-auth.js +244 -0
  4. package/dist/execution-events.d.ts +53 -0
  5. package/dist/execution-events.d.ts.map +1 -0
  6. package/dist/execution-events.js +195 -0
  7. package/dist/execution-graph.d.ts +27 -0
  8. package/dist/execution-graph.d.ts.map +1 -0
  9. package/dist/execution-graph.js +126 -0
  10. package/dist/execution-jobs.d.ts +70 -0
  11. package/dist/execution-jobs.d.ts.map +1 -0
  12. package/dist/execution-jobs.js +229 -0
  13. package/dist/execution-outputs.d.ts +9 -0
  14. package/dist/execution-outputs.d.ts.map +1 -0
  15. package/dist/execution-outputs.js +393 -0
  16. package/dist/execution-phases.d.ts +21 -0
  17. package/dist/execution-phases.d.ts.map +1 -0
  18. package/dist/execution-phases.js +262 -0
  19. package/dist/execution-runtime-types.d.ts +35 -0
  20. package/dist/execution-runtime-types.d.ts.map +1 -0
  21. package/dist/execution-runtime-types.js +1 -0
  22. package/dist/execution-scheduler.d.ts +31 -0
  23. package/dist/execution-scheduler.d.ts.map +1 -0
  24. package/dist/execution-scheduler.js +241 -0
  25. package/dist/execution-traces.d.ts +16 -0
  26. package/dist/execution-traces.d.ts.map +1 -0
  27. package/dist/execution-traces.js +164 -0
  28. package/dist/execution-usage.d.ts +12 -0
  29. package/dist/execution-usage.d.ts.map +1 -0
  30. package/dist/execution-usage.js +433 -0
  31. package/dist/generic-spec.d.ts +113 -0
  32. package/dist/generic-spec.d.ts.map +1 -0
  33. package/dist/generic-spec.js +656 -0
  34. package/dist/index.d.ts +160 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +2858 -0
  37. package/dist/model-prices-litellm.d.ts +9674 -0
  38. package/dist/model-prices-litellm.d.ts.map +1 -0
  39. package/dist/model-prices-litellm.js +9668 -0
  40. package/dist/runtime-utils.d.ts +18 -0
  41. package/dist/runtime-utils.d.ts.map +1 -0
  42. package/dist/runtime-utils.js +108 -0
  43. package/dist/sandbox-backends/docker.d.ts +5 -0
  44. package/dist/sandbox-backends/docker.d.ts.map +1 -0
  45. package/dist/sandbox-backends/docker.js +568 -0
  46. package/dist/sandbox-backends/index.d.ts +37 -0
  47. package/dist/sandbox-backends/index.d.ts.map +1 -0
  48. package/dist/sandbox-backends/index.js +79 -0
  49. package/dist/sandbox-backends/names.d.ts +6 -0
  50. package/dist/sandbox-backends/names.d.ts.map +1 -0
  51. package/dist/sandbox-backends/names.js +14 -0
  52. package/dist/sandbox-backends/template-images.d.ts +4 -0
  53. package/dist/sandbox-backends/template-images.d.ts.map +1 -0
  54. package/dist/sandbox-backends/template-images.js +48 -0
  55. package/dist/sandbox-inputs.d.ts +27 -0
  56. package/dist/sandbox-inputs.d.ts.map +1 -0
  57. package/dist/sandbox-inputs.js +220 -0
  58. package/dist/sandbox-plane.d.ts +89 -0
  59. package/dist/sandbox-plane.d.ts.map +1 -0
  60. package/dist/sandbox-plane.js +327 -0
  61. package/dist/subject-patch.d.ts +8 -0
  62. package/dist/subject-patch.d.ts.map +1 -0
  63. package/dist/subject-patch.js +63 -0
  64. package/dist/trace-files.d.ts +18 -0
  65. package/dist/trace-files.d.ts.map +1 -0
  66. package/dist/trace-files.js +94 -0
  67. package/environments/libreoffice-agent/Dockerfile +13 -0
  68. package/environments/libreoffice-python/Dockerfile +11 -0
  69. package/environments/node-22/Dockerfile +3 -0
  70. package/environments/python-3.12/Dockerfile +8 -0
  71. package/package.json +42 -0
  72. package/worker/sandbox-adapter-runner.cjs +275 -0
@@ -0,0 +1,18 @@
1
+ import type { Json } from "@workbench-ai/workbench-contract";
2
+ export declare function importNodeModule<T>(specifier: string): Promise<T>;
3
+ export declare function nodeBuiltin(name: string): string;
4
+ export declare function asRuntimeRecord(value: unknown): Record<string, unknown>;
5
+ export declare function jsonRecord(value: unknown): Record<string, Json>;
6
+ export declare function numberValue(value: unknown): number | undefined;
7
+ export declare function stringValue(value: unknown): string | undefined;
8
+ export declare function isJsonPayload(value: unknown): value is import("@workbench-ai/workbench-contract").Json;
9
+ export declare function resolveDockerRuntimeImageRef(imageRef: string, options: {
10
+ runtimeRegistry: string;
11
+ label: string;
12
+ allowMutableLatest?: boolean;
13
+ }): string;
14
+ export declare function normalizeRuntimeRegistry(value: string): string;
15
+ export declare function normalizeWorkbenchWorkerId(value: unknown): string | undefined;
16
+ export declare function resolveWorkbenchWorkerId(subjects: readonly unknown[], fallback: string): string;
17
+ export declare function quoteShellArg(value: string): string;
18
+ //# sourceMappingURL=runtime-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-utils.d.ts","sourceRoot":"","sources":["../src/runtime-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,kCAAkC,CAAC;AAE1C,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAEvE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIvE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAI/D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,kCAAkC,EAAE,IAAI,CAWtG;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GAChF,MAAM,CASR;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAeD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS7E;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS/F;AAoBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKnD"}
@@ -0,0 +1,108 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ export async function importNodeModule(specifier) {
10
+ return await import(__rewriteRelativeImportExtension(/* webpackIgnore: true */ specifier));
11
+ }
12
+ export function nodeBuiltin(name) {
13
+ return `node:${name}`;
14
+ }
15
+ export function asRuntimeRecord(value) {
16
+ return value && typeof value === "object" && !Array.isArray(value)
17
+ ? value
18
+ : {};
19
+ }
20
+ export function jsonRecord(value) {
21
+ return value && typeof value === "object" && !Array.isArray(value)
22
+ ? value
23
+ : {};
24
+ }
25
+ export function numberValue(value) {
26
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
27
+ }
28
+ export function stringValue(value) {
29
+ return typeof value === "string" && value.length > 0 ? value : undefined;
30
+ }
31
+ export function isJsonPayload(value) {
32
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
33
+ return Number.isFinite(value) || typeof value !== "number";
34
+ }
35
+ if (Array.isArray(value)) {
36
+ return value.every(isJsonPayload);
37
+ }
38
+ if (value && typeof value === "object") {
39
+ return Object.values(value).every(isJsonPayload);
40
+ }
41
+ return false;
42
+ }
43
+ export function resolveDockerRuntimeImageRef(imageRef, options) {
44
+ if (!imageRef.startsWith("docker://")) {
45
+ throw new Error(`${options.label} must start with docker://.`);
46
+ }
47
+ const image = applyRuntimeRegistry(imageRef.slice("docker://".length), options.runtimeRegistry);
48
+ if (!options.allowMutableLatest && hasMutableLatestTag(image)) {
49
+ throw new Error(`${options.label} must not use mutable tag :latest.`);
50
+ }
51
+ return image;
52
+ }
53
+ export function normalizeRuntimeRegistry(value) {
54
+ return value.replace(/^https?:\/\//u, "").replace(/\/+$/u, "");
55
+ }
56
+ const NON_IDENTIFYING_WORKER_IDS = new Set([
57
+ "*",
58
+ "0",
59
+ "0.0.0.0",
60
+ "::",
61
+ "::0",
62
+ "[::]",
63
+ "127.0.0.1",
64
+ "::1",
65
+ "localhost",
66
+ "localhost.localdomain",
67
+ ]);
68
+ export function normalizeWorkbenchWorkerId(value) {
69
+ if (typeof value !== "string") {
70
+ return undefined;
71
+ }
72
+ const normalized = value.trim();
73
+ if (!normalized) {
74
+ return undefined;
75
+ }
76
+ return NON_IDENTIFYING_WORKER_IDS.has(normalized.toLowerCase()) ? undefined : normalized;
77
+ }
78
+ export function resolveWorkbenchWorkerId(subjects, fallback) {
79
+ for (const subject of subjects) {
80
+ const normalized = normalizeWorkbenchWorkerId(subject);
81
+ if (normalized) {
82
+ return normalized;
83
+ }
84
+ }
85
+ const normalizedFallback = normalizeWorkbenchWorkerId(fallback);
86
+ return normalizedFallback ?? "worker";
87
+ }
88
+ function applyRuntimeRegistry(image, runtimeRegistry) {
89
+ if (!runtimeRegistry || hasRegistryHost(image)) {
90
+ return image;
91
+ }
92
+ return `${runtimeRegistry}/${image}`;
93
+ }
94
+ function hasRegistryHost(image) {
95
+ const first = image.split("/")[0] ?? "";
96
+ return first === "localhost" || first.includes(".") || first.includes(":");
97
+ }
98
+ function hasMutableLatestTag(image) {
99
+ const leaf = image.slice(image.lastIndexOf("/") + 1);
100
+ const taggedName = leaf.includes("@") ? leaf.slice(0, leaf.indexOf("@")) : leaf;
101
+ return taggedName.endsWith(":latest");
102
+ }
103
+ export function quoteShellArg(value) {
104
+ if (value.length === 0) {
105
+ return "''";
106
+ }
107
+ return `'${value.replace(/'/gu, `'\"'\"'`)}'`;
108
+ }
@@ -0,0 +1,5 @@
1
+ import type { WorkbenchExecutionRuntimeInput } from "../execution-runtime-types.ts";
2
+ import { type SandboxBackendDescriptor, type SandboxExecutionFileStore, type SandboxPlane } from "../sandbox-plane.ts";
3
+ export declare function createDockerSandboxBackendDescriptor(): SandboxBackendDescriptor;
4
+ export declare function createDockerSandboxPlane(args: WorkbenchExecutionRuntimeInput, startedAt: string, fileStore: SandboxExecutionFileStore): SandboxPlane;
5
+ //# sourceMappingURL=docker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/sandbox-backends/docker.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,8BAA8B,EAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,yBAAyB,EAE9B,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAuC7B,wBAAgB,oCAAoC,IACjD,wBAAwB,CAY1B;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,8BAA8B,EACpC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,yBAAyB,GACnC,YAAY,CAmDd"}