@wrongstack/core 0.265.1 → 0.267.0
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/{agent-bridge-DrkBxszZ.d.ts → agent-bridge-STJ3JwwK.d.ts} +1 -1
- package/dist/{agent-subagent-runner-DM2pP-B6.d.ts → agent-subagent-runner-CzPGP3jA.d.ts} +25 -7
- package/dist/{brain-BXd_61kQ.d.ts → brain-Cdg77tVN.d.ts} +73 -1
- package/dist/{compactor-B8pOf45Y.d.ts → compactor-iMZ84CXq.d.ts} +19 -1
- package/dist/{config-BMCj_XDs.d.ts → config-Du3pYYln.d.ts} +54 -3
- package/dist/{context-MRk5PhNv.d.ts → context-dT5Ueund.d.ts} +65 -1
- package/dist/coordination/index.d.ts +17 -17
- package/dist/coordination/index.js +138 -114
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +25 -25
- package/dist/defaults/index.js +1729 -781
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +15 -15
- package/dist/execution/index.js +1119 -229
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{goal-preamble-DvHDSKSe.d.ts → goal-preamble-SulMTowG.d.ts} +28 -11
- package/dist/{goal-store-DtLMySNb.d.ts → goal-store-CABDwdFE.d.ts} +1 -1
- package/dist/{index-CEDeNodM.d.ts → index-Bms0m4oy.d.ts} +5 -5
- package/dist/{index-B-ch8K9C.d.ts → index-DtCVWel4.d.ts} +8 -8
- package/dist/index-IEuxQd-E.d.ts +82 -0
- package/dist/index.d.ts +118 -45
- package/dist/index.js +3083 -1602
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/infrastructure/index.js +72 -1
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +9 -9
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-2x4w6Jn9.d.ts → mcp-servers-C2cBTxUR.d.ts} +3 -3
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +30 -1
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-DmJlKuNp.d.ts → models-registry-BqGZNJQ-.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-DyCkCZnU.d.ts → multi-agent-coordinator-B8R43uPz.d.ts} +1 -1
- package/dist/{null-fleet-bus-CG9QY2aP.d.ts → null-fleet-bus-CnXa5oTH.d.ts} +14 -9
- package/dist/observability/index.d.ts +2 -2
- package/dist/{parallel-eternal-engine-Jw9uhEoT.d.ts → parallel-eternal-engine-DdNnw9BQ.d.ts} +11 -9
- package/dist/{path-resolver-Dy2ej-gE.d.ts → path-resolver-COIMLCQL.d.ts} +3 -3
- package/dist/{permission-B9SB45lp.d.ts → permission-B75JAi3-.d.ts} +1 -1
- package/dist/{permission-policy-CkjSXabK.d.ts → permission-policy-DlR9eJAM.d.ts} +2 -2
- package/dist/{pipeline-DPDxH_7m.d.ts → pipeline-BfD2k1rT.d.ts} +2 -2
- package/dist/{plan-templates-CzD9GnAU.d.ts → plan-templates-DSIKCXZN.d.ts} +5 -5
- package/dist/{llm-selector-C0tfTCUe.d.ts → provider-model-resolve-BNRsNuJx.d.ts} +40 -3
- package/dist/{provider-runner-DMa70ODu.d.ts → provider-runner-CX7iIvox.d.ts} +3 -3
- package/dist/{retry-policy-CN0khdlj.d.ts → retry-policy-BilV1ujH.d.ts} +1 -1
- package/dist/sdd/index.d.ts +8 -8
- package/dist/sdd/index.js +12 -12
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-B2yw84VT.d.ts → secret-vault-gkvEZZfE.d.ts} +2 -2
- package/dist/security/index.d.ts +5 -67
- package/dist/security/index.js +96 -76
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-CzHh_igB.d.ts → selector-Bc7eWtT3.d.ts} +1 -1
- package/dist/{session-event-bridge-BUI6Jf-4.d.ts → session-event-bridge-D-araDEz.d.ts} +1 -1
- package/dist/{session-reader-CMgdMSRP.d.ts → session-reader-D7Dapswh.d.ts} +1 -1
- package/dist/storage/index.d.ts +11 -11
- package/dist/storage/index.js +81 -84
- package/dist/storage/index.js.map +1 -1
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +19 -19
- package/dist/types/index.js +1265 -400
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +454 -406
- package/dist/utils/index.js +2191 -1201
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -449,11 +449,6 @@ function safeParse(input, maxBytes = 5e6) {
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
// src/utils/string.ts
|
|
453
|
-
function truncate(s, max) {
|
|
454
|
-
return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
452
|
// src/utils/expect-defined.ts
|
|
458
453
|
function expectDefined(value, label) {
|
|
459
454
|
if (value === null || value === void 0) {
|
|
@@ -463,111 +458,6 @@ function expectDefined(value, label) {
|
|
|
463
458
|
}
|
|
464
459
|
return value;
|
|
465
460
|
}
|
|
466
|
-
function projectSlug(absRoot) {
|
|
467
|
-
const base = slugify(path5.basename(absRoot));
|
|
468
|
-
const hash = createHash("sha256").update(path5.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
469
|
-
return `${base}-${hash}`;
|
|
470
|
-
}
|
|
471
|
-
function slugify(name) {
|
|
472
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
|
|
473
|
-
}
|
|
474
|
-
function wstackGlobalRoot() {
|
|
475
|
-
const fromEnv = process.env["WRONGSTACK_HOME"];
|
|
476
|
-
if (fromEnv && fromEnv.trim().length > 0) return path5.resolve(fromEnv);
|
|
477
|
-
return path5.join(os.homedir(), ".wrongstack");
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// src/utils/message-invariants.ts
|
|
481
|
-
function repairToolUseAdjacency(messages) {
|
|
482
|
-
const removedToolUses = [];
|
|
483
|
-
const removedToolResults = [];
|
|
484
|
-
let removedMessages = 0;
|
|
485
|
-
let changed = false;
|
|
486
|
-
const out = [];
|
|
487
|
-
for (let i = 0; i < messages.length; i++) {
|
|
488
|
-
const original = expectDefined(messages[i]);
|
|
489
|
-
let msg = original;
|
|
490
|
-
if (hasToolUse(msg)) {
|
|
491
|
-
const nextIds = toolResultIds(messages[i + 1]);
|
|
492
|
-
const filtered = mapContent(msg, (blocks) => {
|
|
493
|
-
const next = [];
|
|
494
|
-
for (const block of blocks) {
|
|
495
|
-
if (block.type === "tool_use" && !nextIds.has(block.id)) {
|
|
496
|
-
removedToolUses.push(block.id);
|
|
497
|
-
changed = true;
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
next.push(block);
|
|
501
|
-
}
|
|
502
|
-
return next;
|
|
503
|
-
});
|
|
504
|
-
msg = filtered ?? msg;
|
|
505
|
-
}
|
|
506
|
-
if (hasToolResult(msg)) {
|
|
507
|
-
const allowed = toolUseIds(out[out.length - 1]);
|
|
508
|
-
const filtered = mapContent(msg, (blocks) => {
|
|
509
|
-
const next = [];
|
|
510
|
-
for (const block of blocks) {
|
|
511
|
-
if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
|
|
512
|
-
removedToolResults.push(block.tool_use_id);
|
|
513
|
-
changed = true;
|
|
514
|
-
continue;
|
|
515
|
-
}
|
|
516
|
-
next.push(block);
|
|
517
|
-
}
|
|
518
|
-
return next;
|
|
519
|
-
});
|
|
520
|
-
msg = filtered ?? msg;
|
|
521
|
-
}
|
|
522
|
-
if (isEmptyMessage(msg)) {
|
|
523
|
-
removedMessages++;
|
|
524
|
-
changed = true;
|
|
525
|
-
continue;
|
|
526
|
-
}
|
|
527
|
-
out.push(msg);
|
|
528
|
-
}
|
|
529
|
-
return {
|
|
530
|
-
messages: changed ? out : messages,
|
|
531
|
-
report: { changed, removedToolUses, removedToolResults, removedMessages }
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
function hasToolUse(msg) {
|
|
535
|
-
return contentBlocks(msg).some((b) => b.type === "tool_use");
|
|
536
|
-
}
|
|
537
|
-
function hasToolResult(msg) {
|
|
538
|
-
return contentBlocks(msg).some((b) => b.type === "tool_result");
|
|
539
|
-
}
|
|
540
|
-
function toolUseIds(msg) {
|
|
541
|
-
const ids = /* @__PURE__ */ new Set();
|
|
542
|
-
if (!msg || msg.role !== "assistant") return ids;
|
|
543
|
-
for (const block of contentBlocks(msg)) {
|
|
544
|
-
if (block.type === "tool_use") ids.add(block.id);
|
|
545
|
-
}
|
|
546
|
-
return ids;
|
|
547
|
-
}
|
|
548
|
-
function toolResultIds(msg) {
|
|
549
|
-
const ids = /* @__PURE__ */ new Set();
|
|
550
|
-
if (!msg || msg.role !== "user") return ids;
|
|
551
|
-
for (const block of contentBlocks(msg)) {
|
|
552
|
-
if (block.type === "tool_result") ids.add(block.tool_use_id);
|
|
553
|
-
}
|
|
554
|
-
return ids;
|
|
555
|
-
}
|
|
556
|
-
function contentBlocks(msg) {
|
|
557
|
-
return msg && Array.isArray(msg.content) ? msg.content : [];
|
|
558
|
-
}
|
|
559
|
-
function mapContent(msg, fn) {
|
|
560
|
-
if (!Array.isArray(msg.content)) return msg;
|
|
561
|
-
const next = fn(msg.content);
|
|
562
|
-
if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
|
|
563
|
-
return msg;
|
|
564
|
-
}
|
|
565
|
-
return { ...msg, content: next };
|
|
566
|
-
}
|
|
567
|
-
function isEmptyMessage(msg) {
|
|
568
|
-
if (typeof msg.content === "string") return msg.content.trim().length === 0;
|
|
569
|
-
return msg.content.length === 0;
|
|
570
|
-
}
|
|
571
461
|
var GLOB_CHARS = /* @__PURE__ */ new Set(["*", "?", "["]);
|
|
572
462
|
var IS_WINDOWS = process.platform === "win32";
|
|
573
463
|
var SEP = IS_WINDOWS ? "\\" : "/";
|
|
@@ -684,6 +574,116 @@ async function expandGlob(pattern) {
|
|
|
684
574
|
return [...results];
|
|
685
575
|
}
|
|
686
576
|
|
|
577
|
+
// src/utils/message-invariants.ts
|
|
578
|
+
function repairToolUseAdjacency(messages) {
|
|
579
|
+
const removedToolUses = [];
|
|
580
|
+
const removedToolResults = [];
|
|
581
|
+
let removedMessages = 0;
|
|
582
|
+
let changed = false;
|
|
583
|
+
const out = [];
|
|
584
|
+
for (let i = 0; i < messages.length; i++) {
|
|
585
|
+
const original = expectDefined(messages[i]);
|
|
586
|
+
let msg = original;
|
|
587
|
+
if (hasToolUse(msg)) {
|
|
588
|
+
const nextIds = toolResultIds(messages[i + 1]);
|
|
589
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
590
|
+
const next = [];
|
|
591
|
+
for (const block of blocks) {
|
|
592
|
+
if (block.type === "tool_use" && !nextIds.has(block.id)) {
|
|
593
|
+
removedToolUses.push(block.id);
|
|
594
|
+
changed = true;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
next.push(block);
|
|
598
|
+
}
|
|
599
|
+
return next;
|
|
600
|
+
});
|
|
601
|
+
msg = filtered ?? msg;
|
|
602
|
+
}
|
|
603
|
+
if (hasToolResult(msg)) {
|
|
604
|
+
const allowed = toolUseIds(out[out.length - 1]);
|
|
605
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
606
|
+
const next = [];
|
|
607
|
+
for (const block of blocks) {
|
|
608
|
+
if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
|
|
609
|
+
removedToolResults.push(block.tool_use_id);
|
|
610
|
+
changed = true;
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
next.push(block);
|
|
614
|
+
}
|
|
615
|
+
return next;
|
|
616
|
+
});
|
|
617
|
+
msg = filtered ?? msg;
|
|
618
|
+
}
|
|
619
|
+
if (isEmptyMessage(msg)) {
|
|
620
|
+
removedMessages++;
|
|
621
|
+
changed = true;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
out.push(msg);
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
messages: changed ? out : messages,
|
|
628
|
+
report: { changed, removedToolUses, removedToolResults, removedMessages }
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
function hasToolUse(msg) {
|
|
632
|
+
return contentBlocks(msg).some((b) => b.type === "tool_use");
|
|
633
|
+
}
|
|
634
|
+
function hasToolResult(msg) {
|
|
635
|
+
return contentBlocks(msg).some((b) => b.type === "tool_result");
|
|
636
|
+
}
|
|
637
|
+
function toolUseIds(msg) {
|
|
638
|
+
const ids = /* @__PURE__ */ new Set();
|
|
639
|
+
if (!msg || msg.role !== "assistant") return ids;
|
|
640
|
+
for (const block of contentBlocks(msg)) {
|
|
641
|
+
if (block.type === "tool_use") ids.add(block.id);
|
|
642
|
+
}
|
|
643
|
+
return ids;
|
|
644
|
+
}
|
|
645
|
+
function toolResultIds(msg) {
|
|
646
|
+
const ids = /* @__PURE__ */ new Set();
|
|
647
|
+
if (!msg || msg.role !== "user") return ids;
|
|
648
|
+
for (const block of contentBlocks(msg)) {
|
|
649
|
+
if (block.type === "tool_result") ids.add(block.tool_use_id);
|
|
650
|
+
}
|
|
651
|
+
return ids;
|
|
652
|
+
}
|
|
653
|
+
function contentBlocks(msg) {
|
|
654
|
+
return msg && Array.isArray(msg.content) ? msg.content : [];
|
|
655
|
+
}
|
|
656
|
+
function mapContent(msg, fn) {
|
|
657
|
+
if (!Array.isArray(msg.content)) return msg;
|
|
658
|
+
const next = fn(msg.content);
|
|
659
|
+
if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
|
|
660
|
+
return msg;
|
|
661
|
+
}
|
|
662
|
+
return { ...msg, content: next };
|
|
663
|
+
}
|
|
664
|
+
function isEmptyMessage(msg) {
|
|
665
|
+
if (typeof msg.content === "string") return msg.content.trim().length === 0;
|
|
666
|
+
return msg.content.length === 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// src/utils/string.ts
|
|
670
|
+
function truncate(s, max) {
|
|
671
|
+
return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
|
|
672
|
+
}
|
|
673
|
+
function projectSlug(absRoot) {
|
|
674
|
+
const base = slugify(path5.basename(absRoot));
|
|
675
|
+
const hash = createHash("sha256").update(path5.resolve(absRoot)).digest("hex").slice(0, 6);
|
|
676
|
+
return `${base}-${hash}`;
|
|
677
|
+
}
|
|
678
|
+
function slugify(name) {
|
|
679
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
|
|
680
|
+
}
|
|
681
|
+
function wstackGlobalRoot() {
|
|
682
|
+
const fromEnv = process.env["WRONGSTACK_HOME"];
|
|
683
|
+
if (fromEnv && fromEnv.trim().length > 0) return path5.resolve(fromEnv);
|
|
684
|
+
return path5.join(os.homedir(), ".wrongstack");
|
|
685
|
+
}
|
|
686
|
+
|
|
687
687
|
// src/types/errors.ts
|
|
688
688
|
var ERROR_CODES = {
|
|
689
689
|
// Provider
|
|
@@ -1539,6 +1539,24 @@ Working rules:
|
|
|
1539
1539
|
var DEFAULT_SUBAGENT_BASELINE = `You are a subagent operating under a Director. You were spawned to handle
|
|
1540
1540
|
a specific slice of a larger plan \u2014 do that slice well and report back.
|
|
1541
1541
|
|
|
1542
|
+
Capabilities & operating rules:
|
|
1543
|
+
- You have full developer tools for your task: read, write/edit, search,
|
|
1544
|
+
shell + build (lint, format, typecheck, test), and dependency install.
|
|
1545
|
+
Use them directly to finish the task end-to-end. You run non-interactively
|
|
1546
|
+
\u2014 there is no human to approve individual tool calls, so routine work is
|
|
1547
|
+
pre-authorized; do not stop to ask for permission to read, edit, or build.
|
|
1548
|
+
- Stay inside the project root. Do not write files outside the repository,
|
|
1549
|
+
and do not touch machine config, credentials, or global state \u2014 those
|
|
1550
|
+
require an explicit grant you do not have.
|
|
1551
|
+
- Prefer the least-destructive path. Do not run irreversible or destructive
|
|
1552
|
+
commands (e.g. \`rm -rf\`, \`git push --force\`, history rewrites, dropping
|
|
1553
|
+
databases, mass deletes) unless the task explicitly requires it and names
|
|
1554
|
+
the target.
|
|
1555
|
+
- When you change code, verify it: run the relevant build / typecheck / tests
|
|
1556
|
+
and fix what you broke before reporting done.
|
|
1557
|
+
- Make only the changes the task calls for \u2014 don't refactor or reformat
|
|
1558
|
+
unrelated code.
|
|
1559
|
+
|
|
1542
1560
|
Bridge contract:
|
|
1543
1561
|
- You have a parent (the Director). You may call \`request\` on the
|
|
1544
1562
|
parent bridge to ask a clarifying question. Use this sparingly; the
|
|
@@ -6996,6 +7014,8 @@ var Director = class _Director {
|
|
|
6996
7014
|
sessionsRoot;
|
|
6997
7015
|
/** Director run id for JSONL path resolution. */
|
|
6998
7016
|
directorRunId;
|
|
7017
|
+
/** Optional logger for structured logging. Falls back to noop when omitted. */
|
|
7018
|
+
logger;
|
|
6999
7019
|
/** Resolves task descriptions back from `assign()` so completion events
|
|
7000
7020
|
* can also carry a human-readable title. */
|
|
7001
7021
|
taskDescriptions = /* @__PURE__ */ new Map();
|
|
@@ -7084,6 +7104,7 @@ var Director = class _Director {
|
|
|
7084
7104
|
opts.checkpointDebounceMs ?? 250
|
|
7085
7105
|
) : null;
|
|
7086
7106
|
this.fleetManager = opts.fleetManager;
|
|
7107
|
+
this.logger = opts.logger;
|
|
7087
7108
|
if (this.sharedScratchpadPath) {
|
|
7088
7109
|
void fsp6.mkdir(this.sharedScratchpadPath, { recursive: true }).catch((err) => this.logShutdownError("shared_scratchpad_mkdir", err));
|
|
7089
7110
|
}
|
|
@@ -7383,7 +7404,10 @@ var Director = class _Director {
|
|
|
7383
7404
|
entry.session.cancel(reason);
|
|
7384
7405
|
for (const [_role, subagentId] of entry.session.getSubagentIds()) {
|
|
7385
7406
|
this.coordinator.stop(subagentId).catch((err) => {
|
|
7386
|
-
|
|
7407
|
+
this.logger?.debug(`stop subagent ${subagentId} failed (may have already completed)`, {
|
|
7408
|
+
subagentId,
|
|
7409
|
+
err: err instanceof Error ? err.message : String(err)
|
|
7410
|
+
});
|
|
7387
7411
|
});
|
|
7388
7412
|
}
|
|
7389
7413
|
}
|
|
@@ -7443,7 +7467,7 @@ var Director = class _Director {
|
|
|
7443
7467
|
* Caller-supplied `priceLookup` is optional but recommended — without
|
|
7444
7468
|
* it the `cost` column in `usage.snapshot()` stays at 0.
|
|
7445
7469
|
*/
|
|
7446
|
-
async spawn(
|
|
7470
|
+
async spawn(callerConfig, priceLookup) {
|
|
7447
7471
|
if (this.workCompleteFlag) {
|
|
7448
7472
|
throw new FleetSpawnBudgetError(
|
|
7449
7473
|
"max_spawns",
|
|
@@ -7452,6 +7476,7 @@ var Director = class _Director {
|
|
|
7452
7476
|
"workComplete() has been called \u2014 director closed further spawning"
|
|
7453
7477
|
);
|
|
7454
7478
|
}
|
|
7479
|
+
const config = { ...callerConfig };
|
|
7455
7480
|
if (!config.model && this.modelMatrix) {
|
|
7456
7481
|
const matrix = typeof this.modelMatrix === "function" ? this.modelMatrix() : this.modelMatrix;
|
|
7457
7482
|
const entry = resolveModelMatrix(matrix, config.role);
|
|
@@ -12985,8 +13010,7 @@ var ChangeManager = class {
|
|
|
12985
13010
|
// filled after quality gate
|
|
12986
13011
|
satisfiesGoals: input.satisfiesGoals
|
|
12987
13012
|
});
|
|
12988
|
-
void this._runQualityGate(node.id, input.files).then((gate) => {
|
|
12989
|
-
void this.graph.update(node.id, { qualityGate: gate });
|
|
13013
|
+
void this._runQualityGate(node.id, input.files).then((gate) => this.graph.update(node.id, { qualityGate: gate })).catch(() => {
|
|
12990
13014
|
});
|
|
12991
13015
|
this._emit("change:proposed", { changeId: node.id, title: node.title });
|
|
12992
13016
|
return node;
|