deepline 0.1.0 → 0.1.1

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 (97) hide show
  1. package/dist/cli/index.js +212 -54
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/cli/index.mjs +198 -40
  4. package/dist/cli/index.mjs.map +1 -1
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.mjs +1 -1
  9. package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +3256 -0
  10. package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +710 -0
  11. package/dist/repo/apps/play-runner-workers/src/entry.ts +5070 -0
  12. package/dist/repo/apps/play-runner-workers/src/runtime/README.md +21 -0
  13. package/dist/repo/apps/play-runner-workers/src/runtime/batching.ts +177 -0
  14. package/dist/repo/apps/play-runner-workers/src/runtime/execution-plan.ts +52 -0
  15. package/dist/repo/apps/play-runner-workers/src/runtime/tool-batch.ts +100 -0
  16. package/dist/repo/apps/play-runner-workers/src/runtime/tool-result.ts +184 -0
  17. package/dist/repo/sdk/src/cli/commands/auth.ts +482 -0
  18. package/dist/repo/sdk/src/cli/commands/billing.ts +188 -0
  19. package/dist/repo/sdk/src/cli/commands/csv.ts +123 -0
  20. package/dist/repo/sdk/src/cli/commands/db.ts +119 -0
  21. package/dist/repo/sdk/src/cli/commands/feedback.ts +40 -0
  22. package/dist/repo/sdk/src/cli/commands/org.ts +117 -0
  23. package/dist/repo/sdk/src/cli/commands/play.ts +3200 -0
  24. package/dist/repo/sdk/src/cli/commands/tools.ts +687 -0
  25. package/dist/repo/sdk/src/cli/dataset-stats.ts +341 -0
  26. package/dist/repo/sdk/src/cli/index.ts +138 -0
  27. package/dist/repo/sdk/src/cli/progress.ts +135 -0
  28. package/dist/repo/sdk/src/cli/trace.ts +61 -0
  29. package/dist/repo/sdk/src/cli/utils.ts +145 -0
  30. package/dist/repo/sdk/src/client.ts +1188 -0
  31. package/dist/repo/sdk/src/compat.ts +77 -0
  32. package/dist/repo/sdk/src/config.ts +285 -0
  33. package/dist/repo/sdk/src/errors.ts +125 -0
  34. package/dist/repo/sdk/src/http.ts +391 -0
  35. package/dist/repo/sdk/src/index.ts +139 -0
  36. package/dist/repo/sdk/src/play.ts +1330 -0
  37. package/dist/repo/sdk/src/plays/bundle-play-file.ts +133 -0
  38. package/dist/repo/sdk/src/plays/harness-stub.ts +210 -0
  39. package/dist/repo/sdk/src/plays/local-file-discovery.ts +326 -0
  40. package/dist/repo/sdk/src/tool-output.ts +489 -0
  41. package/dist/repo/sdk/src/types.ts +669 -0
  42. package/dist/repo/sdk/src/version.ts +2 -0
  43. package/dist/repo/sdk/src/worker-play-entry.ts +286 -0
  44. package/dist/repo/shared_libs/observability/node-tracing.ts +129 -0
  45. package/dist/repo/shared_libs/observability/tracing.ts +98 -0
  46. package/dist/repo/shared_libs/play-runtime/backend.ts +139 -0
  47. package/dist/repo/shared_libs/play-runtime/batch-runtime.ts +182 -0
  48. package/dist/repo/shared_libs/play-runtime/batching-types.ts +91 -0
  49. package/dist/repo/shared_libs/play-runtime/context.ts +3999 -0
  50. package/dist/repo/shared_libs/play-runtime/coordinator-headers.ts +78 -0
  51. package/dist/repo/shared_libs/play-runtime/ctx-contract.ts +250 -0
  52. package/dist/repo/shared_libs/play-runtime/ctx-types.ts +713 -0
  53. package/dist/repo/shared_libs/play-runtime/dataset-id.ts +10 -0
  54. package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +304 -0
  55. package/dist/repo/shared_libs/play-runtime/db-session.ts +462 -0
  56. package/dist/repo/shared_libs/play-runtime/dedup-backend.ts +0 -0
  57. package/dist/repo/shared_libs/play-runtime/default-batch-strategies.ts +124 -0
  58. package/dist/repo/shared_libs/play-runtime/execution-plan.ts +262 -0
  59. package/dist/repo/shared_libs/play-runtime/live-events.ts +214 -0
  60. package/dist/repo/shared_libs/play-runtime/live-state-contract.ts +50 -0
  61. package/dist/repo/shared_libs/play-runtime/map-execution-frame.ts +114 -0
  62. package/dist/repo/shared_libs/play-runtime/map-row-identity.ts +158 -0
  63. package/dist/repo/shared_libs/play-runtime/profiles.ts +90 -0
  64. package/dist/repo/shared_libs/play-runtime/progress-emitter.ts +172 -0
  65. package/dist/repo/shared_libs/play-runtime/protocol.ts +121 -0
  66. package/dist/repo/shared_libs/play-runtime/public-play-contract.ts +42 -0
  67. package/dist/repo/shared_libs/play-runtime/result-normalization.ts +33 -0
  68. package/dist/repo/shared_libs/play-runtime/runtime-actions.ts +208 -0
  69. package/dist/repo/shared_libs/play-runtime/runtime-api.ts +1873 -0
  70. package/dist/repo/shared_libs/play-runtime/runtime-constraints.ts +2 -0
  71. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-neon-serverless.ts +201 -0
  72. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver-pg.ts +48 -0
  73. package/dist/repo/shared_libs/play-runtime/runtime-pg-driver.ts +84 -0
  74. package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +174 -0
  75. package/dist/repo/shared_libs/play-runtime/static-pipeline-types.ts +147 -0
  76. package/dist/repo/shared_libs/play-runtime/suspension.ts +68 -0
  77. package/dist/repo/shared_libs/play-runtime/tool-batch-executor.ts +146 -0
  78. package/dist/repo/shared_libs/play-runtime/tool-result.ts +387 -0
  79. package/dist/repo/shared_libs/play-runtime/tracing.ts +31 -0
  80. package/dist/repo/shared_libs/play-runtime/waterfall-replay.ts +75 -0
  81. package/dist/repo/shared_libs/play-runtime/worker-api-types.ts +140 -0
  82. package/dist/repo/shared_libs/plays/artifact-transport.ts +14 -0
  83. package/dist/repo/shared_libs/plays/artifact-types.ts +49 -0
  84. package/dist/repo/shared_libs/plays/bundling/index.ts +1346 -0
  85. package/dist/repo/shared_libs/plays/compiler-manifest.ts +186 -0
  86. package/dist/repo/shared_libs/plays/contracts.ts +51 -0
  87. package/dist/repo/shared_libs/plays/dataset.ts +308 -0
  88. package/dist/repo/shared_libs/plays/definition.ts +264 -0
  89. package/dist/repo/shared_libs/plays/file-refs.ts +11 -0
  90. package/dist/repo/shared_libs/plays/rate-limit-scheduler.ts +206 -0
  91. package/dist/repo/shared_libs/plays/resolve-static-pipeline.ts +164 -0
  92. package/dist/repo/shared_libs/plays/row-identity.ts +302 -0
  93. package/dist/repo/shared_libs/plays/runtime-validation.ts +415 -0
  94. package/dist/repo/shared_libs/plays/static-pipeline.ts +560 -0
  95. package/dist/repo/shared_libs/temporal/constants.ts +39 -0
  96. package/dist/repo/shared_libs/temporal/preview-config.ts +153 -0
  97. package/package.json +4 -4
@@ -0,0 +1,140 @@
1
+ export type PlayStagedFileRef = {
2
+ storageKind: 'r2';
3
+ storageKey: string;
4
+ logicalPath: string;
5
+ fileName: string;
6
+ contentHash: string;
7
+ contentType: string;
8
+ bytes: number;
9
+ };
10
+
11
+ export type PlayVisualNodeProgress = {
12
+ completed?: number;
13
+ total?: number;
14
+ failed?: number;
15
+ message?: string;
16
+ updatedAt?: number;
17
+ startedAt?: number;
18
+ completedAt?: number;
19
+ artifactTableNamespace?: string | null;
20
+ };
21
+
22
+ export type PlayVisualNodeProgressMap = Record<string, PlayVisualNodeProgress>;
23
+
24
+ export type ComputeBillingItem = {
25
+ itemId: string;
26
+ source: string;
27
+ unit: string;
28
+ units: number;
29
+ providerCostUsd: number;
30
+ metadata?: unknown;
31
+ };
32
+
33
+ const DAYTONA_COMPUTE_PRICING_USD = {
34
+ vcpuSecond: 0.000014,
35
+ memoryGiBSecond: 0.0000045,
36
+ storageGiBSecond: 0.00000003,
37
+ includedStorageGiB: 5,
38
+ } as const;
39
+
40
+ const TEMPORAL_COMPUTE_PRICING_USD = {
41
+ action: 50 / 1_000_000,
42
+ } as const;
43
+
44
+ const NEON_COMPUTE_PRICING_USD = {
45
+ cuHour: 0.106,
46
+ defaultCu: 1,
47
+ } as const;
48
+
49
+ function roundUsd(amount: number): number {
50
+ return Number(Math.max(0, amount).toFixed(12));
51
+ }
52
+
53
+ export function resolveDaytonaSandboxComputeItem(input: {
54
+ itemId: string;
55
+ source?: string;
56
+ wallTimeSeconds: number;
57
+ cpu: number;
58
+ memoryGiB: number;
59
+ diskGiB: number;
60
+ sandboxId?: string | null;
61
+ startedAt?: number;
62
+ endedAt?: number;
63
+ }): ComputeBillingItem {
64
+ const billableSeconds = Math.max(1, Math.ceil(input.wallTimeSeconds));
65
+ const cpu = Math.max(0, input.cpu);
66
+ const memoryGiB = Math.max(0, input.memoryGiB);
67
+ const billableDiskGiB = Math.max(
68
+ 0,
69
+ input.diskGiB - DAYTONA_COMPUTE_PRICING_USD.includedStorageGiB,
70
+ );
71
+ const providerCostUsd = roundUsd(
72
+ billableSeconds *
73
+ (cpu * DAYTONA_COMPUTE_PRICING_USD.vcpuSecond +
74
+ memoryGiB * DAYTONA_COMPUTE_PRICING_USD.memoryGiBSecond +
75
+ billableDiskGiB *
76
+ DAYTONA_COMPUTE_PRICING_USD.storageGiBSecond),
77
+ );
78
+
79
+ return {
80
+ itemId: input.itemId,
81
+ source: input.source ?? 'daytona',
82
+ unit: 'sandbox_second',
83
+ units: billableSeconds,
84
+ providerCostUsd,
85
+ metadata: {
86
+ sandboxId: input.sandboxId ?? null,
87
+ cpu,
88
+ memoryGiB,
89
+ diskGiB: Math.max(0, input.diskGiB),
90
+ billableDiskGiB,
91
+ startedAt: input.startedAt,
92
+ endedAt: input.endedAt,
93
+ },
94
+ };
95
+ }
96
+
97
+ export function resolveTemporalComputeItem(input: {
98
+ itemId: string;
99
+ actions: number;
100
+ metadata?: unknown;
101
+ }): ComputeBillingItem {
102
+ const actions = Math.max(0, Math.ceil(input.actions));
103
+ return {
104
+ itemId: input.itemId,
105
+ source: 'temporal',
106
+ unit: 'action',
107
+ units: actions,
108
+ providerCostUsd: roundUsd(actions * TEMPORAL_COMPUTE_PRICING_USD.action),
109
+ metadata: input.metadata,
110
+ };
111
+ }
112
+
113
+ export function resolveNeonComputeItem(input: {
114
+ itemId: string;
115
+ activeSeconds: number;
116
+ cu?: number;
117
+ metadata?: unknown;
118
+ }): ComputeBillingItem {
119
+ const billableSeconds = Math.max(0, Math.ceil(input.activeSeconds));
120
+ const cu = Math.max(0, input.cu ?? NEON_COMPUTE_PRICING_USD.defaultCu);
121
+ return {
122
+ itemId: input.itemId,
123
+ source: 'neon',
124
+ unit: 'cu_second',
125
+ units: billableSeconds * cu,
126
+ providerCostUsd: roundUsd(
127
+ billableSeconds * cu * (NEON_COMPUTE_PRICING_USD.cuHour / 3600),
128
+ ),
129
+ metadata: {
130
+ activeSeconds: billableSeconds,
131
+ cu,
132
+ cuHourUsd: NEON_COMPUTE_PRICING_USD.cuHour,
133
+ ...(input.metadata && typeof input.metadata === 'object'
134
+ ? (input.metadata as Record<string, unknown>)
135
+ : input.metadata !== undefined
136
+ ? { inputMetadata: input.metadata }
137
+ : {}),
138
+ },
139
+ };
140
+ }
@@ -0,0 +1,14 @@
1
+ import type { PlayBundleArtifact } from './artifact-types';
2
+
3
+ const INLINE_SOURCE_MAP_PATTERN =
4
+ /\r?\n?\/\/# sourceMappingURL=data:application\/json;base64,[A-Za-z0-9+/=]+\s*$/;
5
+
6
+ export function compactPlayArtifactForRuntimeTransport(
7
+ artifact: PlayBundleArtifact,
8
+ ): PlayBundleArtifact {
9
+ return {
10
+ ...artifact,
11
+ bundledCode: artifact.bundledCode.replace(INLINE_SOURCE_MAP_PATTERN, ''),
12
+ sourceMap: '',
13
+ };
14
+ }
@@ -0,0 +1,49 @@
1
+ export type PlayPackageImport = {
2
+ name: string;
3
+ version: string | null;
4
+ };
5
+
6
+ export type PlayImportPolicy = {
7
+ localFiles: string[];
8
+ nodeBuiltins: string[];
9
+ packages: PlayPackageImport[];
10
+ };
11
+
12
+ export type PlayRuntimeFeature =
13
+ | 'artifact_storage'
14
+ | 'checkpoint_resume'
15
+ | 'durable_sleep'
16
+ | 'packaged_files';
17
+
18
+ export type PlayArtifactCompatibility = {
19
+ apiVersion: number;
20
+ artifactVersion: number;
21
+ minRunnerVersion: number;
22
+ runtimeFeatures: PlayRuntimeFeature[];
23
+ runtimeBackend?: string | null;
24
+ };
25
+
26
+ /**
27
+ * Identifies which runtime can consume this artifact:
28
+ * - cjs_node20: Daytona / local-process (Node.js)
29
+ * - esm_workers: Cloudflare Workers (V8 isolate)
30
+ */
31
+ export type PlayArtifactKind = 'cjs_node20' | 'esm_workers';
32
+
33
+ export type PlayBundleArtifact = {
34
+ codeFormat: 'cjs_module' | 'esm_module';
35
+ /** Defaults to cjs_node20 when not present (legacy artifacts). */
36
+ artifactKind?: PlayArtifactKind;
37
+ entryFile: string;
38
+ virtualFilename: string;
39
+ sourceHash: string;
40
+ graphHash: string;
41
+ artifactHash: string;
42
+ sourceMapHash: string;
43
+ bundledCode: string;
44
+ sourceMap: string;
45
+ importPolicy: PlayImportPolicy;
46
+ compatibility: PlayArtifactCompatibility;
47
+ generatedAt: number;
48
+ cacheHit: boolean;
49
+ };