gsd-pi 2.76.0-dev.82e249f7b → 2.76.0-dev.97f5583d9
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/claude-cli-check.js +32 -3
- package/dist/mcp-server.d.ts +7 -0
- package/dist/mcp-server.js +35 -1
- package/dist/resource-loader.d.ts +1 -1
- package/dist/resource-loader.js +2 -8
- package/dist/resources/extensions/claude-code-cli/readiness.js +4 -3
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +77 -17
- package/dist/resources/extensions/gsd/auto/phases.js +42 -1
- package/dist/resources/extensions/gsd/auto/run-unit.js +27 -0
- package/dist/resources/extensions/gsd/auto/session.js +12 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +16 -3
- package/dist/resources/extensions/gsd/auto-model-selection.js +1 -1
- package/dist/resources/extensions/gsd/auto-post-unit.js +25 -2
- package/dist/resources/extensions/gsd/auto-prompts.js +14 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +13 -0
- package/dist/resources/extensions/gsd/auto-start.js +27 -18
- package/dist/resources/extensions/gsd/auto-worktree.js +51 -53
- package/dist/resources/extensions/gsd/auto.js +55 -27
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +17 -1
- package/dist/resources/extensions/gsd/bootstrap/db-tools.js +39 -9
- package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +93 -0
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +2 -0
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +51 -5
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +34 -2
- package/dist/resources/extensions/gsd/clean-root-preflight.js +93 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +968 -23
- package/dist/resources/extensions/gsd/compaction-snapshot.js +121 -0
- package/dist/resources/extensions/gsd/error-classifier.js +10 -3
- package/dist/resources/extensions/gsd/exec-history.js +120 -0
- package/dist/resources/extensions/gsd/exec-sandbox.js +258 -0
- package/dist/resources/extensions/gsd/gsd-db.js +115 -7
- package/dist/resources/extensions/gsd/guided-flow.js +189 -0
- package/dist/resources/extensions/gsd/health-widget.js +4 -1
- package/dist/resources/extensions/gsd/init-wizard.js +15 -1
- package/dist/resources/extensions/gsd/key-manager.js +6 -0
- package/dist/resources/extensions/gsd/model-router.js +36 -3
- package/dist/resources/extensions/gsd/pre-execution-checks.js +35 -9
- package/dist/resources/extensions/gsd/preferences-types.js +9 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +83 -0
- package/dist/resources/extensions/gsd/preferences.js +17 -17
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/dist/resources/extensions/gsd/safety/evidence-collector.js +96 -0
- package/dist/resources/extensions/gsd/safety/file-change-validator.js +13 -5
- package/dist/resources/extensions/gsd/safety/safety-harness.js +5 -1
- package/dist/resources/extensions/gsd/token-counter.js +22 -5
- package/dist/resources/extensions/gsd/tools/exec-search-tool.js +59 -0
- package/dist/resources/extensions/gsd/tools/exec-tool.js +126 -0
- package/dist/resources/extensions/gsd/tools/resume-tool.js +23 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +20 -3
- package/dist/resources/extensions/gsd/workflow-mcp.js +3 -0
- package/dist/resources/skills/verify-before-complete/SKILL.md +2 -1
- package/dist/resources/skills/write-docs/SKILL.md +2 -1
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +10 -10
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/required-server-files.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +10 -10
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/server.js +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/dist/remote-questions.d.ts +45 -0
- package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -0
- package/packages/mcp-server/dist/remote-questions.js +732 -0
- package/packages/mcp-server/dist/remote-questions.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +7 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +41 -4
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
- package/packages/mcp-server/dist/workflow-tools.js +64 -25
- package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
- package/packages/mcp-server/package.json +2 -1
- package/packages/mcp-server/src/mcp-server.test.ts +30 -0
- package/packages/mcp-server/src/remote-questions.test.ts +294 -0
- package/packages/mcp-server/src/remote-questions.ts +916 -0
- package/packages/mcp-server/src/server.ts +62 -10
- package/packages/mcp-server/src/workflow-tools.test.ts +146 -1
- package/packages/mcp-server/src/workflow-tools.ts +84 -43
- package/packages/mcp-server/tsconfig.test.json +19 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js +1 -1
- package/packages/pi-ai/dist/providers/anthropic-auth.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic-shared.js +27 -4
- package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +8 -3
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +80 -0
- package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts +10 -0
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +16 -1
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/src/providers/anthropic-auth.test.ts +1 -1
- package/packages/pi-ai/src/providers/anthropic-shared.ts +26 -5
- package/packages/pi-ai/src/providers/anthropic.ts +9 -3
- package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +98 -0
- package/packages/pi-ai/src/providers/simple-options.ts +17 -1
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js +203 -0
- package/packages/pi-coding-agent/dist/core/model-registry-custom-caps.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +14 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js +49 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js +67 -0
- package/packages/pi-coding-agent/dist/core/redact-secrets.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +9 -5
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +25 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js +5 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/chat-frame.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +7 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +29 -21
- package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/model-registry-custom-caps.test.ts +245 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +16 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.test.ts +86 -0
- package/packages/pi-coding-agent/src/core/redact-secrets.ts +58 -0
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +36 -1
- package/packages/pi-coding-agent/src/core/session-manager.ts +9 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/chat-frame.ts +6 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +36 -22
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +13 -1
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/claude-code-cli/readiness.ts +4 -3
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +78 -17
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +149 -5
- package/src/resources/extensions/gsd/auto/loop-deps.ts +13 -0
- package/src/resources/extensions/gsd/auto/phases.ts +66 -1
- package/src/resources/extensions/gsd/auto/run-unit.ts +29 -0
- package/src/resources/extensions/gsd/auto/session.ts +22 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +16 -3
- package/src/resources/extensions/gsd/auto-model-selection.ts +1 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +29 -3
- package/src/resources/extensions/gsd/auto-prompts.ts +28 -1
- package/src/resources/extensions/gsd/auto-recovery.ts +15 -0
- package/src/resources/extensions/gsd/auto-start.ts +29 -19
- package/src/resources/extensions/gsd/auto-worktree.ts +62 -63
- package/src/resources/extensions/gsd/auto.ts +58 -27
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +23 -1
- package/src/resources/extensions/gsd/bootstrap/db-tools.ts +40 -9
- package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +109 -0
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +2 -0
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +53 -5
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +35 -2
- package/src/resources/extensions/gsd/clean-root-preflight.ts +111 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +898 -32
- package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
- package/src/resources/extensions/gsd/error-classifier.ts +10 -3
- package/src/resources/extensions/gsd/exec-history.ts +153 -0
- package/src/resources/extensions/gsd/exec-sandbox.ts +326 -0
- package/src/resources/extensions/gsd/gsd-db.ts +122 -7
- package/src/resources/extensions/gsd/guided-flow.ts +221 -0
- package/src/resources/extensions/gsd/health-widget.ts +3 -1
- package/src/resources/extensions/gsd/init-wizard.ts +15 -1
- package/src/resources/extensions/gsd/journal.ts +2 -1
- package/src/resources/extensions/gsd/key-manager.ts +6 -0
- package/src/resources/extensions/gsd/model-router.ts +42 -1
- package/src/resources/extensions/gsd/pre-execution-checks.ts +36 -10
- package/src/resources/extensions/gsd/preferences-types.ts +46 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +79 -0
- package/src/resources/extensions/gsd/preferences.ts +17 -17
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +8 -0
- package/src/resources/extensions/gsd/prompts/discuss.md +29 -2
- package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +5 -2
- package/src/resources/extensions/gsd/safety/evidence-collector.ts +119 -0
- package/src/resources/extensions/gsd/safety/file-change-validator.ts +17 -4
- package/src/resources/extensions/gsd/safety/safety-harness.ts +9 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +119 -1
- package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/clean-root-preflight.test.ts +186 -0
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/doctor-providers.test.ts +31 -0
- package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/escalation.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/exec-history.test.ts +124 -0
- package/src/resources/extensions/gsd/tests/exec-sandbox.test.ts +210 -0
- package/src/resources/extensions/gsd/tests/file-change-validator.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +152 -1
- package/src/resources/extensions/gsd/tests/init-wizard.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/isolation-none-branch-guard.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/issue-4540-regressions.test.ts +288 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/key-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/parallel-research-dispatch.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/pre-exec-gate-loop.test.ts +272 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +234 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +44 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +388 -0
- package/src/resources/extensions/gsd/tests/restore-tools-after-discuss.test.ts +9 -3
- package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +205 -0
- package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +32 -40
- package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +56 -0
- package/src/resources/extensions/gsd/tests/token-counter.test.ts +105 -1
- package/src/resources/extensions/gsd/tests/tool-compatibility.test.ts +107 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +23 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +65 -2
- package/src/resources/extensions/gsd/tests/write-gate.test.ts +64 -0
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +3 -1
- package/src/resources/extensions/gsd/token-counter.ts +22 -5
- package/src/resources/extensions/gsd/tools/exec-search-tool.ts +81 -0
- package/src/resources/extensions/gsd/tools/exec-tool.ts +183 -0
- package/src/resources/extensions/gsd/tools/resume-tool.ts +40 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +26 -3
- package/src/resources/extensions/gsd/workflow-logger.ts +3 -1
- package/src/resources/extensions/gsd/workflow-mcp.ts +3 -0
- package/src/resources/skills/verify-before-complete/SKILL.md +2 -1
- package/src/resources/skills/write-docs/SKILL.md +2 -1
- /package/dist/web/standalone/.next/static/{ecSsu49rxxcpbNmVP4mLD → lLdDRDspgYzfz0bJAmUSz}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{ecSsu49rxxcpbNmVP4mLD → lLdDRDspgYzfz0bJAmUSz}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for #4563:
|
|
3
|
+
* Bug 1 — custom/Anthropic-compatible models were hard-capped to 32 k output tokens
|
|
4
|
+
* Bug 2 — custom models in models.json could not declare capabilities.supportsXhigh
|
|
5
|
+
*/
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
11
|
+
import { AuthStorage } from "./auth-storage.js";
|
|
12
|
+
import { ModelRegistry } from "./model-registry.js";
|
|
13
|
+
|
|
14
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
let testDir: string;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
testDir = join(
|
|
20
|
+
tmpdir(),
|
|
21
|
+
`model-registry-custom-caps-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
22
|
+
);
|
|
23
|
+
mkdirSync(testDir, { recursive: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
try {
|
|
28
|
+
rmSync(testDir, { recursive: true, force: true });
|
|
29
|
+
} catch {
|
|
30
|
+
// best-effort cleanup
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function createRegistry(modelsJson: object): ModelRegistry {
|
|
35
|
+
const path = join(testDir, "models.json");
|
|
36
|
+
writeFileSync(path, JSON.stringify(modelsJson));
|
|
37
|
+
return new ModelRegistry(AuthStorage.inMemory(), path);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function writeModelsJson(obj: object): string {
|
|
41
|
+
const path = join(testDir, "models.json");
|
|
42
|
+
writeFileSync(path, JSON.stringify(obj));
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ─── Bug 1: 32 k cap must not apply to custom/OpenAI-compatible models ────────
|
|
47
|
+
|
|
48
|
+
describe("Bug 1 — maxTokens cap (#4563)", () => {
|
|
49
|
+
it("custom openai-completions model with maxTokens > 32 k is not capped", () => {
|
|
50
|
+
const registry = createRegistry({
|
|
51
|
+
providers: {
|
|
52
|
+
"kimi-custom": {
|
|
53
|
+
baseUrl: "https://api.example.com/v1",
|
|
54
|
+
apiKey: "sk-test",
|
|
55
|
+
api: "openai-completions",
|
|
56
|
+
models: [
|
|
57
|
+
{
|
|
58
|
+
id: "kimi-k2.6-code-preview",
|
|
59
|
+
name: "Kimi K2.6 Code Preview",
|
|
60
|
+
maxTokens: 131072,
|
|
61
|
+
contextWindow: 262144,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const model = registry.getAll().find((m) => m.id === "kimi-k2.6-code-preview");
|
|
69
|
+
assert.ok(model, "model should be registered");
|
|
70
|
+
assert.equal(
|
|
71
|
+
model.maxTokens,
|
|
72
|
+
131072,
|
|
73
|
+
"maxTokens must be preserved as declared — not capped to 32 000",
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("custom model with maxTokens exactly 32 k is not affected", () => {
|
|
78
|
+
const registry = createRegistry({
|
|
79
|
+
providers: {
|
|
80
|
+
"custom-provider": {
|
|
81
|
+
baseUrl: "https://api.example.com/v1",
|
|
82
|
+
apiKey: "sk-test",
|
|
83
|
+
api: "openai-completions",
|
|
84
|
+
models: [{ id: "model-32k", maxTokens: 32000, contextWindow: 128000 }],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const model = registry.getAll().find((m) => m.id === "model-32k");
|
|
90
|
+
assert.ok(model);
|
|
91
|
+
assert.equal(model.maxTokens, 32000);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("custom model with maxTokens 65 k is stored at full value", () => {
|
|
95
|
+
const registry = createRegistry({
|
|
96
|
+
providers: {
|
|
97
|
+
"dashscope-custom": {
|
|
98
|
+
baseUrl: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
|
|
99
|
+
apiKey: "sk-test",
|
|
100
|
+
api: "openai-completions",
|
|
101
|
+
models: [
|
|
102
|
+
{
|
|
103
|
+
id: "qwen3.5-plus",
|
|
104
|
+
name: "Qwen3.5 Plus",
|
|
105
|
+
maxTokens: 65536,
|
|
106
|
+
contextWindow: 1000000,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const model = registry.getAll().find((m) => m.id === "qwen3.5-plus" && m.provider === "dashscope-custom");
|
|
114
|
+
assert.ok(model);
|
|
115
|
+
assert.equal(model.maxTokens, 65536);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// ─── Bug 2: capabilities.supportsXhigh must be declarable in models.json ──────
|
|
120
|
+
|
|
121
|
+
describe("Bug 2 — capabilities.supportsXhigh in models.json (#4563)", () => {
|
|
122
|
+
it("model with capabilities.supportsXhigh: true surfaces the flag", () => {
|
|
123
|
+
const registry = createRegistry({
|
|
124
|
+
providers: {
|
|
125
|
+
"kimi-custom": {
|
|
126
|
+
baseUrl: "https://api.example.com/v1",
|
|
127
|
+
apiKey: "sk-test",
|
|
128
|
+
api: "anthropic-messages",
|
|
129
|
+
models: [
|
|
130
|
+
{
|
|
131
|
+
id: "kimi-k2.6-code-preview",
|
|
132
|
+
name: "Kimi K2.6 Code Preview",
|
|
133
|
+
maxTokens: 131072,
|
|
134
|
+
contextWindow: 262144,
|
|
135
|
+
capabilities: { supportsXhigh: true },
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const model = registry.getAll().find((m) => m.id === "kimi-k2.6-code-preview");
|
|
143
|
+
assert.ok(model, "model should be registered");
|
|
144
|
+
assert.equal(
|
|
145
|
+
model.capabilities?.supportsXhigh,
|
|
146
|
+
true,
|
|
147
|
+
"supportsXhigh must be true as declared in models.json",
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("model without capabilities declaration has no supportsXhigh", () => {
|
|
152
|
+
const registry = createRegistry({
|
|
153
|
+
providers: {
|
|
154
|
+
"plain-provider": {
|
|
155
|
+
baseUrl: "https://api.example.com/v1",
|
|
156
|
+
apiKey: "sk-test",
|
|
157
|
+
api: "openai-completions",
|
|
158
|
+
models: [{ id: "plain-model", maxTokens: 16384, contextWindow: 128000 }],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const model = registry.getAll().find((m) => m.id === "plain-model");
|
|
164
|
+
assert.ok(model);
|
|
165
|
+
// supportsXhigh should be absent or explicitly false — never implicitly true
|
|
166
|
+
assert.ok(
|
|
167
|
+
!model.capabilities?.supportsXhigh,
|
|
168
|
+
"supportsXhigh must not be set for models that don't declare it",
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("capabilities.supportsXhigh: false is respected", () => {
|
|
173
|
+
const registry = createRegistry({
|
|
174
|
+
providers: {
|
|
175
|
+
"explicit-provider": {
|
|
176
|
+
baseUrl: "https://api.example.com/v1",
|
|
177
|
+
apiKey: "sk-test",
|
|
178
|
+
api: "openai-completions",
|
|
179
|
+
models: [
|
|
180
|
+
{
|
|
181
|
+
id: "no-xhigh-model",
|
|
182
|
+
capabilities: { supportsXhigh: false },
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const model = registry.getAll().find((m) => m.id === "no-xhigh-model");
|
|
190
|
+
assert.ok(model);
|
|
191
|
+
assert.equal(model.capabilities?.supportsXhigh, false);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("supportsXhigh declared in models.json is not overwritten by capability patches", () => {
|
|
195
|
+
// The capability-patches system must not overwrite an explicit declaration in models.json.
|
|
196
|
+
// applyCapabilityPatches uses spread: { ...patch.caps, ...model.capabilities }
|
|
197
|
+
// so model.capabilities wins. This test verifies the precedence end-to-end.
|
|
198
|
+
const registry = createRegistry({
|
|
199
|
+
providers: {
|
|
200
|
+
"compat-provider": {
|
|
201
|
+
baseUrl: "https://api.example.com/v1",
|
|
202
|
+
apiKey: "sk-test",
|
|
203
|
+
api: "openai-completions",
|
|
204
|
+
models: [
|
|
205
|
+
{
|
|
206
|
+
id: "custom-xhigh-model",
|
|
207
|
+
capabilities: { supportsXhigh: true },
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const model = registry.getAll().find((m) => m.id === "custom-xhigh-model");
|
|
215
|
+
assert.ok(model);
|
|
216
|
+
assert.equal(model.capabilities?.supportsXhigh, true);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("modelOverrides can set capabilities.supportsXhigh on built-in models", () => {
|
|
220
|
+
// A user-facing override in models.json should be able to add supportsXhigh
|
|
221
|
+
// to a built-in model that doesn't declare it.
|
|
222
|
+
const path = writeModelsJson({
|
|
223
|
+
providers: {
|
|
224
|
+
anthropic: {
|
|
225
|
+
modelOverrides: {
|
|
226
|
+
"claude-3-5-haiku-20241022": {
|
|
227
|
+
capabilities: { supportsXhigh: true },
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const registry = new ModelRegistry(AuthStorage.inMemory(), path);
|
|
235
|
+
const model = registry.getAll().find(
|
|
236
|
+
(m) => m.provider === "anthropic" && m.id === "claude-3-5-haiku-20241022",
|
|
237
|
+
);
|
|
238
|
+
assert.ok(model, "built-in model must still be present");
|
|
239
|
+
assert.equal(
|
|
240
|
+
model.capabilities?.supportsXhigh,
|
|
241
|
+
true,
|
|
242
|
+
"modelOverrides must be able to set capabilities.supportsXhigh",
|
|
243
|
+
);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -48,6 +48,14 @@ const VercelGatewayRoutingSchema = Type.Object({
|
|
|
48
48
|
order: Type.Optional(Type.Array(Type.String())),
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
// Schema for model capability declarations (mirrors ModelCapabilities in pi-ai types)
|
|
52
|
+
const ModelCapabilitiesSchema = Type.Object({
|
|
53
|
+
supportsXhigh: Type.Optional(Type.Boolean()),
|
|
54
|
+
requiresToolCallId: Type.Optional(Type.Boolean()),
|
|
55
|
+
supportsServiceTier: Type.Optional(Type.Boolean()),
|
|
56
|
+
charsPerToken: Type.Optional(Type.Number()),
|
|
57
|
+
});
|
|
58
|
+
|
|
51
59
|
// Schema for OpenAI compatibility settings
|
|
52
60
|
const OpenAICompletionsCompatSchema = Type.Object({
|
|
53
61
|
supportsStore: Type.Optional(Type.Boolean()),
|
|
@@ -91,6 +99,7 @@ const ModelDefinitionSchema = Type.Object({
|
|
|
91
99
|
maxTokens: Type.Optional(Type.Number()),
|
|
92
100
|
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
93
101
|
compat: Type.Optional(OpenAICompatSchema),
|
|
102
|
+
capabilities: Type.Optional(ModelCapabilitiesSchema),
|
|
94
103
|
});
|
|
95
104
|
|
|
96
105
|
// Schema for per-model overrides (all fields optional, merged with built-in model)
|
|
@@ -110,6 +119,7 @@ const ModelOverrideSchema = Type.Object({
|
|
|
110
119
|
maxTokens: Type.Optional(Type.Number()),
|
|
111
120
|
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
112
121
|
compat: Type.Optional(OpenAICompatSchema),
|
|
122
|
+
capabilities: Type.Optional(ModelCapabilitiesSchema),
|
|
113
123
|
});
|
|
114
124
|
|
|
115
125
|
type ModelOverride = Static<typeof ModelOverrideSchema>;
|
|
@@ -219,6 +229,11 @@ function applyModelOverride(model: Model<Api>, override: ModelOverride): Model<A
|
|
|
219
229
|
// Deep merge compat
|
|
220
230
|
result.compat = mergeCompat(model.compat, override.compat);
|
|
221
231
|
|
|
232
|
+
// Merge capabilities (override wins per-field)
|
|
233
|
+
if (override.capabilities) {
|
|
234
|
+
result.capabilities = { ...model.capabilities, ...override.capabilities };
|
|
235
|
+
}
|
|
236
|
+
|
|
222
237
|
return result;
|
|
223
238
|
}
|
|
224
239
|
|
|
@@ -514,6 +529,7 @@ export class ModelRegistry {
|
|
|
514
529
|
maxTokens: modelDef.maxTokens ?? 16384,
|
|
515
530
|
headers,
|
|
516
531
|
compat: modelDef.compat,
|
|
532
|
+
capabilities: modelDef.capabilities,
|
|
517
533
|
} as Model<Api>);
|
|
518
534
|
}
|
|
519
535
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// pi-coding-agent — unit tests for session-log secret redaction
|
|
2
|
+
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
|
|
6
|
+
import { redactSecrets } from "./redact-secrets.js";
|
|
7
|
+
|
|
8
|
+
describe("redactSecrets", () => {
|
|
9
|
+
it("is a no-op on plain text with no secret markers", () => {
|
|
10
|
+
const input = "Hello world — this is just some prose with numbers 12345 and dashes - - -.";
|
|
11
|
+
assert.equal(redactSecrets(input), input);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("redacts Anthropic keys before generic openai sk- pattern", () => {
|
|
15
|
+
const out = redactSecrets("key=sk-ant-api03-abcDEF1234567890abcDEF1234567890");
|
|
16
|
+
assert.equal(out, "key=[REDACTED:anthropic]");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("redacts legacy OpenAI sk- keys", () => {
|
|
20
|
+
const out = redactSecrets("OPENAI_API_KEY=sk-abcDEF1234567890abcDEF12");
|
|
21
|
+
assert.equal(out, "OPENAI_API_KEY=[REDACTED:openai]");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("redacts OpenAI project sk-proj- keys with hyphens/underscores in body", () => {
|
|
25
|
+
const out = redactSecrets("OPENAI_API_KEY=sk-proj-AbCd_1234-EfGh_5678-IjKl_9012");
|
|
26
|
+
assert.equal(out, "OPENAI_API_KEY=[REDACTED:openai]");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("redacts OpenAI admin sk-admin- keys", () => {
|
|
30
|
+
const out = redactSecrets("OPENAI_ADMIN_KEY=sk-admin-AbCd1234EfGh5678IjKl9012");
|
|
31
|
+
assert.equal(out, "OPENAI_ADMIN_KEY=[REDACTED:openai]");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("redacts LlamaCloud llx- keys", () => {
|
|
35
|
+
const out = redactSecrets("LLAMA_CLOUD_API_KEY=llx-abcDEF1234567890abcDEF1234567890");
|
|
36
|
+
assert.equal(out, "LLAMA_CLOUD_API_KEY=[REDACTED:llamacloud]");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("redacts AWS access key ids", () => {
|
|
40
|
+
const out = redactSecrets("aws_access_key_id = AKIAIOSFODNN7EXAMPLE");
|
|
41
|
+
assert.equal(out, "aws_access_key_id = [REDACTED:aws-access-key]");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("redacts GitHub personal/oauth/app/server/refresh tokens", () => {
|
|
45
|
+
const out = redactSecrets("token=ghp_abcdefghijklmnopqrstuvwxyz0123456789");
|
|
46
|
+
assert.equal(out, "token=[REDACTED:github-token]");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("redacts Slack tokens", () => {
|
|
50
|
+
const out = redactSecrets("slack=xoxb-1234567890-abcdefghij");
|
|
51
|
+
assert.equal(out, "slack=[REDACTED:slack-token]");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("redacts Google API keys", () => {
|
|
55
|
+
// Google API keys are exactly AIza + 35 chars (39 total).
|
|
56
|
+
const out = redactSecrets("key=AIzaSyA-1234567890abcdefghijklmnopqrstu");
|
|
57
|
+
assert.equal(out, "key=[REDACTED:google-api-key]");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("redacts PEM private key blocks across newlines", () => {
|
|
61
|
+
const pem = [
|
|
62
|
+
"-----BEGIN RSA PRIVATE KEY-----",
|
|
63
|
+
"MIIEowIBAAKCAQEAabcDEF...",
|
|
64
|
+
"morekeymaterial==",
|
|
65
|
+
"-----END RSA PRIVATE KEY-----",
|
|
66
|
+
].join("\n");
|
|
67
|
+
const out = redactSecrets(`before\n${pem}\nafter`);
|
|
68
|
+
assert.equal(out, "before\n[REDACTED:pem-private-key]\nafter");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("redacts multiple secrets in the same string", () => {
|
|
72
|
+
const out = redactSecrets(
|
|
73
|
+
"AZURE_CLIENT_SECRET: also llx-abcDEF1234567890abcDEF1234567890 and AKIAIOSFODNN7EXAMPLE",
|
|
74
|
+
);
|
|
75
|
+
assert.equal(
|
|
76
|
+
out,
|
|
77
|
+
"AZURE_CLIENT_SECRET: also [REDACTED:llamacloud] and [REDACTED:aws-access-key]",
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("does not redact short strings that merely contain sk- prose", () => {
|
|
82
|
+
// "sk-foo" is too short to match the openai pattern — must be 20+ chars.
|
|
83
|
+
const input = "the sk- prefix isn't always a secret";
|
|
84
|
+
assert.equal(redactSecrets(input), input);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// pi-coding-agent — secret redaction for session log persistence
|
|
2
|
+
//
|
|
3
|
+
// Called by prepareForPersistence() in session-manager.ts on every string
|
|
4
|
+
// before it lands in the JSONL transcript. Replaces well-known secret shapes
|
|
5
|
+
// with [REDACTED:<kind>] placeholders so credentials pasted by the user or
|
|
6
|
+
// read from .env-style files never persist to disk.
|
|
7
|
+
//
|
|
8
|
+
// Pattern selection bias: high-specificity shapes only. Loose patterns
|
|
9
|
+
// (e.g. FOO_SECRET=...) produce too many false positives in docs and code
|
|
10
|
+
// samples and are intentionally excluded.
|
|
11
|
+
|
|
12
|
+
interface SecretPattern {
|
|
13
|
+
kind: string;
|
|
14
|
+
regex: RegExp;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Order matters: more-specific patterns first (sk-ant- before generic sk-).
|
|
18
|
+
const PATTERNS: readonly SecretPattern[] = [
|
|
19
|
+
{ kind: "anthropic", regex: /sk-ant-[A-Za-z0-9_-]{20,}/g },
|
|
20
|
+
{ kind: "llamacloud", regex: /llx-[A-Za-z0-9_-]{20,}/g },
|
|
21
|
+
// Covers all three official OpenAI key shapes: legacy `sk-…`, project `sk-proj-…`,
|
|
22
|
+
// and admin `sk-admin-…`. Hyphens and underscores appear inside real project keys
|
|
23
|
+
// so the remainder class must allow them. `sk-ant-` is matched earlier by the
|
|
24
|
+
// anthropic pattern and already replaced by the time this runs.
|
|
25
|
+
{ kind: "openai", regex: /sk-(?:proj-|admin-)?[A-Za-z0-9_-]{20,}/g },
|
|
26
|
+
{ kind: "aws-access-key", regex: /\b(?:AKIA|ASIA|AROA)[0-9A-Z]{16}\b/g },
|
|
27
|
+
{ kind: "github-token", regex: /\bgh[pousr]_[A-Za-z0-9]{30,}\b/g },
|
|
28
|
+
{ kind: "slack-token", regex: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g },
|
|
29
|
+
{ kind: "google-api-key", regex: /\bAIza[0-9A-Za-z_-]{35}\b/g },
|
|
30
|
+
{
|
|
31
|
+
kind: "pem-private-key",
|
|
32
|
+
regex: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export function redactSecrets(input: string): string {
|
|
37
|
+
// Short-circuit: skip regex work on strings with no plausible secret markers.
|
|
38
|
+
// Cheap heuristic — if none of these substrings are present, no pattern can match.
|
|
39
|
+
if (
|
|
40
|
+
!input.includes("sk-") &&
|
|
41
|
+
!input.includes("llx-") &&
|
|
42
|
+
!input.includes("AKIA") &&
|
|
43
|
+
!input.includes("ASIA") &&
|
|
44
|
+
!input.includes("AROA") &&
|
|
45
|
+
!input.includes("gh") &&
|
|
46
|
+
!input.includes("xox") &&
|
|
47
|
+
!input.includes("AIza") &&
|
|
48
|
+
!input.includes("PRIVATE KEY")
|
|
49
|
+
) {
|
|
50
|
+
return input;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let out = input;
|
|
54
|
+
for (const { kind, regex } of PATTERNS) {
|
|
55
|
+
out = out.replace(regex, `[REDACTED:${kind}]`);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it, afterEach } from "node:test";
|
|
3
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
|
|
@@ -63,3 +63,38 @@ describe("SessionManager usage totals", () => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
describe("SessionManager secret redaction on persistence", () => {
|
|
68
|
+
let dir: string;
|
|
69
|
+
|
|
70
|
+
afterEach(() => {
|
|
71
|
+
if (dir) {
|
|
72
|
+
rmSync(dir, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("scrubs known secret shapes from JSONL on disk", () => {
|
|
77
|
+
dir = mkdtempSync(join(tmpdir(), "gsd-session-redact-test-"));
|
|
78
|
+
const manager = SessionManager.create(dir, dir);
|
|
79
|
+
|
|
80
|
+
const leakedKey = "llx-abcDEF1234567890abcDEF1234567890";
|
|
81
|
+
manager.appendMessage({
|
|
82
|
+
role: "user",
|
|
83
|
+
content: [{ type: "text", text: `here is my key: ${leakedKey}` }],
|
|
84
|
+
} as any);
|
|
85
|
+
// Persistence is gated on an assistant message being present.
|
|
86
|
+
manager.appendMessage(makeAssistantMessage(1, 1, 0, 0, 0));
|
|
87
|
+
|
|
88
|
+
const sessionFile = manager.getSessionFile();
|
|
89
|
+
assert.ok(sessionFile, "session file should be set");
|
|
90
|
+
const contents = readFileSync(sessionFile!, "utf8");
|
|
91
|
+
assert.ok(
|
|
92
|
+
!contents.includes(leakedKey),
|
|
93
|
+
"raw secret must not appear in persisted JSONL",
|
|
94
|
+
);
|
|
95
|
+
assert.ok(
|
|
96
|
+
contents.includes("[REDACTED:llamacloud]"),
|
|
97
|
+
"redaction placeholder must appear in persisted JSONL",
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
createCustomMessage,
|
|
27
27
|
} from "./messages.js";
|
|
28
28
|
import { BlobStore, externalizeImageData, isBlobRef, resolveImageData } from "./blob-store.js";
|
|
29
|
+
import { redactSecrets } from "./redact-secrets.js";
|
|
29
30
|
|
|
30
31
|
/** Inline concurrency limiter to cap parallel async operations. */
|
|
31
32
|
function pLimit(concurrency: number) {
|
|
@@ -499,15 +500,18 @@ function prepareForPersistence(obj: unknown, blobStore: BlobStore, key?: string)
|
|
|
499
500
|
if (obj === null || obj === undefined) return obj;
|
|
500
501
|
|
|
501
502
|
if (typeof obj === "string") {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
// Cryptographic signatures must be preserved byte-exact — never redact or truncate
|
|
504
|
+
// their contents, only the oversize-clear path below handles them.
|
|
505
|
+
const isSignature = key === "thinkingSignature" || key === "thoughtSignature" || key === "textSignature";
|
|
506
|
+
const redacted = isSignature ? obj : redactSecrets(obj);
|
|
507
|
+
if (redacted.length > MAX_PERSIST_CHARS) {
|
|
508
|
+
if (isSignature) {
|
|
505
509
|
return "";
|
|
506
510
|
}
|
|
507
511
|
const limit = Math.max(0, MAX_PERSIST_CHARS - TRUNCATION_NOTICE.length);
|
|
508
|
-
return `${truncateString(
|
|
512
|
+
return `${truncateString(redacted, limit)}${TRUNCATION_NOTICE}`;
|
|
509
513
|
}
|
|
510
|
-
return
|
|
514
|
+
return redacted;
|
|
511
515
|
}
|
|
512
516
|
|
|
513
517
|
if (Array.isArray(obj)) {
|
|
@@ -2,7 +2,7 @@ import { truncateToWidth, visibleWidth } from "@gsd/pi-tui";
|
|
|
2
2
|
import { theme } from "../theme/theme.js";
|
|
3
3
|
import { formatTimestamp, type TimestampFormat } from "./timestamp.js";
|
|
4
4
|
|
|
5
|
-
type FrameTone = "assistant" | "user" | "compaction";
|
|
5
|
+
type FrameTone = "assistant" | "user" | "compaction" | "skill";
|
|
6
6
|
|
|
7
7
|
function trimOuterBlankLines(lines: string[]): string[] {
|
|
8
8
|
let start = 0;
|
|
@@ -25,14 +25,14 @@ export function renderChatFrame(
|
|
|
25
25
|
): string[] {
|
|
26
26
|
const outerWidth = Math.max(20, width);
|
|
27
27
|
const contentWidth = Math.max(1, outerWidth - 2); // "│ " + content
|
|
28
|
+
const isPurple = opts.tone === "compaction" || opts.tone === "skill";
|
|
28
29
|
const borderColor =
|
|
29
30
|
opts.tone === "user"
|
|
30
31
|
? "border"
|
|
31
|
-
:
|
|
32
|
+
: isPurple
|
|
32
33
|
? "customMessageLabel"
|
|
33
34
|
: "borderAccent";
|
|
34
|
-
const borderMuted =
|
|
35
|
-
opts.tone === "compaction" ? "customMessageLabel" : "borderMuted";
|
|
35
|
+
const borderMuted = isPurple ? "customMessageLabel" : "borderMuted";
|
|
36
36
|
const border = (s: string) => theme.fg(borderColor, s);
|
|
37
37
|
const leftRaw = `• ${opts.label}`;
|
|
38
38
|
const rightRaw =
|
|
@@ -47,7 +47,7 @@ export function renderChatFrame(
|
|
|
47
47
|
const labelColor =
|
|
48
48
|
opts.tone === "user"
|
|
49
49
|
? "border"
|
|
50
|
-
:
|
|
50
|
+
: isPurple
|
|
51
51
|
? "customMessageLabel"
|
|
52
52
|
: "borderAccent";
|
|
53
53
|
const dashIdx = left.indexOf(" - ");
|
|
@@ -71,7 +71,7 @@ export function renderChatFrame(
|
|
|
71
71
|
const bodyColor =
|
|
72
72
|
opts.tone === "user"
|
|
73
73
|
? "userMessageText"
|
|
74
|
-
:
|
|
74
|
+
: isPurple
|
|
75
75
|
? "customMessageText"
|
|
76
76
|
: "assistantMessageText";
|
|
77
77
|
const bodyLines = (sourceLines.length > 0 ? sourceLines : [""]).map((line) => {
|
package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts
CHANGED
|
@@ -1,55 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
// GSD / pi-coding-agent — Skill invocation message component
|
|
2
|
+
import { Container, Markdown, type MarkdownTheme, Text } from "@gsd/pi-tui";
|
|
2
3
|
import type { ParsedSkillBlock } from "../../../core/agent-session.js";
|
|
3
4
|
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
|
5
|
+
import { renderChatFrame } from "./chat-frame.js";
|
|
4
6
|
import { editorKey } from "./keybinding-hints.js";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Renders a skill invocation in the shared chat-frame style (top rule,
|
|
10
|
+
* `• skill - <name>` header, `│ ` body margin) with purple border/label
|
|
11
|
+
* matching compaction so it visually aligns with user/assistant messages.
|
|
10
12
|
*/
|
|
11
|
-
export class SkillInvocationMessageComponent extends
|
|
13
|
+
export class SkillInvocationMessageComponent extends Container {
|
|
12
14
|
private expanded = false;
|
|
13
15
|
private skillBlock: ParsedSkillBlock;
|
|
14
16
|
private markdownTheme: MarkdownTheme;
|
|
15
17
|
|
|
16
18
|
constructor(skillBlock: ParsedSkillBlock, markdownTheme: MarkdownTheme = getMarkdownTheme()) {
|
|
17
|
-
super(
|
|
19
|
+
super();
|
|
18
20
|
this.skillBlock = skillBlock;
|
|
19
21
|
this.markdownTheme = markdownTheme;
|
|
20
|
-
this.
|
|
22
|
+
this.rebuild();
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
setExpanded(expanded: boolean): void {
|
|
24
|
-
this.expanded
|
|
25
|
-
|
|
26
|
+
if (this.expanded !== expanded) {
|
|
27
|
+
this.expanded = expanded;
|
|
28
|
+
this.rebuild();
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
override invalidate(): void {
|
|
29
33
|
super.invalidate();
|
|
30
|
-
this.
|
|
34
|
+
this.rebuild();
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
private
|
|
37
|
+
private rebuild(): void {
|
|
34
38
|
this.clear();
|
|
35
39
|
|
|
36
40
|
if (this.expanded) {
|
|
37
|
-
// Expanded: label + skill name header + full content
|
|
38
|
-
const label = theme.fg("customMessageLabel", theme.bold("[skill]"));
|
|
39
|
-
this.addChild(new Text(label, 0, 0));
|
|
40
|
-
const header = `**${this.skillBlock.name}**\n\n`;
|
|
41
41
|
this.addChild(
|
|
42
|
-
new Markdown(
|
|
42
|
+
new Markdown(this.skillBlock.content, 0, 0, this.markdownTheme, {
|
|
43
43
|
color: (text: string) => theme.fg("customMessageText", text),
|
|
44
44
|
}),
|
|
45
45
|
);
|
|
46
46
|
} else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
this.addChild(
|
|
48
|
+
new Text(
|
|
49
|
+
theme.fg("dim", `(${editorKey("expandTools")} to expand)`),
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
override render(width: number): string[] {
|
|
58
|
+
const frameWidth = Math.max(20, width);
|
|
59
|
+
const contentWidth = Math.max(1, frameWidth - 4);
|
|
60
|
+
const lines = super.render(contentWidth);
|
|
61
|
+
const framed = renderChatFrame(lines, frameWidth, {
|
|
62
|
+
label: `skill - ${this.skillBlock.name}`,
|
|
63
|
+
tone: "skill",
|
|
64
|
+
timestampFormat: "date-time-iso",
|
|
65
|
+
showTimestamp: false,
|
|
66
|
+
});
|
|
67
|
+
return framed.length > 0 ? ["", ...framed] : framed;
|
|
68
|
+
}
|
|
55
69
|
}
|
|
@@ -3585,7 +3585,19 @@ export class InteractiveMode {
|
|
|
3585
3585
|
this.ui.requestRender();
|
|
3586
3586
|
},
|
|
3587
3587
|
async (provider: string) => {
|
|
3588
|
-
// Enter key → auth setup for selected provider (#3579)
|
|
3588
|
+
// Enter key → auth setup for selected provider (#3579).
|
|
3589
|
+
// Only OAuth providers support the login dialog flow.
|
|
3590
|
+
// externalCli providers (e.g. claude-code) authenticate through
|
|
3591
|
+
// their own CLI — sending them to the OAuth dialog produces
|
|
3592
|
+
// "Unknown OAuth provider: claude-code" (#4548).
|
|
3593
|
+
const isOAuthProvider = this.session.modelRegistry.authStorage
|
|
3594
|
+
.getOAuthProviders()
|
|
3595
|
+
.some((p) => p.id === provider);
|
|
3596
|
+
if (!isOAuthProvider) {
|
|
3597
|
+
done();
|
|
3598
|
+
this.showStatus(`${provider} uses external CLI auth — use /model to select a model or run the provider's own auth command.`);
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3589
3601
|
done();
|
|
3590
3602
|
await this.showLoginDialog(provider);
|
|
3591
3603
|
},
|