deepline 0.3.71 → 0.3.73

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 (26) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +712 -632
  3. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +2 -0
  4. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +40 -10
  5. package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +116 -4
  6. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +4 -1
  7. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +2 -14
  8. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/native-batch.ts +9 -92
  9. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +159 -621
  10. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +19 -13
  11. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -5
  12. package/dist/bundling-sources/shared_libs/plays/contracts.ts +1 -4
  13. package/dist/bundling-sources/shared_libs/plays/tool-response-contract.ts +2 -4
  14. package/dist/cli/index.js +324 -123
  15. package/dist/cli/index.mjs +324 -123
  16. package/dist/{compiler-manifest-IkyvsUO-.d.mts → compiler-manifest-CMNgA_JQ.d.mts} +7 -1
  17. package/dist/{compiler-manifest-IkyvsUO-.d.ts → compiler-manifest-CMNgA_JQ.d.ts} +7 -1
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +32 -3
  21. package/dist/index.mjs +32 -3
  22. package/dist/install-integrity.json +2 -2
  23. package/dist/plays/bundle-play-file.d.mts +2 -2
  24. package/dist/plays/bundle-play-file.d.ts +2 -2
  25. package/dist/plays/bundle-play-file.mjs +1 -1
  26. package/package.json +1 -1
@@ -48,6 +48,8 @@ export type RuntimeStepToolResultReceiptsInput = {
48
48
  */
49
49
  executionLock?: {
50
50
  required?: boolean;
51
+ /** Provider-operation identity; defaults to the result-cache receipt. */
52
+ key?: string;
51
53
  ttlMs?: number;
52
54
  waitMs?: number;
53
55
  pollMs?: number;
@@ -88,6 +90,7 @@ type OwnedReceipt = {
88
90
  ownerRunId: string;
89
91
  force: boolean;
90
92
  executionLockOwnerId: string | null;
93
+ executionLockKey: string | null;
91
94
  lockLost: boolean;
92
95
  completedByAnotherOwner: ToolExecuteResult | null;
93
96
  heartbeatTimer: ReturnType<typeof setTimeout> | null;
@@ -99,9 +102,9 @@ type OwnedReceipt = {
99
102
  *
100
103
  * Tool results deliberately use the store's immutable completed-cache mode:
101
104
  * a cache hit is reused, execution does not publish a `running` row, and the
102
- * winner inserts one serialized ToolExecuteResult. That is what lets a V2
103
- * receipt key be distinct from a legacy one without creating another provider
104
- * invocation fence. The provider fence remains the dispatcher's Operation.
105
+ * winner inserts one canonical serialized ToolExecuteResult. Response
106
+ * presentation is materialized after cache recovery; only actions that
107
+ * explicitly require an execution fence acquire the optional lock below.
105
108
  */
106
109
  export function createRuntimeStepToolResultReceipts(
107
110
  input: RuntimeStepToolResultReceiptsInput,
@@ -164,7 +167,7 @@ export function createRuntimeStepToolResultReceipts(
164
167
  return;
165
168
  }
166
169
  await input.store.releaseExecutionLock({
167
- receiptKey: record.resultReceiptKey,
170
+ receiptKey: record.executionLockKey ?? record.resultReceiptKey,
168
171
  ownerExecutionId: record.executionLockOwnerId,
169
172
  });
170
173
  record.executionLockOwnerId = null;
@@ -177,7 +180,7 @@ export function createRuntimeStepToolResultReceipts(
177
180
  return 'active';
178
181
  }
179
182
  const renewed = await input.store.acquireExecutionLock({
180
- receiptKey: record.resultReceiptKey,
183
+ receiptKey: record.executionLockKey ?? record.resultReceiptKey,
181
184
  ownerExecutionId: record.executionLockOwnerId,
182
185
  ttlMs: lock.ttlMs,
183
186
  });
@@ -238,7 +241,7 @@ export function createRuntimeStepToolResultReceipts(
238
241
  const acquireExecutionLock = async (
239
242
  resultReceiptKey: string,
240
243
  force: boolean,
241
- ): Promise<string | null> => {
244
+ ): Promise<{ ownerId: string; key: string } | null> => {
242
245
  if (!lock.required || !input.store.enabled) return null;
243
246
  if (
244
247
  !input.store.acquireExecutionLock ||
@@ -249,11 +252,12 @@ export function createRuntimeStepToolResultReceipts(
249
252
  );
250
253
  }
251
254
 
255
+ const executionLockKey = lock.key || resultReceiptKey;
252
256
  const ownerExecutionId = `tool-result:${crypto.randomUUID()}`;
253
257
  const deadline = Date.now() + lock.waitMs;
254
258
  while (true) {
255
259
  const acquired = await input.store.acquireExecutionLock({
256
- receiptKey: resultReceiptKey,
260
+ receiptKey: executionLockKey,
257
261
  ownerExecutionId,
258
262
  ttlMs: lock.ttlMs,
259
263
  });
@@ -265,13 +269,13 @@ export function createRuntimeStepToolResultReceipts(
265
269
  const cached = await readCompleted(resultReceiptKey, 'in_flight');
266
270
  if (cached) {
267
271
  await input.store.releaseExecutionLock({
268
- receiptKey: resultReceiptKey,
272
+ receiptKey: executionLockKey,
269
273
  ownerExecutionId,
270
274
  });
271
275
  return null;
272
276
  }
273
277
  }
274
- return ownerExecutionId;
278
+ return { ownerId: ownerExecutionId, key: executionLockKey };
275
279
  }
276
280
 
277
281
  if (!force) {
@@ -299,11 +303,11 @@ export function createRuntimeStepToolResultReceipts(
299
303
  if (cached) return { kind: 'completed', result: cached };
300
304
  }
301
305
 
302
- const executionLockOwnerId = await acquireExecutionLock(
306
+ const executionLock = await acquireExecutionLock(
303
307
  resultReceiptKey,
304
308
  candidate.force,
305
309
  );
306
- if (input.store.enabled && !candidate.force && !executionLockOwnerId) {
310
+ if (input.store.enabled && !candidate.force && !executionLock) {
307
311
  const cached = await readCompleted(resultReceiptKey, 'cache');
308
312
  if (cached) return { kind: 'completed', result: cached };
309
313
  // The only non-lock reason to get here is a store without a lock
@@ -311,12 +315,13 @@ export function createRuntimeStepToolResultReceipts(
311
315
  }
312
316
 
313
317
  const leaseId =
314
- executionLockOwnerId ?? `tool-result:${crypto.randomUUID()}`;
318
+ executionLock?.ownerId ?? `tool-result:${crypto.randomUUID()}`;
315
319
  owned.set(leaseId, {
316
320
  resultReceiptKey,
317
321
  ownerRunId,
318
322
  force: candidate.force,
319
- executionLockOwnerId,
323
+ executionLockOwnerId: executionLock?.ownerId ?? null,
324
+ executionLockKey: executionLock?.key ?? null,
320
325
  lockLost: false,
321
326
  completedByAnotherOwner: null,
322
327
  heartbeatTimer: null,
@@ -505,6 +510,7 @@ function normalizeExecutionLock(
505
510
  }
506
511
  return {
507
512
  required: input?.required === true,
513
+ key: input?.key?.trim() ?? '',
508
514
  ttlMs: Math.floor(ttlMs),
509
515
  waitMs: Math.floor(waitMs),
510
516
  pollMs: Math.floor(pollMs),
@@ -456,9 +456,7 @@ export type PlayAuthoringCronInput<TInput> = TInput extends readonly unknown[]
456
456
  : never;
457
457
 
458
458
  /** The one public type for options accepted by definePlay. */
459
- export type PlayAuthoringBindings<
460
- TInput = Record<string, unknown>,
461
- > = {
459
+ export type PlayAuthoringBindings<TInput = Record<string, unknown>> = {
462
460
  description?: string;
463
461
  compatibility?: {
464
462
  toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
@@ -1239,7 +1237,14 @@ export interface PlayAuthoringRuntimeContext {
1239
1237
  options: PlayAuthoringCallOptions,
1240
1238
  ): Promise<TOutput>;
1241
1239
 
1242
- log(message: string): void;
1240
+ /**
1241
+ * Write a customer-safe line to the durable Run Log Stream. Omitting level
1242
+ * preserves the historical info-level behavior.
1243
+ */
1244
+ log(
1245
+ message: string,
1246
+ options?: { level?: 'debug' | 'info' | 'warn' | 'error' },
1247
+ ): void;
1243
1248
  sleep(ms: number): Promise<void>;
1244
1249
  }
1245
1250
 
@@ -2783,7 +2788,7 @@ export const PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
2783
2788
  " fetch(key: string, url: string | URL, init?: RequestInit & { headers?: HeadersInit & { 'Idempotency-Key'?: string; 'X-Idempotency-Key'?: string }; auth?: SecretAuthInput }, options?: FetchOptions): Promise<PlayFetchResponse>;",
2784
2789
  ' secrets: { get(name: string): SecretPromise; bearer(secret: string | SecretPromise | SecretHandle): SecretAuth; header(header: string, secret: string | SecretPromise | SecretHandle): SecretAuth };',
2785
2790
  ` runPlay<TOutput = unknown>(key: string, playRef: ${cloudReferenceType('ctx.runPlay.playRef')}, input: ${cloudReferenceType('ctx.runPlay.input')}, options: PlayCallOptions): Promise<TOutput>;`,
2786
- ' log(message: string): void;',
2791
+ " log(message: string, options?: { level?: 'debug' | 'info' | 'warn' | 'error' }): void;",
2787
2792
  ` sleep(ms: ${cloudReferenceType('ctx.sleep.ms')}): Promise<void>;`,
2788
2793
  '}',
2789
2794
  "export type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = { id: string; description?: string; input: PlayInputContract<TInput>; run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>; bindings?: PlayBindings<TInput>; billing?: PlayBindings<TInput>['billing']; runtime?: PlayBindings<TInput>['runtime']; compatibility?: PlayBindings<TInput>['compatibility'] };",
@@ -50,10 +50,7 @@ export type PlayContractCompatibilitySnapshot = {
50
50
  authoringContractEdition?: PlayAuthoringContractEdition;
51
51
  /** Immutable execute-result transport selected when the artifact is built. */
52
52
  toolResponseContract?: ToolResponseContract;
53
- /**
54
- * Deliberate receipt-cache boundary for a response transformation. Missing
55
- * preserves the original namespace of artifacts written before this field.
56
- */
53
+ /** Legacy response metadata; it does not change completed-result caching. */
57
54
  toolResponseReceiptRevision?: string;
58
55
  };
59
56
 
@@ -10,9 +10,8 @@ export const V2_TOOL_RESPONSE_CONTRACT = 'v2-tool-response' as const;
10
10
  export const RAW_V2_TOOL_RESPONSE_CONTRACT = 'raw-v2' as const;
11
11
 
12
12
  /**
13
- * Deliberate durable-receipt boundary for the raw-v2 response transformation.
14
- * Bump only when that transformation changes serialized tool output. Do not
15
- * bump for ordinary protocol, authoring, or transport contract changes.
13
+ * Legacy artifact compatibility metadata. It is carried through published
14
+ * artifacts but does not partition completed-result cache entries.
16
15
  */
17
16
  export const RAW_V2_TOOL_RESPONSE_RECEIPT_REVISION = 'raw-v2-receipt-v1';
18
17
  const TOOL_RESPONSE_RECEIPT_REVISION_PATTERN =
@@ -36,7 +35,6 @@ export function isToolResponseContract(
36
35
  /**
37
36
  * Preserves the distinction between an old artifact with no declared response
38
37
  * contract and an artifact that explicitly selected the legacy V2 contract.
39
- * Receipt reuse is controlled separately by `toolResponseReceiptRevision`.
40
38
  */
41
39
  export function declaredToolResponseContract(
42
40
  value: unknown,