gsd-pi 2.76.0-dev.b072ebb73 → 2.76.0-dev.fe143342a
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/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/stream-adapter.js +66 -4
- package/dist/resources/extensions/gsd/auto/phases.js +4 -1
- package/dist/resources/extensions/gsd/auto/session.js +4 -0
- package/dist/resources/extensions/gsd/auto-model-selection.js +39 -13
- package/dist/resources/extensions/gsd/auto-start.js +39 -21
- package/dist/resources/extensions/gsd/auto.js +15 -12
- package/dist/resources/extensions/gsd/blocked-models.js +68 -0
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +76 -0
- 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 +35 -0
- package/dist/resources/extensions/gsd/compaction-snapshot.js +121 -0
- package/dist/resources/extensions/gsd/complexity-classifier.js +5 -3
- package/dist/resources/extensions/gsd/error-classifier.js +31 -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 +62 -4
- 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/pre-execution-checks.js +13 -3
- 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/prompt-loader.js +22 -7
- package/dist/resources/extensions/gsd/safety/file-change-validator.js +1 -1
- 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/workflow-mcp.js +3 -0
- package/dist/resources/extensions/search-the-web/command-search-provider.js +5 -4
- package/dist/resources/extensions/search-the-web/native-search.js +45 -13
- 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 +8 -8
- 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 +8 -8
- 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/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/src/workflow-tools.test.ts +146 -1
- package/packages/mcp-server/src/workflow-tools.ts +84 -43
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +60 -15
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts +17 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js +75 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.js.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js +41 -0
- package/packages/pi-ai/dist/providers/think-tag-parser.test.js.map +1 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +57 -16
- package/packages/pi-ai/src/providers/think-tag-parser.test.ts +44 -0
- package/packages/pi-ai/src/providers/think-tag-parser.ts +94 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts +3 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.js +92 -12
- package/packages/pi-coding-agent/dist/core/model-discovery.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js +16 -1
- package/packages/pi-coding-agent/dist/core/model-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js +61 -1
- package/packages/pi-coding-agent/dist/core/model-registry-discovery.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +5 -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 +76 -10
- 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/provider-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.js +13 -7
- package/packages/pi-coding-agent/dist/modes/interactive/components/provider-manager.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/src/core/model-discovery.test.ts +19 -0
- package/packages/pi-coding-agent/src/core/model-discovery.ts +99 -12
- package/packages/pi-coding-agent/src/core/model-registry-discovery.test.ts +75 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +86 -10
- 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/provider-manager.ts +16 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +36 -22
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/scripts/link-workspace-packages.cjs +1 -0
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +67 -4
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +137 -2
- package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -0
- package/src/resources/extensions/gsd/auto/phases.ts +4 -0
- package/src/resources/extensions/gsd/auto/session.ts +7 -1
- package/src/resources/extensions/gsd/auto-model-selection.ts +50 -12
- package/src/resources/extensions/gsd/auto-start.ts +40 -22
- package/src/resources/extensions/gsd/auto.ts +15 -12
- package/src/resources/extensions/gsd/blocked-models.ts +98 -0
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +97 -0
- 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 +36 -0
- package/src/resources/extensions/gsd/compaction-snapshot.ts +165 -0
- package/src/resources/extensions/gsd/complexity-classifier.ts +5 -3
- package/src/resources/extensions/gsd/error-classifier.ts +36 -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 +68 -4
- package/src/resources/extensions/gsd/init-wizard.ts +15 -1
- package/src/resources/extensions/gsd/key-manager.ts +6 -0
- package/src/resources/extensions/gsd/pre-execution-checks.ts +13 -3
- package/src/resources/extensions/gsd/preferences-types.ts +38 -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/prompt-loader.ts +30 -7
- package/src/resources/extensions/gsd/safety/file-change-validator.ts +1 -1
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +33 -3
- package/src/resources/extensions/gsd/tests/auto-thinking-restore.test.ts +38 -0
- package/src/resources/extensions/gsd/tests/blocked-models.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/compaction-snapshot.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/complexity-classifier.test.ts +3 -3
- 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 +20 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +151 -0
- 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/key-manager.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +19 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +110 -0
- package/src/resources/extensions/gsd/tests/prompt-loader-extension-dir.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +91 -0
- package/src/resources/extensions/gsd/tests/save-gate-result-render.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/zombie-gsd-state.test.ts +3 -1
- 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/workflow-logger.ts +2 -1
- package/src/resources/extensions/gsd/workflow-mcp.ts +3 -0
- package/src/resources/extensions/search-the-web/command-search-provider.ts +5 -4
- package/src/resources/extensions/search-the-web/native-search.ts +48 -12
- /package/dist/web/standalone/.next/static/{pBwmOoye64ZrRp-_rf0v1 → n21VtX2hZlkpdEUO_nU4z}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{pBwmOoye64ZrRp-_rf0v1 → n21VtX2hZlkpdEUO_nU4z}/_ssgManifest.js +0 -0
|
@@ -29,7 +29,7 @@ import { getAgentDir } from "../config.js";
|
|
|
29
29
|
import type { AuthStorage } from "./auth-storage.js";
|
|
30
30
|
import { ModelDiscoveryCache } from "./discovery-cache.js";
|
|
31
31
|
import type { DiscoveredModel, DiscoveryResult } from "./model-discovery.js";
|
|
32
|
-
import { getDefaultTTL, getDiscoverableProviders, getDiscoveryAdapter } from "./model-discovery.js";
|
|
32
|
+
import { getDefaultTTL, getDiscoverableProviders, getDiscoveryAdapter, supportsDiscoveryForApi } from "./model-discovery.js";
|
|
33
33
|
import { clearConfigValueCache, resolveConfigValue, resolveHeaders } from "./resolve-config-value.js";
|
|
34
34
|
import { isLocalModel } from "./local-model-check.js";
|
|
35
35
|
|
|
@@ -788,11 +788,12 @@ export class ModelRegistry {
|
|
|
788
788
|
* Results are cached and merged into the registry (never overrides existing models).
|
|
789
789
|
*/
|
|
790
790
|
async discoverModels(providers?: string[]): Promise<DiscoveryResult[]> {
|
|
791
|
-
const targetProviders = providers ??
|
|
791
|
+
const targetProviders = providers ?? this.getAutoDiscoverableProviders();
|
|
792
792
|
const results: DiscoveryResult[] = [];
|
|
793
793
|
|
|
794
794
|
for (const providerName of targetProviders) {
|
|
795
|
-
const
|
|
795
|
+
const providerApis = this.getProviderApis(providerName);
|
|
796
|
+
const adapter = getDiscoveryAdapter(providerName, providerApis);
|
|
796
797
|
if (!adapter.supportsDiscovery) continue;
|
|
797
798
|
|
|
798
799
|
// Skip if cache is still fresh
|
|
@@ -812,8 +813,10 @@ export class ModelRegistry {
|
|
|
812
813
|
const apiKey = await this.authStorage.getApiKey(providerName);
|
|
813
814
|
if (!apiKey && !this.isProviderRequestReady(providerName)) continue;
|
|
814
815
|
|
|
815
|
-
const
|
|
816
|
-
|
|
816
|
+
const baseUrl = this.getProviderBaseUrl(providerName);
|
|
817
|
+
const models = await adapter.fetchModels(apiKey ?? "", baseUrl);
|
|
818
|
+
const ttlMs = this.getDiscoveryTtl(providerName, providerApis);
|
|
819
|
+
this.discoveryCache.set(providerName, models, ttlMs);
|
|
817
820
|
results.push({
|
|
818
821
|
provider: providerName,
|
|
819
822
|
models,
|
|
@@ -865,24 +868,97 @@ export class ModelRegistry {
|
|
|
865
868
|
const converted: Model<Api>[] = [];
|
|
866
869
|
for (const result of results) {
|
|
867
870
|
if (result.error) continue;
|
|
871
|
+
const providerDefaults = this.getDiscoveryProviderDefaults(result.provider);
|
|
868
872
|
for (const dm of result.models) {
|
|
869
873
|
converted.push({
|
|
870
874
|
id: dm.id,
|
|
871
875
|
name: dm.name ?? dm.id,
|
|
872
|
-
api:
|
|
876
|
+
api: providerDefaults.api,
|
|
873
877
|
provider: result.provider,
|
|
874
|
-
baseUrl:
|
|
878
|
+
baseUrl: providerDefaults.baseUrl,
|
|
875
879
|
reasoning: dm.reasoning ?? false,
|
|
876
|
-
input: dm.input ??
|
|
880
|
+
input: dm.input ?? providerDefaults.input,
|
|
877
881
|
cost: dm.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
878
|
-
contextWindow: dm.contextWindow ??
|
|
879
|
-
maxTokens: dm.maxTokens ??
|
|
882
|
+
contextWindow: dm.contextWindow ?? providerDefaults.contextWindow,
|
|
883
|
+
maxTokens: dm.maxTokens ?? providerDefaults.maxTokens,
|
|
880
884
|
} as Model<Api>);
|
|
881
885
|
}
|
|
882
886
|
}
|
|
883
887
|
return converted;
|
|
884
888
|
}
|
|
885
889
|
|
|
890
|
+
private getProviderApis(provider: string): Set<string> {
|
|
891
|
+
const apis = new Set<string>();
|
|
892
|
+
for (const model of this.models) {
|
|
893
|
+
if (model.provider === provider && typeof model.api === "string" && model.api.length > 0) {
|
|
894
|
+
apis.add(model.api);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const providerConfig = this.registeredProviders.get(provider);
|
|
899
|
+
if (providerConfig?.api) apis.add(providerConfig.api);
|
|
900
|
+
for (const modelDef of providerConfig?.models ?? []) {
|
|
901
|
+
if (modelDef.api) apis.add(modelDef.api);
|
|
902
|
+
}
|
|
903
|
+
return apis;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
private getAutoDiscoverableProviders(): string[] {
|
|
907
|
+
const discoverable = new Set<string>(getDiscoverableProviders());
|
|
908
|
+
for (const provider of new Set(this.models.map((m) => m.provider))) {
|
|
909
|
+
const apis = this.getProviderApis(provider);
|
|
910
|
+
for (const api of apis) {
|
|
911
|
+
if (supportsDiscoveryForApi(api)) {
|
|
912
|
+
discoverable.add(provider);
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return [...discoverable];
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
private getProviderBaseUrl(provider: string): string | undefined {
|
|
921
|
+
const fromModels = this.models.find((m) => m.provider === provider && typeof m.baseUrl === "string" && m.baseUrl.length > 0);
|
|
922
|
+
if (fromModels?.baseUrl) return fromModels.baseUrl;
|
|
923
|
+
return this.registeredProviders.get(provider)?.baseUrl;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
private getDiscoveryProviderDefaults(provider: string): {
|
|
927
|
+
api: Api;
|
|
928
|
+
baseUrl: string;
|
|
929
|
+
input: ("text" | "image")[];
|
|
930
|
+
contextWindow: number;
|
|
931
|
+
maxTokens: number;
|
|
932
|
+
} {
|
|
933
|
+
const first = this.models.find((m) => m.provider === provider);
|
|
934
|
+
if (first) {
|
|
935
|
+
return {
|
|
936
|
+
api: first.api,
|
|
937
|
+
baseUrl: first.baseUrl,
|
|
938
|
+
input: first.input,
|
|
939
|
+
contextWindow: first.contextWindow,
|
|
940
|
+
maxTokens: first.maxTokens,
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
return {
|
|
945
|
+
api: "openai-completions",
|
|
946
|
+
baseUrl: this.registeredProviders.get(provider)?.baseUrl ?? "",
|
|
947
|
+
input: ["text"],
|
|
948
|
+
contextWindow: 128000,
|
|
949
|
+
maxTokens: 16384,
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
private getDiscoveryTtl(provider: string, providerApis: Set<string>): number {
|
|
954
|
+
for (const api of providerApis) {
|
|
955
|
+
if (supportsDiscoveryForApi(api)) {
|
|
956
|
+
return getDefaultTTL("openai");
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return getDefaultTTL(provider);
|
|
960
|
+
}
|
|
961
|
+
|
|
886
962
|
/**
|
|
887
963
|
* Check if a model's baseUrl points to a local endpoint.
|
|
888
964
|
* Delegates to standalone isLocalModel() function.
|
|
@@ -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) => {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type TUI,
|
|
13
13
|
} from "@gsd/pi-tui";
|
|
14
14
|
import type { AuthStorage } from "../../../core/auth-storage.js";
|
|
15
|
-
import { getDiscoverableProviders } from "../../../core/model-discovery.js";
|
|
15
|
+
import { getDiscoverableProviders, getDiscoveryAdapter } from "../../../core/model-discovery.js";
|
|
16
16
|
import { providerDisplayName } from "./model-selector.js";
|
|
17
17
|
import type { ModelRegistry } from "../../../core/model-registry.js";
|
|
18
18
|
import { ModelsJsonWriter } from "../../../core/models-json-writer.js";
|
|
@@ -102,12 +102,21 @@ export class ProviderManagerComponent extends Container implements Focusable {
|
|
|
102
102
|
|
|
103
103
|
this.providers = Array.from(providerNames)
|
|
104
104
|
.sort()
|
|
105
|
-
.map((name) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
.map((name) => {
|
|
106
|
+
const providerApis = new Set(
|
|
107
|
+
allModels
|
|
108
|
+
.filter((m) => m.provider === name)
|
|
109
|
+
.map((m) => m.api)
|
|
110
|
+
.filter((api): api is string => typeof api === "string" && api.length > 0),
|
|
111
|
+
);
|
|
112
|
+
return {
|
|
113
|
+
name,
|
|
114
|
+
hasAuth: this.authStorage.hasAuth(name),
|
|
115
|
+
supportsDiscovery:
|
|
116
|
+
discoverableSet.has(name) || getDiscoveryAdapter(name, providerApis).supportsDiscovery,
|
|
117
|
+
modelCount: providerModelCounts.get(name) ?? 0,
|
|
118
|
+
};
|
|
119
|
+
});
|
|
111
120
|
this.clampSelectedIndex();
|
|
112
121
|
}
|
|
113
122
|
|
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
|
}
|