@wrongstack/core 0.9.19 → 0.9.20

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.
Files changed (63) hide show
  1. package/dist/{agent-bridge-DMVOX0cF.d.ts → agent-bridge-Dti3KXGk.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-C4qt9e5Y.d.ts → agent-subagent-runner-U-rs7kk7.d.ts} +3 -4
  3. package/dist/compactor-D7X96RLZ.d.ts +41 -0
  4. package/dist/{config-CWva0qoL.d.ts → config-CLXMDOSs.d.ts} +1 -1
  5. package/dist/{context-BRNbHmRM.d.ts → context-zkZeILpr.d.ts} +46 -0
  6. package/dist/coordination/index.d.ts +13 -13
  7. package/dist/coordination/index.js +660 -146
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +20 -20
  10. package/dist/defaults/index.js +918 -350
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-CiG9qUM_.d.ts → events-DH-9r-_C.d.ts} +42 -1
  13. package/dist/execution/index.d.ts +41 -30
  14. package/dist/execution/index.js +358 -112
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/extension/index.js.map +1 -1
  18. package/dist/{index-aizK8olO.d.ts → index-BIHJ4uII.d.ts} +11 -8
  19. package/dist/{index-p95HQ22A.d.ts → index-CFO9QmJo.d.ts} +8 -8
  20. package/dist/index.d.ts +311 -35
  21. package/dist/index.js +1933 -512
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/infrastructure/index.js +36 -0
  25. package/dist/infrastructure/index.js.map +1 -1
  26. package/dist/kernel/index.d.ts +9 -9
  27. package/dist/kernel/index.js.map +1 -1
  28. package/dist/{mcp-servers-BkVEqkRe.d.ts → mcp-servers-DkESgh0G.d.ts} +25 -3
  29. package/dist/models/index.d.ts +2 -2
  30. package/dist/models/index.js +1 -1
  31. package/dist/models/index.js.map +1 -1
  32. package/dist/{multi-agent-3ZnTB1aT.d.ts → multi-agent-DNp6lAzg.d.ts} +35 -23
  33. package/dist/{multi-agent-coordinator-bRaI_aD1.d.ts → multi-agent-coordinator-CAhsegPz.d.ts} +20 -2
  34. package/dist/{null-fleet-bus-DKM3Iy9d.d.ts → null-fleet-bus-Dnl19vmf.d.ts} +411 -110
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{path-resolver-TcJfc29Y.d.ts → path-resolver-CHiBL0DD.d.ts} +2 -2
  37. package/dist/{permission-bPuzAy4x.d.ts → permission-H35s9Evv.d.ts} +1 -1
  38. package/dist/{permission-policy-BUQSutpl.d.ts → permission-policy-CT-nRmTn.d.ts} +2 -2
  39. package/dist/{plan-templates-fkQTyz3U.d.ts → plan-templates-Bs8iRwi6.d.ts} +4 -4
  40. package/dist/{provider-runner-BEpikbbN.d.ts → provider-runner-BZdDrWrS.d.ts} +3 -3
  41. package/dist/{retry-policy-BYkq0ugs.d.ts → retry-policy-J9N_PM40.d.ts} +1 -1
  42. package/dist/sdd/index.d.ts +9 -10
  43. package/dist/sdd/index.js +224 -68
  44. package/dist/sdd/index.js.map +1 -1
  45. package/dist/security/index.d.ts +3 -3
  46. package/dist/{selector-pox8abg0.d.ts → selector-CFTh3Z6p.d.ts} +1 -1
  47. package/dist/{session-reader-CSWcb5Ga.d.ts → session-reader-C7JJlxOw.d.ts} +2 -2
  48. package/dist/skills/index.d.ts +1 -1
  49. package/dist/skills/index.js +1 -1
  50. package/dist/skills/index.js.map +1 -1
  51. package/dist/storage/index.d.ts +390 -6
  52. package/dist/storage/index.js +672 -35
  53. package/dist/storage/index.js.map +1 -1
  54. package/dist/{system-prompt-Bs-Wliab.d.ts → system-prompt-CneIxVip.d.ts} +1 -1
  55. package/dist/{tool-executor-Boo3dekH.d.ts → tool-executor-flTuxsqO.d.ts} +9 -4
  56. package/dist/types/index.d.ts +14 -14
  57. package/dist/types/index.js +60 -0
  58. package/dist/types/index.js.map +1 -1
  59. package/dist/utils/index.d.ts +18 -6
  60. package/dist/utils/index.js +61 -56
  61. package/dist/utils/index.js.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/compactor-DVTKL7XD.d.ts +0 -23
@@ -1,4 +1,4 @@
1
- import { N as TodoItem, M as Message, J as JSONSchema } from '../context-BRNbHmRM.js';
1
+ import { N as TodoItem, M as Message, J as JSONSchema } from '../context-zkZeILpr.js';
2
2
  export { W as WstackPathOptions, a as WstackPaths, p as projectHash, r as resolveWstackPaths } from '../wstack-paths-BCgmTNlG.js';
3
3
 
4
4
  interface AtomicWriteOptions {
@@ -255,12 +255,24 @@ declare function compileUserRegex(pattern: string, flags: string): CompileResult
255
255
 
256
256
  /**
257
257
  * Attempt to close an incomplete JSON object string by auto-closing braces
258
- * and completing any unclosed double-quoted string values. This handles the
259
- * common streaming truncation case where the JSON stream ends mid-object
260
- * (e.g. `{"old_string": "line1\nline2` without the closing `"}` and `}`).
258
+ * and completing any unclosed double-quoted string values.
261
259
  *
262
- * Returns the completed string on best-effort, or the original if no useful
263
- * salvage was possible.
260
+ * Strategy:
261
+ * 1. Compute origOpen from the ORIGINAL input (how many braces are unclosed).
262
+ * 2. Add that many closing braces. If result is now valid JSON → return it.
263
+ * 3. If still invalid: trim trailing whitespace, strip trailing backslash.
264
+ * 4. Walk backwards to detect an unclosed string value.
265
+ * - Quote followed by `:` → key-name, skip
266
+ * - Quote followed by `,` `}` or end-of-string → toggle in/out of string
267
+ * 5. If we end INSIDE a string (unclosed opening `"`), append `"` + origOpen `}`.
268
+ *
269
+ * Known limitations:
270
+ * - Strings whose content ends with a `"` character cannot be repaired
271
+ * (algorithm can't distinguish content-`"` from string-terminator `"`).
272
+ * - Input ending in bare `:` (incomplete value expression) can't be meaningfully repaired.
273
+ * - Bare `{` returns unchanged.
274
+ * - If origOpen=0 (braces balanced) but string is unclosed, repair is skipped
275
+ * (the input would be valid JSON per JSON.parse, so it's returned as-is).
264
276
  */
265
277
  declare function completePartialObject(s: string): string;
266
278
 
@@ -959,80 +959,85 @@ function compileUserRegex(pattern, flags) {
959
959
 
960
960
  // src/utils/json-repair.ts
961
961
  function completePartialObject(s) {
962
- let result = s;
963
- const trimmed = result.trim();
964
- if (!trimmed.startsWith("{")) return s;
965
- for (let pass = 0; pass < 3; pass++) {
966
- let braceDepth = 0;
967
- let inString2 = false;
968
- let escaped2 = false;
969
- let foundClose = false;
970
- for (const ch of result) {
971
- if (escaped2) {
972
- escaped2 = false;
962
+ if (!s.trim().startsWith("{")) return s;
963
+ if (tryParse(s).ok) return s;
964
+ const stack = [];
965
+ let inString = false;
966
+ let escaped = false;
967
+ let sawKey = false;
968
+ let prevSig = "";
969
+ let contentEnd = 0;
970
+ let stringBraceDepth = 0;
971
+ for (let i = 0; i < s.length; i++) {
972
+ const ch = s[i];
973
+ if (inString) {
974
+ contentEnd = i + 1;
975
+ if (escaped) {
976
+ escaped = false;
973
977
  continue;
974
978
  }
975
979
  if (ch === "\\") {
976
- escaped2 = true;
980
+ escaped = true;
977
981
  continue;
978
982
  }
979
983
  if (ch === '"') {
980
- inString2 = !inString2;
984
+ inString = false;
985
+ prevSig = '"';
986
+ stringBraceDepth = 0;
981
987
  continue;
982
988
  }
983
- if (inString2) continue;
984
- if (ch === "{") {
985
- braceDepth++;
986
- foundClose = false;
987
- } else if (ch === "}") {
988
- braceDepth--;
989
- if (braceDepth === 0) foundClose = true;
990
- }
991
- }
992
- if (foundClose || braceDepth <= 0) break;
993
- result += "}".repeat(braceDepth);
994
- }
995
- if (tryParse(result).ok) return result;
996
- let inString = false;
997
- let escaped = false;
998
- for (let i = result.length - 1; i >= 0; i--) {
999
- const ch = result[i];
1000
- if (escaped) {
1001
- escaped = false;
1002
- continue;
1003
- }
1004
- if (ch === "\\") {
1005
- escaped = true;
989
+ if (ch === "{") stringBraceDepth++;
990
+ else if (ch === "}" && stringBraceDepth > 0) stringBraceDepth--;
1006
991
  continue;
1007
992
  }
993
+ if (ch === " " || ch === " " || ch === "\n" || ch === "\r") continue;
994
+ contentEnd = i + 1;
1008
995
  if (ch === '"') {
1009
- let nextNonWs;
1010
- for (let j = i + 1; j < result.length; j++) {
1011
- const nc = result[j];
1012
- if (nc === " " || nc === " " || nc === "\n" || nc === "\r") continue;
1013
- nextNonWs = result[j];
1014
- break;
1015
- }
1016
- if (nextNonWs === ":") {
1017
- continue;
1018
- } else {
1019
- inString = !inString;
1020
- continue;
1021
- }
996
+ inString = true;
997
+ sawKey = true;
998
+ stringBraceDepth = 0;
999
+ prevSig = '"';
1000
+ } else if (ch === "{" || ch === "[") {
1001
+ stack.push(ch);
1002
+ prevSig = ch;
1003
+ } else if (ch === "}" || ch === "]") {
1004
+ stack.pop();
1005
+ prevSig = ch;
1006
+ } else {
1007
+ prevSig = ch;
1022
1008
  }
1023
1009
  }
1010
+ if (!sawKey && !inString) return s;
1011
+ let result = s.slice(0, contentEnd);
1024
1012
  if (inString) {
1025
- result = result.trimEnd();
1026
- if (result.endsWith("\\")) result = result.slice(0, -1);
1027
- let depth = 0;
1028
- for (const ch of result) {
1029
- if (ch === "{") depth++;
1030
- else if (ch === "}") depth = Math.max(0, depth - 1);
1013
+ if (escaped) {
1014
+ result = result.slice(0, -1);
1015
+ } else if (endsWithInvalidEscape(result)) {
1016
+ result = result.slice(0, -2);
1031
1017
  }
1032
- result += '"' + "}".repeat(Math.max(1, depth));
1018
+ if (stringBraceDepth > 0) result += "}".repeat(stringBraceDepth);
1019
+ result += '"';
1020
+ } else if (prevSig === ":") {
1021
+ result += "null";
1022
+ }
1023
+ for (let k = stack.length - 1; k >= 0; k--) {
1024
+ result += stack[k] === "{" ? "}" : "]";
1025
+ }
1026
+ if (!tryParse(result).ok) {
1027
+ const patched = result.replace(/:(\s*)([}\]])/g, ":null$2");
1028
+ if (tryParse(patched).ok) result = patched;
1033
1029
  }
1034
1030
  return result;
1035
1031
  }
1032
+ var VALID_ESCAPE = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
1033
+ function endsWithInvalidEscape(str) {
1034
+ const last = str[str.length - 1];
1035
+ if (str[str.length - 2] !== "\\" || last === void 0) return false;
1036
+ if (VALID_ESCAPE.has(last)) return false;
1037
+ let backslashes = 0;
1038
+ for (let k = str.length - 2; k >= 0 && str[k] === "\\"; k--) backslashes++;
1039
+ return backslashes % 2 === 1;
1040
+ }
1036
1041
  function tryParse(s) {
1037
1042
  try {
1038
1043
  return { ok: true, value: JSON.parse(s) };