deepline 0.3.510 → 0.3.512
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/observability/scheduled-jobs.json +39 -3
- package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +9 -3
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +35 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +241 -34
- package/dist/cli/artifacts-5IGM3EYP.js +268 -0
- package/dist/cli/artifacts-YSYWQFQQ.mjs +268 -0
- package/dist/cli/{auth-USS2W3UV.mjs → auth-4MVWCUXS.mjs} +5 -5
- package/dist/cli/auth-M3AJBJ3O.js +43 -0
- package/dist/cli/{billing-LQQHU443.js → billing-OYYHWNVS.js} +82 -82
- package/dist/cli/{billing-JCUWM5XB.mjs → billing-SZXRENPC.mjs} +7 -7
- package/dist/cli/{chunk-RHKFNEV2.mjs → chunk-2BS6BRGH.mjs} +2 -2
- package/dist/cli/{chunk-WAOLTP6R.mjs → chunk-2R6M62UO.mjs} +2 -2
- package/dist/cli/{chunk-YYUVOUEH.mjs → chunk-32UMZXCZ.mjs} +5 -5
- package/dist/cli/{chunk-7BF4R26M.mjs → chunk-3INAN6EK.mjs} +3 -3
- package/dist/cli/{chunk-BPGFNVH2.js → chunk-4DSRBHN6.js} +44 -44
- package/dist/cli/{chunk-EEQ2QQOH.js → chunk-4QR64X2S.js} +10 -10
- package/dist/cli/{chunk-JY73USD7.js → chunk-4ZDHGAE6.js} +2 -2
- package/dist/cli/{chunk-KXSOZYCS.mjs → chunk-5XLU47DG.mjs} +1 -1
- package/dist/cli/{chunk-ZRACZKEE.mjs → chunk-77DPQI6W.mjs} +62 -0
- package/dist/cli/{chunk-YDALHHUC.js → chunk-7U3WY2F3.js} +53 -53
- package/dist/cli/{chunk-DMF56C6D.mjs → chunk-AATUAFD2.mjs} +2 -2
- package/dist/cli/{chunk-XJZU7KO4.js → chunk-AVYI522S.js} +5 -5
- package/dist/cli/{chunk-LF3FF2B2.js → chunk-BP4XEO6Z.js} +1 -1
- package/dist/cli/{chunk-7VT7RMZ2.mjs → chunk-DJ4FD5DR.mjs} +2 -2
- package/dist/cli/{chunk-CLV4T5FN.mjs → chunk-EQAKPIGI.mjs} +2 -2
- package/dist/cli/{chunk-XK3AJFYQ.js → chunk-FF25PDQ2.js} +62 -0
- package/dist/cli/{chunk-B6Q6BHSY.mjs → chunk-FJPJ6SO3.mjs} +2 -2
- package/dist/cli/{chunk-UV524JZ5.mjs → chunk-GJMIW4Q6.mjs} +1 -1
- package/dist/cli/{chunk-5MYXW6M6.mjs → chunk-HA5NSCTH.mjs} +2 -2
- package/dist/cli/{chunk-63DHG7BM.js → chunk-HCMFRAYT.js} +26 -26
- package/dist/cli/{chunk-FND6GZZ4.mjs → chunk-I6OK54YK.mjs} +5 -5
- package/dist/cli/{chunk-F6IXWFPF.js → chunk-IMC2HQ6V.js} +6 -6
- package/dist/cli/{chunk-DEPBCRKG.mjs → chunk-JDD6OLWN.mjs} +3 -3
- package/dist/cli/{chunk-EJ57CA2L.mjs → chunk-JH7JISQ2.mjs} +1 -1
- package/dist/cli/{chunk-XRLE2FPE.js → chunk-JKLFRDQ6.js} +6 -6
- package/dist/cli/{chunk-7VQKU6MS.js → chunk-JU35QU3Z.js} +270 -199
- package/dist/cli/{chunk-ZCYV6MZH.js → chunk-KBM5T6UV.js} +5 -5
- package/dist/cli/{chunk-VPJSQMWQ.js → chunk-L7CAOWHY.js} +3 -3
- package/dist/cli/{chunk-B2U3LVSO.mjs → chunk-LYOWQKGN.mjs} +1 -1
- package/dist/cli/{chunk-HOKOJGQW.mjs → chunk-MQ5GBB7V.mjs} +1 -1
- package/dist/cli/{chunk-OEG6VCK4.mjs → chunk-MTSHUN2R.mjs} +72 -1
- package/dist/cli/{chunk-ASBWPRBN.js → chunk-O24VWLOY.js} +16 -16
- package/dist/cli/{chunk-HC27PYJM.js → chunk-OU6AK63V.js} +2 -2
- package/dist/cli/{chunk-563HM4D2.mjs → chunk-P3RYPSOQ.mjs} +6 -6
- package/dist/cli/{chunk-6AL2VF3E.js → chunk-PJCPFF7J.js} +14 -14
- package/dist/cli/{chunk-4ZIIS6KG.js → chunk-Q72Q3ZWB.js} +9 -9
- package/dist/cli/{chunk-JNECQ5QF.js → chunk-RR6G6ZCT.js} +11 -11
- package/dist/cli/{chunk-Q5EJO4TE.mjs → chunk-RXZRZEW7.mjs} +5 -5
- package/dist/cli/{chunk-WC5754QJ.mjs → chunk-T3SUWKUT.mjs} +5 -5
- package/dist/cli/{chunk-QRQBKLOM.js → chunk-TKN2TRW5.js} +3 -3
- package/dist/cli/{chunk-PQ56GE55.mjs → chunk-TNQ5MF6K.mjs} +1 -1
- package/dist/cli/{chunk-B2T7PBS6.js → chunk-V6FQRUPJ.js} +41 -41
- package/dist/cli/{chunk-3LXU22UZ.js → chunk-VGCNLFER.js} +2 -2
- package/dist/cli/{chunk-XL4FFVWL.js → chunk-VZN6D23P.js} +7 -7
- package/dist/cli/{chunk-5N2HFB3G.js → chunk-W7DAWILZ.js} +16 -16
- package/dist/cli/{chunk-2JXEZAJF.js → chunk-WDCOUJQ5.js} +21 -21
- package/dist/cli/{chunk-FFPLCSTZ.mjs → chunk-XKFWY4IK.mjs} +10 -10
- package/dist/cli/{chunk-V6DLYRSO.mjs → chunk-YJN55ZWG.mjs} +1 -1
- package/dist/cli/{chunk-JVEU6MXD.mjs → chunk-YNMHIJC5.mjs} +1 -1
- package/dist/cli/{chunk-N7FV7OM3.js → chunk-ZLHIQU2G.js} +96 -96
- package/dist/cli/{chunk-5DU7RXDW.mjs → chunk-ZVYMGTZ7.mjs} +4 -4
- package/dist/cli/{chunk-4NJK6P5T.js → chunk-ZZ7SVWKR.js} +4 -4
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-MTFVEDPU.mjs → csv-AY4KT3NZ.mjs} +4 -4
- package/dist/cli/{csv-UXFQZLZM.js → csv-YR2E5HNM.js} +13 -13
- package/dist/cli/{db-3WPUYCCI.mjs → db-IMYD3OCM.mjs} +6 -6
- package/dist/cli/{db-RGWT6B7K.js → db-YKV6564I.js} +27 -27
- package/dist/cli/{describe-XJY5654F.mjs → describe-72GI2Q6T.mjs} +18 -18
- package/dist/cli/describe-UFGHQBM7.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-PDE4V5YH.mjs → executions-2YO6KIP3.mjs} +6 -6
- package/dist/cli/{executions-IWTALFNB.js → executions-OSNL5CSU.js} +8 -8
- package/dist/cli/{feedback-BMOVTPC4.mjs → feedback-SYDNAT62.mjs} +5 -5
- package/dist/cli/{feedback-I72P4XZS.js → feedback-WSA7YTKS.js} +10 -10
- package/dist/cli/{git-QJG3EF4P.mjs → git-WBH7N3EF.mjs} +5 -5
- package/dist/cli/git-YYOW4CYQ.js +25 -0
- package/dist/cli/index.js +148 -144
- package/dist/cli/index.mjs +47 -43
- package/dist/cli/{legacy-noops-5P75CQC7.js → legacy-noops-BZPLWY5C.js} +9 -9
- package/dist/cli/{legacy-noops-MZ45GDMK.mjs → legacy-noops-USZM4ZXF.mjs} +6 -6
- package/dist/cli/{monitors-VIOBUG2X.mjs → monitors-6HOZMLEV.mjs} +7 -7
- package/dist/cli/{monitors-5PHQZDZM.js → monitors-XHXAMMYC.js} +100 -100
- package/dist/cli/{org-B5LDVP2P.js → org-BAAOAZF3.js} +72 -72
- package/dist/cli/{org-D5RTFJNY.mjs → org-LT3DICB4.mjs} +6 -6
- package/dist/cli/{pages-BUJYG3JL.js → pages-7NP4PKLA.js} +18 -18
- package/dist/cli/{pages-XWZL3YV2.mjs → pages-MOCSTZZQ.mjs} +6 -6
- package/dist/cli/{play-SEC3EE7H.js → play-CGUL22GL.js} +317 -317
- package/dist/cli/{play-OSXLGCLZ.mjs → play-MGJ7B7RL.mjs} +18 -18
- package/dist/cli/{providers-RQPUASLI.js → providers-5LCUHKX2.js} +9 -9
- package/dist/cli/{providers-ENSURIW6.mjs → providers-AOWBHJ24.mjs} +6 -6
- package/dist/cli/{quickstart-XDTU4MAT.js → quickstart-7YZUT7GO.js} +6 -6
- package/dist/cli/{quickstart-HJTK6XWI.mjs → quickstart-Z6NA2CCM.mjs} +4 -4
- package/dist/cli/{run-ZMWSQAR2.mjs → run-7QGBNUKE.mjs} +23 -23
- package/dist/cli/{run-GX2SU5AT.js → run-M66ILCWL.js} +41 -41
- package/dist/cli/search-OZQH5VMI.js +33 -0
- package/dist/cli/{search-DZHZBHWT.mjs → search-Z2T3B4V4.mjs} +8 -8
- package/dist/cli/{search-output-3JVZERNV.js → search-output-6OHPSJGK.js} +6 -6
- package/dist/cli/{search-output-MNHAR754.mjs → search-output-MLHVBRIR.mjs} +4 -4
- package/dist/cli/{secrets-WO2LMDQ2.js → secrets-T7MW2DMK.js} +15 -15
- package/dist/cli/{secrets-VALVNVXB.mjs → secrets-VBSILT5H.mjs} +6 -6
- package/dist/cli/{sessions-EPYCH3AY.mjs → sessions-KNITGDLS.mjs} +6 -6
- package/dist/cli/sessions-XKEIBOTP.js +18 -0
- package/dist/cli/{settings-W2ABZUD4.mjs → settings-NBZRRKZS.mjs} +13 -13
- package/dist/cli/{settings-OSF4O5HM.js → settings-OSEBDBKR.js} +86 -86
- package/dist/cli/{setup-DCXNQG6R.js → setup-7DZPC6FC.js} +50 -50
- package/dist/cli/{setup-XI2ERSMQ.mjs → setup-WTEQPZ5I.mjs} +10 -10
- package/dist/cli/{skills-ZO4AH2YR.mjs → skills-JMD2MNJZ.mjs} +8 -8
- package/dist/cli/skills-R6RO6MQF.js +37 -0
- package/dist/cli/{tools-FTECXZYA.mjs → tools-LK5BM2Z7.mjs} +17 -17
- package/dist/cli/tools-NBBDUNPR.js +57 -0
- package/dist/cli/update-BI2ABPGX.js +35 -0
- package/dist/cli/{update-WPFZO2JE.mjs → update-IVUSIA2E.mjs} +10 -10
- package/dist/cli/{workflow-7X75IP3D.mjs → workflow-4QP6G54M.mjs} +7 -7
- package/dist/cli/{workflow-PKMU33LV.js → workflow-GY374FMJ.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 +110 -108
- 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/dist/viewer/viewer.js +16 -7
- package/package.json +1 -1
- package/dist/cli/auth-S2Z5YMU3.js +0 -43
- package/dist/cli/describe-LNCLA2LA.js +0 -50
- package/dist/cli/git-QWH7SPGF.js +0 -25
- package/dist/cli/search-7WPABWYO.js +0 -33
- package/dist/cli/sessions-2IA2DGWO.js +0 -18
- package/dist/cli/skills-QMD2WARJ.js +0 -37
- package/dist/cli/tools-53E6GBQU.js +0 -57
- package/dist/cli/update-PPPNR6J5.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;
|
|
@@ -6989,6 +7001,28 @@ async function deferAbsurdAttemptForExecutorTokenOutage(input: {
|
|
|
6989
7001
|
);
|
|
6990
7002
|
}
|
|
6991
7003
|
|
|
7004
|
+
/**
|
|
7005
|
+
* The terminal message a customer sees. A worker that cannot sign the gateway
|
|
7006
|
+
* credential names its secret and the pinned deployment; those stay in the
|
|
7007
|
+
* worker log and the customer reads only that the profile is unavailable.
|
|
7008
|
+
*/
|
|
7009
|
+
export function customerSafeSalvageMessage(
|
|
7010
|
+
runId: string,
|
|
7011
|
+
error: unknown,
|
|
7012
|
+
): string {
|
|
7013
|
+
if (
|
|
7014
|
+
isRuntimeGatewayLaunchError(error) &&
|
|
7015
|
+
error.code === 'runtime_gateway_oidc_unavailable'
|
|
7016
|
+
) {
|
|
7017
|
+
console.error('[absurd-runtime.worker] runtime_gateway_oidc_unavailable', {
|
|
7018
|
+
runId,
|
|
7019
|
+
error: error.message,
|
|
7020
|
+
});
|
|
7021
|
+
return 'The requested Runtime gateway profile is unavailable, so this run cannot start. Run without a gateway profile or retry later.';
|
|
7022
|
+
}
|
|
7023
|
+
return runErrorMessage(error);
|
|
7024
|
+
}
|
|
7025
|
+
|
|
6992
7026
|
/**
|
|
6993
7027
|
* Final-attempt terminal salvage. When the LAST engine attempt of a play-run
|
|
6994
7028
|
* task dies with an unexpected error (Daytona/app-runtime/DB throw — NOT a park
|
|
@@ -7040,7 +7074,7 @@ async function salvageAbsurdFinalAttemptTerminal(input: {
|
|
|
7040
7074
|
);
|
|
7041
7075
|
}
|
|
7042
7076
|
if (!input.force && attempt < maxAttempts) return;
|
|
7043
|
-
const message =
|
|
7077
|
+
const message = customerSafeSalvageMessage(input.runId, input.error);
|
|
7044
7078
|
const failedResult: PlayRunnerResult = {
|
|
7045
7079
|
status: 'failed',
|
|
7046
7080
|
error:
|
|
@@ -8903,8 +8937,10 @@ export function selectAbsurdAdoptionQueues(input: {
|
|
|
8903
8937
|
*
|
|
8904
8938
|
* - No `onWake`: an adopted queue never opens a direct LISTEN session (see
|
|
8905
8939
|
* `ABSURD_ADOPTED_LANE_POLL_INTERVAL_MS`).
|
|
8906
|
-
* - `idlePollFallbackMs` is the same 30-second durable bound
|
|
8907
|
-
*
|
|
8940
|
+
* - `idlePollFallbackMs` is the same 30-second durable bound as an active
|
|
8941
|
+
* lane's unprobed standby claim (`ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS`).
|
|
8942
|
+
* Adopted lanes run no 1-second standby probe: their parked waits tolerate
|
|
8943
|
+
* the adoption rotation already.
|
|
8908
8944
|
* - `nextPollDelayMs` still shortens the wait to the lane's next indexed due
|
|
8909
8945
|
* transition, so an already-due parked wake is claimed on the next pass.
|
|
8910
8946
|
*/
|
|
@@ -10616,10 +10652,133 @@ export async function readAbsurdQueueNextDueAt(
|
|
|
10616
10652
|
return (await readAbsurdQueueNextDue(client, queue)).dueAt;
|
|
10617
10653
|
}
|
|
10618
10654
|
|
|
10655
|
+
/**
|
|
10656
|
+
* Whether `absurd.claim_task` on this queue would do anything now: claim a
|
|
10657
|
+
* runnable run, fail an expired claim lease, or cancel a task past its
|
|
10658
|
+
* deadline. Each branch is a superset of the matching `claim_task` predicate
|
|
10659
|
+
* (the claim also checks its task row), so `false` proves the claim would
|
|
10660
|
+
* select nothing. Each branch is an ordered seek on the index `claim_task`
|
|
10661
|
+
* itself uses (`r_<queue>_sai`, `r_<queue>_cei`, `t_<queue>_cai`), bounded by
|
|
10662
|
+
* now. `readAbsurdQueueNextDue` cannot stand in for it: its
|
|
10663
|
+
* `min(available_at)` over two states aggregates every parked run.
|
|
10664
|
+
*/
|
|
10665
|
+
export async function hasAbsurdQueueDueWork(
|
|
10666
|
+
client: RuntimeSchedulerQueryClient,
|
|
10667
|
+
queue: string,
|
|
10668
|
+
): Promise<boolean> {
|
|
10669
|
+
const runTable = quotePostgresIdentifier(`r_${queue}`);
|
|
10670
|
+
const taskTable = quotePostgresIdentifier(`t_${queue}`);
|
|
10671
|
+
// `absurd.current_time()` is volatile, so it cannot bound an index scan
|
|
10672
|
+
// directly. Read it once (honouring `absurd.fake_now`, like claim_task) and
|
|
10673
|
+
// compare against the materialized value.
|
|
10674
|
+
const result = await client.query<{ due: boolean }>(
|
|
10675
|
+
`WITH clock AS MATERIALIZED (SELECT absurd.current_time() AS now)
|
|
10676
|
+
SELECT (
|
|
10677
|
+
(SELECT run_id FROM absurd.${runTable}
|
|
10678
|
+
WHERE state = 'pending'
|
|
10679
|
+
AND available_at <= (SELECT now FROM clock)
|
|
10680
|
+
ORDER BY available_at LIMIT 1) IS NOT NULL
|
|
10681
|
+
OR (SELECT run_id FROM absurd.${runTable}
|
|
10682
|
+
WHERE state = 'sleeping'
|
|
10683
|
+
AND available_at <= (SELECT now FROM clock)
|
|
10684
|
+
ORDER BY available_at LIMIT 1) IS NOT NULL
|
|
10685
|
+
OR (SELECT run_id FROM absurd.${runTable}
|
|
10686
|
+
WHERE state = 'running'
|
|
10687
|
+
AND claim_expires_at IS NOT NULL
|
|
10688
|
+
AND claim_expires_at <= (SELECT now FROM clock)
|
|
10689
|
+
ORDER BY claim_expires_at LIMIT 1) IS NOT NULL
|
|
10690
|
+
OR (SELECT task_id FROM absurd.${taskTable}
|
|
10691
|
+
WHERE state IN ('pending', 'sleeping', 'running')
|
|
10692
|
+
AND cancel_at IS NOT NULL
|
|
10693
|
+
AND cancel_at <= (SELECT now FROM clock)
|
|
10694
|
+
ORDER BY cancel_at LIMIT 1) IS NOT NULL
|
|
10695
|
+
) AS due`,
|
|
10696
|
+
);
|
|
10697
|
+
return result.rows[0]?.due === true;
|
|
10698
|
+
}
|
|
10699
|
+
|
|
10700
|
+
/**
|
|
10701
|
+
* Wraps the engine's two maintenance hooks to tell whether its claim loop can
|
|
10702
|
+
* take work. The engine calls `saturatedMaintenance` only while every slot is
|
|
10703
|
+
* busy, and `afterClaim` only after a claim, which it attempts only with a free
|
|
10704
|
+
* slot; the later of the two is the loop's current state. When a slot frees,
|
|
10705
|
+
* the engine claims by itself, so a stale saturated reading lasts only until
|
|
10706
|
+
* that claim.
|
|
10707
|
+
*/
|
|
10708
|
+
export function trackAbsurdClaimLoopCapacity(hooks: {
|
|
10709
|
+
afterClaim: () => Promise<void>;
|
|
10710
|
+
saturatedMaintenance: () => Promise<void>;
|
|
10711
|
+
}): {
|
|
10712
|
+
afterClaim: () => Promise<void>;
|
|
10713
|
+
saturatedMaintenance: () => Promise<void>;
|
|
10714
|
+
hasIdleSlot: () => boolean;
|
|
10715
|
+
} {
|
|
10716
|
+
let saturated = false;
|
|
10717
|
+
return {
|
|
10718
|
+
afterClaim: () => {
|
|
10719
|
+
saturated = false;
|
|
10720
|
+
return hooks.afterClaim();
|
|
10721
|
+
},
|
|
10722
|
+
saturatedMaintenance: () => {
|
|
10723
|
+
saturated = true;
|
|
10724
|
+
return hooks.saturatedMaintenance();
|
|
10725
|
+
},
|
|
10726
|
+
hasIdleSlot: () => !saturated,
|
|
10727
|
+
};
|
|
10728
|
+
}
|
|
10729
|
+
|
|
10730
|
+
/**
|
|
10731
|
+
* The standby half of the active lane's wake path. The elected listener is
|
|
10732
|
+
* woken by NOTIFY; every other worker on the queue runs this loop. Each tick
|
|
10733
|
+
* runs `probe` (`hasAbsurdQueueDueWork`) and, when it finds due work, wakes the
|
|
10734
|
+
* engine's claim loop, which claims at once. An empty tick costs only the
|
|
10735
|
+
* probe, so polling every second never plans the multi-kilobyte claim on an
|
|
10736
|
+
* idle queue.
|
|
10737
|
+
*
|
|
10738
|
+
* Skipped while this worker is the listener (NOTIFY already wakes it) and while
|
|
10739
|
+
* every slot is busy: a woken saturated loop only repeats its maintenance, and
|
|
10740
|
+
* the engine claims by itself as soon as a slot frees.
|
|
10741
|
+
*/
|
|
10742
|
+
export async function runAbsurdStandbyDueWorkProbe(input: {
|
|
10743
|
+
isListening: () => boolean;
|
|
10744
|
+
/** False while the claim loop last stopped because every slot was busy. */
|
|
10745
|
+
hasIdleSlot: () => boolean;
|
|
10746
|
+
probe: () => Promise<boolean>;
|
|
10747
|
+
/** The engine's "poll now" trigger; a lossy hint like any other wake. */
|
|
10748
|
+
wake: () => boolean;
|
|
10749
|
+
shouldStop: () => boolean;
|
|
10750
|
+
intervalMs?: number;
|
|
10751
|
+
sleep?: (ms: number) => Promise<void>;
|
|
10752
|
+
onWake?: () => void;
|
|
10753
|
+
onError: (error: unknown) => void;
|
|
10754
|
+
}): Promise<void> {
|
|
10755
|
+
const intervalMs = Math.max(
|
|
10756
|
+
1,
|
|
10757
|
+
Math.floor(input.intervalMs ?? ABSURD_ACTIVE_STANDBY_POLL_INTERVAL_MS),
|
|
10758
|
+
);
|
|
10759
|
+
const wait = input.sleep ?? ((ms: number) => sleep(ms));
|
|
10760
|
+
while (!input.shouldStop()) {
|
|
10761
|
+
await wait(intervalMs);
|
|
10762
|
+
if (input.shouldStop()) return;
|
|
10763
|
+
// A failed tick is reported and retried next interval; the loop never
|
|
10764
|
+
// exits early, or the standby would silently fall back to its 30 s claim.
|
|
10765
|
+
try {
|
|
10766
|
+
if (input.isListening() || !input.hasIdleSlot()) continue;
|
|
10767
|
+
if ((await input.probe()) && !input.shouldStop() && input.wake()) {
|
|
10768
|
+
input.onWake?.();
|
|
10769
|
+
}
|
|
10770
|
+
} catch (error) {
|
|
10771
|
+
input.onError(error);
|
|
10772
|
+
}
|
|
10773
|
+
}
|
|
10774
|
+
}
|
|
10775
|
+
|
|
10619
10776
|
/**
|
|
10620
10777
|
* 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
|
-
*
|
|
10778
|
+
* direct LISTEN session; each loser immediately closes its session and finds
|
|
10779
|
+
* work through the 1-second standby probe (`runAbsurdStandbyDueWorkProbe`),
|
|
10780
|
+
* with the bounded durable claim fallback beneath it, until it can win a later
|
|
10781
|
+
* election.
|
|
10623
10782
|
*/
|
|
10624
10783
|
export type AbsurdWorkerWakeHook = ((
|
|
10625
10784
|
wake: () => void,
|
|
@@ -10718,10 +10877,12 @@ export function createAbsurdWorkerWakeHook(input: {
|
|
|
10718
10877
|
};
|
|
10719
10878
|
// A local hint does not establish LISTEN health. Preserve the fast durable
|
|
10720
10879
|
// fallback on isolated workers, including when a hint is lost or unavailable.
|
|
10880
|
+
// A direct-notify standby discovers work through its 1-second probe
|
|
10881
|
+
// (`runAbsurdStandbyDueWorkProbe`); its unprobed claim keeps the 30 s bound.
|
|
10721
10882
|
hook.idlePollFallbackMs =
|
|
10722
10883
|
input.useDirectNotify === false
|
|
10723
10884
|
? ABSURD_WAKE_UNAVAILABLE_POLL_INTERVAL_MS
|
|
10724
|
-
:
|
|
10885
|
+
: ABSURD_ACTIVE_STANDBY_CLAIM_FALLBACK_MS;
|
|
10725
10886
|
hook.close = () => {
|
|
10726
10887
|
closed = true;
|
|
10727
10888
|
listening = false;
|
|
@@ -10903,15 +11064,16 @@ export async function startRuntimeWorkerHost(
|
|
|
10903
11064
|
...recovered,
|
|
10904
11065
|
});
|
|
10905
11066
|
}
|
|
11067
|
+
const useDirectNotify = shouldUseRuntimeSchedulerDirectNotify(
|
|
11068
|
+
schedulerOptions.schema,
|
|
11069
|
+
);
|
|
10906
11070
|
const onWake = createAbsurdWorkerWakeHook({
|
|
10907
11071
|
poolOptions,
|
|
10908
11072
|
queue,
|
|
10909
11073
|
// A draining lane is deliberately cold except while it has runnable work.
|
|
10910
11074
|
// It must not compete with the active lane for the one direct LISTEN slot.
|
|
10911
11075
|
draining: drainExit,
|
|
10912
|
-
useDirectNotify
|
|
10913
|
-
schedulerOptions.schema,
|
|
10914
|
-
),
|
|
11076
|
+
useDirectNotify,
|
|
10915
11077
|
enableWakeHints: true,
|
|
10916
11078
|
});
|
|
10917
11079
|
const reportCancellationProgress = createRateLimitedRuntimeLogger({
|
|
@@ -10946,11 +11108,7 @@ export async function startRuntimeWorkerHost(
|
|
|
10946
11108
|
const reportQueueError = createRateLimitedRuntimeLogger({
|
|
10947
11109
|
log: (...args) => console.error(...args),
|
|
10948
11110
|
});
|
|
10949
|
-
const
|
|
10950
|
-
workerId: `${workerBase}:${queue}`,
|
|
10951
|
-
concurrency: slots,
|
|
10952
|
-
claimTimeout: HEARTBEAT_CLAIM_TIMEOUT_SECONDS,
|
|
10953
|
-
pollInterval: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11111
|
+
const claimLoop = trackAbsurdClaimLoopCapacity({
|
|
10954
11112
|
// `claim_task` performs the indexed max_delay sweep. Reconcile after every
|
|
10955
11113
|
// sweep, including claims that return backlog work, so a saturated queue
|
|
10956
11114
|
// cannot postpone a cancellation's scheduler/outbox terminal indefinitely.
|
|
@@ -10960,6 +11118,14 @@ export async function startRuntimeWorkerHost(
|
|
|
10960
11118
|
// by sweeping without claiming, then project cancellation into the
|
|
10961
11119
|
// scheduler/outbox.
|
|
10962
11120
|
saturatedMaintenance: sweepAndReconcileCancellations,
|
|
11121
|
+
});
|
|
11122
|
+
const worker = await absurdClient.startWorker({
|
|
11123
|
+
workerId: `${workerBase}:${queue}`,
|
|
11124
|
+
concurrency: slots,
|
|
11125
|
+
claimTimeout: HEARTBEAT_CLAIM_TIMEOUT_SECONDS,
|
|
11126
|
+
pollInterval: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11127
|
+
afterClaim: claimLoop.afterClaim,
|
|
11128
|
+
saturatedMaintenance: claimLoop.saturatedMaintenance,
|
|
10963
11129
|
nextPollDelayMs: () =>
|
|
10964
11130
|
withRuntimeSchedulerClient(poolOptions, async (client) => {
|
|
10965
11131
|
const nextDue = await readAbsurdQueueNextDue(client, queue);
|
|
@@ -10967,15 +11133,51 @@ export async function startRuntimeWorkerHost(
|
|
|
10967
11133
|
return nextDue.dueAt.getTime() - Date.now();
|
|
10968
11134
|
}),
|
|
10969
11135
|
// Once this lane is the elected healthy listener, a transactional NOTIFY
|
|
10970
|
-
// wakes it. Standby/down lanes
|
|
10971
|
-
//
|
|
10972
|
-
// shortens the wait for
|
|
11136
|
+
// wakes it. Standby/down lanes find new work through the 1-second probe
|
|
11137
|
+
// below and keep a 30-second unprobed claim, so idle workers never repeat
|
|
11138
|
+
// empty claims; the indexed next-due read still shortens the wait for
|
|
11139
|
+
// known deadlines.
|
|
10973
11140
|
idlePollFallbackMs: () => resolveAbsurdIdlePollFallbackMs(onWake),
|
|
10974
11141
|
onWake,
|
|
10975
11142
|
fatalOnLeaseTimeout: false,
|
|
10976
11143
|
onError: (error) =>
|
|
10977
11144
|
reportQueueError('[absurd-runtime.worker] queue_error', { queue, error }),
|
|
10978
11145
|
});
|
|
11146
|
+
// Isolated (Preview) workers already claim every second, and a draining lane
|
|
11147
|
+
// has no wake hook, so only a direct-notify active lane runs the probe.
|
|
11148
|
+
let standbyProbeStopped = false;
|
|
11149
|
+
const reportStandbyProbeWake = createRateLimitedRuntimeLogger({
|
|
11150
|
+
log: (...args) => console.info(...args),
|
|
11151
|
+
});
|
|
11152
|
+
const reportStandbyProbeError = createRateLimitedRuntimeLogger({
|
|
11153
|
+
log: (...args) => console.error(...args),
|
|
11154
|
+
});
|
|
11155
|
+
const standbyProbe =
|
|
11156
|
+
onWake && useDirectNotify
|
|
11157
|
+
? runAbsurdStandbyDueWorkProbe({
|
|
11158
|
+
isListening: () => onWake.isListening(),
|
|
11159
|
+
hasIdleSlot: claimLoop.hasIdleSlot,
|
|
11160
|
+
probe: () =>
|
|
11161
|
+
withRuntimeSchedulerClient(poolOptions, (client) =>
|
|
11162
|
+
hasAbsurdQueueDueWork(client, queue),
|
|
11163
|
+
),
|
|
11164
|
+
wake: () => onWake.wake(),
|
|
11165
|
+
shouldStop: () => standbyProbeStopped,
|
|
11166
|
+
onWake: () =>
|
|
11167
|
+
reportStandbyProbeWake(
|
|
11168
|
+
'[absurd-runtime.worker] standby_probe_wake',
|
|
11169
|
+
{ queue, releaseId },
|
|
11170
|
+
),
|
|
11171
|
+
onError: (error) =>
|
|
11172
|
+
reportStandbyProbeError(
|
|
11173
|
+
'[absurd-runtime.worker] standby_probe_failed',
|
|
11174
|
+
{
|
|
11175
|
+
queue,
|
|
11176
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11177
|
+
},
|
|
11178
|
+
),
|
|
11179
|
+
})
|
|
11180
|
+
: null;
|
|
10979
11181
|
// Compute settlement and cleanup each have their own controller and
|
|
10980
11182
|
// database lease. Neither consumes an ordinary play slot or competes with
|
|
10981
11183
|
// new starts under org concurrency.
|
|
@@ -11167,6 +11369,9 @@ export async function startRuntimeWorkerHost(
|
|
|
11167
11369
|
schema: schedulerOptions.schema ?? null,
|
|
11168
11370
|
slots,
|
|
11169
11371
|
idlePollIntervalSeconds: ABSURD_IDLE_POLL_INTERVAL_SECONDS,
|
|
11372
|
+
standbyProbeIntervalMs: standbyProbe
|
|
11373
|
+
? ABSURD_ACTIVE_STANDBY_POLL_INTERVAL_MS
|
|
11374
|
+
: null,
|
|
11170
11375
|
queue,
|
|
11171
11376
|
releaseId,
|
|
11172
11377
|
drainExit,
|
|
@@ -11183,6 +11388,7 @@ export async function startRuntimeWorkerHost(
|
|
|
11183
11388
|
// its listener without exhausting primary scheduler sessions.
|
|
11184
11389
|
closeWake: () => onWake?.close(),
|
|
11185
11390
|
stopControllers: () => {
|
|
11391
|
+
standbyProbeStopped = true;
|
|
11186
11392
|
drainStopped = true;
|
|
11187
11393
|
billingStopped = true;
|
|
11188
11394
|
cleanupStopped = true;
|
|
@@ -11190,6 +11396,7 @@ export async function startRuntimeWorkerHost(
|
|
|
11190
11396
|
overdueCeilingStopped = true;
|
|
11191
11397
|
},
|
|
11192
11398
|
controllers: [
|
|
11399
|
+
standbyProbe,
|
|
11193
11400
|
overdueCeilingController,
|
|
11194
11401
|
drainWatch,
|
|
11195
11402
|
adoptionSupervisor,
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkKBM5T6UVjs = require('./chunk-KBM5T6UV.js');
|
|
4
|
+
require('./chunk-JU35QU3Z.js');
|
|
5
|
+
require('./chunk-E4CABWXL.js');
|
|
6
|
+
require('./chunk-RNSHCJME.js');
|
|
7
|
+
require('./chunk-NMU3VR5U.js');
|
|
8
|
+
require('./chunk-WSGXBROE.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkVZN6D23Pjs = require('./chunk-VZN6D23P.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkL7CAOWHYjs = require('./chunk-L7CAOWHY.js');
|
|
15
|
+
require('./chunk-ZZ7SVWKR.js');
|
|
16
|
+
require('./chunk-ALJJRZNJ.js');
|
|
17
|
+
require('./chunk-XNYIZMNQ.js');
|
|
18
|
+
require('./chunk-DIAWYWT5.js');
|
|
19
|
+
require('./chunk-BP4XEO6Z.js');
|
|
20
|
+
require('./chunk-OG64RBAC.js');
|
|
21
|
+
require('./chunk-COGTRVWW.js');
|
|
22
|
+
|
|
23
|
+
// src/cli/commands/artifacts.ts
|
|
24
|
+
var _promises = require('fs/promises');
|
|
25
|
+
var ARTIFACTS_FEATURE = "artifacts";
|
|
26
|
+
function print(command, json, data, lines) {
|
|
27
|
+
_chunkVZN6D23Pjs.printCommandEnvelope.call(void 0,
|
|
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 _promises.readFile.call(void 0, value.slice(1), "utf8") : value;
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(text);
|
|
46
|
+
} catch (e) {
|
|
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: !_chunkL7CAOWHYjs.cliFeatureEnabled.call(void 0, 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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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(_nullishCoalesce(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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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 (0, _chunkKBM5T6UVjs.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
|
+
|
|
267
|
+
|
|
268
|
+
exports.registerArtifactsCommands = registerArtifactsCommands;
|