deepline 0.3.509 → 0.3.511
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.
- package/dist/bundling-sources/sdk/src/client-core.ts +159 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +7 -2
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +94 -43
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +111 -27
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +79 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +80 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-transient-retry.ts +571 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +218 -33
- package/dist/cli/artifacts-G6JHRHY5.mjs +268 -0
- package/dist/cli/artifacts-PLF5ZUS7.js +268 -0
- package/dist/cli/{auth-6IR2QH4N.mjs → auth-2XMJMDWG.mjs} +5 -5
- package/dist/cli/auth-PI2KS2CD.js +43 -0
- package/dist/cli/{billing-WEWHH6ST.mjs → billing-6C5AI42X.mjs} +7 -7
- package/dist/cli/{billing-SYBK3ZYU.js → billing-Z3XFXP3H.js} +82 -82
- package/dist/cli/{chunk-JZJNA57M.js → chunk-2Q4H2Y6N.js} +6 -6
- package/dist/cli/{chunk-VTVZ7EUA.js → chunk-2YVRIXVR.js} +9 -9
- package/dist/cli/{chunk-RSKAPLST.mjs → chunk-5WTLXL6O.mjs} +1 -1
- package/dist/cli/{chunk-YJM3NOME.mjs → chunk-77DPQI6W.mjs} +94 -10
- package/dist/cli/{chunk-FNLGMMJJ.mjs → chunk-ASXOFBF7.mjs} +2 -2
- package/dist/cli/{chunk-AO63MXT6.js → chunk-BHV7JKXQ.js} +1 -1
- package/dist/cli/{chunk-RA2NKHV5.js → chunk-D5VWSR4D.js} +5 -5
- package/dist/cli/{chunk-CMSPA5VX.js → chunk-FAGSSIOY.js} +6 -6
- package/dist/cli/{chunk-J5P4PDRT.js → chunk-FF25PDQ2.js} +94 -10
- package/dist/cli/{chunk-SEQIB5WJ.mjs → chunk-FTT2SBBH.mjs} +5 -5
- package/dist/cli/{chunk-5Y3I5LEQ.js → chunk-FV4PASXH.js} +16 -16
- package/dist/cli/{chunk-GTAU4C44.js → chunk-GD3ES3JU.js} +14 -14
- package/dist/cli/{chunk-HMAETS53.js → chunk-GGQHOLH6.js} +3 -3
- package/dist/cli/{chunk-T67NAGSD.mjs → chunk-GJWL4KTY.mjs} +4 -4
- package/dist/cli/{chunk-6KBVQ76G.mjs → chunk-HLEZQDEZ.mjs} +2 -2
- package/dist/cli/{chunk-WJ6H2W3O.mjs → chunk-ISY7PBIK.mjs} +5 -5
- package/dist/cli/{chunk-AD45WJHN.js → chunk-IYWN7M4I.js} +5 -5
- package/dist/cli/{chunk-3CZHC24N.mjs → chunk-JDDKJIZU.mjs} +1 -1
- package/dist/cli/{chunk-E3HWUGDT.mjs → chunk-JHBZBCU4.mjs} +1 -1
- package/dist/cli/{chunk-7KALZEDZ.js → chunk-JIY25SUX.js} +4 -4
- package/dist/cli/{chunk-726UDAV2.js → chunk-JYFLIQPE.js} +7 -7
- package/dist/cli/{chunk-DGOSW42X.js → chunk-K4JB2BZP.js} +96 -96
- package/dist/cli/{chunk-XEQH65DT.mjs → chunk-KK6NZHAJ.mjs} +1 -1
- package/dist/cli/chunk-KUDNPJ43.js +77 -0
- package/dist/cli/{chunk-IZW7IOD6.mjs → chunk-KXGH4YUQ.mjs} +1 -1
- package/dist/cli/{chunk-Q7G6WORO.js → chunk-KZBKQPSA.js} +2 -2
- package/dist/cli/{chunk-4DVANPBN.js → chunk-LDZYGM7W.js} +41 -41
- package/dist/cli/{chunk-XPKBYMJH.js → chunk-LKSJXTRP.js} +53 -53
- package/dist/cli/{chunk-Q5UO2ENN.js → chunk-NVMNMKZW.js} +3 -3
- package/dist/cli/{chunk-VZ773N7G.js → chunk-O37BQ2CG.js} +21 -10
- package/dist/cli/{chunk-OOD5LGUS.mjs → chunk-OQ4YBPOQ.mjs} +3 -3
- package/dist/cli/{chunk-UART6FGK.mjs → chunk-PCI4MMH7.mjs} +1 -1
- package/dist/cli/{chunk-2ZJRCAHG.js → chunk-PI45LZ5B.js} +11 -11
- package/dist/cli/{chunk-O527H5GY.js → chunk-PUFEARWT.js} +16 -16
- package/dist/cli/{chunk-25MAOMVS.mjs → chunk-QDWNVTTO.mjs} +2 -2
- package/dist/cli/{chunk-WUKNKFB3.mjs → chunk-RPPU3XB3.mjs} +2 -2
- package/dist/cli/{chunk-XIBNY6H6.mjs → chunk-S5C4CWSS.mjs} +5 -5
- package/dist/cli/{chunk-2U7Z4LFG.mjs → chunk-S6KEACD3.mjs} +6 -6
- package/dist/cli/{chunk-Y4M5HPQV.mjs → chunk-SI4QXATV.mjs} +5 -5
- package/dist/cli/{chunk-R2KNJMOY.mjs → chunk-VEOFISLZ.mjs} +1 -1
- package/dist/cli/{chunk-Z2LVZDO5.js → chunk-VHFTN6VY.js} +44 -44
- package/dist/cli/{chunk-54YPOG5W.mjs → chunk-VQ74WMKG.mjs} +15 -4
- package/dist/cli/{chunk-ZXGMWXZW.js → chunk-WDBEWOU6.js} +2 -2
- package/dist/cli/{chunk-6TBRWRJ2.js → chunk-XGXXNT4O.js} +270 -199
- package/dist/cli/chunk-XREZY4FA.mjs +77 -0
- package/dist/cli/{chunk-K2RCVD7S.mjs → chunk-XSBGWMI6.mjs} +72 -1
- package/dist/cli/{chunk-S7JEF2MR.mjs → chunk-XXQZYLLL.mjs} +2 -2
- package/dist/cli/{chunk-EEEWADSR.mjs → chunk-XZ6IZIQJ.mjs} +2 -2
- package/dist/cli/{chunk-WPBTWRKG.js → chunk-YX7E2VQM.js} +26 -26
- package/dist/cli/{chunk-FQCIYGQY.mjs → chunk-ZFJ2U76O.mjs} +2 -2
- package/dist/cli/{chunk-7NMPGX3W.js → chunk-ZWGBQKW7.js} +21 -21
- package/dist/cli/{chunk-VH522HUP.mjs → chunk-ZYVR4A4P.mjs} +10 -10
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-4LAJ2ZKG.mjs → csv-CNK6ZF3T.mjs} +4 -4
- package/dist/cli/{csv-5KNONIAX.js → csv-S44OGG2O.js} +13 -13
- package/dist/cli/{db-BEVCJI66.mjs → db-AVO6QJU6.mjs} +6 -6
- package/dist/cli/{db-5PEXOSN3.js → db-WKZ6EXNG.js} +27 -27
- package/dist/cli/{describe-TDJIUSD6.mjs → describe-2HQRT5MI.mjs} +18 -18
- package/dist/cli/describe-CCK77NER.js +50 -0
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-KXCPU6YC.mjs → executions-DKHOR7HD.mjs} +6 -6
- package/dist/cli/{executions-36GV3A27.js → executions-MTAHNARA.js} +8 -8
- package/dist/cli/{feedback-GEUUT4S7.mjs → feedback-K6SJS4LG.mjs} +11 -7
- package/dist/cli/{feedback-SPQABV33.js → feedback-R2UABU3E.js} +15 -11
- package/dist/cli/{git-AE36X2R6.mjs → git-3EPA7433.mjs} +5 -5
- package/dist/cli/git-7L3PY2A4.js +25 -0
- package/dist/cli/index.js +177 -156
- package/dist/cli/index.mjs +80 -59
- package/dist/cli/{legacy-noops-TKPHN7WT.js → legacy-noops-3Q2D2F24.js} +9 -8
- package/dist/cli/{legacy-noops-LUEDAK7J.mjs → legacy-noops-66OPCJJD.mjs} +6 -5
- package/dist/cli/{monitors-JHJZ5XG7.mjs → monitors-2PYPRWT4.mjs} +7 -7
- package/dist/cli/{monitors-B2EAIGZI.js → monitors-KHH4MZDF.js} +100 -100
- package/dist/cli/{org-GUICCEBZ.mjs → org-WAW3OL7B.mjs} +6 -6
- package/dist/cli/{org-PYCPXEAU.js → org-X5G36B2Q.js} +72 -72
- package/dist/cli/{pages-Y2XI36HY.mjs → pages-KABWXDGW.mjs} +6 -6
- package/dist/cli/{pages-CV4TQNFY.js → pages-XDPHCHHU.js} +18 -18
- package/dist/cli/{play-VWCQNGZZ.mjs → play-654B2HQU.mjs} +18 -18
- package/dist/cli/{play-MTVK66JK.js → play-UE5FKQCO.js} +317 -317
- package/dist/cli/{providers-N72BUCXZ.js → providers-QT2BZMJ7.js} +9 -9
- package/dist/cli/{providers-ZOZTST3A.mjs → providers-SKNGX6IT.mjs} +6 -6
- package/dist/cli/{quickstart-DXIC3NHS.mjs → quickstart-BX7XMJIQ.mjs} +4 -4
- package/dist/cli/{quickstart-FK53VZB3.js → quickstart-XWDVAQTT.js} +6 -6
- package/dist/cli/{run-NNAYDCEN.js → run-C6YYD4AK.js} +41 -41
- package/dist/cli/{run-IL2KI33N.mjs → run-JTU4K4MY.mjs} +23 -23
- package/dist/cli/{search-7IPVMQCO.mjs → search-NHV4Y4SX.mjs} +8 -8
- package/dist/cli/search-RIFW5JCK.js +33 -0
- package/dist/cli/{search-output-ZY2GE35S.mjs → search-output-AAOMFK7K.mjs} +4 -4
- package/dist/cli/{search-output-YHTWLSDE.js → search-output-WLFFEGCY.js} +6 -6
- package/dist/cli/{secrets-ZML76SH2.js → secrets-H4WTLQJJ.js} +15 -15
- package/dist/cli/{secrets-BGUMHDZ7.mjs → secrets-S66PZSRO.mjs} +6 -6
- package/dist/cli/sessions-EFWO62XJ.js +18 -0
- package/dist/cli/{sessions-F5XO6HZJ.mjs → sessions-PY6FJX3O.mjs} +6 -5
- package/dist/cli/{settings-73SMIICV.mjs → settings-V7BM42KQ.mjs} +39 -12
- package/dist/cli/{settings-TOX2P5M5.js → settings-YO4FFPN6.js} +109 -82
- package/dist/cli/{setup-DNFHFQ7N.js → setup-IFZYYQ2W.js} +50 -50
- package/dist/cli/{setup-FDJZYBMS.mjs → setup-VUBM2HMH.mjs} +10 -10
- package/dist/cli/{skills-6HJ2IAY6.mjs → skills-EYWRSQQJ.mjs} +8 -8
- package/dist/cli/skills-LFP53SWQ.js +37 -0
- package/dist/cli/tools-SR2Q7KC5.js +57 -0
- package/dist/cli/{tools-4FJIIE4R.mjs → tools-VZOW4MUD.mjs} +17 -17
- package/dist/cli/update-ADZBZZZS.js +35 -0
- package/dist/cli/{update-UMRPPILV.mjs → update-CQDJJYU2.mjs} +10 -10
- package/dist/cli/{workflow-LSFOG5VU.mjs → workflow-2VRDIPF3.mjs} +7 -7
- package/dist/cli/{workflow-SK3BUHB4.js → workflow-XS3JEU6X.js} +17 -17
- package/dist/{client-DMpsMNH9.d.mts → client-By7bUS8h.d.mts} +1 -1
- package/dist/{client-BlwD-G4v.d.ts → client-CmlKSBXd.d.ts} +1 -1
- package/dist/{client-core-DwBLuEkm.d.ts → client-core-BM0mKhgp.d.ts} +93 -1
- package/dist/{client-core-CITtRTbB.d.mts → client-core-BZ3tpY_J.d.mts} +93 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +111 -106
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-SUTQ4SZQ.js +0 -43
- package/dist/cli/describe-ZB6G6DOV.js +0 -50
- package/dist/cli/git-UX7L6R32.js +0 -25
- package/dist/cli/search-OZHP5ZE2.js +0 -33
- package/dist/cli/sessions-WDINUUZ3.js +0 -17
- package/dist/cli/skills-NE7WN5PP.js +0 -37
- package/dist/cli/tools-ETX4MNNO.js +0 -57
- package/dist/cli/update-N2DMPSUH.js +0 -35
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts
CHANGED
|
@@ -482,12 +482,27 @@ const HEARTBEAT_CLAIM_TIMEOUT_SECONDS = RUNTIME_CLAIM_LEASE_SECONDS;
|
|
|
482
482
|
export const ABSURD_IDLE_POLL_INTERVAL_SECONDS = 30;
|
|
483
483
|
/**
|
|
484
484
|
* Worker modes that intentionally have no wake hook keep a fast durable poll.
|
|
485
|
-
* Active lanes with an election hook use the
|
|
486
|
-
*
|
|
485
|
+
* Active lanes with an election hook use the standby cadence below when they
|
|
486
|
+
* are not the elected listener.
|
|
487
487
|
*/
|
|
488
488
|
export const ABSURD_WAKE_UNAVAILABLE_POLL_INTERVAL_MS = 1_000;
|
|
489
|
-
/**
|
|
490
|
-
|
|
489
|
+
/**
|
|
490
|
+
* How often an active-lane worker that is not the elected listener looks for
|
|
491
|
+
* new work. Only one worker per queue holds the LISTEN session, so at a
|
|
492
|
+
* burst's onset every other idle worker learns of the backlog from this poll.
|
|
493
|
+
* Each poll is `hasAbsurdQueueDueWork`, a few index seeks, and the claim runs
|
|
494
|
+
* only when it finds due work (`runAbsurdStandbyDueWorkProbe`), as
|
|
495
|
+
* `docs/runtime-postgres-idle-polling.md` requires of an idle claim poller.
|
|
496
|
+
* At 30 s, Production bursts on 2026-11-11 left a live second Machine idle
|
|
497
|
+
* for 25-33 s while runs queued.
|
|
498
|
+
*/
|
|
499
|
+
export const ABSURD_ACTIVE_STANDBY_POLL_INTERVAL_MS = 1_000;
|
|
500
|
+
/**
|
|
501
|
+
* A standby's unprobed claim, which also projects manual cancellations
|
|
502
|
+
* (`afterClaim`), keeps its 30-second durable bound. It covers a probe that
|
|
503
|
+
* keeps failing; the probe above carries the normal discovery latency.
|
|
504
|
+
*/
|
|
505
|
+
export const ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS =
|
|
491
506
|
ABSURD_IDLE_POLL_INTERVAL_SECONDS * 1000;
|
|
492
507
|
/**
|
|
493
508
|
* An adopted (retired) lane is served by durable polling only. Its parked
|
|
@@ -1852,19 +1867,16 @@ export async function parkAndResolveSuspension(input: {
|
|
|
1852
1867
|
ceilingDeadlineMs,
|
|
1853
1868
|
inspectDetachedRunner: input.inspectDetachedRunner,
|
|
1854
1869
|
suspension,
|
|
1855
|
-
probeControlPlaneOutage:
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
if (observedAtMs > 0) outageObservedAtMs = observedAtMs;
|
|
1866
|
-
}
|
|
1867
|
-
: undefined,
|
|
1870
|
+
probeControlPlaneOutage: input.observeControlPlaneOutage
|
|
1871
|
+
? async (probeStepName) => {
|
|
1872
|
+
const observedAtMs = await ctx.step(
|
|
1873
|
+
`${suspension.boundaryId}:liveness-confirm-heartbeat:${renewed?.heartbeatIdentity ?? renewed?.heartbeatAt ?? 'none'}:${probeStepName}`,
|
|
1874
|
+
async () =>
|
|
1875
|
+
(await input.observeControlPlaneOutage?.()) ? Date.now() : 0,
|
|
1876
|
+
);
|
|
1877
|
+
if (observedAtMs > 0) outageObservedAtMs = observedAtMs;
|
|
1878
|
+
}
|
|
1879
|
+
: undefined,
|
|
1868
1880
|
runnerResponded: async () => {
|
|
1869
1881
|
// A wake replays every finished slice. One read per replay is enough.
|
|
1870
1882
|
if (Date.now() < quietUntilMs) return false;
|
|
@@ -8903,8 +8915,10 @@ export function selectAbsurdAdoptionQueues(input: {
|
|
|
8903
8915
|
*
|
|
8904
8916
|
* - No `onWake`: an adopted queue never opens a direct LISTEN session (see
|
|
8905
8917
|
* `ABSURD_ADOPTED_LANE_POLL_INTERVAL_MS`).
|
|
8906
|
-
* - `idlePollFallbackMs` is the same 30-second durable bound
|
|
8907
|
-
*
|
|
8918
|
+
* - `idlePollFallbackMs` is the same 30-second durable bound as an active
|
|
8919
|
+
* lane's unprobed standby claim (`ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS`).
|
|
8920
|
+
* Adopted lanes run no 1-second standby probe: their parked waits tolerate
|
|
8921
|
+
* the adoption rotation already.
|
|
8908
8922
|
* - `nextPollDelayMs` still shortens the wait to the lane's next indexed due
|
|
8909
8923
|
* transition, so an already-due parked wake is claimed on the next pass.
|
|
8910
8924
|
*/
|
|
@@ -10616,10 +10630,133 @@ export async function readAbsurdQueueNextDueAt(
|
|
|
10616
10630
|
return (await readAbsurdQueueNextDue(client, queue)).dueAt;
|
|
10617
10631
|
}
|
|
10618
10632
|
|
|
10633
|
+
/**
|
|
10634
|
+
* Whether `absurd.claim_task` on this queue would do anything now: claim a
|
|
10635
|
+
* runnable run, fail an expired claim lease, or cancel a task past its
|
|
10636
|
+
* deadline. Each branch is a superset of the matching `claim_task` predicate
|
|
10637
|
+
* (the claim also checks its task row), so `false` proves the claim would
|
|
10638
|
+
* select nothing. Each branch is an ordered seek on the index `claim_task`
|
|
10639
|
+
* itself uses (`r_<queue>_sai`, `r_<queue>_cei`, `t_<queue>_cai`), bounded by
|
|
10640
|
+
* now. `readAbsurdQueueNextDue` cannot stand in for it: its
|
|
10641
|
+
* `min(available_at)` over two states aggregates every parked run.
|
|
10642
|
+
*/
|
|
10643
|
+
export async function hasAbsurdQueueDueWork(
|
|
10644
|
+
client: RuntimeSchedulerQueryClient,
|
|
10645
|
+
queue: string,
|
|
10646
|
+
): Promise<boolean> {
|
|
10647
|
+
const runTable = quotePostgresIdentifier(`r_${queue}`);
|
|
10648
|
+
const taskTable = quotePostgresIdentifier(`t_${queue}`);
|
|
10649
|
+
// `absurd.current_time()` is volatile, so it cannot bound an index scan
|
|
10650
|
+
// directly. Read it once (honouring `absurd.fake_now`, like claim_task) and
|
|
10651
|
+
// compare against the materialized value.
|
|
10652
|
+
const result = await client.query<{ due: boolean }>(
|
|
10653
|
+
`WITH clock AS MATERIALIZED (SELECT absurd.current_time() AS now)
|
|
10654
|
+
SELECT (
|
|
10655
|
+
(SELECT run_id FROM absurd.${runTable}
|
|
10656
|
+
WHERE state = 'pending'
|
|
10657
|
+
AND available_at <= (SELECT now FROM clock)
|
|
10658
|
+
ORDER BY available_at LIMIT 1) IS NOT NULL
|
|
10659
|
+
OR (SELECT run_id FROM absurd.${runTable}
|
|
10660
|
+
WHERE state = 'sleeping'
|
|
10661
|
+
AND available_at <= (SELECT now FROM clock)
|
|
10662
|
+
ORDER BY available_at LIMIT 1) IS NOT NULL
|
|
10663
|
+
OR (SELECT run_id FROM absurd.${runTable}
|
|
10664
|
+
WHERE state = 'running'
|
|
10665
|
+
AND claim_expires_at IS NOT NULL
|
|
10666
|
+
AND claim_expires_at <= (SELECT now FROM clock)
|
|
10667
|
+
ORDER BY claim_expires_at LIMIT 1) IS NOT NULL
|
|
10668
|
+
OR (SELECT task_id FROM absurd.${taskTable}
|
|
10669
|
+
WHERE state IN ('pending', 'sleeping', 'running')
|
|
10670
|
+
AND cancel_at IS NOT NULL
|
|
10671
|
+
AND cancel_at <= (SELECT now FROM clock)
|
|
10672
|
+
ORDER BY cancel_at LIMIT 1) IS NOT NULL
|
|
10673
|
+
) AS due`,
|
|
10674
|
+
);
|
|
10675
|
+
return result.rows[0]?.due === true;
|
|
10676
|
+
}
|
|
10677
|
+
|
|
10678
|
+
/**
|
|
10679
|
+
* Wraps the engine's two maintenance hooks to tell whether its claim loop can
|
|
10680
|
+
* take work. The engine calls `saturatedMaintenance` only while every slot is
|
|
10681
|
+
* busy, and `afterClaim` only after a claim, which it attempts only with a free
|
|
10682
|
+
* slot; the later of the two is the loop's current state. When a slot frees,
|
|
10683
|
+
* the engine claims by itself, so a stale saturated reading lasts only until
|
|
10684
|
+
* that claim.
|
|
10685
|
+
*/
|
|
10686
|
+
export function trackAbsurdClaimLoopCapacity(hooks: {
|
|
10687
|
+
afterClaim: () => Promise<void>;
|
|
10688
|
+
saturatedMaintenance: () => Promise<void>;
|
|
10689
|
+
}): {
|
|
10690
|
+
afterClaim: () => Promise<void>;
|
|
10691
|
+
saturatedMaintenance: () => Promise<void>;
|
|
10692
|
+
hasIdleSlot: () => boolean;
|
|
10693
|
+
} {
|
|
10694
|
+
let saturated = false;
|
|
10695
|
+
return {
|
|
10696
|
+
afterClaim: () => {
|
|
10697
|
+
saturated = false;
|
|
10698
|
+
return hooks.afterClaim();
|
|
10699
|
+
},
|
|
10700
|
+
saturatedMaintenance: () => {
|
|
10701
|
+
saturated = true;
|
|
10702
|
+
return hooks.saturatedMaintenance();
|
|
10703
|
+
},
|
|
10704
|
+
hasIdleSlot: () => !saturated,
|
|
10705
|
+
};
|
|
10706
|
+
}
|
|
10707
|
+
|
|
10708
|
+
/**
|
|
10709
|
+
* The standby half of the active lane's wake path. The elected listener is
|
|
10710
|
+
* woken by NOTIFY; every other worker on the queue runs this loop. Each tick
|
|
10711
|
+
* runs `probe` (`hasAbsurdQueueDueWork`) and, when it finds due work, wakes the
|
|
10712
|
+
* engine's claim loop, which claims at once. An empty tick costs only the
|
|
10713
|
+
* probe, so polling every second never plans the multi-kilobyte claim on an
|
|
10714
|
+
* idle queue.
|
|
10715
|
+
*
|
|
10716
|
+
* Skipped while this worker is the listener (NOTIFY already wakes it) and while
|
|
10717
|
+
* every slot is busy: a woken saturated loop only repeats its maintenance, and
|
|
10718
|
+
* the engine claims by itself as soon as a slot frees.
|
|
10719
|
+
*/
|
|
10720
|
+
export async function runAbsurdStandbyDueWorkProbe(input: {
|
|
10721
|
+
isListening: () => boolean;
|
|
10722
|
+
/** False while the claim loop last stopped because every slot was busy. */
|
|
10723
|
+
hasIdleSlot: () => boolean;
|
|
10724
|
+
probe: () => Promise<boolean>;
|
|
10725
|
+
/** The engine's "poll now" trigger; a lossy hint like any other wake. */
|
|
10726
|
+
wake: () => boolean;
|
|
10727
|
+
shouldStop: () => boolean;
|
|
10728
|
+
intervalMs?: number;
|
|
10729
|
+
sleep?: (ms: number) => Promise<void>;
|
|
10730
|
+
onWake?: () => void;
|
|
10731
|
+
onError: (error: unknown) => void;
|
|
10732
|
+
}): Promise<void> {
|
|
10733
|
+
const intervalMs = Math.max(
|
|
10734
|
+
1,
|
|
10735
|
+
Math.floor(input.intervalMs ?? ABSURD_ACTIVE_STANDBY_POLL_INTERVAL_MS),
|
|
10736
|
+
);
|
|
10737
|
+
const wait = input.sleep ?? ((ms: number) => sleep(ms));
|
|
10738
|
+
while (!input.shouldStop()) {
|
|
10739
|
+
await wait(intervalMs);
|
|
10740
|
+
if (input.shouldStop()) return;
|
|
10741
|
+
// A failed tick is reported and retried next interval; the loop never
|
|
10742
|
+
// exits early, or the standby would silently fall back to its 30 s claim.
|
|
10743
|
+
try {
|
|
10744
|
+
if (input.isListening() || !input.hasIdleSlot()) continue;
|
|
10745
|
+
if ((await input.probe()) && !input.shouldStop() && input.wake()) {
|
|
10746
|
+
input.onWake?.();
|
|
10747
|
+
}
|
|
10748
|
+
} catch (error) {
|
|
10749
|
+
input.onError(error);
|
|
10750
|
+
}
|
|
10751
|
+
}
|
|
10752
|
+
}
|
|
10753
|
+
|
|
10619
10754
|
/**
|
|
10620
10755
|
* Only an active lane participates in the wake election. The winner owns one
|
|
10621
|
-
* direct LISTEN session; each loser immediately closes its session and
|
|
10622
|
-
*
|
|
10756
|
+
* direct LISTEN session; each loser immediately closes its session and finds
|
|
10757
|
+
* work through the 1-second standby probe (`runAbsurdStandbyDueWorkProbe`),
|
|
10758
|
+
* with the bounded durable claim fallback beneath it, until it can win a later
|
|
10759
|
+
* election.
|
|
10623
10760
|
*/
|
|
10624
10761
|
export type AbsurdWorkerWakeHook = ((
|
|
10625
10762
|
wake: () => void,
|
|
@@ -10718,10 +10855,12 @@ export function createAbsurdWorkerWakeHook(input: {
|
|
|
10718
10855
|
};
|
|
10719
10856
|
// A local hint does not establish LISTEN health. Preserve the fast durable
|
|
10720
10857
|
// fallback on isolated workers, including when a hint is lost or unavailable.
|
|
10858
|
+
// A direct-notify standby discovers work through its 1-second probe
|
|
10859
|
+
// (`runAbsurdStandbyDueWorkProbe`); its unprobed claim keeps the 30 s bound.
|
|
10721
10860
|
hook.idlePollFallbackMs =
|
|
10722
10861
|
input.useDirectNotify === false
|
|
10723
10862
|
? ABSURD_WAKE_UNAVAILABLE_POLL_INTERVAL_MS
|
|
10724
|
-
:
|
|
10863
|
+
: ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS;
|
|
10725
10864
|
hook.close = () => {
|
|
10726
10865
|
closed = true;
|
|
10727
10866
|
listening = false;
|
|
@@ -10903,15 +11042,16 @@ export async function startRuntimeWorkerHost(
|
|
|
10903
11042
|
...recovered,
|
|
10904
11043
|
});
|
|
10905
11044
|
}
|
|
11045
|
+
const useDirectNotify = shouldUseRuntimeSchedulerDirectNotify(
|
|
11046
|
+
schedulerOptions.schema,
|
|
11047
|
+
);
|
|
10906
11048
|
const onWake = createAbsurdWorkerWakeHook({
|
|
10907
11049
|
poolOptions,
|
|
10908
11050
|
queue,
|
|
10909
11051
|
// A draining lane is deliberately cold except while it has runnable work.
|
|
10910
11052
|
// It must not compete with the active lane for the one direct LISTEN slot.
|
|
10911
11053
|
draining: drainExit,
|
|
10912
|
-
useDirectNotify
|
|
10913
|
-
schedulerOptions.schema,
|
|
10914
|
-
),
|
|
11054
|
+
useDirectNotify,
|
|
10915
11055
|
enableWakeHints: true,
|
|
10916
11056
|
});
|
|
10917
11057
|
const reportCancellationProgress = createRateLimitedRuntimeLogger({
|
|
@@ -10946,11 +11086,7 @@ export async function startRuntimeWorkerHost(
|
|
|
10946
11086
|
const reportQueueError = createRateLimitedRuntimeLogger({
|
|
10947
11087
|
log: (...args) => console.error(...args),
|
|
10948
11088
|
});
|
|
10949
|
-
const
|
|
10950
|
-
workerId: `${workerBase}:${queue}`,
|
|
10951
|
-
concurrency: slots,
|
|
10952
|
-
claimTimeout: HEARTBEAT_CLAIM_TIMEOUT_SECONDS,
|
|
10953
|
-
pollInterval: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11089
|
+
const claimLoop = trackAbsurdClaimLoopCapacity({
|
|
10954
11090
|
// `claim_task` performs the indexed max_delay sweep. Reconcile after every
|
|
10955
11091
|
// sweep, including claims that return backlog work, so a saturated queue
|
|
10956
11092
|
// cannot postpone a cancellation's scheduler/outbox terminal indefinitely.
|
|
@@ -10960,6 +11096,14 @@ export async function startRuntimeWorkerHost(
|
|
|
10960
11096
|
// by sweeping without claiming, then project cancellation into the
|
|
10961
11097
|
// scheduler/outbox.
|
|
10962
11098
|
saturatedMaintenance: sweepAndReconcileCancellations,
|
|
11099
|
+
});
|
|
11100
|
+
const worker = await absurdClient.startWorker({
|
|
11101
|
+
workerId: `${workerBase}:${queue}`,
|
|
11102
|
+
concurrency: slots,
|
|
11103
|
+
claimTimeout: HEARTBEAT_CLAIM_TIMEOUT_SECONDS,
|
|
11104
|
+
pollInterval: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11105
|
+
afterClaim: claimLoop.afterClaim,
|
|
11106
|
+
saturatedMaintenance: claimLoop.saturatedMaintenance,
|
|
10963
11107
|
nextPollDelayMs: () =>
|
|
10964
11108
|
withRuntimeSchedulerClient(poolOptions, async (client) => {
|
|
10965
11109
|
const nextDue = await readAbsurdQueueNextDue(client, queue);
|
|
@@ -10967,15 +11111,51 @@ export async function startRuntimeWorkerHost(
|
|
|
10967
11111
|
return nextDue.dueAt.getTime() - Date.now();
|
|
10968
11112
|
}),
|
|
10969
11113
|
// Once this lane is the elected healthy listener, a transactional NOTIFY
|
|
10970
|
-
// wakes it. Standby/down lanes
|
|
10971
|
-
//
|
|
10972
|
-
// shortens the wait for
|
|
11114
|
+
// wakes it. Standby/down lanes find new work through the 1-second probe
|
|
11115
|
+
// below and keep a 30-second unprobed claim, so idle workers never repeat
|
|
11116
|
+
// empty claims; the indexed next-due read still shortens the wait for
|
|
11117
|
+
// known deadlines.
|
|
10973
11118
|
idlePollFallbackMs: () => resolveAbsurdIdlePollFallbackMs(onWake),
|
|
10974
11119
|
onWake,
|
|
10975
11120
|
fatalOnLeaseTimeout: false,
|
|
10976
11121
|
onError: (error) =>
|
|
10977
11122
|
reportQueueError('[absurd-runtime.worker] queue_error', { queue, error }),
|
|
10978
11123
|
});
|
|
11124
|
+
// Isolated (Preview) workers already claim every second, and a draining lane
|
|
11125
|
+
// has no wake hook, so only a direct-notify active lane runs the probe.
|
|
11126
|
+
let standbyProbeStopped = false;
|
|
11127
|
+
const reportStandbyProbeWake = createRateLimitedRuntimeLogger({
|
|
11128
|
+
log: (...args) => console.info(...args),
|
|
11129
|
+
});
|
|
11130
|
+
const reportStandbyProbeError = createRateLimitedRuntimeLogger({
|
|
11131
|
+
log: (...args) => console.error(...args),
|
|
11132
|
+
});
|
|
11133
|
+
const standbyProbe =
|
|
11134
|
+
onWake && useDirectNotify
|
|
11135
|
+
? runAbsurdStandbyDueWorkProbe({
|
|
11136
|
+
isListening: () => onWake.isListening(),
|
|
11137
|
+
hasIdleSlot: claimLoop.hasIdleSlot,
|
|
11138
|
+
probe: () =>
|
|
11139
|
+
withRuntimeSchedulerClient(poolOptions, (client) =>
|
|
11140
|
+
hasAbsurdQueueDueWork(client, queue),
|
|
11141
|
+
),
|
|
11142
|
+
wake: () => onWake.wake(),
|
|
11143
|
+
shouldStop: () => standbyProbeStopped,
|
|
11144
|
+
onWake: () =>
|
|
11145
|
+
reportStandbyProbeWake(
|
|
11146
|
+
'[absurd-runtime.worker] standby_probe_wake',
|
|
11147
|
+
{ queue, releaseId },
|
|
11148
|
+
),
|
|
11149
|
+
onError: (error) =>
|
|
11150
|
+
reportStandbyProbeError(
|
|
11151
|
+
'[absurd-runtime.worker] standby_probe_failed',
|
|
11152
|
+
{
|
|
11153
|
+
queue,
|
|
11154
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11155
|
+
},
|
|
11156
|
+
),
|
|
11157
|
+
})
|
|
11158
|
+
: null;
|
|
10979
11159
|
// Compute settlement and cleanup each have their own controller and
|
|
10980
11160
|
// database lease. Neither consumes an ordinary play slot or competes with
|
|
10981
11161
|
// new starts under org concurrency.
|
|
@@ -11167,6 +11347,9 @@ export async function startRuntimeWorkerHost(
|
|
|
11167
11347
|
schema: schedulerOptions.schema ?? null,
|
|
11168
11348
|
slots,
|
|
11169
11349
|
idlePollIntervalSeconds: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11350
|
+
standbyProbeIntervalMs: standbyProbe
|
|
11351
|
+
? ABSURD_ACTIVE_STANDBY_POLL_INTERVAL_MS
|
|
11352
|
+
: null,
|
|
11170
11353
|
queue,
|
|
11171
11354
|
releaseId,
|
|
11172
11355
|
drainExit,
|
|
@@ -11183,6 +11366,7 @@ export async function startRuntimeWorkerHost(
|
|
|
11183
11366
|
// its listener without exhausting primary scheduler sessions.
|
|
11184
11367
|
closeWake: () => onWake?.close(),
|
|
11185
11368
|
stopControllers: () => {
|
|
11369
|
+
standbyProbeStopped = true;
|
|
11186
11370
|
drainStopped = true;
|
|
11187
11371
|
billingStopped = true;
|
|
11188
11372
|
cleanupStopped = true;
|
|
@@ -11190,6 +11374,7 @@ export async function startRuntimeWorkerHost(
|
|
|
11190
11374
|
overdueCeilingStopped = true;
|
|
11191
11375
|
},
|
|
11192
11376
|
controllers: [
|
|
11377
|
+
standbyProbe,
|
|
11193
11378
|
overdueCeilingController,
|
|
11194
11379
|
drainWatch,
|
|
11195
11380
|
adoptionSupervisor,
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeeplineClient
|
|
3
|
+
} from "./chunk-ZFJ2U76O.mjs";
|
|
4
|
+
import "./chunk-XSBGWMI6.mjs";
|
|
5
|
+
import "./chunk-L2VKAASU.mjs";
|
|
6
|
+
import "./chunk-N4TR6QRI.mjs";
|
|
7
|
+
import "./chunk-S3A4IXBQ.mjs";
|
|
8
|
+
import "./chunk-BMCRTI6Z.mjs";
|
|
9
|
+
import {
|
|
10
|
+
printCommandEnvelope
|
|
11
|
+
} from "./chunk-HLEZQDEZ.mjs";
|
|
12
|
+
import {
|
|
13
|
+
cliFeatureEnabled
|
|
14
|
+
} from "./chunk-VEOFISLZ.mjs";
|
|
15
|
+
import "./chunk-JDDKJIZU.mjs";
|
|
16
|
+
import "./chunk-4QF2K7TM.mjs";
|
|
17
|
+
import "./chunk-DLIRSHV6.mjs";
|
|
18
|
+
import "./chunk-HBL4PM5Q.mjs";
|
|
19
|
+
import "./chunk-5WTLXL6O.mjs";
|
|
20
|
+
import "./chunk-WZYKRD7T.mjs";
|
|
21
|
+
import "./chunk-KRD6H754.mjs";
|
|
22
|
+
|
|
23
|
+
// src/cli/commands/artifacts.ts
|
|
24
|
+
import { readFile } from "fs/promises";
|
|
25
|
+
var ARTIFACTS_FEATURE = "artifacts";
|
|
26
|
+
function print(command, json, data, lines) {
|
|
27
|
+
printCommandEnvelope(
|
|
28
|
+
{ command, ...data, render: { sections: [{ title: command, lines }] } },
|
|
29
|
+
{ json: Boolean(json), text: `${lines.join("\n")}
|
|
30
|
+
` }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
async function run(action) {
|
|
34
|
+
try {
|
|
35
|
+
await action();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function readJsonOption(value, flag) {
|
|
42
|
+
if (value === void 0) return void 0;
|
|
43
|
+
const text = value.startsWith("@") ? await readFile(value.slice(1), "utf8") : value;
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(text);
|
|
46
|
+
} catch {
|
|
47
|
+
throw new Error(`${flag} takes JSON, or @path to a JSON file.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function artifactLines(artifact) {
|
|
51
|
+
return [
|
|
52
|
+
artifact.name,
|
|
53
|
+
` ${artifact.url}`,
|
|
54
|
+
` id ${artifact.id} \xB7 Play ${artifact.play} \xB7 ${artifact.access === "public" ? "public" : "workspace members"}`,
|
|
55
|
+
...artifact.description ? [` ${artifact.description}`] : []
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
function registerArtifactsCommands(program) {
|
|
59
|
+
const artifacts = program.command("artifacts", { hidden: !cliFeatureEnabled(ARTIFACTS_FEATURE) }).description(
|
|
60
|
+
"Show what a Play returns at a fixed URL on artifacts.deepline.com."
|
|
61
|
+
).addHelpText(
|
|
62
|
+
"after",
|
|
63
|
+
`
|
|
64
|
+
Examples:
|
|
65
|
+
deepline artifacts create --name "Pipeline" --play score-accounts
|
|
66
|
+
deepline artifacts refresh <id>
|
|
67
|
+
deepline artifacts set-access <id> public
|
|
68
|
+
`
|
|
69
|
+
);
|
|
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
|
+
async (options) => run(async () => {
|
|
72
|
+
const result = await new DeeplineClient().listArtifacts({
|
|
73
|
+
cursor: options.cursor,
|
|
74
|
+
limit: options.limit
|
|
75
|
+
});
|
|
76
|
+
print("artifacts list", options.json, result, [
|
|
77
|
+
...result.artifacts.length === 0 ? [
|
|
78
|
+
"No artifacts yet. Create one: deepline artifacts create --name <name> --play <play>"
|
|
79
|
+
] : [],
|
|
80
|
+
...result.artifacts.flatMap(artifactLines),
|
|
81
|
+
...result.next_cursor ? [`More: --cursor ${result.next_cursor}`] : []
|
|
82
|
+
]);
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
artifacts.command("get <id>").description("Show one artifact and what you may do with it.").option("--json", "Emit raw JSON response").action(
|
|
86
|
+
async (id, options) => run(async () => {
|
|
87
|
+
const artifact = await new DeeplineClient().getArtifact(id);
|
|
88
|
+
print("artifacts get", options.json, artifact, [
|
|
89
|
+
...artifactLines(artifact),
|
|
90
|
+
` saved input ${JSON.stringify(artifact.input)}`
|
|
91
|
+
]);
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
artifacts.command("create").description("Create an artifact that shows a Play's runs at a fixed URL.").requiredOption("--name <name>", "Artifact name").requiredOption(
|
|
95
|
+
"--play <play>",
|
|
96
|
+
"Play in this workspace, or prebuilt/<name>"
|
|
97
|
+
).option(
|
|
98
|
+
"--input <json>",
|
|
99
|
+
"Saved input Refresh runs the Play with (JSON or @file)"
|
|
100
|
+
).option("--description <text>", "What the artifact is").option("--json", "Emit raw JSON response").addHelpText(
|
|
101
|
+
"after",
|
|
102
|
+
`
|
|
103
|
+
Examples:
|
|
104
|
+
deepline artifacts create --name "Pipeline" --play score-accounts
|
|
105
|
+
deepline artifacts create --name "Brief" --play meeting-brief --input '{"team":"Growth"}'
|
|
106
|
+
`
|
|
107
|
+
).action(
|
|
108
|
+
async (options) => run(async () => {
|
|
109
|
+
const artifact = await new DeeplineClient().createArtifact({
|
|
110
|
+
name: options.name,
|
|
111
|
+
play: options.play,
|
|
112
|
+
...options.input !== void 0 ? {
|
|
113
|
+
input: await readJsonOption(
|
|
114
|
+
options.input,
|
|
115
|
+
"--input"
|
|
116
|
+
)
|
|
117
|
+
} : {},
|
|
118
|
+
...options.description ? { description: options.description } : {}
|
|
119
|
+
});
|
|
120
|
+
print("artifacts create", options.json, artifact, [
|
|
121
|
+
`Created ${artifact.name}`,
|
|
122
|
+
...artifactLines(artifact)
|
|
123
|
+
]);
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
artifacts.command("edit <id>").description(
|
|
127
|
+
"Change an artifact's name, Play, saved input, or description."
|
|
128
|
+
).option("--name <name>", "New name").option("--play <play>", "Play in this workspace, or prebuilt/<name>").option(
|
|
129
|
+
"--input <json>",
|
|
130
|
+
"Saved input Refresh runs the Play with (JSON or @file)"
|
|
131
|
+
).option("--description <text>", "What the artifact is").option("--json", "Emit raw JSON response").action(
|
|
132
|
+
async (id, options) => run(async () => {
|
|
133
|
+
const fields = {
|
|
134
|
+
...options.name !== void 0 ? { name: options.name } : {},
|
|
135
|
+
...options.play !== void 0 ? { play: options.play } : {},
|
|
136
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
137
|
+
...options.input !== void 0 ? {
|
|
138
|
+
input: await readJsonOption(
|
|
139
|
+
options.input,
|
|
140
|
+
"--input"
|
|
141
|
+
)
|
|
142
|
+
} : {}
|
|
143
|
+
};
|
|
144
|
+
if (Object.keys(fields).length === 0) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
"Nothing to change. See: deepline artifacts edit --help"
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const artifact = await new DeeplineClient().updateArtifact(id, fields);
|
|
150
|
+
print(
|
|
151
|
+
"artifacts edit",
|
|
152
|
+
options.json,
|
|
153
|
+
artifact,
|
|
154
|
+
artifactLines(artifact)
|
|
155
|
+
);
|
|
156
|
+
})
|
|
157
|
+
);
|
|
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
|
+
async (id, options) => run(async () => {
|
|
160
|
+
const result = await new DeeplineClient().listArtifactRuns(id, {
|
|
161
|
+
limit: options.limit
|
|
162
|
+
});
|
|
163
|
+
print("artifacts runs", options.json, result, [
|
|
164
|
+
...result.runs.length === 0 ? ["No runs yet. Run: deepline artifacts refresh " + id] : [],
|
|
165
|
+
...result.runs.map(
|
|
166
|
+
(r) => `${r.run_id} ${r.status} ${new Date(r.finished_at ?? r.created_at).toISOString()}`
|
|
167
|
+
)
|
|
168
|
+
]);
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
artifacts.command("refresh <id>").description(
|
|
172
|
+
"Run the artifact's Play. The artifact shows the run when it finishes."
|
|
173
|
+
).option(
|
|
174
|
+
"--input <json>",
|
|
175
|
+
"Input for this run instead of the artifact's saved input"
|
|
176
|
+
).option("--json", "Emit raw JSON response").action(
|
|
177
|
+
async (id, options) => run(async () => {
|
|
178
|
+
const input = options.input !== void 0 ? await readJsonOption(options.input, "--input") : void 0;
|
|
179
|
+
const started = await new DeeplineClient().refreshArtifact(id, input);
|
|
180
|
+
print("artifacts refresh", options.json, started, [
|
|
181
|
+
`Started run ${started.workflowId}.`,
|
|
182
|
+
`Watch it: deepline runs get ${started.workflowId}`
|
|
183
|
+
]);
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
artifacts.command("set-access <id> <access>").description("Choose who can open an artifact: workspace or public.").option("--json", "Emit raw JSON response").action(
|
|
187
|
+
async (id, access, options) => run(async () => {
|
|
188
|
+
if (access !== "workspace" && access !== "public") {
|
|
189
|
+
throw new Error("Access is workspace or public.");
|
|
190
|
+
}
|
|
191
|
+
const artifact = await new DeeplineClient().setArtifactAccess(
|
|
192
|
+
id,
|
|
193
|
+
access
|
|
194
|
+
);
|
|
195
|
+
print(
|
|
196
|
+
"artifacts set-access",
|
|
197
|
+
options.json,
|
|
198
|
+
artifact,
|
|
199
|
+
artifactLines(artifact)
|
|
200
|
+
);
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
artifacts.command("delete <id>").description("Delete an artifact. Its Play and runs are not touched.").option("--json", "Emit raw JSON response").action(
|
|
204
|
+
async (id, options) => run(async () => {
|
|
205
|
+
const result = await new DeeplineClient().deleteArtifact(id);
|
|
206
|
+
print("artifacts delete", options.json, result, [
|
|
207
|
+
`Deleted artifact ${id}.`
|
|
208
|
+
]);
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
const permissions = artifacts.command("permissions").description(
|
|
212
|
+
"Show or change who may create, edit, delete, publish, and refresh artifacts."
|
|
213
|
+
);
|
|
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
|
+
async (options) => run(async () => {
|
|
216
|
+
const result = await new DeeplineClient().getArtifactPermissions();
|
|
217
|
+
print("artifacts permissions", options.json, result, [
|
|
218
|
+
...Object.entries(result.rules).map(
|
|
219
|
+
([verb, level]) => `${verb}: ${level}`
|
|
220
|
+
),
|
|
221
|
+
...result.can ? [
|
|
222
|
+
`you may: ${Object.entries(result.can).filter(([, ok]) => ok).map(([verb]) => verb).join(", ") || "view only"}`
|
|
223
|
+
] : []
|
|
224
|
+
]);
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
const verbs = [
|
|
228
|
+
"create",
|
|
229
|
+
"edit",
|
|
230
|
+
"delete",
|
|
231
|
+
"setAccess",
|
|
232
|
+
"refresh"
|
|
233
|
+
];
|
|
234
|
+
permissions.command("set").description(
|
|
235
|
+
"Change artifact rules (admins only). Each is members or admins."
|
|
236
|
+
).option("--create <level>", "Create artifacts").option("--edit <level>", "Edit artifacts").option("--delete <level>", "Delete artifacts").option("--set-access <level>", "Make artifacts public or workspace-only").option("--refresh <level>", "Refresh artifacts and start Plays from them").option("--json", "Emit raw JSON response").action(
|
|
237
|
+
async (options) => run(async () => {
|
|
238
|
+
const rules = {};
|
|
239
|
+
for (const verb of verbs) {
|
|
240
|
+
const value = options[verb];
|
|
241
|
+
if (value === void 0) continue;
|
|
242
|
+
if (value !== "members" && value !== "admins") {
|
|
243
|
+
throw new Error(
|
|
244
|
+
`--${verb === "setAccess" ? "set-access" : verb} is members or admins.`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
rules[verb] = value;
|
|
248
|
+
}
|
|
249
|
+
if (Object.keys(rules).length === 0) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
"Pass at least one rule. See: deepline artifacts permissions set --help"
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const result = await new DeeplineClient().setArtifactPermissions(rules);
|
|
255
|
+
print(
|
|
256
|
+
"artifacts permissions set",
|
|
257
|
+
options.json,
|
|
258
|
+
result,
|
|
259
|
+
Object.entries(result.rules).map(
|
|
260
|
+
([verb, level]) => `${verb}: ${level}`
|
|
261
|
+
)
|
|
262
|
+
);
|
|
263
|
+
})
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
export {
|
|
267
|
+
registerArtifactsCommands
|
|
268
|
+
};
|