deepline 0.3.552 → 0.3.554
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 +107 -12
- package/dist/bundling-sources/sdk/src/compat.ts +239 -87
- package/dist/bundling-sources/sdk/src/config.ts +113 -2
- package/dist/bundling-sources/sdk/src/errors.ts +2 -0
- package/dist/bundling-sources/sdk/src/http-core.ts +118 -8
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/integrations.ts +6 -4
- package/dist/bundling-sources/sdk/src/play.ts +3 -0
- package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +8 -1
- package/dist/bundling-sources/sdk/src/tool-calls.ts +2 -1
- package/dist/bundling-sources/sdk/src/tool-failure-hint.ts +104 -0
- package/dist/bundling-sources/sdk/src/types.ts +9 -1
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +4 -2
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-plan-skus.ts +25 -0
- package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/billing/credit-recovery.ts +58 -4
- package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +8 -0
- package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +11 -0
- package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +13 -0
- package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +103 -5
- package/dist/bundling-sources/shared_libs/monitors/fleets/converge-admission.ts +133 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/fence-attention.ts +165 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/fence-release.ts +726 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/fence-walk.ts +274 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +1 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +28 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/provider-bulk-wait.ts +126 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/shared-payload.ts +189 -0
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +28 -0
- package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +4 -0
- package/dist/bundling-sources/shared_libs/monitors/inventory-counter-errors.ts +25 -0
- package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +65 -0
- package/dist/bundling-sources/shared_libs/monitors/package.json +9 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +152 -1
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +6 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +390 -10
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +34 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +66 -30
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +30 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +26 -3
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +41 -13
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/raw-receipt-causes.ts +219 -0
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +21 -10
- package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +13 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +6 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +13 -0
- package/dist/bundling-sources/shared_libs/observability/dlq.ts +1 -1
- package/dist/bundling-sources/shared_libs/observability/log-metadata.ts +5 -3
- package/dist/bundling-sources/shared_libs/observability/queue-health.ts +10 -1
- package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/redaction.ts +24 -1
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +168 -41
- package/dist/bundling-sources/shared_libs/observability/scheduled-work-manual.ts +1 -2
- package/dist/bundling-sources/shared_libs/play-data-plane/preview-r2-oidc.ts +188 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +170 -16
- package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +68 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +444 -39
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-fetch-caller-deadline.ts +200 -0
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +21 -1
- package/dist/bundling-sources/shared_libs/play-runtime/durable-call-cache.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +70 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-tool-identity.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +72 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +7 -1
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +62 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +74 -3
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +31 -3
- package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/query-result-dataset.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +33 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +24 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +254 -44
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +87 -6
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +241 -10
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +161 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +16 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-compression.ts +37 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-paths.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +259 -52
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +30 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +62 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +206 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +185 -64
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-slot-ledger.ts +157 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +110 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +323 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/executor-attempt-standing.ts +72 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-storage.ts +23 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-workspace-purge.ts +199 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +632 -66
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +517 -16
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-receipt-value-storage.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +599 -2
- package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +51 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +113 -3
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +5 -7
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +3 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +40 -5
- package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/control-plane-types.ts +16 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +10 -41
- package/dist/bundling-sources/shared_libs/plays/extension-bridge.ts +33 -0
- package/dist/bundling-sources/shared_libs/plays/row-identity.ts +18 -1
- package/dist/bundling-sources/shared_libs/plays/tool-execution-error.ts +108 -0
- package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +14 -0
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +171 -0
- package/dist/bundling-sources/shared_libs/product-notifications/events.ts +27 -1
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +9 -24
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +178 -5
- package/dist/bundling-sources/shared_libs/security/signup-email-dns-screen.ts +148 -0
- package/dist/bundling-sources/shared_libs/tool-execution-error.ts +108 -0
- package/dist/cli/{auth-KVSBJZOX.mjs → auth-HJUNW7T2.mjs} +8 -7
- package/dist/cli/auth-SP6SKZJZ.js +44 -0
- package/dist/cli/{billing-FQREA7UA.js → billing-4TSA5HEC.js} +297 -161
- package/dist/cli/{billing-54RHFEBI.mjs → billing-SJYRJAQ2.mjs} +197 -61
- package/dist/cli/{chunk-4MK42735.js → chunk-2HMN5H54.js} +215 -130
- package/dist/cli/{chunk-UBKA33KY.mjs → chunk-2MGZAI54.mjs} +17 -0
- package/dist/cli/{chunk-EOPEYCY7.mjs → chunk-2ORPFQUA.mjs} +18 -18
- package/dist/cli/{chunk-RQZQVFCJ.js → chunk-2OVHNHCF.js} +2 -2
- package/dist/cli/{chunk-QX7LFGJR.mjs → chunk-33WRQSQ2.mjs} +1874 -91
- package/dist/cli/{chunk-UPMRIVZB.js → chunk-3IKGZ4CG.js} +74 -13
- package/dist/cli/{chunk-EUPVF4SU.mjs → chunk-3Z4VFCXO.mjs} +8 -8
- package/dist/cli/{chunk-GKYAYLRI.js → chunk-4DOFGIEJ.js} +27 -31
- package/dist/cli/{chunk-4TALT2M3.mjs → chunk-52Q5KETX.mjs} +69 -3
- package/dist/cli/{chunk-RBEUVDZF.js → chunk-5CYZHOKI.js} +249 -107
- package/dist/cli/{chunk-LX35AXTN.mjs → chunk-5TYLSS4Q.mjs} +6 -6
- package/dist/cli/{chunk-IYSTRCLX.mjs → chunk-62AUAWQV.mjs} +4 -4
- package/dist/cli/{chunk-ZIAXDBXX.mjs → chunk-62HWJXST.mjs} +17 -21
- package/dist/cli/{chunk-QY3ZNU6Z.mjs → chunk-6EXOAT6T.mjs} +2 -2
- package/dist/cli/{chunk-EITMD3A5.js → chunk-6VLFQZK6.js} +8 -8
- package/dist/cli/{chunk-ADRC5I3R.js → chunk-7OWI736E.js} +30 -30
- package/dist/cli/{chunk-NURW5XH4.mjs → chunk-ASB47RXJ.mjs} +1 -1
- package/dist/cli/{chunk-PTVD2GVQ.mjs → chunk-B6HO2XWH.mjs} +13 -13
- package/dist/cli/{chunk-YJHE3O5M.mjs → chunk-BOZAP2EM.mjs} +141 -56
- package/dist/cli/chunk-BVXIGOBZ.js +32 -0
- package/dist/cli/{chunk-XDVT3GOM.js → chunk-CFJFUVX2.js} +18 -1
- package/dist/cli/{chunk-WE5HES3H.mjs → chunk-D6Z6POKE.mjs} +151 -43
- package/dist/cli/{chunk-AZQ264ID.mjs → chunk-DSKSFFK2.mjs} +1 -1
- package/dist/cli/{chunk-SHLFOPD6.js → chunk-DUBXUAAO.js} +5 -5
- package/dist/cli/{chunk-V436Z54K.js → chunk-E2G2DNAB.js} +3 -1
- package/dist/cli/{chunk-HO3XK3R7.js → chunk-E74KGKFZ.js} +8 -8
- package/dist/cli/{chunk-77AAAGVB.js → chunk-ECHKAC7M.js} +2 -2
- package/dist/cli/{chunk-KWSH5T7K.js → chunk-EN5NHCCQ.js} +21 -21
- package/dist/cli/{chunk-6RZOWL2V.mjs → chunk-F7CMRKSK.mjs} +1 -1
- package/dist/cli/{chunk-JWUAX6OP.js → chunk-FBAFX43W.js} +11 -11
- package/dist/cli/{chunk-AQWQ2BFX.mjs → chunk-FXQ3JKE3.mjs} +1 -1
- package/dist/cli/{chunk-QPKH23EC.mjs → chunk-GA2M3G3Y.mjs} +5 -5
- package/dist/cli/{chunk-G4O75EXF.js → chunk-GHT2NDL7.js} +18 -18
- package/dist/cli/{chunk-MF2GHZDO.js → chunk-GRZENGNE.js} +2 -2
- package/dist/cli/{chunk-4UUR4TCH.js → chunk-IVZKMJUK.js} +1875 -92
- package/dist/cli/{chunk-FTJLJCE5.mjs → chunk-KVBQY4ST.mjs} +3 -3
- package/dist/cli/{chunk-S5S355UY.mjs → chunk-KZHBDMGF.mjs} +12 -12
- package/dist/cli/{chunk-BBTKAASQ.js → chunk-LFQJW4S2.js} +42 -1
- package/dist/cli/{chunk-6ZORHRKB.mjs → chunk-LRZGS6RZ.mjs} +2 -0
- package/dist/cli/{chunk-2WFPHBR4.js → chunk-LY5MMXFF.js} +47 -29
- package/dist/cli/{chunk-BAIST2BR.js → chunk-M7STM3MZ.js} +36 -36
- package/dist/cli/{chunk-SL6MYJYM.js → chunk-MJTVX4QK.js} +35 -35
- package/dist/cli/{chunk-45PVGZST.js → chunk-OPTV7D2V.js} +508 -361
- package/dist/cli/{chunk-PFO3ISXA.js → chunk-OVEYWO4H.js} +174 -129
- package/dist/cli/{chunk-BGBJV26E.mjs → chunk-PC2FTUCP.mjs} +4 -4
- package/dist/cli/{chunk-WLN3SUIA.js → chunk-PQQMPUCZ.js} +3 -3
- package/dist/cli/{chunk-HYC4MKGK.mjs → chunk-Q7ACILL2.mjs} +5 -5
- package/dist/cli/{chunk-CBV7AKWM.js → chunk-R6DZ6NQ2.js} +5 -5
- package/dist/cli/{chunk-57VZVF5D.mjs → chunk-RBBTCYQB.mjs} +3 -3
- package/dist/cli/{chunk-F2LH7TGF.js → chunk-RTHMGSZX.js} +21 -21
- package/dist/cli/{chunk-YLTMXJFC.mjs → chunk-S6W6SJ6E.mjs} +158 -16
- package/dist/cli/chunk-STXDSVQZ.mjs +32 -0
- package/dist/cli/{chunk-WEHCBH5R.mjs → chunk-TGUQET3O.mjs} +67 -6
- package/dist/cli/{chunk-IHRKLXZN.js → chunk-TJ6HLN56.js} +5 -5
- package/dist/cli/{chunk-3FD5EQ62.js → chunk-TOO3YM5N.js} +6 -7
- package/dist/cli/{chunk-QILKGXYF.mjs → chunk-UBBYHB2B.mjs} +2 -2
- package/dist/cli/{chunk-6PRW5UBA.mjs → chunk-UC4BDZKI.mjs} +299 -69
- package/dist/cli/{chunk-634ZDA3F.js → chunk-UNNOZKRT.js} +1 -1
- package/dist/cli/{chunk-IDVVIXPJ.js → chunk-UOT7HPBH.js} +41 -41
- package/dist/cli/{chunk-6YCA5NKJ.js → chunk-UYCZFQYQ.js} +12 -12
- package/dist/cli/{chunk-7IKQKKNX.js → chunk-VIUUTEHY.js} +90 -24
- package/dist/cli/{chunk-Z5TSLLOW.mjs → chunk-VLO5NFH2.mjs} +63 -18
- package/dist/cli/{chunk-U7QRMBIY.mjs → chunk-VQ75KX7G.mjs} +5 -5
- package/dist/cli/{chunk-4NQF6KJ3.js → chunk-VV4XGZ24.js} +13 -13
- package/dist/cli/{chunk-FSIVF2SI.mjs → chunk-VZGLIK5U.mjs} +1 -1
- package/dist/cli/{chunk-S46HWQKO.js → chunk-W6CZDTIR.js} +69 -69
- package/dist/cli/{chunk-XVB7V4N7.js → chunk-WL7P32PI.js} +161 -53
- package/dist/cli/{chunk-DJ2JDK4O.mjs → chunk-XD3MFTHA.mjs} +1 -1
- package/dist/cli/{chunk-GGGAEVCX.mjs → chunk-XFZX6FNM.mjs} +40 -22
- package/dist/cli/{chunk-AWJPDPMA.mjs → chunk-XU6QNM4D.mjs} +1 -1
- package/dist/cli/{chunk-QAORXEY3.mjs → chunk-YCOGPOUX.mjs} +6 -7
- package/dist/cli/{chunk-VQALXEXO.js → chunk-YQKCH4R7.js} +348 -118
- package/dist/cli/{chunk-6O5HOODW.mjs → chunk-YY55NYAH.mjs} +207 -60
- package/dist/cli/{chunk-JL2OTMSG.mjs → chunk-Z3A2S3QM.mjs} +41 -0
- package/dist/cli/command-docs.js +3 -3
- package/dist/cli/command-docs.mjs +2 -2
- package/dist/cli/{concurrent-runs-help-Q4KPAUJX.mjs → concurrent-runs-help-O3Q5IPLF.mjs} +9 -8
- package/dist/cli/concurrent-runs-help-ZFRZWX5V.js +22 -0
- package/dist/cli/{csv-F5VAGX4K.js → csv-4ZQ2RATI.js} +16 -15
- package/dist/cli/{csv-2PTVDNO6.mjs → csv-Y3BFPEM6.mjs} +7 -6
- package/dist/cli/{db-IEDXAUF7.mjs → db-3JYY4JNN.mjs} +17 -17
- package/dist/cli/{db-Z3OIUFMM.js → db-VEIFS4M7.js} +45 -45
- package/dist/cli/describe-EVJ4MFVU.mjs +50 -0
- package/dist/cli/describe-FG625QPF.js +50 -0
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/describe-core.js +7 -7
- package/dist/cli/describe-core.mjs +6 -6
- package/dist/cli/{executions-H6H5655J.js → executions-HPZXOOVX.js} +12 -12
- package/dist/cli/{executions-R3LP74QN.mjs → executions-PCXZKEHM.mjs} +10 -10
- package/dist/cli/{feedback-WL3MRVT5.mjs → feedback-Y6VKZNY6.mjs} +9 -8
- package/dist/cli/{feedback-VFOUR66B.js → feedback-ZKFHFVL6.js} +17 -16
- package/dist/cli/git-RUBMALLH.js +26 -0
- package/dist/cli/{git-YX2J4GCI.mjs → git-UMPR2QYC.mjs} +8 -7
- package/dist/cli/index.js +170 -158
- package/dist/cli/index.mjs +60 -48
- package/dist/cli/{integrations-E2JZYKHS.js → integrations-3GQCTRTF.js} +23 -27
- package/dist/cli/{integrations-5ZK5KLVP.mjs → integrations-V3TM6XAB.mjs} +15 -19
- package/dist/cli/{legacy-noops-SMN3GSXY.mjs → legacy-noops-JZBUD7ZE.mjs} +9 -8
- package/dist/cli/{legacy-noops-3VW4IJTH.js → legacy-noops-VYCO7NGW.js} +12 -11
- package/dist/cli/{mcp-UQV2K4EW.js → mcp-4OIWTCE6.js} +121 -48
- package/dist/cli/{mcp-V6MGCYAG.mjs → mcp-PH4KZ76P.mjs} +100 -27
- package/dist/cli/{monitors-R3BBDCRC.js → monitors-E2A6VPBY.js} +221 -186
- package/dist/cli/{monitors-GGKS5W6M.mjs → monitors-SSMGIDGX.mjs} +58 -23
- package/dist/cli/org-SFDKSK5D.mjs +2289 -0
- package/dist/cli/org-WUDZGWBT.js +2289 -0
- package/dist/cli/outcomes-QT7LQBPK.mjs +2865 -0
- package/dist/cli/outcomes-Y7SZTLSL.js +2865 -0
- package/dist/cli/{play-MDWPR4XG.mjs → play-EK7KSFPL.mjs} +376 -106
- package/dist/cli/{play-2MVO27VO.js → play-GDNHCRRR.js} +1150 -880
- package/dist/cli/{providers-AKDYFZJZ.mjs → providers-FVZLRXAU.mjs} +10 -10
- package/dist/cli/{providers-2AACRUZH.js → providers-ZKOSECLV.js} +13 -13
- package/dist/cli/{quickstart-H6IV3PV3.js → quickstart-KSDKIXYD.js} +9 -8
- package/dist/cli/{quickstart-QDGRJFZY.mjs → quickstart-UJZ6PIQV.mjs} +7 -6
- package/dist/cli/{run-RTSQNGRD.mjs → run-E7MZ7P35.mjs} +35 -33
- package/dist/cli/{run-2634REDK.js → run-PD2BBG6S.js} +55 -53
- package/dist/cli/run-identity-LMLFMACS.js +31 -0
- package/dist/cli/{run-identity-MRNCEGV2.mjs → run-identity-MAZ7ANH5.mjs} +9 -3
- package/dist/cli/search-TKSPTPHA.js +32 -0
- package/dist/cli/{search-6AOJ4XPP.mjs → search-VTFUFTOY.mjs} +11 -11
- package/dist/cli/{search-output-S5ODBL5E.js → search-output-G2AGDCOY.js} +13 -12
- package/dist/cli/{search-output-6ADMTOU5.mjs → search-output-PFVXQCWA.mjs} +10 -9
- package/dist/cli/{secrets-TFIFBFB3.mjs → secrets-7CIMEMX7.mjs} +11 -11
- package/dist/cli/{secrets-LHCIIHMT.js → secrets-BCOQ4U7U.js} +20 -20
- package/dist/cli/sessions-4CO556VD.js +23 -0
- package/dist/cli/{sessions-WHBVUHVW.mjs → sessions-IUCQZEF7.mjs} +9 -8
- package/dist/cli/{settings-EBONWL5C.mjs → settings-KZN62UQK.mjs} +16 -16
- package/dist/cli/{settings-CP4FVK2W.js → settings-REL4736M.js} +89 -89
- package/dist/cli/{setup-I5AZE3IU.mjs → setup-2P7OG3OU.mjs} +22 -24
- package/dist/cli/{setup-LFGHTNLQ.js → setup-2XIVBBCS.js} +62 -64
- package/dist/cli/skills-JYT5DEY6.js +37 -0
- package/dist/cli/{skills-W76AO5XE.mjs → skills-VIGNDJKI.mjs} +10 -9
- package/dist/cli/tools-NTVUQ2TG.js +57 -0
- package/dist/cli/{tools-7IJHGF6W.mjs → tools-W3QT5EJY.mjs} +24 -24
- package/dist/cli/{update-GFOPZTHY.mjs → update-GZVBVMY3.mjs} +14 -11
- package/dist/cli/update-TWJZPUZM.js +37 -0
- package/dist/cli/{views-D4NX4SBG.mjs → views-BOGEH424.mjs} +47 -49
- package/dist/cli/{views-BPL2TQJ4.js → views-TOLJNLSV.js} +62 -64
- package/dist/cli/{workflow-ZYNAUCKC.js → workflow-ENWFRK5M.js} +23 -23
- package/dist/cli/{workflow-YXP42FUI.mjs → workflow-VDG2FDQV.mjs} +13 -13
- package/dist/{client-CyXGrO4D.d.mts → client-B8f7RNF8.d.mts} +1 -1
- package/dist/{client-Bf3IpUKN.d.ts → client-C5TgXmJQ.d.ts} +1 -1
- package/dist/{client-core-BxsLnXlm.d.mts → client-core-SLLGBTht.d.mts} +268 -23
- package/dist/{client-core-BWd0lX0Z.d.ts → client-core-p0sOxnkl.d.ts} +268 -23
- package/dist/{compiler-manifest-BqwVrOri.d.ts → compiler-manifest-D_zZEh9Q.d.mts} +70 -5
- package/dist/{compiler-manifest-BqwVrOri.d.mts → compiler-manifest-D_zZEh9Q.d.ts} +70 -5
- package/dist/{errors-BU8FB99X.d.mts → errors-CZCrBFrQ.d.mts} +1 -1
- package/dist/{errors-DfVN_FUG.d.ts → errors-DsUkLrdZ.d.ts} +1 -1
- package/dist/{index-BGnvtYGc.d.ts → index-B6RTOZGC.d.ts} +1 -1
- package/dist/{index-DjZgwpGw.d.mts → index-DeOVrEmX.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +66 -55
- package/dist/index.mjs +25 -14
- package/dist/install-integrity.json +163 -144
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +23 -4
- package/dist/plays/csv-data-input.js +3 -3
- package/dist/plays/csv-data-input.mjs +2 -2
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/plays/run-request.js +4 -4
- package/dist/plays/run-request.mjs +3 -3
- 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 +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +15 -13
- package/dist/server.mjs +9 -7
- package/package.json +1 -1
- package/dist/cli/auth-MMNVWATX.js +0 -43
- package/dist/cli/chunk-AID3OYVJ.js +0 -8
- package/dist/cli/chunk-OVDNJAJN.mjs +0 -8
- package/dist/cli/concurrent-runs-help-FQAIHKKC.js +0 -21
- package/dist/cli/describe-QDANCTS3.mjs +0 -50
- package/dist/cli/describe-VUTT5ZKU.js +0 -50
- package/dist/cli/git-ETB3GH3K.js +0 -25
- package/dist/cli/org-GRYVMNSW.js +0 -1282
- package/dist/cli/org-Z37NGJV4.mjs +0 -1282
- package/dist/cli/run-identity-G257GQED.js +0 -25
- package/dist/cli/search-VTW2YNBS.js +0 -32
- package/dist/cli/sessions-CJ4FJ2WB.js +0 -22
- package/dist/cli/skills-R7EBXREW.js +0 -36
- package/dist/cli/tools-V7U2BDXM.js +0 -57
- package/dist/cli/update-4COPZETK.js +0 -34
|
@@ -0,0 +1,2289 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkDUBXUAAOjs = require('./chunk-DUBXUAAO.js');
|
|
4
|
+
require('./chunk-OVEYWO4H.js');
|
|
5
|
+
require('./chunk-4WAM6TLD.js');
|
|
6
|
+
require('./chunk-MJTVX4QK.js');
|
|
7
|
+
require('./chunk-PMH4GLMD.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkYQKCH4R7js = require('./chunk-YQKCH4R7.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _chunkVIUUTEHYjs = require('./chunk-VIUUTEHY.js');
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunk5CYZHOKIjs = require('./chunk-5CYZHOKI.js');
|
|
36
|
+
require('./chunk-6VLFQZK6.js');
|
|
37
|
+
require('./chunk-XNYIZMNQ.js');
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var _chunkLFQJW4S2js = require('./chunk-LFQJW4S2.js');
|
|
41
|
+
require('./chunk-CFJFUVX2.js');
|
|
42
|
+
require('./chunk-UNNOZKRT.js');
|
|
43
|
+
require('./chunk-OG64RBAC.js');
|
|
44
|
+
require('./chunk-COGTRVWW.js');
|
|
45
|
+
|
|
46
|
+
// src/cli/commands/org.ts
|
|
47
|
+
var _crypto = require('crypto');
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
var _fs = require('fs');
|
|
55
|
+
var _path = require('path');
|
|
56
|
+
|
|
57
|
+
// src/cli/commands/scim-groups.ts
|
|
58
|
+
var GROUPS_PATH = "/api/v2/auth/workspace/scim/groups";
|
|
59
|
+
function groupPath(groupId) {
|
|
60
|
+
const trimmed = groupId.trim();
|
|
61
|
+
if (trimmed === "") {
|
|
62
|
+
throw new Error("Pass a group id from `deepline org scim groups list`.");
|
|
63
|
+
}
|
|
64
|
+
return `${GROUPS_PATH}/${encodeURIComponent(trimmed)}`;
|
|
65
|
+
}
|
|
66
|
+
function describeMapping(group) {
|
|
67
|
+
if (group.team_id === null) return "not mapped";
|
|
68
|
+
const name = _nullishCoalesce(group.team_name, () => ( group.team_id));
|
|
69
|
+
return `-> ${name} (${group.team_id})${group.team_archived ? ", archived" : ""}${group.syncing ? ", syncing members" : ""}`;
|
|
70
|
+
}
|
|
71
|
+
function describeGroup(group) {
|
|
72
|
+
return `${group.display_name} ${group.group_id} ${group.member_count} member(s) ${describeMapping(group)}`;
|
|
73
|
+
}
|
|
74
|
+
function describeMember(member) {
|
|
75
|
+
const state = !member.org_member ? "not in the org (applies when they rejoin)" : member.in_workspace ? "in workspace" : "not in workspace";
|
|
76
|
+
return `${_nullishCoalesce(member.email, () => ( member.user_id))} ${member.user_id} ${state}`;
|
|
77
|
+
}
|
|
78
|
+
function printMapping(title, payload, json) {
|
|
79
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
80
|
+
{
|
|
81
|
+
...payload,
|
|
82
|
+
render: {
|
|
83
|
+
sections: [
|
|
84
|
+
{
|
|
85
|
+
title,
|
|
86
|
+
lines: [
|
|
87
|
+
describeGroup(payload.group),
|
|
88
|
+
payload.changed ? `Workspace memberships added: ${payload.added}, removed: ${payload.removed}.` : "Nothing changed.",
|
|
89
|
+
...payload.group.syncing ? [
|
|
90
|
+
"Removed access already ended. The remaining members are being brought in line in the background; run `deepline org scim groups get` to see when syncing is done."
|
|
91
|
+
] : []
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{ json }
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function registerScimGroupCommands(scim, http2 = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ))) {
|
|
101
|
+
const groups = scim.command("groups").description(
|
|
102
|
+
"Map SCIM groups from your identity provider to workspaces (Enterprise; owners and admins)."
|
|
103
|
+
);
|
|
104
|
+
groups.command("list").description("List the org's SCIM groups and the workspace each maps to.").option("--json", "Emit JSON output").action(async (options) => {
|
|
105
|
+
const payload = await http2().get(GROUPS_PATH);
|
|
106
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
107
|
+
{
|
|
108
|
+
...payload,
|
|
109
|
+
render: {
|
|
110
|
+
sections: [
|
|
111
|
+
{
|
|
112
|
+
title: "SCIM groups",
|
|
113
|
+
lines: payload.groups.length === 0 ? [
|
|
114
|
+
"No SCIM groups yet. Push groups from your identity provider to /api/scim/v2/Groups."
|
|
115
|
+
] : payload.groups.map(describeGroup)
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{ json: options.json }
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
groups.command("get <group-id>").description(
|
|
124
|
+
"Show a SCIM group and where each member stands (in the org, in the workspace)."
|
|
125
|
+
).option("--json", "Emit JSON output").action(async (groupId, options) => {
|
|
126
|
+
const client = http2();
|
|
127
|
+
const members = [];
|
|
128
|
+
let group = null;
|
|
129
|
+
let cursor = null;
|
|
130
|
+
do {
|
|
131
|
+
const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : "";
|
|
132
|
+
const page = await client.get(
|
|
133
|
+
`${groupPath(groupId)}${query}`
|
|
134
|
+
);
|
|
135
|
+
group = page.group;
|
|
136
|
+
members.push(...page.members);
|
|
137
|
+
cursor = page.next_cursor;
|
|
138
|
+
} while (cursor);
|
|
139
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
140
|
+
{
|
|
141
|
+
group,
|
|
142
|
+
members,
|
|
143
|
+
render: {
|
|
144
|
+
sections: [
|
|
145
|
+
{
|
|
146
|
+
title: group ? describeGroup(group) : groupId,
|
|
147
|
+
lines: members.length === 0 ? ["No members."] : members.map(describeMember)
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{ json: options.json }
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
groups.command("map <group-id>").description(
|
|
156
|
+
"Map a SCIM group to a workspace; the group's org members join it."
|
|
157
|
+
).requiredOption(
|
|
158
|
+
"--workspace <workspace-id>",
|
|
159
|
+
"Workspace id from `deepline org workspaces list` (not the default workspace)"
|
|
160
|
+
).option("--json", "Emit JSON output").action(
|
|
161
|
+
async (groupId, options) => {
|
|
162
|
+
const teamId = options.workspace.trim();
|
|
163
|
+
if (teamId === "") {
|
|
164
|
+
throw new Error(
|
|
165
|
+
"Pass --workspace with a workspace id from `deepline org workspaces list`. The default workspace has every org member already."
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
printMapping(
|
|
169
|
+
"SCIM group mapped",
|
|
170
|
+
await http2().put(
|
|
171
|
+
`${groupPath(groupId)}/workspace`,
|
|
172
|
+
{
|
|
173
|
+
team_id: teamId
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
options.json
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
groups.command("unmap <group-id>").description(
|
|
181
|
+
"Unmap a SCIM group. Members leave the workspace unless added manually or by another mapped group."
|
|
182
|
+
).option("--json", "Emit JSON output").action(async (groupId, options) => {
|
|
183
|
+
printMapping(
|
|
184
|
+
"SCIM group unmapped",
|
|
185
|
+
await http2().delete(
|
|
186
|
+
`${groupPath(groupId)}/workspace`
|
|
187
|
+
),
|
|
188
|
+
options.json
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/cli/commands/team-move.ts
|
|
194
|
+
var MOVE_KINDS = [
|
|
195
|
+
"play",
|
|
196
|
+
"view",
|
|
197
|
+
"workflow",
|
|
198
|
+
"monitor",
|
|
199
|
+
"fleet",
|
|
200
|
+
"cloud_job",
|
|
201
|
+
"secret"
|
|
202
|
+
];
|
|
203
|
+
function teamLabel(teamId) {
|
|
204
|
+
return teamId === null ? "the default workspace" : `workspace ${teamId}`;
|
|
205
|
+
}
|
|
206
|
+
function printMove(payload, json) {
|
|
207
|
+
const counts = Object.entries(payload.moved).filter(([, count]) => count > 0).map(([name, count]) => `${name.replaceAll("_", " ")}: ${count}`);
|
|
208
|
+
const lines = payload.move_id === null ? [
|
|
209
|
+
`${payload.kind} ${payload.id} is already in ${teamLabel(payload.to_team_id)}.`
|
|
210
|
+
] : [
|
|
211
|
+
`${payload.kind} ${payload.id}: ${teamLabel(payload.from_team_id)} -> ${teamLabel(payload.to_team_id)}`,
|
|
212
|
+
payload.status === "done" ? "Done." : `Moving${payload.stage ? ` (${payload.stage.replaceAll("_", " ")})` : ""}. Check with: deepline org workspaces move-status ${payload.move_id}`,
|
|
213
|
+
...counts.length > 0 ? [`Moved so far: ${counts.join(", ")}`] : [],
|
|
214
|
+
`Move id: ${payload.move_id}`
|
|
215
|
+
];
|
|
216
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
217
|
+
{
|
|
218
|
+
...payload,
|
|
219
|
+
render: {
|
|
220
|
+
sections: [
|
|
221
|
+
{ title: "Workspace move", lines: [...lines, payload.note] }
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{ json }
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function parseMoveTarget(value) {
|
|
229
|
+
const trimmed = value.trim();
|
|
230
|
+
if (trimmed === "") {
|
|
231
|
+
throw new Error(
|
|
232
|
+
"Pass --to <workspace-id>, or --to default for the default workspace."
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
return trimmed === "default" ? null : trimmed;
|
|
236
|
+
}
|
|
237
|
+
function registerTeamMoveCommands(teams) {
|
|
238
|
+
teams.command("move <kind> <id>").description(
|
|
239
|
+
"Move a Play, view, workflow, monitor, Fleet, cloud job, or secret to another workspace."
|
|
240
|
+
).requiredOption(
|
|
241
|
+
"--to <workspace-id>",
|
|
242
|
+
'The workspace to move it to, or "default" for the default workspace'
|
|
243
|
+
).option(
|
|
244
|
+
"--with-views",
|
|
245
|
+
"Move a Play's views with it (a view must use a Play in its own workspace)"
|
|
246
|
+
).option("--json", "Emit JSON output").addHelpText(
|
|
247
|
+
"after",
|
|
248
|
+
`
|
|
249
|
+
Kinds and ids:
|
|
250
|
+
play the Play's name
|
|
251
|
+
view the view id
|
|
252
|
+
workflow the workflow id or name
|
|
253
|
+
monitor the monitor key (a Fleet member moves with its Fleet)
|
|
254
|
+
fleet the Fleet id
|
|
255
|
+
cloud_job the cloud job id
|
|
256
|
+
secret an org secret's id (a Play's own secrets move with the Play)
|
|
257
|
+
|
|
258
|
+
Notes:
|
|
259
|
+
Org owners and admins only. The resource is in the new workspace when this
|
|
260
|
+
returns. A Play's runs and run summaries, a workflow's runs, and a Fleet's
|
|
261
|
+
members follow in batches: status "moving" until they finish. Running the
|
|
262
|
+
same move again is safe; it resumes it or reports it done. Moving to the
|
|
263
|
+
workspace it is already in does nothing.
|
|
264
|
+
A move that would split related work is refused with the reason, for
|
|
265
|
+
example a view whose Play stays in another workspace.
|
|
266
|
+
Customer DB data (workspace schemas) does not move.
|
|
267
|
+
|
|
268
|
+
Examples:
|
|
269
|
+
deepline org workspaces move play lead-enrichment --to <workspace-id>
|
|
270
|
+
deepline org workspaces move play lead-enrichment --to <workspace-id> --with-views
|
|
271
|
+
deepline org workspaces move fleet fleet_abc --to default
|
|
272
|
+
deepline org workspaces move-status <move-id>
|
|
273
|
+
`
|
|
274
|
+
).action(
|
|
275
|
+
async (kind, id, options) => {
|
|
276
|
+
if (!MOVE_KINDS.includes(kind)) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
`Unknown kind "${kind}". Use one of: ${MOVE_KINDS.join(", ")}.`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const payload = await new (0, _chunkVIUUTEHYjs.HttpClient)(
|
|
282
|
+
_chunkVIUUTEHYjs.resolveConfig.call(void 0, )
|
|
283
|
+
).post("/api/v2/teams/move", {
|
|
284
|
+
kind,
|
|
285
|
+
id,
|
|
286
|
+
to_team_id: parseMoveTarget(options.to),
|
|
287
|
+
...options.withViews ? { with_views: true } : {}
|
|
288
|
+
});
|
|
289
|
+
printMove(payload, options.json);
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
teams.command("move-status <move-id>").description("Show the progress of a workspace move.").option("--json", "Emit JSON output").addHelpText(
|
|
293
|
+
"after",
|
|
294
|
+
`
|
|
295
|
+
Examples:
|
|
296
|
+
deepline org workspaces move-status <move-id>
|
|
297
|
+
deepline org workspaces move-status <move-id> --json
|
|
298
|
+
`
|
|
299
|
+
).action(async (moveId, options) => {
|
|
300
|
+
printMove(
|
|
301
|
+
await new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, )).get(
|
|
302
|
+
`/api/v2/teams/move/${encodeURIComponent(moveId)}`
|
|
303
|
+
),
|
|
304
|
+
options.json
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/cli/commands/workspace-integrations.ts
|
|
310
|
+
|
|
311
|
+
var http = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
312
|
+
function requireArgument(value, label) {
|
|
313
|
+
const trimmed = value.trim();
|
|
314
|
+
if (!trimmed) throw new Error(`Pass a ${label}.`);
|
|
315
|
+
return trimmed;
|
|
316
|
+
}
|
|
317
|
+
function sourceLabel(row) {
|
|
318
|
+
if (row.overridden) return "overridden";
|
|
319
|
+
return row.org_configured ? "inherited" : "not connected";
|
|
320
|
+
}
|
|
321
|
+
function readApiKey(options) {
|
|
322
|
+
const sources = [
|
|
323
|
+
options.apiKey !== void 0,
|
|
324
|
+
options.apiKeyFile !== void 0,
|
|
325
|
+
options.apiKeyStdin === true
|
|
326
|
+
].filter(Boolean).length;
|
|
327
|
+
if (sources > 1) {
|
|
328
|
+
throw new Error(
|
|
329
|
+
"Choose one of --api-key, --api-key-file, or --api-key-stdin."
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const raw = _nullishCoalesce(options.apiKey, () => ( (options.apiKeyFile !== void 0 ? _fs.readFileSync.call(void 0, options.apiKeyFile, "utf8") : options.apiKeyStdin ? _fs.readFileSync.call(void 0, 0, "utf8") : void 0)));
|
|
333
|
+
if (raw === void 0) return void 0;
|
|
334
|
+
const trimmed = raw.trim();
|
|
335
|
+
if (!trimmed) throw new Error("The API key is empty.");
|
|
336
|
+
return trimmed;
|
|
337
|
+
}
|
|
338
|
+
function registerWorkspaceIntegrationCommands(workspaces) {
|
|
339
|
+
const integrations = workspaces.command("integrations").description(
|
|
340
|
+
"Show and manage a workspace's integration overrides. Without one, a workspace uses the org's integration."
|
|
341
|
+
);
|
|
342
|
+
integrations.command("list <workspace-id>").description(
|
|
343
|
+
"List each connected integration in a workspace as inherited from the org or overridden."
|
|
344
|
+
).option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
345
|
+
const id = requireArgument(teamId, "workspace id");
|
|
346
|
+
const payload = await http().get(
|
|
347
|
+
`/api/v2/integrations/overrides?team_id=${encodeURIComponent(id)}`
|
|
348
|
+
);
|
|
349
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
350
|
+
{
|
|
351
|
+
...payload,
|
|
352
|
+
render: {
|
|
353
|
+
sections: [
|
|
354
|
+
{
|
|
355
|
+
title: `Integrations in ${id}`,
|
|
356
|
+
lines: payload.integrations.length === 0 ? [
|
|
357
|
+
"No integrations are connected in the org or this workspace."
|
|
358
|
+
] : payload.integrations.map(
|
|
359
|
+
(row) => `${row.provider} ${sourceLabel(row)}`
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{ json: options.json }
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
integrations.command("set <workspace-id> <provider>").description(
|
|
369
|
+
"Override a provider in one workspace with the workspace's own API key (owners and admins). For an OAuth provider, omit the key and open the printed URL. For meta_audiences, pass a Meta system user token as the key."
|
|
370
|
+
).option("--api-key <key>", "The workspace\u2019s API key for this provider").option("--api-key-file <path>", "Read the API key from a file").option("--api-key-stdin", "Read the API key from standard input").option("--json", "Emit JSON output").action(
|
|
371
|
+
async (teamId, provider, options) => {
|
|
372
|
+
const id = requireArgument(teamId, "workspace id");
|
|
373
|
+
const name = requireArgument(provider, "provider");
|
|
374
|
+
const apiKey = readApiKey(options);
|
|
375
|
+
const payload = name === "meta_audiences" && apiKey !== void 0 ? await http().post(
|
|
376
|
+
"/api/v2/integrations/meta_audiences/token",
|
|
377
|
+
{ access_token: apiKey, team_id: id }
|
|
378
|
+
) : await http().post(
|
|
379
|
+
"/api/v2/integrations/connect",
|
|
380
|
+
{
|
|
381
|
+
provider: name,
|
|
382
|
+
team_id: id,
|
|
383
|
+
...apiKey === void 0 ? {} : { api_key: apiKey }
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
387
|
+
{
|
|
388
|
+
provider: name,
|
|
389
|
+
team_id: id,
|
|
390
|
+
...payload,
|
|
391
|
+
render: {
|
|
392
|
+
sections: [
|
|
393
|
+
{
|
|
394
|
+
title: "Workspace override",
|
|
395
|
+
lines: payload.redirect_url ? [
|
|
396
|
+
`Open this URL to connect ${name} for workspace ${id}:`,
|
|
397
|
+
payload.redirect_url
|
|
398
|
+
] : [`Workspace ${id} now uses its own ${name} connection.`]
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{ json: options.json }
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
);
|
|
407
|
+
integrations.command("test <workspace-id> <provider>").description(
|
|
408
|
+
"Test a provider exactly as the workspace resolves it: its override, else the org\u2019s (owners and admins)."
|
|
409
|
+
).option("--json", "Emit JSON output").action(
|
|
410
|
+
async (teamId, provider, options) => {
|
|
411
|
+
const id = requireArgument(teamId, "workspace id");
|
|
412
|
+
const name = requireArgument(provider, "provider");
|
|
413
|
+
const payload = await http().post(
|
|
414
|
+
"/api/v2/integrations/test",
|
|
415
|
+
{ provider: name, team_id: id }
|
|
416
|
+
);
|
|
417
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
418
|
+
{
|
|
419
|
+
provider: name,
|
|
420
|
+
team_id: id,
|
|
421
|
+
result: payload,
|
|
422
|
+
render: {
|
|
423
|
+
sections: [
|
|
424
|
+
{
|
|
425
|
+
title: "Integration test",
|
|
426
|
+
lines: [`${name} works in workspace ${id}.`]
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
{ json: options.json }
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
integrations.command("clear <workspace-id> <provider>").description(
|
|
436
|
+
"Clear a workspace's override of a provider so it uses the org's again (owners and admins)."
|
|
437
|
+
).option("--json", "Emit JSON output").action(
|
|
438
|
+
async (teamId, provider, options) => {
|
|
439
|
+
const id = requireArgument(teamId, "workspace id");
|
|
440
|
+
const name = requireArgument(provider, "provider");
|
|
441
|
+
const payload = await http().request(
|
|
442
|
+
"/api/v2/integrations/overrides",
|
|
443
|
+
{ method: "DELETE", body: { provider: name, team_id: id } }
|
|
444
|
+
);
|
|
445
|
+
const cleared = payload.cleared.credentials + payload.cleared.configurations + payload.cleared.oauthConnections;
|
|
446
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
447
|
+
{
|
|
448
|
+
...payload,
|
|
449
|
+
render: {
|
|
450
|
+
sections: [
|
|
451
|
+
{
|
|
452
|
+
title: "Workspace override",
|
|
453
|
+
lines: [
|
|
454
|
+
cleared === 0 ? `Workspace ${id} had no ${name} override; it uses the org's.` : `Workspace ${id} now uses the org's ${name} connection.`
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{ json: options.json }
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/cli/commands/org.ts
|
|
467
|
+
function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
|
|
468
|
+
const intent = _crypto.createHash.call(void 0, "sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
|
|
469
|
+
return _path.join.call(void 0, _chunkVIUUTEHYjs.sdkCliStateDirPath.call(void 0, baseUrl), `pending-org-create-${intent}.json`);
|
|
470
|
+
}
|
|
471
|
+
function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
|
|
472
|
+
let value;
|
|
473
|
+
try {
|
|
474
|
+
value = JSON.parse(_fs.readFileSync.call(void 0, path, "utf8"));
|
|
475
|
+
} catch (error) {
|
|
476
|
+
throw new Error(
|
|
477
|
+
`Cannot resume the pending org creation recorded at ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (typeof value !== "object" || value === null || value.accountId !== accountId || value.sourceOrgId !== sourceOrgId || value.name !== name || typeof value.idempotencyKey !== "string" || !value.idempotencyKey.trim()) {
|
|
481
|
+
throw new Error(
|
|
482
|
+
`Cannot resume the pending org creation recorded at ${path}: the saved intent is invalid.`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
return value;
|
|
486
|
+
}
|
|
487
|
+
function loadOrCreatePendingOrgCreate(input) {
|
|
488
|
+
const stateDir = _chunkVIUUTEHYjs.sdkCliStateDirPath.call(void 0, input.baseUrl);
|
|
489
|
+
const path = pendingOrgCreatePath(
|
|
490
|
+
input.baseUrl,
|
|
491
|
+
input.accountId,
|
|
492
|
+
input.sourceOrgId,
|
|
493
|
+
input.name
|
|
494
|
+
);
|
|
495
|
+
_fs.mkdirSync.call(void 0, stateDir, { recursive: true });
|
|
496
|
+
if (_fs.existsSync.call(void 0, path)) {
|
|
497
|
+
return {
|
|
498
|
+
...readPendingOrgCreate(
|
|
499
|
+
path,
|
|
500
|
+
input.accountId,
|
|
501
|
+
input.sourceOrgId,
|
|
502
|
+
input.name
|
|
503
|
+
),
|
|
504
|
+
path
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
const pending = {
|
|
508
|
+
accountId: input.accountId,
|
|
509
|
+
sourceOrgId: input.sourceOrgId,
|
|
510
|
+
name: input.name,
|
|
511
|
+
idempotencyKey: _crypto.randomUUID.call(void 0, )
|
|
512
|
+
};
|
|
513
|
+
try {
|
|
514
|
+
_fs.writeFileSync.call(void 0, path, `${JSON.stringify(pending)}
|
|
515
|
+
`, {
|
|
516
|
+
encoding: "utf8",
|
|
517
|
+
flag: "wx",
|
|
518
|
+
mode: 384
|
|
519
|
+
});
|
|
520
|
+
return { ...pending, path };
|
|
521
|
+
} catch (error) {
|
|
522
|
+
if (error.code !== "EEXIST") throw error;
|
|
523
|
+
return {
|
|
524
|
+
...readPendingOrgCreate(
|
|
525
|
+
path,
|
|
526
|
+
input.accountId,
|
|
527
|
+
input.sourceOrgId,
|
|
528
|
+
input.name
|
|
529
|
+
),
|
|
530
|
+
path
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async function fetchWorkspaceCreationIdentity(http2, apiKey) {
|
|
535
|
+
const status = await http2.post("/api/v2/auth/cli/status", { api_key: apiKey });
|
|
536
|
+
const accountId = _optionalChain([status, 'access', _ => _.user_id, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]);
|
|
537
|
+
if (!accountId) {
|
|
538
|
+
throw new Error(
|
|
539
|
+
"Org creation requires an API key linked to a user account."
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
return { accountId, orgId: _optionalChain([status, 'access', _4 => _4.org_id, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]) || null };
|
|
543
|
+
}
|
|
544
|
+
async function fetchOrganizations(http2, apiKey) {
|
|
545
|
+
return http2.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
|
|
546
|
+
}
|
|
547
|
+
function normalizeAuthScope(value) {
|
|
548
|
+
if (!value) return "auto";
|
|
549
|
+
if (value === "auto" || value === "folder" || value === "global") {
|
|
550
|
+
return value;
|
|
551
|
+
}
|
|
552
|
+
throw new Error(
|
|
553
|
+
`Invalid --auth-scope "${value}". Expected one of: auto, folder, global.`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
function orgListLines(orgs) {
|
|
557
|
+
return orgs.flatMap((org, index) => {
|
|
558
|
+
const current = org.is_current ? " (current)" : "";
|
|
559
|
+
const role = org.role ? ` [${org.role}]` : "";
|
|
560
|
+
const workspaces = (_nullishCoalesce(org.workspaces, () => ( []))).map((workspace) => {
|
|
561
|
+
const id = _nullishCoalesce(workspace.team_id, () => ( "default"));
|
|
562
|
+
const marker = workspace.is_current ? " (current)" : "";
|
|
563
|
+
return ` - ${workspace.name} [${id}]${marker}`;
|
|
564
|
+
});
|
|
565
|
+
return [`${index + 1}. ${org.name}${role}${current}`, ...workspaces];
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
function redactApiKey(value) {
|
|
569
|
+
if (!value) return null;
|
|
570
|
+
if (value.length <= 10) return `${value.slice(0, 3)}...`;
|
|
571
|
+
return `${value.slice(0, 8)}...${value.slice(-4)}`;
|
|
572
|
+
}
|
|
573
|
+
function processEnvValue(name) {
|
|
574
|
+
return _nullishCoalesce(_optionalChain([process, 'access', _7 => _7.env, 'access', _8 => _8[name], 'optionalAccess', _9 => _9.trim, 'call', _10 => _10()]), () => ( ""));
|
|
575
|
+
}
|
|
576
|
+
function organizationAuthValues(input) {
|
|
577
|
+
return {
|
|
578
|
+
[_chunkVIUUTEHYjs.HOST_URL_ENV]: input.baseUrl,
|
|
579
|
+
[_chunkVIUUTEHYjs.API_KEY_ENV]: input.apiKey,
|
|
580
|
+
[_chunkVIUUTEHYjs.ACTIVE_ORG_ID_ENV]: input.orgId,
|
|
581
|
+
[_chunkVIUUTEHYjs.ACTIVE_ORG_NAME_ENV]: input.orgName,
|
|
582
|
+
..._chunkVIUUTEHYjs.featureEnvValues.call(void 0, input)
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function organizationCommandContext(input) {
|
|
586
|
+
return {
|
|
587
|
+
active_organization: {
|
|
588
|
+
org_id: input.orgId,
|
|
589
|
+
org_name: input.orgName
|
|
590
|
+
},
|
|
591
|
+
auth_scope: input.authScope,
|
|
592
|
+
metadata_source: input.authScope === "folder" ? "folder_env" : "host_env"
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
function agentCommandContext(commandContext) {
|
|
596
|
+
return _chunk5CYZHOKIjs.detectAgentRuntime.call(void 0, ) !== "unknown" ? { command_context: commandContext } : {};
|
|
597
|
+
}
|
|
598
|
+
function resolveOrgSwitchAuthTarget(scope, config) {
|
|
599
|
+
const activeProject = _chunkVIUUTEHYjs.getResolvedProjectAuthSource.call(void 0,
|
|
600
|
+
config.baseUrl,
|
|
601
|
+
config.apiKey
|
|
602
|
+
);
|
|
603
|
+
const folderTarget = _chunkVIUUTEHYjs.resolveProjectPinTarget.call(void 0, );
|
|
604
|
+
const globalOverrideWarning = activeProject && scope === "global" ? [
|
|
605
|
+
`Folder auth in ${activeProject.filePath} overrides global auth for commands run here.`
|
|
606
|
+
] : [];
|
|
607
|
+
if (scope === "folder") {
|
|
608
|
+
if (!folderTarget.ok) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
`Cowork project folder is ambiguous. Candidate folders: ${folderTarget.candidates.join(
|
|
611
|
+
", "
|
|
612
|
+
)}. Set CLAUDE_PROJECT_DIR or cd into the intended project folder before running this command.`
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
return {
|
|
616
|
+
kind: "folder",
|
|
617
|
+
requested_scope: scope,
|
|
618
|
+
effective_scope: "folder",
|
|
619
|
+
reason: "explicit_folder",
|
|
620
|
+
source: folderTarget.source,
|
|
621
|
+
warnings: []
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
if (scope === "global") {
|
|
625
|
+
return {
|
|
626
|
+
kind: "global",
|
|
627
|
+
requested_scope: scope,
|
|
628
|
+
effective_scope: "global",
|
|
629
|
+
reason: "explicit_global",
|
|
630
|
+
warnings: globalOverrideWarning
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
if (activeProject) {
|
|
634
|
+
return {
|
|
635
|
+
kind: "folder",
|
|
636
|
+
requested_scope: scope,
|
|
637
|
+
effective_scope: "folder",
|
|
638
|
+
reason: "existing_folder_auth",
|
|
639
|
+
source: activeProject.source,
|
|
640
|
+
warnings: []
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
if (folderTarget.ok && folderTarget.source === "cowork") {
|
|
644
|
+
return {
|
|
645
|
+
kind: "folder",
|
|
646
|
+
requested_scope: scope,
|
|
647
|
+
effective_scope: "folder",
|
|
648
|
+
reason: "detected_cowork_project",
|
|
649
|
+
source: "cowork",
|
|
650
|
+
warnings: []
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
if (!folderTarget.ok) {
|
|
654
|
+
return {
|
|
655
|
+
kind: "global",
|
|
656
|
+
requested_scope: scope,
|
|
657
|
+
effective_scope: "global",
|
|
658
|
+
reason: "ambiguous_cowork_fell_back_global",
|
|
659
|
+
warnings: [
|
|
660
|
+
`Cowork project folder is ambiguous, so global auth was updated. Candidate folders: ${folderTarget.candidates.join(
|
|
661
|
+
", "
|
|
662
|
+
)}. Set CLAUDE_PROJECT_DIR or cd into the intended project folder to update folder auth.`
|
|
663
|
+
]
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
kind: "global",
|
|
668
|
+
requested_scope: scope,
|
|
669
|
+
effective_scope: "global",
|
|
670
|
+
reason: "default_global",
|
|
671
|
+
warnings: []
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
async function handleOrgList(options) {
|
|
675
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
676
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
677
|
+
const payload = await fetchOrganizations(http2, config.apiKey);
|
|
678
|
+
let organizations = payload.organizations;
|
|
679
|
+
if (options.workspaces) {
|
|
680
|
+
const directory = await http2.get(
|
|
681
|
+
"/api/v2/auth/workspace/directory"
|
|
682
|
+
);
|
|
683
|
+
const byOrg = new Map(
|
|
684
|
+
directory.organizations.map((org) => [org.org_id, org.workspaces])
|
|
685
|
+
);
|
|
686
|
+
organizations = payload.organizations.map((org) => ({
|
|
687
|
+
...org,
|
|
688
|
+
workspaces: _nullishCoalesce(byOrg.get(org.org_id), () => ( []))
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
692
|
+
{
|
|
693
|
+
...payload,
|
|
694
|
+
organizations,
|
|
695
|
+
render: {
|
|
696
|
+
sections: [
|
|
697
|
+
{
|
|
698
|
+
title: "Your organizations:",
|
|
699
|
+
lines: orgListLines(organizations)
|
|
700
|
+
}
|
|
701
|
+
]
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{ json: options.json }
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
async function handleOrgStatus(options) {
|
|
708
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
709
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
710
|
+
const payload = await fetchOrganizations(http2, config.apiKey);
|
|
711
|
+
const current = _nullishCoalesce(_nullishCoalesce(payload.organizations.find((org) => org.is_current), () => ( payload.organizations.find(
|
|
712
|
+
(org) => org.org_id === payload.current_org_id
|
|
713
|
+
))), () => ( null));
|
|
714
|
+
const projectCandidate = _chunkVIUUTEHYjs.getActiveProjectAuthSource.call(void 0, );
|
|
715
|
+
const activeProject = _chunkVIUUTEHYjs.getResolvedProjectAuthSource.call(void 0,
|
|
716
|
+
config.baseUrl,
|
|
717
|
+
config.apiKey
|
|
718
|
+
);
|
|
719
|
+
const folderTarget = _chunkVIUUTEHYjs.resolveProjectPinTarget.call(void 0, );
|
|
720
|
+
const provenance = _chunkVIUUTEHYjs.resolveCliAuthProvenance.call(void 0, config);
|
|
721
|
+
const hostPath = _chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl);
|
|
722
|
+
const envApiKey = processEnvValue(_chunkVIUUTEHYjs.API_KEY_ENV);
|
|
723
|
+
const envHostUrl = processEnvValue(_chunkVIUUTEHYjs.HOST_URL_ENV);
|
|
724
|
+
const authSource = envApiKey ? {
|
|
725
|
+
scope: "env",
|
|
726
|
+
source: "process",
|
|
727
|
+
path: null,
|
|
728
|
+
api_key: redactApiKey(envApiKey),
|
|
729
|
+
host: envHostUrl || null,
|
|
730
|
+
overrides_global: true,
|
|
731
|
+
overrides_folder: Boolean(projectCandidate)
|
|
732
|
+
} : activeProject ? {
|
|
733
|
+
scope: "folder",
|
|
734
|
+
source: activeProject.source,
|
|
735
|
+
path: activeProject.filePath,
|
|
736
|
+
api_key: redactApiKey(activeProject.env.DEEPLINE_API_KEY),
|
|
737
|
+
overrides_global: true
|
|
738
|
+
} : {
|
|
739
|
+
scope: "global",
|
|
740
|
+
source: "host",
|
|
741
|
+
path: hostPath,
|
|
742
|
+
api_key: redactApiKey(config.apiKey),
|
|
743
|
+
overrides_global: false
|
|
744
|
+
};
|
|
745
|
+
const folderTargetPayload = folderTarget.ok ? {
|
|
746
|
+
ok: true,
|
|
747
|
+
source: folderTarget.source,
|
|
748
|
+
dir: folderTarget.dir,
|
|
749
|
+
env_path: `${folderTarget.dir}/.env.deepline`
|
|
750
|
+
} : {
|
|
751
|
+
ok: false,
|
|
752
|
+
reason: folderTarget.reason,
|
|
753
|
+
candidates: folderTarget.candidates
|
|
754
|
+
};
|
|
755
|
+
const lines = [
|
|
756
|
+
`Organization: ${_nullishCoalesce(_optionalChain([current, 'optionalAccess', _11 => _11.name]), () => ( "(unknown)"))}`,
|
|
757
|
+
`Organization ID: ${_nullishCoalesce(payload.current_org_id, () => ( "(unknown)"))}`,
|
|
758
|
+
`Host: ${config.baseUrl}`,
|
|
759
|
+
`Auth scope: ${authSource.scope}`
|
|
760
|
+
];
|
|
761
|
+
if (authSource.path) {
|
|
762
|
+
lines.push(`Auth file: ${authSource.path}`);
|
|
763
|
+
} else {
|
|
764
|
+
lines.push(`Auth source: ${_chunkVIUUTEHYjs.API_KEY_ENV} process environment`);
|
|
765
|
+
}
|
|
766
|
+
if (envApiKey) {
|
|
767
|
+
lines.push(`${_chunkVIUUTEHYjs.API_KEY_ENV} overrides saved auth for this process.`);
|
|
768
|
+
} else if (activeProject) {
|
|
769
|
+
lines.push("Global auth is overridden in this folder.");
|
|
770
|
+
} else if (provenance.scope === "global" && provenance.project.state === "project") {
|
|
771
|
+
lines.push("Cloud mutations are blocked until this project is pinned.");
|
|
772
|
+
lines.push("Pin it: deepline org set --auth-scope folder");
|
|
773
|
+
}
|
|
774
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
775
|
+
{
|
|
776
|
+
ok: true,
|
|
777
|
+
host: config.baseUrl,
|
|
778
|
+
organization: current,
|
|
779
|
+
current_org_id: payload.current_org_id,
|
|
780
|
+
auth_source: authSource,
|
|
781
|
+
host_env_path: hostPath,
|
|
782
|
+
folder_target: folderTargetPayload,
|
|
783
|
+
project_pin: provenance.scope === "global" && provenance.project.state === "project" ? {
|
|
784
|
+
available: true,
|
|
785
|
+
required: false,
|
|
786
|
+
path: provenance.project.pinPath,
|
|
787
|
+
cloud_mutations_blocked: false,
|
|
788
|
+
command: "deepline org set --auth-scope folder"
|
|
789
|
+
} : {
|
|
790
|
+
available: false,
|
|
791
|
+
required: false,
|
|
792
|
+
cloud_mutations_blocked: false
|
|
793
|
+
},
|
|
794
|
+
next: {
|
|
795
|
+
set_auto: "deepline org set <org>",
|
|
796
|
+
set_folder: "deepline org set <org> --auth-scope folder",
|
|
797
|
+
set_global: "deepline org set <org> --auth-scope global"
|
|
798
|
+
},
|
|
799
|
+
render: {
|
|
800
|
+
sections: [{ title: "org status", lines }]
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
{ json: options.json }
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
async function handleOrgSwitch(selection, options) {
|
|
807
|
+
const authScope = normalizeAuthScope(options.authScope);
|
|
808
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
809
|
+
const provenance = _chunkVIUUTEHYjs.resolveCliAuthProvenance.call(void 0, config);
|
|
810
|
+
if (!selection && !options.orgId && authScope === "folder" && provenance.scope === "global" && provenance.project.state === "project") {
|
|
811
|
+
const commandContext = _chunkVIUUTEHYjs.resolveCliCommandContext.call(void 0, config);
|
|
812
|
+
const activeOrganization = commandContext.active_organization;
|
|
813
|
+
const pinnedFeatures = _chunkVIUUTEHYjs.storedHostFeatures.call(void 0, config.baseUrl);
|
|
814
|
+
const project_env_paths2 = _chunkVIUUTEHYjs.saveProjectDeeplineEnvValues.call(void 0,
|
|
815
|
+
{
|
|
816
|
+
[_chunkVIUUTEHYjs.HOST_URL_ENV]: config.baseUrl,
|
|
817
|
+
[_chunkVIUUTEHYjs.API_KEY_ENV]: config.apiKey,
|
|
818
|
+
...activeOrganization ? {
|
|
819
|
+
[_chunkVIUUTEHYjs.ACTIVE_ORG_ID_ENV]: activeOrganization.org_id,
|
|
820
|
+
[_chunkVIUUTEHYjs.ACTIVE_ORG_NAME_ENV]: _nullishCoalesce(activeOrganization.org_name, () => ( ""))
|
|
821
|
+
} : {},
|
|
822
|
+
...pinnedFeatures !== void 0 ? { [_chunkVIUUTEHYjs.FEATURES_ENV]: pinnedFeatures } : {}
|
|
823
|
+
},
|
|
824
|
+
provenance.project.dir
|
|
825
|
+
);
|
|
826
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
827
|
+
{
|
|
828
|
+
ok: true,
|
|
829
|
+
unchanged: true,
|
|
830
|
+
requested_auth_scope: "folder",
|
|
831
|
+
effective_auth_scope: "folder",
|
|
832
|
+
auth_scope: "folder",
|
|
833
|
+
...agentCommandContext(
|
|
834
|
+
activeOrganization ? organizationCommandContext({
|
|
835
|
+
orgId: activeOrganization.org_id,
|
|
836
|
+
orgName: activeOrganization.org_name,
|
|
837
|
+
authScope: "folder"
|
|
838
|
+
}) : _chunkVIUUTEHYjs.resolveCliCommandContext.call(void 0, config, "folder")
|
|
839
|
+
),
|
|
840
|
+
project_env_paths: project_env_paths2,
|
|
841
|
+
next: { status: "deepline org status" },
|
|
842
|
+
render: {
|
|
843
|
+
sections: [
|
|
844
|
+
{
|
|
845
|
+
title: "org set",
|
|
846
|
+
lines: [
|
|
847
|
+
"\u2713 Pinned this project to the current target.",
|
|
848
|
+
`Saved folder auth in ${project_env_paths2[0]}.`,
|
|
849
|
+
"Global host auth was not changed."
|
|
850
|
+
]
|
|
851
|
+
}
|
|
852
|
+
]
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
{ json: options.json }
|
|
856
|
+
);
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
860
|
+
const payload = await fetchOrganizations(http2, config.apiKey);
|
|
861
|
+
if (!selection && !options.orgId) {
|
|
862
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
863
|
+
{
|
|
864
|
+
...payload,
|
|
865
|
+
next: { set: "deepline org set <number>" },
|
|
866
|
+
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
867
|
+
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
868
|
+
warnings: options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
869
|
+
render: {
|
|
870
|
+
sections: [
|
|
871
|
+
{
|
|
872
|
+
title: "Your organizations:",
|
|
873
|
+
lines: orgListLines(payload.organizations)
|
|
874
|
+
}
|
|
875
|
+
],
|
|
876
|
+
actions: [{ label: "Run", command: "deepline org set <number>" }]
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
{ json: options.json }
|
|
880
|
+
);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
let target = payload.organizations.find(
|
|
884
|
+
(org) => org.org_id === options.orgId
|
|
885
|
+
);
|
|
886
|
+
if (!target && selection) {
|
|
887
|
+
const index = Number.parseInt(selection, 10);
|
|
888
|
+
if (Number.isFinite(index) && index >= 1 && index <= payload.organizations.length) {
|
|
889
|
+
target = payload.organizations[index - 1];
|
|
890
|
+
} else {
|
|
891
|
+
target = payload.organizations.find(
|
|
892
|
+
(org) => org.name === selection || org.org_id === selection
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (!target) {
|
|
897
|
+
throw new Error("Could not resolve the selected organization.");
|
|
898
|
+
}
|
|
899
|
+
const authTarget = resolveOrgSwitchAuthTarget(authScope, config);
|
|
900
|
+
if (target.is_current) {
|
|
901
|
+
let project_env_paths2 = [];
|
|
902
|
+
const features = await http2.post("/api/v2/auth/cli/status", {
|
|
903
|
+
api_key: config.apiKey
|
|
904
|
+
}).then((status) => status.features).catch(() => void 0);
|
|
905
|
+
const authValues2 = organizationAuthValues({
|
|
906
|
+
baseUrl: config.baseUrl,
|
|
907
|
+
apiKey: config.apiKey,
|
|
908
|
+
orgId: target.org_id,
|
|
909
|
+
orgName: target.name,
|
|
910
|
+
features
|
|
911
|
+
});
|
|
912
|
+
if (authTarget.kind === "folder") {
|
|
913
|
+
project_env_paths2 = _chunkVIUUTEHYjs.saveProjectDeeplineEnvValues.call(void 0, authValues2);
|
|
914
|
+
} else {
|
|
915
|
+
_chunkVIUUTEHYjs.saveHostEnvValues.call(void 0, config.baseUrl, authValues2);
|
|
916
|
+
}
|
|
917
|
+
const renderLines2 = [`Already on ${target.name}.`];
|
|
918
|
+
for (const projectPath of project_env_paths2) {
|
|
919
|
+
renderLines2.push(`Saved folder auth in ${projectPath}`);
|
|
920
|
+
}
|
|
921
|
+
if (authTarget.kind === "global") {
|
|
922
|
+
renderLines2.push(
|
|
923
|
+
`Saved global auth in ${_chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl)}`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
renderLines2.push(
|
|
927
|
+
`Scope: ${authTarget.requested_scope} -> ${authTarget.effective_scope} (${authTarget.reason})`
|
|
928
|
+
);
|
|
929
|
+
if (options.deprecatedSwitch) {
|
|
930
|
+
renderLines2.push("Warning: org switch is deprecated; use org set.");
|
|
931
|
+
}
|
|
932
|
+
for (const warning of authTarget.warnings) {
|
|
933
|
+
renderLines2.push(`Warning: ${warning}`);
|
|
934
|
+
}
|
|
935
|
+
const warnings2 = [
|
|
936
|
+
...options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
937
|
+
...authTarget.warnings
|
|
938
|
+
];
|
|
939
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
940
|
+
{
|
|
941
|
+
ok: true,
|
|
942
|
+
unchanged: true,
|
|
943
|
+
organization: target,
|
|
944
|
+
requested_auth_scope: authTarget.requested_scope,
|
|
945
|
+
effective_auth_scope: authTarget.effective_scope,
|
|
946
|
+
auth_scope_reason: authTarget.reason,
|
|
947
|
+
auth_scope: authTarget.effective_scope,
|
|
948
|
+
...agentCommandContext(
|
|
949
|
+
organizationCommandContext({
|
|
950
|
+
orgId: target.org_id,
|
|
951
|
+
orgName: target.name,
|
|
952
|
+
authScope: authTarget.effective_scope
|
|
953
|
+
})
|
|
954
|
+
),
|
|
955
|
+
host_env_path: authTarget.kind === "global" ? _chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl) : null,
|
|
956
|
+
project_env_paths: project_env_paths2,
|
|
957
|
+
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
958
|
+
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
959
|
+
warnings: warnings2,
|
|
960
|
+
render: {
|
|
961
|
+
sections: [{ title: "org set", lines: renderLines2 }]
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
{ json: options.json }
|
|
965
|
+
);
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
const switched = await http2.post("/api/v2/auth/cli/switch", {
|
|
969
|
+
api_key: config.apiKey,
|
|
970
|
+
org_id: target.org_id
|
|
971
|
+
});
|
|
972
|
+
let project_env_paths = [];
|
|
973
|
+
const authValues = organizationAuthValues({
|
|
974
|
+
baseUrl: config.baseUrl,
|
|
975
|
+
apiKey: switched.api_key,
|
|
976
|
+
orgId: switched.org_id,
|
|
977
|
+
orgName: switched.org_name,
|
|
978
|
+
features: switched.features
|
|
979
|
+
});
|
|
980
|
+
if (authTarget.kind === "folder") {
|
|
981
|
+
project_env_paths = _chunkVIUUTEHYjs.saveProjectDeeplineEnvValues.call(void 0, authValues);
|
|
982
|
+
} else {
|
|
983
|
+
_chunkVIUUTEHYjs.saveHostEnvValues.call(void 0, config.baseUrl, authValues);
|
|
984
|
+
}
|
|
985
|
+
const { api_key: _apiKey, ...publicSwitched } = switched;
|
|
986
|
+
const renderLines = [`Switched to ${switched.org_name}.`];
|
|
987
|
+
if (authTarget.kind === "folder") {
|
|
988
|
+
for (const projectPath of project_env_paths) {
|
|
989
|
+
renderLines.push(`Saved folder auth in ${projectPath}`);
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
renderLines.push(`Saved global auth in ${_chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl)}`);
|
|
993
|
+
}
|
|
994
|
+
renderLines.push(
|
|
995
|
+
`Scope: ${authTarget.requested_scope} -> ${authTarget.effective_scope} (${authTarget.reason})`
|
|
996
|
+
);
|
|
997
|
+
if (options.deprecatedSwitch) {
|
|
998
|
+
renderLines.push("Warning: org switch is deprecated; use org set.");
|
|
999
|
+
}
|
|
1000
|
+
for (const warning of authTarget.warnings) {
|
|
1001
|
+
renderLines.push(`Warning: ${warning}`);
|
|
1002
|
+
}
|
|
1003
|
+
const warnings = [
|
|
1004
|
+
...options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
1005
|
+
...authTarget.warnings
|
|
1006
|
+
];
|
|
1007
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1008
|
+
{
|
|
1009
|
+
ok: true,
|
|
1010
|
+
host_env_path: authTarget.kind === "global" ? _chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl) : null,
|
|
1011
|
+
project_env_paths,
|
|
1012
|
+
...publicSwitched,
|
|
1013
|
+
api_key_saved: true,
|
|
1014
|
+
requested_auth_scope: authTarget.requested_scope,
|
|
1015
|
+
effective_auth_scope: authTarget.effective_scope,
|
|
1016
|
+
auth_scope_reason: authTarget.reason,
|
|
1017
|
+
auth_scope: authTarget.effective_scope,
|
|
1018
|
+
...agentCommandContext(
|
|
1019
|
+
organizationCommandContext({
|
|
1020
|
+
orgId: switched.org_id,
|
|
1021
|
+
orgName: switched.org_name,
|
|
1022
|
+
authScope: authTarget.effective_scope
|
|
1023
|
+
})
|
|
1024
|
+
),
|
|
1025
|
+
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
1026
|
+
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
1027
|
+
warnings,
|
|
1028
|
+
render: {
|
|
1029
|
+
sections: [
|
|
1030
|
+
{
|
|
1031
|
+
title: "org set",
|
|
1032
|
+
lines: renderLines
|
|
1033
|
+
}
|
|
1034
|
+
]
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
{ json: options.json }
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
async function handleOrgCreate(name, options) {
|
|
1041
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
1042
|
+
const normalizedName = name.trim();
|
|
1043
|
+
if (!normalizedName) {
|
|
1044
|
+
throw new Error("Org name is required.");
|
|
1045
|
+
}
|
|
1046
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
1047
|
+
const identity = await fetchWorkspaceCreationIdentity(http2, config.apiKey);
|
|
1048
|
+
let created;
|
|
1049
|
+
let workspaceApiKey;
|
|
1050
|
+
let workspaceFeatures;
|
|
1051
|
+
let pendingIntentPath = null;
|
|
1052
|
+
if (!identity.orgId) {
|
|
1053
|
+
const firstWorkspace = await http2.post("/api/v2/auth/cli/org-create", {
|
|
1054
|
+
api_key: config.apiKey,
|
|
1055
|
+
name: normalizedName
|
|
1056
|
+
});
|
|
1057
|
+
const {
|
|
1058
|
+
api_key: apiKey,
|
|
1059
|
+
features,
|
|
1060
|
+
...publicFirstWorkspace
|
|
1061
|
+
} = firstWorkspace;
|
|
1062
|
+
workspaceApiKey = apiKey;
|
|
1063
|
+
workspaceFeatures = features;
|
|
1064
|
+
created = publicFirstWorkspace;
|
|
1065
|
+
} else {
|
|
1066
|
+
const pending = loadOrCreatePendingOrgCreate({
|
|
1067
|
+
baseUrl: config.baseUrl,
|
|
1068
|
+
accountId: identity.accountId,
|
|
1069
|
+
sourceOrgId: identity.orgId,
|
|
1070
|
+
name: normalizedName
|
|
1071
|
+
});
|
|
1072
|
+
const workspace = await new (0, _chunkDUBXUAAOjs.DeeplineClient)({
|
|
1073
|
+
apiKey: config.apiKey,
|
|
1074
|
+
baseUrl: config.baseUrl
|
|
1075
|
+
}).workspaces.create({
|
|
1076
|
+
name: normalizedName,
|
|
1077
|
+
idempotencyKey: pending.idempotencyKey
|
|
1078
|
+
});
|
|
1079
|
+
const switched = await http2.post("/api/v2/auth/cli/switch", {
|
|
1080
|
+
api_key: config.apiKey,
|
|
1081
|
+
org_id: workspace.org_id
|
|
1082
|
+
});
|
|
1083
|
+
workspaceApiKey = switched.api_key;
|
|
1084
|
+
workspaceFeatures = switched.features;
|
|
1085
|
+
created = { ...workspace };
|
|
1086
|
+
pendingIntentPath = pending.path;
|
|
1087
|
+
}
|
|
1088
|
+
const authValues = organizationAuthValues({
|
|
1089
|
+
baseUrl: config.baseUrl,
|
|
1090
|
+
apiKey: workspaceApiKey,
|
|
1091
|
+
orgId: created.org_id,
|
|
1092
|
+
orgName: created.org_name,
|
|
1093
|
+
features: workspaceFeatures
|
|
1094
|
+
});
|
|
1095
|
+
_chunkVIUUTEHYjs.saveHostEnvValues.call(void 0, config.baseUrl, authValues);
|
|
1096
|
+
if (pendingIntentPath) _fs.unlinkSync.call(void 0, pendingIntentPath);
|
|
1097
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1098
|
+
{
|
|
1099
|
+
ok: true,
|
|
1100
|
+
...created,
|
|
1101
|
+
initial_credits: typeof created.initial_credits === "number" ? created.initial_credits : 0,
|
|
1102
|
+
api_key_saved: true,
|
|
1103
|
+
switched: true,
|
|
1104
|
+
host_env_path: _chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl),
|
|
1105
|
+
...agentCommandContext(
|
|
1106
|
+
organizationCommandContext({
|
|
1107
|
+
orgId: created.org_id,
|
|
1108
|
+
orgName: created.org_name,
|
|
1109
|
+
authScope: "global"
|
|
1110
|
+
})
|
|
1111
|
+
),
|
|
1112
|
+
render: {
|
|
1113
|
+
sections: [
|
|
1114
|
+
{
|
|
1115
|
+
title: "org create",
|
|
1116
|
+
lines: [
|
|
1117
|
+
`Created organization: ${created.org_name}.`,
|
|
1118
|
+
`Switched to ${created.org_name}.`,
|
|
1119
|
+
`Saved host auth in ${_chunkVIUUTEHYjs.hostEnvFilePath.call(void 0, config.baseUrl)}`
|
|
1120
|
+
]
|
|
1121
|
+
}
|
|
1122
|
+
]
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
{ json: options.json }
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
var TEAMS_HELP_TEXT = `
|
|
1129
|
+
Notes:
|
|
1130
|
+
Every org has a default workspace (no workspace id; every member is in it; rename it
|
|
1131
|
+
with \`deepline org default-workspace\`). Named workspaces hold their own Plays, runs,
|
|
1132
|
+
tables, and monitors. Org owners and admins reach every workspace; other members
|
|
1133
|
+
reach the default workspace and the workspaces they belong to. Anyone in the org can
|
|
1134
|
+
list workspaces and members; creating, renaming, archiving, and changing members
|
|
1135
|
+
needs the owner or admin role.
|
|
1136
|
+
|
|
1137
|
+
Workspace names are 1 to 64 characters, unique in the org (ignoring case), and
|
|
1138
|
+
can't match the default workspace's name. Archiving is refused while the workspace
|
|
1139
|
+
has active schedules (Play triggers, cloud jobs, workflow triggers) or
|
|
1140
|
+
monitors; the refusal lists them. An archived workspace keeps its members and
|
|
1141
|
+
work, can't be chosen with --workspace, and can be restored with \`unarchive\`.
|
|
1142
|
+
|
|
1143
|
+
Integrations are set on the org and every workspace uses them. A named
|
|
1144
|
+
workspace can override one with its own key or account (\`integrations set\`);
|
|
1145
|
+
clearing the override (\`integrations clear\`) returns it to the org's. The
|
|
1146
|
+
default workspace always uses the org's.
|
|
1147
|
+
|
|
1148
|
+
Examples:
|
|
1149
|
+
deepline org workspaces list
|
|
1150
|
+
deepline org workspaces list --archived --json
|
|
1151
|
+
deepline org workspaces create "Growth"
|
|
1152
|
+
deepline org workspaces rename <workspace-id> "Growth EMEA"
|
|
1153
|
+
deepline org workspaces members <workspace-id>
|
|
1154
|
+
deepline org workspaces add-member <workspace-id> jane@example.com
|
|
1155
|
+
deepline org workspaces remove-member <workspace-id> <user-id>
|
|
1156
|
+
deepline org workspaces archive <workspace-id>
|
|
1157
|
+
deepline org workspaces unarchive <workspace-id>
|
|
1158
|
+
deepline org workspaces cap list
|
|
1159
|
+
deepline org workspaces cap set <workspace-id> 500
|
|
1160
|
+
deepline org workspaces cap remove <workspace-id>
|
|
1161
|
+
deepline org workspaces integrations list <workspace-id>
|
|
1162
|
+
deepline org workspaces integrations set <workspace-id> hunter --api-key-stdin
|
|
1163
|
+
deepline org workspaces integrations test <workspace-id> hunter
|
|
1164
|
+
deepline org workspaces integrations clear <workspace-id> hunter
|
|
1165
|
+
`;
|
|
1166
|
+
function describeGrant(member) {
|
|
1167
|
+
const groups = _nullishCoalesce(_optionalChain([member, 'access', _12 => _12.granted_by, 'optionalAccess', _13 => _13.scim_groups]), () => ( []));
|
|
1168
|
+
if (groups.length === 0) return "";
|
|
1169
|
+
const names = groups.map((group) => group.display_name).join(", ");
|
|
1170
|
+
return _optionalChain([member, 'access', _14 => _14.granted_by, 'optionalAccess', _15 => _15.manual]) ? ` (manual and SCIM: ${names})` : ` (SCIM: ${names})`;
|
|
1171
|
+
}
|
|
1172
|
+
function describeTeamCap(cap) {
|
|
1173
|
+
const spend = `${cap.spent_credits} credits spent in the last 30 days`;
|
|
1174
|
+
return cap.enabled && cap.monthly_credits_limit !== null ? `${cap.name} ${cap.team_id} cap ${cap.monthly_credits_limit} credits, ${spend}, ${_nullishCoalesce(cap.remaining_credits, () => ( 0))} remaining` : `${cap.name} ${cap.team_id} no cap, ${spend}`;
|
|
1175
|
+
}
|
|
1176
|
+
function describeOrgCap(orgCap) {
|
|
1177
|
+
return orgCap.enabled && orgCap.monthly_credits_limit !== null ? `Organization cap: ${orgCap.monthly_credits_limit} credits (${orgCap.spent_credits} spent). It still applies to every workspace.` : `Organization cap: none (${orgCap.spent_credits} spent).`;
|
|
1178
|
+
}
|
|
1179
|
+
function parseCapCredits(value) {
|
|
1180
|
+
const credits = Number(value.trim());
|
|
1181
|
+
if (!Number.isInteger(credits) || credits < 1) {
|
|
1182
|
+
throw new Error(
|
|
1183
|
+
"Pass the cap as a whole number of credits, at least 1. Remove a cap with `deepline org workspaces cap remove <workspace-id>`."
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
return credits;
|
|
1187
|
+
}
|
|
1188
|
+
function requireTeamIdArgument(teamId) {
|
|
1189
|
+
const trimmed = teamId.trim();
|
|
1190
|
+
if (trimmed === "") {
|
|
1191
|
+
throw new Error(
|
|
1192
|
+
"Pass a workspace id from `deepline org workspaces list`. The default workspace has no id; use `deepline org default-workspace`."
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
return trimmed;
|
|
1196
|
+
}
|
|
1197
|
+
function describeTeam(team) {
|
|
1198
|
+
return [
|
|
1199
|
+
`Name: ${team.name}`,
|
|
1200
|
+
`Workspace id: ${team.team_id}`,
|
|
1201
|
+
...team.archived_at === null ? [] : [`Archived: ${new Date(team.archived_at).toISOString()}`]
|
|
1202
|
+
];
|
|
1203
|
+
}
|
|
1204
|
+
var WORKSPACE_SOURCE_LABEL = {
|
|
1205
|
+
option: "from the workspace option",
|
|
1206
|
+
env: "from --workspace or DEEPLINE_WORKSPACE_ID",
|
|
1207
|
+
saved: "saved by deepline org workspace set",
|
|
1208
|
+
default: "default"
|
|
1209
|
+
};
|
|
1210
|
+
function resolveTeamSelection(entries, selection) {
|
|
1211
|
+
const value = selection.trim();
|
|
1212
|
+
const live = entries.filter((entry) => entry.archived_at === null);
|
|
1213
|
+
if (/^\d+$/.test(value)) {
|
|
1214
|
+
const entry = entries[Number(value) - 1];
|
|
1215
|
+
if (entry && entry.archived_at === null) return entry;
|
|
1216
|
+
throw new (0, _chunkLFQJW4S2js.DeeplineError)(
|
|
1217
|
+
`No workspace numbered ${value}. Run \`deepline org workspace set\` to list them.`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
if (value.toLowerCase() === "default") {
|
|
1221
|
+
const entry = live.find((candidate) => candidate.is_default);
|
|
1222
|
+
if (entry) return entry;
|
|
1223
|
+
}
|
|
1224
|
+
const byId = live.find((entry) => entry.team_id === value);
|
|
1225
|
+
if (byId) return byId;
|
|
1226
|
+
const byName = live.filter(
|
|
1227
|
+
(entry) => entry.name.toLowerCase() === value.toLowerCase()
|
|
1228
|
+
);
|
|
1229
|
+
if (byName.length === 1) return byName[0];
|
|
1230
|
+
throw new (0, _chunkLFQJW4S2js.DeeplineError)(
|
|
1231
|
+
byName.length > 1 ? `More than one workspace is named "${value}". Use its workspace id.` : `No workspace "${value}" in this org. Run \`deepline org workspace set\` to list them.`
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
function describeTeamListEntry(entry) {
|
|
1235
|
+
const members = entry.member_count === null ? "many members" : `${entry.member_count} member${entry.member_count === 1 ? "" : "s"}`;
|
|
1236
|
+
if (entry.is_default) {
|
|
1237
|
+
return `${entry.name} (default workspace, no id) ${members}`;
|
|
1238
|
+
}
|
|
1239
|
+
const flags = [
|
|
1240
|
+
entry.archived_at === null ? null : "archived",
|
|
1241
|
+
entry.viewer_is_member ? "you are a member" : null
|
|
1242
|
+
].filter(Boolean);
|
|
1243
|
+
return `${entry.name} ${entry.team_id} ${members}${flags.length ? ` (${flags.join(", ")})` : ""}`;
|
|
1244
|
+
}
|
|
1245
|
+
function archiveBlockedError(error) {
|
|
1246
|
+
if (!(error instanceof _chunkLFQJW4S2js.DeeplineError) || error.code !== "archive_blocked") {
|
|
1247
|
+
return null;
|
|
1248
|
+
}
|
|
1249
|
+
const response = _optionalChain([error, 'access', _16 => _16.details, 'optionalAccess', _17 => _17.response]);
|
|
1250
|
+
const blockers = _optionalChain([response, 'optionalAccess', _18 => _18.blockers]);
|
|
1251
|
+
const lines = [error.message];
|
|
1252
|
+
const more = (listed, total) => (_nullishCoalesce(total, () => ( listed))) > listed ? [` and ${(_nullishCoalesce(total, () => ( listed))) - listed} more`] : [];
|
|
1253
|
+
for (const schedule of _nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _19 => _19.schedules]), () => ( []))) {
|
|
1254
|
+
lines.push(` schedule ${schedule.kind} ${schedule.id} (${schedule.name})`);
|
|
1255
|
+
}
|
|
1256
|
+
lines.push(
|
|
1257
|
+
...more(_nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _20 => _20.schedules, 'optionalAccess', _21 => _21.length]), () => ( 0)), _optionalChain([blockers, 'optionalAccess', _22 => _22.schedule_count]))
|
|
1258
|
+
);
|
|
1259
|
+
for (const monitor of _nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _23 => _23.monitors]), () => ( []))) {
|
|
1260
|
+
lines.push(
|
|
1261
|
+
` monitor ${monitor.monitor_key}${monitor.name ? ` (${monitor.name})` : ""}`
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
lines.push(...more(_nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _24 => _24.monitors, 'optionalAccess', _25 => _25.length]), () => ( 0)), _optionalChain([blockers, 'optionalAccess', _26 => _26.monitor_count])));
|
|
1265
|
+
for (const fleet of _nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _27 => _27.fleets]), () => ( []))) {
|
|
1266
|
+
lines.push(` monitor fleet ${fleet.fleet_id}`);
|
|
1267
|
+
}
|
|
1268
|
+
lines.push(...more(_nullishCoalesce(_optionalChain([blockers, 'optionalAccess', _28 => _28.fleets, 'optionalAccess', _29 => _29.length]), () => ( 0)), _optionalChain([blockers, 'optionalAccess', _30 => _30.fleet_count])));
|
|
1269
|
+
return new (0, _chunkLFQJW4S2js.DeeplineError)(
|
|
1270
|
+
lines.join("\n"),
|
|
1271
|
+
error.statusCode,
|
|
1272
|
+
error.code,
|
|
1273
|
+
error.details
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
function registerOrgCommands(program) {
|
|
1277
|
+
const org = program.command("org").description("List, create, and set organizations.").addHelpText(
|
|
1278
|
+
"after",
|
|
1279
|
+
`
|
|
1280
|
+
Notes:
|
|
1281
|
+
Orgs were called workspaces in earlier versions; API fields and some older
|
|
1282
|
+
commands still say workspace. Auth is stored as an API key scoped to one
|
|
1283
|
+
org, so setting an org saves a key for the selected auth scope.
|
|
1284
|
+
|
|
1285
|
+
Auth scopes:
|
|
1286
|
+
auto Update the folder pin that already controls this command; in
|
|
1287
|
+
Cowork, write the mounted project folder; otherwise update global
|
|
1288
|
+
host auth.
|
|
1289
|
+
folder Write .env.deepline in the current project/Cowork project and make
|
|
1290
|
+
sure .env.deepline is gitignored. Commands below that folder use
|
|
1291
|
+
this org; sibling folders can pin different orgs.
|
|
1292
|
+
global Write ~/.local/deepline/<host>/.env. Commands outside folder pins
|
|
1293
|
+
use this org. Existing folder pins still override global auth.
|
|
1294
|
+
|
|
1295
|
+
Process env DEEPLINE_API_KEY overrides saved auth for that command only.
|
|
1296
|
+
For projects, agents, CI, and multiple customer orgs, prefer folder
|
|
1297
|
+
scope or a per-command DEEPLINE_API_KEY. Global scope is machine-wide and
|
|
1298
|
+
can make an unrelated terminal target the last-selected organization.
|
|
1299
|
+
|
|
1300
|
+
Agent loop:
|
|
1301
|
+
deepline org list
|
|
1302
|
+
deepline org set <number-or-org-id> --auth-scope folder
|
|
1303
|
+
deepline org status
|
|
1304
|
+
deepline auth status
|
|
1305
|
+
|
|
1306
|
+
Examples:
|
|
1307
|
+
deepline org list
|
|
1308
|
+
deepline org status
|
|
1309
|
+
deepline org create Acme
|
|
1310
|
+
deepline org set 2
|
|
1311
|
+
deepline org set 2 --auth-scope folder
|
|
1312
|
+
deepline org set --org-id org_123
|
|
1313
|
+
cd path/to/project-a && deepline org set Prove --auth-scope folder
|
|
1314
|
+
cd path/to/project-b && deepline org set Mixmax --auth-scope folder
|
|
1315
|
+
cd .. && deepline org status
|
|
1316
|
+
`
|
|
1317
|
+
);
|
|
1318
|
+
const members = org.command("members").description("List org members and manage their grants.");
|
|
1319
|
+
members.command("list").description("List one page of memberships and effective grants.").option("--cursor <cursor>", "Continue from the previous page").option("--json", "Output JSON").action(async (options) => {
|
|
1320
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.members(options);
|
|
1321
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1322
|
+
{
|
|
1323
|
+
...result,
|
|
1324
|
+
render: {
|
|
1325
|
+
sections: [
|
|
1326
|
+
{
|
|
1327
|
+
title: "Org members",
|
|
1328
|
+
lines: result.members.map(
|
|
1329
|
+
(member) => `${member.id} user=${member.userId} grants=${member.grants.join(",")}`
|
|
1330
|
+
)
|
|
1331
|
+
}
|
|
1332
|
+
]
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
{ json: options.json }
|
|
1336
|
+
);
|
|
1337
|
+
});
|
|
1338
|
+
members.command("set-grants <member-id> <grants...>").description(
|
|
1339
|
+
"Replace a member\u2019s grants (read, run, admin). Requires admin."
|
|
1340
|
+
).option("--json", "Output JSON").action(
|
|
1341
|
+
async (memberId, grants, options) => {
|
|
1342
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.setMemberGrants(
|
|
1343
|
+
memberId,
|
|
1344
|
+
grants
|
|
1345
|
+
);
|
|
1346
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1347
|
+
{
|
|
1348
|
+
...result,
|
|
1349
|
+
render: {
|
|
1350
|
+
sections: [
|
|
1351
|
+
{
|
|
1352
|
+
title: "Org grants",
|
|
1353
|
+
lines: [`${result.memberId}: ${result.role}`]
|
|
1354
|
+
}
|
|
1355
|
+
]
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
{ json: options.json }
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
);
|
|
1362
|
+
const serviceAccounts = org.command("service-accounts").description(
|
|
1363
|
+
"Manage service accounts: members that are not people and own API keys."
|
|
1364
|
+
);
|
|
1365
|
+
const renderServiceAccount = (account) => `${account.id} ${account.name} role=${_nullishCoalesce(account.role, () => ( "none"))} keys=${account.activeKeyCount}`;
|
|
1366
|
+
serviceAccounts.command("list").description("List service accounts and, for admins, their keys.").option("--json", "Output JSON").action(async (options) => {
|
|
1367
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.list();
|
|
1368
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1369
|
+
{
|
|
1370
|
+
...result,
|
|
1371
|
+
render: {
|
|
1372
|
+
sections: [
|
|
1373
|
+
{
|
|
1374
|
+
title: "Service accounts",
|
|
1375
|
+
lines: result.serviceAccounts.flatMap((account) => [
|
|
1376
|
+
renderServiceAccount(account),
|
|
1377
|
+
...(_nullishCoalesce(account.keys, () => ( []))).map(
|
|
1378
|
+
(key) => ` key ${key.id} ${key.keyPrefix}\u2026${key.keyLast4}`
|
|
1379
|
+
)
|
|
1380
|
+
])
|
|
1381
|
+
}
|
|
1382
|
+
]
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
{ json: options.json }
|
|
1386
|
+
);
|
|
1387
|
+
});
|
|
1388
|
+
serviceAccounts.command("create <name>").description("Create a service account. Requires admin.").requiredOption("--role <role>", "read, run, or member").option("--json", "Output JSON").action(async (name, options) => {
|
|
1389
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.create({
|
|
1390
|
+
name,
|
|
1391
|
+
role: options.role
|
|
1392
|
+
});
|
|
1393
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1394
|
+
{
|
|
1395
|
+
...result,
|
|
1396
|
+
render: {
|
|
1397
|
+
sections: [
|
|
1398
|
+
{
|
|
1399
|
+
title: "Service account created",
|
|
1400
|
+
lines: [renderServiceAccount(result.serviceAccount)]
|
|
1401
|
+
}
|
|
1402
|
+
]
|
|
1403
|
+
},
|
|
1404
|
+
next: {
|
|
1405
|
+
createKey: `deepline org service-accounts keys create ${result.serviceAccount.id}`
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
{ json: options.json }
|
|
1409
|
+
);
|
|
1410
|
+
});
|
|
1411
|
+
serviceAccounts.command("set-role <service-account-id> <role>").description("Change a service account\u2019s role. Requires admin.").option("--json", "Output JSON").action(
|
|
1412
|
+
async (serviceAccountId, role, options) => {
|
|
1413
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.setRole(
|
|
1414
|
+
serviceAccountId,
|
|
1415
|
+
role
|
|
1416
|
+
);
|
|
1417
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1418
|
+
{
|
|
1419
|
+
...result,
|
|
1420
|
+
render: {
|
|
1421
|
+
sections: [
|
|
1422
|
+
{
|
|
1423
|
+
title: "Service account role",
|
|
1424
|
+
lines: [renderServiceAccount(result.serviceAccount)]
|
|
1425
|
+
}
|
|
1426
|
+
]
|
|
1427
|
+
}
|
|
1428
|
+
},
|
|
1429
|
+
{ json: options.json }
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1432
|
+
);
|
|
1433
|
+
serviceAccounts.command("delete <service-account-id>").description(
|
|
1434
|
+
"Delete a service account and revoke its keys. Requires admin."
|
|
1435
|
+
).option("--json", "Output JSON").action(async (serviceAccountId, options) => {
|
|
1436
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.delete(
|
|
1437
|
+
serviceAccountId
|
|
1438
|
+
);
|
|
1439
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1440
|
+
{
|
|
1441
|
+
...result,
|
|
1442
|
+
render: {
|
|
1443
|
+
sections: [
|
|
1444
|
+
{
|
|
1445
|
+
title: "Service account deleted",
|
|
1446
|
+
lines: [`${result.id} revoked keys=${result.revokedKeyCount}`]
|
|
1447
|
+
}
|
|
1448
|
+
]
|
|
1449
|
+
}
|
|
1450
|
+
},
|
|
1451
|
+
{ json: options.json }
|
|
1452
|
+
);
|
|
1453
|
+
});
|
|
1454
|
+
const serviceAccountKeys = serviceAccounts.command("keys").description(
|
|
1455
|
+
"Create, rotate and revoke a service account\u2019s API key. A service account holds one active key."
|
|
1456
|
+
);
|
|
1457
|
+
serviceAccountKeys.command("create <service-account-id>").description(
|
|
1458
|
+
"Create the API key for a service account that has none. Requires admin."
|
|
1459
|
+
).option("--json", "Output JSON").action(async (serviceAccountId, options) => {
|
|
1460
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.createKey(
|
|
1461
|
+
serviceAccountId
|
|
1462
|
+
);
|
|
1463
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1464
|
+
{
|
|
1465
|
+
...result,
|
|
1466
|
+
render: {
|
|
1467
|
+
sections: [
|
|
1468
|
+
{
|
|
1469
|
+
title: "Service account key (shown once)",
|
|
1470
|
+
lines: [result.apiKey, `id ${result.key.id}`]
|
|
1471
|
+
}
|
|
1472
|
+
]
|
|
1473
|
+
}
|
|
1474
|
+
},
|
|
1475
|
+
{ json: options.json }
|
|
1476
|
+
);
|
|
1477
|
+
});
|
|
1478
|
+
serviceAccountKeys.command("rotate <service-account-id>").description(
|
|
1479
|
+
"Replace a service account\u2019s API key: the old key stops working and the new one is shown once. Requires admin."
|
|
1480
|
+
).option("--json", "Output JSON").action(async (serviceAccountId, options) => {
|
|
1481
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.rotateKey(
|
|
1482
|
+
serviceAccountId
|
|
1483
|
+
);
|
|
1484
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1485
|
+
{
|
|
1486
|
+
...result,
|
|
1487
|
+
render: {
|
|
1488
|
+
sections: [
|
|
1489
|
+
{
|
|
1490
|
+
title: "Service account key rotated (shown once)",
|
|
1491
|
+
lines: [
|
|
1492
|
+
result.apiKey,
|
|
1493
|
+
`id ${result.key.id}`,
|
|
1494
|
+
`revoked ${result.revokedKeyIds.join(", ")}`
|
|
1495
|
+
]
|
|
1496
|
+
}
|
|
1497
|
+
]
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1500
|
+
{ json: options.json }
|
|
1501
|
+
);
|
|
1502
|
+
});
|
|
1503
|
+
serviceAccountKeys.command("revoke <service-account-id> <key-id>").description("Revoke a service account API key. Requires admin.").option("--json", "Output JSON").action(
|
|
1504
|
+
async (serviceAccountId, keyId, options) => {
|
|
1505
|
+
const result = await new (0, _chunkDUBXUAAOjs.DeeplineClient)().workspaces.serviceAccounts.revokeKey(
|
|
1506
|
+
serviceAccountId,
|
|
1507
|
+
keyId
|
|
1508
|
+
);
|
|
1509
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1510
|
+
{
|
|
1511
|
+
...result,
|
|
1512
|
+
render: {
|
|
1513
|
+
sections: [
|
|
1514
|
+
{
|
|
1515
|
+
title: "Service account key revoked",
|
|
1516
|
+
lines: [`${result.keyId} ${result.status}`]
|
|
1517
|
+
}
|
|
1518
|
+
]
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
{ json: options.json }
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
);
|
|
1525
|
+
const sso = org.command("sso").description("Manage Enterprise org SSO.");
|
|
1526
|
+
const ssoPath = "/api/v2/auth/workspace/sso";
|
|
1527
|
+
const printSso = (payload, json) => _chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1528
|
+
{
|
|
1529
|
+
...payload,
|
|
1530
|
+
render: {
|
|
1531
|
+
sections: [
|
|
1532
|
+
{
|
|
1533
|
+
title: "Org SSO",
|
|
1534
|
+
lines: [
|
|
1535
|
+
`Plan eligible: ${payload.eligible ? "yes" : "no"}`,
|
|
1536
|
+
`Can manage: ${payload.canManage ? "yes" : "no"}`,
|
|
1537
|
+
payload.provider ? `${payload.provider.type.toUpperCase()} for ${payload.provider.domain} (${payload.provider.domainVerified ? "verified" : "awaiting DNS verification"})` : "No SSO connection.",
|
|
1538
|
+
...payload.provider && !payload.provider.domainVerified ? [
|
|
1539
|
+
`DNS host: _better-auth-token-${payload.provider.providerId}.${payload.provider.domain}`,
|
|
1540
|
+
...payload.verificationToken ? [
|
|
1541
|
+
`DNS value: _better-auth-token-${payload.provider.providerId}=${payload.verificationToken}`
|
|
1542
|
+
] : []
|
|
1543
|
+
] : []
|
|
1544
|
+
]
|
|
1545
|
+
}
|
|
1546
|
+
]
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1549
|
+
{ json }
|
|
1550
|
+
);
|
|
1551
|
+
const ssoHttp = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
1552
|
+
sso.command("status").description("Show this org's SSO connection and plan eligibility.").option("--json", "Emit JSON output").action(async (options) => {
|
|
1553
|
+
printSso(await ssoHttp().get(ssoPath), options.json);
|
|
1554
|
+
});
|
|
1555
|
+
sso.command("configure-oidc").requiredOption("--domain <domain>", "Verified email domain").requiredOption("--issuer <url>", "OIDC issuer URL").requiredOption("--client-id <id>", "OIDC client ID").requiredOption(
|
|
1556
|
+
"--client-secret-file <path>",
|
|
1557
|
+
"File containing the client secret"
|
|
1558
|
+
).option("--json", "Emit JSON output").action(
|
|
1559
|
+
async (options) => {
|
|
1560
|
+
const clientSecret = _fs.readFileSync.call(void 0,
|
|
1561
|
+
options.clientSecretFile,
|
|
1562
|
+
"utf8"
|
|
1563
|
+
).trim();
|
|
1564
|
+
if (!clientSecret) throw new Error("Client secret file is empty.");
|
|
1565
|
+
printSso(
|
|
1566
|
+
await ssoHttp().post(ssoPath, {
|
|
1567
|
+
operation: "create_oidc",
|
|
1568
|
+
domain: options.domain,
|
|
1569
|
+
issuer: options.issuer,
|
|
1570
|
+
client_id: options.clientId,
|
|
1571
|
+
client_secret: clientSecret
|
|
1572
|
+
}),
|
|
1573
|
+
options.json
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
);
|
|
1577
|
+
sso.command("configure-saml").requiredOption("--domain <domain>", "Verified email domain").requiredOption(
|
|
1578
|
+
"--idp-metadata-file <path>",
|
|
1579
|
+
"Identity provider metadata XML file"
|
|
1580
|
+
).option("--json", "Emit JSON output").action(
|
|
1581
|
+
async (options) => {
|
|
1582
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
1583
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
1584
|
+
const identity = await fetchWorkspaceCreationIdentity(
|
|
1585
|
+
http2,
|
|
1586
|
+
config.apiKey
|
|
1587
|
+
);
|
|
1588
|
+
if (!identity.orgId) throw new Error("No active org.");
|
|
1589
|
+
const providerId = `sso-${identity.orgId}`;
|
|
1590
|
+
const issuer = new URL(
|
|
1591
|
+
`/api/auth/sso/saml2/sp/metadata?providerId=${encodeURIComponent(providerId)}`,
|
|
1592
|
+
config.baseUrl
|
|
1593
|
+
).toString();
|
|
1594
|
+
printSso(
|
|
1595
|
+
await http2.post(ssoPath, {
|
|
1596
|
+
operation: "create_saml",
|
|
1597
|
+
domain: options.domain,
|
|
1598
|
+
issuer,
|
|
1599
|
+
idp_metadata_xml: _fs.readFileSync.call(void 0, options.idpMetadataFile, "utf8")
|
|
1600
|
+
}),
|
|
1601
|
+
options.json
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
);
|
|
1605
|
+
for (const [name, operation] of [
|
|
1606
|
+
["request-token", "request_token"],
|
|
1607
|
+
["verify", "verify"],
|
|
1608
|
+
["test", "test"]
|
|
1609
|
+
]) {
|
|
1610
|
+
sso.command(name).description(
|
|
1611
|
+
name === "verify" ? "Verify the SSO domain TXT record." : name === "test" ? "Validate the saved SSO connection configuration." : "Get or renew the SSO domain verification token."
|
|
1612
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
1613
|
+
printSso(
|
|
1614
|
+
await ssoHttp().post(ssoPath, { operation }),
|
|
1615
|
+
options.json
|
|
1616
|
+
);
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
sso.command("remove").description("Remove this org's SSO connection.").option("--json", "Emit JSON output").action(async (options) => {
|
|
1620
|
+
printSso(await ssoHttp().delete(ssoPath), options.json);
|
|
1621
|
+
});
|
|
1622
|
+
const scim = org.command("scim").description(
|
|
1623
|
+
"Manage SCIM user provisioning from your identity provider (Enterprise)."
|
|
1624
|
+
).addHelpText(
|
|
1625
|
+
"after",
|
|
1626
|
+
`
|
|
1627
|
+
Notes:
|
|
1628
|
+
SCIM needs Enterprise SSO with a verified email domain. Your identity
|
|
1629
|
+
provider uses the base URL and token to add, update, deactivate, and remove
|
|
1630
|
+
org members. Deactivating someone removes their org membership and revokes
|
|
1631
|
+
their API keys in this org. Only emails on the verified domain are
|
|
1632
|
+
provisioned.
|
|
1633
|
+
|
|
1634
|
+
create-token and rotate-token print the token once; Deepline keeps only its
|
|
1635
|
+
hash. Rotating stops the previous token immediately. Managing SCIM needs the
|
|
1636
|
+
owner or admin role.
|
|
1637
|
+
|
|
1638
|
+
Groups your identity provider pushes appear under \`org scim groups\`; map
|
|
1639
|
+
one to a workspace and its members join that workspace.
|
|
1640
|
+
|
|
1641
|
+
Examples:
|
|
1642
|
+
deepline org scim status
|
|
1643
|
+
deepline org scim create-token
|
|
1644
|
+
deepline org scim rotate-token --json
|
|
1645
|
+
deepline org scim remove
|
|
1646
|
+
deepline org scim groups list
|
|
1647
|
+
`
|
|
1648
|
+
);
|
|
1649
|
+
const scimPath = "/api/v2/auth/workspace/scim";
|
|
1650
|
+
const printScim = (payload, json) => _chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1651
|
+
{
|
|
1652
|
+
...payload,
|
|
1653
|
+
render: {
|
|
1654
|
+
sections: [
|
|
1655
|
+
{
|
|
1656
|
+
title: "SCIM provisioning",
|
|
1657
|
+
lines: [
|
|
1658
|
+
`Plan eligible: ${payload.eligible ? "yes" : "no"}`,
|
|
1659
|
+
`Can manage: ${payload.canManage ? "yes" : "no"}`,
|
|
1660
|
+
`SSO domain verified: ${payload.ssoReady ? "yes" : "no"}`,
|
|
1661
|
+
payload.connection ? `Connected since ${new Date(payload.connection.createdAt).toISOString()} (token updated ${new Date(payload.connection.updatedAt).toISOString()})` : "No SCIM connection.",
|
|
1662
|
+
`Base URL: ${payload.base_url}`,
|
|
1663
|
+
...payload.token ? [
|
|
1664
|
+
`Token (shown once): ${payload.token}`,
|
|
1665
|
+
"Paste the base URL and token into your identity provider now."
|
|
1666
|
+
] : []
|
|
1667
|
+
]
|
|
1668
|
+
}
|
|
1669
|
+
]
|
|
1670
|
+
}
|
|
1671
|
+
},
|
|
1672
|
+
{ json }
|
|
1673
|
+
);
|
|
1674
|
+
const scimHttp = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
1675
|
+
scim.command("status").description("Show this org's SCIM connection and plan eligibility.").option("--json", "Emit JSON output").action(async (options) => {
|
|
1676
|
+
printScim(await scimHttp().get(scimPath), options.json);
|
|
1677
|
+
});
|
|
1678
|
+
for (const [name, operation, description] of [
|
|
1679
|
+
[
|
|
1680
|
+
"create-token",
|
|
1681
|
+
"create_token",
|
|
1682
|
+
"Create the SCIM connection and print its token once."
|
|
1683
|
+
],
|
|
1684
|
+
[
|
|
1685
|
+
"rotate-token",
|
|
1686
|
+
"rotate_token",
|
|
1687
|
+
"Replace the SCIM token; the previous token stops working."
|
|
1688
|
+
]
|
|
1689
|
+
]) {
|
|
1690
|
+
scim.command(name).description(description).option("--json", "Emit JSON output").action(async (options) => {
|
|
1691
|
+
printScim(
|
|
1692
|
+
await scimHttp().post(scimPath, { operation }),
|
|
1693
|
+
options.json
|
|
1694
|
+
);
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
scim.command("remove").description(
|
|
1698
|
+
"Remove this org's SCIM connection. Provisioned members stay in the org."
|
|
1699
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
1700
|
+
printScim(await scimHttp().delete(scimPath), options.json);
|
|
1701
|
+
});
|
|
1702
|
+
registerScimGroupCommands(scim, scimHttp);
|
|
1703
|
+
const team = org.command("workspace").description("Show which workspace this CLI acts in, or set it with `set`.").option("--json", "Print JSON").addHelpText(
|
|
1704
|
+
"after",
|
|
1705
|
+
`
|
|
1706
|
+
Notes:
|
|
1707
|
+
The CLI acts in the workspace named by --workspace, else DEEPLINE_WORKSPACE_ID, else the
|
|
1708
|
+
workspace saved by \`deepline org workspace set\`, else the org's default workspace
|
|
1709
|
+
(team_id null). This checks that choice against your access and prints it
|
|
1710
|
+
with where it came from (source: option, env, saved, default).
|
|
1711
|
+
|
|
1712
|
+
Examples:
|
|
1713
|
+
deepline org workspace
|
|
1714
|
+
deepline org workspace set 2
|
|
1715
|
+
deepline --workspace <workspace-id> org workspace --json
|
|
1716
|
+
`
|
|
1717
|
+
).action(async (options) => {
|
|
1718
|
+
const config = _chunkVIUUTEHYjs.resolveConfig.call(void 0, );
|
|
1719
|
+
const { source } = _chunkVIUUTEHYjs.resolveCliWorkspace.call(void 0, config, config.workspace);
|
|
1720
|
+
const payload = await new (0, _chunkVIUUTEHYjs.HttpClient)(config).get("/api/v2/auth/workspace/active-team");
|
|
1721
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1722
|
+
{
|
|
1723
|
+
...payload,
|
|
1724
|
+
source: payload.team_id === null ? "default" : source,
|
|
1725
|
+
render: {
|
|
1726
|
+
sections: [
|
|
1727
|
+
{
|
|
1728
|
+
title: "Workspace",
|
|
1729
|
+
lines: [
|
|
1730
|
+
payload.team_id === null ? "The org's default workspace." : `Workspace ${payload.team_id} (${WORKSPACE_SOURCE_LABEL[source]}).`
|
|
1731
|
+
]
|
|
1732
|
+
}
|
|
1733
|
+
]
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
{ json: options.json }
|
|
1737
|
+
);
|
|
1738
|
+
});
|
|
1739
|
+
team.command("set [selection]").description("Save the workspace this CLI acts in for the current org.").option("--json", "Emit JSON output").addHelpText(
|
|
1740
|
+
"after",
|
|
1741
|
+
`
|
|
1742
|
+
Notes:
|
|
1743
|
+
Selection is a number from the list this prints without one, an exact workspace
|
|
1744
|
+
name, a workspace id, or \`default\` for the org's default workspace. Your access is
|
|
1745
|
+
checked first.
|
|
1746
|
+
|
|
1747
|
+
Saved next to the org's credential, in the file \`deepline org set\` wrote
|
|
1748
|
+
(.env.deepline for a folder pin, else global host auth), so it applies
|
|
1749
|
+
wherever that org does. Changing org with \`deepline org set\` goes back to
|
|
1750
|
+
the new org's default workspace. --workspace and DEEPLINE_WORKSPACE_ID still override it
|
|
1751
|
+
for one command.
|
|
1752
|
+
|
|
1753
|
+
Examples:
|
|
1754
|
+
deepline org workspace set
|
|
1755
|
+
deepline org workspace set 2
|
|
1756
|
+
deepline org workspace set "Growth"
|
|
1757
|
+
deepline org workspace set default
|
|
1758
|
+
`
|
|
1759
|
+
).action(
|
|
1760
|
+
async (selection, options) => {
|
|
1761
|
+
const config = { ..._chunkVIUUTEHYjs.resolveConfig.call(void 0, ), workspace: void 0 };
|
|
1762
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(config);
|
|
1763
|
+
const { teams: entries } = await http2.get(
|
|
1764
|
+
"/api/v2/auth/workspace/teams"
|
|
1765
|
+
);
|
|
1766
|
+
if (!selection) {
|
|
1767
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1768
|
+
{
|
|
1769
|
+
teams: entries,
|
|
1770
|
+
next: { set: "deepline org workspace set <number>" },
|
|
1771
|
+
render: {
|
|
1772
|
+
sections: [
|
|
1773
|
+
{
|
|
1774
|
+
title: "Workspaces",
|
|
1775
|
+
lines: entries.map(
|
|
1776
|
+
(entry, index) => `${index + 1}. ${describeTeamListEntry(entry)}`
|
|
1777
|
+
)
|
|
1778
|
+
}
|
|
1779
|
+
],
|
|
1780
|
+
actions: [
|
|
1781
|
+
{
|
|
1782
|
+
label: "Run",
|
|
1783
|
+
command: "deepline org workspace set <number>"
|
|
1784
|
+
}
|
|
1785
|
+
]
|
|
1786
|
+
}
|
|
1787
|
+
},
|
|
1788
|
+
{ json: options.json }
|
|
1789
|
+
);
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
const target = resolveTeamSelection(entries, selection);
|
|
1793
|
+
if (target.team_id !== null) {
|
|
1794
|
+
await new (0, _chunkVIUUTEHYjs.HttpClient)({ ...config, workspace: target.team_id }).get(
|
|
1795
|
+
"/api/v2/auth/workspace/active-team"
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
const saved = _chunkVIUUTEHYjs.saveCliWorkspace.call(void 0, config, target.team_id);
|
|
1799
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1800
|
+
{
|
|
1801
|
+
ok: true,
|
|
1802
|
+
team_id: target.team_id,
|
|
1803
|
+
name: target.name,
|
|
1804
|
+
is_default: target.team_id === null,
|
|
1805
|
+
auth_scope: saved.scope,
|
|
1806
|
+
env_path: saved.filePath,
|
|
1807
|
+
render: {
|
|
1808
|
+
sections: [
|
|
1809
|
+
{
|
|
1810
|
+
title: "org workspace set",
|
|
1811
|
+
lines: [
|
|
1812
|
+
target.team_id === null ? `\u2713 Acting in the default workspace, ${target.name}.` : `\u2713 Acting in ${target.name} (${target.team_id}).`,
|
|
1813
|
+
`Saved ${saved.scope} auth in ${saved.filePath}.`
|
|
1814
|
+
]
|
|
1815
|
+
}
|
|
1816
|
+
]
|
|
1817
|
+
}
|
|
1818
|
+
},
|
|
1819
|
+
{ json: options.json }
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
1822
|
+
);
|
|
1823
|
+
const defaultTeam = org.command("default-workspace").description("Show this org's default workspace.").addHelpText(
|
|
1824
|
+
"after",
|
|
1825
|
+
`
|
|
1826
|
+
Notes:
|
|
1827
|
+
Every org has one default workspace. It has no workspace id, every org member is in
|
|
1828
|
+
it, and work that names no workspace belongs to it, so it cannot be deleted or
|
|
1829
|
+
replaced. It is always named after the org; rename the org to change it.
|
|
1830
|
+
|
|
1831
|
+
Examples:
|
|
1832
|
+
deepline org default-workspace
|
|
1833
|
+
deepline org default-workspace --json
|
|
1834
|
+
`
|
|
1835
|
+
);
|
|
1836
|
+
const defaultTeamPath = "/api/v2/auth/workspace/default-team";
|
|
1837
|
+
const printDefaultTeam = (payload, json) => _chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1838
|
+
{
|
|
1839
|
+
...payload,
|
|
1840
|
+
render: {
|
|
1841
|
+
sections: [
|
|
1842
|
+
{
|
|
1843
|
+
title: "Default workspace",
|
|
1844
|
+
lines: [
|
|
1845
|
+
`Name: ${payload.name} (the org name)`,
|
|
1846
|
+
"Every org member is in this workspace."
|
|
1847
|
+
]
|
|
1848
|
+
}
|
|
1849
|
+
]
|
|
1850
|
+
}
|
|
1851
|
+
},
|
|
1852
|
+
{ json }
|
|
1853
|
+
);
|
|
1854
|
+
const defaultTeamHttp = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
1855
|
+
defaultTeam.option("--json", "Emit JSON output").action(async (options) => {
|
|
1856
|
+
printDefaultTeam(
|
|
1857
|
+
await defaultTeamHttp().get(defaultTeamPath),
|
|
1858
|
+
options.json
|
|
1859
|
+
);
|
|
1860
|
+
});
|
|
1861
|
+
defaultTeam.command("rename <name>", { hidden: true }).description(
|
|
1862
|
+
"Removed: the default workspace is always named after the org."
|
|
1863
|
+
).option("--json", "Emit JSON output").action(async (name, options) => {
|
|
1864
|
+
printDefaultTeam(
|
|
1865
|
+
await defaultTeamHttp().patch(defaultTeamPath, {
|
|
1866
|
+
name
|
|
1867
|
+
}),
|
|
1868
|
+
options.json
|
|
1869
|
+
);
|
|
1870
|
+
});
|
|
1871
|
+
defaultTeam.command("reset", { hidden: true }).description(
|
|
1872
|
+
"Removed: the default workspace is always named after the org."
|
|
1873
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
1874
|
+
printDefaultTeam(
|
|
1875
|
+
await defaultTeamHttp().patch(defaultTeamPath, {
|
|
1876
|
+
name: null
|
|
1877
|
+
}),
|
|
1878
|
+
options.json
|
|
1879
|
+
);
|
|
1880
|
+
});
|
|
1881
|
+
const teams = org.command("workspaces").description("List and manage this org's workspaces.").addHelpText("after", TEAMS_HELP_TEXT);
|
|
1882
|
+
registerTeamMoveCommands(teams);
|
|
1883
|
+
registerWorkspaceIntegrationCommands(teams);
|
|
1884
|
+
const teamsPath = "/api/v2/auth/workspace/teams";
|
|
1885
|
+
const teamPath = (teamId) => `${teamsPath}/${encodeURIComponent(requireTeamIdArgument(teamId))}`;
|
|
1886
|
+
const teamsHttp = () => new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
1887
|
+
const printTeam = (title, payload, json) => _chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1888
|
+
{
|
|
1889
|
+
...payload,
|
|
1890
|
+
render: {
|
|
1891
|
+
sections: [{ title, lines: describeTeam(payload) }]
|
|
1892
|
+
}
|
|
1893
|
+
},
|
|
1894
|
+
{ json }
|
|
1895
|
+
);
|
|
1896
|
+
teams.command("list").description("List the org's workspaces, the default workspace first.").option("--archived", "Include archived workspaces").option("--json", "Emit JSON output").action(async (options) => {
|
|
1897
|
+
const payload = await teamsHttp().get(
|
|
1898
|
+
options.archived ? `${teamsPath}?include_archived=true` : teamsPath
|
|
1899
|
+
);
|
|
1900
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1901
|
+
{
|
|
1902
|
+
...payload,
|
|
1903
|
+
render: {
|
|
1904
|
+
sections: [
|
|
1905
|
+
{
|
|
1906
|
+
title: "Workspaces",
|
|
1907
|
+
lines: payload.teams.map(describeTeamListEntry)
|
|
1908
|
+
}
|
|
1909
|
+
]
|
|
1910
|
+
}
|
|
1911
|
+
},
|
|
1912
|
+
{ json: options.json }
|
|
1913
|
+
);
|
|
1914
|
+
});
|
|
1915
|
+
teams.command("create <name>").description(
|
|
1916
|
+
"Create a workspace (owners and admins; 64 characters at most)."
|
|
1917
|
+
).option("--json", "Emit JSON output").action(async (name, options) => {
|
|
1918
|
+
printTeam(
|
|
1919
|
+
"Workspace created",
|
|
1920
|
+
await teamsHttp().post(teamsPath, { name }),
|
|
1921
|
+
options.json
|
|
1922
|
+
);
|
|
1923
|
+
});
|
|
1924
|
+
teams.command("rename <workspace-id> <name>").description("Rename a workspace (owners and admins).").option("--json", "Emit JSON output").action(
|
|
1925
|
+
async (teamId, name, options) => {
|
|
1926
|
+
printTeam(
|
|
1927
|
+
"Workspace renamed",
|
|
1928
|
+
await teamsHttp().patch(teamPath(teamId), { name }),
|
|
1929
|
+
options.json
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1932
|
+
);
|
|
1933
|
+
teams.command("archive <workspace-id>").description(
|
|
1934
|
+
"Archive a workspace (owners and admins). Refused, with the list, while it has active schedules or monitors."
|
|
1935
|
+
).option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
1936
|
+
let payload;
|
|
1937
|
+
try {
|
|
1938
|
+
payload = await teamsHttp().post(
|
|
1939
|
+
`${teamPath(teamId)}/archive`,
|
|
1940
|
+
{}
|
|
1941
|
+
);
|
|
1942
|
+
} catch (error) {
|
|
1943
|
+
throw _nullishCoalesce(archiveBlockedError(error), () => ( error));
|
|
1944
|
+
}
|
|
1945
|
+
printTeam(
|
|
1946
|
+
payload.changed ? "Workspace archived" : "Workspace already archived",
|
|
1947
|
+
payload,
|
|
1948
|
+
options.json
|
|
1949
|
+
);
|
|
1950
|
+
});
|
|
1951
|
+
teams.command("unarchive <workspace-id>").description(
|
|
1952
|
+
"Restore an archived workspace with its members (owners and admins)."
|
|
1953
|
+
).option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
1954
|
+
const payload = await teamsHttp().post(`${teamPath(teamId)}/unarchive`, {});
|
|
1955
|
+
printTeam(
|
|
1956
|
+
payload.changed ? "Workspace restored" : "Workspace was not archived",
|
|
1957
|
+
payload,
|
|
1958
|
+
options.json
|
|
1959
|
+
);
|
|
1960
|
+
});
|
|
1961
|
+
teams.command("members <workspace-id>").description("List a workspace's members.").option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
1962
|
+
const http2 = teamsHttp();
|
|
1963
|
+
const members2 = [];
|
|
1964
|
+
let team2 = null;
|
|
1965
|
+
let cursor = null;
|
|
1966
|
+
do {
|
|
1967
|
+
const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : "";
|
|
1968
|
+
const page = await http2.get(
|
|
1969
|
+
`${teamPath(teamId)}/members${query}`
|
|
1970
|
+
);
|
|
1971
|
+
team2 = page.team;
|
|
1972
|
+
members2.push(...page.members);
|
|
1973
|
+
cursor = page.next_cursor;
|
|
1974
|
+
} while (cursor);
|
|
1975
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
1976
|
+
{
|
|
1977
|
+
team: team2,
|
|
1978
|
+
members: members2,
|
|
1979
|
+
render: {
|
|
1980
|
+
sections: [
|
|
1981
|
+
{
|
|
1982
|
+
title: `Members of ${_nullishCoalesce(_optionalChain([team2, 'optionalAccess', _31 => _31.name]), () => ( teamId))}`,
|
|
1983
|
+
lines: members2.length === 0 ? [
|
|
1984
|
+
"No members yet. Owners and admins reach every workspace."
|
|
1985
|
+
] : members2.map(
|
|
1986
|
+
(member) => `${member.email || member.user_id} ${member.user_id} ${_nullishCoalesce(member.org_role, () => ( ""))}${describeGrant(member)}`.trimEnd()
|
|
1987
|
+
)
|
|
1988
|
+
}
|
|
1989
|
+
]
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
{ json: options.json }
|
|
1993
|
+
);
|
|
1994
|
+
});
|
|
1995
|
+
teams.command("add-member <workspace-id> <user>").description(
|
|
1996
|
+
"Add an org member to a workspace by user id or email (owners and admins)."
|
|
1997
|
+
).option("--json", "Emit JSON output").action(
|
|
1998
|
+
async (teamId, user, options) => {
|
|
1999
|
+
const payload = await teamsHttp().post(
|
|
2000
|
+
`${teamPath(teamId)}/members`,
|
|
2001
|
+
{ user }
|
|
2002
|
+
);
|
|
2003
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
2004
|
+
{
|
|
2005
|
+
...payload,
|
|
2006
|
+
render: {
|
|
2007
|
+
sections: [
|
|
2008
|
+
{
|
|
2009
|
+
title: "Workspace member",
|
|
2010
|
+
lines: [
|
|
2011
|
+
payload.added ? `Added ${payload.user_id} to ${payload.team_id}.` : `${payload.user_id} is already in ${payload.team_id}.`
|
|
2012
|
+
]
|
|
2013
|
+
}
|
|
2014
|
+
]
|
|
2015
|
+
}
|
|
2016
|
+
},
|
|
2017
|
+
{ json: options.json }
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
);
|
|
2021
|
+
teams.command("remove-member <workspace-id> <user>").description(
|
|
2022
|
+
"Remove someone from a workspace by user id or email (owners and admins). They stay in the org."
|
|
2023
|
+
).option("--json", "Emit JSON output").action(
|
|
2024
|
+
async (teamId, user, options) => {
|
|
2025
|
+
const value = user.trim();
|
|
2026
|
+
if (value === "") throw new Error("Pass a user id or email.");
|
|
2027
|
+
const payload = await teamsHttp().delete(
|
|
2028
|
+
`${teamPath(teamId)}/members/${encodeURIComponent(value)}`
|
|
2029
|
+
);
|
|
2030
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
2031
|
+
{
|
|
2032
|
+
...payload,
|
|
2033
|
+
render: {
|
|
2034
|
+
sections: [
|
|
2035
|
+
{
|
|
2036
|
+
title: "Workspace member",
|
|
2037
|
+
lines: [
|
|
2038
|
+
payload.removed ? `Removed ${payload.user_id} from ${payload.team_id}.` : (_nullishCoalesce(_optionalChain([payload, 'access', _32 => _32.retained_by_scim_groups, 'optionalAccess', _33 => _33.length]), () => ( 0))) > 0 ? `${_nullishCoalesce(payload.user_id, () => ( value))} stays in ${payload.team_id}: SCIM group ${payload.retained_by_scim_groups.map((group) => group.display_name).join(", ")} grants it. Remove them from the group in your identity provider, or unmap it with \`deepline org scim groups unmap\`.` : `${_nullishCoalesce(payload.user_id, () => ( value))} was not in ${payload.team_id}.`
|
|
2039
|
+
]
|
|
2040
|
+
}
|
|
2041
|
+
]
|
|
2042
|
+
}
|
|
2043
|
+
},
|
|
2044
|
+
{ json: options.json }
|
|
2045
|
+
);
|
|
2046
|
+
}
|
|
2047
|
+
);
|
|
2048
|
+
const caps = teams.command("cap").description(
|
|
2049
|
+
"Read and manage workspaces' rolling 30-day spending caps (owners and admins change them)."
|
|
2050
|
+
);
|
|
2051
|
+
const printCap = (title, payload, json) => _chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
2052
|
+
{
|
|
2053
|
+
...payload,
|
|
2054
|
+
render: {
|
|
2055
|
+
sections: [
|
|
2056
|
+
{
|
|
2057
|
+
title,
|
|
2058
|
+
lines: [
|
|
2059
|
+
describeTeamCap(payload.cap),
|
|
2060
|
+
...payload.org_cap ? [describeOrgCap(payload.org_cap)] : []
|
|
2061
|
+
]
|
|
2062
|
+
}
|
|
2063
|
+
]
|
|
2064
|
+
}
|
|
2065
|
+
},
|
|
2066
|
+
{ json }
|
|
2067
|
+
);
|
|
2068
|
+
caps.command("list").description(
|
|
2069
|
+
"List workspace caps with spend in the last 30 days, and the organization cap."
|
|
2070
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
2071
|
+
const payload = await teamsHttp().get(`${teamsPath}/caps`);
|
|
2072
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
2073
|
+
{
|
|
2074
|
+
...payload,
|
|
2075
|
+
render: {
|
|
2076
|
+
sections: [
|
|
2077
|
+
{
|
|
2078
|
+
title: "Workspace caps",
|
|
2079
|
+
lines: [
|
|
2080
|
+
...payload.caps.length === 0 ? ["No workspace has a cap."] : payload.caps.map(describeTeamCap),
|
|
2081
|
+
describeOrgCap(payload.org_cap)
|
|
2082
|
+
]
|
|
2083
|
+
}
|
|
2084
|
+
]
|
|
2085
|
+
}
|
|
2086
|
+
},
|
|
2087
|
+
{ json: options.json }
|
|
2088
|
+
);
|
|
2089
|
+
});
|
|
2090
|
+
caps.command("get <workspace-id>").description("Show a workspace's cap and its spend in the last 30 days.").option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
2091
|
+
printCap(
|
|
2092
|
+
"Workspace cap",
|
|
2093
|
+
await teamsHttp().get(`${teamPath(teamId)}/cap`),
|
|
2094
|
+
options.json
|
|
2095
|
+
);
|
|
2096
|
+
});
|
|
2097
|
+
caps.command("set <workspace-id> <credits>").description(
|
|
2098
|
+
"Set, raise, or lower a workspace's rolling 30-day cap in credits (owners and admins)."
|
|
2099
|
+
).option("--json", "Emit JSON output").action(
|
|
2100
|
+
async (teamId, credits, options) => {
|
|
2101
|
+
const path = `${teamPath(teamId)}/cap`;
|
|
2102
|
+
const monthly_credits_limit = parseCapCredits(credits);
|
|
2103
|
+
const payload = await teamsHttp().put(path, { monthly_credits_limit });
|
|
2104
|
+
printCap(
|
|
2105
|
+
payload.changed ? "Workspace cap set" : "Workspace cap unchanged",
|
|
2106
|
+
payload,
|
|
2107
|
+
options.json
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
);
|
|
2111
|
+
caps.command("remove <workspace-id>").description("Remove a workspace's cap (owners and admins).").option("--json", "Emit JSON output").action(async (teamId, options) => {
|
|
2112
|
+
const payload = await teamsHttp().delete(`${teamPath(teamId)}/cap`);
|
|
2113
|
+
printCap(
|
|
2114
|
+
payload.changed ? "Workspace cap removed" : "Workspace had no cap",
|
|
2115
|
+
payload,
|
|
2116
|
+
options.json
|
|
2117
|
+
);
|
|
2118
|
+
});
|
|
2119
|
+
org.command("logo [url]").description("Show, set, or remove the current organization's logo.").addHelpText(
|
|
2120
|
+
"after",
|
|
2121
|
+
`
|
|
2122
|
+
Notes:
|
|
2123
|
+
With no arguments, shows where the logo comes from. Setting or removing it
|
|
2124
|
+
mutates org branding and requires the owner role in the current
|
|
2125
|
+
organization.
|
|
2126
|
+
|
|
2127
|
+
--domain looks up the company's logo from its domain when you run it; the
|
|
2128
|
+
resolved image URL is not shown. A URL argument uses that http(s) image
|
|
2129
|
+
as-is. --remove clears the logo. The logo appears in the dashboard org
|
|
2130
|
+
switcher.
|
|
2131
|
+
|
|
2132
|
+
Examples:
|
|
2133
|
+
deepline org logo
|
|
2134
|
+
deepline org logo --domain acme.com
|
|
2135
|
+
deepline org logo https://example.com/logo.png
|
|
2136
|
+
deepline org logo --remove
|
|
2137
|
+
`
|
|
2138
|
+
).option("--domain <domain>", "Use the logo for this company's domain").option("--remove", "Remove the logo").option("--json", "Emit JSON output").action(
|
|
2139
|
+
async (url, options) => {
|
|
2140
|
+
const chosen = [url, options.domain, options.remove].filter(Boolean);
|
|
2141
|
+
if (chosen.length > 1) {
|
|
2142
|
+
throw new Error("Pass one of a logo URL, --domain, or --remove.");
|
|
2143
|
+
}
|
|
2144
|
+
const http2 = new (0, _chunkVIUUTEHYjs.HttpClient)(_chunkVIUUTEHYjs.resolveConfig.call(void 0, ));
|
|
2145
|
+
const path = "/api/v2/auth/workspace/logo";
|
|
2146
|
+
const payload = chosen.length === 0 ? await http2.get(path) : await http2.patch(
|
|
2147
|
+
path,
|
|
2148
|
+
options.domain ? { domain: options.domain } : { logo: _nullishCoalesce(url, () => ( null)) }
|
|
2149
|
+
);
|
|
2150
|
+
_chunkYQKCH4R7js.printCommandEnvelope.call(void 0,
|
|
2151
|
+
{
|
|
2152
|
+
...payload,
|
|
2153
|
+
render: {
|
|
2154
|
+
sections: [
|
|
2155
|
+
{
|
|
2156
|
+
title: "Org logo",
|
|
2157
|
+
lines: [
|
|
2158
|
+
payload.source === "domain" ? `From domain: ${payload.domain}` : payload.source === "url" ? `From URL: ${payload.url}` : "No logo."
|
|
2159
|
+
]
|
|
2160
|
+
}
|
|
2161
|
+
]
|
|
2162
|
+
}
|
|
2163
|
+
},
|
|
2164
|
+
{ json: options.json }
|
|
2165
|
+
);
|
|
2166
|
+
}
|
|
2167
|
+
);
|
|
2168
|
+
org.command("list").description("List your organizations.").addHelpText(
|
|
2169
|
+
"after",
|
|
2170
|
+
`
|
|
2171
|
+
Notes:
|
|
2172
|
+
Read-only. Marks the active organization when the server returns that metadata.
|
|
2173
|
+
--workspaces also lists each organization's workspaces you can switch into:
|
|
2174
|
+
the default workspace first, then named workspaces. Owners and admins see
|
|
2175
|
+
every workspace; other members see the default workspace and their own.
|
|
2176
|
+
|
|
2177
|
+
Examples:
|
|
2178
|
+
deepline org list
|
|
2179
|
+
deepline org list --workspaces --json
|
|
2180
|
+
`
|
|
2181
|
+
).option("--workspaces", "Also list each organization's workspaces").option("--json", "Emit JSON output").action(handleOrgList);
|
|
2182
|
+
org.command("create <name>").description("Create a new organization and switch this CLI to it.").addHelpText(
|
|
2183
|
+
"after",
|
|
2184
|
+
`
|
|
2185
|
+
Notes:
|
|
2186
|
+
Mutates org and billing state. The new organization is created for the
|
|
2187
|
+
current authenticated user and provisioned on the active PAYG offer before
|
|
2188
|
+
this CLI switches to it. Interrupted requests resume automatically.
|
|
2189
|
+
|
|
2190
|
+
Examples:
|
|
2191
|
+
deepline org create Acme
|
|
2192
|
+
deepline org create "Acme Sales"
|
|
2193
|
+
`
|
|
2194
|
+
).option("--json", "Emit JSON output").action(handleOrgCreate);
|
|
2195
|
+
org.command("status").description("Show the current organization and auth source.").addHelpText(
|
|
2196
|
+
"after",
|
|
2197
|
+
`
|
|
2198
|
+
Notes:
|
|
2199
|
+
Read-only. Shows the current org plus auth_source.scope, auth_source.path,
|
|
2200
|
+
folder_target, host_env_path, and next commands.
|
|
2201
|
+
|
|
2202
|
+
Scopes are env, folder, or global. env means DEEPLINE_API_KEY/
|
|
2203
|
+
DEEPLINE_HOST_URL in process env wins. folder means nearest/Cowork
|
|
2204
|
+
.env.deepline wins. global means host config wins.
|
|
2205
|
+
|
|
2206
|
+
Run before and after org set to verify what future commands will use.
|
|
2207
|
+
|
|
2208
|
+
Examples:
|
|
2209
|
+
deepline org status
|
|
2210
|
+
deepline org status
|
|
2211
|
+
`
|
|
2212
|
+
).option("--json", "Emit JSON output").action(handleOrgStatus);
|
|
2213
|
+
const addOrgSetOptions = (command) => command.option("--org-id <id>", "Set using an explicit organization id").option(
|
|
2214
|
+
"--auth-scope <scope>",
|
|
2215
|
+
"Where to save auth: auto, folder, or global",
|
|
2216
|
+
"auto"
|
|
2217
|
+
).option("--json", "Emit JSON output");
|
|
2218
|
+
addOrgSetOptions(
|
|
2219
|
+
org.command("set [selection]").description("Set the organization for the selected auth scope.").addHelpText(
|
|
2220
|
+
"after",
|
|
2221
|
+
`
|
|
2222
|
+
Notes:
|
|
2223
|
+
Selection can be a list number, exact organization name, or organization id.
|
|
2224
|
+
Without a selection, prints choices. With --auth-scope folder while this
|
|
2225
|
+
project is using global host auth, it pins the current target directly
|
|
2226
|
+
without an additional organization lookup.
|
|
2227
|
+
|
|
2228
|
+
Mutates local auth state and asks Deepline for an org-scoped API key. It
|
|
2229
|
+
writes only the selected scope:
|
|
2230
|
+
auto Update the folder pin that already controls this command; in
|
|
2231
|
+
Cowork, write the mounted project folder; otherwise update global
|
|
2232
|
+
host auth.
|
|
2233
|
+
folder Write .env.deepline in the current project/Cowork project and make
|
|
2234
|
+
sure .env.deepline is gitignored.
|
|
2235
|
+
global Write ~/.local/deepline/<host>/.env.
|
|
2236
|
+
|
|
2237
|
+
Folder auth shadows global auth. If you set --auth-scope global from a pinned
|
|
2238
|
+
folder, commands in that folder still use the folder pin until it is changed
|
|
2239
|
+
or removed.
|
|
2240
|
+
|
|
2241
|
+
Prefer --auth-scope folder for a repository or customer org. Use
|
|
2242
|
+
--auth-scope global only for deliberate host-wide interactive defaults; it
|
|
2243
|
+
is shared by every unpinned CLI on this machine. Global auth remains
|
|
2244
|
+
supported in projects; use a folder pin when you want a project-specific
|
|
2245
|
+
default. For automation, pass
|
|
2246
|
+
DEEPLINE_API_KEY only to that invocation and confirm with org status.
|
|
2247
|
+
|
|
2248
|
+
Use --json for stable fields including effective_auth_scope,
|
|
2249
|
+
auth_scope_reason, host_env_path, project_env_paths, warnings, org_id, and
|
|
2250
|
+
org_name.
|
|
2251
|
+
|
|
2252
|
+
Examples:
|
|
2253
|
+
deepline org set
|
|
2254
|
+
deepline org set 2
|
|
2255
|
+
deepline org set 2 --auth-scope folder
|
|
2256
|
+
deepline org set 2 --auth-scope global
|
|
2257
|
+
deepline org set --org-id org_123
|
|
2258
|
+
deepline org status
|
|
2259
|
+
`
|
|
2260
|
+
)
|
|
2261
|
+
).action(handleOrgSwitch);
|
|
2262
|
+
addOrgSetOptions(
|
|
2263
|
+
org.command("switch [selection]", { hidden: true }).description(
|
|
2264
|
+
"Deprecated alias for org set. Set the organization for the selected auth scope."
|
|
2265
|
+
).addHelpText(
|
|
2266
|
+
"after",
|
|
2267
|
+
`
|
|
2268
|
+
Notes:
|
|
2269
|
+
Deprecated alias. Use deepline org set instead. The command still mutates
|
|
2270
|
+
local auth state with the same --auth-scope behavior as org set.
|
|
2271
|
+
|
|
2272
|
+
Run deepline org set --help for scope definitions and the agent verification
|
|
2273
|
+
loop.
|
|
2274
|
+
|
|
2275
|
+
Examples:
|
|
2276
|
+
deepline org switch
|
|
2277
|
+
deepline org switch 2
|
|
2278
|
+
deepline org switch 2 --auth-scope folder
|
|
2279
|
+
deepline org switch 2 --auth-scope global
|
|
2280
|
+
deepline org switch --org-id org_123
|
|
2281
|
+
`
|
|
2282
|
+
)
|
|
2283
|
+
).action(
|
|
2284
|
+
(selection, options) => handleOrgSwitch(selection, { ...options, deprecatedSwitch: true })
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
exports.registerOrgCommands = registerOrgCommands;
|