deepline 0.3.513 → 0.3.514

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 (135) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/completed-answer.ts +134 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +25 -31
  4. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +1 -1
  5. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +33 -2
  6. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -4
  7. package/dist/cli/{artifacts-AMM4RZNI.mjs → artifacts-GNFL5LY4.mjs} +6 -6
  8. package/dist/cli/{artifacts-SZA52D3P.js → artifacts-OZRO4LHT.js} +18 -18
  9. package/dist/cli/{auth-3HQ7FXPX.mjs → auth-53EDAX7Y.mjs} +5 -5
  10. package/dist/cli/auth-SM5GLO45.js +43 -0
  11. package/dist/cli/{billing-SVFRN4BJ.js → billing-B6V3FELL.js} +82 -82
  12. package/dist/cli/{billing-7AIKDEQQ.mjs → billing-ZMX2V5X3.mjs} +7 -7
  13. package/dist/cli/{chunk-Y2SIHXYS.js → chunk-2CTTSNFE.js} +4 -4
  14. package/dist/cli/{chunk-JA5PBN44.js → chunk-2RCZCWPO.js} +6 -6
  15. package/dist/cli/{chunk-7NIBAJML.mjs → chunk-53F6JDQ3.mjs} +2 -2
  16. package/dist/cli/{chunk-CEWRCUSH.mjs → chunk-54IH5U3I.mjs} +5 -5
  17. package/dist/cli/{chunk-PFEFK2FB.js → chunk-55WBE4UK.js} +26 -26
  18. package/dist/cli/{chunk-QDGUDNVR.js → chunk-5LBXLQRW.js} +7 -7
  19. package/dist/cli/{chunk-LA66PYB4.mjs → chunk-6FYGFIXD.mjs} +2 -2
  20. package/dist/cli/{chunk-3SE4O52N.mjs → chunk-6OIRN4PC.mjs} +1 -1
  21. package/dist/cli/{chunk-7UVKC5G4.mjs → chunk-6SSISVXD.mjs} +1 -1
  22. package/dist/cli/{chunk-3WHK7WCP.mjs → chunk-753MZFDF.mjs} +3 -3
  23. package/dist/cli/{chunk-46QVEEXR.mjs → chunk-76M3DL5G.mjs} +1 -1
  24. package/dist/cli/{chunk-TWHJ4WCA.js → chunk-7KD4IYLA.js} +16 -16
  25. package/dist/cli/{chunk-ROJ55CXM.mjs → chunk-7MBI2OLW.mjs} +1 -1
  26. package/dist/cli/{chunk-ZKUXTF6X.mjs → chunk-7ZCXQDOQ.mjs} +2 -2
  27. package/dist/cli/{chunk-PGHCBL5G.js → chunk-A253CMOI.js} +3 -3
  28. package/dist/cli/{chunk-4EGBOZ53.js → chunk-BBDWIUJA.js} +9 -9
  29. package/dist/cli/{chunk-5IZXMA2L.js → chunk-C24VEYSP.js} +17 -4
  30. package/dist/cli/{chunk-VMLZQ3VM.js → chunk-CUMA6DE2.js} +14 -14
  31. package/dist/cli/{chunk-WFN6SB2B.mjs → chunk-DBBLPDXK.mjs} +1 -1
  32. package/dist/cli/{chunk-P2EHYH2Q.mjs → chunk-DLYWOHO4.mjs} +1 -1
  33. package/dist/cli/{chunk-JNNQ53BX.mjs → chunk-DMBCJFGY.mjs} +2 -2
  34. package/dist/cli/{chunk-FC6BR2OA.mjs → chunk-EO52BKGA.mjs} +13 -12
  35. package/dist/cli/{chunk-FLG3VIDQ.mjs → chunk-EVTD3ELD.mjs} +5 -5
  36. package/dist/cli/{chunk-HDDE4Y4V.js → chunk-FPWOEK7G.js} +2 -2
  37. package/dist/cli/{chunk-5T4SZPVO.mjs → chunk-G6A7CGFV.mjs} +2 -2
  38. package/dist/cli/{chunk-EAQQTYJL.js → chunk-G6PUQQJP.js} +5 -5
  39. package/dist/cli/{chunk-K3CUVLW7.mjs → chunk-H53YG6QG.mjs} +1 -1
  40. package/dist/cli/{chunk-P63SBUEW.mjs → chunk-H7L5MS5E.mjs} +1 -1
  41. package/dist/cli/{chunk-5UWWZLMX.mjs → chunk-HJ5B67S3.mjs} +17 -4
  42. package/dist/cli/{chunk-ROIFA4H7.mjs → chunk-ILITNKGM.mjs} +6 -6
  43. package/dist/cli/{chunk-ZDO67LFA.mjs → chunk-IZJGOMCW.mjs} +5 -5
  44. package/dist/cli/{chunk-YZW4ZLU3.js → chunk-JC3ABOZP.js} +21 -21
  45. package/dist/cli/{chunk-3UKVFI2R.js → chunk-LV2DGEJ3.js} +7 -7
  46. package/dist/cli/{chunk-ADB6FD2Q.js → chunk-MF7ZVWJK.js} +41 -41
  47. package/dist/cli/{chunk-KINDIV44.mjs → chunk-MJIS4XAZ.mjs} +4 -4
  48. package/dist/cli/{chunk-UDVX7HKU.js → chunk-MQK5SY5N.js} +16 -16
  49. package/dist/cli/{chunk-6UVAYLQG.js → chunk-NXT52SIV.js} +2 -2
  50. package/dist/cli/{chunk-MPOF4Z44.js → chunk-OQ4JV3IW.js} +1 -1
  51. package/dist/cli/{chunk-ORQVTTTM.js → chunk-QSFAUGFK.js} +5 -5
  52. package/dist/cli/{chunk-D72M5LBQ.js → chunk-R5PJ6XZI.js} +10 -10
  53. package/dist/cli/{chunk-XCP75LSJ.mjs → chunk-RFN7OKT2.mjs} +1 -1
  54. package/dist/cli/{chunk-U5QR527Y.js → chunk-RLVSWAWB.js} +44 -44
  55. package/dist/cli/{chunk-C5KH6FDN.mjs → chunk-RMRZ4BC4.mjs} +3 -3
  56. package/dist/cli/{chunk-OD72PULZ.mjs → chunk-RVMV4MXO.mjs} +2 -2
  57. package/dist/cli/{chunk-JI2LKS5V.js → chunk-T4NQ2ZOH.js} +11 -11
  58. package/dist/cli/{chunk-P6TG7COR.js → chunk-TG4IMWAL.js} +53 -53
  59. package/dist/cli/{chunk-6JNRYX65.js → chunk-TZS4G7CS.js} +2 -2
  60. package/dist/cli/{chunk-Z52XVM5I.js → chunk-VLIDBQYL.js} +3 -3
  61. package/dist/cli/{chunk-PPQU263U.mjs → chunk-W3TN352L.mjs} +2 -2
  62. package/dist/cli/{chunk-SDD75XIU.js → chunk-WP3ULMRU.js} +6 -6
  63. package/dist/cli/{chunk-H6WD65CD.js → chunk-Y2RIMVEM.js} +99 -98
  64. package/dist/cli/{chunk-B4BKATGX.mjs → chunk-Z5WO6IBV.mjs} +5 -5
  65. package/dist/cli/command-docs.js +2 -2
  66. package/dist/cli/command-docs.mjs +1 -1
  67. package/dist/cli/{csv-WKF5O6C4.js → csv-2BLYUV2G.js} +13 -13
  68. package/dist/cli/{csv-56JWAO3Y.mjs → csv-ONKAMLL4.mjs} +4 -4
  69. package/dist/cli/{db-SENEFS45.mjs → db-4GVSGAXL.mjs} +6 -6
  70. package/dist/cli/{db-UURETUXZ.js → db-YKT6LEQ3.js} +27 -27
  71. package/dist/cli/describe-KPGQP4LH.js +50 -0
  72. package/dist/cli/{describe-R3XKAGF5.mjs → describe-PRT2WQMS.mjs} +18 -18
  73. package/dist/cli/{executions-BAUUWHSW.mjs → executions-7OSL25KJ.mjs} +6 -6
  74. package/dist/cli/{executions-WZUS3S2K.js → executions-VFCU5NGH.js} +8 -8
  75. package/dist/cli/{feedback-Z6A7WMJS.js → feedback-ERTOLEC4.js} +10 -10
  76. package/dist/cli/{feedback-5SCDE247.mjs → feedback-RPZELEA5.mjs} +5 -5
  77. package/dist/cli/git-U353JURQ.js +25 -0
  78. package/dist/cli/{git-246MRTK7.mjs → git-XKRQZ4A6.mjs} +5 -5
  79. package/dist/cli/index.js +145 -145
  80. package/dist/cli/index.mjs +44 -44
  81. package/dist/cli/{legacy-noops-AKETAVNI.js → legacy-noops-HG3M5HGZ.js} +9 -9
  82. package/dist/cli/{legacy-noops-M242HT67.mjs → legacy-noops-MZCFS2FQ.mjs} +6 -6
  83. package/dist/cli/{monitors-N5T6PLCX.mjs → monitors-GBO5XAEZ.mjs} +7 -7
  84. package/dist/cli/{monitors-QIHYTSKD.js → monitors-MESMMU5P.js} +100 -100
  85. package/dist/cli/{org-YMDLKBVM.mjs → org-DJRNWIPO.mjs} +6 -6
  86. package/dist/cli/{org-BSCPIN7Y.js → org-EZPREEWH.js} +72 -72
  87. package/dist/cli/{pages-FRLPAY6I.mjs → pages-36BHVOFL.mjs} +6 -6
  88. package/dist/cli/{pages-BYSQBWD5.js → pages-ACI7VV6I.js} +18 -18
  89. package/dist/cli/{play-OIJAMP5P.js → play-KCLLAGWR.js} +317 -317
  90. package/dist/cli/{play-CMJI6RNI.mjs → play-SUSVQHX5.mjs} +18 -18
  91. package/dist/cli/{providers-KWFIH3E7.mjs → providers-MV2YW3J5.mjs} +6 -6
  92. package/dist/cli/{providers-6Q7H2RYZ.js → providers-YFO3EFLK.js} +9 -9
  93. package/dist/cli/{quickstart-UZWAQ7VJ.mjs → quickstart-KMXU2T3Z.mjs} +4 -4
  94. package/dist/cli/{quickstart-GU35UZPU.js → quickstart-MATFTZVQ.js} +6 -6
  95. package/dist/cli/{run-OYOQIVBM.js → run-UW5FM64G.js} +41 -41
  96. package/dist/cli/{run-AJ24G4CT.mjs → run-YRYVGUCJ.mjs} +23 -23
  97. package/dist/cli/search-4ZQOFG7G.js +33 -0
  98. package/dist/cli/{search-2KNDV3DL.mjs → search-WF3Q3I5X.mjs} +8 -8
  99. package/dist/cli/{search-output-526FOJQD.js → search-output-BG743WAM.js} +6 -6
  100. package/dist/cli/{search-output-X5TMIIA4.mjs → search-output-THOAHTCU.mjs} +4 -4
  101. package/dist/cli/{secrets-QL5SMK62.js → secrets-EOGBWN44.js} +15 -15
  102. package/dist/cli/{secrets-XEOGG6TV.mjs → secrets-LM7OTAUE.mjs} +6 -6
  103. package/dist/cli/sessions-GDSJ72XI.js +18 -0
  104. package/dist/cli/{sessions-Z352OY5B.mjs → sessions-SP2JL27H.mjs} +6 -6
  105. package/dist/cli/{settings-AET5AKBY.mjs → settings-JXTFX5G2.mjs} +13 -13
  106. package/dist/cli/{settings-EKLYIRWJ.js → settings-OWE3EEG7.js} +86 -86
  107. package/dist/cli/{setup-JPGTZYR2.mjs → setup-FG37SKMB.mjs} +10 -10
  108. package/dist/cli/{setup-IJWDEYLG.js → setup-Z5BEQKA7.js} +50 -50
  109. package/dist/cli/skills-SIX5OTNX.js +37 -0
  110. package/dist/cli/{skills-DGCK6723.mjs → skills-UGNCBZTJ.mjs} +8 -8
  111. package/dist/cli/tools-EZOV37MQ.js +57 -0
  112. package/dist/cli/{tools-7GEQLQWX.mjs → tools-J3PKLQSL.mjs} +17 -17
  113. package/dist/cli/{update-SAN6LDPT.mjs → update-GGZ2XTMZ.mjs} +10 -10
  114. package/dist/cli/update-ISU7YN34.js +35 -0
  115. package/dist/cli/{workflow-E4NGYGGM.js → workflow-AUZCSCZP.js} +17 -17
  116. package/dist/cli/{workflow-C66GOHRB.mjs → workflow-C66BBXHH.mjs} +7 -7
  117. package/dist/index.js +9 -9
  118. package/dist/index.mjs +6 -6
  119. package/dist/install-integrity.json +107 -106
  120. package/dist/plays/bundle-play-file.mjs +6 -4
  121. package/dist/release.d.mts +1 -1
  122. package/dist/release.d.ts +1 -1
  123. package/dist/release.js +2 -2
  124. package/dist/release.mjs +1 -1
  125. package/dist/server.js +5 -5
  126. package/dist/server.mjs +3 -3
  127. package/package.json +1 -1
  128. package/dist/cli/auth-THCURTEC.js +0 -43
  129. package/dist/cli/describe-GIJAGNZM.js +0 -50
  130. package/dist/cli/git-D5UAIEQE.js +0 -25
  131. package/dist/cli/search-UZM6U4MZ.js +0 -33
  132. package/dist/cli/sessions-T27GUYZX.js +0 -18
  133. package/dist/cli/skills-MLMVPHWG.js +0 -37
  134. package/dist/cli/tools-5WBKZRLQ.js +0 -57
  135. package/dist/cli/update-JK4NLT4H.js +0 -35
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.513',
208
+ version: '0.3.514',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -0,0 +1,134 @@
1
+ import {
2
+ isSerializedToolExecuteResult,
3
+ isToolExecuteResult,
4
+ } from './tool-result';
5
+
6
+ /**
7
+ * The one definition of a "completed successful answer": a result another
8
+ * call may be handed in place of calling the tool again. Publishing a result
9
+ * for reuse and reading one back both ask this function, so a result that may
10
+ * not be published can never be served either (including results published
11
+ * by an older runner that had no such check).
12
+ *
13
+ * Not decided here, because the surrounding layers already enforce them:
14
+ * errors throw and never reach a publish, a secret-tainted result throws in
15
+ * `executeWithFreshnessReceipt`, and a result larger than the receipt writer
16
+ * limit is skipped, never truncated.
17
+ */
18
+ export type CompletedAnswerVerdict =
19
+ | { eligible: true }
20
+ | { eligible: false; reason: CompletedAnswerRefusal };
21
+
22
+ export type CompletedAnswerRefusal =
23
+ /** null / undefined: nothing was answered. */
24
+ | 'empty'
25
+ /** The tool reported `no_result`. A "nothing found" answer is re-paid, never shared. */
26
+ | 'no_result'
27
+ /** Any envelope status other than `completed` (`failed`, `running`, unknown). */
28
+ | 'not_completed'
29
+ /** The response body says the request did not succeed (`ok`/`success` false). */
30
+ | 'error_shaped_body'
31
+ /** The provider answered that the work is not finished (pending, 202/222...). */
32
+ | 'non_final_response';
33
+
34
+ /**
35
+ * Top-level response-body `status` values that mean "accepted, not answered
36
+ * yet". This one is a denylist on purpose: a body `status` is provider data
37
+ * ('valid', 'invalid', 'found', 'catch_all'...), so an allowlist would refuse
38
+ * the common verification answers and re-pay for them. The envelope status
39
+ * above is the lifecycle and is an allowlist. A match only keeps the result
40
+ * out of reuse (the call is paid again), so the list is kept broad.
41
+ */
42
+ const NON_FINAL_BODY_STATUSES = new Set([
43
+ 'pending',
44
+ 'queued',
45
+ 'processing',
46
+ 'running',
47
+ 'in_progress',
48
+ 'in-progress',
49
+ 'inprogress',
50
+ 'accepted',
51
+ 'started',
52
+ 'more_time_required',
53
+ 'partial',
54
+ 'partial_failure',
55
+ 'submitted',
56
+ 'launched',
57
+ 'created',
58
+ 'scheduled',
59
+ 'queued_for_send',
60
+ 'in_flight',
61
+ 'waiting',
62
+ 'initiated',
63
+ ]);
64
+
65
+ /** HTTP statuses that are 2xx but carry no final verdict. */
66
+ const NON_FINAL_HTTP_STATUSES = new Set([202, 222]);
67
+
68
+ function isRecord(value: unknown): value is Record<string, unknown> {
69
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
70
+ }
71
+
72
+ function responseBodyOf(value: unknown): unknown {
73
+ if (isToolExecuteResult(value)) {
74
+ return value.toolResponse.rawV2 ?? value.toolResponse.raw;
75
+ }
76
+ if (isSerializedToolExecuteResult(value)) {
77
+ const response = value.toolResponse as Record<string, unknown>;
78
+ return 'rawV2' in response ? response.rawV2 : response.raw;
79
+ }
80
+ return undefined;
81
+ }
82
+
83
+ function bodyRefusal(
84
+ body: unknown,
85
+ nested = true,
86
+ ): CompletedAnswerRefusal | null {
87
+ if (!isRecord(body)) return null;
88
+ // Providers often wrap the answer: `{ data: { status: 'pending' } }`.
89
+ const wrapped = nested && isRecord(body.data) ? bodyRefusal(body.data, false) : null;
90
+ if (wrapped) return wrapped;
91
+ if (body.ok === false || body.success === false) return 'error_shaped_body';
92
+ const status = body.status;
93
+ if (
94
+ typeof status === 'string' &&
95
+ NON_FINAL_BODY_STATUSES.has(status.trim().toLowerCase())
96
+ ) {
97
+ return 'non_final_response';
98
+ }
99
+ for (const field of ['http_status', 'httpStatus', 'status_code', 'statusCode']) {
100
+ const code = body[field];
101
+ if (typeof code === 'number' && NON_FINAL_HTTP_STATUSES.has(code)) {
102
+ return 'non_final_response';
103
+ }
104
+ }
105
+ if (typeof status === 'number' && NON_FINAL_HTTP_STATUSES.has(status)) {
106
+ return 'non_final_response';
107
+ }
108
+ return null;
109
+ }
110
+
111
+ export function completedAnswerEligibility(
112
+ value: unknown,
113
+ ): CompletedAnswerVerdict {
114
+ if (value === undefined || value === null) {
115
+ return { eligible: false, reason: 'empty' };
116
+ }
117
+ const isTool =
118
+ isToolExecuteResult(value) || isSerializedToolExecuteResult(value);
119
+ if (!isTool) return { eligible: true };
120
+ const status = (value as { status: string }).status;
121
+ if (status === 'no_result') return { eligible: false, reason: 'no_result' };
122
+ // Fail safe: the gateway lifecycle status is exactly completed, no_result or
123
+ // running (ProviderOutcomeStatus), plus failed. Only `completed` is final;
124
+ // any other string, including ones not thought of yet, is refused.
125
+ if (status !== 'completed') {
126
+ return { eligible: false, reason: 'not_completed' };
127
+ }
128
+ const refusal = bodyRefusal(responseBodyOf(value));
129
+ return refusal ? { eligible: false, reason: refusal } : { eligible: true };
130
+ }
131
+
132
+ export function isCompletedSuccessfulAnswer(value: unknown): boolean {
133
+ return completedAnswerEligibility(value).eligible;
134
+ }
@@ -187,6 +187,7 @@ import {
187
187
  SlackHitlTimeoutError,
188
188
  } from '../plays/slack-hitl-timeout-error';
189
189
  import { InMemoryRateStateBackend } from './governor/in-memory-rate-state-backend';
190
+ import { isCompletedSuccessfulAnswer } from './completed-answer';
190
191
  import { pacingPolicyForTool } from './pacing';
191
192
  import {
192
193
  cloneToolExecuteResultWithExecution,
@@ -4144,6 +4145,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4144
4145
  execute: () => Promise<T>;
4145
4146
  completedAt?: (value: T) => number | undefined;
4146
4147
  sharesResult?: (value: T) => boolean;
4148
+ eligibleAnswer?: (value: T) => boolean;
4147
4149
  publishLatestOnRefresh?: true;
4148
4150
  /** Names the tool in the shared-cache skip log. */
4149
4151
  toolId?: string;
@@ -4177,6 +4179,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4177
4179
  store: this.durableReceiptExecutionStore(),
4178
4180
  completedAt: input.completedAt,
4179
4181
  sharesResult: input.sharesResult,
4182
+ eligibleAnswer: input.eligibleAnswer,
4180
4183
  ...(input.publishLatestOnRefresh
4181
4184
  ? { publishLatestOnRefresh: true as const }
4182
4185
  : {}),
@@ -6715,6 +6718,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
6715
6718
  isSerializedToolExecuteResult(receipt.output) ||
6716
6719
  isToolExecuteResult(receipt.output)
6717
6720
  ) ||
6721
+ !isCompletedSuccessfulAnswer(receipt.output) ||
6718
6722
  !this.canReuseToolResultForCurrentResponseContract(receipt.output)
6719
6723
  ) {
6720
6724
  return null;
@@ -6738,8 +6742,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
6738
6742
  !publish ||
6739
6743
  !DURABLE_RUNS_ROLLOUT.sharedReadCacheWrites ||
6740
6744
  !isToolExecuteResult(input.result) ||
6741
- input.result.status === 'no_result' ||
6742
- input.result.status === 'failed'
6745
+ !isCompletedSuccessfulAnswer(input.result)
6743
6746
  ) {
6744
6747
  return;
6745
6748
  }
@@ -14448,40 +14451,28 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14448
14451
  ...input,
14449
14452
  result_mode: undefined,
14450
14453
  });
14451
- const [eventWait, invocationScoped, retryPolicy, reusableSupport] =
14454
+ // A positive or null window on any tool call is the author's explicit
14455
+ // acceptance of reuse, including for writes, sends and purchases: a hit
14456
+ // returns the recorded answer and suppresses that repeat on purpose. Only
14457
+ // calls that are structurally not answers stay refused: event waits,
14458
+ // live datasets, Customer DB SQL mutations and Workspace operations.
14459
+ const eventWait =
14452
14460
  policy.effective === 0 && !refreshMayPublish
14453
- ? ([null, false, null, null] as const)
14454
- : await Promise.all([
14455
- this.#options.getIntegrationEventWaitHandler?.(toolId) ?? null,
14456
- this.#options
14457
- .getToolIdempotencyScope?.(toolId)
14458
- .then((scope) => scope === 'invocation') ?? false,
14459
- this.#options.getToolRetryPolicy?.(toolId, input) ?? null,
14460
- this.#options.getToolReusableResultSupport?.(toolId) ?? null,
14461
- ]);
14462
- const requiresExecutionFence = retryPolicy?.requiresExecutionFence === true;
14463
- if (policy.effective !== 0 && reusableSupport?.supported !== true) {
14464
- throw new Error(
14465
- `Tool ${toolId} does not support reusable freshness; use staleAfterSeconds: 0. ${reusableSupport?.unavailableReason ?? 'No read-result reuse capability was supplied by the action owner.'}`,
14466
- );
14467
- }
14461
+ ? null
14462
+ : ((await this.#options.getIntegrationEventWaitHandler?.(toolId)) ??
14463
+ null);
14468
14464
  const mustExecuteEveryTime = Boolean(
14469
14465
  eventWait ||
14470
- invocationScoped ||
14471
- requiresExecutionFence ||
14472
14466
  liveDataset ||
14473
14467
  sqlMutation ||
14474
14468
  isAlwaysFreshIntegrationTool(toolId),
14475
14469
  );
14476
- // Same eligibility as reuse: only a read whose result may serve a later
14477
- // call is shared. Writes and live observations never publish.
14478
- const publishLatestOnRefresh =
14479
- refreshMayPublish &&
14480
- reusableSupport?.supported === true &&
14481
- !mustExecuteEveryTime;
14470
+ // A refresh of a reusable call still publishes its fresh result as the
14471
+ // request's newest shared result; an authored 0 never does.
14472
+ const publishLatestOnRefresh = refreshMayPublish && !mustExecuteEveryTime;
14482
14473
  if (policy.effective !== 0 && mustExecuteEveryTime) {
14483
14474
  throw new Error(
14484
- `Tool ${toolId} does not support reusable freshness; use staleAfterSeconds: 0. Live datasets, event waits, invocation-scoped actions, writes, and Workspace operations cannot reuse an older result.`,
14475
+ `Tool ${toolId} cannot reuse an older result; use staleAfterSeconds: 0. Live datasets, event waits, Customer DB mutations, and Workspace operations are never reused.`,
14485
14476
  );
14486
14477
  }
14487
14478
 
@@ -14578,15 +14569,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14578
14569
  ? completedAt
14579
14570
  : value._metadata.execution.completedAt;
14580
14571
  },
14581
- sharesResult: (value) =>
14582
- !isToolExecuteResult(value) ||
14583
- (value.status !== 'no_result' && value.status !== 'failed'),
14572
+ sharesResult: isCompletedSuccessfulAnswer,
14573
+ eligibleAnswer: isCompletedSuccessfulAnswer,
14584
14574
  execute: async () => {
14575
+ // The freshness layer is the only reuse authority here. The legacy
14576
+ // durable call cache below it would otherwise hand back an earlier
14577
+ // completed-but-ineligible answer (a pending or empty result) that the
14578
+ // eligibility check just refused, so this call must reach the provider.
14585
14579
  const value = await this.executeToolLegacyInternal(
14586
14580
  key,
14587
14581
  toolId,
14588
14582
  requestInput,
14589
- { ...options },
14583
+ { ...options, force: true },
14590
14584
  true,
14591
14585
  );
14592
14586
  if ((await this.resolveToolAuthScopeDigest(toolId)) !== authScope) {
@@ -20,7 +20,7 @@ export function resolveExplicitDurableCallPolicy(input: {
20
20
  }): { requested: number | null; effective: number | null } {
21
21
  if (input.staleAfterSeconds === undefined) {
22
22
  throw new Error(
23
- 'Choose staleAfterSeconds explicitly: 0, a positive whole number of seconds, or null.',
23
+ 'Choose staleAfterSeconds explicitly: 0 for a fresh call, a positive whole number of seconds to accept a completed answer up to that old, or null to accept any age.',
24
24
  );
25
25
  }
26
26
  resolveDurableCallCachePolicy(input.staleAfterSeconds);
@@ -233,6 +233,13 @@ export async function executeWithFreshnessReceipt<T>(input: {
233
233
  * cache. Run history and bucket reuse are unchanged.
234
234
  */
235
235
  sharesResult?: (value: T) => boolean;
236
+ /**
237
+ * Whether a result is an answer another call may be handed. Set by tool
238
+ * calls only: it gates the per-window receipt and serving a cached entry,
239
+ * on top of `sharesResult`. Steps and fetches leave it unset, so a step that
240
+ * returned nothing keeps its policy-window reuse.
241
+ */
242
+ eligibleAnswer?: (value: T) => boolean;
236
243
  /**
237
244
  * An operator refresh (`--refresh-cache`) of a read whose authored policy
238
245
  * reuses results. Its effective policy is 0, so it reuses nothing, but its
@@ -432,6 +439,18 @@ export async function executeWithFreshnessReceipt<T>(input: {
432
439
  operationReceiptKey: operationKey,
433
440
  });
434
441
  };
442
+ /** The stored answer when it is eligible to serve another call, else null. */
443
+ const servedAnswer = async (
444
+ call: CompletedCall,
445
+ ): Promise<{ value: T } | null> => {
446
+ if (call.undefinedValue) return null;
447
+ const stored = (
448
+ call.valueReceiptKey
449
+ ? await readReferencedResult(call.valueReceiptKey)
450
+ : call.value
451
+ ) as T;
452
+ return input.eligibleAnswer?.(stored) === false ? null : { value: stored };
453
+ };
435
454
  const publish = async (
436
455
  key: string,
437
456
  call: CompletedCall,
@@ -506,8 +525,14 @@ export async function executeWithFreshnessReceipt<T>(input: {
506
525
  if (!cached) continue;
507
526
  const age = now() - cached.completedAt;
508
527
  if (age < 0 || (ttl !== null && age >= ttl * 1000)) continue;
528
+ // Read applies the same eligibility as publish, so an entry an older
529
+ // runner published (a failed, empty or still-running result) is a miss.
530
+ const served = input.eligibleAnswer
531
+ ? await servedAnswer(cached)
532
+ : undefined;
533
+ if (served === null) continue;
509
534
  const own = await publish(operationKey, cached);
510
- return outcome(own, 'reusable_result');
535
+ return outcome(own, 'reusable_result', served);
511
536
  }
512
537
  }
513
538
 
@@ -521,7 +546,13 @@ export async function executeWithFreshnessReceipt<T>(input: {
521
546
 
522
547
  // Recover this exact operation even if reusable publication fails afterwards.
523
548
  await publish(operationKey, completed);
524
- if (ttl !== 0) {
549
+ // The same eligibility gates the policy bucket and the newest shared
550
+ // result: a failed, empty or non-final answer recovers within this run but
551
+ // is never handed to another call.
552
+ const sharedAnswer = input.eligibleAnswer
553
+ ? input.eligibleAnswer(value)
554
+ : true;
555
+ if (ttl !== 0 && sharedAnswer) {
525
556
  const completionPartition =
526
557
  ttl === null
527
558
  ? 'indefinite'
@@ -28,10 +28,12 @@ export const EXPLICIT_FRESHNESS_PLAY_AUTHORING_THRESHOLD = 11 as const;
28
28
  export const REQUEST_DIGEST_CALL_SLOT_PLAY_AUTHORING_THRESHOLD = 12 as const;
29
29
  const EXPLICIT_FRESHNESS_STALE_AFTER_SECONDS_DESCRIPTION = [
30
30
  'Edition 11 requires an explicit choice.',
31
- '`0` starts a fresh logical call, though a matching operation receipt may recover that same operation after resume;',
32
- '`null` allows indefinite result reuse;',
33
- 'a positive integer is the maximum result age in seconds.',
34
- 'Omitted values retain legacy behavior in older editions.',
31
+ '`0` is a fresh call (so is omitting it in editions before 11); a matching operation receipt still recovers that same operation after resume.',
32
+ 'A positive integer accepts a completed, successful answer to the same request (workspace, credential, tool version) up to that many seconds old, otherwise the tool runs;',
33
+ '`null` accepts an answer of any age.',
34
+ 'A reused answer makes no provider call and no provider charge.',
35
+ 'This applies to every tool: a positive window on a write, send or purchase skips a repeat on purpose, so use 0 for a repeat and re-read after a write with 0.',
36
+ 'Failed, empty and unfinished answers are never reused.',
35
37
  ].join(' ');
36
38
  export const PLAY_AUTHORING_INPUT_SCHEMA_SNAPSHOT_EDITION = 3 as const;
37
39
  export const SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS = [
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  DeeplineClient
3
- } from "./chunk-ZKUXTF6X.mjs";
4
- import "./chunk-P63SBUEW.mjs";
3
+ } from "./chunk-7ZCXQDOQ.mjs";
4
+ import "./chunk-H7L5MS5E.mjs";
5
5
  import "./chunk-L2VKAASU.mjs";
6
6
  import "./chunk-N4TR6QRI.mjs";
7
7
  import "./chunk-S3A4IXBQ.mjs";
8
8
  import "./chunk-BMCRTI6Z.mjs";
9
9
  import {
10
10
  printCommandEnvelope
11
- } from "./chunk-5T4SZPVO.mjs";
11
+ } from "./chunk-G6A7CGFV.mjs";
12
12
  import {
13
13
  cliFeatureEnabled
14
- } from "./chunk-3SE4O52N.mjs";
15
- import "./chunk-7UVKC5G4.mjs";
14
+ } from "./chunk-6OIRN4PC.mjs";
15
+ import "./chunk-6SSISVXD.mjs";
16
16
  import "./chunk-4QF2K7TM.mjs";
17
17
  import "./chunk-DLIRSHV6.mjs";
18
18
  import "./chunk-HBL4PM5Q.mjs";
19
- import "./chunk-46QVEEXR.mjs";
19
+ import "./chunk-76M3DL5G.mjs";
20
20
  import "./chunk-WZYKRD7T.mjs";
21
21
  import "./chunk-KRD6H754.mjs";
22
22
 
@@ -1,22 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkEAQQTYJLjs = require('./chunk-EAQQTYJL.js');
4
- require('./chunk-QDGUDNVR.js');
3
+ var _chunkG6PUQQJPjs = require('./chunk-G6PUQQJP.js');
4
+ require('./chunk-5LBXLQRW.js');
5
5
  require('./chunk-E4CABWXL.js');
6
6
  require('./chunk-RNSHCJME.js');
7
7
  require('./chunk-NMU3VR5U.js');
8
8
  require('./chunk-WSGXBROE.js');
9
9
 
10
10
 
11
- var _chunk3UKVFI2Rjs = require('./chunk-3UKVFI2R.js');
11
+ var _chunkLV2DGEJ3js = require('./chunk-LV2DGEJ3.js');
12
12
 
13
13
 
14
- var _chunkPGHCBL5Gjs = require('./chunk-PGHCBL5G.js');
15
- require('./chunk-Y2SIHXYS.js');
14
+ var _chunkA253CMOIjs = require('./chunk-A253CMOI.js');
15
+ require('./chunk-2CTTSNFE.js');
16
16
  require('./chunk-ALJJRZNJ.js');
17
17
  require('./chunk-XNYIZMNQ.js');
18
18
  require('./chunk-DIAWYWT5.js');
19
- require('./chunk-MPOF4Z44.js');
19
+ require('./chunk-OQ4JV3IW.js');
20
20
  require('./chunk-OG64RBAC.js');
21
21
  require('./chunk-COGTRVWW.js');
22
22
 
@@ -24,7 +24,7 @@ require('./chunk-COGTRVWW.js');
24
24
  var _promises = require('fs/promises');
25
25
  var ARTIFACTS_FEATURE = "artifacts";
26
26
  function print(command, json, data, lines) {
27
- _chunk3UKVFI2Rjs.printCommandEnvelope.call(void 0,
27
+ _chunkLV2DGEJ3js.printCommandEnvelope.call(void 0,
28
28
  { command, ...data, render: { sections: [{ title: command, lines }] } },
29
29
  { json: Boolean(json), text: `${lines.join("\n")}
30
30
  ` }
@@ -56,7 +56,7 @@ function artifactLines(artifact) {
56
56
  ];
57
57
  }
58
58
  function registerArtifactsCommands(program) {
59
- const artifacts = program.command("artifacts", { hidden: !_chunkPGHCBL5Gjs.cliFeatureEnabled.call(void 0, ARTIFACTS_FEATURE) }).description(
59
+ const artifacts = program.command("artifacts", { hidden: !_chunkA253CMOIjs.cliFeatureEnabled.call(void 0, ARTIFACTS_FEATURE) }).description(
60
60
  "Show what a Play returns at a fixed URL on artifacts.deepline.com."
61
61
  ).addHelpText(
62
62
  "after",
@@ -69,7 +69,7 @@ Examples:
69
69
  );
70
70
  artifacts.command("list").description("List this workspace's artifacts.").option("--cursor <cursor>", "Continue from a previous page of results").option("--limit <n>", "Results per request, up to 100", Number).option("--json", "Emit raw JSON response").action(
71
71
  async (options) => run(async () => {
72
- const result = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().listArtifacts({
72
+ const result = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().listArtifacts({
73
73
  cursor: options.cursor,
74
74
  limit: options.limit
75
75
  });
@@ -84,7 +84,7 @@ Examples:
84
84
  );
85
85
  artifacts.command("get <id>").description("Show one artifact and what you may do with it.").option("--json", "Emit raw JSON response").action(
86
86
  async (id, options) => run(async () => {
87
- const artifact = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().getArtifact(id);
87
+ const artifact = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().getArtifact(id);
88
88
  print("artifacts get", options.json, artifact, [
89
89
  ...artifactLines(artifact),
90
90
  ` saved input ${JSON.stringify(artifact.input)}`
@@ -106,7 +106,7 @@ Examples:
106
106
  `
107
107
  ).action(
108
108
  async (options) => run(async () => {
109
- const artifact = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().createArtifact({
109
+ const artifact = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().createArtifact({
110
110
  name: options.name,
111
111
  play: options.play,
112
112
  ...options.input !== void 0 ? {
@@ -146,7 +146,7 @@ Examples:
146
146
  "Nothing to change. See: deepline artifacts edit --help"
147
147
  );
148
148
  }
149
- const artifact = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().updateArtifact(id, fields);
149
+ const artifact = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().updateArtifact(id, fields);
150
150
  print(
151
151
  "artifacts edit",
152
152
  options.json,
@@ -157,7 +157,7 @@ Examples:
157
157
  );
158
158
  artifacts.command("runs <id>").description("List runs of the artifact's Play, newest first.").option("--limit <n>", "Runs to list, up to 100", Number).option("--json", "Emit raw JSON response").action(
159
159
  async (id, options) => run(async () => {
160
- const result = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().listArtifactRuns(id, {
160
+ const result = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().listArtifactRuns(id, {
161
161
  limit: options.limit
162
162
  });
163
163
  print("artifacts runs", options.json, result, [
@@ -176,7 +176,7 @@ Examples:
176
176
  ).option("--json", "Emit raw JSON response").action(
177
177
  async (id, options) => run(async () => {
178
178
  const input = options.input !== void 0 ? await readJsonOption(options.input, "--input") : void 0;
179
- const started = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().refreshArtifact(id, input);
179
+ const started = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().refreshArtifact(id, input);
180
180
  print("artifacts refresh", options.json, started, [
181
181
  `Started run ${started.workflowId}.`,
182
182
  `Watch it: deepline runs get ${started.workflowId}`
@@ -188,7 +188,7 @@ Examples:
188
188
  if (access !== "workspace" && access !== "public") {
189
189
  throw new Error("Access is workspace or public.");
190
190
  }
191
- const artifact = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().setArtifactAccess(
191
+ const artifact = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().setArtifactAccess(
192
192
  id,
193
193
  access
194
194
  );
@@ -202,7 +202,7 @@ Examples:
202
202
  );
203
203
  artifacts.command("delete <id>").description("Delete an artifact. Its Play and runs are not touched.").option("--json", "Emit raw JSON response").action(
204
204
  async (id, options) => run(async () => {
205
- const result = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().deleteArtifact(id);
205
+ const result = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().deleteArtifact(id);
206
206
  print("artifacts delete", options.json, result, [
207
207
  `Deleted artifact ${id}.`
208
208
  ]);
@@ -213,7 +213,7 @@ Examples:
213
213
  );
214
214
  permissions.command("get", { isDefault: true }).description("Show the workspace's artifact rules and what you may do.").option("--json", "Emit raw JSON response").action(
215
215
  async (options) => run(async () => {
216
- const result = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().getArtifactPermissions();
216
+ const result = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().getArtifactPermissions();
217
217
  print("artifacts permissions", options.json, result, [
218
218
  ...Object.entries(result.rules).map(
219
219
  ([verb, level]) => `${verb}: ${level}`
@@ -251,7 +251,7 @@ Examples:
251
251
  "Pass at least one rule. See: deepline artifacts permissions set --help"
252
252
  );
253
253
  }
254
- const result = await new (0, _chunkEAQQTYJLjs.DeeplineClient)().setArtifactPermissions(rules);
254
+ const result = await new (0, _chunkG6PUQQJPjs.DeeplineClient)().setArtifactPermissions(rules);
255
255
  print(
256
256
  "artifacts permissions set",
257
257
  options.json,
@@ -14,14 +14,14 @@ import {
14
14
  reportSetupCompleted,
15
15
  resolvePendingAuthClaimForResume,
16
16
  statusBannerLine
17
- } from "./chunk-C5KH6FDN.mjs";
18
- import "./chunk-5T4SZPVO.mjs";
19
- import "./chunk-3SE4O52N.mjs";
20
- import "./chunk-7UVKC5G4.mjs";
17
+ } from "./chunk-RMRZ4BC4.mjs";
18
+ import "./chunk-G6A7CGFV.mjs";
19
+ import "./chunk-6OIRN4PC.mjs";
20
+ import "./chunk-6SSISVXD.mjs";
21
21
  import "./chunk-4QF2K7TM.mjs";
22
22
  import "./chunk-DLIRSHV6.mjs";
23
23
  import "./chunk-HBL4PM5Q.mjs";
24
- import "./chunk-46QVEEXR.mjs";
24
+ import "./chunk-76M3DL5G.mjs";
25
25
  import "./chunk-WZYKRD7T.mjs";
26
26
  import "./chunk-KRD6H754.mjs";
27
27
  export {
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunkTG4IMWALjs = require('./chunk-TG4IMWAL.js');
18
+ require('./chunk-LV2DGEJ3.js');
19
+ require('./chunk-A253CMOI.js');
20
+ require('./chunk-2CTTSNFE.js');
21
+ require('./chunk-ALJJRZNJ.js');
22
+ require('./chunk-XNYIZMNQ.js');
23
+ require('./chunk-DIAWYWT5.js');
24
+ require('./chunk-OQ4JV3IW.js');
25
+ require('./chunk-OG64RBAC.js');
26
+ require('./chunk-COGTRVWW.js');
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ exports.EXIT_WORKSPACE_MISMATCH = _chunkTG4IMWALjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunkTG4IMWALjs.authStatusLine; exports.clearPendingClaim = _chunkTG4IMWALjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunkTG4IMWALjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunkTG4IMWALjs.handleRegister; exports.handleStatus = _chunkTG4IMWALjs.handleStatus; exports.handleWait = _chunkTG4IMWALjs.handleWait; exports.httpJson = _chunkTG4IMWALjs.httpJson; exports.readPendingAuthClaim = _chunkTG4IMWALjs.readPendingAuthClaim; exports.readStatusBanner = _chunkTG4IMWALjs.readStatusBanner; exports.registerAuthCommands = _chunkTG4IMWALjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunkTG4IMWALjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunkTG4IMWALjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunkTG4IMWALjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunkTG4IMWALjs.statusBannerLine;