deepline 0.3.16 → 0.3.18

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 (27) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +7 -0
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/integrations/bettercontact-execution-policy.ts +29 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +45 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/batch-runtime.ts +19 -3
  6. package/dist/bundling-sources/shared_libs/play-runtime/bettercontact-batching.ts +726 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +45 -24
  8. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +254 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +6 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +28 -3
  12. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +3 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +5 -2
  14. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +344 -26
  15. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +50 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1 -1
  17. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +378 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/runtime-reliability-policy.ts +391 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +125 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +21 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +36 -39
  22. package/dist/cli/index.js +265 -1
  23. package/dist/cli/index.mjs +265 -1
  24. package/dist/index.js +265 -1
  25. package/dist/index.mjs +265 -1
  26. package/dist/install-integrity.json +6 -0
  27. package/package.json +1 -1
@@ -88,6 +88,10 @@ import type { PlayCompilerManifest } from '../../shared_libs/plays/compiler-mani
88
88
  import type { EnrichCompiledConfig } from './cli/enrich-play-compiler.js';
89
89
  import { RUNTIME_ENVIRONMENT_TOKEN_HEADER } from '../../shared_libs/play-runtime/coordinator-headers.js';
90
90
  import { resolveTheirstackClientTimeoutMs } from '../../shared_libs/integrations/theirstack-execution-policy.js';
91
+ import {
92
+ BETTERCONTACT_LAUNCHER_CLIENT_TIMEOUT_MS,
93
+ usesExtendedBetterContactLauncherBudget,
94
+ } from '../../shared_libs/integrations/bettercontact-execution-policy.js';
91
95
  import {
92
96
  normalizePlayRuntimeEnvironment,
93
97
  normalizePlayRuntimeNamespace,
@@ -460,6 +464,9 @@ function resolveToolExecuteTimeoutMs(
460
464
  input,
461
465
  );
462
466
  if (theirstackTimeoutMs !== null) return theirstackTimeoutMs;
467
+ if (usesExtendedBetterContactLauncherBudget(normalized)) {
468
+ return BETTERCONTACT_LAUNCHER_CLIENT_TIMEOUT_MS;
469
+ }
463
470
  return normalized === 'deeplineagent' ||
464
471
  normalized === 'deeplineagent_deeplineagent' ||
465
472
  normalized === 'ai_inference' ||
@@ -192,7 +192,7 @@ export const SDK_RELEASE = {
192
192
  // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
193
193
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
194
194
  // getters keep their established compatibility behavior.
195
- version: '0.3.16',
195
+ version: '0.3.18',
196
196
  updateSummary:
197
197
  'New raw-v2 tool responses preserve complete scrubbed provider envelopes at toolResponse.rawV2, including JSON:API included resources, links, cursors, and totals. Existing toolResponse.raw and declared getters keep working unchanged.',
198
198
  contracts: {
@@ -0,0 +1,29 @@
1
+ /**
2
+ * BetterContact launchers are upstream-async but Deepline gives callers a
3
+ * bounded synchronous convenience wait before returning a pollable request
4
+ * id. Keep the provider and SDK budgets together so the client cannot abandon
5
+ * a launched job while the server is still inside that documented path.
6
+ */
7
+
8
+ /** Per-request upstream timeout used by BetterContact launch and poll calls. */
9
+ export const BETTERCONTACT_UPSTREAM_REQUEST_TIMEOUT_MS = 30_000;
10
+
11
+ /**
12
+ * Client budget for a BetterContact launcher response.
13
+ *
14
+ * Covers route cold start, the bounded synchronous wait, one in-flight
15
+ * upstream request, and response serialization without widening unrelated
16
+ * tool requests.
17
+ */
18
+ export const BETTERCONTACT_LAUNCHER_CLIENT_TIMEOUT_MS = 120_000;
19
+
20
+ const BETTERCONTACT_LAUNCHER_TOOL_IDS = new Set([
21
+ 'bettercontact_enrich',
22
+ 'bettercontact_bulk_enrich',
23
+ ]);
24
+
25
+ export function usesExtendedBetterContactLauncherBudget(
26
+ toolId: string,
27
+ ): boolean {
28
+ return BETTERCONTACT_LAUNCHER_TOOL_IDS.has(toolId.trim().toLowerCase());
29
+ }
@@ -52,6 +52,11 @@ import {
52
52
  import { vercelProtectionBypassHeaders } from '@shared_libs/play-runtime/vercel-protection';
53
53
  import type { RuntimeReceiptAction } from '@shared_libs/play-runtime/runtime-actions';
54
54
  import { RUNTIME_CAPACITY_POLICY } from '@shared_libs/play-runtime/runtime-capacity-policy';
55
+ import {
56
+ DEFAULT_RUNTIME_TRAFFIC_POLICY,
57
+ isRuntimeTrafficPolicy,
58
+ type RuntimeTrafficPolicy,
59
+ } from '@shared_libs/play-runtime/runtime-traffic-policy';
55
60
 
56
61
  export type StoredPlayArtifactPayload = {
57
62
  sourceCode: string;
@@ -217,6 +222,7 @@ type RuntimeApiRequest =
217
222
  | ({
218
223
  action: 'governor_budget_charge';
219
224
  } & PlayRunnerBudgetChargeInput)
225
+ | { action: 'get_runtime_traffic_policy' }
220
226
  | RuntimeReceiptAction;
221
227
 
222
228
  export type WorkerRuntimeApiContext = {
@@ -1472,6 +1478,45 @@ export async function chargeGovernorBudgetViaAppRuntime(
1472
1478
  });
1473
1479
  }
1474
1480
 
1481
+ export async function getRuntimeTrafficPolicyViaAppRuntime(
1482
+ context: WorkerRuntimeApiContext,
1483
+ ): Promise<RuntimeTrafficPolicy> {
1484
+ const response = await postAppRuntimeApi<unknown>(context, {
1485
+ action: 'get_runtime_traffic_policy',
1486
+ });
1487
+ if (isRuntimeTrafficPolicy(response)) return response;
1488
+ // A 200 response is not enough to activate an incident control. A rollout
1489
+ // mismatch or proxy body must behave as a control-plane outage (and use the
1490
+ // caller's visible compiled-default fallback), never as an implicit limit.
1491
+ throw new AppRuntimeApiResponseError({
1492
+ action: 'get_runtime_traffic_policy',
1493
+ status: 502,
1494
+ code: 'runtime_traffic_policy_invalid_response',
1495
+ retryable: true,
1496
+ detail:
1497
+ 'Runtime traffic policy response did not match the versioned contract.',
1498
+ });
1499
+ }
1500
+
1501
+ /**
1502
+ * The incident policy is a load-reduction overlay, never an execution
1503
+ * prerequisite. During an app/Convex rolling deploy or a control-plane outage
1504
+ * it is safer to use the compiled normal policy than to strand every new Play
1505
+ * before sandbox creation. Callers must emit the returned diagnostic; this is
1506
+ * intentionally a visible fail-open, not a silent fallback.
1507
+ */
1508
+ export function fallbackRuntimeTrafficPolicyForUnavailableControlPlane(
1509
+ error: unknown,
1510
+ ): RuntimeTrafficPolicy | null {
1511
+ if (
1512
+ error instanceof AppRuntimeApiTransportError ||
1513
+ (error instanceof AppRuntimeApiResponseError && error.status >= 500)
1514
+ ) {
1515
+ return DEFAULT_RUNTIME_TRAFFIC_POLICY;
1516
+ }
1517
+ return null;
1518
+ }
1519
+
1475
1520
  export async function writeStagedFileFromAppRuntime(
1476
1521
  context: WorkerRuntimeApiContext,
1477
1522
  file: Pick<PlayStagedFileRef, 'storageKey'>,
@@ -102,16 +102,31 @@ export async function executeChunkedRequests<TRequest, TResult>(input: {
102
102
  input.weightOf,
103
103
  );
104
104
  for (const chunk of chunks) {
105
+ // notifyChain serializes onChunkComplete calls (the caller's callback can
106
+ // touch shared, non-concurrency-safe state) without letting one entry's
107
+ // callback failure skip a sibling's callback. A naive `.then()` chain
108
+ // would propagate a rejection forward and silently drop every queued
109
+ // notify() behind it -- for BetterContact/native-batch callers that
110
+ // means a correlation-mismatch throw on one row would leak the tool
111
+ // slots of every other row in the same chunk, since their
112
+ // onChunkComplete (and its `finally { releaseToolSlot() }`) would never
113
+ // run. Each callback failure is caught and re-thrown only after every
114
+ // queued entry in the chunk has had its callback invoked.
105
115
  let notifyChain: Promise<void> = Promise.resolve();
116
+ let firstCallbackFailure: unknown;
106
117
  const notify = async (
107
118
  entry: ChunkExecutionResult<TRequest, TResult>,
108
119
  ): Promise<void> => {
109
120
  if (input.retainResults !== false) {
110
121
  results.push(entry);
111
122
  }
112
- notifyChain = notifyChain.then(
113
- async () => await input.onChunkComplete?.([entry]),
114
- );
123
+ notifyChain = notifyChain.then(async () => {
124
+ try {
125
+ await input.onChunkComplete?.([entry]);
126
+ } catch (error) {
127
+ firstCallbackFailure ??= error;
128
+ }
129
+ });
115
130
  await notifyChain;
116
131
  };
117
132
 
@@ -135,6 +150,7 @@ export async function executeChunkedRequests<TRequest, TResult>(input: {
135
150
  }),
136
151
  );
137
152
  await notifyChain;
153
+ if (firstCallbackFailure !== undefined) throw firstCallbackFailure;
138
154
  }
139
155
 
140
156
  return results;