deepline 0.3.461 → 0.3.463
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 +7593 -0
- package/dist/bundling-sources/sdk/src/client.ts +8 -7366
- package/dist/bundling-sources/sdk/src/http-core.ts +1239 -0
- package/dist/bundling-sources/sdk/src/http.ts +6 -1231
- package/dist/bundling-sources/sdk/src/index.ts +4 -1
- package/dist/bundling-sources/sdk/src/play.ts +5 -5
- package/dist/bundling-sources/sdk/src/plays/client-core.ts +437 -0
- package/dist/bundling-sources/sdk/src/plays/client.ts +4 -421
- package/dist/bundling-sources/sdk/src/plays/input-example.ts +3 -4
- package/dist/bundling-sources/sdk/src/plays/play-description.ts +1 -1
- 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/server.ts +43 -0
- package/dist/bundling-sources/sdk/src/types.ts +15 -5
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +15 -0
- package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +17 -17
- package/dist/bundling-sources/shared_libs/monitors/callback-security.ts +0 -307
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +3 -0
- package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +3 -2
- package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +34 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +61 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +122 -2
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +11 -1
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-failure-codes.ts +24 -0
- package/dist/bundling-sources/shared_libs/observability/dlq.ts +32 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +57 -3
- package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +66 -1
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +36 -7
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +250 -11
- package/dist/bundling-sources/shared_libs/play-runtime/array-input-store.ts +319 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +991 -359
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +110 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +155 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +110 -6
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +127 -13
- package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +14 -1
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +57 -1
- package/dist/bundling-sources/shared_libs/play-runtime/free-company-lookup-batching.ts +218 -0
- package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +42 -5
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-budget-state-backend.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +92 -31
- package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +69 -14
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +93 -23
- package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +15 -4
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +22 -18
- package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +190 -14
- package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +131 -0
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +77 -2
- package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +271 -2
- package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +51 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +27 -1
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-text-for-log.ts +63 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-event-transport.ts +112 -16
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +104 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +265 -151
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-gateway-transport.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +35 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-sheet-persistence-retry.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-labels.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +136 -70
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +237 -36
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +148 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +285 -32
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +251 -56
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +29 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/sandbox-create-outcome.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +22 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1397 -382
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-array-input-receipts.ts +920 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +16 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +38 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +30 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +14 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +31 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +47 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +20 -7
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +1496 -320
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +31 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1389 -129
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-dispatch-authority.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +162 -23
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +499 -115
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +377 -9
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +117 -8
- package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +25 -0
- package/dist/bundling-sources/shared_libs/play-runtime/terminal-runtime-performance.ts +391 -0
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +40 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/mapped-calls.ts +171 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +16 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +38 -12
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +33 -9
- package/dist/bundling-sources/shared_libs/play-runtime/transport-error-diagnostics.ts +28 -0
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +55 -5
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +41 -1
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +4 -0
- package/dist/bundling-sources/shared_libs/plays/dataset.ts +9 -3
- package/dist/bundling-sources/shared_libs/plays/deploy/manifest-contract.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +3 -2
- package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +2 -2
- package/dist/bundling-sources/shared_libs/plays/run-output-summary.ts +66 -0
- package/dist/bundling-sources/shared_libs/plays/script-entry.ts +1 -1
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +43 -1
- package/dist/bundling-sources/shared_libs/product-notifications/content.ts +9 -0
- package/dist/bundling-sources/shared_libs/product-notifications/email.ts +91 -13
- package/dist/bundling-sources/shared_libs/product-notifications/events.ts +3 -0
- package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +41 -24
- package/dist/bundling-sources/shared_libs/security/attested-client-ip.ts +91 -0
- package/dist/bundling-sources/shared_libs/security/internal-actor.ts +0 -11
- package/dist/cli/{auth-6HJXNWUG.mjs → auth-LZLBR4C3.mjs} +5 -4
- package/dist/cli/auth-XPGKBJKB.js +41 -0
- package/dist/cli/{billing-6P5HO6QG.js → billing-6TJPNJQD.js} +152 -78
- package/dist/cli/{billing-MJ42N7YF.mjs → billing-OTOP5RE4.mjs} +84 -10
- package/dist/cli/{chunk-FCAZQ7WV.js → chunk-2NISBXMN.js} +52 -50
- package/dist/cli/{chunk-PNATXKLP.js → chunk-2ZIRCBYG.js} +6 -6
- package/dist/cli/{chunk-5FDKJQZE.js → chunk-3BOIOCNX.js} +1 -1
- package/dist/cli/chunk-3BVLLJ3H.mjs +1038 -0
- package/dist/cli/{chunk-FJZILBL7.mjs → chunk-3U5EAP6E.mjs} +5 -5
- package/dist/cli/{describe-FRAVCY5F.mjs → chunk-4YZKBBLZ.mjs} +19 -36
- package/dist/cli/{chunk-QWRHGGUH.js → chunk-5DRNNC72.js} +20 -2
- package/dist/cli/{chunk-Z2GUFYT6.js → chunk-5LEAXRHV.js} +11 -11
- package/dist/cli/{chunk-5MDIZX7M.js → chunk-5LHXOIPT.js} +8 -6
- package/dist/cli/{chunk-NMJ4D2WO.js → chunk-6PMCRYDA.js} +216 -91
- package/dist/cli/{chunk-EBU7LQ64.js → chunk-6V7KVRR5.js} +3 -3
- package/dist/cli/{chunk-MGXEUZHL.mjs → chunk-7D6X7IXW.mjs} +7 -5
- package/dist/cli/{chunk-SAZFZQRI.js → chunk-7FCYPAPP.js} +2 -2
- package/dist/cli/{chunk-ACCR7POB.js → chunk-7XYDDCQ2.js} +27 -27
- package/dist/cli/{chunk-5IYOUBFZ.js → chunk-ALZBANZI.js} +28 -54
- package/dist/cli/{chunk-3DNKFH2G.mjs → chunk-BAPTQDLF.mjs} +19 -1
- package/dist/cli/chunk-BGNWI3KH.js +827 -0
- package/dist/cli/{chunk-V7REJRDZ.mjs → chunk-C25QE4CH.mjs} +1 -1
- package/dist/cli/{chunk-FGMX4HUZ.js → chunk-CBZP6J3V.js} +29 -27
- package/dist/cli/{chunk-QEYHTIV4.mjs → chunk-CTQ56DXP.mjs} +10 -1
- package/dist/cli/{chunk-IHHLTHE7.mjs → chunk-CVQ7N5CV.mjs} +267 -38
- package/dist/cli/{chunk-7DH2FD7Y.mjs → chunk-D464JW3N.mjs} +5 -85
- package/dist/cli/{chunk-MEAIOXJL.mjs → chunk-DHXCBITQ.mjs} +7 -5
- package/dist/cli/chunk-F2RHUPVH.mjs +827 -0
- package/dist/cli/chunk-F6QV42MC.mjs +91 -0
- package/dist/cli/{chunk-OZBWRICM.js → chunk-FK2HNDCN.js} +2 -2
- package/dist/cli/{chunk-BGY2PLP7.mjs → chunk-GUT7CLOL.mjs} +23 -49
- package/dist/cli/{chunk-RY4IVOU3.mjs → chunk-I624J4H5.mjs} +16 -806
- package/dist/cli/{chunk-Z2XUZC34.js → chunk-IAYSWZDJ.js} +188 -76
- package/dist/cli/{chunk-FGLKOWSC.mjs → chunk-IKWRUNAP.mjs} +1 -1
- package/dist/cli/{chunk-KCCOQ5G5.js → chunk-JVDKZJUH.js} +511 -282
- package/dist/cli/{chunk-HDFRJ4IT.mjs → chunk-JVHOS3K3.mjs} +177 -65
- package/dist/cli/chunk-LYFKBLJI.mjs +1039 -0
- package/dist/cli/{chunk-SLEUWLJE.mjs → chunk-MSY22NQW.mjs} +5 -5
- package/dist/cli/{chunk-5FY72YOV.js → chunk-NAPTMYTY.js} +8 -8
- package/dist/cli/{chunk-O6QOMHCH.js → chunk-NDHJR2WZ.js} +37 -35
- package/dist/cli/{chunk-KXMNM4AQ.js → chunk-NMU3VR5U.js} +4 -5
- package/dist/cli/chunk-NTLI6P6Y.mjs +19 -0
- package/dist/cli/{chunk-RFONC4WJ.mjs → chunk-O3BJYD6D.mjs} +3 -3
- package/dist/cli/{describe-2WQY7ZCY.js → chunk-PVY4DPPF.js} +27 -44
- package/dist/cli/{chunk-WIYWSYDS.mjs → chunk-Q2EIZKVX.mjs} +3 -3
- package/dist/cli/{chunk-VZBCEA5S.mjs → chunk-RD6IQ2JY.mjs} +223 -92
- package/dist/cli/chunk-RGOUCIIZ.js +1039 -0
- package/dist/cli/{chunk-EIMG75BT.mjs → chunk-S3A4IXBQ.mjs} +4 -5
- package/dist/cli/{chunk-QIW7TVV6.mjs → chunk-S4XQCFES.mjs} +14 -12
- package/dist/cli/chunk-SKU6ECIY.js +19 -0
- package/dist/cli/{chunk-CRYOUPEB.js → chunk-TIRBDQ3W.js} +16 -16
- package/dist/cli/{chunk-G7L27KZB.mjs → chunk-TKAQR3IB.mjs} +31 -21
- package/dist/cli/{chunk-MDJPEGVN.js → chunk-UC4SFYNU.js} +392 -261
- package/dist/cli/{chunk-3BMLICF7.mjs → chunk-UIURR26V.mjs} +13 -8
- package/dist/cli/{chunk-TNMBPMMC.js → chunk-UROQDCVW.js} +13 -4
- package/dist/cli/{chunk-R64BGGRQ.mjs → chunk-VDGTTH7K.mjs} +2 -2
- package/dist/cli/chunk-VLEVVDWG.js +91 -0
- package/dist/cli/{chunk-R2GLGLDR.mjs → chunk-VPHN2HAL.mjs} +216 -91
- package/dist/cli/chunk-VY2GBNTX.js +1038 -0
- package/dist/cli/{chunk-CFUTOWE4.js → chunk-WG3KGAII.js} +8 -88
- package/dist/cli/{chunk-QAJAJPKK.mjs → chunk-WUMIYOXQ.mjs} +4 -2
- package/dist/cli/{chunk-SCIR5JXW.js → chunk-WUZS2HK6.js} +56 -51
- package/dist/cli/{chunk-T3MVIPHG.mjs → chunk-XDWS2JJT.mjs} +1 -1
- package/dist/cli/{chunk-KGQNIA37.js → chunk-XQCTG5OO.js} +44 -34
- package/dist/cli/{chunk-KVJ5VHW5.mjs → chunk-XW2JIYG7.mjs} +2 -2
- package/dist/cli/chunk-YGGIZ3VT.js +920 -0
- package/dist/cli/command-docs.d.mts +5 -0
- package/dist/cli/command-docs.d.ts +5 -0
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-NX7NO3O6.js → csv-EH5QWR4O.js} +13 -12
- package/dist/cli/{csv-DQ6GW5B5.mjs → csv-OK45Z5XQ.mjs} +4 -3
- package/dist/cli/{db-R72DFMP6.js → db-3ESJKETS.js} +30 -27
- package/dist/cli/{db-2YP33M4K.mjs → db-6Z5E4HKN.mjs} +10 -7
- package/dist/cli/describe-PNDQB7YS.mjs +48 -0
- package/dist/cli/describe-QUF7VTTR.js +48 -0
- package/dist/cli/describe-core.d.mts +153 -5
- package/dist/cli/describe-core.d.ts +153 -5
- package/dist/cli/describe-core.js +9 -5
- package/dist/cli/describe-core.mjs +10 -6
- package/dist/cli/{executions-WFBU7L2Q.mjs → executions-2NTWQFEG.mjs} +7 -5
- package/dist/cli/{executions-ZLHD4QIT.js → executions-KUOBRX5V.js} +9 -7
- package/dist/cli/{feedback-CN3HJFVF.mjs → feedback-7RPRMSGY.mjs} +6 -5
- package/dist/cli/{feedback-NDV6TPHG.js → feedback-UPHAZJ4C.js} +10 -9
- package/dist/cli/getting-started.d.mts +6 -6
- package/dist/cli/getting-started.d.ts +6 -6
- package/dist/cli/getting-started.js +2 -2
- package/dist/cli/getting-started.mjs +1 -1
- package/dist/cli/{git-QAD6E3HW.mjs → git-SCYP6WSZ.mjs} +5 -4
- package/dist/cli/git-UH653WHV.js +25 -0
- package/dist/cli/index.js +152 -142
- package/dist/cli/index.mjs +56 -46
- package/dist/cli/{legacy-noops-KVC5QJ74.js → legacy-noops-7XMFCVRG.js} +8 -7
- package/dist/cli/{legacy-noops-TPTKNBI2.mjs → legacy-noops-A4KYAGI6.mjs} +5 -4
- package/dist/cli/{monitors-SV57JFLO.mjs → monitors-FLC5J7RI.mjs} +19 -6
- package/dist/cli/{monitors-KCROV6PJ.js → monitors-NZV6IX5H.js} +103 -90
- package/dist/cli/{org-NJYX5743.js → org-IZ7UP3XF.js} +70 -67
- package/dist/cli/{org-KX6QIR7A.mjs → org-LUETJ7Z5.mjs} +9 -6
- package/dist/cli/pages-22ML3O7O.js +252 -0
- package/dist/cli/pages-EUX5EAGF.mjs +252 -0
- package/dist/cli/{play-IQQ57L7Z.mjs → play-CDHPAKKM.mjs} +512 -1508
- package/dist/cli/{play-32L7EQN4.js → play-USJBQADG.js} +1090 -2086
- package/dist/cli/{providers-4WEC2EQN.mjs → providers-CCXZ3SQF.mjs} +7 -5
- package/dist/cli/{providers-ZQV6QLVQ.js → providers-WFEUNPGC.js} +10 -8
- package/dist/cli/{quickstart-HKUSFADF.js → quickstart-O4JSUORZ.js} +13 -12
- package/dist/cli/{quickstart-RQ76RIUE.mjs → quickstart-ZUULI635.mjs} +5 -4
- package/dist/cli/run-ISDJYJMU.js +443 -0
- package/dist/cli/run-QJ4NX5F5.mjs +443 -0
- package/dist/cli/{search-ZRAVFBZC.mjs → search-IX3XKZJ3.mjs} +8 -6
- package/dist/cli/search-TIFNLRPM.js +32 -0
- package/dist/cli/{secrets-CMJOVNVH.mjs → secrets-7VUDXTUZ.mjs} +7 -5
- package/dist/cli/{secrets-J3G5Y43U.js → secrets-ELQSNCTR.js} +16 -14
- package/dist/cli/{sessions-WY7VN4AE.js → sessions-A3FG3AZX.js} +6 -5
- package/dist/cli/{sessions-MDQYY5CB.mjs → sessions-VOIQ62GB.mjs} +5 -4
- package/dist/cli/{settings-4RWZPCT5.mjs → settings-S6N6EFBG.mjs} +14 -11
- package/dist/cli/{settings-HTNTFKCE.js → settings-ZTXQEMZI.js} +80 -77
- package/dist/cli/{setup-P3GYYZWG.mjs → setup-AYPIK4JE.mjs} +12 -10
- package/dist/cli/{setup-QGCAP62X.js → setup-Y3WOIFLS.js} +53 -51
- package/dist/cli/{skills-7NAE4ICL.mjs → skills-5SF5QWNI.mjs} +7 -6
- package/dist/cli/skills-MWFRMG3H.js +31 -0
- package/dist/cli/tools-3XNZ4J64.mjs +55 -0
- package/dist/cli/tools-XEC4OD3R.js +55 -0
- package/dist/cli/{update-GODLRKNB.mjs → update-3U4OVX5R.mjs} +9 -8
- package/dist/cli/update-DWYEYTZE.js +33 -0
- package/dist/cli/{workflow-4BXOUVEO.mjs → workflow-2M5JP7SA.mjs} +10 -8
- package/dist/cli/{workflow-AO3A6LXN.js → workflow-RM7H7555.js} +20 -18
- package/dist/client-DS2IWYZF.d.ts +10 -0
- package/dist/client-DTwnz_AW.d.mts +10 -0
- package/dist/{client-CYqG23K1.d.ts → client-core-B_6HAIBy.d.ts} +385 -12
- package/dist/{client-BbU5_j7n.d.mts → client-core-DzBSlY1U.d.mts} +385 -12
- package/dist/{compiler-manifest-CWz_sNOQ.d.ts → compiler-manifest-Dcyd3-Zd.d.mts} +43 -1
- package/dist/{compiler-manifest-CWz_sNOQ.d.mts → compiler-manifest-Dcyd3-Zd.d.ts} +43 -1
- package/dist/errors-d-sTrZhe.d.mts +142 -0
- package/dist/errors-yQwfgrcX.d.ts +142 -0
- package/dist/{index-BF2JB_Ug.d.mts → index-C6oXchjN.d.mts} +1 -1
- package/dist/{index-4NPXDzlD.d.ts → index-P56zy_z5.d.ts} +1 -1
- package/dist/index.d.mts +11 -147
- package/dist/index.d.ts +11 -147
- package/dist/index.js +16 -12
- package/dist/index.mjs +15 -11
- package/dist/install-integrity.json +141 -104
- 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 +2 -1
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/play-description.js +2 -2
- package/dist/plays/play-description.mjs +1 -1
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- 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 +17 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +76 -0
- package/dist/server.mjs +76 -0
- package/package.json +6 -1
- package/dist/cli/auth-IACERYQH.js +0 -40
- package/dist/cli/chunk-PQUUWFXY.js +0 -95
- package/dist/cli/chunk-YBWAG72P.mjs +0 -95
- package/dist/cli/chunk-YQDUODZW.js +0 -1710
- package/dist/cli/git-JVI36ZFV.js +0 -24
- package/dist/cli/search-75X5LTDE.js +0 -30
- package/dist/cli/skills-BKJ53JOQ.js +0 -30
- package/dist/cli/tools-COWMIEJ6.mjs +0 -45
- package/dist/cli/tools-TASOCE7I.js +0 -45
- package/dist/cli/update-SJIKVME6.js +0 -32
|
@@ -0,0 +1,920 @@
|
|
|
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
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkALJJRZNJjs = require('./chunk-ALJJRZNJ.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkXNYIZMNQjs = require('./chunk-XNYIZMNQ.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkDIAWYWT5js = require('./chunk-DIAWYWT5.js');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunk3BOIOCNXjs = require('./chunk-3BOIOCNX.js');
|
|
20
|
+
|
|
21
|
+
// src/version.ts
|
|
22
|
+
var SDK_VERSION = _chunk3BOIOCNXjs.SDK_RELEASE.version;
|
|
23
|
+
var SDK_API_MAJOR = _chunk3BOIOCNXjs.SDK_RELEASE.contracts.api.currentMajor;
|
|
24
|
+
var SDK_API_CONTRACT = _nullishCoalesce(_chunk3BOIOCNXjs.SDK_RELEASE.contracts.api.legacyWireIds[0], () => ( `api-v${SDK_API_MAJOR}`));
|
|
25
|
+
|
|
26
|
+
// src/agent-runtime.ts
|
|
27
|
+
var _os = require('os');
|
|
28
|
+
var EXPLICIT_AGENT_RUNTIMES = /* @__PURE__ */ new Set([
|
|
29
|
+
"claude_code",
|
|
30
|
+
"claude_cowork",
|
|
31
|
+
"codex",
|
|
32
|
+
"cline",
|
|
33
|
+
"cursor",
|
|
34
|
+
"gemini",
|
|
35
|
+
"antigravity",
|
|
36
|
+
"windsurf",
|
|
37
|
+
"unknown"
|
|
38
|
+
]);
|
|
39
|
+
function truthyEnv(name) {
|
|
40
|
+
return ["1", "true", "yes", "on"].includes(
|
|
41
|
+
String(_nullishCoalesce(process.env[name], () => ( ""))).trim().toLowerCase()
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function normalizeAgentRuntime(value) {
|
|
45
|
+
const explicit = _optionalChain([value, 'optionalAccess', _ => _.trim, 'call', _2 => _2(), 'access', _3 => _3.toLowerCase, 'call', _4 => _4(), 'access', _5 => _5.replace, 'call', _6 => _6(/-/g, "_")]);
|
|
46
|
+
if (!explicit) return null;
|
|
47
|
+
if (explicit === "gemini_cli") return "gemini";
|
|
48
|
+
return EXPLICIT_AGENT_RUNTIMES.has(explicit) ? explicit : null;
|
|
49
|
+
}
|
|
50
|
+
var AGENT_SESSION_ID_VARIABLES = [
|
|
51
|
+
"CLAUDE_CODE_SESSION_ID",
|
|
52
|
+
"CODEX_SESSION_ID",
|
|
53
|
+
"CODEX_THREAD_ID"
|
|
54
|
+
];
|
|
55
|
+
function agentSessionIdFromEnvironment(env = process.env, agentRuntime) {
|
|
56
|
+
const detectedRuntime = normalizeAgentRuntime(
|
|
57
|
+
_nullishCoalesce(agentRuntime, () => ( env.DEEPLINE_AGENT_RUNTIME))
|
|
58
|
+
);
|
|
59
|
+
const runtime = _nullishCoalesce((detectedRuntime === "unknown" ? null : detectedRuntime), () => ( (_optionalChain([env, 'access', _7 => _7.CODEX_SESSION_ID, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]) || _optionalChain([env, 'access', _10 => _10.CODEX_THREAD_ID, 'optionalAccess', _11 => _11.trim, 'call', _12 => _12()]) ? "codex" : null)));
|
|
60
|
+
const variables = runtime === "codex" ? ["CODEX_SESSION_ID", "CODEX_THREAD_ID"] : runtime === "claude_code" || runtime === "claude_cowork" ? ["CLAUDE_CODE_SESSION_ID"] : runtime === null ? AGENT_SESSION_ID_VARIABLES : [];
|
|
61
|
+
for (const variable of variables) {
|
|
62
|
+
const sessionId = _optionalChain([env, 'access', _13 => _13[variable], 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()]);
|
|
63
|
+
if (sessionId) return sessionId;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
function isCoworkLikeSandbox() {
|
|
68
|
+
const pluginMode = truthyEnv("DEEPLINE_PLUGIN_MODE");
|
|
69
|
+
const claudeRemote = truthyEnv("CLAUDE_CODE_REMOTE");
|
|
70
|
+
const projectDir = Boolean(_optionalChain([process, 'access', _16 => _16.env, 'access', _17 => _17.CLAUDE_PROJECT_DIR, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]));
|
|
71
|
+
const pluginRoot = Boolean(_optionalChain([process, 'access', _20 => _20.env, 'access', _21 => _21.DEEPLINE_PLUGIN_ROOT, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]));
|
|
72
|
+
const home = _optionalChain([process, 'access', _24 => _24.env, 'access', _25 => _25.HOME, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()]) || _os.homedir.call(void 0, );
|
|
73
|
+
const sessionHome = home === "/sessions" || home.startsWith("/sessions/");
|
|
74
|
+
return claudeRemote || sessionHome || (pluginMode || pluginRoot) && projectDir;
|
|
75
|
+
}
|
|
76
|
+
function detectAgentRuntime(options = {}) {
|
|
77
|
+
const env = _nullishCoalesce(options.env, () => ( process.env));
|
|
78
|
+
const explicit = normalizeAgentRuntime(env.DEEPLINE_AGENT_RUNTIME);
|
|
79
|
+
if (explicit) return explicit;
|
|
80
|
+
if (_optionalChain([env, 'access', _28 => _28.CODEX_THREAD_ID, 'optionalAccess', _29 => _29.trim, 'call', _30 => _30()])) return "codex";
|
|
81
|
+
if (options.detectCowork !== false && isCoworkLikeSandbox()) {
|
|
82
|
+
return "claude_cowork";
|
|
83
|
+
}
|
|
84
|
+
if (_optionalChain([env, 'access', _31 => _31.CLAUDECODE, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]) === "1") return "claude_code";
|
|
85
|
+
if (_optionalChain([env, 'access', _34 => _34.CLINE_ACTIVE, 'optionalAccess', _35 => _35.trim, 'call', _36 => _36(), 'access', _37 => _37.toLowerCase, 'call', _38 => _38()]) === "true") return "cline";
|
|
86
|
+
if (_optionalChain([env, 'access', _39 => _39.CURSOR_TRACE_ID, 'optionalAccess', _40 => _40.trim, 'call', _41 => _41()]) || _optionalChain([env, 'access', _42 => _42.CURSOR_AGENT, 'optionalAccess', _43 => _43.trim, 'call', _44 => _44()])) {
|
|
87
|
+
return "cursor";
|
|
88
|
+
}
|
|
89
|
+
if (_optionalChain([env, 'access', _45 => _45.WINDSURF, 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]) || _optionalChain([env, 'access', _48 => _48.CASCADE, 'optionalAccess', _49 => _49.trim, 'call', _50 => _50()])) {
|
|
90
|
+
return "windsurf";
|
|
91
|
+
}
|
|
92
|
+
if (_optionalChain([env, 'access', _51 => _51.ANTIGRAVITY, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()]) || _optionalChain([env, 'access', _54 => _54.ANTIGRAVITY_CLI, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()]) || _optionalChain([env, 'access', _57 => _57.ANTIGRAVITY_AGENT, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()]) || _optionalChain([env, 'access', _60 => _60.ANTIGRAVITY_WORKSPACE, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])) {
|
|
93
|
+
return "antigravity";
|
|
94
|
+
}
|
|
95
|
+
if (_optionalChain([env, 'access', _63 => _63.GEMINI_CLI, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || _optionalChain([env, 'access', _66 => _66.GEMINI_CLI_VERSION, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]) || _optionalChain([env, 'access', _69 => _69.GEMINI_SANDBOX, 'optionalAccess', _70 => _70.trim, 'call', _71 => _71()]) || _optionalChain([env, 'access', _72 => _72.GEMINI_CONFIG_DIR, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()])) {
|
|
96
|
+
return "gemini";
|
|
97
|
+
}
|
|
98
|
+
return _nullishCoalesce(options.defaultRuntime, () => ( "unknown"));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/deployment-protection.ts
|
|
102
|
+
function deploymentProtectionHeaders(env = typeof process !== "undefined" ? process.env : {}) {
|
|
103
|
+
const token = env.VERCEL_PROTECTION_BYPASS_TOKEN;
|
|
104
|
+
return token ? { "x-vercel-protection-bypass": token } : {};
|
|
105
|
+
}
|
|
106
|
+
var fetchWithDeploymentProtection = (input, init) => {
|
|
107
|
+
const headers = new Headers(
|
|
108
|
+
input instanceof Request ? input.headers : void 0
|
|
109
|
+
);
|
|
110
|
+
new Headers(_optionalChain([init, 'optionalAccess', _75 => _75.headers])).forEach((value, name) => headers.set(name, value));
|
|
111
|
+
for (const [name, value] of Object.entries(deploymentProtectionHeaders())) {
|
|
112
|
+
headers.set(name, value);
|
|
113
|
+
}
|
|
114
|
+
return fetch(input, { ...init, headers });
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// ../play-runtime/coordinator-headers.ts
|
|
118
|
+
var COORDINATOR_INTERNAL_TOKEN_HEADER = "x-deepline-internal-token";
|
|
119
|
+
var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
|
|
120
|
+
var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
|
|
121
|
+
var RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER = "x-deepline-runtime-scheduler-schema";
|
|
122
|
+
var RUNTIME_ENVIRONMENT_TOKEN_HEADER = "x-deepline-runtime-environment-token";
|
|
123
|
+
var RETAINED_PIPELINE_RECEIVERS_HEADER = "x-deepline-retained-pipeline-receivers";
|
|
124
|
+
var ABSURD_RELEASE_OVERRIDE_HEADER = "x-deepline-absurd-release";
|
|
125
|
+
var PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER = "x-deepline-preferred-receipt-gateway-machine-id";
|
|
126
|
+
var SYNTHETIC_RUN_HEADER = "x-deepline-synthetic-run";
|
|
127
|
+
|
|
128
|
+
// ../play-runtime/test-runtime-seams.ts
|
|
129
|
+
var PLAY_RUNTIME_TEST_FAULT_HEADER = "x-deepline-test-fault";
|
|
130
|
+
var MAX_RUNTIME_TEST_POLICY_MS = 10 * 6e4;
|
|
131
|
+
var MAX_RUNNER_HEARTBEAT_SILENCE_MS = 10 * 6e4;
|
|
132
|
+
|
|
133
|
+
// ../integration-contracts/execute-retry-contract.ts
|
|
134
|
+
var EXECUTE_RETRY_POLICY_HEADER = "x-deepline-execute-retry-policy";
|
|
135
|
+
var EXECUTE_RETRY_POLICY_VERSION = 1;
|
|
136
|
+
function parseExecuteRetryPolicy(value) {
|
|
137
|
+
if (value === `v${EXECUTE_RETRY_POLICY_VERSION}:transient-http-safe`) {
|
|
138
|
+
return "transient-http-safe";
|
|
139
|
+
}
|
|
140
|
+
if (value === `v${EXECUTE_RETRY_POLICY_VERSION}:transient-http-unsafe`) {
|
|
141
|
+
return "transient-http-unsafe";
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
var ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER = "x-deepline-atomic-tool-supported";
|
|
146
|
+
|
|
147
|
+
// src/http-core.ts
|
|
148
|
+
var MAX_DIAGNOSTIC_HEADER_LENGTH = 120;
|
|
149
|
+
var COWORK_NETWORK_HINT = "Claude Cowork appears to be running Deepline in a network-restricted sandbox. In Claude Desktop, open Settings > Capabilities, turn on Allow network egress, and set Domain allowlist to All domains for the Cowork session.";
|
|
150
|
+
var REQUEST_TIMEOUT_MARKER = Symbol("deeplineRequestTimeout");
|
|
151
|
+
var REQUEST_ABORT_MARKER = Symbol("deeplineRequestAbort");
|
|
152
|
+
var MAX_AUTOMATIC_RETRY_WAIT_MS = 3e4;
|
|
153
|
+
function requestCancelledError(signal) {
|
|
154
|
+
const error = withErrorCause(new Error("Request aborted"), signal.reason);
|
|
155
|
+
error[REQUEST_ABORT_MARKER] = true;
|
|
156
|
+
return error;
|
|
157
|
+
}
|
|
158
|
+
function normalizeRequestAbortError(error, input) {
|
|
159
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
160
|
+
const tagged = normalized;
|
|
161
|
+
if (input.timedOut) {
|
|
162
|
+
tagged[REQUEST_TIMEOUT_MARKER] = input.timeoutMs;
|
|
163
|
+
} else if (isAbortLikeError(normalized)) {
|
|
164
|
+
tagged[REQUEST_ABORT_MARKER] = true;
|
|
165
|
+
}
|
|
166
|
+
return normalized;
|
|
167
|
+
}
|
|
168
|
+
function applyExplicitHeaders(headers, explicit) {
|
|
169
|
+
if (!explicit) return headers;
|
|
170
|
+
for (const [rawName, value] of Object.entries(explicit)) {
|
|
171
|
+
const name = rawName.trim().toLowerCase();
|
|
172
|
+
if (!name) continue;
|
|
173
|
+
for (const existing of Object.keys(headers)) {
|
|
174
|
+
if (existing.toLowerCase() === name) delete headers[existing];
|
|
175
|
+
}
|
|
176
|
+
headers[rawName.trim()] = value;
|
|
177
|
+
}
|
|
178
|
+
return headers;
|
|
179
|
+
}
|
|
180
|
+
function isAbortLikeError(error) {
|
|
181
|
+
const name = error.name.toLowerCase();
|
|
182
|
+
const message = error.message.toLowerCase();
|
|
183
|
+
return name === "aborterror" || message.includes("operation was aborted") || message === "aborted";
|
|
184
|
+
}
|
|
185
|
+
function withErrorCause(error, cause) {
|
|
186
|
+
if (cause !== null && cause !== void 0) {
|
|
187
|
+
Object.defineProperty(error, "cause", {
|
|
188
|
+
value: cause,
|
|
189
|
+
configurable: true,
|
|
190
|
+
writable: true
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return error;
|
|
194
|
+
}
|
|
195
|
+
function mapNetworkError(baseUrl, error, targetLabel) {
|
|
196
|
+
const tagged = error;
|
|
197
|
+
const timeoutMs = _optionalChain([tagged, 'optionalAccess', _76 => _76[REQUEST_TIMEOUT_MARKER]]);
|
|
198
|
+
if (typeof timeoutMs === "number") {
|
|
199
|
+
return {
|
|
200
|
+
message: `Request to ${targetLabel} timed out after ${timeoutMs}ms while waiting for a response.`,
|
|
201
|
+
code: "NETWORK_TIMEOUT",
|
|
202
|
+
details: { timeoutMs, target: targetLabel }
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (_optionalChain([tagged, 'optionalAccess', _77 => _77[REQUEST_ABORT_MARKER]])) {
|
|
206
|
+
return {
|
|
207
|
+
message: `Request to ${targetLabel} was aborted before it completed.`,
|
|
208
|
+
code: "NETWORK_ABORTED"
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
message: _optionalChain([error, 'optionalAccess', _78 => _78.message]) ? `Unable to connect to ${baseUrl}. ${error.message}` : `Unable to connect to ${baseUrl}. Is the computer able to access the url?`,
|
|
213
|
+
code: "NETWORK_ERROR"
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function describeRequestTarget(path) {
|
|
217
|
+
const toolExecuteMatch = path.match(
|
|
218
|
+
/^\/api\/v2\/integrations\/([^/?#]+)\/execute(?:[/?#]|$)/
|
|
219
|
+
);
|
|
220
|
+
if (toolExecuteMatch) {
|
|
221
|
+
return providerLabelFromToolId(decodeURIComponent(toolExecuteMatch[1]));
|
|
222
|
+
}
|
|
223
|
+
return "Deepline";
|
|
224
|
+
}
|
|
225
|
+
function networkDiagnosticUrl(value) {
|
|
226
|
+
try {
|
|
227
|
+
const url = new URL(value);
|
|
228
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") return void 0;
|
|
229
|
+
return `${url.origin}${url.pathname}`;
|
|
230
|
+
} catch (e) {
|
|
231
|
+
return void 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function providerLabelFromToolId(toolId) {
|
|
235
|
+
const normalized = toolId.trim().toLowerCase();
|
|
236
|
+
const provider = normalized.split(/[_:./-]+/)[0];
|
|
237
|
+
return provider || normalized || "provider";
|
|
238
|
+
}
|
|
239
|
+
function isRecord(value) {
|
|
240
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
241
|
+
}
|
|
242
|
+
var HttpClient = class {
|
|
243
|
+
constructor(config, readLocalSkillsVersion) {
|
|
244
|
+
this.config = config;
|
|
245
|
+
this.readLocalSkillsVersion = readLocalSkillsVersion;
|
|
246
|
+
}
|
|
247
|
+
cleanDiagnosticHeader(value) {
|
|
248
|
+
const normalized = String(_nullishCoalesce(value, () => ( ""))).replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, MAX_DIAGNOSTIC_HEADER_LENGTH);
|
|
249
|
+
return normalized || null;
|
|
250
|
+
}
|
|
251
|
+
environment() {
|
|
252
|
+
return _nullishCoalesce(this.config.environment, () => ( (typeof process !== "undefined" ? process.env : {})));
|
|
253
|
+
}
|
|
254
|
+
readSkillsVersionHeader() {
|
|
255
|
+
const explicit = this.cleanDiagnosticHeader(
|
|
256
|
+
this.environment().DEEPLINE_SKILLS_VERSION
|
|
257
|
+
);
|
|
258
|
+
if (explicit) return explicit;
|
|
259
|
+
try {
|
|
260
|
+
return this.cleanDiagnosticHeader(
|
|
261
|
+
_optionalChain([this, 'access', _79 => _79.readLocalSkillsVersion, 'optionalCall', _80 => _80(this.config.baseUrl)])
|
|
262
|
+
);
|
|
263
|
+
} catch (e2) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
authHeaders(extra) {
|
|
268
|
+
const env = this.environment();
|
|
269
|
+
const transportHeaders = {
|
|
270
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
271
|
+
"User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
|
|
272
|
+
"X-Deepline-Client-Family": "sdk",
|
|
273
|
+
"X-Deepline-CLI-Family": "sdk",
|
|
274
|
+
"X-Deepline-Agent-Runtime": detectAgentRuntime(
|
|
275
|
+
this.config.environment ? { env, detectCowork: false } : {}
|
|
276
|
+
),
|
|
277
|
+
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
278
|
+
"X-Deepline-SDK-Version": SDK_VERSION,
|
|
279
|
+
"X-Deepline-API-Contract": SDK_API_CONTRACT,
|
|
280
|
+
"X-Deepline-Run-Result-Shape": "canonical"
|
|
281
|
+
};
|
|
282
|
+
const headers = deploymentProtectionHeaders(env);
|
|
283
|
+
const skillsVersion = this.readSkillsVersionHeader();
|
|
284
|
+
if (skillsVersion) {
|
|
285
|
+
headers["X-Deepline-Skills-Version"] = skillsVersion;
|
|
286
|
+
}
|
|
287
|
+
const agentSessionId = agentSessionIdFromEnvironment(env);
|
|
288
|
+
if (agentSessionId) {
|
|
289
|
+
headers["X-Deepline-Agent-Session-Id"] = agentSessionId;
|
|
290
|
+
}
|
|
291
|
+
const playArtifactR2Prefix = env.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX;
|
|
292
|
+
if (playArtifactR2Prefix) {
|
|
293
|
+
headers["x-deepline-play-artifact-r2-prefix"] = playArtifactR2Prefix;
|
|
294
|
+
}
|
|
295
|
+
const coordinatorUrl = env.DEEPLINE_COORDINATOR_URL;
|
|
296
|
+
const coordinatorInternalToken = env.DEEPLINE_INTERNAL_TOKEN;
|
|
297
|
+
const absurdReleaseOverride = env.DEEPLINE_ABSURD_RELEASE;
|
|
298
|
+
const preferredReceiptGatewayMachineId = env.DEEPLINE_PREFERRED_RECEIPT_GATEWAY_MACHINE_ID;
|
|
299
|
+
if (_optionalChain([coordinatorUrl, 'optionalAccess', _81 => _81.trim, 'call', _82 => _82()])) {
|
|
300
|
+
headers[COORDINATOR_URL_OVERRIDE_HEADER] = coordinatorUrl.trim();
|
|
301
|
+
}
|
|
302
|
+
const workerCallbackUrl = env.DEEPLINE_WORKER_CALLBACK_URL;
|
|
303
|
+
if (_optionalChain([workerCallbackUrl, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()])) {
|
|
304
|
+
headers[WORKER_CALLBACK_URL_OVERRIDE_HEADER] = workerCallbackUrl.trim();
|
|
305
|
+
}
|
|
306
|
+
const runtimeSchedulerSchema = env.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA;
|
|
307
|
+
if (_optionalChain([runtimeSchedulerSchema, 'optionalAccess', _85 => _85.trim, 'call', _86 => _86()])) {
|
|
308
|
+
headers[RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER] = runtimeSchedulerSchema.trim();
|
|
309
|
+
}
|
|
310
|
+
const syntheticRun = env.DEEPLINE_SYNTHETIC_RUN;
|
|
311
|
+
if (syntheticRun && syntheticRun.trim() && syntheticRun.trim() !== "0") {
|
|
312
|
+
headers[SYNTHETIC_RUN_HEADER] = "1";
|
|
313
|
+
}
|
|
314
|
+
const runtimeTestFault = env.DEEPLINE_TEST_RUNTIME_FAULT;
|
|
315
|
+
if (_optionalChain([runtimeTestFault, 'optionalAccess', _87 => _87.trim, 'call', _88 => _88()])) {
|
|
316
|
+
headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
|
|
317
|
+
}
|
|
318
|
+
const retainedReceivers = _optionalChain([env, 'access', _89 => _89.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]);
|
|
319
|
+
if (retainedReceivers && _optionalChain([coordinatorInternalToken, 'optionalAccess', _92 => _92.trim, 'call', _93 => _93()])) {
|
|
320
|
+
headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
|
|
321
|
+
headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
|
|
322
|
+
}
|
|
323
|
+
if (_optionalChain([absurdReleaseOverride, 'optionalAccess', _94 => _94.trim, 'call', _95 => _95()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _96 => _96.trim, 'call', _97 => _97()])) {
|
|
324
|
+
headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
|
|
325
|
+
}
|
|
326
|
+
if (_optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _100 => _100.trim, 'call', _101 => _101()])) {
|
|
327
|
+
headers[PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER] = preferredReceiptGatewayMachineId.trim();
|
|
328
|
+
}
|
|
329
|
+
if (_optionalChain([coordinatorInternalToken, 'optionalAccess', _102 => _102.trim, 'call', _103 => _103()]) && (_optionalChain([coordinatorUrl, 'optionalAccess', _104 => _104.trim, 'call', _105 => _105()]) || _optionalChain([workerCallbackUrl, 'optionalAccess', _106 => _106.trim, 'call', _107 => _107()]) || _optionalChain([runtimeTestFault, 'optionalAccess', _108 => _108.trim, 'call', _109 => _109()]) || _optionalChain([absurdReleaseOverride, 'optionalAccess', _110 => _110.trim, 'call', _111 => _111()]) || _optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _112 => _112.trim, 'call', _113 => _113()]))) {
|
|
330
|
+
headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
|
|
331
|
+
}
|
|
332
|
+
return applyExplicitHeaders(
|
|
333
|
+
applyExplicitHeaders(
|
|
334
|
+
applyExplicitHeaders(transportHeaders, extra),
|
|
335
|
+
headers
|
|
336
|
+
),
|
|
337
|
+
this.config.headers
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Send an HTTP request with automatic retries and error handling.
|
|
342
|
+
*
|
|
343
|
+
* @typeParam T - Expected response body type
|
|
344
|
+
* @param path - API path (e.g. `"/api/v2/tools"`)
|
|
345
|
+
* @param options - HTTP method, body, headers, and timeout
|
|
346
|
+
* @returns Parsed JSON response body
|
|
347
|
+
* @throws {@link AuthError} on Deepline-auth HTTP 401/403 (immediate, no retry)
|
|
348
|
+
* @throws {@link RateLimitError} on HTTP 429 after all retries exhausted
|
|
349
|
+
* @throws {@link DeeplineError} on other API errors or connection failures
|
|
350
|
+
*/
|
|
351
|
+
async request(path, options) {
|
|
352
|
+
const baseUrl = this.config.baseUrl;
|
|
353
|
+
const url = `${baseUrl}${path}`;
|
|
354
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _114 => _114.method]), () => ( "GET"));
|
|
355
|
+
const requestStartedAt = Date.now();
|
|
356
|
+
let fetchAttempts = 0;
|
|
357
|
+
let lastRequestUrl = url;
|
|
358
|
+
let networkFailedAt;
|
|
359
|
+
let networkPhase = "before_request";
|
|
360
|
+
const headers = this.authHeaders(_optionalChain([options, 'optionalAccess', _115 => _115.headers]));
|
|
361
|
+
if (_optionalChain([options, 'optionalAccess', _116 => _116.body]) !== void 0) {
|
|
362
|
+
applyExplicitHeaders(headers, { "Content-Type": "application/json" });
|
|
363
|
+
}
|
|
364
|
+
let lastError = null;
|
|
365
|
+
const candidateUrls = _optionalChain([options, 'optionalAccess', _117 => _117.exactUrlOnly]) ? [url] : buildCandidateUrls(url);
|
|
366
|
+
let retryAfterDelayMs = null;
|
|
367
|
+
let totalRetryWaitMs = 0;
|
|
368
|
+
let maxRetries = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _118 => _118.maxRetries]), () => ( this.config.maxRetries));
|
|
369
|
+
requestAttempts: for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
370
|
+
if (_optionalChain([options, 'optionalAccess', _119 => _119.signal, 'optionalAccess', _120 => _120.aborted])) {
|
|
371
|
+
lastError = requestCancelledError(options.signal);
|
|
372
|
+
networkFailedAt = Date.now();
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
if (attempt > 0) {
|
|
376
|
+
const backoffMs = Math.min(1e3 * Math.pow(2, attempt - 1), 3e4);
|
|
377
|
+
const delayMs = retryAfterDelayMs === null ? backoffMs : Math.max(backoffMs, retryAfterDelayMs);
|
|
378
|
+
retryAfterDelayMs = null;
|
|
379
|
+
if (totalRetryWaitMs + delayMs > MAX_AUTOMATIC_RETRY_WAIT_MS) {
|
|
380
|
+
break requestAttempts;
|
|
381
|
+
}
|
|
382
|
+
totalRetryWaitMs += delayMs;
|
|
383
|
+
networkPhase = "retry_wait";
|
|
384
|
+
try {
|
|
385
|
+
await sleep(delayMs, _optionalChain([options, 'optionalAccess', _121 => _121.signal]));
|
|
386
|
+
} catch (error) {
|
|
387
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
388
|
+
networkFailedAt = Date.now();
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
for (const candidateUrl of candidateUrls) {
|
|
393
|
+
if (_optionalChain([options, 'optionalAccess', _122 => _122.signal, 'optionalAccess', _123 => _123.aborted])) {
|
|
394
|
+
lastError = requestCancelledError(options.signal);
|
|
395
|
+
networkFailedAt = Date.now();
|
|
396
|
+
break requestAttempts;
|
|
397
|
+
}
|
|
398
|
+
const controller = new AbortController();
|
|
399
|
+
const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _124 => _124.timeout]), () => ( this.config.timeout));
|
|
400
|
+
let requestTimedOut = false;
|
|
401
|
+
const timeoutId = setTimeout(() => {
|
|
402
|
+
requestTimedOut = true;
|
|
403
|
+
controller.abort();
|
|
404
|
+
}, timeoutMs);
|
|
405
|
+
const abortRequest = () => controller.abort();
|
|
406
|
+
_optionalChain([options, 'optionalAccess', _125 => _125.signal, 'optionalAccess', _126 => _126.addEventListener, 'call', _127 => _127("abort", abortRequest, {
|
|
407
|
+
once: true
|
|
408
|
+
})]);
|
|
409
|
+
networkPhase = "before_request";
|
|
410
|
+
try {
|
|
411
|
+
const requestBody = _optionalChain([options, 'optionalAccess', _128 => _128.formData]) !== void 0 ? typeof options.formData === "function" ? options.formData() : options.formData : _optionalChain([options, 'optionalAccess', _129 => _129.body]) !== void 0 ? JSON.stringify(options.body) : void 0;
|
|
412
|
+
fetchAttempts += 1;
|
|
413
|
+
lastRequestUrl = candidateUrl;
|
|
414
|
+
networkPhase = "awaiting_headers";
|
|
415
|
+
const response = await fetch(candidateUrl, {
|
|
416
|
+
method,
|
|
417
|
+
headers,
|
|
418
|
+
body: requestBody,
|
|
419
|
+
signal: controller.signal
|
|
420
|
+
});
|
|
421
|
+
networkPhase = "reading_body";
|
|
422
|
+
_optionalChain([options, 'optionalAccess', _130 => _130.onResponse, 'optionalCall', _131 => _131(response)]);
|
|
423
|
+
if (response.status === 404 && _optionalChain([options, 'optionalAccess', _132 => _132.allowNotFound])) {
|
|
424
|
+
clearTimeout(timeoutId);
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
const body = await response.text();
|
|
428
|
+
const receivedAtMs = Date.now();
|
|
429
|
+
clearTimeout(timeoutId);
|
|
430
|
+
const parsed = parseResponseBody(body);
|
|
431
|
+
_optionalChain([options, 'optionalAccess', _133 => _133.onResponseBody, 'optionalCall', _134 => _134({
|
|
432
|
+
receivedAtMs,
|
|
433
|
+
httpStatus: response.status,
|
|
434
|
+
body: parsed
|
|
435
|
+
})]);
|
|
436
|
+
const responseRetryAllowed = _optionalChain([options, 'optionalAccess', _135 => _135.retryFromExecutePolicy]) !== true || parseExecuteRetryPolicy(
|
|
437
|
+
response.headers.get(EXECUTE_RETRY_POLICY_HEADER)
|
|
438
|
+
) === "transient-http-safe";
|
|
439
|
+
if (_optionalChain([options, 'optionalAccess', _136 => _136.retryFromExecutePolicy]) === true && responseRetryAllowed && options.executePolicyMaxRetries !== void 0) {
|
|
440
|
+
maxRetries = options.executePolicyMaxRetries;
|
|
441
|
+
}
|
|
442
|
+
const structuredToolError = _optionalChain([options, 'optionalAccess', _137 => _137.toolId]) && !response.ok ? _chunkDIAWYWT5js.deserializeToolExecutionFailure.call(void 0,
|
|
443
|
+
_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status),
|
|
444
|
+
isRecord(parsed) ? parsed.tool_error : null,
|
|
445
|
+
_chunkDIAWYWT5js.TOOL_EXECUTION_ERROR_SCHEMA_VERSION
|
|
446
|
+
) : null;
|
|
447
|
+
if (structuredToolError) {
|
|
448
|
+
if (response.status === 429) {
|
|
449
|
+
const retryAfter = parseRetryAfter(response);
|
|
450
|
+
const failure = _chunkDIAWYWT5js.serializeToolExecutionFailure.call(void 0, structuredToolError);
|
|
451
|
+
lastError = failure === null ? structuredToolError : new (0, _chunkALJJRZNJjs.ToolRateLimitError)(structuredToolError.message, {
|
|
452
|
+
...failure,
|
|
453
|
+
retryAfterMs: _nullishCoalesce(failure.retryAfterMs, () => ( Math.max(0, retryAfter)))
|
|
454
|
+
});
|
|
455
|
+
if (responseRetryAllowed && attempt < maxRetries) {
|
|
456
|
+
retryAfterDelayMs = retryAfter;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
throw lastError;
|
|
460
|
+
}
|
|
461
|
+
throw structuredToolError;
|
|
462
|
+
}
|
|
463
|
+
if (response.status === 429) {
|
|
464
|
+
if (_optionalChain([options, 'optionalAccess', _138 => _138.preserveRateLimitResponse]) && isMonitorRateLimitEnvelope(parsed)) {
|
|
465
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
466
|
+
_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status),
|
|
467
|
+
response.status,
|
|
468
|
+
_chunkXNYIZMNQjs.apiErrorCodeFromResponse.call(void 0, parsed),
|
|
469
|
+
{ response: parsed }
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
const retryAfter = parseRetryAfter(response);
|
|
473
|
+
lastError = new (0, _chunkALJJRZNJjs.RateLimitError)(retryAfter);
|
|
474
|
+
if (responseRetryAllowed && attempt < maxRetries) {
|
|
475
|
+
retryAfterDelayMs = retryAfter;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
throw lastError;
|
|
479
|
+
}
|
|
480
|
+
if (response.status === 401 && !isProviderOriginatedHttpError(parsed)) {
|
|
481
|
+
throw new (0, _chunkALJJRZNJjs.AuthError)(_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status));
|
|
482
|
+
}
|
|
483
|
+
if (!response.ok) {
|
|
484
|
+
const retryableApiError = _optionalChain([options, 'optionalAccess', _139 => _139.retryApiErrors]) === true && responseRetryAllowed && isRetryableApiErrorResponse(response.status);
|
|
485
|
+
const htmlError = detectHtmlErrorBody(
|
|
486
|
+
body,
|
|
487
|
+
response.headers.get("content-type")
|
|
488
|
+
);
|
|
489
|
+
if (htmlError) {
|
|
490
|
+
lastError = new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
491
|
+
htmlError.message(response.status),
|
|
492
|
+
response.status,
|
|
493
|
+
"API_ERROR",
|
|
494
|
+
{
|
|
495
|
+
htmlErrorPage: true,
|
|
496
|
+
...htmlError.title ? { title: htmlError.title } : {},
|
|
497
|
+
...htmlError.workerThrewException ? { workerThrewException: true } : {}
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
if (retryableApiError && attempt < maxRetries) {
|
|
501
|
+
retryAfterDelayMs = parseOptionalRetryAfter(response);
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
throw lastError;
|
|
505
|
+
}
|
|
506
|
+
const errorValue = typeof parsed === "object" && parsed && "error" in parsed ? parsed.error : void 0;
|
|
507
|
+
const msg = typeof errorValue === "string" ? errorValue : errorValue && typeof errorValue === "object" && "message" in errorValue && typeof errorValue.message === "string" ? errorValue.message : typeof parsed === "object" && parsed && "message" in parsed && typeof parsed.message === "string" ? parsed.message : `HTTP ${response.status}`;
|
|
508
|
+
const apiErrorCode = _chunkXNYIZMNQjs.apiErrorCodeFromResponse.call(void 0, parsed);
|
|
509
|
+
lastError = new (0, _chunkDIAWYWT5js.DeeplineError)(msg, response.status, apiErrorCode, {
|
|
510
|
+
response: parsed
|
|
511
|
+
});
|
|
512
|
+
if (retryableApiError && attempt < maxRetries) {
|
|
513
|
+
retryAfterDelayMs = parseOptionalRetryAfter(response);
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
throw lastError;
|
|
517
|
+
}
|
|
518
|
+
if (typeof parsed === "string") {
|
|
519
|
+
const interstitial = detectHtmlErrorBody(
|
|
520
|
+
body,
|
|
521
|
+
response.headers.get("content-type")
|
|
522
|
+
);
|
|
523
|
+
if (interstitial) {
|
|
524
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
525
|
+
`${this.config.baseUrl} returned a deployment-protection page instead of JSON. Set VERCEL_PROTECTION_BYPASS_TOKEN, or run \`vercel login\` if the CLI session expired.`,
|
|
526
|
+
response.status,
|
|
527
|
+
"DEPLOYMENT_PROTECTED",
|
|
528
|
+
{ htmlErrorPage: true }
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return parsed;
|
|
533
|
+
} catch (error) {
|
|
534
|
+
clearTimeout(timeoutId);
|
|
535
|
+
networkFailedAt = Date.now();
|
|
536
|
+
if (_optionalChain([options, 'optionalAccess', _140 => _140.signal, 'optionalAccess', _141 => _141.aborted])) {
|
|
537
|
+
lastError = requestCancelledError(options.signal);
|
|
538
|
+
break requestAttempts;
|
|
539
|
+
}
|
|
540
|
+
if (error instanceof _chunkALJJRZNJjs.AuthError || error instanceof _chunkDIAWYWT5js.DeeplineError) {
|
|
541
|
+
throw error;
|
|
542
|
+
}
|
|
543
|
+
if (error instanceof _chunkALJJRZNJjs.RateLimitError) {
|
|
544
|
+
lastError = error;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
lastError = normalizeRequestAbortError(error, {
|
|
548
|
+
timeoutMs,
|
|
549
|
+
timedOut: requestTimedOut
|
|
550
|
+
});
|
|
551
|
+
if (_optionalChain([options, 'optionalAccess', _142 => _142.retryFromExecutePolicy]) && options.retryAmbiguousDelivery !== true) {
|
|
552
|
+
break requestAttempts;
|
|
553
|
+
}
|
|
554
|
+
} finally {
|
|
555
|
+
clearTimeout(timeoutId);
|
|
556
|
+
_optionalChain([options, 'optionalAccess', _143 => _143.signal, 'optionalAccess', _144 => _144.removeEventListener, 'call', _145 => _145("abort", abortRequest)]);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (attempt < maxRetries) continue;
|
|
560
|
+
}
|
|
561
|
+
if (lastError instanceof _chunkDIAWYWT5js.DeeplineError) {
|
|
562
|
+
throw lastError;
|
|
563
|
+
}
|
|
564
|
+
const mappedNetworkError = mapNetworkError(
|
|
565
|
+
baseUrl,
|
|
566
|
+
lastError,
|
|
567
|
+
describeRequestTarget(path)
|
|
568
|
+
);
|
|
569
|
+
const failedAt = _nullishCoalesce(networkFailedAt, () => ( Date.now()));
|
|
570
|
+
const diagnosticUrl = networkDiagnosticUrl(lastRequestUrl);
|
|
571
|
+
const networkDetails = {
|
|
572
|
+
...mappedNetworkError.details,
|
|
573
|
+
request: {
|
|
574
|
+
method,
|
|
575
|
+
...diagnosticUrl === void 0 ? {} : { url: diagnosticUrl },
|
|
576
|
+
failedAtUtc: new Date(failedAt).toISOString(),
|
|
577
|
+
// Elapsed time covers the entire logical request, including retries.
|
|
578
|
+
elapsedMs: Math.max(0, failedAt - requestStartedAt),
|
|
579
|
+
attempts: fetchAttempts,
|
|
580
|
+
phase: networkPhase
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
if (_optionalChain([options, 'optionalAccess', _146 => _146.toolId])) {
|
|
584
|
+
const code = mappedNetworkError.code;
|
|
585
|
+
throw withErrorCause(
|
|
586
|
+
new (0, _chunkDIAWYWT5js.ToolExecutionError)(
|
|
587
|
+
withCoworkNetworkHint(mappedNetworkError.message),
|
|
588
|
+
{
|
|
589
|
+
toolId: options.toolId,
|
|
590
|
+
provider: providerLabelFromToolId(options.toolId),
|
|
591
|
+
operation: options.toolId,
|
|
592
|
+
code,
|
|
593
|
+
origin: "deepline",
|
|
594
|
+
category: "network",
|
|
595
|
+
// A direct client timeout has ambiguous delivery. Fail closed unless
|
|
596
|
+
// the server returns the authoritative action delivery contract.
|
|
597
|
+
retryable: options.retryAmbiguousDelivery === true,
|
|
598
|
+
statusCode: null,
|
|
599
|
+
requestId: null,
|
|
600
|
+
retryAfterMs: null,
|
|
601
|
+
networkKind: code === "NETWORK_TIMEOUT" ? "timeout" : code === "NETWORK_ABORTED" ? "unknown" : "unavailable",
|
|
602
|
+
networkScope: "client_to_deepline",
|
|
603
|
+
details: networkDetails,
|
|
604
|
+
publicDetails: options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : null
|
|
605
|
+
}
|
|
606
|
+
),
|
|
607
|
+
lastError
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
throw withErrorCause(
|
|
611
|
+
new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
612
|
+
withCoworkNetworkHint(mappedNetworkError.message),
|
|
613
|
+
void 0,
|
|
614
|
+
mappedNetworkError.code,
|
|
615
|
+
networkDetails
|
|
616
|
+
),
|
|
617
|
+
lastError
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Send a GET request.
|
|
622
|
+
*
|
|
623
|
+
* @typeParam T - Expected response body type
|
|
624
|
+
* @param path - API path (e.g. `"/api/v2/tools"`)
|
|
625
|
+
*/
|
|
626
|
+
async get(path, options) {
|
|
627
|
+
return this.request(path, {
|
|
628
|
+
method: "GET",
|
|
629
|
+
retryApiErrors: true,
|
|
630
|
+
...options
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
async *streamSse(path, options) {
|
|
634
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
635
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _147 => _147.method]), () => ( "GET"));
|
|
636
|
+
const headers = this.authHeaders({
|
|
637
|
+
Accept: "text/event-stream",
|
|
638
|
+
..._optionalChain([options, 'optionalAccess', _148 => _148.headers])
|
|
639
|
+
});
|
|
640
|
+
if (_optionalChain([options, 'optionalAccess', _149 => _149.body]) !== void 0) {
|
|
641
|
+
applyExplicitHeaders(headers, { "Content-Type": "application/json" });
|
|
642
|
+
}
|
|
643
|
+
let lastError = null;
|
|
644
|
+
const candidateUrls = _optionalChain([options, 'optionalAccess', _150 => _150.exactUrlOnly]) ? [url] : buildCandidateUrls(url);
|
|
645
|
+
for (const candidateUrl of candidateUrls) {
|
|
646
|
+
try {
|
|
647
|
+
const response = await fetch(candidateUrl, {
|
|
648
|
+
method,
|
|
649
|
+
headers,
|
|
650
|
+
body: _optionalChain([options, 'optionalAccess', _151 => _151.body]) !== void 0 ? JSON.stringify(options.body) : void 0,
|
|
651
|
+
signal: _optionalChain([options, 'optionalAccess', _152 => _152.signal])
|
|
652
|
+
});
|
|
653
|
+
if (!response.ok) {
|
|
654
|
+
const body = await response.text();
|
|
655
|
+
const parsed = parseResponseBody(body);
|
|
656
|
+
if (response.status === 401 && !isProviderOriginatedHttpError(parsed)) {
|
|
657
|
+
throw new (0, _chunkALJJRZNJjs.AuthError)(_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status));
|
|
658
|
+
}
|
|
659
|
+
const htmlError = detectHtmlErrorBody(
|
|
660
|
+
body,
|
|
661
|
+
response.headers.get("content-type")
|
|
662
|
+
);
|
|
663
|
+
if (htmlError) {
|
|
664
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
665
|
+
htmlError.message(response.status),
|
|
666
|
+
response.status,
|
|
667
|
+
"API_ERROR",
|
|
668
|
+
{
|
|
669
|
+
htmlErrorPage: true,
|
|
670
|
+
...htmlError.title ? { title: htmlError.title } : {},
|
|
671
|
+
...htmlError.workerThrewException ? { workerThrewException: true } : {}
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
676
|
+
_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status),
|
|
677
|
+
response.status,
|
|
678
|
+
_chunkXNYIZMNQjs.apiErrorCodeFromResponse.call(void 0, parsed),
|
|
679
|
+
{ response: parsed }
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
if (!response.body) {
|
|
683
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)("SSE response did not include a body.");
|
|
684
|
+
}
|
|
685
|
+
yield* decodeSseStream(response.body);
|
|
686
|
+
return;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (error instanceof _chunkALJJRZNJjs.AuthError || error instanceof _chunkDIAWYWT5js.DeeplineError) {
|
|
689
|
+
throw error;
|
|
690
|
+
}
|
|
691
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
692
|
+
if (isAbortLikeError(normalized) && _optionalChain([options, 'optionalAccess', _153 => _153.signal, 'optionalAccess', _154 => _154.aborted])) {
|
|
693
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
694
|
+
`Stream from ${this.config.baseUrl} was aborted by the caller.`,
|
|
695
|
+
void 0,
|
|
696
|
+
"ABORTED"
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
lastError = normalized;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (lastError && isAbortLikeError(lastError)) {
|
|
703
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
704
|
+
withCoworkNetworkHint(
|
|
705
|
+
`Unable to stream from ${this.config.baseUrl}. The remote stream was interrupted.`
|
|
706
|
+
),
|
|
707
|
+
void 0,
|
|
708
|
+
"PLAY_STREAM_NETWORK_ABORTED"
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
throw new (0, _chunkDIAWYWT5js.DeeplineError)(
|
|
712
|
+
withCoworkNetworkHint(
|
|
713
|
+
_optionalChain([lastError, 'optionalAccess', _155 => _155.message]) ? `Unable to stream from ${this.config.baseUrl}. ${lastError.message}` : `Unable to stream from ${this.config.baseUrl}.`
|
|
714
|
+
)
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Send a POST request with a JSON body.
|
|
719
|
+
*
|
|
720
|
+
* @typeParam T - Expected response body type
|
|
721
|
+
* @param path - API path
|
|
722
|
+
* @param body - Request body (will be JSON-serialized)
|
|
723
|
+
*/
|
|
724
|
+
async post(path, body, headers, options) {
|
|
725
|
+
return this.request(path, {
|
|
726
|
+
method: "POST",
|
|
727
|
+
body,
|
|
728
|
+
headers,
|
|
729
|
+
...options
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
async postFormData(path, formData, headers) {
|
|
733
|
+
return this.request(path, {
|
|
734
|
+
method: "POST",
|
|
735
|
+
formData,
|
|
736
|
+
headers
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Send a PATCH request with a JSON body.
|
|
741
|
+
*
|
|
742
|
+
* @typeParam T - Expected response body type
|
|
743
|
+
* @param path - API path
|
|
744
|
+
* @param body - JSON-serializable request body
|
|
745
|
+
*/
|
|
746
|
+
async patch(path, body, headers) {
|
|
747
|
+
return this.request(path, {
|
|
748
|
+
method: "PATCH",
|
|
749
|
+
body,
|
|
750
|
+
headers
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
async put(path, body, headers) {
|
|
754
|
+
return this.request(path, { method: "PUT", body, headers });
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Send a DELETE request.
|
|
758
|
+
*
|
|
759
|
+
* @typeParam T - Expected response body type
|
|
760
|
+
* @param path - API path
|
|
761
|
+
*/
|
|
762
|
+
async delete(path) {
|
|
763
|
+
return this.request(path, { method: "DELETE" });
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
function parseResponseBody(body) {
|
|
767
|
+
try {
|
|
768
|
+
return JSON.parse(body);
|
|
769
|
+
} catch (e3) {
|
|
770
|
+
return body;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function isProviderOriginatedHttpError(parsed) {
|
|
774
|
+
const response = asRecord(parsed);
|
|
775
|
+
const error = asRecord(_optionalChain([response, 'optionalAccess', _156 => _156.error]));
|
|
776
|
+
const failureOrigin = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _157 => _157.failure_origin]), () => ( _optionalChain([response, 'optionalAccess', _158 => _158.failure_origin])));
|
|
777
|
+
const code = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _159 => _159.code]), () => ( _optionalChain([response, 'optionalAccess', _160 => _160.code])));
|
|
778
|
+
return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
|
|
779
|
+
}
|
|
780
|
+
function isMonitorRateLimitEnvelope(parsed) {
|
|
781
|
+
const response = asRecord(parsed);
|
|
782
|
+
const error = asRecord(_optionalChain([response, 'optionalAccess', _161 => _161.error]));
|
|
783
|
+
return (_optionalChain([error, 'optionalAccess', _162 => _162.code]) === "monitor_upstream_rate_limited" || _optionalChain([error, 'optionalAccess', _163 => _163.code]) === "monitor_preview_rate_limited") && typeof error.message === "string";
|
|
784
|
+
}
|
|
785
|
+
function asRecord(value) {
|
|
786
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
787
|
+
}
|
|
788
|
+
function isRetryableApiErrorResponse(status) {
|
|
789
|
+
return status === 408 || status === 425 || status >= 500 && status < 600;
|
|
790
|
+
}
|
|
791
|
+
function detectHtmlErrorBody(body, contentType) {
|
|
792
|
+
const trimmed = body.trim();
|
|
793
|
+
const lower = trimmed.toLowerCase();
|
|
794
|
+
const isHtml = (_nullishCoalesce(contentType, () => ( ""))).toLowerCase().includes("text/html") || lower.startsWith("<!doctype") || lower.startsWith("<html");
|
|
795
|
+
if (!isHtml) {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
const titleMatch = trimmed.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
799
|
+
const title = _optionalChain([titleMatch, 'optionalAccess', _164 => _164[1], 'optionalAccess', _165 => _165.replace, 'call', _166 => _166(/\s+/g, " "), 'access', _167 => _167.trim, 'call', _168 => _168()]) || void 0;
|
|
800
|
+
const workerThrewException = /worker threw exception/i.test(trimmed);
|
|
801
|
+
return {
|
|
802
|
+
title,
|
|
803
|
+
workerThrewException,
|
|
804
|
+
message: (status) => {
|
|
805
|
+
const segments = [`HTTP ${status}`];
|
|
806
|
+
if (workerThrewException) {
|
|
807
|
+
segments.push("Worker threw exception");
|
|
808
|
+
}
|
|
809
|
+
if (title) {
|
|
810
|
+
segments.push(title);
|
|
811
|
+
}
|
|
812
|
+
return `${segments.join(": ")} (Cloudflare HTML error page suppressed)`;
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function parseRetryAfter(response) {
|
|
817
|
+
return _nullishCoalesce(parseOptionalRetryAfter(response), () => ( 5e3));
|
|
818
|
+
}
|
|
819
|
+
function parseOptionalRetryAfter(response) {
|
|
820
|
+
const header = response.headers.get("retry-after");
|
|
821
|
+
if (header) {
|
|
822
|
+
const seconds = Number(header);
|
|
823
|
+
if (Number.isFinite(seconds) && seconds > 0) {
|
|
824
|
+
return seconds * 1e3;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
function buildCandidateUrls(url) {
|
|
830
|
+
try {
|
|
831
|
+
const parsed = new URL(url);
|
|
832
|
+
const candidates = [url];
|
|
833
|
+
if (parsed.hostname === "localhost") {
|
|
834
|
+
const loopback = new URL(url);
|
|
835
|
+
loopback.hostname = "127.0.0.1";
|
|
836
|
+
candidates.push(loopback.toString());
|
|
837
|
+
}
|
|
838
|
+
return [...new Set(candidates)];
|
|
839
|
+
} catch (e4) {
|
|
840
|
+
return [url];
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
async function* decodeSseStream(body) {
|
|
844
|
+
const reader = body.getReader();
|
|
845
|
+
const decoder = new TextDecoder();
|
|
846
|
+
let buffered = "";
|
|
847
|
+
try {
|
|
848
|
+
while (true) {
|
|
849
|
+
const { value, done } = await reader.read();
|
|
850
|
+
if (done) break;
|
|
851
|
+
buffered += decoder.decode(value, { stream: true });
|
|
852
|
+
const frames = buffered.split(/\r?\n\r?\n/);
|
|
853
|
+
buffered = _nullishCoalesce(frames.pop(), () => ( ""));
|
|
854
|
+
for (const frame of frames) {
|
|
855
|
+
const event2 = decodeSseFrame(frame);
|
|
856
|
+
if (event2) {
|
|
857
|
+
yield event2;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
buffered += decoder.decode();
|
|
862
|
+
const event = decodeSseFrame(buffered);
|
|
863
|
+
if (event) {
|
|
864
|
+
yield event;
|
|
865
|
+
}
|
|
866
|
+
} finally {
|
|
867
|
+
reader.releaseLock();
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
function decodeSseFrame(frame) {
|
|
871
|
+
const data = frame.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trimStart()).join("\n").trim();
|
|
872
|
+
if (!data) {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
const parsed = JSON.parse(data);
|
|
876
|
+
if (!parsed || typeof parsed !== "object" || typeof parsed.cursor !== "string" || typeof parsed.streamId !== "string" || typeof parsed.scope !== "string" || typeof parsed.type !== "string" || typeof parsed.at !== "string") {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
return parsed;
|
|
880
|
+
}
|
|
881
|
+
function sleep(ms, signal) {
|
|
882
|
+
return new Promise((resolve, reject) => {
|
|
883
|
+
if (_optionalChain([signal, 'optionalAccess', _169 => _169.aborted])) {
|
|
884
|
+
reject(requestCancelledError(signal));
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const timeoutId = setTimeout(() => {
|
|
888
|
+
_optionalChain([signal, 'optionalAccess', _170 => _170.removeEventListener, 'call', _171 => _171("abort", abort)]);
|
|
889
|
+
resolve();
|
|
890
|
+
}, ms);
|
|
891
|
+
const abort = () => {
|
|
892
|
+
clearTimeout(timeoutId);
|
|
893
|
+
_optionalChain([signal, 'optionalAccess', _172 => _172.removeEventListener, 'call', _173 => _173("abort", abort)]);
|
|
894
|
+
reject(requestCancelledError(signal));
|
|
895
|
+
};
|
|
896
|
+
_optionalChain([signal, 'optionalAccess', _174 => _174.addEventListener, 'call', _175 => _175("abort", abort, { once: true })]);
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
function withCoworkNetworkHint(message) {
|
|
900
|
+
if (!isCoworkLikeSandbox() || message.includes(COWORK_NETWORK_HINT)) {
|
|
901
|
+
return message;
|
|
902
|
+
}
|
|
903
|
+
return `${message}
|
|
904
|
+
${COWORK_NETWORK_HINT}`;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
exports.ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER = ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER; exports.SDK_VERSION = SDK_VERSION; exports.SDK_API_MAJOR = SDK_API_MAJOR; exports.SDK_API_CONTRACT = SDK_API_CONTRACT; exports.COORDINATOR_INTERNAL_TOKEN_HEADER = COORDINATOR_INTERNAL_TOKEN_HEADER; exports.RUNTIME_ENVIRONMENT_TOKEN_HEADER = RUNTIME_ENVIRONMENT_TOKEN_HEADER; exports.RETAINED_PIPELINE_RECEIVERS_HEADER = RETAINED_PIPELINE_RECEIVERS_HEADER; exports.agentSessionIdFromEnvironment = agentSessionIdFromEnvironment; exports.detectAgentRuntime = detectAgentRuntime; exports.deploymentProtectionHeaders = deploymentProtectionHeaders; exports.fetchWithDeploymentProtection = fetchWithDeploymentProtection; exports.HttpClient = HttpClient;
|