deepline 0.3.535 → 0.3.536
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 +232 -147
- package/dist/bundling-sources/sdk/src/index.ts +4 -0
- package/dist/bundling-sources/sdk/src/plays/local-file-discovery.ts +27 -1
- package/dist/bundling-sources/sdk/src/plays/run-request.ts +16 -5
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +2 -23
- package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +26 -14
- package/dist/bundling-sources/shared_libs/integration-contracts/monitor-input-contract.ts +33 -8
- package/dist/bundling-sources/shared_libs/monitors/fleets/count-drift-alert.ts +121 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +14 -82
- package/dist/bundling-sources/shared_libs/monitors/package.json +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +4 -4
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +0 -26
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +36 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +21 -31
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +88 -96
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +12 -10
- package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +3 -1
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +71 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +127 -9
- package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +15 -2
- package/dist/bundling-sources/shared_libs/play-runtime/prebuilt-result-quality.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +41 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +5 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +8 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +31 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +11 -4
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +73 -18
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +169 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +26 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +84 -49
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +37 -32
- package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +13 -1
- package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +68 -1
- package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +57 -1
- package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +22 -9
- package/dist/cli/auth-6XQKFOLG.js +43 -0
- package/dist/cli/{auth-ZCTMB5RA.mjs → auth-KCTCUO7P.mjs} +7 -7
- package/dist/cli/{billing-GVFKZQH3.js → billing-4VBGZ3CT.js} +273 -112
- package/dist/cli/{billing-OU2ZHL72.mjs → billing-OOJHKLNS.mjs} +185 -24
- package/dist/cli/{chunk-FGN75ZN6.js → chunk-2B4IOGFD.js} +390 -382
- package/dist/cli/{chunk-KOZBZPRM.js → chunk-2FCSUOYN.js} +55 -55
- package/dist/cli/{chunk-T2N3B7IQ.js → chunk-2GJZLIKW.js} +8 -8
- package/dist/cli/{chunk-AUEUAPVS.mjs → chunk-2YWJS76L.mjs} +1 -1
- package/dist/cli/{chunk-W5YJYU4G.mjs → chunk-3PCYV6ZJ.mjs} +2 -2
- package/dist/cli/{chunk-UUQ2OXMH.js → chunk-4E5JXZ3W.js} +18 -20
- package/dist/cli/{chunk-R4RG4FV5.mjs → chunk-4KWD3MX2.mjs} +13 -10
- package/dist/cli/{chunk-XSOTEVOB.js → chunk-6BBGUQJJ.js} +50 -141
- package/dist/cli/{chunk-PHLNYBAA.js → chunk-6VUGBQZQ.js} +5 -5
- package/dist/cli/{chunk-G2DLG32W.mjs → chunk-AB2GBOD4.mjs} +40 -27
- package/dist/cli/{chunk-JWWYLGUT.mjs → chunk-ANUKBZ6W.mjs} +475 -11
- package/dist/cli/{chunk-FZKPPB5P.mjs → chunk-BASLYGXK.mjs} +85 -77
- package/dist/cli/{chunk-SQWET4SL.js → chunk-BBTKAASQ.js} +2 -1
- package/dist/cli/{chunk-NRO3NTVO.js → chunk-CBV7AKWM.js} +5 -5
- package/dist/cli/{chunk-PI5R65OQ.js → chunk-CIDN5K23.js} +1 -1
- package/dist/cli/{chunk-QNHHZ63P.mjs → chunk-CQBIO6HW.mjs} +1 -1
- package/dist/cli/{chunk-2KHUFWTK.js → chunk-CQDQNZGH.js} +42 -37
- package/dist/cli/{chunk-D4MHCCIR.js → chunk-CWSLUNA6.js} +33 -33
- package/dist/cli/{chunk-E3CLOVG5.mjs → chunk-CXTW7SRW.mjs} +50 -141
- package/dist/cli/{chunk-H6SWS5CG.mjs → chunk-DA2I2M7D.mjs} +2 -2
- package/dist/cli/{chunk-WAIBM6KX.mjs → chunk-DQHUJMCL.mjs} +5 -5
- package/dist/cli/{chunk-DWPY6ZID.mjs → chunk-DUYAMLOC.mjs} +1 -1
- package/dist/cli/{chunk-K53NKWZO.mjs → chunk-E24UGPGG.mjs} +13 -15
- package/dist/cli/{chunk-STR5LXK4.mjs → chunk-FSIVF2SI.mjs} +1 -1
- package/dist/cli/{chunk-7R5DAANG.mjs → chunk-GF32SBST.mjs} +1 -1
- package/dist/cli/{chunk-7CWSAEYS.mjs → chunk-GHLDCLSC.mjs} +1 -1
- package/dist/cli/{chunk-ZUVE63Y7.js → chunk-GTVZKY3F.js} +2 -2
- package/dist/cli/{chunk-J75DANZY.mjs → chunk-HAJQGP5V.mjs} +2 -2
- package/dist/cli/{chunk-RFQWSH6I.js → chunk-HWDKRN7L.js} +3 -3
- package/dist/cli/{chunk-5YAJGRWB.js → chunk-IPVRMYWT.js} +7 -7
- package/dist/cli/{chunk-ZPGGW27Q.mjs → chunk-JL2OTMSG.mjs} +1 -0
- package/dist/cli/{chunk-K76AEBFY.mjs → chunk-JUHDJNSI.mjs} +4 -4
- package/dist/cli/{chunk-R2KKEHJN.mjs → chunk-KPQHUVYW.mjs} +5 -5
- package/dist/cli/{chunk-6LHX33VN.js → chunk-KWYGWO4Y.js} +9 -6
- package/dist/cli/{chunk-7PXP2FQK.js → chunk-LDGZFDUB.js} +2 -2
- package/dist/cli/{chunk-KWGXHPHL.js → chunk-LN6RXDTB.js} +523 -59
- package/dist/cli/{chunk-TCVCFZP6.mjs → chunk-LZXZQPA2.mjs} +4 -1
- package/dist/cli/{chunk-2D6SWQTK.js → chunk-MSP4DTSD.js} +13 -13
- package/dist/cli/{chunk-BNH4Y35W.mjs → chunk-OLH2PHMC.mjs} +2 -2
- package/dist/cli/{chunk-QYBAHYP4.mjs → chunk-OUDTOMZC.mjs} +7 -9
- package/dist/cli/{chunk-GESIFFQX.mjs → chunk-OVX3Q5Q3.mjs} +1 -1
- package/dist/cli/{chunk-6TYRRNXY.mjs → chunk-PNY3BWHP.mjs} +2 -2
- package/dist/cli/{chunk-DYIWDUY4.js → chunk-Q4MNUOS4.js} +316 -303
- package/dist/cli/{chunk-5EKNDNFQ.js → chunk-Q5CXV3E3.js} +2 -2
- package/dist/cli/{chunk-W6T23EUC.mjs → chunk-RVSSQPQO.mjs} +1 -1
- package/dist/cli/{chunk-WNNA4L6Z.js → chunk-SLPJ3LXI.js} +22 -22
- package/dist/cli/{chunk-K3IPGMGP.js → chunk-TX5TUHJN.js} +17 -19
- package/dist/cli/{chunk-IF75RD6U.js → chunk-U2LVWCTD.js} +18 -6
- package/dist/cli/{chunk-ZS2WHWWL.js → chunk-UNDLNT3V.js} +1 -1
- package/dist/cli/{chunk-4NLRWKZB.js → chunk-VBDZIMWD.js} +26 -26
- package/dist/cli/{chunk-DAPKLYST.js → chunk-W7AEIGZR.js} +41 -41
- package/dist/cli/{chunk-LVISZFYO.mjs → chunk-WC5M3JXE.mjs} +2 -2
- package/dist/cli/{chunk-C374C22Y.js → chunk-WOQO3GV4.js} +14 -11
- package/dist/cli/{chunk-243O3FH5.js → chunk-XBAH3TKU.js} +5 -5
- package/dist/cli/{chunk-DFJODFMC.mjs → chunk-XJD2GYUP.mjs} +5 -5
- package/dist/cli/{chunk-BF65LB7X.mjs → chunk-XVZRJJDS.mjs} +4 -4
- package/dist/cli/{chunk-OM732MGV.js → chunk-Y2NTPYGS.js} +17 -17
- package/dist/cli/{chunk-YFZLZNTH.mjs → chunk-YBMHOH6H.mjs} +4 -4
- package/dist/cli/{chunk-RKY4LBX3.mjs → chunk-YRLAUGQY.mjs} +3 -3
- package/dist/cli/{chunk-FKD3KL5Q.mjs → chunk-Z2XA6YU4.mjs} +10 -5
- package/dist/cli/{chunk-JQQG4QL4.mjs → chunk-Z7UIOGW4.mjs} +3 -3
- package/dist/cli/{chunk-HYBZWSSH.js → chunk-ZEV2Y56V.js} +44 -44
- package/dist/cli/{chunk-MI6ZP7XI.mjs → chunk-ZG7BOECV.mjs} +18 -6
- package/dist/cli/{chunk-HWPOXCCK.js → chunk-ZILSRDIN.js} +8 -8
- package/dist/cli/{chunk-CIDATNTY.js → chunk-ZISEH7OL.js} +16 -16
- package/dist/cli/{chunk-KA6ZERJL.js → chunk-ZZ4MF2GI.js} +6 -6
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-CD55KEIO.js → csv-2V2DIFNG.js} +15 -15
- package/dist/cli/{csv-CLPVMIRF.mjs → csv-P3HLK4GO.mjs} +6 -6
- package/dist/cli/{db-MQKLDAEO.js → db-MREAQVW6.js} +36 -36
- package/dist/cli/{db-AU4SMWUN.mjs → db-ZYOY3QRQ.mjs} +9 -9
- package/dist/cli/describe-IKZFOADR.mjs +49 -0
- package/dist/cli/describe-WW3OQRLP.js +49 -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 +5 -5
- package/dist/cli/describe-core.mjs +4 -4
- package/dist/cli/{executions-77GOLWRM.js → executions-H5IJ7QSQ.js} +11 -11
- package/dist/cli/{executions-TFIJPUX7.mjs → executions-KTSY5M34.mjs} +9 -9
- package/dist/cli/{feedback-OV5YAL3A.js → feedback-724QK3Z5.js} +16 -16
- package/dist/cli/{feedback-2WRSZ5WL.mjs → feedback-WWJRIXEU.mjs} +8 -8
- package/dist/cli/git-PHYRD56H.js +25 -0
- package/dist/cli/{git-VNS4ATLZ.mjs → git-R5VRG7X6.mjs} +7 -7
- package/dist/cli/index.js +151 -157
- package/dist/cli/index.mjs +51 -57
- package/dist/cli/{legacy-noops-HDOB5C6F.js → legacy-noops-C6GDEGPU.js} +11 -11
- package/dist/cli/{legacy-noops-C732QDCY.mjs → legacy-noops-PWZ5XLAO.mjs} +8 -8
- package/dist/cli/{monitors-5IUMHH3E.js → monitors-VAVQ4WCE.js} +125 -122
- package/dist/cli/{monitors-2LYEFXOU.mjs → monitors-WQSKMHAP.mjs} +19 -16
- package/dist/cli/{org-ADW2EVAC.js → org-CWWRWXZQ.js} +89 -89
- package/dist/cli/{org-G4YGZPHS.mjs → org-MAL4QPVF.mjs} +9 -9
- package/dist/cli/{play-7GQ56C2D.mjs → play-ILW6MSNG.mjs} +123 -76
- package/dist/cli/{play-EHSOSSHT.js → play-WJOWK5PQ.js} +641 -594
- package/dist/cli/{providers-WL3YTCSV.mjs → providers-4V2NMLZZ.mjs} +9 -9
- package/dist/cli/{providers-PWCF6OOO.js → providers-W662ANCH.js} +12 -12
- package/dist/cli/{quickstart-ZKI5MURA.js → quickstart-BW6EBUYX.js} +8 -8
- package/dist/cli/{quickstart-323XOPGI.mjs → quickstart-C22BR743.mjs} +6 -6
- package/dist/cli/{run-XZPWA6JS.js → run-KW7KW4FX.js} +50 -53
- package/dist/cli/{run-ZCNZU3K2.mjs → run-SPAU5IMW.mjs} +31 -34
- package/dist/cli/search-HLE54W5G.js +32 -0
- package/dist/cli/{search-CVLVSFMJ.mjs → search-XPC75HLM.mjs} +10 -11
- package/dist/cli/{search-output-6PY6RN2R.mjs → search-output-JKYJSEPM.mjs} +6 -6
- package/dist/cli/{search-output-7HRSSRBS.js → search-output-VJYE7USJ.js} +8 -8
- package/dist/cli/{secrets-6S2ZWDIM.mjs → secrets-OJG73GXQ.mjs} +9 -9
- package/dist/cli/{secrets-IYD5VKY4.js → secrets-YB57KGSB.js} +18 -18
- package/dist/cli/{sessions-GVEX5TUJ.mjs → sessions-7ZL37BW4.mjs} +8 -8
- package/dist/cli/sessions-VEBYZIEU.js +22 -0
- package/dist/cli/{settings-CANK4HJQ.js → settings-A7DD2ZYE.js} +88 -89
- package/dist/cli/{settings-BN5MJZ3C.mjs → settings-RKSQB7FA.mjs} +15 -16
- package/dist/cli/{setup-JNMSCCU4.mjs → setup-NXDUTITY.mjs} +11 -12
- package/dist/cli/{setup-YSGKGLSJ.js → setup-S3K5YU62.js} +51 -52
- package/dist/cli/skills-NVQ744CN.js +36 -0
- package/dist/cli/{skills-QCQN2UM2.mjs → skills-VMFAIDO6.mjs} +9 -10
- package/dist/cli/{tools-CDPOID7V.mjs → tools-52NTHBSJ.mjs} +20 -21
- package/dist/cli/tools-SBDUL3WB.js +56 -0
- package/dist/cli/update-HHVFZPCV.js +34 -0
- package/dist/cli/{update-D3ZERUQ3.mjs → update-SAKBEKMV.mjs} +11 -12
- package/dist/cli/{views-RDZRWQBQ.mjs → views-ACRV7MD6.mjs} +54 -10
- package/dist/cli/{views-4NV2KQKA.js → views-C3GJOBDG.js} +66 -22
- package/dist/cli/{workflow-2CG3TVCG.mjs → workflow-CS22E7TC.mjs} +10 -10
- package/dist/cli/{workflow-RABJCAZC.js → workflow-ZNWCZEGN.js} +20 -20
- package/dist/{client-DhSvMO3A.d.mts → client-BlLYQDNo.d.mts} +1 -1
- package/dist/{client-oGNJMQFd.d.ts → client-DSQlkIDO.d.ts} +1 -1
- package/dist/{client-core-CdWH6Sii.d.ts → client-core-CDwapXy5.d.ts} +159 -108
- package/dist/{client-core-CVG1Et-4.d.mts → client-core-rX7n2H8U.d.mts} +159 -108
- package/dist/{compiler-manifest-D2ZlBGxj.d.ts → compiler-manifest-BHNC4RL-.d.mts} +15 -22
- package/dist/{compiler-manifest-D2ZlBGxj.d.mts → compiler-manifest-BHNC4RL-.d.ts} +15 -22
- package/dist/{errors-B-gOQdj-.d.mts → errors-D7sPXrvB.d.mts} +1 -1
- package/dist/{errors-CB0KAmmV.d.ts → errors-lhtIWG5Z.d.ts} +1 -1
- package/dist/{index-c3nvUGCS.d.ts → index-CQTBHXHr.d.ts} +1 -1
- package/dist/{index-BbJADro4.d.mts → index-NaDZq2xf.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +15 -15
- package/dist/index.mjs +11 -11
- package/dist/install-integrity.json +129 -132
- package/dist/monitor-fleet-contract.d.mts +17 -11
- package/dist/monitor-fleet-contract.d.ts +17 -11
- package/dist/monitor-fleet-contract.js +3 -3
- package/dist/monitor-fleet-contract.mjs +2 -2
- package/dist/monitor-input-contract.js +2 -2
- package/dist/monitor-input-contract.mjs +1 -1
- 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 +17 -5
- 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 +3 -3
- package/dist/plays/run-request.mjs +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 +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +12 -12
- package/dist/server.mjs +6 -6
- package/package.json +1 -1
- package/dist/cli/auth-VDCU3T6A.js +0 -43
- package/dist/cli/chunk-4QELPWUW.mjs +0 -405
- package/dist/cli/chunk-T7RBM2WX.js +0 -405
- package/dist/cli/describe-5BFNHT5V.js +0 -50
- package/dist/cli/describe-AWJUXE2U.mjs +0 -50
- package/dist/cli/git-HGMX52XU.js +0 -25
- package/dist/cli/pages-KXKWSCEV.mjs +0 -266
- package/dist/cli/pages-VTJGAI2D.js +0 -266
- package/dist/cli/search-J6EY7DQN.js +0 -33
- package/dist/cli/sessions-7HPIVSQ4.js +0 -22
- package/dist/cli/skills-WDGSSKJZ.js +0 -37
- package/dist/cli/tools-URNVXSTZ.js +0 -57
- package/dist/cli/update-Q6JW32IA.js +0 -35
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpClient,
|
|
3
|
+
autoDetectBaseUrl,
|
|
4
|
+
resolveApiKeyForBaseUrl,
|
|
3
5
|
resolveCliCommandContext,
|
|
4
6
|
resolveConfig
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3PCYV6ZJ.mjs";
|
|
6
8
|
import {
|
|
9
|
+
SDK_VERSION,
|
|
10
|
+
agentSessionIdFromEnvironment,
|
|
11
|
+
deploymentProtectionHeaders,
|
|
7
12
|
detectAgentRuntime
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-YRLAUGQY.mjs";
|
|
9
14
|
import {
|
|
10
15
|
DeeplineError,
|
|
16
|
+
normalizeToolExecutionFailure,
|
|
11
17
|
readToolUpstreamResponse,
|
|
12
18
|
serializeToolExecutionFailure
|
|
13
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JL2OTMSG.mjs";
|
|
14
20
|
|
|
15
21
|
// src/cli/json-fields.ts
|
|
16
22
|
var RUN_FIELDS = new Set(
|
|
@@ -186,6 +192,388 @@ function withJsonNotices(value) {
|
|
|
186
192
|
return { ...record, notices };
|
|
187
193
|
}
|
|
188
194
|
|
|
195
|
+
// src/cli/failure-reporting.ts
|
|
196
|
+
import { hostname, platform, release } from "os";
|
|
197
|
+
var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";
|
|
198
|
+
var REPORT_FAILURE_TIMEOUT_MS = 1e4;
|
|
199
|
+
var BACKGROUND_REPORT_FAILURE_TIMEOUT_MS = 2e3;
|
|
200
|
+
var MAX_FAILURE_TEXT_CHARS = 4e3;
|
|
201
|
+
var MAX_COMMAND_TOKENS = 3;
|
|
202
|
+
var REPORTABLE_EXIT_CODES = /* @__PURE__ */ new Set([4, 5]);
|
|
203
|
+
var EMAIL_RE = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
204
|
+
var UNIX_PATH_RE = /(?:\/Users\/|\/home\/|\/var\/folders\/|\/tmp\/|\/sessions\/)[^"'\n\r`]+/g;
|
|
205
|
+
var WINDOWS_PATH_RE = /[A-Za-z]:(?:\\{1,2})(?:Users|Temp|tmp)(?:\\{1,2})[^"'\n\r`]+/g;
|
|
206
|
+
var ASSIGNMENT_SECRET_RE = /\b(access[_-]?token|api[_-]?key|apikey|auth(?:orization)?|bearer|password|secret|session)\b(\s*[:=]\s*)(?!Bearer\s+\[redacted-secret\])([^\s,;]+)/gi;
|
|
207
|
+
var BEARER_SECRET_RE = /\b(bearer)\s+([A-Za-z0-9._-]+)/gi;
|
|
208
|
+
var GENERIC_TOKEN_RE = /\b(?:dlp|sk|ghp|xox[baprs])[-_A-Za-z0-9]{8,}\b/g;
|
|
209
|
+
var SECRET_OPTION_RE = /^--?(?:access[-_]?token|api[-_]?key|apikey|auth(?:orization)?|bearer|password|secret|session|token)$/i;
|
|
210
|
+
function truthyEnv(name) {
|
|
211
|
+
return ["1", "true", "yes", "on"].includes(
|
|
212
|
+
String(process.env[name] ?? "").trim().toLowerCase()
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
function isFailureReportingDisabled() {
|
|
216
|
+
return truthyEnv(FAILURE_REPORT_DISABLE_ENV);
|
|
217
|
+
}
|
|
218
|
+
function redactFailureText(value, maxChars = MAX_FAILURE_TEXT_CHARS) {
|
|
219
|
+
const home = process.env.HOME?.trim();
|
|
220
|
+
let text = String(value ?? "");
|
|
221
|
+
if (!text) return "";
|
|
222
|
+
if (home && home !== "/") {
|
|
223
|
+
text = text.split(home).join("~");
|
|
224
|
+
}
|
|
225
|
+
return text.replace(EMAIL_RE, "[redacted-email]").replace(UNIX_PATH_RE, "[redacted-path]").replace(WINDOWS_PATH_RE, "[redacted-path]").replace(BEARER_SECRET_RE, "$1 [redacted-secret]").replace(ASSIGNMENT_SECRET_RE, "$1$2[redacted-secret]").replace(GENERIC_TOKEN_RE, "[redacted-secret]").slice(0, maxChars);
|
|
226
|
+
}
|
|
227
|
+
function sanitizeCommand(argv, prefix = "deepline") {
|
|
228
|
+
const tokens = [];
|
|
229
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
230
|
+
const arg = argv[index];
|
|
231
|
+
const value = String(arg ?? "").trim();
|
|
232
|
+
if (!value) continue;
|
|
233
|
+
if (value.startsWith("-")) {
|
|
234
|
+
if (!value.includes("=") && SECRET_OPTION_RE.test(value)) {
|
|
235
|
+
index += 1;
|
|
236
|
+
}
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
tokens.push(redactFailureText(value, 200));
|
|
240
|
+
if (tokens.length >= MAX_COMMAND_TOKENS) break;
|
|
241
|
+
}
|
|
242
|
+
return tokens.length > 0 ? [prefix, ...tokens].join(" ") : prefix;
|
|
243
|
+
}
|
|
244
|
+
function errorMessage(error) {
|
|
245
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
246
|
+
return String(error ?? "");
|
|
247
|
+
}
|
|
248
|
+
function errorStack(error) {
|
|
249
|
+
if (error instanceof Error && error.stack) {
|
|
250
|
+
return redactFailureText(error.stack);
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
function classifyNetworkFailure(error) {
|
|
255
|
+
const seen = /* @__PURE__ */ new Set();
|
|
256
|
+
let current = error;
|
|
257
|
+
while (current && !seen.has(current)) {
|
|
258
|
+
seen.add(current);
|
|
259
|
+
const record = typeof current === "object" && current !== null ? current : {};
|
|
260
|
+
const code = String(record.code ?? "").toLowerCase();
|
|
261
|
+
const name = current instanceof Error ? current.name.toLowerCase() : "";
|
|
262
|
+
const text = String(
|
|
263
|
+
current instanceof Error ? current.message : current
|
|
264
|
+
).toLowerCase();
|
|
265
|
+
const combined = `${code} ${name} ${text}`;
|
|
266
|
+
if (combined.includes("aborterror") || combined.includes("timeout") || combined.includes("timed out") || combined.includes("etimedout")) {
|
|
267
|
+
return "network_timeout";
|
|
268
|
+
}
|
|
269
|
+
if (combined.includes("enotfound") || combined.includes("eai_again") || combined.includes("getaddrinfo") || combined.includes("name or service not known") || combined.includes("temporary failure in name resolution")) {
|
|
270
|
+
return "network_dns_resolution_failed";
|
|
271
|
+
}
|
|
272
|
+
if (combined.includes("econnrefused") || combined.includes("connection refused")) {
|
|
273
|
+
return "network_connection_refused";
|
|
274
|
+
}
|
|
275
|
+
if (combined.includes("econnreset") || combined.includes("connection reset")) {
|
|
276
|
+
return "network_connection_reset";
|
|
277
|
+
}
|
|
278
|
+
if (combined.includes("incompleteread") || combined.includes("incomplete read")) {
|
|
279
|
+
return "network_incomplete_read";
|
|
280
|
+
}
|
|
281
|
+
if (combined.includes("remotedisconnected") || combined.includes("remote end closed connection") || combined.includes("other side closed") || combined.includes("socket hang up")) {
|
|
282
|
+
return "network_remote_disconnected";
|
|
283
|
+
}
|
|
284
|
+
if (
|
|
285
|
+
// Local filenames and retry commands may contain "ssl" or "tls".
|
|
286
|
+
// Require a transport identifier or protocol failure text instead.
|
|
287
|
+
code.includes("ssl") || code.includes("tls") || name.includes("ssl") || name.includes("tls") || /(?:^|[\s[(:])(?:ssl|tls)[\s:_-]+(?:error|handshake|certificate|routines|connection|failed|failure)(?:$|[\s:_-])/.test(
|
|
288
|
+
text
|
|
289
|
+
) || combined.includes("unexpected_eof_while_reading")
|
|
290
|
+
) {
|
|
291
|
+
return "network_ssl_error";
|
|
292
|
+
}
|
|
293
|
+
current = record.cause ?? record.context;
|
|
294
|
+
}
|
|
295
|
+
return "network_error";
|
|
296
|
+
}
|
|
297
|
+
function classifyNetworkCauseCategory(error) {
|
|
298
|
+
const seen = /* @__PURE__ */ new Set();
|
|
299
|
+
let cause = error;
|
|
300
|
+
while (cause && typeof cause === "object" && !seen.has(cause)) {
|
|
301
|
+
seen.add(cause);
|
|
302
|
+
const record = cause;
|
|
303
|
+
if (record.code === "UND_ERR_CONNECT_TIMEOUT") return "connect_timeout";
|
|
304
|
+
cause = record.cause;
|
|
305
|
+
}
|
|
306
|
+
switch (classifyNetworkFailure(error)) {
|
|
307
|
+
case "network_dns_resolution_failed":
|
|
308
|
+
return "dns";
|
|
309
|
+
case "network_ssl_error":
|
|
310
|
+
return "tls";
|
|
311
|
+
case "network_connection_reset":
|
|
312
|
+
return "reset";
|
|
313
|
+
case "network_timeout":
|
|
314
|
+
return "timeout";
|
|
315
|
+
default:
|
|
316
|
+
return "unknown";
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function isNetworkFailure(error) {
|
|
320
|
+
if (!(error instanceof Error)) return false;
|
|
321
|
+
if (error instanceof DeeplineError && error.statusCode) return false;
|
|
322
|
+
const code = classifyNetworkFailure(error);
|
|
323
|
+
return code !== "network_error" || /unable to connect|unable to stream/i.test(error.message);
|
|
324
|
+
}
|
|
325
|
+
function buildEnvironmentContext() {
|
|
326
|
+
const context = {
|
|
327
|
+
os: platform(),
|
|
328
|
+
os_release: release(),
|
|
329
|
+
platform: `${platform()}-${release()}-${process.arch}`,
|
|
330
|
+
node_version: process.version,
|
|
331
|
+
runtime: "Node.js",
|
|
332
|
+
hostname: hostname(),
|
|
333
|
+
agent_runtime: detectAgentRuntime()
|
|
334
|
+
};
|
|
335
|
+
for (const key of ["CLAUDE_CODE_REMOTE", "DEEPLINE_PLUGIN_MODE"]) {
|
|
336
|
+
const normalized = process.env[key]?.trim();
|
|
337
|
+
if (normalized) context[key.toLowerCase()] = normalized;
|
|
338
|
+
}
|
|
339
|
+
if (process.env.CLAUDE_PROJECT_DIR?.trim()) {
|
|
340
|
+
context.claude_project_dir_present = "true";
|
|
341
|
+
}
|
|
342
|
+
if (process.env.DEEPLINE_PLUGIN_ROOT?.trim()) {
|
|
343
|
+
context.deepline_plugin_root_present = "true";
|
|
344
|
+
}
|
|
345
|
+
if (process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim()) {
|
|
346
|
+
context.deepline_plugin_skills_dir_present = "true";
|
|
347
|
+
}
|
|
348
|
+
if (process.env.HOME?.trim().startsWith("/sessions/")) {
|
|
349
|
+
context.home_scope = "sessions";
|
|
350
|
+
}
|
|
351
|
+
return context;
|
|
352
|
+
}
|
|
353
|
+
function failureReportHeaders(apiKey) {
|
|
354
|
+
const agentSessionId = agentSessionIdFromEnvironment();
|
|
355
|
+
return {
|
|
356
|
+
...deploymentProtectionHeaders(),
|
|
357
|
+
...agentSessionId ? { "X-Deepline-Agent-Session-Id": agentSessionId } : {},
|
|
358
|
+
Authorization: `Bearer ${apiKey}`,
|
|
359
|
+
"Content-Type": "application/json",
|
|
360
|
+
"User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
|
|
361
|
+
"X-Deepline-Client-Family": "sdk",
|
|
362
|
+
"X-Deepline-CLI-Family": "sdk",
|
|
363
|
+
"X-Deepline-Agent-Runtime": detectAgentRuntime(),
|
|
364
|
+
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
365
|
+
"X-Deepline-SDK-Version": SDK_VERSION
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
async function postFailureReport(input) {
|
|
369
|
+
const controller = new AbortController();
|
|
370
|
+
const timeout = setTimeout(() => controller.abort(), input.timeoutMs);
|
|
371
|
+
if (input.background) timeout.unref();
|
|
372
|
+
try {
|
|
373
|
+
await fetch(new URL("/api/v2/cli/report-failure", input.baseUrl), {
|
|
374
|
+
method: "POST",
|
|
375
|
+
headers: failureReportHeaders(input.apiKey),
|
|
376
|
+
body: JSON.stringify(input.body),
|
|
377
|
+
signal: controller.signal
|
|
378
|
+
});
|
|
379
|
+
return true;
|
|
380
|
+
} catch {
|
|
381
|
+
return false;
|
|
382
|
+
} finally {
|
|
383
|
+
clearTimeout(timeout);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
function boundedTelemetryString(value, maxChars) {
|
|
387
|
+
return redactFailureText(value.trim(), maxChars);
|
|
388
|
+
}
|
|
389
|
+
async function maybeReportAutomaticSkillsSyncFailure(input) {
|
|
390
|
+
if (isFailureReportingDisabled()) return false;
|
|
391
|
+
let apiKey = "";
|
|
392
|
+
try {
|
|
393
|
+
apiKey = resolveApiKeyForBaseUrl(input.baseUrl);
|
|
394
|
+
} catch {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
if (!apiKey) return false;
|
|
398
|
+
const attempts = input.attempts.slice(0, 2).map((attempt) => ({
|
|
399
|
+
installer: attempt.installer,
|
|
400
|
+
outcome: attempt.outcome,
|
|
401
|
+
exit_code: typeof attempt.exitCode === "number" && Number.isFinite(attempt.exitCode) ? Math.trunc(attempt.exitCode) : null
|
|
402
|
+
}));
|
|
403
|
+
const agents = input.agents.slice(0, 8).map((agent) => boundedTelemetryString(agent, 100)).filter(Boolean);
|
|
404
|
+
const baseUrl = input.baseUrl.replace(/\/$/, "");
|
|
405
|
+
const failureKind = "background_warning";
|
|
406
|
+
const failureCode2 = "SKILLS_AUTO_SYNC_FAILED";
|
|
407
|
+
const failureStage = "skills_install";
|
|
408
|
+
return postFailureReport({
|
|
409
|
+
baseUrl,
|
|
410
|
+
apiKey,
|
|
411
|
+
timeoutMs: BACKGROUND_REPORT_FAILURE_TIMEOUT_MS,
|
|
412
|
+
background: true,
|
|
413
|
+
body: {
|
|
414
|
+
command: "deepline skills",
|
|
415
|
+
subcommand: "skills",
|
|
416
|
+
failure_kind: failureKind,
|
|
417
|
+
failure_code: failureCode2,
|
|
418
|
+
failure_stage: failureStage,
|
|
419
|
+
error_body: "Automatic Deepline skills installation failed.",
|
|
420
|
+
cli_version: SDK_VERSION,
|
|
421
|
+
context: {
|
|
422
|
+
environment: buildEnvironmentContext(),
|
|
423
|
+
skills_sync: {
|
|
424
|
+
skills_package: boundedTelemetryString(input.skillsPackage, 100),
|
|
425
|
+
remote_skills_version: boundedTelemetryString(
|
|
426
|
+
input.remoteSkillsVersion,
|
|
427
|
+
200
|
|
428
|
+
),
|
|
429
|
+
agents,
|
|
430
|
+
target_skill_count: Math.max(
|
|
431
|
+
0,
|
|
432
|
+
Math.trunc(
|
|
433
|
+
Number.isFinite(input.targetSkillCount) ? input.targetSkillCount : 0
|
|
434
|
+
)
|
|
435
|
+
),
|
|
436
|
+
marker_written: input.markerWritten,
|
|
437
|
+
attempts
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function subcommandFromArgv(argv) {
|
|
444
|
+
return argv.find((arg) => arg && !arg.startsWith("-")) ?? null;
|
|
445
|
+
}
|
|
446
|
+
function commandTokens(argv) {
|
|
447
|
+
return argv.map((arg) => String(arg ?? "").trim()).filter((arg) => arg && !arg.startsWith("-"));
|
|
448
|
+
}
|
|
449
|
+
function isServerLoggedPlayRunStartFailure(input) {
|
|
450
|
+
const [subcommand, command] = commandTokens(input.argv);
|
|
451
|
+
return subcommand === "plays" && command === "run" && input.error instanceof DeeplineError && typeof input.error.statusCode === "number";
|
|
452
|
+
}
|
|
453
|
+
function shouldReport(input) {
|
|
454
|
+
if (input.error !== void 0) return true;
|
|
455
|
+
return input.exitCode !== null && REPORTABLE_EXIT_CODES.has(input.exitCode);
|
|
456
|
+
}
|
|
457
|
+
function failureCode(input) {
|
|
458
|
+
if (input.error !== void 0) {
|
|
459
|
+
if (isNetworkFailure(input.error))
|
|
460
|
+
return classifyNetworkFailure(input.error);
|
|
461
|
+
if (input.error instanceof DeeplineError && input.error.code) {
|
|
462
|
+
return input.error.code;
|
|
463
|
+
}
|
|
464
|
+
if (input.error instanceof Error && input.error.name)
|
|
465
|
+
return input.error.name;
|
|
466
|
+
return "CLI_FAILURE";
|
|
467
|
+
}
|
|
468
|
+
return input.exitCode === 4 ? "network_error" : "command_exit";
|
|
469
|
+
}
|
|
470
|
+
function resolvedExitCode(input) {
|
|
471
|
+
if (typeof input.exitCode === "number" && Number.isFinite(input.exitCode)) {
|
|
472
|
+
return Math.trunc(input.exitCode);
|
|
473
|
+
}
|
|
474
|
+
if (input.error === void 0) return null;
|
|
475
|
+
return isNetworkFailure(input.error) ? 4 : 5;
|
|
476
|
+
}
|
|
477
|
+
function resolveSdkCliFailureExitCode(error) {
|
|
478
|
+
return isNetworkFailure(error) ? 4 : 1;
|
|
479
|
+
}
|
|
480
|
+
function resolvedFailureKind(input) {
|
|
481
|
+
return input.error === void 0 ? "command_exit" : "uncaught_exception";
|
|
482
|
+
}
|
|
483
|
+
function safeRequestDiagnostics(error) {
|
|
484
|
+
if (!(error instanceof DeeplineError)) return null;
|
|
485
|
+
const request = error.details?.request;
|
|
486
|
+
if (!request || typeof request !== "object" || Array.isArray(request))
|
|
487
|
+
return null;
|
|
488
|
+
const value = request;
|
|
489
|
+
const result = {};
|
|
490
|
+
if (typeof value.phase === "string" && [
|
|
491
|
+
"before_request",
|
|
492
|
+
"retry_wait",
|
|
493
|
+
"awaiting_headers",
|
|
494
|
+
"reading_body"
|
|
495
|
+
].includes(value.phase))
|
|
496
|
+
result.phase = value.phase;
|
|
497
|
+
if (typeof value.method === "string" && /^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(value.method))
|
|
498
|
+
result.method = value.method;
|
|
499
|
+
if (typeof value.url === "string") {
|
|
500
|
+
try {
|
|
501
|
+
const url = new URL(value.url);
|
|
502
|
+
if (url.protocol === "https:" || url.protocol === "http:") {
|
|
503
|
+
result.url = redactFailureText(`${url.origin}${url.pathname}`, 1e3);
|
|
504
|
+
}
|
|
505
|
+
} catch {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (typeof value.failedAtUtc === "string" && Number.isFinite(Date.parse(value.failedAtUtc))) {
|
|
509
|
+
result.failedAtUtc = new Date(value.failedAtUtc).toISOString();
|
|
510
|
+
}
|
|
511
|
+
for (const key of ["elapsedMs", "attempts"]) {
|
|
512
|
+
const number = value[key];
|
|
513
|
+
if (typeof number === "number" && Number.isSafeInteger(number) && number >= 0)
|
|
514
|
+
result[key] = number;
|
|
515
|
+
}
|
|
516
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
517
|
+
}
|
|
518
|
+
function buildFailureReport(input) {
|
|
519
|
+
const durationMs = Math.max(0, Date.now() - input.startedAtMs);
|
|
520
|
+
const request = safeRequestDiagnostics(input.error);
|
|
521
|
+
const failureKind = resolvedFailureKind({
|
|
522
|
+
exitCode: input.exitCode,
|
|
523
|
+
error: input.error
|
|
524
|
+
});
|
|
525
|
+
const code = failureCode({ exitCode: input.exitCode, error: input.error });
|
|
526
|
+
const errorBody = input.error === void 0 ? `SDK CLI command exited ${input.exitCode ?? "unknown"}` : errorMessage(input.error);
|
|
527
|
+
const networkCauseCategory = input.error !== void 0 && isNetworkFailure(input.error) ? classifyNetworkCauseCategory(input.error) : null;
|
|
528
|
+
return {
|
|
529
|
+
command: sanitizeCommand(input.argv),
|
|
530
|
+
subcommand: subcommandFromArgv(input.argv),
|
|
531
|
+
error_status: input.exitCode,
|
|
532
|
+
error_body: redactFailureText(errorBody),
|
|
533
|
+
exit_code: input.exitCode,
|
|
534
|
+
duration_ms: durationMs,
|
|
535
|
+
error_class: input.error instanceof Error ? input.error.name : null,
|
|
536
|
+
stack_trace: errorStack(input.error),
|
|
537
|
+
failure_kind: failureKind,
|
|
538
|
+
failure_code: code,
|
|
539
|
+
failure_stage: input.error === void 0 ? "command_exit" : "cli_main",
|
|
540
|
+
cli_version: SDK_VERSION,
|
|
541
|
+
context: {
|
|
542
|
+
base_url: redactFailureText(input.baseUrl, 400),
|
|
543
|
+
command_summary: sanitizeCommand(input.argv),
|
|
544
|
+
environment: buildEnvironmentContext(),
|
|
545
|
+
...request ? { request } : {},
|
|
546
|
+
failure_kind: failureKind,
|
|
547
|
+
failure_code: code,
|
|
548
|
+
failure_stage: input.error === void 0 ? "command_exit" : "cli_main",
|
|
549
|
+
duration_ms: durationMs,
|
|
550
|
+
...input.exitCode !== null ? { exit_code: input.exitCode } : {},
|
|
551
|
+
...networkCauseCategory ? { network_cause_category: networkCauseCategory } : {}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
async function maybeReportSdkCliFailure(input) {
|
|
556
|
+
if (isFailureReportingDisabled()) return false;
|
|
557
|
+
if (isServerLoggedPlayRunStartFailure(input)) return false;
|
|
558
|
+
const exitCode = resolvedExitCode(input);
|
|
559
|
+
if (!shouldReport({ exitCode, error: input.error })) return false;
|
|
560
|
+
const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
|
|
561
|
+
const apiKey = resolveApiKeyForBaseUrl(baseUrl);
|
|
562
|
+
if (!apiKey) return false;
|
|
563
|
+
return postFailureReport({
|
|
564
|
+
baseUrl,
|
|
565
|
+
apiKey,
|
|
566
|
+
timeoutMs: REPORT_FAILURE_TIMEOUT_MS,
|
|
567
|
+
body: buildFailureReport({
|
|
568
|
+
argv: input.argv,
|
|
569
|
+
startedAtMs: input.startedAtMs,
|
|
570
|
+
error: input.error,
|
|
571
|
+
exitCode,
|
|
572
|
+
baseUrl
|
|
573
|
+
})
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
189
577
|
// src/cli/utils.ts
|
|
190
578
|
import { createHash } from "crypto";
|
|
191
579
|
import {
|
|
@@ -905,19 +1293,87 @@ function cliToolExecutionFailure(error) {
|
|
|
905
1293
|
const { publicDetails: _publicDetails, ...facts } = failure;
|
|
906
1294
|
return facts;
|
|
907
1295
|
}
|
|
1296
|
+
var UPSTREAM_BODY_EXCERPT_CHARS = 300;
|
|
1297
|
+
var UPSTREAM_BODY_MAX_DEPTH = 6;
|
|
1298
|
+
var CREDENTIAL_FIELD_RE = /(?:^|[-_])(?:auth|key|sig(?:nature)?|session)$|api[-_]?key|apikey|access[-_]?key|private|token|secret|passw(?:or)?d|authorization|cookie|credential|bearer/i;
|
|
1299
|
+
var TRANSIENT_CLIENT_ERROR_STATUSES = /* @__PURE__ */ new Set([408, 425, 429]);
|
|
1300
|
+
function maskCredentialFields(value, depth = 0) {
|
|
1301
|
+
if (value === null || typeof value !== "object") return value;
|
|
1302
|
+
if (depth >= UPSTREAM_BODY_MAX_DEPTH) return "[nested]";
|
|
1303
|
+
if (Array.isArray(value)) {
|
|
1304
|
+
return value.map((entry) => maskCredentialFields(entry, depth + 1));
|
|
1305
|
+
}
|
|
1306
|
+
return Object.fromEntries(
|
|
1307
|
+
Object.entries(value).map(([key, entry]) => [
|
|
1308
|
+
key,
|
|
1309
|
+
CREDENTIAL_FIELD_RE.test(key) ? "[redacted-secret]" : maskCredentialFields(entry, depth + 1)
|
|
1310
|
+
])
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
function formatUpstreamBodyExcerpt(body) {
|
|
1314
|
+
let value = body;
|
|
1315
|
+
if (typeof value === "string") {
|
|
1316
|
+
const trimmed = value.trim();
|
|
1317
|
+
if (!trimmed) return "(empty body)";
|
|
1318
|
+
try {
|
|
1319
|
+
value = JSON.parse(trimmed);
|
|
1320
|
+
} catch {
|
|
1321
|
+
value = trimmed;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (value === null || value === void 0) return "(empty body)";
|
|
1325
|
+
let text;
|
|
1326
|
+
try {
|
|
1327
|
+
text = typeof value === "string" ? value : JSON.stringify(maskCredentialFields(value)) ?? String(value);
|
|
1328
|
+
} catch {
|
|
1329
|
+
text = String(value);
|
|
1330
|
+
}
|
|
1331
|
+
const redacted = redactFailureText(text, Number.MAX_SAFE_INTEGER).replace(/\s+/g, " ").trim();
|
|
1332
|
+
if (!redacted) return "(empty body)";
|
|
1333
|
+
return redacted.length > UPSTREAM_BODY_EXCERPT_CHARS ? `${redacted.slice(0, UPSTREAM_BODY_EXCERPT_CHARS)}\u2026 (full body: rerun with --json)` : redacted;
|
|
1334
|
+
}
|
|
1335
|
+
function permanentProviderFailureLine(status, connectedCredential) {
|
|
1336
|
+
if (typeof status !== "number" || status < 400 || status >= 500) return null;
|
|
1337
|
+
if (TRANSIENT_CLIENT_ERROR_STATUSES.has(status)) return null;
|
|
1338
|
+
if (connectedCredential && (status === 401 || status === 403)) {
|
|
1339
|
+
return "Permanent: the provider refused this credential or its permissions. Check the connected key and its plan before retrying.";
|
|
1340
|
+
}
|
|
1341
|
+
return "Permanent: the provider rejected this request. Retrying it unchanged will fail again.";
|
|
1342
|
+
}
|
|
908
1343
|
function formatToolExecutionErrorDiagnostic(error) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1344
|
+
return formatCliFailureDiagnostic(errorToJsonPayload(error).error);
|
|
1345
|
+
}
|
|
1346
|
+
function formatCliFailureDiagnostic(error) {
|
|
1347
|
+
if (error === null || typeof error !== "object") return null;
|
|
1348
|
+
const record = error;
|
|
1349
|
+
const failure = normalizeToolExecutionFailure(record.tool_error);
|
|
1350
|
+
const upstreamResponse = readToolUpstreamResponse(record);
|
|
1351
|
+
if (!failure && !upstreamResponse) return null;
|
|
1352
|
+
const lines = [];
|
|
1353
|
+
if (failure) {
|
|
1354
|
+
lines.push(
|
|
1355
|
+
`Tool: ${failure.toolId}${failure.provider ? `; provider: ${failure.provider}` : ""}${failure.operation ? `; operation: ${failure.operation}` : ""}.`,
|
|
1356
|
+
`Failure: ${failure.origin} / ${failure.category}. Same-call retry: ${failure.retryable ? `safe${failure.retryAfterMs === null ? "" : ` after ${failure.retryAfterMs}ms`}` : "unsafe"}.`
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
if (upstreamResponse) {
|
|
1360
|
+
lines.push(
|
|
1361
|
+
`Provider response: HTTP ${upstreamResponse.status}: ${formatUpstreamBodyExcerpt(upstreamResponse.body)}`
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
if (!failure || failure.origin === "provider" && !failure.retryable) {
|
|
1365
|
+
const permanent = permanentProviderFailureLine(
|
|
1366
|
+
upstreamResponse?.status ?? failure?.statusCode,
|
|
1367
|
+
upstreamResponse !== null && upstreamResponse !== void 0
|
|
1368
|
+
);
|
|
1369
|
+
if (permanent) lines.push(permanent);
|
|
1370
|
+
}
|
|
1371
|
+
if (failure?.networkKind || failure?.networkScope) {
|
|
916
1372
|
lines.push(
|
|
917
1373
|
`Network: ${failure.networkKind ?? "unknown"}${failure.networkScope ? ` (${failure.networkScope})` : ""}.`
|
|
918
1374
|
);
|
|
919
1375
|
}
|
|
920
|
-
if (failure
|
|
1376
|
+
if (failure?.requestId) lines.push(`Request: ${failure.requestId}.`);
|
|
921
1377
|
return lines.join("\n");
|
|
922
1378
|
}
|
|
923
1379
|
function errorToJsonPayload(error) {
|
|
@@ -1057,6 +1513,13 @@ export {
|
|
|
1057
1513
|
writeRawStderr,
|
|
1058
1514
|
markJsonOutputHandled,
|
|
1059
1515
|
takeSilentJsonFailureMessage,
|
|
1516
|
+
isFailureReportingDisabled,
|
|
1517
|
+
redactFailureText,
|
|
1518
|
+
sanitizeCommand,
|
|
1519
|
+
failureReportHeaders,
|
|
1520
|
+
maybeReportAutomaticSkillsSyncFailure,
|
|
1521
|
+
resolveSdkCliFailureExitCode,
|
|
1522
|
+
maybeReportSdkCliFailure,
|
|
1060
1523
|
getAuthedHttpClient,
|
|
1061
1524
|
openInBrowser,
|
|
1062
1525
|
sleep,
|
|
@@ -1072,6 +1535,7 @@ export {
|
|
|
1072
1535
|
printJson,
|
|
1073
1536
|
printCompactJson,
|
|
1074
1537
|
formatToolExecutionErrorDiagnostic,
|
|
1538
|
+
formatCliFailureDiagnostic,
|
|
1075
1539
|
errorToJsonPayload,
|
|
1076
1540
|
formatProviderConcurrencyDiagnostic,
|
|
1077
1541
|
printJsonError,
|