deepline 0.3.582 → 0.3.583

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 (145) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +14 -0
  3. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +53 -6
  4. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +14 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +69 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +33 -4
  7. package/dist/cli/{agents-UAXDG4FS.mjs → agents-G344SPW2.mjs} +68 -4
  8. package/dist/cli/{agents-2L73CJHH.js → agents-ZPDXVPEE.js} +95 -31
  9. package/dist/cli/{auth-3B2QB4UH.mjs → auth-V66RP2A6.mjs} +5 -5
  10. package/dist/cli/auth-VU6VIPVY.js +44 -0
  11. package/dist/cli/{billing-CPBRWG3M.mjs → billing-BTMGZJCR.mjs} +9 -9
  12. package/dist/cli/{billing-E7FO622G.js → billing-ROYUQF67.js} +105 -105
  13. package/dist/cli/{chunk-V54YQHPV.js → chunk-23LYXVI4.js} +6 -6
  14. package/dist/cli/{chunk-CYZSHD66.js → chunk-2D5YISAL.js} +2 -2
  15. package/dist/cli/{chunk-OUFOJTEJ.mjs → chunk-2QIVGZKS.mjs} +5 -5
  16. package/dist/cli/{chunk-NZR5PBNP.mjs → chunk-43MKV6E4.mjs} +3 -3
  17. package/dist/cli/{chunk-EGH4JNJP.js → chunk-6GYGMWQV.js} +8 -8
  18. package/dist/cli/{chunk-KDITCSPN.mjs → chunk-6S3OAJCJ.mjs} +19 -0
  19. package/dist/cli/{chunk-JD7P73ZW.mjs → chunk-72MEXMSH.mjs} +1 -1
  20. package/dist/cli/{chunk-ISN4F6AY.js → chunk-73IZARR5.js} +13 -13
  21. package/dist/cli/{chunk-NVHICORD.mjs → chunk-7AFTLM74.mjs} +2 -2
  22. package/dist/cli/{chunk-7QX5PCHP.mjs → chunk-ACS6BYE5.mjs} +2 -2
  23. package/dist/cli/{chunk-POYADK77.js → chunk-AHQDUMDM.js} +20 -20
  24. package/dist/cli/{chunk-JF4DUC2F.mjs → chunk-AXKFZIXC.mjs} +2 -2
  25. package/dist/cli/{chunk-LDMCTV2Z.mjs → chunk-AXOQ2FMS.mjs} +1 -1
  26. package/dist/cli/{chunk-HP6A3JCX.js → chunk-BUMCOVBP.js} +5 -5
  27. package/dist/cli/{chunk-SYWLWTWM.mjs → chunk-C233ZRNX.mjs} +4 -4
  28. package/dist/cli/{chunk-EB2YLLZJ.js → chunk-C7UCDL2K.js} +41 -41
  29. package/dist/cli/{chunk-H3KVMALU.js → chunk-CCC3NIYB.js} +9 -9
  30. package/dist/cli/{chunk-4ZAWRCB6.mjs → chunk-DNYFNOWG.mjs} +5 -5
  31. package/dist/cli/{chunk-ZARGHLZZ.mjs → chunk-EHV52KUV.mjs} +1 -1
  32. package/dist/cli/{chunk-6NEMTKTA.mjs → chunk-GFX6CDAB.mjs} +5 -5
  33. package/dist/cli/{chunk-JUZIMW4S.js → chunk-GQHZV7EQ.js} +7 -7
  34. package/dist/cli/{chunk-ZH23XGJO.js → chunk-H4BYWEV5.js} +4 -4
  35. package/dist/cli/{chunk-I5J6HGVR.mjs → chunk-H7F3ROT3.mjs} +2 -2
  36. package/dist/cli/{chunk-2K6EIL2D.mjs → chunk-HOGRT5X6.mjs} +1 -1
  37. package/dist/cli/{chunk-DPLYQITT.js → chunk-HYT5B2NL.js} +2 -2
  38. package/dist/cli/{chunk-G5YU6RJ4.mjs → chunk-J54DMFV5.mjs} +2 -2
  39. package/dist/cli/{chunk-FWB3QR7W.mjs → chunk-JQT3SHXL.mjs} +1 -1
  40. package/dist/cli/{chunk-4TTEAUZV.mjs → chunk-K6GDSCFL.mjs} +3 -3
  41. package/dist/cli/{chunk-XYQMOXP4.mjs → chunk-KSXBLXLV.mjs} +1 -1
  42. package/dist/cli/{chunk-Y36SQMSN.js → chunk-LHD3HOYN.js} +19 -0
  43. package/dist/cli/{chunk-LHA45DNY.mjs → chunk-LVJAHM2I.mjs} +3 -3
  44. package/dist/cli/{chunk-YPP436NM.js → chunk-MEAWK5G7.js} +53 -53
  45. package/dist/cli/{chunk-MRSYC74T.js → chunk-MFPHCUHK.js} +5 -5
  46. package/dist/cli/{chunk-D7J33HTK.mjs → chunk-N5RCXI3M.mjs} +5 -5
  47. package/dist/cli/{chunk-KQEW3EAU.js → chunk-N5XRUZRS.js} +16 -16
  48. package/dist/cli/{chunk-U2QQQNWW.mjs → chunk-P2YNTAGL.mjs} +2 -2
  49. package/dist/cli/{chunk-CPZL6Z7D.js → chunk-PGUK5VPC.js} +2 -2
  50. package/dist/cli/{chunk-VA35T3AF.js → chunk-PULU5YGX.js} +20 -20
  51. package/dist/cli/{chunk-ABJZQHON.mjs → chunk-PVDP3AZY.mjs} +4 -4
  52. package/dist/cli/{chunk-NJGXYYHN.js → chunk-QGOHEJVJ.js} +5 -5
  53. package/dist/cli/{chunk-3EOET5UB.js → chunk-QPN662ZP.js} +100 -100
  54. package/dist/cli/{chunk-Z3IAEHID.js → chunk-RO2LTLJA.js} +48 -48
  55. package/dist/cli/{chunk-3DVWSTAI.mjs → chunk-ROWROMXD.mjs} +1 -1
  56. package/dist/cli/{chunk-ROUNT4NX.mjs → chunk-U6BTY4WS.mjs} +1 -1
  57. package/dist/cli/{chunk-FBSPHBAF.js → chunk-VH45GV3T.js} +1 -1
  58. package/dist/cli/{chunk-5436ZJPH.js → chunk-VXDKL434.js} +3 -3
  59. package/dist/cli/{chunk-PNQVB4UD.mjs → chunk-VXEZKZU4.mjs} +11 -11
  60. package/dist/cli/{chunk-SKKRESFB.js → chunk-W3ECB7GC.js} +3 -3
  61. package/dist/cli/{chunk-RNZXMOA6.mjs → chunk-W5WLWRKL.mjs} +2 -2
  62. package/dist/cli/{chunk-DI5MULNX.js → chunk-WAZR72D5.js} +26 -26
  63. package/dist/cli/{chunk-GZBXN56A.js → chunk-WUVDJSZE.js} +23 -23
  64. package/dist/cli/{chunk-ZL3O7F5J.js → chunk-YRNWA2IL.js} +15 -15
  65. package/dist/cli/{chunk-3HIJNXRB.js → chunk-ZFJNIZHI.js} +10 -10
  66. package/dist/cli/{chunk-DSHIB2XQ.mjs → chunk-ZHIJA4MW.mjs} +1 -1
  67. package/dist/cli/command-docs.js +2 -2
  68. package/dist/cli/command-docs.mjs +1 -1
  69. package/dist/cli/concurrent-runs-help-6WUNDV77.js +22 -0
  70. package/dist/cli/{concurrent-runs-help-UFNYQYU2.mjs → concurrent-runs-help-A2Y33OQ5.mjs} +6 -6
  71. package/dist/cli/{csv-QSDRGLQH.mjs → csv-PS74WVXE.mjs} +4 -4
  72. package/dist/cli/{csv-ZI5LYFHF.js → csv-TKSR2LFV.js} +13 -13
  73. package/dist/cli/{db-WVWXNNMO.mjs → db-EXLBRZ7K.mjs} +6 -6
  74. package/dist/cli/{db-ZDL6Q53U.js → db-R6GOM4VC.js} +27 -27
  75. package/dist/cli/describe-CA2FL2OS.js +50 -0
  76. package/dist/cli/{describe-UUQBKUVL.mjs → describe-JJBXFPVQ.mjs} +18 -18
  77. package/dist/cli/{executions-SCGHTWTC.js → executions-474U7R3Y.js} +8 -8
  78. package/dist/cli/{executions-QN3OYJKT.mjs → executions-5PEODJQG.mjs} +6 -6
  79. package/dist/cli/{feedback-7QPHLXGU.mjs → feedback-QUQVRDBD.mjs} +6 -6
  80. package/dist/cli/{feedback-6QQ7ONLW.js → feedback-URTCAOXP.js} +14 -14
  81. package/dist/cli/{git-HFPJX573.mjs → git-AQF23KKU.mjs} +5 -5
  82. package/dist/cli/git-WJ4V2B4T.js +26 -0
  83. package/dist/cli/index.js +148 -148
  84. package/dist/cli/index.mjs +47 -47
  85. package/dist/cli/{integrations-4SZ5O24P.mjs → integrations-5POBI72U.mjs} +7 -7
  86. package/dist/cli/{integrations-ND2HULSH.js → integrations-NMFOOSS4.js} +29 -29
  87. package/dist/cli/{legacy-noops-WUP3TBR2.mjs → legacy-noops-6YVCOSFO.mjs} +6 -6
  88. package/dist/cli/{legacy-noops-GQF6AYP5.js → legacy-noops-V75T5LHV.js} +9 -9
  89. package/dist/cli/{mcp-3GUFYGCQ.mjs → mcp-7WEYQ5V7.mjs} +4 -4
  90. package/dist/cli/{mcp-L3YYVEU6.js → mcp-N6GYXCUQ.js} +24 -24
  91. package/dist/cli/{monitors-CVZZN5WG.js → monitors-HW4H4PE5.js} +100 -100
  92. package/dist/cli/{monitors-OFCVJSH5.mjs → monitors-TAK4M5Y4.mjs} +7 -7
  93. package/dist/cli/{org-3DTAYA52.mjs → org-3C2RN36N.mjs} +6 -6
  94. package/dist/cli/{org-MQ5AUN7I.js → org-FULXOXNE.js} +121 -121
  95. package/dist/cli/{outcomes-42W24EXG.mjs → outcomes-4KRZL6OL.mjs} +6 -6
  96. package/dist/cli/{outcomes-MGDUYHUD.js → outcomes-O3HDQWGN.js} +14 -14
  97. package/dist/cli/{play-IMAD7QTV.js → play-HA4RGX7T.js} +336 -336
  98. package/dist/cli/{play-PD45RNYZ.mjs → play-ZTRWUODW.mjs} +19 -19
  99. package/dist/cli/{providers-WONHPTRG.js → providers-DXMKWBZN.js} +9 -9
  100. package/dist/cli/{providers-DYKHG7NV.mjs → providers-FAKWWJE2.mjs} +6 -6
  101. package/dist/cli/{quickstart-6AAFULGC.js → quickstart-MA74UPNI.js} +6 -6
  102. package/dist/cli/{quickstart-5QPGHLEX.mjs → quickstart-YWGBTW77.mjs} +4 -4
  103. package/dist/cli/{run-WOW7QO3W.js → run-4DXSGXRB.js} +44 -44
  104. package/dist/cli/{run-4K6ZU7H7.mjs → run-QHCYMSBP.mjs} +23 -23
  105. package/dist/cli/{search-CKVFWVXQ.mjs → search-N4ZOK5XX.mjs} +7 -7
  106. package/dist/cli/search-V765JH2H.js +32 -0
  107. package/dist/cli/{search-output-B5QE7ZNK.js → search-output-D5VAC52B.js} +6 -6
  108. package/dist/cli/{search-output-WWB25JWA.mjs → search-output-F2OYLVK2.mjs} +4 -4
  109. package/dist/cli/{secrets-WKIMR346.js → secrets-3KETOTDS.js} +15 -15
  110. package/dist/cli/{secrets-SVZB6TSW.mjs → secrets-LD4FVAQI.mjs} +6 -6
  111. package/dist/cli/{sessions-P3QENG6T.mjs → sessions-LPLI4Z4O.mjs} +6 -6
  112. package/dist/cli/sessions-XC65OMDS.js +23 -0
  113. package/dist/cli/{settings-V5ABL6D2.mjs → settings-NCGPJG3Z.mjs} +12 -12
  114. package/dist/cli/{settings-UIFRGJW3.js → settings-NFBTCOMB.js} +85 -85
  115. package/dist/cli/{setup-A5MIJU3S.js → setup-ATBSUSH4.js} +49 -49
  116. package/dist/cli/{setup-E67NJTEF.mjs → setup-NH6MRYXZ.mjs} +9 -9
  117. package/dist/cli/skills-4NQBTGOL.js +37 -0
  118. package/dist/cli/{skills-WLHOQ4DO.mjs → skills-ITPBPIXD.mjs} +7 -7
  119. package/dist/cli/{tools-EG4KL3BB.mjs → tools-2XZPR65V.mjs} +17 -17
  120. package/dist/cli/tools-ZVOFATX2.js +57 -0
  121. package/dist/cli/update-QME3KPOP.js +37 -0
  122. package/dist/cli/{update-IPFBE6SA.mjs → update-VFB22FWO.mjs} +9 -9
  123. package/dist/cli/{views-XDN6SEWY.mjs → views-MRN3HWTG.mjs} +6 -6
  124. package/dist/cli/{views-ZIBY2RVB.js → views-WJUZOQM2.js} +21 -21
  125. package/dist/cli/{workflow-O2XPMOVL.mjs → workflow-A6P7YV5W.mjs} +42 -18
  126. package/dist/cli/{workflow-BLKPBRBT.js → workflow-Q4JFBTVH.js} +53 -29
  127. package/dist/index.js +9 -9
  128. package/dist/index.mjs +6 -6
  129. package/dist/install-integrity.json +116 -116
  130. package/dist/release.d.mts +1 -1
  131. package/dist/release.d.ts +1 -1
  132. package/dist/release.js +2 -2
  133. package/dist/release.mjs +1 -1
  134. package/dist/server.js +5 -5
  135. package/dist/server.mjs +3 -3
  136. package/package.json +1 -1
  137. package/dist/cli/auth-ALBG5LF4.js +0 -44
  138. package/dist/cli/concurrent-runs-help-E3YMAO5Q.js +0 -22
  139. package/dist/cli/describe-QB5T47B3.js +0 -50
  140. package/dist/cli/git-4FXTWHXT.js +0 -26
  141. package/dist/cli/search-YZIJS7QU.js +0 -32
  142. package/dist/cli/sessions-VQPGPXMU.js +0 -23
  143. package/dist/cli/skills-GTBK33MV.js +0 -37
  144. package/dist/cli/tools-GPAIPRPQ.js +0 -57
  145. package/dist/cli/update-QLWS32WR.js +0 -37
@@ -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.582',
208
+ version: '0.3.583',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -372,6 +372,13 @@ export type WorkflowRunExecutionTokenClaims =
372
372
  * number: a projector uses it only within its own bound.
373
373
  */
374
374
  run_ledger_terminal_backlog_prefix_facts?: number;
375
+ /**
376
+ * The issuing build serves `project_run_events_prefixed`. Minted beside
377
+ * `run_ledger_ingress_prefix_origin` by builds that serve that action and
378
+ * never by older ones, so it is the projector's opt-in for multi-fact
379
+ * receipts to a mutable receiver.
380
+ */
381
+ run_ledger_prefixed_projection?: true;
375
382
  };
376
383
 
377
384
  export type RuntimeRateScopeTokenClaims = {
@@ -698,6 +705,8 @@ function isValidWorkflowClaimsShape(
698
705
  isValidRuntimeOrigin(claims.run_ledger_ingress_prefix_origin)) &&
699
706
  (claims.run_ledger_terminal_backlog_prefix_facts === undefined ||
700
707
  typeof claims.run_ledger_terminal_backlog_prefix_facts === 'number') &&
708
+ (claims.run_ledger_prefixed_projection === undefined ||
709
+ claims.run_ledger_prefixed_projection === true) &&
701
710
  Array.isArray(claims.capabilities) &&
702
711
  claims.capabilities.length > 0 &&
703
712
  claims.capabilities.every(isRuntimeExecutionCapability) &&
@@ -932,6 +941,11 @@ export async function mintWorkflowRunExecutionToken(input: {
932
941
  // the facts its verifier proves (run-ledger-projection-contract).
933
942
  run_ledger_terminal_backlog_prefix_facts:
934
943
  RUN_LEDGER_TERMINAL_BACKLOG_PREFIX_MAX_FACTS,
944
+ // This build serves `project_run_events_prefixed`. A projector may
945
+ // send this run's multi-fact receipts to a mutable receiver only on
946
+ // this claim: an older app never mints it, so a runtime deployed
947
+ // first, or an app rolled back past this build, opts no new run in.
948
+ run_ledger_prefixed_projection: true,
935
949
  }
936
950
  : {}),
937
951
  sub: input.subject ?? 'workflow_executor',
@@ -1,4 +1,9 @@
1
- import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
1
+ import {
2
+ createHash,
3
+ createHmac,
4
+ randomBytes,
5
+ timingSafeEqual,
6
+ } from 'node:crypto';
2
7
  import {
3
8
  earlySandboxCapUnits,
4
9
  type PlaySandboxRuntimeLimits,
@@ -164,7 +169,8 @@ export const MODAL_SANDBOX_TAGS_MAX_BYTES = 512;
164
169
  /** Bytes Modal counts toward that cap: every tag name and value (UTF-8). */
165
170
  export function modalSandboxTagsBytes(tags: Record<string, string>): number {
166
171
  return Object.entries(tags).reduce(
167
- (sum, [name, value]) => sum + Buffer.byteLength(name) + Buffer.byteLength(value),
172
+ (sum, [name, value]) =>
173
+ sum + Buffer.byteLength(name) + Buffer.byteLength(value),
168
174
  0,
169
175
  );
170
176
  }
@@ -252,7 +258,12 @@ export function verifyEarlyPrebootPlan(input: {
252
258
  nowMs: number;
253
259
  }):
254
260
  | { plan: EarlyPrebootPlan }
255
- | { refused: 'preboot_plan_missing' | 'preboot_plan_invalid' | 'preboot_stale' } {
261
+ | {
262
+ refused:
263
+ | 'preboot_plan_missing'
264
+ | 'preboot_plan_invalid'
265
+ | 'preboot_stale';
266
+ } {
256
267
  const value = input.tags[EARLY_PREBOOT_TAG];
257
268
  // `1` (the create-time claim) or absent: not published (yet). Any other
258
269
  // plan form (an older or newer build's) is refused, never guessed at.
@@ -668,6 +679,17 @@ export type EarlySandboxAdapter<
668
679
  }): Promise<EarlySandboxSweepOutcome | { skipped: string }>;
669
680
  };
670
681
 
682
+ /**
683
+ * An advisory check run inside the fire-and-forget create, before any
684
+ * provider call: a skip names why this run would not adopt in time (its
685
+ * org's sandbox capacity is full, so the run will queue past the adoption
686
+ * window). Null, or a rejected check, creates as before.
687
+ */
688
+ export type EarlySandboxCreateGate = () => Promise<{
689
+ reason: string;
690
+ [detail: string]: unknown;
691
+ } | null>;
692
+
671
693
  /**
672
694
  * Start (fire and forget) the early sandbox for an admitted run. Idempotent
673
695
  * per process; a second hint for the same run is ignored.
@@ -675,6 +697,7 @@ export type EarlySandboxAdapter<
675
697
  export function startEarlySandbox<TSandbox extends EarlySandboxHandle>(
676
698
  adapter: EarlySandboxAdapter<TSandbox>,
677
699
  input: EarlySandboxStartRequest,
700
+ options: { createGate?: EarlySandboxCreateGate } = {},
678
701
  ): boolean {
679
702
  if (
680
703
  !resolveExperimentSwitch(
@@ -700,14 +723,38 @@ export function startEarlySandbox<TSandbox extends EarlySandboxHandle>(
700
723
  });
701
724
  if (adapter.registry.hinted(key)) return false;
702
725
  const hintAtMs = Date.now();
703
- const started = (async () =>
704
- await adapter.createEarly({
726
+ const createGate = options.createGate;
727
+ const started = (async () => {
728
+ if (createGate) {
729
+ const skip = await createGate().catch((error: unknown) => {
730
+ // Advisory: a failed check creates exactly as before.
731
+ logEarlySandbox(adapter.logScope, 'create_gate_failed', {
732
+ key,
733
+ orgId,
734
+ error: error instanceof Error ? error.message : String(error),
735
+ });
736
+ return null;
737
+ });
738
+ if (skip) {
739
+ // Resolves null like a failed create: the registry releases the
740
+ // entry's units and the launch creates its own sandbox.
741
+ logEarlySandbox(adapter.logScope, 'create_skipped', {
742
+ key,
743
+ orgId,
744
+ workflowId: input.workflowId,
745
+ ...skip,
746
+ });
747
+ return null;
748
+ }
749
+ }
750
+ return await adapter.createEarly({
705
751
  ...input,
706
752
  key,
707
753
  orgId,
708
754
  hintAtMs,
709
755
  scope,
710
- }))().catch((error: unknown) => {
756
+ });
757
+ })().catch((error: unknown) => {
711
758
  logEarlySandbox(adapter.logScope, 'create_failed', {
712
759
  key,
713
760
  orgId,
@@ -85,6 +85,11 @@ export const RUNTIME_OPERATION_CAPABILITIES = {
85
85
  repair_runtime_storage_grants: 'sheet.write',
86
86
  append_run_events: 'run.progress',
87
87
  project_run_events: 'run.progress',
88
+ // A multi-fact Run Ledger receipt for a run.events prefix. Identical to
89
+ // project_run_events at a receiver that proves prefixes; its own name is
90
+ // the capability fence, so an older app refuses it instead of reading a
91
+ // multi-fact receipt with single-fact proof.
92
+ project_run_events_prefixed: 'run.progress',
88
93
  save_results: 'run.progress',
89
94
  start_run: 'run.progress',
90
95
  record_first_claim_latency: 'run.progress',
@@ -135,6 +140,13 @@ export const RUNTIME_OPERATION_CONTRACT: DeployedOperationContract =
135
140
  kind: 'equivalent-fallback',
136
141
  action: 'append_run_events',
137
142
  },
143
+ // Never degrade to project_run_events: that would hand a multi-fact
144
+ // receipt to a receiver without prefix proof. The projector retains
145
+ // the claimed facts and retries after the newer app promotes.
146
+ project_run_events_prefixed: {
147
+ kind: 'feature-unavailable',
148
+ code: 'RUN_LEDGER_PREFIX_RECEIPT_UNAVAILABLE',
149
+ },
138
150
  // The runner retains the complete result before attempting this
139
151
  // compact completion. An older app receiver reports the action as
140
152
  // unsupported, and the adapter retries the established full-payload
@@ -175,6 +187,7 @@ const BLOCKED_ACCOUNT_COMPLETION_OPERATIONS = new Set<string>([
175
187
  'heartbeat_runtime_step_receipts',
176
188
  'append_run_events',
177
189
  'project_run_events',
190
+ 'project_run_events_prefixed',
178
191
  'save_results',
179
192
  'compute_billing_upsert',
180
193
  'compute_billing_record_item',
@@ -241,6 +254,7 @@ export function runtimeOperationCapabilityForRequest(
241
254
  capabilities.length !== 1 ||
242
255
  ![
243
256
  'project_run_events',
257
+ 'project_run_events_prefixed',
244
258
  'project_run_created',
245
259
  'append_run_events',
246
260
  'start_run',
@@ -405,6 +405,7 @@ import {
405
405
  reserveRuntimeSandboxOperation,
406
406
  RUNTIME_SANDBOX_CAPACITY_LEASE_MS,
407
407
  runtimeSandboxCapacityAdmissionMode,
408
+ type RuntimeSandboxCapacityAdmissionMode,
408
409
  RuntimeSandboxCapacityLimitError,
409
410
  } from './runtime-sandbox-capacity';
410
411
  import {
@@ -11969,6 +11970,9 @@ export function createAbsurdRuntimeWorkerHostLifecycle(input: {
11969
11970
  return closing !== null || capacity.draining;
11970
11971
  },
11971
11972
  hasIdleSlot: () => closing === null && capacity.hasIdleSlot(),
11973
+ ...(capacity.orgSandboxCapacity
11974
+ ? { orgSandboxCapacity: capacity.orgSandboxCapacity }
11975
+ : {}),
11972
11976
  },
11973
11977
  }
11974
11978
  : {}),
@@ -12023,6 +12027,46 @@ export function resolveAbsurdRuntimeWorkerReleaseIdentity(
12023
12027
  };
12024
12028
  }
12025
12029
 
12030
+ /** Bound on the early-sandbox org-capacity read before an early create. */
12031
+ export const EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS = 1_000;
12032
+
12033
+ /**
12034
+ * The pool's signal bounds admission only, not the query, so the early create
12035
+ * waits on the read no longer than the bound: past it the check rejects and
12036
+ * the create proceeds as before (`create_gate_failed`).
12037
+ */
12038
+ export function withEarlySandboxOrgCapacityDeadline<T>(
12039
+ read: Promise<T>,
12040
+ timeoutMs: number = EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS,
12041
+ ): Promise<T> {
12042
+ let timer: ReturnType<typeof setTimeout> | undefined;
12043
+ const deadline = new Promise<never>((_, reject) => {
12044
+ timer = setTimeout(
12045
+ () =>
12046
+ reject(
12047
+ new Error(
12048
+ `early sandbox org capacity check exceeded ${timeoutMs} ms`,
12049
+ ),
12050
+ ),
12051
+ timeoutMs,
12052
+ );
12053
+ timer.unref?.();
12054
+ });
12055
+ return Promise.race([read, deadline]).finally(() => clearTimeout(timer));
12056
+ }
12057
+
12058
+ /**
12059
+ * Only `enforce` admission holds a run at its org's sandbox limit. In `observe`
12060
+ * an over-limit org still starts runs immediately, so a "full" read would skip
12061
+ * an early create the run would have adopted; install the check only then.
12062
+ */
12063
+ export function earlySandboxOrgCapacityCheckForAdmissionMode<T>(
12064
+ mode: RuntimeSandboxCapacityAdmissionMode,
12065
+ check: T,
12066
+ ): { orgSandboxCapacity: T } | Record<string, never> {
12067
+ return mode === 'enforce' ? { orgSandboxCapacity: check } : {};
12068
+ }
12069
+
12026
12070
  /**
12027
12071
  * Start one poll loop and slot pool. Event waits park the task in Postgres and
12028
12072
  * release the slot until their own top-level play resumes.
@@ -12570,6 +12614,31 @@ export async function startRuntimeWorkerHost(
12570
12614
  earlySandboxCapacity: {
12571
12615
  draining: drainExit,
12572
12616
  hasIdleSlot: claimLoop.hasIdleSlot,
12617
+ // One bounded read: a slow or failed check creates as before.
12618
+ ...earlySandboxOrgCapacityCheckForAdmissionMode(
12619
+ runtimeSandboxCapacityAdmissionMode(),
12620
+ ({ orgId, runId }: { orgId: string; runId: string }) =>
12621
+ withEarlySandboxOrgCapacityDeadline(
12622
+ withRuntimeSchedulerClient(
12623
+ poolOptions,
12624
+ (client) =>
12625
+ precheckRuntimeSandboxCapacity(
12626
+ client,
12627
+ { orgId, runId },
12628
+ schedulerOptions.schema
12629
+ ? { schema: schedulerOptions.schema }
12630
+ : {},
12631
+ ),
12632
+ { runId, phase: 'early_sandbox_org_capacity' },
12633
+ {
12634
+ maxAttempts: 1,
12635
+ signal: AbortSignal.timeout(
12636
+ EARLY_SANDBOX_ORG_CAPACITY_CHECK_TIMEOUT_MS,
12637
+ ),
12638
+ },
12639
+ ),
12640
+ ),
12641
+ ),
12573
12642
  },
12574
12643
  // Release LISTEN before joining accepted work, so a replacement can elect
12575
12644
  // its listener without exhausting primary scheduler sessions.
@@ -113,6 +113,17 @@ export type EarlySandboxWorkerCapacity = {
113
113
  readonly draining: boolean;
114
114
  /** Whether the claim loop has a free slot to claim the hinted run with. */
115
115
  hasIdleSlot(): boolean;
116
+ /**
117
+ * Advisory, lock-free read of the hinted org's sandbox capacity
118
+ * (`precheckRuntimeSandboxCapacity`). A full org's run waits for a lease,
119
+ * usually past the adoption window, so its early sandbox would only be
120
+ * reaped (Production 2026-12-01: 73 of 98 capacity-held runs waited 30 s
121
+ * or more). Absent: no check, as before.
122
+ */
123
+ orgSandboxCapacity?(input: {
124
+ orgId: string;
125
+ runId: string;
126
+ }): Promise<{ full: boolean; limit: number; activeLeases: number }>;
116
127
  };
117
128
 
118
129
  /** A hinted run's early-sandbox switches (E2, PB, CA). */
@@ -269,8 +280,7 @@ export function outstandingEarlySandboxesForOrg(
269
280
  ),
270
281
  );
271
282
  let total = 0;
272
- for (const registry of registries)
273
- total += registry.outstandingForOrg(orgId);
283
+ for (const registry of registries) total += registry.outstandingForOrg(orgId);
274
284
  return total;
275
285
  }
276
286
 
@@ -416,6 +426,25 @@ export function startWorkerLaneEarlySandbox(
416
426
  ? { sandboxRuntimeLimits: input.sandboxRuntimeLimits }
417
427
  : {}),
418
428
  };
429
+ const orgCapacity = input.capacity?.orgSandboxCapacity;
430
+ const startOptions =
431
+ orgCapacity && hintOrgId
432
+ ? {
433
+ createGate: async () => {
434
+ const capacity = await orgCapacity({
435
+ orgId: hintOrgId,
436
+ runId: input.workflowId,
437
+ });
438
+ return capacity.full
439
+ ? {
440
+ reason: 'org_sandbox_capacity_full',
441
+ limit: capacity.limit,
442
+ activeLeases: capacity.activeLeases,
443
+ }
444
+ : null;
445
+ },
446
+ }
447
+ : {};
419
448
  if (
420
449
  !resolveExperimentSwitch(
421
450
  'LH',
@@ -423,7 +452,7 @@ export function startWorkerLaneEarlySandbox(
423
452
  EARLY_SANDBOX_LISTENER_HINT,
424
453
  )
425
454
  ) {
426
- return startEarlySandbox(adapter, request);
455
+ return startEarlySandbox(adapter, request, startOptions);
427
456
  }
428
457
  // LH: admitted only by this worker's desk, bound to the hint's queue,
429
458
  // this worker's current listener generation and one free slot.
@@ -463,7 +492,7 @@ export function startWorkerLaneEarlySandbox(
463
492
  if (refusal) {
464
493
  return refuseEarlySandboxHint({ ...hint, reason: `listener_${refusal}` });
465
494
  }
466
- const started = startEarlySandbox(adapter, request);
495
+ const started = startEarlySandbox(adapter, request, startOptions);
467
496
  if (!started) desk.released(key);
468
497
  return started;
469
498
  }
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  getAuthedHttpClient,
3
3
  printCommandEnvelope
4
- } from "./chunk-NVHICORD.mjs";
4
+ } from "./chunk-7AFTLM74.mjs";
5
5
  import {
6
6
  cliFeatureEnabled
7
- } from "./chunk-ROUNT4NX.mjs";
8
- import "./chunk-LDMCTV2Z.mjs";
7
+ } from "./chunk-U6BTY4WS.mjs";
8
+ import "./chunk-AXOQ2FMS.mjs";
9
9
  import "./chunk-ASB47RXJ.mjs";
10
10
  import "./chunk-DLIRSHV6.mjs";
11
11
  import {
12
12
  DeeplineError
13
13
  } from "./chunk-Z3A2S3QM.mjs";
14
14
  import "./chunk-2MGZAI54.mjs";
15
- import "./chunk-ZARGHLZZ.mjs";
15
+ import "./chunk-EHV52KUV.mjs";
16
16
  import "./chunk-WZYKRD7T.mjs";
17
17
  import "./chunk-KRD6H754.mjs";
18
18
 
@@ -42,6 +42,10 @@ function describeOwnedOutcome(owned) {
42
42
  const last = owned.lastWake ? `last ring ${new Date(owned.lastWake.at).toISOString()} ${WAKE_STATUS_WORDS[owned.lastWake.status]}${owned.lastWake.what.length > 0 ? ` (${owned.lastWake.what.join(", ")})` : ""}` : "never rung";
43
43
  return `${owned.outcome} \u2014 as ${owned.agent}; ${watch}; ${last}; ${owned.turnsInWindow} of ${owned.turnLimit} turns this hour`;
44
44
  }
45
+ function describeHomeWakes(home) {
46
+ const last = home.lastWake ? `last ring ${new Date(home.lastWake.at).toISOString()} ${WAKE_STATUS_WORDS[home.lastWake.status]}${home.lastWake.what.length > 0 ? ` (${home.lastWake.what.join(", ")})` : ""}` : "never rung";
47
+ return `#${home.conversationName} (${home.conversationId}) \u2014 ${home.agent} on ${home.outcome}; ${home.watching ? "woken there" : "not woken (no watch)"}; ${last}; ${home.turnsInWindow} of ${home.turnLimit} turns this hour`;
48
+ }
45
49
  var REPLIES_MAX_LIMIT = 100;
46
50
  var REPLIES_INVALID_CURSOR = "DEEPLINE_AGENT_REPLIES_INVALID_CURSOR";
47
51
  var FEEDBACK_MAX_LIMIT = 100;
@@ -496,6 +500,66 @@ function registerWorkspaceCommands(agents, readKey) {
496
500
  options
497
501
  );
498
502
  });
503
+ agents.command("wakes").description(
504
+ "List outcome home channels with how their agent was last woken and its hourly turn budget."
505
+ ).option("--json", "Emit JSON output").action(async (options) => {
506
+ const { http } = getAuthedHttpClient();
507
+ const result = await http.get(
508
+ `${AGENT_PATH}/wakes`
509
+ );
510
+ print(
511
+ result,
512
+ "agent wakes",
513
+ result.homes.length === 0 ? [
514
+ "No channel is an outcome\u2019s home. Make one with: deepline agents channels set <channel-id> --outcome <outcome>"
515
+ ] : result.homes.map(describeHomeWakes),
516
+ options
517
+ );
518
+ });
519
+ agents.command("memory").description(
520
+ "Show what the agent remembers about an outcome, in each channel that works toward it, and who said it; --clear forgets it all (both need member access)."
521
+ ).argument("<outcome>", "Outcome name, as deepline outcomes list prints it").option(
522
+ "--clear",
523
+ "Forget everything the agent remembers about this outcome (member access)"
524
+ ).option("--json", "Emit JSON output").action(
525
+ async (outcome, options) => {
526
+ const name = requireArgument(outcome, "an outcome name");
527
+ const path = `${AGENT_PATH}/memory?outcome=${encodeURIComponent(name)}`;
528
+ const { http } = getAuthedHttpClient();
529
+ if (options.clear) {
530
+ const result2 = await http.delete(path);
531
+ print(
532
+ result2,
533
+ "agent memory",
534
+ [
535
+ result2.cleared === 0 ? `The agent remembered nothing about ${name}.` : `Forgot ${result2.cleared} ${result2.cleared === 1 ? "thing" : "things"} the agent remembered about ${name}.`
536
+ ],
537
+ options
538
+ );
539
+ return;
540
+ }
541
+ const result = await http.get(path);
542
+ print(
543
+ result,
544
+ "agent memory",
545
+ result.memories.length === 0 ? [
546
+ `The agent remembers nothing about ${name} yet. It saves what people tell it that will matter later (decisions, deadlines, preferences, who owns what).`
547
+ ] : [
548
+ ...result.memories.flatMap(describeOutcomeMemory),
549
+ `Forget it all with: deepline agents memory ${name} --clear`
550
+ ],
551
+ options
552
+ );
553
+ }
554
+ );
555
+ }
556
+ function describeOutcomeMemory(memory) {
557
+ return [
558
+ memory.owner ? "Bot by Deepline (no channel):" : `#${memory.conversationName}:`,
559
+ ...memory.entries.map(
560
+ (entry) => ` ${entry.n}. ${entry.text} (${entry.source})`
561
+ )
562
+ ];
499
563
  }
500
564
  function registerAgentCommands(agents) {
501
565
  agents.command("get").description("Show one agent: its instructions, skills and channels.").argument("<name>", "Agent name").option("--json", "Emit JSON output").action(async (name, options) => {