@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/security/index.js
CHANGED
|
@@ -116,7 +116,12 @@ function hasCredentialAnchors(text) {
|
|
|
116
116
|
text.includes("_TOKEN=") || // ACCESS_TOKEN=, AUTH_TOKEN=, ...
|
|
117
117
|
text.includes("_SECRET=") || // API_SECRET=, CLIENT_SECRET=, ...
|
|
118
118
|
text.includes("_PASSWORD=") || // DB_PASSWORD=, ROOT_PASSWORD=, ...
|
|
119
|
-
text.includes("mongodb://") || text.includes("mongodb+srv://") || text.includes("postgres://") || text.includes("postgresql://") || text.includes("mysql://") || text.includes("redis://")
|
|
119
|
+
text.includes("mongodb://") || text.includes("mongodb+srv://") || text.includes("postgres://") || text.includes("postgresql://") || text.includes("mysql://") || text.includes("redis://") || // JSON-style credential keys: tool outputs often serialise objects as
|
|
120
|
+
// raw JSON strings rather than parsed objects. The value may not start
|
|
121
|
+
// with a recognisable prefix (sk-, ghp_, etc.), so we anchor on common
|
|
122
|
+
// key names. The `"` prefix avoids matching prose that happens to mention
|
|
123
|
+
// these words — JSON serialisation always quotes string keys.
|
|
124
|
+
text.includes('"apiKey"') || text.includes('"api_key"') || text.includes('"token"') || text.includes('"secret"') || text.includes('"password"') || text.includes('"authorization"') || text.includes('"bearer"') || text.includes('"private_key"') || text.includes('"access_token"') || text.includes('"refresh_token"') || text.includes('"client_secret"');
|
|
120
125
|
}
|
|
121
126
|
var DefaultSecretScrubber = class {
|
|
122
127
|
scrub(text) {
|
|
@@ -612,7 +617,7 @@ function walk(node, vault, transform) {
|
|
|
612
617
|
}
|
|
613
618
|
return out;
|
|
614
619
|
}
|
|
615
|
-
var SECRET_KEY_PATTERN = /(?:apikey|api_key|authtoken|auth_token|bearer|secret|password|passwd|pwd|refreshtoken|refresh_token|sessionkey|session_key|access[_-]?token|private[_-]?key)/i;
|
|
620
|
+
var SECRET_KEY_PATTERN = /(?:apikey|api_key|authtoken|auth_token|bearer|secret|password|passwd|pwd|refreshtoken|refresh_token|sessionkey|session_key|access[_-]?token|private[_-]?key|token\b)/i;
|
|
616
621
|
var NON_SECRET_OVERRIDES = /* @__PURE__ */ new Set(["publickey", "public_key"]);
|
|
617
622
|
function isSecretField(name) {
|
|
618
623
|
const lc = name.toLowerCase();
|
|
@@ -705,31 +710,40 @@ function unwrapDataKey(buf, keyFile) {
|
|
|
705
710
|
});
|
|
706
711
|
}
|
|
707
712
|
}
|
|
708
|
-
function checkKeyFilePermissions(keyFile) {
|
|
713
|
+
function checkKeyFilePermissions(keyFile, opts) {
|
|
709
714
|
if (process.platform === "win32") return;
|
|
715
|
+
const warn = opts?.warn ?? ((msg) => console.warn(msg));
|
|
710
716
|
try {
|
|
711
717
|
const stat2 = fs2.statSync(keyFile);
|
|
712
718
|
const actualMode = stat2.mode & 511;
|
|
713
719
|
if (actualMode !== KEY_FILE_MODE) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
message: `Key file ${keyFile} has mode ${actualMode.toString(8)} \u2014 expected ${KEY_FILE_MODE.toString(8)}. Run: chmod ${KEY_FILE_MODE.toString(8)} ${keyFile}`,
|
|
718
|
-
keyFile,
|
|
719
|
-
expectedMode: KEY_FILE_MODE,
|
|
720
|
-
actualMode,
|
|
721
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
722
|
-
}));
|
|
720
|
+
warn(
|
|
721
|
+
`Key file ${keyFile} has mode ${actualMode.toString(8)} \u2014 expected ${KEY_FILE_MODE.toString(8)}. Run: chmod ${KEY_FILE_MODE.toString(8)} ${keyFile}`
|
|
722
|
+
);
|
|
723
723
|
}
|
|
724
724
|
} catch {
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
var DefaultSecretVault = class {
|
|
728
728
|
keyFile;
|
|
729
|
+
logger;
|
|
729
730
|
key;
|
|
730
731
|
_keyVersion = 1;
|
|
731
732
|
constructor(opts) {
|
|
732
733
|
this.keyFile = opts.keyFile;
|
|
734
|
+
this.logger = opts.logger;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Emit a structured warning. Uses the configured Logger when available;
|
|
738
|
+
* falls back to console.warn(JSON) so warnings are never silently dropped
|
|
739
|
+
* during early boot.
|
|
740
|
+
*/
|
|
741
|
+
logWarn(msg, ctx) {
|
|
742
|
+
if (this.logger) {
|
|
743
|
+
this.logger.warn(msg, ctx);
|
|
744
|
+
} else {
|
|
745
|
+
console.warn(JSON.stringify({ ...ctx, message: msg, timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
746
|
+
}
|
|
733
747
|
}
|
|
734
748
|
/** Current key version. Starts at 1; incremented by rotateKey(). */
|
|
735
749
|
get keyVersion() {
|
|
@@ -808,7 +822,7 @@ var DefaultSecretVault = class {
|
|
|
808
822
|
newKey.copy(keyFileBuf, KEY_FILE_MAGIC.length + 1);
|
|
809
823
|
fs2.writeFileSync(this.keyFile, keyFileBuf, { mode: 384 });
|
|
810
824
|
}
|
|
811
|
-
checkKeyFilePermissions(this.keyFile);
|
|
825
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
812
826
|
this.key = newKey;
|
|
813
827
|
this._keyVersion = newVersion;
|
|
814
828
|
return { oldVersion, newVersion };
|
|
@@ -827,7 +841,7 @@ var DefaultSecretVault = class {
|
|
|
827
841
|
fs2.writeFileSync(this.keyFile, wrapDataKey(this.key, this._keyVersion, passphrase), {
|
|
828
842
|
mode: 384
|
|
829
843
|
});
|
|
830
|
-
checkKeyFilePermissions(this.keyFile);
|
|
844
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
831
845
|
} catch {
|
|
832
846
|
}
|
|
833
847
|
}
|
|
@@ -839,13 +853,13 @@ var DefaultSecretVault = class {
|
|
|
839
853
|
const { key: key2, version } = unwrapDataKey(buf, this.keyFile);
|
|
840
854
|
this.key = key2;
|
|
841
855
|
this._keyVersion = version;
|
|
842
|
-
checkKeyFilePermissions(this.keyFile);
|
|
856
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
843
857
|
return this.key;
|
|
844
858
|
}
|
|
845
859
|
if (buf.length === KEY_BYTES) {
|
|
846
860
|
this.key = buf;
|
|
847
861
|
this._keyVersion = 1;
|
|
848
|
-
checkKeyFilePermissions(this.keyFile);
|
|
862
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
849
863
|
this.migrateToWrappedIfPassphrase();
|
|
850
864
|
return this.key;
|
|
851
865
|
}
|
|
@@ -869,7 +883,7 @@ var DefaultSecretVault = class {
|
|
|
869
883
|
}
|
|
870
884
|
this.key = Buffer.from(key2);
|
|
871
885
|
this._keyVersion = version;
|
|
872
|
-
checkKeyFilePermissions(this.keyFile);
|
|
886
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
873
887
|
this.migrateToWrappedIfPassphrase();
|
|
874
888
|
return this.key;
|
|
875
889
|
}
|
|
@@ -894,13 +908,13 @@ var DefaultSecretVault = class {
|
|
|
894
908
|
const { key: winnerKey, version } = unwrapDataKey(buf, this.keyFile);
|
|
895
909
|
this.key = winnerKey;
|
|
896
910
|
this._keyVersion = version;
|
|
897
|
-
checkKeyFilePermissions(this.keyFile);
|
|
911
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
898
912
|
return this.key;
|
|
899
913
|
}
|
|
900
914
|
if (buf.length === KEY_BYTES) {
|
|
901
915
|
this.key = buf;
|
|
902
916
|
this._keyVersion = 1;
|
|
903
|
-
checkKeyFilePermissions(this.keyFile);
|
|
917
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
904
918
|
return this.key;
|
|
905
919
|
}
|
|
906
920
|
if (buf.length === VERSIONED_KEY_FILE_SIZE) {
|
|
@@ -916,7 +930,7 @@ var DefaultSecretVault = class {
|
|
|
916
930
|
const winnerKey = buf.subarray(KEY_FILE_MAGIC.length + 1);
|
|
917
931
|
this.key = Buffer.from(winnerKey);
|
|
918
932
|
this._keyVersion = version;
|
|
919
|
-
checkKeyFilePermissions(this.keyFile);
|
|
933
|
+
checkKeyFilePermissions(this.keyFile, { warn: (msg) => this.logWarn(msg) });
|
|
920
934
|
return this.key;
|
|
921
935
|
}
|
|
922
936
|
throw new ConfigError({
|
|
@@ -1207,6 +1221,173 @@ function getDangerousCapabilities(toolOrCaps) {
|
|
|
1207
1221
|
);
|
|
1208
1222
|
}
|
|
1209
1223
|
|
|
1224
|
+
// src/security/permission-policy-schema.ts
|
|
1225
|
+
var TRUST_POLICY_SCHEMA_VERSION = 1;
|
|
1226
|
+
var TRUST_POLICY_LIMITS = Object.freeze({
|
|
1227
|
+
maxTools: 1e3,
|
|
1228
|
+
maxPatternsPerRule: 1e3,
|
|
1229
|
+
maxToolNameChars: 256,
|
|
1230
|
+
maxPatternChars: 4096
|
|
1231
|
+
});
|
|
1232
|
+
var TRUST_POLICY_JSON_SCHEMA = Object.freeze({
|
|
1233
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
1234
|
+
$id: "https://wrongstack.dev/schemas/trust-policy-v1.json",
|
|
1235
|
+
title: "WrongStack Trust Policy",
|
|
1236
|
+
type: "object",
|
|
1237
|
+
maxProperties: TRUST_POLICY_LIMITS.maxTools,
|
|
1238
|
+
propertyNames: {
|
|
1239
|
+
minLength: 1,
|
|
1240
|
+
maxLength: TRUST_POLICY_LIMITS.maxToolNameChars,
|
|
1241
|
+
not: { enum: ["__proto__", "prototype", "constructor"] }
|
|
1242
|
+
},
|
|
1243
|
+
additionalProperties: {
|
|
1244
|
+
type: "object",
|
|
1245
|
+
additionalProperties: false,
|
|
1246
|
+
properties: {
|
|
1247
|
+
allow: {
|
|
1248
|
+
type: "array",
|
|
1249
|
+
maxItems: TRUST_POLICY_LIMITS.maxPatternsPerRule,
|
|
1250
|
+
items: { type: "string", minLength: 1, maxLength: TRUST_POLICY_LIMITS.maxPatternChars }
|
|
1251
|
+
},
|
|
1252
|
+
deny: {
|
|
1253
|
+
type: "array",
|
|
1254
|
+
maxItems: TRUST_POLICY_LIMITS.maxPatternsPerRule,
|
|
1255
|
+
items: { type: "string", minLength: 1, maxLength: TRUST_POLICY_LIMITS.maxPatternChars }
|
|
1256
|
+
},
|
|
1257
|
+
auto: { type: "boolean" },
|
|
1258
|
+
trustWorkdir: { type: "boolean" },
|
|
1259
|
+
denyPrivate: { type: "boolean" }
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
var RULE_FIELDS = /* @__PURE__ */ new Set(["allow", "deny", "auto", "trustWorkdir", "denyPrivate"]);
|
|
1264
|
+
var UNSAFE_PROPERTY_NAMES = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
1265
|
+
function isRecord(value) {
|
|
1266
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1267
|
+
}
|
|
1268
|
+
function error(diagnostics, code, path3, message) {
|
|
1269
|
+
diagnostics.push({ severity: "error", code, path: path3, message });
|
|
1270
|
+
}
|
|
1271
|
+
function validatePatterns(value, path3, diagnostics) {
|
|
1272
|
+
if (!Array.isArray(value)) {
|
|
1273
|
+
error(diagnostics, "invalid_pattern_list", path3, "must be an array of strings");
|
|
1274
|
+
return void 0;
|
|
1275
|
+
}
|
|
1276
|
+
if (value.length > TRUST_POLICY_LIMITS.maxPatternsPerRule) {
|
|
1277
|
+
error(
|
|
1278
|
+
diagnostics,
|
|
1279
|
+
"too_many_patterns",
|
|
1280
|
+
path3,
|
|
1281
|
+
`must contain at most ${TRUST_POLICY_LIMITS.maxPatternsPerRule} patterns`
|
|
1282
|
+
);
|
|
1283
|
+
return void 0;
|
|
1284
|
+
}
|
|
1285
|
+
const patterns = [];
|
|
1286
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1287
|
+
for (const [index, pattern] of value.entries()) {
|
|
1288
|
+
const itemPath = `${path3}[${index}]`;
|
|
1289
|
+
if (typeof pattern !== "string" || pattern.length === 0 || pattern.length > TRUST_POLICY_LIMITS.maxPatternChars) {
|
|
1290
|
+
error(
|
|
1291
|
+
diagnostics,
|
|
1292
|
+
"invalid_pattern",
|
|
1293
|
+
itemPath,
|
|
1294
|
+
`must be a non-empty string up to ${TRUST_POLICY_LIMITS.maxPatternChars} characters`
|
|
1295
|
+
);
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
if (seen.has(pattern)) {
|
|
1299
|
+
diagnostics.push({
|
|
1300
|
+
severity: "warning",
|
|
1301
|
+
code: "duplicate_pattern",
|
|
1302
|
+
path: itemPath,
|
|
1303
|
+
message: "duplicates an earlier pattern and was normalized away"
|
|
1304
|
+
});
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
seen.add(pattern);
|
|
1308
|
+
patterns.push(pattern);
|
|
1309
|
+
}
|
|
1310
|
+
return patterns;
|
|
1311
|
+
}
|
|
1312
|
+
function validateTrustPolicy(value) {
|
|
1313
|
+
const diagnostics = [];
|
|
1314
|
+
if (!isRecord(value)) {
|
|
1315
|
+
return {
|
|
1316
|
+
ok: false,
|
|
1317
|
+
diagnostics: [
|
|
1318
|
+
{
|
|
1319
|
+
severity: "error",
|
|
1320
|
+
code: "invalid_root",
|
|
1321
|
+
path: "$",
|
|
1322
|
+
message: "trust policy must be an object"
|
|
1323
|
+
}
|
|
1324
|
+
]
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const entries = Object.entries(value);
|
|
1328
|
+
if (entries.length > TRUST_POLICY_LIMITS.maxTools) {
|
|
1329
|
+
error(
|
|
1330
|
+
diagnostics,
|
|
1331
|
+
"too_many_tools",
|
|
1332
|
+
"$",
|
|
1333
|
+
`must contain at most ${TRUST_POLICY_LIMITS.maxTools} tool rules`
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
const policy = {};
|
|
1337
|
+
for (const [toolName, rawRule] of entries.slice(0, TRUST_POLICY_LIMITS.maxTools)) {
|
|
1338
|
+
const toolPath = `$[${JSON.stringify(toolName)}]`;
|
|
1339
|
+
if (toolName.length === 0 || toolName.length > TRUST_POLICY_LIMITS.maxToolNameChars) {
|
|
1340
|
+
error(
|
|
1341
|
+
diagnostics,
|
|
1342
|
+
"invalid_tool_name",
|
|
1343
|
+
toolPath,
|
|
1344
|
+
`tool name must be 1-${TRUST_POLICY_LIMITS.maxToolNameChars} characters`
|
|
1345
|
+
);
|
|
1346
|
+
continue;
|
|
1347
|
+
}
|
|
1348
|
+
if (UNSAFE_PROPERTY_NAMES.has(toolName)) {
|
|
1349
|
+
error(
|
|
1350
|
+
diagnostics,
|
|
1351
|
+
"unsafe_tool_name",
|
|
1352
|
+
toolPath,
|
|
1353
|
+
"reserved object property names are not valid tool rules"
|
|
1354
|
+
);
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
if (!isRecord(rawRule)) {
|
|
1358
|
+
error(diagnostics, "invalid_rule", toolPath, "tool rule must be an object");
|
|
1359
|
+
continue;
|
|
1360
|
+
}
|
|
1361
|
+
for (const field of Object.keys(rawRule)) {
|
|
1362
|
+
if (!RULE_FIELDS.has(field)) {
|
|
1363
|
+
error(
|
|
1364
|
+
diagnostics,
|
|
1365
|
+
"unknown_field",
|
|
1366
|
+
`${toolPath}.${field}`,
|
|
1367
|
+
`unknown policy field "${field}"`
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
const rule = {};
|
|
1372
|
+
for (const field of ["allow", "deny"]) {
|
|
1373
|
+
if (rawRule[field] === void 0) continue;
|
|
1374
|
+
const patterns = validatePatterns(rawRule[field], `${toolPath}.${field}`, diagnostics);
|
|
1375
|
+
if (patterns) rule[field] = patterns;
|
|
1376
|
+
}
|
|
1377
|
+
for (const field of ["auto", "trustWorkdir", "denyPrivate"]) {
|
|
1378
|
+
const setting = rawRule[field];
|
|
1379
|
+
if (setting === void 0) continue;
|
|
1380
|
+
if (typeof setting !== "boolean") {
|
|
1381
|
+
error(diagnostics, "invalid_boolean", `${toolPath}.${field}`, "must be a boolean");
|
|
1382
|
+
} else {
|
|
1383
|
+
rule[field] = setting;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
policy[toolName] = rule;
|
|
1387
|
+
}
|
|
1388
|
+
return diagnostics.some((diagnostic) => diagnostic.severity === "error") ? { ok: false, diagnostics } : { ok: true, policy, diagnostics };
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1210
1391
|
// src/utils/lru-cache.ts
|
|
1211
1392
|
var LruCache = class {
|
|
1212
1393
|
store = /* @__PURE__ */ new Map();
|
|
@@ -1375,6 +1556,8 @@ var DefaultPermissionPolicy = class {
|
|
|
1375
1556
|
* the LRU evicts the least-recently-used entries first.
|
|
1376
1557
|
*/
|
|
1377
1558
|
_evalCache = new LruCache(500);
|
|
1559
|
+
policyDiagnostics = [];
|
|
1560
|
+
policyInvalid = false;
|
|
1378
1561
|
constructor(opts) {
|
|
1379
1562
|
this.trustFile = opts.trustFile;
|
|
1380
1563
|
this.yolo = opts.yolo ?? false;
|
|
@@ -1418,13 +1601,50 @@ var DefaultPermissionPolicy = class {
|
|
|
1418
1601
|
getConfirmDestructive() {
|
|
1419
1602
|
return this.confirmDestructive;
|
|
1420
1603
|
}
|
|
1604
|
+
/** Read-only diagnostics for policy inspector/editor surfaces. */
|
|
1605
|
+
getPolicyDiagnostics() {
|
|
1606
|
+
return this.policyDiagnostics.map((diagnostic) => ({ ...diagnostic }));
|
|
1607
|
+
}
|
|
1421
1608
|
async reload() {
|
|
1609
|
+
this.policyDiagnostics = [];
|
|
1610
|
+
this.policyInvalid = false;
|
|
1422
1611
|
try {
|
|
1423
1612
|
const raw = await fs3.readFile(this.trustFile, "utf8");
|
|
1424
1613
|
const parsed = safeParse(raw);
|
|
1425
|
-
if (parsed.ok
|
|
1426
|
-
|
|
1614
|
+
if (!parsed.ok) {
|
|
1615
|
+
this.policy = {};
|
|
1616
|
+
this.policyInvalid = true;
|
|
1617
|
+
this.policyDiagnostics = [
|
|
1618
|
+
{
|
|
1619
|
+
severity: "error",
|
|
1620
|
+
code: "invalid_json",
|
|
1621
|
+
path: "$",
|
|
1622
|
+
message: parsed.error ?? "trust policy is not valid JSON"
|
|
1623
|
+
}
|
|
1624
|
+
];
|
|
1625
|
+
} else {
|
|
1626
|
+
const validation = validateTrustPolicy(parsed.value);
|
|
1627
|
+
this.policyDiagnostics = validation.diagnostics;
|
|
1628
|
+
if (validation.ok) {
|
|
1629
|
+
this.policy = validation.policy;
|
|
1630
|
+
} else {
|
|
1631
|
+
this.policy = {};
|
|
1632
|
+
this.policyInvalid = true;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
} catch (err) {
|
|
1427
1636
|
this.policy = {};
|
|
1637
|
+
if (err.code !== "ENOENT") {
|
|
1638
|
+
this.policyInvalid = true;
|
|
1639
|
+
this.policyDiagnostics = [
|
|
1640
|
+
{
|
|
1641
|
+
severity: "error",
|
|
1642
|
+
code: "read_error",
|
|
1643
|
+
path: "$",
|
|
1644
|
+
message: err instanceof Error ? err.message : String(err)
|
|
1645
|
+
}
|
|
1646
|
+
];
|
|
1647
|
+
}
|
|
1428
1648
|
}
|
|
1429
1649
|
this.wildcardEntries = [];
|
|
1430
1650
|
for (const [key, val] of Object.entries(this.policy)) {
|
|
@@ -1437,6 +1657,13 @@ var DefaultPermissionPolicy = class {
|
|
|
1437
1657
|
}
|
|
1438
1658
|
async evaluate(tool, input, ctx) {
|
|
1439
1659
|
if (!this.loaded) await this.reload();
|
|
1660
|
+
if (this.policyInvalid) {
|
|
1661
|
+
return {
|
|
1662
|
+
permission: "deny",
|
|
1663
|
+
source: "deny",
|
|
1664
|
+
reason: "trust policy is invalid; refusing tool execution until it is repaired"
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1440
1667
|
const namespaceEntry = this.findNamespaceEntry(tool.name);
|
|
1441
1668
|
const entry = this.policy[tool.name] ?? namespaceEntry;
|
|
1442
1669
|
const subject = subjectForToolInput(tool.name, input, tool.subjectKey);
|
|
@@ -1566,6 +1793,9 @@ var DefaultPermissionPolicy = class {
|
|
|
1566
1793
|
}
|
|
1567
1794
|
async trust(rule) {
|
|
1568
1795
|
if (!this.loaded) await this.reload();
|
|
1796
|
+
if (this.policyInvalid) {
|
|
1797
|
+
throw new Error("Cannot update trust rules while trust.json is invalid; repair it first.");
|
|
1798
|
+
}
|
|
1569
1799
|
const entry = this.policy[rule.tool] ?? {};
|
|
1570
1800
|
entry.allow = Array.from(/* @__PURE__ */ new Set([...entry.allow ?? [], rule.pattern]));
|
|
1571
1801
|
this.policy[rule.tool] = entry;
|
|
@@ -1584,6 +1814,9 @@ var DefaultPermissionPolicy = class {
|
|
|
1584
1814
|
/** Persist a deny rule — this tool+pattern pair is permanently blocked. */
|
|
1585
1815
|
async deny(rule) {
|
|
1586
1816
|
if (!this.loaded) await this.reload();
|
|
1817
|
+
if (this.policyInvalid) {
|
|
1818
|
+
throw new Error("Cannot update deny rules while trust.json is invalid; repair it first.");
|
|
1819
|
+
}
|
|
1587
1820
|
const entry = this.policy[rule.tool] ?? {};
|
|
1588
1821
|
entry.deny = Array.from(/* @__PURE__ */ new Set([...entry.deny ?? [], rule.pattern]));
|
|
1589
1822
|
this.policy[rule.tool] = entry;
|
|
@@ -1663,6 +1896,9 @@ export {
|
|
|
1663
1896
|
DefaultPermissionPolicy,
|
|
1664
1897
|
DefaultSecretScrubber,
|
|
1665
1898
|
DefaultSecretVault,
|
|
1899
|
+
TRUST_POLICY_JSON_SCHEMA,
|
|
1900
|
+
TRUST_POLICY_LIMITS,
|
|
1901
|
+
TRUST_POLICY_SCHEMA_VERSION,
|
|
1666
1902
|
ToolCapabilities,
|
|
1667
1903
|
decryptConfigSecrets,
|
|
1668
1904
|
encryptConfigSecrets,
|
|
@@ -1672,6 +1908,7 @@ export {
|
|
|
1672
1908
|
isSecretField,
|
|
1673
1909
|
migratePlaintextSecrets,
|
|
1674
1910
|
rewriteConfigEncrypted,
|
|
1675
|
-
rotateConfigKeys
|
|
1911
|
+
rotateConfigKeys,
|
|
1912
|
+
validateTrustPolicy
|
|
1676
1913
|
};
|
|
1677
1914
|
//# sourceMappingURL=index.js.map
|