@wrongstack/core 0.285.0 → 0.287.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/autophase/phase-orchestrator.d.ts.map +1 -1
- package/dist/boot.d.ts.map +1 -1
- package/dist/coordination/agent-monitor.d.ts +29 -0
- package/dist/coordination/agent-monitor.d.ts.map +1 -1
- package/dist/coordination/autonomous-brain.d.ts +0 -2
- package/dist/coordination/autonomous-brain.d.ts.map +1 -1
- package/dist/coordination/autonomous-coordinator.d.ts +4 -0
- package/dist/coordination/autonomous-coordinator.d.ts.map +1 -1
- package/dist/coordination/brain-ledger.d.ts +142 -0
- package/dist/coordination/brain-ledger.d.ts.map +1 -0
- package/dist/coordination/brain-monitor.d.ts +46 -2
- package/dist/coordination/brain-monitor.d.ts.map +1 -1
- package/dist/coordination/brain.d.ts +43 -0
- package/dist/coordination/brain.d.ts.map +1 -1
- package/dist/coordination/delegate-tool.d.ts +8 -14
- package/dist/coordination/delegate-tool.d.ts.map +1 -1
- package/dist/coordination/director/director-btw-notes.d.ts +20 -0
- package/dist/coordination/director/director-btw-notes.d.ts.map +1 -0
- package/dist/coordination/director/director-collab.d.ts +40 -0
- package/dist/coordination/director/director-collab.d.ts.map +1 -0
- package/dist/coordination/director.d.ts +28 -9
- package/dist/coordination/director.d.ts.map +1 -1
- package/dist/coordination/fleet-manager.d.ts +21 -0
- package/dist/coordination/fleet-manager.d.ts.map +1 -1
- package/dist/coordination/fleet.d.ts +6 -7
- package/dist/coordination/fleet.d.ts.map +1 -1
- package/dist/coordination/global-mailbox.d.ts +96 -21
- package/dist/coordination/global-mailbox.d.ts.map +1 -1
- package/dist/coordination/icoordinator.d.ts +1 -3
- package/dist/coordination/icoordinator.d.ts.map +1 -1
- package/dist/coordination/index.d.ts +2 -1
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +2176 -806
- package/dist/coordination/index.js.map +4 -4
- package/dist/coordination/knowledge-graph.d.ts +13 -1
- package/dist/coordination/knowledge-graph.d.ts.map +1 -1
- package/dist/coordination/mail-tools.d.ts.map +1 -1
- package/dist/coordination/mailbox-actions.d.ts +12 -13
- package/dist/coordination/mailbox-actions.d.ts.map +1 -1
- package/dist/coordination/mailbox-constants.d.ts +64 -0
- package/dist/coordination/mailbox-constants.d.ts.map +1 -0
- package/dist/coordination/mailbox-events.d.ts +32 -0
- package/dist/coordination/mailbox-events.d.ts.map +1 -0
- package/dist/coordination/mailbox-message-codec.d.ts +28 -0
- package/dist/coordination/mailbox-message-codec.d.ts.map +1 -0
- package/dist/coordination/mailbox-types.d.ts +130 -5
- package/dist/coordination/mailbox-types.d.ts.map +1 -1
- package/dist/coordination/mailbox.d.ts +21 -2
- package/dist/coordination/mailbox.d.ts.map +1 -1
- package/dist/coordination/package-author-tracker.d.ts.map +1 -1
- package/dist/coordination/subagent-result-tool.d.ts.map +1 -1
- package/dist/core/agent-loop.d.ts.map +1 -1
- package/dist/core/agent-response.d.ts +10 -1
- package/dist/core/agent-response.d.ts.map +1 -1
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent.d.ts +8 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/context.d.ts +25 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/conversation-state.d.ts +6 -0
- package/dist/core/conversation-state.d.ts.map +1 -1
- package/dist/core/fallback-model.d.ts.map +1 -1
- package/dist/core/mailbox-loop.d.ts +12 -5
- package/dist/core/mailbox-loop.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +14 -6
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/defaults/index.d.ts +0 -1
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +1690 -1998
- package/dist/defaults/index.js.map +4 -4
- package/dist/execution/auto-compaction-middleware.d.ts +8 -1
- package/dist/execution/auto-compaction-middleware.d.ts.map +1 -1
- package/dist/execution/autonomous-runner.d.ts +7 -1
- package/dist/execution/autonomous-runner.d.ts.map +1 -1
- package/dist/execution/autonomy-brain.d.ts +72 -11
- package/dist/execution/autonomy-brain.d.ts.map +1 -1
- package/dist/execution/brain-chain.d.ts +53 -0
- package/dist/execution/brain-chain.d.ts.map +1 -0
- package/dist/execution/brain-evaluation.d.ts +66 -0
- package/dist/execution/brain-evaluation.d.ts.map +1 -0
- package/dist/execution/brain-runtime.d.ts +171 -0
- package/dist/execution/brain-runtime.d.ts.map +1 -0
- package/dist/execution/compaction-core.d.ts.map +1 -1
- package/dist/execution/council-brain.d.ts +79 -0
- package/dist/execution/council-brain.d.ts.map +1 -0
- package/dist/execution/council-orchestrator.d.ts +32 -0
- package/dist/execution/council-orchestrator.d.ts.map +1 -0
- package/dist/execution/council-personas.d.ts +19 -0
- package/dist/execution/council-personas.d.ts.map +1 -0
- package/dist/execution/council-profiles.d.ts +34 -0
- package/dist/execution/council-profiles.d.ts.map +1 -0
- package/dist/execution/council-prompts.d.ts +21 -0
- package/dist/execution/council-prompts.d.ts.map +1 -0
- package/dist/execution/council-resolution.d.ts +57 -0
- package/dist/execution/council-resolution.d.ts.map +1 -0
- package/dist/execution/design-kit-loader.d.ts.map +1 -1
- package/dist/execution/enhance-recovery.d.ts +35 -0
- package/dist/execution/enhance-recovery.d.ts.map +1 -0
- package/dist/execution/error-handler.d.ts.map +1 -1
- package/dist/execution/eternal-autonomy.d.ts +12 -0
- package/dist/execution/eternal-autonomy.d.ts.map +1 -1
- package/dist/execution/index.d.ts +11 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +3076 -526
- package/dist/execution/index.js.map +4 -4
- package/dist/execution/intelligent-compactor.d.ts +18 -7
- package/dist/execution/intelligent-compactor.d.ts.map +1 -1
- package/dist/execution/one-shot-llm.d.ts +52 -0
- package/dist/execution/one-shot-llm.d.ts.map +1 -0
- package/dist/execution/parallel-eternal-engine.d.ts +12 -0
- package/dist/execution/parallel-eternal-engine.d.ts.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +23 -4
- package/dist/execution/prompt-enhancer.d.ts.map +1 -1
- package/dist/execution/prompt-enhancer.js +24 -6
- package/dist/execution/prompt-enhancer.js.map +2 -2
- package/dist/execution/selective-compactor.d.ts +4 -4
- package/dist/execution/strategy-compactor.d.ts +7 -0
- package/dist/execution/strategy-compactor.d.ts.map +1 -1
- package/dist/execution/tool-executor.d.ts +19 -5
- package/dist/execution/tool-executor.d.ts.map +1 -1
- package/dist/hooks/registry.d.ts.map +1 -1
- package/dist/hooks/runner.d.ts.map +1 -1
- package/dist/hooks/shell-executor.d.ts.map +1 -1
- package/dist/hq/alerts.d.ts +5 -0
- package/dist/hq/alerts.d.ts.map +1 -1
- package/dist/hq/auth-store.d.ts +38 -10
- package/dist/hq/auth-store.d.ts.map +1 -1
- package/dist/hq/commands.d.ts +8 -4
- package/dist/hq/commands.d.ts.map +1 -1
- package/dist/hq/cost-bridge.d.ts +5 -3
- package/dist/hq/cost-bridge.d.ts.map +1 -1
- package/dist/hq/factory.d.ts +3 -0
- package/dist/hq/factory.d.ts.map +1 -1
- package/dist/hq/fleet-bridge.d.ts.map +1 -1
- package/dist/hq/index.d.ts +0 -1
- package/dist/hq/index.d.ts.map +1 -1
- package/dist/hq/index.js +1016 -283
- package/dist/hq/index.js.map +4 -4
- package/dist/hq/persistence.d.ts +42 -0
- package/dist/hq/persistence.d.ts.map +1 -1
- package/dist/hq/protocol/brain.d.ts +24 -0
- package/dist/hq/protocol/brain.d.ts.map +1 -0
- package/dist/hq/protocol/browser.d.ts +12 -0
- package/dist/hq/protocol/browser.d.ts.map +1 -0
- package/dist/hq/protocol/client.d.ts +69 -0
- package/dist/hq/protocol/client.d.ts.map +1 -0
- package/dist/hq/protocol/core.d.ts +130 -0
- package/dist/hq/protocol/core.d.ts.map +1 -0
- package/dist/hq/protocol/fleet.d.ts +73 -0
- package/dist/hq/protocol/fleet.d.ts.map +1 -0
- package/dist/hq/protocol/mailbox.d.ts +76 -0
- package/dist/hq/protocol/mailbox.d.ts.map +1 -0
- package/dist/hq/protocol/mcp.d.ts +51 -0
- package/dist/hq/protocol/mcp.d.ts.map +1 -0
- package/dist/hq/protocol/project.d.ts +26 -0
- package/dist/hq/protocol/project.d.ts.map +1 -0
- package/dist/hq/protocol/session.d.ts +153 -0
- package/dist/hq/protocol/session.d.ts.map +1 -0
- package/dist/hq/protocol/tool.d.ts +31 -0
- package/dist/hq/protocol/tool.d.ts.map +1 -0
- package/dist/hq/protocol.d.ts +10 -559
- package/dist/hq/protocol.d.ts.map +1 -1
- package/dist/hq/publisher.d.ts +4 -0
- package/dist/hq/publisher.d.ts.map +1 -1
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7676 -3432
- package/dist/index.js.map +4 -4
- package/dist/infrastructure/index.js +13 -11
- package/dist/infrastructure/index.js.map +2 -2
- package/dist/infrastructure/token-counter.d.ts.map +1 -1
- package/dist/kernel/events/agent-events.d.ts +283 -0
- package/dist/kernel/events/agent-events.d.ts.map +1 -0
- package/dist/kernel/events/brain-events.d.ts +176 -0
- package/dist/kernel/events/brain-events.d.ts.map +1 -0
- package/dist/kernel/events/fleet-events.d.ts +39 -0
- package/dist/kernel/events/fleet-events.d.ts.map +1 -0
- package/dist/kernel/events/memory-events.d.ts +165 -0
- package/dist/kernel/events/memory-events.d.ts.map +1 -0
- package/dist/kernel/events/provider-events.d.ts +98 -0
- package/dist/kernel/events/provider-events.d.ts.map +1 -0
- package/dist/kernel/events/sdd-events.d.ts +118 -0
- package/dist/kernel/events/sdd-events.d.ts.map +1 -0
- package/dist/kernel/events/session-events.d.ts +227 -0
- package/dist/kernel/events/session-events.d.ts.map +1 -0
- package/dist/kernel/events/tool-events.d.ts +185 -0
- package/dist/kernel/events/tool-events.d.ts.map +1 -0
- package/dist/kernel/events/worktree-events.d.ts +58 -0
- package/dist/kernel/events/worktree-events.d.ts.map +1 -0
- package/dist/kernel/events.d.ts +12 -1282
- package/dist/kernel/events.d.ts.map +1 -1
- package/dist/kernel/index.js +22 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/kernel/run-controller.d.ts +15 -0
- package/dist/kernel/run-controller.d.ts.map +1 -1
- package/dist/mailbox-attach.d.ts.map +1 -1
- package/dist/models/index.js +19 -6
- package/dist/models/index.js.map +2 -2
- package/dist/models/llm-selector.d.ts +7 -0
- package/dist/models/llm-selector.d.ts.map +1 -1
- package/dist/observability/index.js +16 -15
- package/dist/observability/index.js.map +2 -2
- package/dist/plugins/auto-review-plugin.d.ts +36 -0
- package/dist/plugins/auto-review-plugin.d.ts.map +1 -0
- package/dist/plugins/chimera-plugin.d.ts +8 -0
- package/dist/plugins/chimera-plugin.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +260 -23
- package/dist/security/index.js.map +4 -4
- package/dist/security/permission-policy-schema.d.ts +77 -0
- package/dist/security/permission-policy-schema.d.ts.map +1 -0
- package/dist/security/permission-policy.d.ts +5 -0
- package/dist/security/permission-policy.d.ts.map +1 -1
- package/dist/security/secret-scrubber.d.ts.map +1 -1
- package/dist/security/secret-vault.d.ts +9 -0
- package/dist/security/secret-vault.d.ts.map +1 -1
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/skills/index.js.map +2 -2
- package/dist/storage/config-loader.d.ts +10 -0
- package/dist/storage/config-loader.d.ts.map +1 -1
- package/dist/storage/goal-kanban.d.ts +69 -0
- package/dist/storage/goal-kanban.d.ts.map +1 -0
- package/dist/storage/goal-store.d.ts +1 -1
- package/dist/storage/goal-store.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +572 -879
- package/dist/storage/index.js.map +4 -4
- package/dist/storage/memory-consolidator.d.ts +9 -1
- package/dist/storage/memory-consolidator.d.ts.map +1 -1
- package/dist/storage/plan-store.d.ts +1 -1
- package/dist/storage/plan-store.d.ts.map +1 -1
- package/dist/storage/queue-store.d.ts +4 -0
- package/dist/storage/queue-store.d.ts.map +1 -1
- package/dist/storage/session-store.d.ts +9 -0
- package/dist/storage/session-store.d.ts.map +1 -1
- package/dist/storage/task-store.d.ts +1 -1
- package/dist/storage/task-store.d.ts.map +1 -1
- package/dist/storage/todos-checkpoint.d.ts +2 -2
- package/dist/storage/todos-checkpoint.d.ts.map +1 -1
- package/dist/tools/council-tool.d.ts +25 -0
- package/dist/tools/council-tool.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1884 -12
- package/dist/tools/index.js.map +4 -4
- package/dist/tools/one-shot-llm-tool.d.ts +51 -0
- package/dist/tools/one-shot-llm-tool.d.ts.map +1 -0
- package/dist/types/config.d.ts +236 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context-window.d.ts.map +1 -1
- package/dist/types/council.d.ts +134 -0
- package/dist/types/council.d.ts.map +1 -0
- package/dist/types/default-config.d.ts +3 -3
- package/dist/types/hooks.d.ts +14 -0
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +40 -8
- package/dist/types/index.js.map +3 -3
- package/dist/types/multi-agent.d.ts +8 -0
- package/dist/types/multi-agent.d.ts.map +1 -1
- package/dist/types/observability.d.ts +5 -0
- package/dist/types/observability.d.ts.map +1 -1
- package/dist/types/one-shot-llm.d.ts +128 -0
- package/dist/types/one-shot-llm.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +6 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/provider.d.ts +17 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/system-prompt.d.ts +2 -1
- package/dist/types/system-prompt.d.ts.map +1 -1
- package/dist/types/tool-executor.d.ts +10 -0
- package/dist/types/tool-executor.d.ts.map +1 -1
- package/dist/types/tool.d.ts +7 -0
- package/dist/types/tool.d.ts.map +1 -1
- package/dist/utils/atomic-write.d.ts.map +1 -1
- package/dist/utils/glob-expand.d.ts.map +1 -1
- package/dist/utils/incoming-images.d.ts +39 -0
- package/dist/utils/incoming-images.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +156 -11
- package/dist/utils/index.js.map +4 -4
- package/dist/utils/tool-wire-compact.d.ts +1 -0
- package/dist/utils/tool-wire-compact.d.ts.map +1 -1
- package/dist/utils/wstack-paths.d.ts +20 -4
- package/dist/utils/wstack-paths.d.ts.map +1 -1
- package/dist/worktree/worktree-manager.d.ts +13 -4
- package/dist/worktree/worktree-manager.d.ts.map +1 -1
- package/instructions/agents/browser.md +25 -16
- package/instructions/cli/next-task-predictor.md +5 -3
- package/instructions/coordination/subagent-baseline.md +17 -2
- package/instructions/leader-after-task.md +19 -8
- package/instructions/llm/council-judge.md +19 -0
- package/instructions/llm/council-voter.md +22 -0
- package/instructions/modes/architect.md +14 -9
- package/instructions/modes/audit-lite.md +9 -7
- package/instructions/modes/brief-system.md +12 -12
- package/instructions/modes/brief.md +7 -5
- package/instructions/modes/code-auditor.md +13 -8
- package/instructions/modes/code-reviewer.md +13 -8
- package/instructions/modes/debug-lite.md +7 -6
- package/instructions/modes/debugger.md +13 -9
- package/instructions/modes/devops.md +13 -9
- package/instructions/modes/plan-lite.md +7 -6
- package/instructions/modes/refactor-lite.md +7 -6
- package/instructions/modes/refactorer.md +14 -9
- package/instructions/modes/research-lite.md +8 -6
- package/instructions/modes/research-web.md +18 -55
- package/instructions/modes/review-lite.md +7 -6
- package/instructions/modes/teach-system.md +15 -15
- package/instructions/modes/teach.md +13 -12
- package/instructions/modes/test-lite.md +6 -5
- package/instructions/modes/tester.md +13 -9
- package/instructions/modes/ui-design.md +14 -8
- package/instructions/sections/tool/commit-hygiene.md +1 -7
- package/instructions/sections/tool/common-patterns.md +7 -1
- package/instructions/sections/tool/delegation-full.md +3 -31
- package/instructions/sections/tool/mailbox-compact.md +1 -1
- package/instructions/sections/tool/mailbox-full.md +6 -22
- package/instructions/system.md +294 -8
- package/package.json +2 -2
- package/skills/docker-deploy/SKILL.md +1 -1
- package/skills/mailbox-bridge/SKILL.md +16 -7
- package/skills/output-standards/SKILL.md +16 -16
- package/skills/wrongstack-mailbox/SKILL.md +57 -12
- package/dist/coordination/director-construction.d.ts +0 -90
- package/dist/coordination/director-construction.d.ts.map +0 -1
- package/dist/hq/agent-bridge.d.ts +0 -27
- package/dist/hq/agent-bridge.d.ts.map +0 -1
- package/dist/plugins/git-plugin.d.ts +0 -15
- package/dist/plugins/git-plugin.d.ts.map +0 -1
- package/dist/plugins/observability-plugin.d.ts +0 -19
- package/dist/plugins/observability-plugin.d.ts.map +0 -1
- package/dist/plugins/plan-plugin.d.ts +0 -16
- package/dist/plugins/plan-plugin.d.ts.map +0 -1
- package/dist/storage/memory-store.d.ts +0 -119
- package/dist/storage/memory-store.d.ts.map +0 -1
package/dist/utils/index.js
CHANGED
|
@@ -10,6 +10,7 @@ function assertNever(x, message) {
|
|
|
10
10
|
// src/utils/atomic-write.ts
|
|
11
11
|
import { randomBytes } from "node:crypto";
|
|
12
12
|
import * as fs from "node:fs/promises";
|
|
13
|
+
import { watch as watchDir } from "node:fs";
|
|
13
14
|
import * as path from "node:path";
|
|
14
15
|
|
|
15
16
|
// src/types/errors.ts
|
|
@@ -181,7 +182,7 @@ async function withFileLock(targetPath, fn, opts = {}) {
|
|
|
181
182
|
await fs.mkdir(dir, { recursive: true });
|
|
182
183
|
continue;
|
|
183
184
|
}
|
|
184
|
-
if (code !== "EEXIST") throw err;
|
|
185
|
+
if (code !== "EEXIST" && code !== "EPERM") throw err;
|
|
185
186
|
try {
|
|
186
187
|
const stat3 = await fs.stat(lockPath);
|
|
187
188
|
if (Date.now() - stat3.mtimeMs > staleMs) {
|
|
@@ -191,7 +192,8 @@ async function withFileLock(targetPath, fn, opts = {}) {
|
|
|
191
192
|
} catch {
|
|
192
193
|
continue;
|
|
193
194
|
}
|
|
194
|
-
|
|
195
|
+
const elapsed = Date.now() - started;
|
|
196
|
+
if (elapsed >= timeoutMs) {
|
|
195
197
|
throw new FsError({
|
|
196
198
|
message: `Timed out waiting for file lock: ${targetPath}`,
|
|
197
199
|
code: "FS_ATOMIC_WRITE_FAILED",
|
|
@@ -199,7 +201,7 @@ async function withFileLock(targetPath, fn, opts = {}) {
|
|
|
199
201
|
context: { timeoutMs }
|
|
200
202
|
});
|
|
201
203
|
}
|
|
202
|
-
await
|
|
204
|
+
await waitForLockRelease(lockPath, timeoutMs - elapsed);
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
try {
|
|
@@ -215,6 +217,50 @@ async function withFileLock(targetPath, fn, opts = {}) {
|
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
}
|
|
220
|
+
async function waitForLockRelease(lockPath, remainingMs) {
|
|
221
|
+
const parentDir = path.dirname(lockPath);
|
|
222
|
+
const lockName = path.basename(lockPath);
|
|
223
|
+
const intervalMs = Math.min(remainingMs, 100);
|
|
224
|
+
return new Promise((resolve5) => {
|
|
225
|
+
let settled = false;
|
|
226
|
+
let watcher = null;
|
|
227
|
+
const timer = setTimeout(() => {
|
|
228
|
+
settled = true;
|
|
229
|
+
watcher?.close();
|
|
230
|
+
resolve5();
|
|
231
|
+
}, intervalMs);
|
|
232
|
+
try {
|
|
233
|
+
watcher = watchDir(parentDir, (eventType, filename) => {
|
|
234
|
+
if (settled) return;
|
|
235
|
+
if (filename === lockName && (eventType === "rename" || eventType === "change")) {
|
|
236
|
+
settled = true;
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
watcher?.close();
|
|
239
|
+
resolve5();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
} catch {
|
|
243
|
+
clearTimeout(timer);
|
|
244
|
+
if (!settled) {
|
|
245
|
+
settled = true;
|
|
246
|
+
setTimeout(resolve5, Math.min(remainingMs, 25));
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
fs.access(lockPath).then(
|
|
251
|
+
() => {
|
|
252
|
+
},
|
|
253
|
+
() => {
|
|
254
|
+
if (!settled) {
|
|
255
|
+
settled = true;
|
|
256
|
+
clearTimeout(timer);
|
|
257
|
+
watcher?.close();
|
|
258
|
+
resolve5();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
218
264
|
var TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EBUSY", "EACCES", "ENOTEMPTY"]);
|
|
219
265
|
async function renameWithRetry(from, to) {
|
|
220
266
|
if (process.platform !== "win32") {
|
|
@@ -1237,9 +1283,17 @@ function globToRegex(pat) {
|
|
|
1237
1283
|
return new RegExp(re + "$");
|
|
1238
1284
|
}
|
|
1239
1285
|
function baseDir(pat) {
|
|
1240
|
-
let
|
|
1241
|
-
|
|
1242
|
-
|
|
1286
|
+
let firstGlob = pat.length;
|
|
1287
|
+
for (let i = 0; i < pat.length; i++) {
|
|
1288
|
+
if (GLOB_CHARS.has(expectDefined(pat[i]))) {
|
|
1289
|
+
firstGlob = i;
|
|
1290
|
+
break;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
const cut = Math.max(
|
|
1294
|
+
pat.lastIndexOf(SEP, firstGlob - 1),
|
|
1295
|
+
pat.lastIndexOf("/", firstGlob - 1)
|
|
1296
|
+
);
|
|
1243
1297
|
return cut < 0 ? "." : pat.slice(0, cut);
|
|
1244
1298
|
}
|
|
1245
1299
|
async function expandGlob(pattern) {
|
|
@@ -1384,6 +1438,71 @@ function matchAny(patterns, input) {
|
|
|
1384
1438
|
return patterns.some((p) => matchGlob(p, input));
|
|
1385
1439
|
}
|
|
1386
1440
|
|
|
1441
|
+
// src/utils/incoming-images.ts
|
|
1442
|
+
var MAX_INCOMING_IMAGES = 8;
|
|
1443
|
+
var MAX_INCOMING_IMAGE_BYTES = 8 * 1024 * 1024;
|
|
1444
|
+
var ALLOWED_IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Set([
|
|
1445
|
+
"image/png",
|
|
1446
|
+
"image/jpeg",
|
|
1447
|
+
"image/webp",
|
|
1448
|
+
"image/gif"
|
|
1449
|
+
]);
|
|
1450
|
+
var IncomingImageError = class extends Error {
|
|
1451
|
+
constructor(message) {
|
|
1452
|
+
super(message);
|
|
1453
|
+
this.name = "IncomingImageError";
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
var DATA_URL_RE = /^data:([a-z0-9.+-]+\/[a-z0-9.+-]+)?(?:;[a-z0-9-]+=[^;,]*)*(;base64)?,/i;
|
|
1457
|
+
function splitDataUrl(data) {
|
|
1458
|
+
const match = DATA_URL_RE.exec(data);
|
|
1459
|
+
if (!match) return { base64: data.trim() };
|
|
1460
|
+
return {
|
|
1461
|
+
base64: data.slice(match[0].length).trim(),
|
|
1462
|
+
mediaType: match[1]?.toLowerCase()
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function parseIncomingImages(images, legacyImageBase64) {
|
|
1466
|
+
const raw = [...images ?? []];
|
|
1467
|
+
if (legacyImageBase64) raw.push({ data: legacyImageBase64 });
|
|
1468
|
+
if (raw.length === 0) return [];
|
|
1469
|
+
if (raw.length > MAX_INCOMING_IMAGES) {
|
|
1470
|
+
throw new IncomingImageError(
|
|
1471
|
+
`Too many images: ${raw.length} (max ${MAX_INCOMING_IMAGES} per message).`
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
return raw.map((img, i) => {
|
|
1475
|
+
const { base64, mediaType: fromUrl } = splitDataUrl(img.data ?? "");
|
|
1476
|
+
const mediaType = (img.mediaType ?? fromUrl ?? "image/png").toLowerCase();
|
|
1477
|
+
if (!ALLOWED_IMAGE_MEDIA_TYPES.has(mediaType)) {
|
|
1478
|
+
throw new IncomingImageError(
|
|
1479
|
+
`Image ${i + 1}: unsupported media type "${mediaType}" (allowed: ${[...ALLOWED_IMAGE_MEDIA_TYPES].join(", ")}).`
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
if (!base64) {
|
|
1483
|
+
throw new IncomingImageError(`Image ${i + 1}: empty image data.`);
|
|
1484
|
+
}
|
|
1485
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(base64)) {
|
|
1486
|
+
throw new IncomingImageError(`Image ${i + 1}: data is not valid base64.`);
|
|
1487
|
+
}
|
|
1488
|
+
const bytes = Math.floor(base64.length * 3 / 4);
|
|
1489
|
+
if (bytes > MAX_INCOMING_IMAGE_BYTES) {
|
|
1490
|
+
throw new IncomingImageError(
|
|
1491
|
+
`Image ${i + 1}: ${(bytes / (1024 * 1024)).toFixed(1)} MB exceeds the ${MAX_INCOMING_IMAGE_BYTES / (1024 * 1024)} MB limit.`
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
return {
|
|
1495
|
+
type: "image",
|
|
1496
|
+
source: { type: "base64", media_type: mediaType, data: base64 }
|
|
1497
|
+
};
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
function buildUserContentBlocks(text, images) {
|
|
1501
|
+
const blocks = [...images];
|
|
1502
|
+
if (text) blocks.push({ type: "text", text });
|
|
1503
|
+
return blocks;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1387
1506
|
// src/utils/ip-guard.ts
|
|
1388
1507
|
import * as dns from "node:dns/promises";
|
|
1389
1508
|
import * as net from "node:net";
|
|
@@ -2343,8 +2462,8 @@ function subjectForToolInput(toolName, input, subjectKey) {
|
|
|
2343
2462
|
}
|
|
2344
2463
|
|
|
2345
2464
|
// src/utils/tool-wire-compact.ts
|
|
2346
|
-
var TOOL_DESCRIPTION_MAX_CHARS =
|
|
2347
|
-
var SCHEMA_DESCRIPTION_MAX_CHARS =
|
|
2465
|
+
var TOOL_DESCRIPTION_MAX_CHARS = 400;
|
|
2466
|
+
var SCHEMA_DESCRIPTION_MAX_CHARS = 120;
|
|
2348
2467
|
var compactCache = /* @__PURE__ */ new WeakMap();
|
|
2349
2468
|
function compactToolDefinitionForWire(tool, opts = {}) {
|
|
2350
2469
|
const useDefaultOptions = opts.descriptionMaxChars === void 0 && opts.schemaDescriptionMaxChars === void 0;
|
|
@@ -3418,14 +3537,34 @@ function applyToolResultRenderModes(registry, modes) {
|
|
|
3418
3537
|
|
|
3419
3538
|
// src/utils/wstack-paths.ts
|
|
3420
3539
|
import { createHash } from "node:crypto";
|
|
3540
|
+
import * as fs3 from "node:fs";
|
|
3421
3541
|
import * as os from "node:os";
|
|
3422
3542
|
import * as path4 from "node:path";
|
|
3543
|
+
function canonicalProjectRoot(absRoot) {
|
|
3544
|
+
const checkoutRoot = path4.resolve(absRoot);
|
|
3545
|
+
const dotGit = path4.join(checkoutRoot, ".git");
|
|
3546
|
+
try {
|
|
3547
|
+
if (!fs3.statSync(dotGit).isFile()) return checkoutRoot;
|
|
3548
|
+
const gitDirLine = fs3.readFileSync(dotGit, "utf8").trim();
|
|
3549
|
+
const match = /^gitdir:\s*(.+)$/i.exec(gitDirLine);
|
|
3550
|
+
if (!match?.[1]) return checkoutRoot;
|
|
3551
|
+
const gitDir = path4.resolve(checkoutRoot, match[1].trim());
|
|
3552
|
+
const commonDirFile = path4.join(gitDir, "commondir");
|
|
3553
|
+
if (!fs3.statSync(commonDirFile).isFile()) return checkoutRoot;
|
|
3554
|
+
const commonDir = path4.resolve(gitDir, fs3.readFileSync(commonDirFile, "utf8").trim());
|
|
3555
|
+
if (path4.basename(commonDir).toLowerCase() !== ".git") return checkoutRoot;
|
|
3556
|
+
return path4.dirname(commonDir);
|
|
3557
|
+
} catch {
|
|
3558
|
+
return checkoutRoot;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3423
3561
|
function projectHash(absRoot) {
|
|
3424
|
-
return createHash("sha256").update(
|
|
3562
|
+
return createHash("sha256").update(canonicalProjectRoot(absRoot)).digest("hex").slice(0, 12);
|
|
3425
3563
|
}
|
|
3426
3564
|
function projectSlug(absRoot) {
|
|
3427
|
-
const
|
|
3428
|
-
const
|
|
3565
|
+
const identityRoot = canonicalProjectRoot(absRoot);
|
|
3566
|
+
const base = slugify2(path4.basename(identityRoot));
|
|
3567
|
+
const hash = createHash("sha256").update(identityRoot).digest("hex").slice(0, 6);
|
|
3429
3568
|
return `${base}-${hash}`;
|
|
3430
3569
|
}
|
|
3431
3570
|
function slugify2(name) {
|
|
@@ -3495,6 +3634,9 @@ export {
|
|
|
3495
3634
|
DEFAULT_TOOL_DESCRIPTION_MODE,
|
|
3496
3635
|
DEFAULT_TOOL_RESULT_RENDER_MODE,
|
|
3497
3636
|
FORBIDDEN_PROTO_KEYS,
|
|
3637
|
+
IncomingImageError,
|
|
3638
|
+
MAX_INCOMING_IMAGES,
|
|
3639
|
+
MAX_INCOMING_IMAGE_BYTES,
|
|
3498
3640
|
applyToolDescriptionModeToTool,
|
|
3499
3641
|
applyToolDescriptionModes,
|
|
3500
3642
|
applyToolResultRenderModes,
|
|
@@ -3504,6 +3646,8 @@ export {
|
|
|
3504
3646
|
buildChildEnv,
|
|
3505
3647
|
buildCompletedWorkLedgerBlock,
|
|
3506
3648
|
buildContextEvidenceDigest,
|
|
3649
|
+
buildUserContentBlocks,
|
|
3650
|
+
canonicalProjectRoot,
|
|
3507
3651
|
coerceAgainstSchema,
|
|
3508
3652
|
color,
|
|
3509
3653
|
compactSchemaDescriptions,
|
|
@@ -3561,6 +3705,7 @@ export {
|
|
|
3561
3705
|
normalizeToolDescriptionMode,
|
|
3562
3706
|
normalizeToolResultRenderMode,
|
|
3563
3707
|
onResize,
|
|
3708
|
+
parseIncomingImages,
|
|
3564
3709
|
projectHash,
|
|
3565
3710
|
projectSlug,
|
|
3566
3711
|
readJsonObjectFile,
|