@wrongstack/core 0.310.1 → 0.313.1
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/chronicle/index.js +84 -6391
- package/dist/chronicle/project-server.js +84 -4868
- package/dist/chunk-2BUUIMQB.js +225 -0
- package/dist/chunk-2FK4WTFF.js +207 -0
- package/dist/chunk-2FQL4PDC.js +292 -0
- package/dist/chunk-2KKODIQU.js +2256 -0
- package/dist/chunk-2YU4WVBW.js +134 -0
- package/dist/chunk-3E244UDA.js +356 -0
- package/dist/chunk-3XPVB7BA.js +135 -0
- package/dist/chunk-4LJJYBAU.js +388 -0
- package/dist/chunk-4VWO3ZXL.js +342 -0
- package/dist/chunk-4XV6IR37.js +187 -0
- package/dist/chunk-4ZHTKJHM.js +183 -0
- package/dist/chunk-52RTVH4M.js +361 -0
- package/dist/chunk-57GEWK5X.js +26 -0
- package/dist/chunk-5DSMEVA4.js +931 -0
- package/dist/chunk-5RP3QTRL.js +1223 -0
- package/dist/chunk-5S437PRC.js +50 -0
- package/dist/chunk-5XDUGTKN.js +511 -0
- package/dist/chunk-62V2AFVG.js +422 -0
- package/dist/chunk-65RDIOR2.js +2470 -0
- package/dist/chunk-6AKOTGLM.js +597 -0
- package/dist/chunk-7ZHZE5EO.js +28 -0
- package/dist/chunk-A455ATZB.js +140 -0
- package/dist/chunk-AD7ZFZCS.js +46 -0
- package/dist/chunk-AI4LLQ2U.js +856 -0
- package/dist/chunk-ASX6AW36.js +789 -0
- package/dist/chunk-AT4V4XGI.js +3522 -0
- package/dist/chunk-AWNQ6ED6.js +311 -0
- package/dist/chunk-B4AMLZPB.js +9 -0
- package/dist/chunk-BAKVJLEV.js +417 -0
- package/dist/chunk-BJHVULHO.js +55 -0
- package/dist/chunk-CB2HFKTP.js +9 -0
- package/dist/chunk-CE4ZOCOI.js +1640 -0
- package/dist/chunk-CQQL4ZOQ.js +151 -0
- package/dist/chunk-DEIQMBD2.js +65 -0
- package/dist/chunk-E6I5RXVK.js +58 -0
- package/dist/chunk-EFEHDQGY.js +1589 -0
- package/dist/chunk-EODDVJBM.js +82 -0
- package/dist/chunk-EPC3GZD4.js +308 -0
- package/dist/chunk-FAYRX2AD.js +13 -0
- package/dist/chunk-FFSX2QDQ.js +362 -0
- package/dist/chunk-FHAMQS7Q.js +5856 -0
- package/dist/chunk-FIV4IJL7.js +2263 -0
- package/dist/chunk-FNXVT7HF.js +52 -0
- package/dist/chunk-FSWCWSTS.js +395 -0
- package/dist/chunk-FW5LDDMJ.js +16464 -0
- package/dist/chunk-FXQLIX3K.js +211 -0
- package/dist/chunk-G5AAKEEZ.js +228 -0
- package/dist/chunk-G5S3S5ZN.js +38 -0
- package/dist/chunk-GAZEWQEZ.js +231 -0
- package/dist/chunk-GFJOMSHG.js +125 -0
- package/dist/chunk-GFXZTHNI.js +158 -0
- package/dist/chunk-GM54GJBU.js +960 -0
- package/dist/chunk-GPQ3NJPR.js +900 -0
- package/dist/chunk-GTCU6DZ3.js +1 -0
- package/dist/chunk-H5E77KUJ.js +15 -0
- package/dist/chunk-H72H4XDU.js +1023 -0
- package/dist/chunk-HA4ZYA6T.js +178 -0
- package/dist/chunk-I45KAW2N.js +5020 -0
- package/dist/chunk-IQ35HMQL.js +1396 -0
- package/dist/chunk-IYFBFX34.js +86 -0
- package/dist/chunk-JJPMWPB6.js +109 -0
- package/dist/chunk-JTHKOYWU.js +663 -0
- package/dist/chunk-JVGPR3TS.js +365 -0
- package/dist/chunk-JVKB2TBL.js +48 -0
- package/dist/chunk-JX7VBZDK.js +31 -0
- package/dist/chunk-K3G6JBUC.js +5232 -0
- package/dist/chunk-K4YUNKU7.js +589 -0
- package/dist/chunk-KBZGE6LN.js +710 -0
- package/dist/chunk-KDQJCT2J.js +45 -0
- package/dist/chunk-KI4L2DUL.js +560 -0
- package/dist/chunk-KJ2ZTQSL.js +47 -0
- package/dist/chunk-KSJ5UTP7.js +154 -0
- package/dist/chunk-LHOA5DWA.js +28 -0
- package/dist/chunk-LX5QWLBL.js +27 -0
- package/dist/chunk-LZDDLNCZ.js +279 -0
- package/dist/chunk-M2WF6AXG.js +115 -0
- package/dist/chunk-M7BS2K6U.js +1 -0
- package/dist/chunk-NDBIPFNY.js +102 -0
- package/dist/chunk-NEMIWEXC.js +1199 -0
- package/dist/chunk-NFAYHPRH.js +323 -0
- package/dist/chunk-O37BQ65S.js +21 -0
- package/dist/chunk-O74MJHXU.js +187 -0
- package/dist/chunk-OJZEX73F.js +112 -0
- package/dist/chunk-PAAWLLZX.js +74 -0
- package/dist/chunk-PFXFQQRT.js +339 -0
- package/dist/chunk-PFZO3C6H.js +14 -0
- package/dist/chunk-PHH7LD45.js +113 -0
- package/dist/chunk-QRTG4XTI.js +188 -0
- package/dist/chunk-QVOVMXJR.js +1351 -0
- package/dist/chunk-RCQYT2I4.js +757 -0
- package/dist/chunk-RD6DEE36.js +1178 -0
- package/dist/chunk-RJIZEJ42.js +30 -0
- package/dist/chunk-RPOA7IAE.js +150 -0
- package/dist/chunk-SN2DQRL6.js +1172 -0
- package/dist/chunk-SQJVFEBV.js +41 -0
- package/dist/chunk-SQP64RCS.js +5391 -0
- package/dist/chunk-SVT4RNTR.js +49 -0
- package/dist/chunk-SWUFN7XM.js +43 -0
- package/dist/chunk-SXMVYC5H.js +174 -0
- package/dist/chunk-SZ6AYUIZ.js +23 -0
- package/dist/chunk-T3KGZBU5.js +3171 -0
- package/dist/chunk-TBRL2RCC.js +9 -0
- package/dist/chunk-TRT2HRWZ.js +18 -0
- package/dist/chunk-TYW2GI5I.js +1077 -0
- package/dist/chunk-UIWONWVG.js +4959 -0
- package/dist/chunk-VB3H5WWB.js +151 -0
- package/dist/chunk-W4A6QA3D.js +258 -0
- package/dist/chunk-WBPVKEEE.js +227 -0
- package/dist/chunk-WEBMSQP2.js +123 -0
- package/dist/chunk-WOEZV3Q4.js +333 -0
- package/dist/chunk-WQQON3SV.js +473 -0
- package/dist/chunk-WQTOVMGV.js +119 -0
- package/dist/chunk-WZO23AWO.js +2779 -0
- package/dist/chunk-XBDP4QPW.js +7 -0
- package/dist/chunk-XEBHSJLT.js +103 -0
- package/dist/chunk-XQ2ECNK3.js +1 -0
- package/dist/chunk-XQ2XGIBF.js +2086 -0
- package/dist/chunk-Y2GE5TSI.js +355 -0
- package/dist/chunk-YBUJCZ57.js +351 -0
- package/dist/chunk-YNCVSFGF.js +149 -0
- package/dist/chunk-YUPMXOGP.js +282 -0
- package/dist/chunk-YY6APYUM.js +49 -0
- package/dist/chunk-Z2IJUO45.js +691 -0
- package/dist/chunk-ZEHUCJHY.js +129 -0
- package/dist/chunk-ZYU2YOJ6.js +1496 -0
- package/dist/chunk-ZZ4V3WIZ.js +163 -0
- package/dist/coordination/agents/index.js +145 -6260
- package/dist/coordination/index.js +365 -34323
- package/dist/coordination/mailbox-project-server.js +48 -3220
- package/dist/coordination/mailbox-types.d.ts +13 -1
- package/dist/coordination/provider-status-tracker.d.ts +4 -0
- package/dist/coordination/sqlite-mailbox.d.ts +2 -1
- package/dist/core/agent.d.ts +14 -1
- package/dist/core/index.js +267 -12479
- package/dist/core/model-ref.js +5 -23
- package/dist/core/provider-runner.d.ts +36 -1
- package/dist/design/index.js +50 -1087
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +1599 -21887
- package/dist/execution/prompt-enhancer.js +16 -535
- package/dist/execution/retry-policy.d.ts +31 -1
- package/dist/extension/index.js +7 -311
- package/dist/goal/index.js +33 -3435
- package/dist/hooks/index.js +14 -1138
- package/dist/hq/index.js +112 -5139
- package/dist/hq/protocol.js +21 -668
- package/dist/index.js +1410 -92655
- package/dist/infrastructure/index.js +64 -4811
- package/dist/kernel/events/provider-events.d.ts +15 -0
- package/dist/kernel/events/wrongtrace-events.d.ts +26 -0
- package/dist/kernel/events.d.ts +16 -7
- package/dist/kernel/index.js +14 -992
- package/dist/models/index.js +40 -1117
- package/dist/notifications/index.js +3 -108
- package/dist/observability/index.js +17 -279
- package/dist/plugin/index.js +584 -14835
- package/dist/prompts/index.js +14 -948
- package/dist/registry/index.js +9 -822
- package/dist/registry-R23UBE7H.js +14 -0
- package/dist/replay/index.js +6 -84
- package/dist/review-finding-store-DKAV3AS6.js +21 -0
- package/dist/review-report-store-OWY3EC3N.js +19 -0
- package/dist/security/index.js +114 -2202
- package/dist/session-catalog/index.js +36 -2103
- package/dist/session-catalog/project-server.js +42 -1435
- package/dist/skills/index.js +35 -1578
- package/dist/storage/index.js +182 -15600
- package/dist/tasking/index.js +10 -676
- package/dist/tools/index.js +52 -9589
- package/dist/types/config/autonomy.d.ts +5 -0
- package/dist/types/config/tools.d.ts +2 -2
- package/dist/types/config/ui.d.ts +1 -1
- package/dist/types/errors.d.ts +18 -0
- package/dist/types/index.js +121 -1341
- package/dist/types/provider-runner.d.ts +8 -0
- package/dist/types/session-markers.js +8 -144
- package/dist/utils/error.js +3 -4
- package/dist/utils/expect-defined.js +3 -9
- package/dist/utils/heap-watchdog.js +6 -706
- package/dist/utils/index.js +269 -5685
- package/dist/utils/sage-output-block.js +5 -42
- package/dist/wiring/proxy-rewrite.d.ts +92 -4
- package/dist/wiring/proxy-rewrite.js +20 -61
- package/dist/worktree/index.js +6 -887
- package/package.json +4 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// src/skills/frontmatter.ts
|
|
2
|
+
var SCALAR_KEYS = /* @__PURE__ */ new Set([
|
|
3
|
+
"name",
|
|
4
|
+
"description",
|
|
5
|
+
"trigger",
|
|
6
|
+
"version",
|
|
7
|
+
"license",
|
|
8
|
+
"compatibility"
|
|
9
|
+
]);
|
|
10
|
+
function parseSkillFrontmatter(raw) {
|
|
11
|
+
const text = normalizeLineEndings(raw);
|
|
12
|
+
if (!text.startsWith("---")) return {};
|
|
13
|
+
const end = text.indexOf("\n---", 4);
|
|
14
|
+
if (end === -1) return {};
|
|
15
|
+
return parseFrontmatterBlock(text.slice(4, end));
|
|
16
|
+
}
|
|
17
|
+
function stripFrontmatter(raw) {
|
|
18
|
+
const text = normalizeLineEndings(raw);
|
|
19
|
+
if (!text.startsWith("---")) return text;
|
|
20
|
+
const end = text.indexOf("\n---", 4);
|
|
21
|
+
if (end === -1) return text;
|
|
22
|
+
let body = text.slice(end + 4);
|
|
23
|
+
if (body.startsWith("\n")) body = body.slice(1);
|
|
24
|
+
return body;
|
|
25
|
+
}
|
|
26
|
+
function normalizeLineEndings(s) {
|
|
27
|
+
return s.replace(/\r\n?/g, "\n");
|
|
28
|
+
}
|
|
29
|
+
function parseFrontmatterBlock(block) {
|
|
30
|
+
const out = {};
|
|
31
|
+
const lines = block.split("\n");
|
|
32
|
+
let i = 0;
|
|
33
|
+
while (i < lines.length) {
|
|
34
|
+
const line = lines[i] ?? "";
|
|
35
|
+
const m = /^([a-zA-Z][a-zA-Z0-9_-]*):\s*(.*)$/.exec(line);
|
|
36
|
+
if (!m) {
|
|
37
|
+
i++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const key = m[1] ?? "";
|
|
41
|
+
const rest = (m[2] ?? "").trim();
|
|
42
|
+
if (key === "metadata") {
|
|
43
|
+
const map = {};
|
|
44
|
+
i++;
|
|
45
|
+
while (i < lines.length) {
|
|
46
|
+
const sub = lines[i] ?? "";
|
|
47
|
+
const sm = /^\s+([a-zA-Z0-9_.-]+):\s*(.*)$/.exec(sub);
|
|
48
|
+
if (!sm) break;
|
|
49
|
+
map[sm[1] ?? ""] = unquote((sm[2] ?? "").trim());
|
|
50
|
+
i++;
|
|
51
|
+
}
|
|
52
|
+
if (Object.keys(map).length > 0) out.metadata = map;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (rest === "|" || rest === ">") {
|
|
56
|
+
const collected = [];
|
|
57
|
+
i++;
|
|
58
|
+
while (i < lines.length) {
|
|
59
|
+
const sub = lines[i] ?? "";
|
|
60
|
+
if (sub === "" || sub.startsWith(" ") || sub.startsWith(" ")) {
|
|
61
|
+
collected.push(sub.replace(/^\s+/, ""));
|
|
62
|
+
i++;
|
|
63
|
+
} else break;
|
|
64
|
+
}
|
|
65
|
+
out[normalizeKey(key)] = collected.join("\n").trim();
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (key === "allowed-tools" || key === "allowedTools" || key === "required-capabilities" || key === "requiredCapabilities" || key === "required-tools" || key === "requiredTools" || key === "optional-capabilities" || key === "optionalCapabilities") {
|
|
69
|
+
const values = rest.replace(/^\[/, "").replace(/\]$/, "").split(/[\s,]+/).map(unquote).filter(Boolean);
|
|
70
|
+
out[normalizeKey(key)] = values;
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (SCALAR_KEYS.has(key)) {
|
|
75
|
+
out[key] = unquote(rest);
|
|
76
|
+
i++;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
i++;
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
function normalizeKey(key) {
|
|
84
|
+
if (key === "allowed-tools") return "allowedTools";
|
|
85
|
+
if (key === "required-capabilities") return "requiredCapabilities";
|
|
86
|
+
if (key === "required-tools") return "requiredTools";
|
|
87
|
+
if (key === "optional-capabilities") return "optionalCapabilities";
|
|
88
|
+
return key;
|
|
89
|
+
}
|
|
90
|
+
function unquote(s) {
|
|
91
|
+
if (s.length >= 2 && (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'"))) {
|
|
92
|
+
return s.slice(1, -1);
|
|
93
|
+
}
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
96
|
+
function isValidSkillNameFormat(name) {
|
|
97
|
+
return name.length >= 1 && name.length <= 64 && /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name);
|
|
98
|
+
}
|
|
99
|
+
function validateSkillName(name, parentDirName) {
|
|
100
|
+
const errors = [];
|
|
101
|
+
if (!name || name.trim().length === 0) {
|
|
102
|
+
errors.push("name is empty");
|
|
103
|
+
return errors;
|
|
104
|
+
}
|
|
105
|
+
if (name.length > 64) errors.push(`name is ${name.length} characters (max 64)`);
|
|
106
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(name)) {
|
|
107
|
+
errors.push(
|
|
108
|
+
"name must be lowercase letters, digits, and single hyphens only (no leading/trailing/consecutive hyphens)"
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (parentDirName !== void 0 && name !== parentDirName) {
|
|
112
|
+
errors.push(`name "${name}" must match its parent directory "${parentDirName}"`);
|
|
113
|
+
}
|
|
114
|
+
return errors;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
parseSkillFrontmatter,
|
|
119
|
+
stripFrontmatter,
|
|
120
|
+
isValidSkillNameFormat,
|
|
121
|
+
validateSkillName
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=chunk-WEBMSQP2.js.map
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toErrorMessage
|
|
3
|
+
} from "./chunk-TBRL2RCC.js";
|
|
4
|
+
|
|
5
|
+
// src/types/errors.ts
|
|
6
|
+
var ERROR_CODES = {
|
|
7
|
+
// Provider
|
|
8
|
+
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
9
|
+
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
10
|
+
PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
|
|
11
|
+
PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
|
|
12
|
+
PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
|
|
13
|
+
PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
|
|
14
|
+
PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
|
|
15
|
+
// Tool
|
|
16
|
+
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
17
|
+
TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
|
|
18
|
+
TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
|
|
19
|
+
TOOL_TIMEOUT: "TOOL_TIMEOUT",
|
|
20
|
+
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
21
|
+
// Config
|
|
22
|
+
CONFIG_INVALID: "CONFIG_INVALID",
|
|
23
|
+
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
|
|
24
|
+
CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
|
|
25
|
+
CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
|
|
26
|
+
// Plugin
|
|
27
|
+
PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
|
|
28
|
+
PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
|
|
29
|
+
PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
|
|
30
|
+
// Agent
|
|
31
|
+
AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
|
|
32
|
+
AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
|
|
33
|
+
AGENT_ABORTED: "AGENT_ABORTED",
|
|
34
|
+
AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
|
|
35
|
+
// Session
|
|
36
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
|
|
37
|
+
SESSION_CORRUPTED: "SESSION_CORRUPTED",
|
|
38
|
+
SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
|
|
39
|
+
// Container / Registry
|
|
40
|
+
CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
|
|
41
|
+
CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
|
|
42
|
+
CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
|
|
43
|
+
REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
|
|
44
|
+
REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
|
|
45
|
+
REGISTRY_INVALID: "REGISTRY_INVALID",
|
|
46
|
+
// File system
|
|
47
|
+
FS_READ_FAILED: "FS_READ_FAILED",
|
|
48
|
+
FS_WRITE_FAILED: "FS_WRITE_FAILED",
|
|
49
|
+
FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
|
|
50
|
+
FS_DELETE_FAILED: "FS_DELETE_FAILED",
|
|
51
|
+
FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
|
|
52
|
+
// SDD (Spec-Driven Development)
|
|
53
|
+
SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
|
|
54
|
+
SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
|
|
55
|
+
SDD_INVALID_STATE: "SDD_INVALID_STATE",
|
|
56
|
+
SDD_NOT_READY: "SDD_NOT_READY",
|
|
57
|
+
// General
|
|
58
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
59
|
+
PARSE_FAILED: "PARSE_FAILED",
|
|
60
|
+
UNKNOWN: "UNKNOWN"
|
|
61
|
+
};
|
|
62
|
+
var WrongStackError = class _WrongStackError extends Error {
|
|
63
|
+
code;
|
|
64
|
+
subsystem;
|
|
65
|
+
severity;
|
|
66
|
+
recoverable;
|
|
67
|
+
context;
|
|
68
|
+
constructor(opts) {
|
|
69
|
+
super(opts.message, { cause: opts.cause });
|
|
70
|
+
this.name = "WrongStackError";
|
|
71
|
+
this.code = opts.code;
|
|
72
|
+
this.subsystem = opts.subsystem;
|
|
73
|
+
this.severity = opts.severity ?? "error";
|
|
74
|
+
this.recoverable = opts.recoverable ?? false;
|
|
75
|
+
this.context = opts.context;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Duck-type guard mirroring {@link ProviderError.isProviderError}.
|
|
79
|
+
*
|
|
80
|
+
* `instanceof WrongStackError` is NOT reliable inside this monorepo: the
|
|
81
|
+
* package builder emits every `@wrongstack/core` subpath (`core`, `types`,
|
|
82
|
+
* `coordination`, `execution`, `extension`, …) as an independent esbuild
|
|
83
|
+
* bundle with `splitting: false`, so each entry inlines its OWN copy of this
|
|
84
|
+
* class. An error constructed by `@wrongstack/providers` (which imports from
|
|
85
|
+
* `@wrongstack/core/types`) therefore fails `instanceof` against the copy
|
|
86
|
+
* baked into `@wrongstack/core/core` — which is where the agent loop and the
|
|
87
|
+
* provider runner live.
|
|
88
|
+
*
|
|
89
|
+
* That mismatch silently downgraded every provider failure to a generic
|
|
90
|
+
* `AgentError` in {@link toWrongStackError}, stripping `kind` / `status` /
|
|
91
|
+
* `body` and blinding the fallback engine and the provider waiting room.
|
|
92
|
+
* Use this guard anywhere the error may have crossed a subpath boundary.
|
|
93
|
+
*/
|
|
94
|
+
static isWrongStackError(err) {
|
|
95
|
+
if (err instanceof _WrongStackError) return true;
|
|
96
|
+
if (!err || typeof err !== "object") return false;
|
|
97
|
+
const e = err;
|
|
98
|
+
return typeof e["name"] === "string" && e["name"].endsWith("Error") && typeof e["code"] === "string" && typeof e["subsystem"] === "string" && typeof e["severity"] === "string" && typeof e["describe"] === "function";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Render a one-line user-facing description.
|
|
102
|
+
* Subclasses should override for domain-specific formatting.
|
|
103
|
+
*/
|
|
104
|
+
describe() {
|
|
105
|
+
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
106
|
+
return `${this.code}: ${this.message}${ctx}`;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function formatContext(ctx) {
|
|
110
|
+
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
111
|
+
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
112
|
+
}
|
|
113
|
+
var ToolError = class extends WrongStackError {
|
|
114
|
+
toolName;
|
|
115
|
+
constructor(opts) {
|
|
116
|
+
super({
|
|
117
|
+
message: opts.message,
|
|
118
|
+
code: opts.code,
|
|
119
|
+
subsystem: "tool",
|
|
120
|
+
recoverable: opts.recoverable,
|
|
121
|
+
context: { tool: opts.toolName, ...opts.context },
|
|
122
|
+
cause: opts.cause
|
|
123
|
+
});
|
|
124
|
+
this.name = "ToolError";
|
|
125
|
+
this.toolName = opts.toolName;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var ConfigError = class extends WrongStackError {
|
|
129
|
+
constructor(opts) {
|
|
130
|
+
super({
|
|
131
|
+
message: opts.message,
|
|
132
|
+
code: opts.code,
|
|
133
|
+
subsystem: "config",
|
|
134
|
+
severity: "fatal",
|
|
135
|
+
recoverable: false,
|
|
136
|
+
context: opts.context,
|
|
137
|
+
cause: opts.cause
|
|
138
|
+
});
|
|
139
|
+
this.name = "ConfigError";
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var PluginError = class extends WrongStackError {
|
|
143
|
+
pluginName;
|
|
144
|
+
constructor(opts) {
|
|
145
|
+
super({
|
|
146
|
+
message: opts.message,
|
|
147
|
+
code: opts.code,
|
|
148
|
+
subsystem: "plugin",
|
|
149
|
+
severity: "error",
|
|
150
|
+
recoverable: opts.code === ERROR_CODES.PLUGIN_MISSING_DEPENDENCY,
|
|
151
|
+
context: { plugin: opts.pluginName, ...opts.context },
|
|
152
|
+
cause: opts.cause
|
|
153
|
+
});
|
|
154
|
+
this.name = "PluginError";
|
|
155
|
+
this.pluginName = opts.pluginName;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var AgentError = class extends WrongStackError {
|
|
159
|
+
constructor(opts) {
|
|
160
|
+
super({
|
|
161
|
+
message: opts.message,
|
|
162
|
+
code: opts.code,
|
|
163
|
+
subsystem: "agent",
|
|
164
|
+
severity: opts.code === ERROR_CODES.AGENT_ABORTED ? "warning" : "error",
|
|
165
|
+
recoverable: opts.recoverable ?? opts.code === ERROR_CODES.AGENT_ITERATION_LIMIT,
|
|
166
|
+
context: opts.context,
|
|
167
|
+
cause: opts.cause
|
|
168
|
+
});
|
|
169
|
+
this.name = "AgentError";
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
function toWrongStackError(err, code = ERROR_CODES.AGENT_RUN_FAILED) {
|
|
173
|
+
if (WrongStackError.isWrongStackError(err)) return err;
|
|
174
|
+
const message = toErrorMessage(err);
|
|
175
|
+
return new AgentError({
|
|
176
|
+
message,
|
|
177
|
+
code: code === "UNKNOWN" ? ERROR_CODES.AGENT_RUN_FAILED : code,
|
|
178
|
+
cause: err
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
var SessionError = class extends WrongStackError {
|
|
182
|
+
sessionId;
|
|
183
|
+
constructor(opts) {
|
|
184
|
+
super({
|
|
185
|
+
message: opts.message,
|
|
186
|
+
code: opts.code,
|
|
187
|
+
subsystem: "session",
|
|
188
|
+
severity: opts.code === ERROR_CODES.SESSION_WRITE_FAILED ? "error" : "warning",
|
|
189
|
+
recoverable: opts.code !== ERROR_CODES.SESSION_CORRUPTED,
|
|
190
|
+
context: { sessionId: opts.sessionId, ...opts.context },
|
|
191
|
+
cause: opts.cause
|
|
192
|
+
});
|
|
193
|
+
this.name = "SessionError";
|
|
194
|
+
this.sessionId = opts.sessionId;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var SddError = class extends WrongStackError {
|
|
198
|
+
constructor(opts) {
|
|
199
|
+
super({
|
|
200
|
+
message: opts.message,
|
|
201
|
+
code: opts.code,
|
|
202
|
+
subsystem: "sdd",
|
|
203
|
+
severity: opts.code === ERROR_CODES.SDD_PARSE_FAILED ? "warning" : "error",
|
|
204
|
+
recoverable: opts.code === ERROR_CODES.SDD_NOT_READY,
|
|
205
|
+
context: opts.context,
|
|
206
|
+
cause: opts.cause
|
|
207
|
+
});
|
|
208
|
+
this.name = "SddError";
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var FsError = class extends WrongStackError {
|
|
212
|
+
path;
|
|
213
|
+
constructor(opts) {
|
|
214
|
+
super({
|
|
215
|
+
message: opts.message,
|
|
216
|
+
code: opts.code,
|
|
217
|
+
subsystem: "fs",
|
|
218
|
+
severity: "error",
|
|
219
|
+
recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
|
|
220
|
+
context: { path: opts.path, ...opts.context },
|
|
221
|
+
cause: opts.cause
|
|
222
|
+
});
|
|
223
|
+
this.name = "FsError";
|
|
224
|
+
this.path = opts.path;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
var FetchError = class extends WrongStackError {
|
|
228
|
+
status;
|
|
229
|
+
constructor(opts) {
|
|
230
|
+
super({
|
|
231
|
+
message: opts.message,
|
|
232
|
+
code: ERROR_CODES.VALIDATION_ERROR,
|
|
233
|
+
subsystem: "general",
|
|
234
|
+
severity: "error",
|
|
235
|
+
recoverable: opts.status === 429 || opts.status >= 500,
|
|
236
|
+
context: { status: opts.status, ...opts.context },
|
|
237
|
+
cause: opts.cause
|
|
238
|
+
});
|
|
239
|
+
this.name = "FetchError";
|
|
240
|
+
this.status = opts.status;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var ToolValidationError = class extends WrongStackError {
|
|
244
|
+
constructor(opts) {
|
|
245
|
+
super({
|
|
246
|
+
message: opts.message,
|
|
247
|
+
code: ERROR_CODES.VALIDATION_ERROR,
|
|
248
|
+
subsystem: "general",
|
|
249
|
+
severity: "error",
|
|
250
|
+
recoverable: false,
|
|
251
|
+
context: { field: opts.field, ...opts.context },
|
|
252
|
+
cause: opts.cause
|
|
253
|
+
});
|
|
254
|
+
this.name = "ToolValidationError";
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var ParseError = class extends WrongStackError {
|
|
258
|
+
source;
|
|
259
|
+
constructor(opts) {
|
|
260
|
+
super({
|
|
261
|
+
message: opts.message,
|
|
262
|
+
code: ERROR_CODES.PARSE_FAILED,
|
|
263
|
+
subsystem: "general",
|
|
264
|
+
severity: "error",
|
|
265
|
+
recoverable: false,
|
|
266
|
+
context: { source: opts.source, ...opts.context },
|
|
267
|
+
cause: opts.cause
|
|
268
|
+
});
|
|
269
|
+
this.name = "ParseError";
|
|
270
|
+
this.source = opts.source;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
function isWrongStackError(err) {
|
|
274
|
+
return err instanceof WrongStackError;
|
|
275
|
+
}
|
|
276
|
+
function isToolError(err) {
|
|
277
|
+
return err instanceof ToolError;
|
|
278
|
+
}
|
|
279
|
+
function isConfigError(err) {
|
|
280
|
+
return err instanceof ConfigError;
|
|
281
|
+
}
|
|
282
|
+
function isPluginError(err) {
|
|
283
|
+
return err instanceof PluginError;
|
|
284
|
+
}
|
|
285
|
+
function isSessionError(err) {
|
|
286
|
+
return err instanceof SessionError;
|
|
287
|
+
}
|
|
288
|
+
function isAgentError(err) {
|
|
289
|
+
return err instanceof AgentError;
|
|
290
|
+
}
|
|
291
|
+
function isFsError(err) {
|
|
292
|
+
return err instanceof FsError;
|
|
293
|
+
}
|
|
294
|
+
function isToolValidationError(err) {
|
|
295
|
+
return err instanceof ToolValidationError;
|
|
296
|
+
}
|
|
297
|
+
function isFetchError(err) {
|
|
298
|
+
return err instanceof FetchError;
|
|
299
|
+
}
|
|
300
|
+
function isParseError(err) {
|
|
301
|
+
return err instanceof ParseError;
|
|
302
|
+
}
|
|
303
|
+
function isSddError(err) {
|
|
304
|
+
return err instanceof SddError;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export {
|
|
308
|
+
ERROR_CODES,
|
|
309
|
+
WrongStackError,
|
|
310
|
+
ToolError,
|
|
311
|
+
ConfigError,
|
|
312
|
+
PluginError,
|
|
313
|
+
AgentError,
|
|
314
|
+
toWrongStackError,
|
|
315
|
+
SessionError,
|
|
316
|
+
SddError,
|
|
317
|
+
FsError,
|
|
318
|
+
FetchError,
|
|
319
|
+
ToolValidationError,
|
|
320
|
+
ParseError,
|
|
321
|
+
isWrongStackError,
|
|
322
|
+
isToolError,
|
|
323
|
+
isConfigError,
|
|
324
|
+
isPluginError,
|
|
325
|
+
isSessionError,
|
|
326
|
+
isAgentError,
|
|
327
|
+
isFsError,
|
|
328
|
+
isToolValidationError,
|
|
329
|
+
isFetchError,
|
|
330
|
+
isParseError,
|
|
331
|
+
isSddError
|
|
332
|
+
};
|
|
333
|
+
//# sourceMappingURL=chunk-WOEZV3Q4.js.map
|