deepline 0.3.45 → 0.3.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 (88) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +2 -3
  2. package/dist/bundling-sources/sdk/src/errors.ts +2 -2
  3. package/dist/bundling-sources/sdk/src/http.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/play.ts +7 -10
  5. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +3 -3
  6. package/dist/bundling-sources/sdk/src/release.ts +3 -3
  7. package/dist/bundling-sources/sdk/src/version.ts +2 -2
  8. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +25 -0
  9. package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +1 -0
  10. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +1 -1
  11. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +19 -19
  12. package/dist/bundling-sources/shared_libs/play-runtime/backend.ts +5 -6
  13. package/dist/bundling-sources/shared_libs/play-runtime/cell-staleness.ts +1 -66
  14. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +11 -11
  15. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +3 -3
  16. package/dist/bundling-sources/shared_libs/play-runtime/dataset-id.ts +4 -3
  17. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -4
  18. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +2 -2
  19. package/dist/bundling-sources/shared_libs/play-runtime/email-status.ts +1 -275
  20. package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +1 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/extractor-targets.ts +1 -106
  22. package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +1 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +13 -4
  24. package/dist/bundling-sources/shared_libs/play-runtime/live-events.ts +1 -5
  25. package/dist/bundling-sources/shared_libs/play-runtime/map-row-identity.ts +2 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/map-row-outcome.ts +2 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +1 -1
  28. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +1 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/projection.ts +5 -5
  30. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -3
  31. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +1 -1
  32. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +1 -1
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +4 -4
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +3 -3
  35. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +8 -8
  36. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +1 -1
  37. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +4 -4
  38. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +7 -7
  39. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +7 -7
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/bundle.ts +13 -2
  41. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/index.ts +2 -2
  42. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runner-events.ts +1 -1
  43. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +1 -1
  44. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +2 -2
  45. package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +1 -1
  46. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +6 -3
  47. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +1 -1
  48. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constraints.ts +1 -2
  49. package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +55 -0
  50. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runtime-limits.ts +1 -109
  51. package/dist/bundling-sources/shared_libs/play-runtime/step-program-dataset-builder.ts +1 -1
  52. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +1 -1
  53. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +1 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/tool-execution-outcome.ts +6 -5
  55. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +1 -1
  56. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +1 -206
  57. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +10 -7
  58. package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +1 -1
  59. package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +8 -3
  60. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +4 -4
  61. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +3 -6
  62. package/dist/bundling-sources/shared_libs/plays/cell-staleness.ts +66 -0
  63. package/dist/bundling-sources/shared_libs/plays/compiler-manifest.ts +1 -1
  64. package/dist/bundling-sources/shared_libs/plays/contracts.ts +2 -2
  65. package/dist/bundling-sources/shared_libs/plays/core.ts +466 -0
  66. package/dist/bundling-sources/shared_libs/plays/email-status.ts +287 -0
  67. package/dist/bundling-sources/shared_libs/plays/extractor-targets.ts +106 -0
  68. package/dist/bundling-sources/shared_libs/plays/row-identity.ts +1 -3
  69. package/dist/bundling-sources/shared_libs/plays/runtime-constraints.ts +2 -0
  70. package/dist/bundling-sources/shared_libs/plays/runtime-validation.ts +4 -2
  71. package/dist/bundling-sources/shared_libs/plays/sandbox-runtime-limits.ts +109 -0
  72. package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +624 -0
  73. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +206 -0
  74. package/dist/bundling-sources/shared_libs/security/safe-outbound-fetch.ts +1 -1
  75. package/dist/cli/index.js +174 -168
  76. package/dist/cli/index.mjs +182 -169
  77. package/dist/{compiler-manifest-DwYe2C2S.d.mts → compiler-manifest-BuoqasqI.d.mts} +585 -540
  78. package/dist/{compiler-manifest-DwYe2C2S.d.ts → compiler-manifest-BuoqasqI.d.ts} +585 -540
  79. package/dist/index.d.mts +9 -2
  80. package/dist/index.d.ts +9 -2
  81. package/dist/index.js +47 -40
  82. package/dist/index.mjs +47 -40
  83. package/dist/install-integrity.json +13 -3
  84. package/dist/plays/bundle-play-file.d.mts +4 -61
  85. package/dist/plays/bundle-play-file.d.ts +4 -61
  86. package/dist/plays/bundle-play-file.mjs +157 -155
  87. package/package.json +9 -6
  88. /package/dist/bundling-sources/shared_libs/{play-runtime → plays}/tool-response-contract.ts +0 -0
@@ -16,15 +16,15 @@ import type {
16
16
  PlayRunnerExecutionConfig,
17
17
  PlayRunnerRuntimeTiming,
18
18
  PlayRunnerResult,
19
- } from '@shared_libs/play-runtime/protocol';
19
+ } from '../../protocol';
20
20
  import {
21
21
  PLAY_RUNNER_TERMINAL_GRACE_SECONDS,
22
22
  STANDARD_PLAY_RUNTIME_LIMIT_SECONDS,
23
- } from '@shared_libs/play-runtime/runtime-constants';
23
+ } from '../../runtime-constants';
24
24
  import {
25
25
  loadDaytonaRequiredConfig,
26
26
  loadDaytonaRunnerPathsConfig,
27
- } from '@shared_libs/play-runtime/daytona-runtime-config';
27
+ } from '../../daytona-runtime-config';
28
28
  import {
29
29
  DAYTONA_CANCELLED_ERROR,
30
30
  DaytonaSandboxAcquisitionUnavailableError,
@@ -42,7 +42,7 @@ import {
42
42
  DaytonaRunnerInitializationError,
43
43
  prepareDetachedDaytonaRunner,
44
44
  } from './daytona-session-execution';
45
- import { RUNTIME_RELIABILITY_POLICY } from '@shared_libs/play-runtime/runtime-reliability-policy';
45
+ import { RUNTIME_RELIABILITY_POLICY } from '../../runtime-reliability-policy';
46
46
 
47
47
  const DAYTONA_COMMAND_RECOVERY_TIMEOUT_MS =
48
48
  RUNTIME_RELIABILITY_POLICY.sandbox.daytonaCommandRecoveryTimeoutMs;
@@ -6,7 +6,7 @@ import type { SpawnOptionsWithoutStdio } from 'node:child_process';
6
6
  import {
7
7
  setSpanAttributes,
8
8
  withActiveSpan,
9
- } from '@shared_libs/observability/tracing';
9
+ } from '../../../observability/tracing';
10
10
  import type { PlayRunnerBackend } from '../types';
11
11
  import { buildPlayRunnerBundle } from '../bundle';
12
12
  import {
@@ -14,25 +14,25 @@ import {
14
14
  parsePlayRunnerEventLine,
15
15
  parsePlayRunnerEvents,
16
16
  } from '../runner-events';
17
- import type { PlayRunnerExecutionConfig } from '@shared_libs/play-runtime/protocol';
18
- import { resolveDaytonaSandboxComputeItem } from '@shared_libs/play-runtime/worker-api-types';
17
+ import type { PlayRunnerExecutionConfig } from '../../protocol';
18
+ import { resolveDaytonaSandboxComputeItem } from '../../worker-api-types';
19
19
  import {
20
20
  recordComputeBillingItemViaAppRuntime,
21
21
  upsertComputeBillingSessionViaAppRuntime,
22
22
  type WorkerRuntimeApiContext,
23
- } from '@shared_libs/play-runtime/app-runtime-api';
23
+ } from '../../app-runtime-api';
24
24
  import {
25
25
  PLAY_RUNNER_STARTUP_GRACE_SECONDS,
26
26
  PLAY_RUNNER_TERMINAL_GRACE_SECONDS,
27
- } from '@shared_libs/play-runtime/runtime-constants';
27
+ } from '../../runtime-constants';
28
28
  import {
29
29
  STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS,
30
30
  validatePlaySandboxRuntimeLimits,
31
- } from '@shared_libs/play-runtime/sandbox-runtime-limits';
31
+ } from '../../../plays/sandbox-runtime-limits';
32
32
  import {
33
33
  runtimeLimitExceededCause,
34
34
  runtimeLimitExceededFailure,
35
- } from '@shared_libs/play-runtime/run-failure';
35
+ } from '../../run-failure';
36
36
  import {
37
37
  buildDaytonaRuntimeWatchdogSource,
38
38
  DAYTONA_RUNTIME_WATCHDOG_EXIT_CODE,
@@ -10,18 +10,18 @@ import type {
10
10
  PlayRunnerExecutionConfig,
11
11
  PlayRunnerResult,
12
12
  PlayRunnerRuntimeTiming,
13
- } from '@shared_libs/play-runtime/protocol';
13
+ } from '../../protocol';
14
14
  import {
15
15
  PLAY_RUNNER_STARTUP_GRACE_SECONDS,
16
16
  PLAY_RUNNER_TERMINAL_GRACE_SECONDS,
17
- } from '@shared_libs/play-runtime/runtime-constants';
17
+ } from '../../runtime-constants';
18
18
  import {
19
19
  MODAL_SANDBOX_CPU_CORES,
20
20
  MODAL_SANDBOX_MEMORY_MIB,
21
21
  loadModalClientConfig,
22
22
  loadModalRequiredConfig,
23
- } from '@shared_libs/play-runtime/modal-runtime-config';
24
- import type { PlaySandboxRuntimeLimits } from '@shared_libs/play-runtime/sandbox-runtime-limits';
23
+ } from '../../modal-runtime-config';
24
+ import type { PlaySandboxRuntimeLimits } from '../../../plays/sandbox-runtime-limits';
25
25
  import { validateDaytonaExecutionContext } from './daytona-lifecycle';
26
26
  import { stageRunnerPayload } from './daytona-payload-transport';
27
27
  import { captureDetachedDaytonaRunnerReadinessBaseline } from './daytona-session-execution';
@@ -29,9 +29,9 @@ import {
29
29
  isPlayRunRecoveryError,
30
30
  recoveryForOpenModalCircuit,
31
31
  recoveryForModalSandboxCreateFailure,
32
- } from '@shared_libs/play-runtime/play-run-recovery-policy';
33
- import { shouldInjectModalSandboxCreateResourceExhausted } from '@shared_libs/play-runtime/test-runtime-seams';
34
- import { RUNTIME_RELIABILITY_POLICY } from '@shared_libs/play-runtime/runtime-reliability-policy';
32
+ } from '../../play-run-recovery-policy';
33
+ import { shouldInjectModalSandboxCreateResourceExhausted } from '../../test-runtime-seams';
34
+ import { RUNTIME_RELIABILITY_POLICY } from '../../runtime-reliability-policy';
35
35
 
36
36
  const MODAL_RUNNER_READY_TIMEOUT_MS =
37
37
  RUNTIME_RELIABILITY_POLICY.sandbox.runnerReadyTimeoutMs;
@@ -5,7 +5,7 @@ import { createRequire } from 'node:module';
5
5
  import {
6
6
  setSpanAttributes,
7
7
  withActiveSpan,
8
- } from '@shared_libs/observability/tracing';
8
+ } from '../../observability/tracing';
9
9
 
10
10
  const runtimeRequire = createRequire(import.meta.url);
11
11
  const esbuild = runtimeRequire('esbuild') as {
@@ -71,6 +71,12 @@ async function listFiles(dir: string): Promise<string[]> {
71
71
  const entries = await readdir(dir, { withFileTypes: true });
72
72
  const values = await Promise.all(
73
73
  entries.map(async (entry) => {
74
+ if (
75
+ entry.isDirectory() &&
76
+ ['.turbo', 'dist', 'node_modules'].includes(entry.name)
77
+ ) {
78
+ return [];
79
+ }
74
80
  const fullPath = join(dir, entry.name);
75
81
  if (entry.isDirectory()) {
76
82
  return await listFiles(fullPath);
@@ -112,7 +118,7 @@ function createRunnerBoundaryPlugin(projectRoot: string) {
112
118
 
113
119
  function rejectionForImport(args: EsbuildOnResolveArgs): string | null {
114
120
  if (args.path.startsWith('@/') || args.path.startsWith('@convex/')) {
115
- return `play-runner bundle cannot import ${args.path}; move shared runtime code to shared_libs or call the app over the runtime API`;
121
+ return `play-runner bundle cannot import ${args.path}; move shared runtime code to a package or call the app over the runtime API`;
116
122
  }
117
123
 
118
124
  if (!args.path.startsWith('.') || !args.importer) {
@@ -195,6 +201,11 @@ export async function buildPlayRunnerBundle(): Promise<string> {
195
201
 
196
202
  const sourceRoots = [
197
203
  resolve(process.cwd(), 'apps', 'play-runner', 'src'),
204
+ resolve(process.cwd(), 'packages', 'observability'),
205
+ resolve(process.cwd(), 'packages', 'play-data-plane'),
206
+ resolve(process.cwd(), 'packages', 'play-runtime'),
207
+ resolve(process.cwd(), 'packages', 'plays'),
208
+ resolve(process.cwd(), 'packages', 'security'),
198
209
  resolve(process.cwd(), 'shared_libs'),
199
210
  ];
200
211
  const sourceHash = await hashRunnerSources(sourceRoots);
@@ -13,13 +13,13 @@ import {
13
13
  PLAY_RUNTIME_BACKENDS,
14
14
  normalizePlayRuntimeBackend,
15
15
  type PlayRuntimeBackendId,
16
- } from '@shared_libs/play-runtime/backend';
16
+ } from '../backend';
17
17
  import {
18
18
  isRuntimeSandboxCanaryProduction,
19
19
  RUNTIME_SANDBOX_PLACEMENT_POLICIES,
20
20
  runtimeSandboxPlacementPolicyForBackend,
21
21
  type RuntimeSandboxPlacementPolicyId,
22
- } from '@shared_libs/play-runtime/runtime-sandbox-placement-policy';
22
+ } from '../runtime-sandbox-placement-policy';
23
23
 
24
24
  export function resolveRuntimeSandboxPlacementBackend(
25
25
  policyId: RuntimeSandboxPlacementPolicyId | string,
@@ -1,7 +1,7 @@
1
1
  import type {
2
2
  PlayRunnerEvent,
3
3
  PlayRunnerResult,
4
- } from '@shared_libs/play-runtime/protocol';
4
+ } from '../protocol';
5
5
 
6
6
  export function parsePlayRunnerEvents(stdout: string): PlayRunnerEvent[] {
7
7
  return stdout
@@ -6,7 +6,7 @@ import {
6
6
  deleteModalSandboxById,
7
7
  readDetachedModalRuntimeCompletion,
8
8
  } from './backends/modal';
9
- import type { DetachedRunnerSuspension } from '@shared_libs/play-runtime/suspension';
9
+ import type { DetachedRunnerSuspension } from '../suspension';
10
10
 
11
11
  export type RuntimeSandboxProviderId = 'daytona' | 'modal';
12
12
 
@@ -2,12 +2,12 @@ import type {
2
2
  PlayCheckpoint,
3
3
  PlayExecutionEvent,
4
4
  PlayRowUpdate,
5
- } from '@shared_libs/play-runtime/ctx-types';
5
+ } from '../ctx-types';
6
6
  import type {
7
7
  PlayRunnerExecutionConfig,
8
8
  PlayRunnerLogEvent,
9
9
  PlayRunnerResult,
10
- } from '@shared_libs/play-runtime/protocol';
10
+ } from '../protocol';
11
11
 
12
12
  export type PlayRunnerRuntimeResource = {
13
13
  kind: 'daytona_sandbox' | 'modal_sandbox';
@@ -4,7 +4,7 @@ import type { PlayRowUpdate } from './ctx-types';
4
4
  import type { PlaySheetContract } from '../plays/static-pipeline';
5
5
  import type { PlayRunLedgerEvent } from './run-ledger';
6
6
  import type { WorkReceiptFailureKind } from './work-receipts';
7
- import type { ToolExecutionFailureV1 } from '../tool-execution-error';
7
+ import type { ToolExecutionFailureV1 } from '../plays/tool-execution-error';
8
8
  import type { DocflowObservationUpsert } from './docflow-observation';
9
9
 
10
10
  export type RuntimeAppendRunEventsAction = {
@@ -8,7 +8,10 @@ import {
8
8
  type RuntimePoolClient,
9
9
  type RuntimeOneShotQueryClient,
10
10
  } from './runtime-pg-driver';
11
- import { createDeferredPlayDataset, type PlayDataset } from '../plays/dataset';
11
+ import {
12
+ createDeferredPlayDataset,
13
+ type PlayDataset,
14
+ } from '../plays/dataset';
12
15
  import type {
13
16
  PlayStaticPipeline,
14
17
  PlaySheetContract,
@@ -59,7 +62,7 @@ import {
59
62
  workReceiptFailureKindFromCode,
60
63
  type WorkReceiptFailureKind,
61
64
  } from './work-receipts';
62
- import type { ToolExecutionFailureV1 } from '../tool-execution-error';
65
+ import type { ToolExecutionFailureV1 } from '../plays/tool-execution-error';
63
66
  import {
64
67
  sanitizePostgresJsonValue,
65
68
  stringifyPostgresJson,
@@ -92,7 +95,7 @@ import {
92
95
  mapRowOutcomeRuntimeFields,
93
96
  resolveMapRowOutcomeKey,
94
97
  } from './map-row-outcome';
95
- import { DEEPLINE_CELL_META_FIELD } from './cell-staleness';
98
+ import { DEEPLINE_CELL_META_FIELD } from '../plays/cell-staleness';
96
99
  import {
97
100
  PLAY_RUNTIME_CONTRACT,
98
101
  PLAY_RUNTIME_CONTRACT_HEADER,
@@ -1,4 +1,4 @@
1
- import { MAX_PLAY_SANDBOX_RUNTIME_LIMITS } from './sandbox-runtime-limits';
1
+ import { MAX_PLAY_SANDBOX_RUNTIME_LIMITS } from '../plays/sandbox-runtime-limits';
2
2
 
3
3
  /** Maximum active user-code runtime for a standard play, in seconds. */
4
4
  export const STANDARD_PLAY_RUNTIME_LIMIT_SECONDS = 30 * 60;
@@ -1,2 +1 @@
1
- export const DISALLOWED_RUN_JAVASCRIPT_TOOL_MESSAGE =
2
- 'No run_javascript tool in plays. Just write regular code.';
1
+ export * from '../plays/runtime-constraints';
@@ -0,0 +1,55 @@
1
+ export type DeeplineRuntimeEnv = 'prod' | 'dev';
2
+
3
+ function normalizeEnvToken(value: string): DeeplineRuntimeEnv | null {
4
+ const token = value.trim().toLowerCase();
5
+ if (!token) return null;
6
+
7
+ if (
8
+ token === 'prod' ||
9
+ token === 'production' ||
10
+ token === 'live' ||
11
+ token.startsWith('prod-')
12
+ ) {
13
+ return 'prod';
14
+ }
15
+
16
+ if (
17
+ token === 'dev' ||
18
+ token === 'development' ||
19
+ token === 'local' ||
20
+ token === 'preview' ||
21
+ token === 'staging' ||
22
+ token === 'stage' ||
23
+ token === 'test' ||
24
+ token.startsWith('dev-')
25
+ ) {
26
+ return 'dev';
27
+ }
28
+
29
+ return null;
30
+ }
31
+
32
+ export function getRuntimeEnv(): DeeplineRuntimeEnv {
33
+ const explicit = normalizeEnvToken(process.env.DEEPLINE_ENV ?? '');
34
+ if (explicit) return explicit;
35
+
36
+ const convexDeployment = String(process.env.CONVEX_DEPLOYMENT ?? '')
37
+ .trim()
38
+ .toLowerCase();
39
+ if (convexDeployment.startsWith('prod:')) return 'prod';
40
+ if (convexDeployment.startsWith('dev:')) return 'dev';
41
+
42
+ const vercelEnv = normalizeEnvToken(process.env.VERCEL_ENV ?? '');
43
+ if (vercelEnv) return vercelEnv;
44
+
45
+ return process.env.NODE_ENV === 'production' ? 'prod' : 'dev';
46
+ }
47
+
48
+ export function getRuntimeEnvInfo() {
49
+ return {
50
+ env: getRuntimeEnv(),
51
+ deepline_env: process.env.DEEPLINE_ENV ?? null,
52
+ convex_deployment: process.env.CONVEX_DEPLOYMENT ?? null,
53
+ node_env: process.env.NODE_ENV ?? null,
54
+ };
55
+ }
@@ -1,109 +1 @@
1
- export type PlaySandboxRuntimeLimits = {
2
- timeoutSeconds: number;
3
- memoryGiB: number;
4
- cpu: number;
5
- diskGiB: number;
6
- };
7
-
8
- export type PlaySandboxSize = 'standard';
9
-
10
- export const PLAY_SANDBOX_SIZE_LIMITS = {
11
- standard: {
12
- memoryGiB: 1,
13
- cpu: 1,
14
- diskGiB: 3,
15
- },
16
- } as const satisfies Record<
17
- PlaySandboxSize,
18
- Omit<PlaySandboxRuntimeLimits, 'timeoutSeconds'>
19
- >;
20
-
21
- export const STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS: PlaySandboxRuntimeLimits = {
22
- timeoutSeconds: 30 * 60,
23
- ...PLAY_SANDBOX_SIZE_LIMITS.standard,
24
- };
25
-
26
- // Product-wide ceilings. Organisation entitlements may lower these, but a
27
- // customer-authored Play can never ask Daytona for an unbounded resource.
28
- export const MAX_PLAY_SANDBOX_RUNTIME_LIMITS: PlaySandboxRuntimeLimits = {
29
- timeoutSeconds: 4 * 60 * 60,
30
- memoryGiB: STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS.memoryGiB,
31
- cpu: STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS.cpu,
32
- diskGiB: STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS.diskGiB,
33
- };
34
-
35
- export type PlaySandboxRuntimeDeclaration = {
36
- timeout?: string;
37
- size?: PlaySandboxSize;
38
- };
39
-
40
- function parseTimeout(value: string): number | null {
41
- const match = /^(\d+)\s*([mh])$/i.exec(value.trim());
42
- if (!match) return null;
43
- const amount = Number(match[1]);
44
- if (!Number.isSafeInteger(amount) || amount <= 0) return null;
45
- return amount * (match[2].toLowerCase() === 'h' ? 3600 : 60);
46
- }
47
-
48
- export function validatePlaySandboxRuntimeLimits(
49
- value: PlaySandboxRuntimeLimits,
50
- ): PlaySandboxRuntimeLimits {
51
- const base = STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS;
52
- for (const key of ['memoryGiB', 'cpu', 'diskGiB'] as const) {
53
- if (value[key] !== base[key]) {
54
- throw new Error(
55
- `Unsupported runtime sandbox resources: ${key}=${value[key]}. ` +
56
- `Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: "standard" ` +
57
- `(${base.cpu} CPU, ${base.memoryGiB}GiB memory, ${base.diskGiB}GiB disk).`,
58
- );
59
- }
60
- }
61
- if (
62
- !Number.isSafeInteger(value.timeoutSeconds) ||
63
- value.timeoutSeconds <= 0
64
- ) {
65
- throw new Error(
66
- 'Invalid runtime sandbox timeout. Use timeout like "90m" or "2h".',
67
- );
68
- }
69
- if (value.timeoutSeconds > MAX_PLAY_SANDBOX_RUNTIME_LIMITS.timeoutSeconds) {
70
- throw new Error(
71
- `Requested runtime timeoutSeconds=${value.timeoutSeconds} exceeds this organisation's maximum ${MAX_PLAY_SANDBOX_RUNTIME_LIMITS.timeoutSeconds}.`,
72
- );
73
- }
74
- return { ...value };
75
- }
76
-
77
- export function resolvePlaySandboxRuntimeLimits(
78
- declaration: PlaySandboxRuntimeDeclaration | null | undefined,
79
- ): PlaySandboxRuntimeLimits {
80
- const base = STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS;
81
- if (!declaration) return { ...base };
82
- const unsupportedProperties = Object.keys(declaration).filter(
83
- (key) => key !== 'timeout' && key !== 'size',
84
- );
85
- if (unsupportedProperties.length > 0) {
86
- throw new Error(
87
- `Unsupported runtime sandbox option${unsupportedProperties.length === 1 ? '' : 's'}: ${unsupportedProperties.join(', ')}. ` +
88
- 'Use runtime.size with a Deepline prebuilt sandbox. Supported sizes: "standard".',
89
- );
90
- }
91
- if (declaration.size !== undefined && declaration.size !== 'standard') {
92
- throw new Error(
93
- `Unsupported runtime sandbox size "${String(declaration.size)}". Supported sizes: "standard".`,
94
- );
95
- }
96
- const timeoutSeconds = declaration.timeout
97
- ? parseTimeout(declaration.timeout)
98
- : base.timeoutSeconds;
99
- if (timeoutSeconds === null) {
100
- throw new Error(
101
- 'Invalid runtime sandbox timeout. Use timeout like "90m" or "2h".',
102
- );
103
- }
104
- const size = declaration.size ?? 'standard';
105
- return validatePlaySandboxRuntimeLimits({
106
- timeoutSeconds,
107
- ...PLAY_SANDBOX_SIZE_LIMITS[size],
108
- });
109
- }
1
+ export * from '../plays/sandbox-runtime-limits';
@@ -1,4 +1,4 @@
1
- import type { PreviousCell } from './cell-staleness';
1
+ import type { PreviousCell } from '../plays/cell-staleness';
2
2
 
3
3
  export type StepProgramDatasetOptions = {
4
4
  runIf?: (
@@ -1,4 +1,4 @@
1
- import { getRuntimeEnv } from '../runtime-env';
1
+ import { getRuntimeEnv } from './runtime-env';
2
2
  import type { PlayRunnerEvent } from './protocol';
3
3
  import {
4
4
  runtimeTestFaultDrills,
@@ -3,7 +3,7 @@ import {
3
3
  normalizeToolHttpErrorMessage,
4
4
  type ToolHttpError,
5
5
  } from './tool-http-errors';
6
- import type { ToolExecutionErrorSchemaVersion } from '../tool-execution-error';
6
+ import type { ToolExecutionErrorSchemaVersion } from '../plays/tool-execution-error';
7
7
 
8
8
  export const TOOL_EXECUTE_TRANSIENT_HTTP_MAX_ATTEMPTS = 2;
9
9
  // A provider may need to finish the original request before it can replay the
@@ -37,10 +37,9 @@ function trimmed(value: OptionalKey): string | null {
37
37
  return normalized ? normalized : null;
38
38
  }
39
39
 
40
- function optionalCacheKey(value: OptionalKey): Pick<
41
- ToolResultExecutionMetadata,
42
- 'cacheKey'
43
- > {
40
+ function optionalCacheKey(
41
+ value: OptionalKey,
42
+ ): Pick<ToolResultExecutionMetadata, 'cacheKey'> {
44
43
  const cacheKey = trimmed(value);
45
44
  return cacheKey ? { cacheKey } : {};
46
45
  }
@@ -97,7 +96,9 @@ export function toolExecutionMetadataForOutcome(
97
96
  case 'in_flight': {
98
97
  const receiptKey = trimmed(outcome.receiptKey);
99
98
  if (!receiptKey) {
100
- throw new Error('In-flight durable tool results require a receipt key.');
99
+ throw new Error(
100
+ 'In-flight durable tool results require a receipt key.',
101
+ );
101
102
  }
102
103
  return {
103
104
  idempotent: true,
@@ -9,7 +9,7 @@ import {
9
9
  normalizeToolExecutionOrigin,
10
10
  type ToolExecutionErrorSchemaVersion,
11
11
  type ToolExecutionErrorOptions,
12
- } from '../tool-execution-error';
12
+ } from '../plays/tool-execution-error';
13
13
 
14
14
  const TOOL_HTTP_ERROR_BRAND = Symbol.for('deepline.tool-http-error.v1');
15
15