deepline 0.3.61 → 0.3.63
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/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +9 -1
- package/dist/cli/index.js +372 -279
- package/dist/cli/index.mjs +352 -259
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plays/bundle-play-file.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1120,7 +1120,7 @@ var SDK_RELEASE = {
|
|
|
1120
1120
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
1121
1121
|
// getters keep their established compatibility behavior.
|
|
1122
1122
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
1123
|
-
version: "0.3.
|
|
1123
|
+
version: "0.3.63",
|
|
1124
1124
|
updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
|
|
1125
1125
|
packageCapabilities: {
|
|
1126
1126
|
updatePreferences: 1
|
|
@@ -22086,7 +22086,7 @@ async function handleFileBackedRun(options, hooks) {
|
|
|
22086
22086
|
package: options.fullJson ? void 0 : started.package,
|
|
22087
22087
|
jsonOutput: options.jsonOutput,
|
|
22088
22088
|
progress,
|
|
22089
|
-
inputFieldCount: Object.keys(
|
|
22089
|
+
inputFieldCount: Object.keys(runtimeInput).length,
|
|
22090
22090
|
revisionLabel: "local file revision",
|
|
22091
22091
|
force: options.force,
|
|
22092
22092
|
forceToolRefresh: options.forceToolRefresh
|
|
@@ -22273,7 +22273,7 @@ async function handleNamedRun(options, hooks) {
|
|
|
22273
22273
|
package: options.fullJson ? void 0 : started.package,
|
|
22274
22274
|
jsonOutput: options.jsonOutput,
|
|
22275
22275
|
progress,
|
|
22276
|
-
inputFieldCount: Object.keys(
|
|
22276
|
+
inputFieldCount: Object.keys(runtimeInput).length,
|
|
22277
22277
|
revisionLabel: selectedRevisionId ? `pinned revision ${selectedRevisionId}` : "live revision",
|
|
22278
22278
|
force: options.force,
|
|
22279
22279
|
forceToolRefresh: options.forceToolRefresh
|
|
@@ -34518,7 +34518,7 @@ Examples:
|
|
|
34518
34518
|
// src/cli/commands/setup.ts
|
|
34519
34519
|
var import_node_child_process4 = require("child_process");
|
|
34520
34520
|
var import_node_fs18 = require("fs");
|
|
34521
|
-
var
|
|
34521
|
+
var import_node_os13 = require("os");
|
|
34522
34522
|
var import_node_path21 = require("path");
|
|
34523
34523
|
|
|
34524
34524
|
// src/cli/installation-lifecycle.ts
|
|
@@ -34646,7 +34646,7 @@ function isOwnedInstallerCommandPath(input2) {
|
|
|
34646
34646
|
// src/cli/commands/skills.ts
|
|
34647
34647
|
var import_node_child_process3 = require("child_process");
|
|
34648
34648
|
var import_node_fs17 = require("fs");
|
|
34649
|
-
var
|
|
34649
|
+
var import_node_os12 = require("os");
|
|
34650
34650
|
var import_node_path20 = require("path");
|
|
34651
34651
|
|
|
34652
34652
|
// ../../shared_libs/cli/install-commands.json
|
|
@@ -34783,6 +34783,318 @@ function resolveShellSpawn(command, args, platform3 = process.platform) {
|
|
|
34783
34783
|
};
|
|
34784
34784
|
}
|
|
34785
34785
|
|
|
34786
|
+
// src/cli/failure-reporting.ts
|
|
34787
|
+
var import_node_os11 = require("os");
|
|
34788
|
+
var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";
|
|
34789
|
+
var REPORT_FAILURE_TIMEOUT_MS = 1e4;
|
|
34790
|
+
var BACKGROUND_REPORT_FAILURE_TIMEOUT_MS = 2e3;
|
|
34791
|
+
var MAX_FAILURE_TEXT_CHARS = 4e3;
|
|
34792
|
+
var MAX_COMMAND_TOKENS = 3;
|
|
34793
|
+
var REPORTABLE_EXIT_CODES = /* @__PURE__ */ new Set([4, 5]);
|
|
34794
|
+
var EMAIL_RE = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
34795
|
+
var UNIX_PATH_RE = /(?:\/Users\/|\/home\/|\/var\/folders\/|\/tmp\/|\/sessions\/)[^"'\n\r`]+/g;
|
|
34796
|
+
var WINDOWS_PATH_RE = /[A-Za-z]:(?:\\{1,2})(?:Users|Temp|tmp)(?:\\{1,2})[^"'\n\r`]+/g;
|
|
34797
|
+
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;
|
|
34798
|
+
var BEARER_SECRET_RE = /\b(bearer)\s+([A-Za-z0-9._-]+)/gi;
|
|
34799
|
+
var GENERIC_TOKEN_RE = /\b(?:dlp|sk|ghp|xox[baprs])[-_A-Za-z0-9]{8,}\b/g;
|
|
34800
|
+
var SECRET_OPTION_RE = /^--?(?:access[-_]?token|api[-_]?key|apikey|auth(?:orization)?|bearer|password|secret|session|token)$/i;
|
|
34801
|
+
function truthyEnv2(name) {
|
|
34802
|
+
return ["1", "true", "yes", "on"].includes(
|
|
34803
|
+
String(process.env[name] ?? "").trim().toLowerCase()
|
|
34804
|
+
);
|
|
34805
|
+
}
|
|
34806
|
+
function isFailureReportingDisabled() {
|
|
34807
|
+
return truthyEnv2(FAILURE_REPORT_DISABLE_ENV);
|
|
34808
|
+
}
|
|
34809
|
+
function redactFailureText(value, maxChars = MAX_FAILURE_TEXT_CHARS) {
|
|
34810
|
+
const home = process.env.HOME?.trim();
|
|
34811
|
+
let text = String(value ?? "");
|
|
34812
|
+
if (!text) return "";
|
|
34813
|
+
if (home && home !== "/") {
|
|
34814
|
+
text = text.split(home).join("~");
|
|
34815
|
+
}
|
|
34816
|
+
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);
|
|
34817
|
+
}
|
|
34818
|
+
function sanitizeCommand(argv, prefix = "deepline") {
|
|
34819
|
+
const tokens = [];
|
|
34820
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
34821
|
+
const arg = argv[index];
|
|
34822
|
+
const value = String(arg ?? "").trim();
|
|
34823
|
+
if (!value) continue;
|
|
34824
|
+
if (value.startsWith("-")) {
|
|
34825
|
+
if (!value.includes("=") && SECRET_OPTION_RE.test(value)) {
|
|
34826
|
+
index += 1;
|
|
34827
|
+
}
|
|
34828
|
+
continue;
|
|
34829
|
+
}
|
|
34830
|
+
tokens.push(redactFailureText(value, 200));
|
|
34831
|
+
if (tokens.length >= MAX_COMMAND_TOKENS) break;
|
|
34832
|
+
}
|
|
34833
|
+
return tokens.length > 0 ? [prefix, ...tokens].join(" ") : prefix;
|
|
34834
|
+
}
|
|
34835
|
+
function errorMessage3(error) {
|
|
34836
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
34837
|
+
return String(error ?? "");
|
|
34838
|
+
}
|
|
34839
|
+
function errorStack(error) {
|
|
34840
|
+
if (error instanceof Error && error.stack) {
|
|
34841
|
+
return redactFailureText(error.stack);
|
|
34842
|
+
}
|
|
34843
|
+
return null;
|
|
34844
|
+
}
|
|
34845
|
+
function classifyNetworkFailure(error) {
|
|
34846
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34847
|
+
let current = error;
|
|
34848
|
+
while (current && !seen.has(current)) {
|
|
34849
|
+
seen.add(current);
|
|
34850
|
+
const record2 = typeof current === "object" && current !== null ? current : {};
|
|
34851
|
+
const code = String(record2.code ?? "").toLowerCase();
|
|
34852
|
+
const name = current instanceof Error ? current.name.toLowerCase() : "";
|
|
34853
|
+
const text = String(
|
|
34854
|
+
current instanceof Error ? current.message : current
|
|
34855
|
+
).toLowerCase();
|
|
34856
|
+
const combined = `${code} ${name} ${text}`;
|
|
34857
|
+
if (combined.includes("aborterror") || combined.includes("timeout") || combined.includes("timed out") || combined.includes("etimedout")) {
|
|
34858
|
+
return "network_timeout";
|
|
34859
|
+
}
|
|
34860
|
+
if (combined.includes("enotfound") || combined.includes("eai_again") || combined.includes("name or service not known") || combined.includes("temporary failure in name resolution")) {
|
|
34861
|
+
return "network_dns_resolution_failed";
|
|
34862
|
+
}
|
|
34863
|
+
if (combined.includes("econnrefused") || combined.includes("connection refused")) {
|
|
34864
|
+
return "network_connection_refused";
|
|
34865
|
+
}
|
|
34866
|
+
if (combined.includes("econnreset") || combined.includes("connection reset")) {
|
|
34867
|
+
return "network_connection_reset";
|
|
34868
|
+
}
|
|
34869
|
+
if (combined.includes("incompleteread") || combined.includes("incomplete read")) {
|
|
34870
|
+
return "network_incomplete_read";
|
|
34871
|
+
}
|
|
34872
|
+
if (combined.includes("remotedisconnected") || combined.includes("remote end closed connection") || combined.includes("other side closed") || combined.includes("socket hang up")) {
|
|
34873
|
+
return "network_remote_disconnected";
|
|
34874
|
+
}
|
|
34875
|
+
if (combined.includes("ssl") || combined.includes("tls") || combined.includes("unexpected_eof_while_reading")) {
|
|
34876
|
+
return "network_ssl_error";
|
|
34877
|
+
}
|
|
34878
|
+
current = record2.cause ?? record2.context;
|
|
34879
|
+
}
|
|
34880
|
+
return "network_error";
|
|
34881
|
+
}
|
|
34882
|
+
function isNetworkFailure(error) {
|
|
34883
|
+
if (!(error instanceof Error)) return false;
|
|
34884
|
+
if (error instanceof DeeplineError && error.statusCode) return false;
|
|
34885
|
+
const code = classifyNetworkFailure(error);
|
|
34886
|
+
return code !== "network_error" || /unable to connect|unable to stream/i.test(error.message);
|
|
34887
|
+
}
|
|
34888
|
+
function buildEnvironmentContext() {
|
|
34889
|
+
const context = {
|
|
34890
|
+
os: (0, import_node_os11.platform)(),
|
|
34891
|
+
os_release: (0, import_node_os11.release)(),
|
|
34892
|
+
platform: `${(0, import_node_os11.platform)()}-${(0, import_node_os11.release)()}-${process.arch}`,
|
|
34893
|
+
node_version: process.version,
|
|
34894
|
+
runtime: "Node.js",
|
|
34895
|
+
hostname: (0, import_node_os11.hostname)(),
|
|
34896
|
+
agent_runtime: detectAgentRuntime()
|
|
34897
|
+
};
|
|
34898
|
+
for (const key of ["CLAUDE_CODE_REMOTE", "DEEPLINE_PLUGIN_MODE"]) {
|
|
34899
|
+
const normalized = process.env[key]?.trim();
|
|
34900
|
+
if (normalized) context[key.toLowerCase()] = normalized;
|
|
34901
|
+
}
|
|
34902
|
+
if (process.env.CLAUDE_PROJECT_DIR?.trim()) {
|
|
34903
|
+
context.claude_project_dir_present = "true";
|
|
34904
|
+
}
|
|
34905
|
+
if (process.env.DEEPLINE_PLUGIN_ROOT?.trim()) {
|
|
34906
|
+
context.deepline_plugin_root_present = "true";
|
|
34907
|
+
}
|
|
34908
|
+
if (process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim()) {
|
|
34909
|
+
context.deepline_plugin_skills_dir_present = "true";
|
|
34910
|
+
}
|
|
34911
|
+
if (process.env.HOME?.trim().startsWith("/sessions/")) {
|
|
34912
|
+
context.home_scope = "sessions";
|
|
34913
|
+
}
|
|
34914
|
+
return context;
|
|
34915
|
+
}
|
|
34916
|
+
function failureReportHeaders(apiKey) {
|
|
34917
|
+
return {
|
|
34918
|
+
Authorization: `Bearer ${apiKey}`,
|
|
34919
|
+
"Content-Type": "application/json",
|
|
34920
|
+
"User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
|
|
34921
|
+
"X-Deepline-Client-Family": "sdk",
|
|
34922
|
+
"X-Deepline-CLI-Family": "sdk",
|
|
34923
|
+
"X-Deepline-Agent-Runtime": detectAgentRuntime(),
|
|
34924
|
+
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
34925
|
+
"X-Deepline-SDK-Version": SDK_VERSION
|
|
34926
|
+
};
|
|
34927
|
+
}
|
|
34928
|
+
async function postFailureReport(input2) {
|
|
34929
|
+
const controller = new AbortController();
|
|
34930
|
+
const timeout = setTimeout(() => controller.abort(), input2.timeoutMs);
|
|
34931
|
+
if (input2.background) timeout.unref();
|
|
34932
|
+
try {
|
|
34933
|
+
await fetch(new URL("/api/v2/cli/report-failure", input2.baseUrl), {
|
|
34934
|
+
method: "POST",
|
|
34935
|
+
headers: failureReportHeaders(input2.apiKey),
|
|
34936
|
+
body: JSON.stringify(input2.body),
|
|
34937
|
+
signal: controller.signal
|
|
34938
|
+
});
|
|
34939
|
+
return true;
|
|
34940
|
+
} catch {
|
|
34941
|
+
return false;
|
|
34942
|
+
} finally {
|
|
34943
|
+
clearTimeout(timeout);
|
|
34944
|
+
}
|
|
34945
|
+
}
|
|
34946
|
+
function boundedTelemetryString(value, maxChars) {
|
|
34947
|
+
return redactFailureText(value.trim(), maxChars);
|
|
34948
|
+
}
|
|
34949
|
+
async function maybeReportAutomaticSkillsSyncFailure(input2) {
|
|
34950
|
+
if (isFailureReportingDisabled()) return false;
|
|
34951
|
+
let apiKey = "";
|
|
34952
|
+
try {
|
|
34953
|
+
apiKey = resolveApiKeyForBaseUrl(input2.baseUrl);
|
|
34954
|
+
} catch {
|
|
34955
|
+
return false;
|
|
34956
|
+
}
|
|
34957
|
+
if (!apiKey) return false;
|
|
34958
|
+
const attempts = input2.attempts.slice(0, 2).map((attempt) => ({
|
|
34959
|
+
installer: attempt.installer,
|
|
34960
|
+
outcome: attempt.outcome,
|
|
34961
|
+
exit_code: typeof attempt.exitCode === "number" && Number.isFinite(attempt.exitCode) ? Math.trunc(attempt.exitCode) : null
|
|
34962
|
+
}));
|
|
34963
|
+
const agents = input2.agents.slice(0, 8).map((agent) => boundedTelemetryString(agent, 100)).filter(Boolean);
|
|
34964
|
+
const baseUrl = input2.baseUrl.replace(/\/$/, "");
|
|
34965
|
+
const failureKind = "background_warning";
|
|
34966
|
+
const failureCode2 = "SKILLS_AUTO_SYNC_FAILED";
|
|
34967
|
+
const failureStage = "skills_install";
|
|
34968
|
+
return postFailureReport({
|
|
34969
|
+
baseUrl,
|
|
34970
|
+
apiKey,
|
|
34971
|
+
timeoutMs: BACKGROUND_REPORT_FAILURE_TIMEOUT_MS,
|
|
34972
|
+
background: true,
|
|
34973
|
+
body: {
|
|
34974
|
+
command: "deepline skills",
|
|
34975
|
+
subcommand: "skills",
|
|
34976
|
+
failure_kind: failureKind,
|
|
34977
|
+
failure_code: failureCode2,
|
|
34978
|
+
failure_stage: failureStage,
|
|
34979
|
+
error_body: "Automatic Deepline skills installation failed.",
|
|
34980
|
+
cli_version: SDK_VERSION,
|
|
34981
|
+
context: {
|
|
34982
|
+
environment: buildEnvironmentContext(),
|
|
34983
|
+
skills_sync: {
|
|
34984
|
+
skills_package: boundedTelemetryString(input2.skillsPackage, 100),
|
|
34985
|
+
remote_skills_version: boundedTelemetryString(
|
|
34986
|
+
input2.remoteSkillsVersion,
|
|
34987
|
+
200
|
|
34988
|
+
),
|
|
34989
|
+
agents,
|
|
34990
|
+
target_skill_count: Math.max(
|
|
34991
|
+
0,
|
|
34992
|
+
Math.trunc(
|
|
34993
|
+
Number.isFinite(input2.targetSkillCount) ? input2.targetSkillCount : 0
|
|
34994
|
+
)
|
|
34995
|
+
),
|
|
34996
|
+
marker_written: input2.markerWritten,
|
|
34997
|
+
attempts
|
|
34998
|
+
}
|
|
34999
|
+
}
|
|
35000
|
+
}
|
|
35001
|
+
});
|
|
35002
|
+
}
|
|
35003
|
+
function subcommandFromArgv(argv) {
|
|
35004
|
+
return argv.find((arg) => arg && !arg.startsWith("-")) ?? null;
|
|
35005
|
+
}
|
|
35006
|
+
function commandTokens(argv) {
|
|
35007
|
+
return argv.map((arg) => String(arg ?? "").trim()).filter((arg) => arg && !arg.startsWith("-"));
|
|
35008
|
+
}
|
|
35009
|
+
function isServerLoggedPlayRunStartFailure(input2) {
|
|
35010
|
+
const [subcommand, command] = commandTokens(input2.argv);
|
|
35011
|
+
return subcommand === "plays" && command === "run" && input2.error instanceof DeeplineError && typeof input2.error.statusCode === "number";
|
|
35012
|
+
}
|
|
35013
|
+
function shouldReport(input2) {
|
|
35014
|
+
if (input2.error !== void 0) return true;
|
|
35015
|
+
return input2.exitCode !== null && REPORTABLE_EXIT_CODES.has(input2.exitCode);
|
|
35016
|
+
}
|
|
35017
|
+
function failureCode(input2) {
|
|
35018
|
+
if (input2.error !== void 0) {
|
|
35019
|
+
if (isNetworkFailure(input2.error))
|
|
35020
|
+
return classifyNetworkFailure(input2.error);
|
|
35021
|
+
if (input2.error instanceof DeeplineError && input2.error.code) {
|
|
35022
|
+
return input2.error.code;
|
|
35023
|
+
}
|
|
35024
|
+
if (input2.error instanceof Error && input2.error.name)
|
|
35025
|
+
return input2.error.name;
|
|
35026
|
+
return "CLI_FAILURE";
|
|
35027
|
+
}
|
|
35028
|
+
return input2.exitCode === 4 ? "network_error" : "command_exit";
|
|
35029
|
+
}
|
|
35030
|
+
function resolvedExitCode(input2) {
|
|
35031
|
+
if (typeof input2.exitCode === "number" && Number.isFinite(input2.exitCode)) {
|
|
35032
|
+
return Math.trunc(input2.exitCode);
|
|
35033
|
+
}
|
|
35034
|
+
if (input2.error === void 0) return null;
|
|
35035
|
+
return isNetworkFailure(input2.error) ? 4 : 5;
|
|
35036
|
+
}
|
|
35037
|
+
function resolveSdkCliFailureExitCode(error) {
|
|
35038
|
+
return isNetworkFailure(error) ? 4 : 1;
|
|
35039
|
+
}
|
|
35040
|
+
function resolvedFailureKind(input2) {
|
|
35041
|
+
return input2.error === void 0 ? "command_exit" : "uncaught_exception";
|
|
35042
|
+
}
|
|
35043
|
+
function buildFailureReport(input2) {
|
|
35044
|
+
const durationMs = Math.max(0, Date.now() - input2.startedAtMs);
|
|
35045
|
+
const failureKind = resolvedFailureKind({
|
|
35046
|
+
exitCode: input2.exitCode,
|
|
35047
|
+
error: input2.error
|
|
35048
|
+
});
|
|
35049
|
+
const code = failureCode({ exitCode: input2.exitCode, error: input2.error });
|
|
35050
|
+
const errorBody = input2.error === void 0 ? `SDK CLI command exited ${input2.exitCode ?? "unknown"}` : errorMessage3(input2.error);
|
|
35051
|
+
return {
|
|
35052
|
+
command: sanitizeCommand(input2.argv),
|
|
35053
|
+
subcommand: subcommandFromArgv(input2.argv),
|
|
35054
|
+
error_status: input2.exitCode,
|
|
35055
|
+
error_body: redactFailureText(errorBody),
|
|
35056
|
+
exit_code: input2.exitCode,
|
|
35057
|
+
duration_ms: durationMs,
|
|
35058
|
+
error_class: input2.error instanceof Error ? input2.error.name : null,
|
|
35059
|
+
stack_trace: errorStack(input2.error),
|
|
35060
|
+
failure_kind: failureKind,
|
|
35061
|
+
failure_code: code,
|
|
35062
|
+
failure_stage: input2.error === void 0 ? "command_exit" : "cli_main",
|
|
35063
|
+
cli_version: SDK_VERSION,
|
|
35064
|
+
context: {
|
|
35065
|
+
base_url: redactFailureText(input2.baseUrl, 400),
|
|
35066
|
+
command_summary: sanitizeCommand(input2.argv),
|
|
35067
|
+
environment: buildEnvironmentContext(),
|
|
35068
|
+
failure_kind: failureKind,
|
|
35069
|
+
failure_code: code,
|
|
35070
|
+
failure_stage: input2.error === void 0 ? "command_exit" : "cli_main",
|
|
35071
|
+
duration_ms: durationMs,
|
|
35072
|
+
...input2.exitCode !== null ? { exit_code: input2.exitCode } : {}
|
|
35073
|
+
}
|
|
35074
|
+
};
|
|
35075
|
+
}
|
|
35076
|
+
async function maybeReportSdkCliFailure(input2) {
|
|
35077
|
+
if (isFailureReportingDisabled()) return false;
|
|
35078
|
+
if (isServerLoggedPlayRunStartFailure(input2)) return false;
|
|
35079
|
+
const exitCode = resolvedExitCode(input2);
|
|
35080
|
+
if (!shouldReport({ exitCode, error: input2.error })) return false;
|
|
35081
|
+
const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
|
|
35082
|
+
const apiKey = resolveApiKeyForBaseUrl(baseUrl);
|
|
35083
|
+
if (!apiKey) return false;
|
|
35084
|
+
return postFailureReport({
|
|
35085
|
+
baseUrl,
|
|
35086
|
+
apiKey,
|
|
35087
|
+
timeoutMs: REPORT_FAILURE_TIMEOUT_MS,
|
|
35088
|
+
body: buildFailureReport({
|
|
35089
|
+
argv: input2.argv,
|
|
35090
|
+
startedAtMs: input2.startedAtMs,
|
|
35091
|
+
error: input2.error,
|
|
35092
|
+
exitCode,
|
|
35093
|
+
baseUrl
|
|
35094
|
+
})
|
|
35095
|
+
});
|
|
35096
|
+
}
|
|
35097
|
+
|
|
34786
35098
|
// src/cli/skills-sync.ts
|
|
34787
35099
|
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
34788
35100
|
function shouldSkipSkillsSync() {
|
|
@@ -34816,7 +35128,9 @@ function writeMarkedSkillsSyncVersion(path, version) {
|
|
|
34816
35128
|
(0, import_node_fs16.mkdirSync)((0, import_node_path19.dirname)(path), { recursive: true });
|
|
34817
35129
|
(0, import_node_fs16.writeFileSync)(path, `${version}
|
|
34818
35130
|
`, "utf-8");
|
|
35131
|
+
return true;
|
|
34819
35132
|
} catch {
|
|
35133
|
+
return false;
|
|
34820
35134
|
}
|
|
34821
35135
|
}
|
|
34822
35136
|
function writeUnavailableSkillsNotice(baseUrl, remoteVersion, skillNames) {
|
|
@@ -34845,7 +35159,7 @@ function hasFailedAutomaticSkillsSync(baseUrl, agents) {
|
|
|
34845
35159
|
return (0, import_node_fs16.existsSync)(failedSkillsSyncPath(baseUrl, agents));
|
|
34846
35160
|
}
|
|
34847
35161
|
function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
34848
|
-
writeMarkedSkillsSyncVersion(
|
|
35162
|
+
return writeMarkedSkillsSyncVersion(
|
|
34849
35163
|
failedSkillsSyncPath(baseUrl, agents),
|
|
34850
35164
|
remoteVersion
|
|
34851
35165
|
);
|
|
@@ -34982,19 +35296,29 @@ function runOneSkillsInstall(install) {
|
|
|
34982
35296
|
resolve21({
|
|
34983
35297
|
ok: false,
|
|
34984
35298
|
detail: `failed to start ${install.command}: ${error.message}`,
|
|
34985
|
-
manualCommand: install.manualCommand
|
|
35299
|
+
manualCommand: install.manualCommand,
|
|
35300
|
+
attempt: {
|
|
35301
|
+
installer: install.command,
|
|
35302
|
+
outcome: "spawn_error",
|
|
35303
|
+
exitCode: null
|
|
35304
|
+
}
|
|
34986
35305
|
});
|
|
34987
35306
|
});
|
|
34988
35307
|
child.on("close", (code) => {
|
|
34989
35308
|
if (code === 0) {
|
|
34990
|
-
resolve21({ ok: true
|
|
35309
|
+
resolve21({ ok: true });
|
|
34991
35310
|
return;
|
|
34992
35311
|
}
|
|
34993
35312
|
const detail = stderr.trim();
|
|
34994
35313
|
resolve21({
|
|
34995
35314
|
ok: false,
|
|
34996
35315
|
detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
|
|
34997
|
-
manualCommand: install.manualCommand
|
|
35316
|
+
manualCommand: install.manualCommand,
|
|
35317
|
+
attempt: {
|
|
35318
|
+
installer: install.command,
|
|
35319
|
+
outcome: code === null ? "terminated" : "exit",
|
|
35320
|
+
exitCode: code
|
|
35321
|
+
}
|
|
34998
35322
|
});
|
|
34999
35323
|
});
|
|
35000
35324
|
});
|
|
@@ -35003,7 +35327,7 @@ async function runSkillsInstall(installs, agents) {
|
|
|
35003
35327
|
const failures = [];
|
|
35004
35328
|
for (const install of installs) {
|
|
35005
35329
|
const result = await runOneSkillsInstall(install);
|
|
35006
|
-
if (result.ok) return true;
|
|
35330
|
+
if (result.ok) return { installed: true };
|
|
35007
35331
|
failures.push(result);
|
|
35008
35332
|
}
|
|
35009
35333
|
const details = failures.map((failure) => failure.detail).filter(Boolean).join("\n");
|
|
@@ -35019,7 +35343,10 @@ ${details}
|
|
|
35019
35343
|
` : "") + `To temporarily suppress automatic skills sync: ${temporarySkillsSyncSkipCommand()}
|
|
35020
35344
|
`
|
|
35021
35345
|
);
|
|
35022
|
-
return
|
|
35346
|
+
return {
|
|
35347
|
+
installed: false,
|
|
35348
|
+
attempts: failures.map(({ attempt }) => attempt)
|
|
35349
|
+
};
|
|
35023
35350
|
}
|
|
35024
35351
|
function runLegacySkillsCleanup(agents) {
|
|
35025
35352
|
const candidates = hasCommand("bunx") ? [
|
|
@@ -35116,9 +35443,22 @@ async function syncSdkSkillsIfNeeded(baseUrl, options = {}) {
|
|
|
35116
35443
|
return;
|
|
35117
35444
|
}
|
|
35118
35445
|
writeSdkSkillsStatusLine("Deepline skills changed; syncing agent skills...");
|
|
35119
|
-
const
|
|
35120
|
-
if (!installed) {
|
|
35121
|
-
markFailedSkillsSync(
|
|
35446
|
+
const installResult = await runSkillsInstall(installs, agents);
|
|
35447
|
+
if (!installResult.installed) {
|
|
35448
|
+
const markerWritten = markFailedSkillsSync(
|
|
35449
|
+
baseUrl,
|
|
35450
|
+
update.remoteVersion,
|
|
35451
|
+
agents
|
|
35452
|
+
);
|
|
35453
|
+
void maybeReportAutomaticSkillsSyncFailure({
|
|
35454
|
+
baseUrl,
|
|
35455
|
+
remoteSkillsVersion: update.remoteVersion,
|
|
35456
|
+
agents,
|
|
35457
|
+
skillsPackage: SKILLS_NPX_PACKAGE,
|
|
35458
|
+
targetSkillCount: skillNames.length,
|
|
35459
|
+
markerWritten,
|
|
35460
|
+
attempts: installResult.attempts
|
|
35461
|
+
});
|
|
35122
35462
|
return;
|
|
35123
35463
|
}
|
|
35124
35464
|
runLegacySkillsCleanup(agents);
|
|
@@ -35189,7 +35529,7 @@ function detectSkillsAgents(input2) {
|
|
|
35189
35529
|
if (knownAgent) return [knownAgent];
|
|
35190
35530
|
const roots = [
|
|
35191
35531
|
...input2.scope === "local" && input2.root ? [input2.root] : [],
|
|
35192
|
-
input2.homeDir ?? (0,
|
|
35532
|
+
input2.homeDir ?? (0, import_node_os12.homedir)()
|
|
35193
35533
|
];
|
|
35194
35534
|
const detected = AGENT_MARKERS.filter(
|
|
35195
35535
|
(marker) => roots.some(
|
|
@@ -35671,7 +36011,7 @@ function safeRead(path) {
|
|
|
35671
36011
|
function removeKnownLegacyPaths(baseUrl) {
|
|
35672
36012
|
return CliInstallation.forUser({
|
|
35673
36013
|
baseUrlSlug: baseUrlSlug(baseUrl),
|
|
35674
|
-
home: (0,
|
|
36014
|
+
home: (0, import_node_os13.homedir)()
|
|
35675
36015
|
}).removeRetiredArtifacts();
|
|
35676
36016
|
}
|
|
35677
36017
|
function resolvePathCommands(command) {
|
|
@@ -36425,7 +36765,7 @@ Examples:
|
|
|
36425
36765
|
|
|
36426
36766
|
// src/cli/update-preferences.ts
|
|
36427
36767
|
var import_node_fs19 = require("fs");
|
|
36428
|
-
var
|
|
36768
|
+
var import_node_os14 = require("os");
|
|
36429
36769
|
var import_node_path22 = require("path");
|
|
36430
36770
|
var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
|
|
36431
36771
|
var CLI_UPDATE_MESSAGES = [
|
|
@@ -36454,7 +36794,7 @@ function unreadablePreferences(path, error) {
|
|
|
36454
36794
|
acknowledgedMessages: CLI_UPDATE_MESSAGES.map(({ id }) => id)
|
|
36455
36795
|
};
|
|
36456
36796
|
}
|
|
36457
|
-
function cliUpdatePreferencesPath(homeDir2 = (0,
|
|
36797
|
+
function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36458
36798
|
return (0, import_node_path22.join)(
|
|
36459
36799
|
homeDir2,
|
|
36460
36800
|
".local",
|
|
@@ -36463,7 +36803,7 @@ function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os13.homedir)()) {
|
|
|
36463
36803
|
"update-preferences.json"
|
|
36464
36804
|
);
|
|
36465
36805
|
}
|
|
36466
|
-
function readCliUpdatePreferences(homeDir2 = (0,
|
|
36806
|
+
function readCliUpdatePreferences(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36467
36807
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
36468
36808
|
if (!(0, import_node_fs19.existsSync)(path)) return defaultPreferences();
|
|
36469
36809
|
try {
|
|
@@ -36480,7 +36820,7 @@ function readCliUpdatePreferences(homeDir2 = (0, import_node_os13.homedir)()) {
|
|
|
36480
36820
|
return unreadablePreferences(path, error);
|
|
36481
36821
|
}
|
|
36482
36822
|
}
|
|
36483
|
-
function writeCliUpdatePreferences(preferences, homeDir2 = (0,
|
|
36823
|
+
function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36484
36824
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
36485
36825
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
36486
36826
|
(0, import_node_fs19.mkdirSync)((0, import_node_path22.dirname)(path), { recursive: true });
|
|
@@ -36495,7 +36835,7 @@ function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os13.
|
|
|
36495
36835
|
(0, import_node_fs19.rmSync)(tempPath, { force: true });
|
|
36496
36836
|
}
|
|
36497
36837
|
}
|
|
36498
|
-
function setCliAutoUpdateEnabled(enabled, homeDir2 = (0,
|
|
36838
|
+
function setCliAutoUpdateEnabled(enabled, homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36499
36839
|
const current = readCliUpdatePreferences(homeDir2);
|
|
36500
36840
|
const next = {
|
|
36501
36841
|
...current,
|
|
@@ -36505,7 +36845,7 @@ function setCliAutoUpdateEnabled(enabled, homeDir2 = (0, import_node_os13.homedi
|
|
|
36505
36845
|
writeCliUpdatePreferences(next, homeDir2);
|
|
36506
36846
|
return next;
|
|
36507
36847
|
}
|
|
36508
|
-
function setCliPinnedVersion(version, homeDir2 = (0,
|
|
36848
|
+
function setCliPinnedVersion(version, homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36509
36849
|
const next = {
|
|
36510
36850
|
...readCliUpdatePreferences(homeDir2),
|
|
36511
36851
|
pinnedVersion: version
|
|
@@ -36513,18 +36853,18 @@ function setCliPinnedVersion(version, homeDir2 = (0, import_node_os13.homedir)()
|
|
|
36513
36853
|
writeCliUpdatePreferences(next, homeDir2);
|
|
36514
36854
|
return next;
|
|
36515
36855
|
}
|
|
36516
|
-
function clearCliPinnedVersion(homeDir2 = (0,
|
|
36856
|
+
function clearCliPinnedVersion(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36517
36857
|
const current = readCliUpdatePreferences(homeDir2);
|
|
36518
36858
|
if (current.pinnedVersion === null) return current;
|
|
36519
36859
|
const next = { ...current, pinnedVersion: null };
|
|
36520
36860
|
writeCliUpdatePreferences(next, homeDir2);
|
|
36521
36861
|
return next;
|
|
36522
36862
|
}
|
|
36523
|
-
function shouldRunCliAutoUpdate(homeDir2 = (0,
|
|
36863
|
+
function shouldRunCliAutoUpdate(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36524
36864
|
const preferences = readCliUpdatePreferences(homeDir2);
|
|
36525
36865
|
return preferences.autoUpdateEnabled && preferences.pinnedVersion === null;
|
|
36526
36866
|
}
|
|
36527
|
-
function consumePendingCliUpdateMessages(homeDir2 = (0,
|
|
36867
|
+
function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
36528
36868
|
const preferences = readCliUpdatePreferences(homeDir2);
|
|
36529
36869
|
const acknowledged = new Set(preferences.acknowledgedMessages);
|
|
36530
36870
|
const pending = CLI_UPDATE_MESSAGES.filter(({ id }) => !acknowledged.has(id));
|
|
@@ -36543,7 +36883,7 @@ function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os13.homedir
|
|
|
36543
36883
|
// src/cli/commands/update.ts
|
|
36544
36884
|
var import_node_child_process5 = require("child_process");
|
|
36545
36885
|
var import_node_fs21 = require("fs");
|
|
36546
|
-
var
|
|
36886
|
+
var import_node_os15 = require("os");
|
|
36547
36887
|
var import_node_path24 = require("path");
|
|
36548
36888
|
|
|
36549
36889
|
// src/cli/install-integrity.ts
|
|
@@ -36922,7 +37262,7 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
36922
37262
|
}
|
|
36923
37263
|
function resolveUpdatePlan(options = {}) {
|
|
36924
37264
|
const env = options.env ?? process.env;
|
|
36925
|
-
const homeDir2 = options.homeDir ?? (0,
|
|
37265
|
+
const homeDir2 = options.homeDir ?? (0, import_node_os15.homedir)();
|
|
36926
37266
|
const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : "");
|
|
36927
37267
|
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path24.dirname)(entrypoint)) : null;
|
|
36928
37268
|
if (sourceRoot) {
|
|
@@ -36978,7 +37318,7 @@ function autoUpdateFailurePath(plan) {
|
|
|
36978
37318
|
return (0, import_node_path24.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
36979
37319
|
}
|
|
36980
37320
|
return (0, import_node_path24.join)(
|
|
36981
|
-
(0,
|
|
37321
|
+
(0, import_node_os15.homedir)(),
|
|
36982
37322
|
".local",
|
|
36983
37323
|
"deepline",
|
|
36984
37324
|
"sdk-cli",
|
|
@@ -38338,12 +38678,12 @@ chooses the connected Slack channel or member and the events it receives.
|
|
|
38338
38678
|
// src/cli/commands/tools.ts
|
|
38339
38679
|
var import_commander3 = require("commander");
|
|
38340
38680
|
var import_node_fs23 = require("fs");
|
|
38341
|
-
var
|
|
38681
|
+
var import_node_os17 = require("os");
|
|
38342
38682
|
var import_node_path26 = require("path");
|
|
38343
38683
|
|
|
38344
38684
|
// src/tool-output.ts
|
|
38345
38685
|
var import_node_fs22 = require("fs");
|
|
38346
|
-
var
|
|
38686
|
+
var import_node_os16 = require("os");
|
|
38347
38687
|
var import_node_path25 = require("path");
|
|
38348
38688
|
function isPlainObject(value) {
|
|
38349
38689
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -38471,7 +38811,7 @@ function projectRowOutput(conversion) {
|
|
|
38471
38811
|
};
|
|
38472
38812
|
}
|
|
38473
38813
|
function ensureOutputDir() {
|
|
38474
|
-
const outputDir = (0, import_node_path25.join)((0,
|
|
38814
|
+
const outputDir = (0, import_node_path25.join)((0, import_node_os16.homedir)(), ".local", "share", "deepline", "data");
|
|
38475
38815
|
(0, import_node_fs22.mkdirSync)(outputDir, { recursive: true });
|
|
38476
38816
|
return outputDir;
|
|
38477
38817
|
}
|
|
@@ -40574,7 +40914,7 @@ function starterScriptJson(script) {
|
|
|
40574
40914
|
function seedToolListScript(input2) {
|
|
40575
40915
|
const stem = safeFileStem(input2.toolId);
|
|
40576
40916
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
40577
|
-
const scriptDir = (0, import_node_fs23.mkdtempSync)((0, import_node_path26.join)((0,
|
|
40917
|
+
const scriptDir = (0, import_node_fs23.mkdtempSync)((0, import_node_path26.join)((0, import_node_os17.tmpdir)(), "deepline-workflow-seed-"));
|
|
40578
40918
|
(0, import_node_fs23.chmodSync)(scriptDir, 448);
|
|
40579
40919
|
const scriptPath = (0, import_node_path26.join)(scriptDir, fileName);
|
|
40580
40920
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
@@ -41779,253 +42119,6 @@ What changed in ${response.update_summary.version}: ${response.update_summary.su
|
|
|
41779
42119
|
return true;
|
|
41780
42120
|
}
|
|
41781
42121
|
|
|
41782
|
-
// src/cli/failure-reporting.ts
|
|
41783
|
-
var import_node_os17 = require("os");
|
|
41784
|
-
var FAILURE_REPORT_DISABLE_ENV = "DEEPLINE_DISABLE_FAILURE_REPORTING";
|
|
41785
|
-
var REPORT_FAILURE_TIMEOUT_MS = 1e4;
|
|
41786
|
-
var MAX_FAILURE_TEXT_CHARS = 4e3;
|
|
41787
|
-
var MAX_COMMAND_TOKENS = 3;
|
|
41788
|
-
var REPORTABLE_EXIT_CODES = /* @__PURE__ */ new Set([4, 5]);
|
|
41789
|
-
var EMAIL_RE = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
|
41790
|
-
var UNIX_PATH_RE = /(?:\/Users\/|\/home\/|\/var\/folders\/|\/tmp\/|\/sessions\/)[^"'\n\r`]+/g;
|
|
41791
|
-
var WINDOWS_PATH_RE = /[A-Za-z]:(?:\\{1,2})(?:Users|Temp|tmp)(?:\\{1,2})[^"'\n\r`]+/g;
|
|
41792
|
-
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;
|
|
41793
|
-
var BEARER_SECRET_RE = /\b(bearer)\s+([A-Za-z0-9._-]+)/gi;
|
|
41794
|
-
var GENERIC_TOKEN_RE = /\b(?:dlp|sk|ghp|xox[baprs])[-_A-Za-z0-9]{8,}\b/g;
|
|
41795
|
-
var SECRET_OPTION_RE = /^--?(?:access[-_]?token|api[-_]?key|apikey|auth(?:orization)?|bearer|password|secret|session|token)$/i;
|
|
41796
|
-
function truthyEnv2(name) {
|
|
41797
|
-
return ["1", "true", "yes", "on"].includes(
|
|
41798
|
-
String(process.env[name] ?? "").trim().toLowerCase()
|
|
41799
|
-
);
|
|
41800
|
-
}
|
|
41801
|
-
function isFailureReportingDisabled() {
|
|
41802
|
-
return truthyEnv2(FAILURE_REPORT_DISABLE_ENV);
|
|
41803
|
-
}
|
|
41804
|
-
function redactFailureText(value, maxChars = MAX_FAILURE_TEXT_CHARS) {
|
|
41805
|
-
const home = process.env.HOME?.trim();
|
|
41806
|
-
let text = String(value ?? "");
|
|
41807
|
-
if (!text) return "";
|
|
41808
|
-
if (home && home !== "/") {
|
|
41809
|
-
text = text.split(home).join("~");
|
|
41810
|
-
}
|
|
41811
|
-
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);
|
|
41812
|
-
}
|
|
41813
|
-
function sanitizeCommand(argv, prefix = "deepline") {
|
|
41814
|
-
const tokens = [];
|
|
41815
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
41816
|
-
const arg = argv[index];
|
|
41817
|
-
const value = String(arg ?? "").trim();
|
|
41818
|
-
if (!value) continue;
|
|
41819
|
-
if (value.startsWith("-")) {
|
|
41820
|
-
if (!value.includes("=") && SECRET_OPTION_RE.test(value)) {
|
|
41821
|
-
index += 1;
|
|
41822
|
-
}
|
|
41823
|
-
continue;
|
|
41824
|
-
}
|
|
41825
|
-
tokens.push(redactFailureText(value, 200));
|
|
41826
|
-
if (tokens.length >= MAX_COMMAND_TOKENS) break;
|
|
41827
|
-
}
|
|
41828
|
-
return tokens.length > 0 ? [prefix, ...tokens].join(" ") : prefix;
|
|
41829
|
-
}
|
|
41830
|
-
function errorMessage3(error) {
|
|
41831
|
-
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
41832
|
-
return String(error ?? "");
|
|
41833
|
-
}
|
|
41834
|
-
function errorStack(error) {
|
|
41835
|
-
if (error instanceof Error && error.stack) {
|
|
41836
|
-
return redactFailureText(error.stack);
|
|
41837
|
-
}
|
|
41838
|
-
return null;
|
|
41839
|
-
}
|
|
41840
|
-
function classifyNetworkFailure(error) {
|
|
41841
|
-
const seen = /* @__PURE__ */ new Set();
|
|
41842
|
-
let current = error;
|
|
41843
|
-
while (current && !seen.has(current)) {
|
|
41844
|
-
seen.add(current);
|
|
41845
|
-
const record2 = typeof current === "object" && current !== null ? current : {};
|
|
41846
|
-
const code = String(record2.code ?? "").toLowerCase();
|
|
41847
|
-
const name = current instanceof Error ? current.name.toLowerCase() : "";
|
|
41848
|
-
const text = String(
|
|
41849
|
-
current instanceof Error ? current.message : current
|
|
41850
|
-
).toLowerCase();
|
|
41851
|
-
const combined = `${code} ${name} ${text}`;
|
|
41852
|
-
if (combined.includes("aborterror") || combined.includes("timeout") || combined.includes("timed out") || combined.includes("etimedout")) {
|
|
41853
|
-
return "network_timeout";
|
|
41854
|
-
}
|
|
41855
|
-
if (combined.includes("enotfound") || combined.includes("eai_again") || combined.includes("name or service not known") || combined.includes("temporary failure in name resolution")) {
|
|
41856
|
-
return "network_dns_resolution_failed";
|
|
41857
|
-
}
|
|
41858
|
-
if (combined.includes("econnrefused") || combined.includes("connection refused")) {
|
|
41859
|
-
return "network_connection_refused";
|
|
41860
|
-
}
|
|
41861
|
-
if (combined.includes("econnreset") || combined.includes("connection reset")) {
|
|
41862
|
-
return "network_connection_reset";
|
|
41863
|
-
}
|
|
41864
|
-
if (combined.includes("incompleteread") || combined.includes("incomplete read")) {
|
|
41865
|
-
return "network_incomplete_read";
|
|
41866
|
-
}
|
|
41867
|
-
if (combined.includes("remotedisconnected") || combined.includes("remote end closed connection") || combined.includes("other side closed") || combined.includes("socket hang up")) {
|
|
41868
|
-
return "network_remote_disconnected";
|
|
41869
|
-
}
|
|
41870
|
-
if (combined.includes("ssl") || combined.includes("tls") || combined.includes("unexpected_eof_while_reading")) {
|
|
41871
|
-
return "network_ssl_error";
|
|
41872
|
-
}
|
|
41873
|
-
current = record2.cause ?? record2.context;
|
|
41874
|
-
}
|
|
41875
|
-
return "network_error";
|
|
41876
|
-
}
|
|
41877
|
-
function isNetworkFailure(error) {
|
|
41878
|
-
if (!(error instanceof Error)) return false;
|
|
41879
|
-
if (error instanceof DeeplineError && error.statusCode) return false;
|
|
41880
|
-
const code = classifyNetworkFailure(error);
|
|
41881
|
-
return code !== "network_error" || /unable to connect|unable to stream/i.test(error.message);
|
|
41882
|
-
}
|
|
41883
|
-
function buildEnvironmentContext() {
|
|
41884
|
-
const context = {
|
|
41885
|
-
os: (0, import_node_os17.platform)(),
|
|
41886
|
-
os_release: (0, import_node_os17.release)(),
|
|
41887
|
-
platform: `${(0, import_node_os17.platform)()}-${(0, import_node_os17.release)()}-${process.arch}`,
|
|
41888
|
-
node_version: process.version,
|
|
41889
|
-
runtime: "Node.js",
|
|
41890
|
-
hostname: (0, import_node_os17.hostname)(),
|
|
41891
|
-
agent_runtime: detectAgentRuntime()
|
|
41892
|
-
};
|
|
41893
|
-
for (const key of ["CLAUDE_CODE_REMOTE", "DEEPLINE_PLUGIN_MODE"]) {
|
|
41894
|
-
const normalized = process.env[key]?.trim();
|
|
41895
|
-
if (normalized) context[key.toLowerCase()] = normalized;
|
|
41896
|
-
}
|
|
41897
|
-
if (process.env.CLAUDE_PROJECT_DIR?.trim()) {
|
|
41898
|
-
context.claude_project_dir_present = "true";
|
|
41899
|
-
}
|
|
41900
|
-
if (process.env.DEEPLINE_PLUGIN_ROOT?.trim()) {
|
|
41901
|
-
context.deepline_plugin_root_present = "true";
|
|
41902
|
-
}
|
|
41903
|
-
if (process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim()) {
|
|
41904
|
-
context.deepline_plugin_skills_dir_present = "true";
|
|
41905
|
-
}
|
|
41906
|
-
if (process.env.HOME?.trim().startsWith("/sessions/")) {
|
|
41907
|
-
context.home_scope = "sessions";
|
|
41908
|
-
}
|
|
41909
|
-
return context;
|
|
41910
|
-
}
|
|
41911
|
-
function subcommandFromArgv(argv) {
|
|
41912
|
-
return argv.find((arg) => arg && !arg.startsWith("-")) ?? null;
|
|
41913
|
-
}
|
|
41914
|
-
function commandTokens(argv) {
|
|
41915
|
-
return argv.map((arg) => String(arg ?? "").trim()).filter((arg) => arg && !arg.startsWith("-"));
|
|
41916
|
-
}
|
|
41917
|
-
function isServerLoggedPlayRunStartFailure(input2) {
|
|
41918
|
-
const [subcommand, command] = commandTokens(input2.argv);
|
|
41919
|
-
return subcommand === "plays" && command === "run" && input2.error instanceof DeeplineError && typeof input2.error.statusCode === "number";
|
|
41920
|
-
}
|
|
41921
|
-
function shouldReport(input2) {
|
|
41922
|
-
if (input2.error !== void 0) return true;
|
|
41923
|
-
return input2.exitCode !== null && REPORTABLE_EXIT_CODES.has(input2.exitCode);
|
|
41924
|
-
}
|
|
41925
|
-
function failureCode(input2) {
|
|
41926
|
-
if (input2.error !== void 0) {
|
|
41927
|
-
if (isNetworkFailure(input2.error))
|
|
41928
|
-
return classifyNetworkFailure(input2.error);
|
|
41929
|
-
if (input2.error instanceof DeeplineError && input2.error.code) {
|
|
41930
|
-
return input2.error.code;
|
|
41931
|
-
}
|
|
41932
|
-
if (input2.error instanceof Error && input2.error.name)
|
|
41933
|
-
return input2.error.name;
|
|
41934
|
-
return "CLI_FAILURE";
|
|
41935
|
-
}
|
|
41936
|
-
return input2.exitCode === 4 ? "network_error" : "command_exit";
|
|
41937
|
-
}
|
|
41938
|
-
function resolvedExitCode(input2) {
|
|
41939
|
-
if (typeof input2.exitCode === "number" && Number.isFinite(input2.exitCode)) {
|
|
41940
|
-
return Math.trunc(input2.exitCode);
|
|
41941
|
-
}
|
|
41942
|
-
if (input2.error === void 0) return null;
|
|
41943
|
-
return isNetworkFailure(input2.error) ? 4 : 5;
|
|
41944
|
-
}
|
|
41945
|
-
function resolveSdkCliFailureExitCode(error) {
|
|
41946
|
-
return isNetworkFailure(error) ? 4 : 1;
|
|
41947
|
-
}
|
|
41948
|
-
function resolvedFailureKind(input2) {
|
|
41949
|
-
return input2.error === void 0 ? "command_exit" : "uncaught_exception";
|
|
41950
|
-
}
|
|
41951
|
-
function buildFailureReport(input2) {
|
|
41952
|
-
const durationMs = Math.max(0, Date.now() - input2.startedAtMs);
|
|
41953
|
-
const failureKind = resolvedFailureKind({
|
|
41954
|
-
exitCode: input2.exitCode,
|
|
41955
|
-
error: input2.error
|
|
41956
|
-
});
|
|
41957
|
-
const code = failureCode({ exitCode: input2.exitCode, error: input2.error });
|
|
41958
|
-
const errorBody = input2.error === void 0 ? `SDK CLI command exited ${input2.exitCode ?? "unknown"}` : errorMessage3(input2.error);
|
|
41959
|
-
return {
|
|
41960
|
-
command: sanitizeCommand(input2.argv),
|
|
41961
|
-
subcommand: subcommandFromArgv(input2.argv),
|
|
41962
|
-
error_status: input2.exitCode,
|
|
41963
|
-
error_body: redactFailureText(errorBody),
|
|
41964
|
-
exit_code: input2.exitCode,
|
|
41965
|
-
duration_ms: durationMs,
|
|
41966
|
-
error_class: input2.error instanceof Error ? input2.error.name : null,
|
|
41967
|
-
stack_trace: errorStack(input2.error),
|
|
41968
|
-
failure_kind: failureKind,
|
|
41969
|
-
failure_code: code,
|
|
41970
|
-
failure_stage: input2.error === void 0 ? "command_exit" : "cli_main",
|
|
41971
|
-
cli_version: SDK_VERSION,
|
|
41972
|
-
context: {
|
|
41973
|
-
base_url: redactFailureText(input2.baseUrl, 400),
|
|
41974
|
-
command_summary: sanitizeCommand(input2.argv),
|
|
41975
|
-
environment: buildEnvironmentContext(),
|
|
41976
|
-
failure_kind: failureKind,
|
|
41977
|
-
failure_code: code,
|
|
41978
|
-
failure_stage: input2.error === void 0 ? "command_exit" : "cli_main",
|
|
41979
|
-
duration_ms: durationMs,
|
|
41980
|
-
...input2.exitCode !== null ? { exit_code: input2.exitCode } : {}
|
|
41981
|
-
}
|
|
41982
|
-
};
|
|
41983
|
-
}
|
|
41984
|
-
async function maybeReportSdkCliFailure(input2) {
|
|
41985
|
-
if (isFailureReportingDisabled()) return false;
|
|
41986
|
-
if (isServerLoggedPlayRunStartFailure(input2)) return false;
|
|
41987
|
-
const exitCode = resolvedExitCode(input2);
|
|
41988
|
-
if (!shouldReport({ exitCode, error: input2.error })) return false;
|
|
41989
|
-
const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
|
|
41990
|
-
const apiKey = resolveApiKeyForBaseUrl(baseUrl);
|
|
41991
|
-
if (!apiKey) return false;
|
|
41992
|
-
const controller = new AbortController();
|
|
41993
|
-
const timeout = setTimeout(
|
|
41994
|
-
() => controller.abort(),
|
|
41995
|
-
REPORT_FAILURE_TIMEOUT_MS
|
|
41996
|
-
);
|
|
41997
|
-
try {
|
|
41998
|
-
await fetch(new URL("/api/v2/cli/report-failure", baseUrl), {
|
|
41999
|
-
method: "POST",
|
|
42000
|
-
headers: {
|
|
42001
|
-
Authorization: `Bearer ${apiKey}`,
|
|
42002
|
-
"Content-Type": "application/json",
|
|
42003
|
-
"User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
|
|
42004
|
-
"X-Deepline-Client-Family": "sdk",
|
|
42005
|
-
"X-Deepline-CLI-Family": "sdk",
|
|
42006
|
-
"X-Deepline-Agent-Runtime": detectAgentRuntime(),
|
|
42007
|
-
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
42008
|
-
"X-Deepline-SDK-Version": SDK_VERSION
|
|
42009
|
-
},
|
|
42010
|
-
body: JSON.stringify(
|
|
42011
|
-
buildFailureReport({
|
|
42012
|
-
argv: input2.argv,
|
|
42013
|
-
startedAtMs: input2.startedAtMs,
|
|
42014
|
-
error: input2.error,
|
|
42015
|
-
exitCode,
|
|
42016
|
-
baseUrl
|
|
42017
|
-
})
|
|
42018
|
-
),
|
|
42019
|
-
signal: controller.signal
|
|
42020
|
-
});
|
|
42021
|
-
return true;
|
|
42022
|
-
} catch {
|
|
42023
|
-
return false;
|
|
42024
|
-
} finally {
|
|
42025
|
-
clearTimeout(timeout);
|
|
42026
|
-
}
|
|
42027
|
-
}
|
|
42028
|
-
|
|
42029
42122
|
// src/cli/index.ts
|
|
42030
42123
|
var PREFLIGHT_TIMEOUT_MS = 3e3;
|
|
42031
42124
|
var ProjectOrgPinRequiredError = class extends Error {
|