@agent-native/core 0.51.15 → 0.53.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/README.md +42 -96
- package/blueprints/action/crud.md +98 -0
- package/blueprints/channel/discord.md +74 -0
- package/blueprints/provider/stripe.md +87 -0
- package/blueprints/sandbox/docker.md +78 -0
- package/dist/action.d.ts +24 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +4 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/observational-memory/compactor.d.ts +43 -0
- package/dist/agent/observational-memory/compactor.d.ts.map +1 -0
- package/dist/agent/observational-memory/compactor.js +50 -0
- package/dist/agent/observational-memory/compactor.js.map +1 -0
- package/dist/agent/observational-memory/config.d.ts +37 -0
- package/dist/agent/observational-memory/config.d.ts.map +1 -0
- package/dist/agent/observational-memory/config.js +48 -0
- package/dist/agent/observational-memory/config.js.map +1 -0
- package/dist/agent/observational-memory/index.d.ts +26 -0
- package/dist/agent/observational-memory/index.d.ts.map +1 -0
- package/dist/agent/observational-memory/index.js +25 -0
- package/dist/agent/observational-memory/index.js.map +1 -0
- package/dist/agent/observational-memory/internal-run.d.ts +37 -0
- package/dist/agent/observational-memory/internal-run.d.ts.map +1 -0
- package/dist/agent/observational-memory/internal-run.js +59 -0
- package/dist/agent/observational-memory/internal-run.js.map +1 -0
- package/dist/agent/observational-memory/message-text.d.ts +13 -0
- package/dist/agent/observational-memory/message-text.d.ts.map +1 -0
- package/dist/agent/observational-memory/message-text.js +46 -0
- package/dist/agent/observational-memory/message-text.js.map +1 -0
- package/dist/agent/observational-memory/migrations.d.ts +13 -0
- package/dist/agent/observational-memory/migrations.d.ts.map +1 -0
- package/dist/agent/observational-memory/migrations.js +43 -0
- package/dist/agent/observational-memory/migrations.js.map +1 -0
- package/dist/agent/observational-memory/observer.d.ts +37 -0
- package/dist/agent/observational-memory/observer.d.ts.map +1 -0
- package/dist/agent/observational-memory/observer.js +82 -0
- package/dist/agent/observational-memory/observer.js.map +1 -0
- package/dist/agent/observational-memory/plugin.d.ts +16 -0
- package/dist/agent/observational-memory/plugin.d.ts.map +1 -0
- package/dist/agent/observational-memory/plugin.js +26 -0
- package/dist/agent/observational-memory/plugin.js.map +1 -0
- package/dist/agent/observational-memory/prompts.d.ts +27 -0
- package/dist/agent/observational-memory/prompts.d.ts.map +1 -0
- package/dist/agent/observational-memory/prompts.js +42 -0
- package/dist/agent/observational-memory/prompts.js.map +1 -0
- package/dist/agent/observational-memory/read.d.ts +47 -0
- package/dist/agent/observational-memory/read.d.ts.map +1 -0
- package/dist/agent/observational-memory/read.js +99 -0
- package/dist/agent/observational-memory/read.js.map +1 -0
- package/dist/agent/observational-memory/reflector.d.ts +31 -0
- package/dist/agent/observational-memory/reflector.d.ts.map +1 -0
- package/dist/agent/observational-memory/reflector.js +76 -0
- package/dist/agent/observational-memory/reflector.js.map +1 -0
- package/dist/agent/observational-memory/schema.d.ts +267 -0
- package/dist/agent/observational-memory/schema.d.ts.map +1 -0
- package/dist/agent/observational-memory/schema.js +48 -0
- package/dist/agent/observational-memory/schema.js.map +1 -0
- package/dist/agent/observational-memory/store.d.ts +52 -0
- package/dist/agent/observational-memory/store.d.ts.map +1 -0
- package/dist/agent/observational-memory/store.js +197 -0
- package/dist/agent/observational-memory/store.js.map +1 -0
- package/dist/agent/observational-memory/types.d.ts +61 -0
- package/dist/agent/observational-memory/types.d.ts.map +1 -0
- package/dist/agent/observational-memory/types.js +9 -0
- package/dist/agent/observational-memory/types.js.map +1 -0
- package/dist/agent/production-agent.d.ts +15 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +240 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +49 -0
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-store.d.ts +17 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +55 -0
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/runtime-context.d.ts +30 -0
- package/dist/agent/runtime-context.d.ts.map +1 -1
- package/dist/agent/runtime-context.js +54 -1
- package/dist/agent/runtime-context.js.map +1 -1
- package/dist/agent/tool-call-journal.d.ts +101 -0
- package/dist/agent/tool-call-journal.d.ts.map +1 -0
- package/dist/agent/tool-call-journal.js +214 -0
- package/dist/agent/tool-call-journal.js.map +1 -0
- package/dist/agent/types.d.ts +24 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/add.d.ts +109 -0
- package/dist/cli/add.d.ts.map +1 -0
- package/dist/cli/add.js +352 -0
- package/dist/cli/add.js.map +1 -0
- package/dist/cli/connect.d.ts +5 -4
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +157 -48
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/eval.d.ts +17 -0
- package/dist/cli/eval.d.ts.map +1 -0
- package/dist/cli/eval.js +121 -0
- package/dist/cli/eval.js.map +1 -0
- package/dist/cli/index.js +44 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-config-writers.d.ts +20 -13
- package/dist/cli/mcp-config-writers.d.ts.map +1 -1
- package/dist/cli/mcp-config-writers.js +152 -13
- package/dist/cli/mcp-config-writers.js.map +1 -1
- package/dist/cli/mcp.d.ts +2 -2
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +50 -196
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/plan-local.d.ts +69 -6
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +517 -23
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +1 -1
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills.d.ts +13 -6
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +287 -111
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +118 -92
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +16 -0
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-engine-key.d.ts +6 -4
- package/dist/client/agent-engine-key.d.ts.map +1 -1
- package/dist/client/agent-engine-key.js +9 -6
- package/dist/client/agent-engine-key.js.map +1 -1
- package/dist/client/chat/run-recovery.js +1 -1
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +20 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +32 -7
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +7 -14
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +13 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +21 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/coding-tools/run-code.d.ts +7 -0
- package/dist/coding-tools/run-code.d.ts.map +1 -1
- package/dist/coding-tools/run-code.js +21 -106
- package/dist/coding-tools/run-code.js.map +1 -1
- package/dist/coding-tools/sandbox/adapter.d.ts +79 -0
- package/dist/coding-tools/sandbox/adapter.d.ts.map +1 -0
- package/dist/coding-tools/sandbox/adapter.js +24 -0
- package/dist/coding-tools/sandbox/adapter.js.map +1 -0
- package/dist/coding-tools/sandbox/index.d.ts +51 -0
- package/dist/coding-tools/sandbox/index.d.ts.map +1 -0
- package/dist/coding-tools/sandbox/index.js +79 -0
- package/dist/coding-tools/sandbox/index.js.map +1 -0
- package/dist/coding-tools/sandbox/local-child-process-adapter.d.ts +24 -0
- package/dist/coding-tools/sandbox/local-child-process-adapter.d.ts.map +1 -0
- package/dist/coding-tools/sandbox/local-child-process-adapter.js +141 -0
- package/dist/coding-tools/sandbox/local-child-process-adapter.js.map +1 -0
- package/dist/db/client.d.ts +4 -2
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +6 -4
- package/dist/db/client.js.map +1 -1
- package/dist/deploy/route-discovery.d.ts.map +1 -1
- package/dist/deploy/route-discovery.js +1 -0
- package/dist/deploy/route-discovery.js.map +1 -1
- package/dist/eval/agent-runner.d.ts +63 -0
- package/dist/eval/agent-runner.d.ts.map +1 -0
- package/dist/eval/agent-runner.js +142 -0
- package/dist/eval/agent-runner.js.map +1 -0
- package/dist/eval/define-eval.d.ts +29 -0
- package/dist/eval/define-eval.d.ts.map +1 -0
- package/dist/eval/define-eval.js +43 -0
- package/dist/eval/define-eval.js.map +1 -0
- package/dist/eval/index.d.ts +18 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +17 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/report.d.ts +8 -0
- package/dist/eval/report.d.ts.map +1 -0
- package/dist/eval/report.js +44 -0
- package/dist/eval/report.js.map +1 -0
- package/dist/eval/runner.d.ts +67 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +256 -0
- package/dist/eval/runner.js.map +1 -0
- package/dist/eval/scorer.d.ts +83 -0
- package/dist/eval/scorer.d.ts.map +1 -0
- package/dist/eval/scorer.js +195 -0
- package/dist/eval/scorer.js.map +1 -0
- package/dist/eval/types.d.ts +162 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +20 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +100 -1
- package/dist/observability/traces.js.map +1 -1
- package/dist/observability/tracing.d.ts +73 -0
- package/dist/observability/tracing.d.ts.map +1 -0
- package/dist/observability/tracing.js +126 -0
- package/dist/observability/tracing.js.map +1 -0
- package/dist/onboarding/default-steps.d.ts.map +1 -1
- package/dist/onboarding/default-steps.js +4 -1
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +10 -3
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +4 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +9 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +118 -110
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +37 -0
- package/dist/server/agent-engine-api-key-route.d.ts.map +1 -0
- package/dist/server/agent-engine-api-key-route.js +105 -0
- package/dist/server/agent-engine-api-key-route.js.map +1 -0
- package/dist/server/agent-teams.d.ts +62 -0
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +99 -2
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +17 -10
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/create-server.js +1 -1
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +2 -0
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +33 -1
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +17 -4
- package/dist/templates/workspace-core/.agents/skills/harness-agents/SKILL.md +20 -0
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/docs/content/agent-teams.md +32 -0
- package/docs/content/blueprint-installer.md +73 -0
- package/docs/content/evals.md +141 -0
- package/docs/content/pr-visual-recap.md +7 -4
- package/docs/content/sandbox-adapters.md +134 -0
- package/docs/content/template-plan.md +20 -8
- package/package.json +5 -1
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +17 -4
- package/src/templates/workspace-core/.agents/skills/harness-agents/SKILL.md +20 -0
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
* Named client helper for storing a bring-your-own provider key (Anthropic,
|
|
5
5
|
* OpenAI, etc.) so the agent chat can run without a Builder connection or an
|
|
6
6
|
* account. The key is persisted by the framework under the matching provider
|
|
7
|
-
*
|
|
7
|
+
* key (e.g. ANTHROPIC_API_KEY) for the current user or org, exactly like the
|
|
8
8
|
* LLM settings panel does — UI code should call this instead of hand-writing
|
|
9
|
-
* a fetch to
|
|
9
|
+
* a fetch to framework routes.
|
|
10
10
|
*/
|
|
11
11
|
/** Providers that can be configured with a single pasted API key. */
|
|
12
12
|
export type AgentEngineProvider = "anthropic" | "openai";
|
|
13
13
|
export interface SaveAgentEngineApiKeyOptions {
|
|
14
|
-
provider
|
|
14
|
+
provider?: AgentEngineProvider;
|
|
15
|
+
key?: string;
|
|
15
16
|
apiKey: string;
|
|
17
|
+
scope?: "user" | "org";
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Persist a provider API key for the current owner. Resolves on success.
|
|
@@ -20,5 +22,5 @@ export interface SaveAgentEngineApiKeyOptions {
|
|
|
20
22
|
* dispatches `agent-engine:configured-changed` so any open agent chat flips
|
|
21
23
|
* out of its "needs setup" state without a reload.
|
|
22
24
|
*/
|
|
23
|
-
export declare function saveAgentEngineApiKey({ provider, apiKey, }: SaveAgentEngineApiKeyOptions): Promise<void>;
|
|
25
|
+
export declare function saveAgentEngineApiKey({ provider, key, apiKey, scope, }: SaveAgentEngineApiKeyOptions): Promise<void>;
|
|
24
26
|
//# sourceMappingURL=agent-engine-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-engine-key.d.ts","sourceRoot":"","sources":["../../src/client/agent-engine-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAUzD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-engine-key.d.ts","sourceRoot":"","sources":["../../src/client/agent-engine-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAUzD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,QAAQ,EACR,GAAG,EACH,MAAM,EACN,KAAK,GACN,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC9C"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Named client helper for storing a bring-your-own provider key (Anthropic,
|
|
5
5
|
* OpenAI, etc.) so the agent chat can run without a Builder connection or an
|
|
6
6
|
* account. The key is persisted by the framework under the matching provider
|
|
7
|
-
*
|
|
7
|
+
* key (e.g. ANTHROPIC_API_KEY) for the current user or org, exactly like the
|
|
8
8
|
* LLM settings panel does — UI code should call this instead of hand-writing
|
|
9
|
-
* a fetch to
|
|
9
|
+
* a fetch to framework routes.
|
|
10
10
|
*/
|
|
11
11
|
import { agentNativePath } from "./api-path.js";
|
|
12
12
|
const PROVIDER_ENV_VAR = {
|
|
@@ -21,16 +21,19 @@ const CONFIGURED_CHANGED_EVENT = "agent-engine:configured-changed";
|
|
|
21
21
|
* dispatches `agent-engine:configured-changed` so any open agent chat flips
|
|
22
22
|
* out of its "needs setup" state without a reload.
|
|
23
23
|
*/
|
|
24
|
-
export async function saveAgentEngineApiKey({ provider, apiKey, }) {
|
|
24
|
+
export async function saveAgentEngineApiKey({ provider, key, apiKey, scope, }) {
|
|
25
25
|
const trimmed = apiKey.trim();
|
|
26
26
|
if (!trimmed) {
|
|
27
27
|
throw new Error("Enter an API key first.");
|
|
28
28
|
}
|
|
29
|
-
const envVar = PROVIDER_ENV_VAR[provider];
|
|
30
|
-
|
|
29
|
+
const envVar = key?.trim() || (provider ? PROVIDER_ENV_VAR[provider] : "");
|
|
30
|
+
if (!envVar) {
|
|
31
|
+
throw new Error("Choose an API key provider first.");
|
|
32
|
+
}
|
|
33
|
+
const res = await fetch(agentNativePath("/_agent-native/agent-engine/api-key"), {
|
|
31
34
|
method: "POST",
|
|
32
35
|
headers: { "Content-Type": "application/json" },
|
|
33
|
-
body: JSON.stringify({
|
|
36
|
+
body: JSON.stringify({ key: envVar, value: trimmed, scope }),
|
|
34
37
|
});
|
|
35
38
|
if (!res.ok) {
|
|
36
39
|
const message = await res
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-engine-key.js","sourceRoot":"","sources":["../../src/client/agent-engine-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKhD,MAAM,gBAAgB,GAAwC;IAC5D,SAAS,EAAE,mBAAmB;IAC9B,MAAM,EAAE,gBAAgB;CACzB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,wBAAwB,GAAG,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-engine-key.js","sourceRoot":"","sources":["../../src/client/agent-engine-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GAS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,MAAM,IAAI,KAAK,CACb,OAAO;YACL,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG;gBACjB,CAAC,CAAC,oDAAoD;gBACtD,CAAC,CAAC,gCAAgC,GAAG,CAAC,MAAM,IAAI,CAAC,CACtD,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["/**\n * Agent engine API-key helpers (browser).\n *\n * Named client helper for storing a bring-your-own provider key (Anthropic,\n * OpenAI, etc.) so the agent chat can run without a Builder connection or an\n * account. The key is persisted by the framework under the matching provider\n * key (e.g. ANTHROPIC_API_KEY) for the current user or org, exactly like the\n * LLM settings panel does — UI code should call this instead of hand-writing\n * a fetch to framework routes.\n */\n\nimport { agentNativePath } from \"./api-path.js\";\n\n/** Providers that can be configured with a single pasted API key. */\nexport type AgentEngineProvider = \"anthropic\" | \"openai\";\n\nconst PROVIDER_ENV_VAR: Record<AgentEngineProvider, string> = {\n anthropic: \"ANTHROPIC_API_KEY\",\n openai: \"OPENAI_API_KEY\",\n};\n\n/** Event other parts of the agent UI listen for to re-check the LLM gate. */\nconst CONFIGURED_CHANGED_EVENT = \"agent-engine:configured-changed\";\n\nexport interface SaveAgentEngineApiKeyOptions {\n provider?: AgentEngineProvider;\n key?: string;\n apiKey: string;\n scope?: \"user\" | \"org\";\n}\n\n/**\n * Persist a provider API key for the current owner. Resolves on success.\n * Throws an Error with a readable message on failure. On success it also\n * dispatches `agent-engine:configured-changed` so any open agent chat flips\n * out of its \"needs setup\" state without a reload.\n */\nexport async function saveAgentEngineApiKey({\n provider,\n key,\n apiKey,\n scope,\n}: SaveAgentEngineApiKeyOptions): Promise<void> {\n const trimmed = apiKey.trim();\n if (!trimmed) {\n throw new Error(\"Enter an API key first.\");\n }\n const envVar = key?.trim() || (provider ? PROVIDER_ENV_VAR[provider] : \"\");\n if (!envVar) {\n throw new Error(\"Choose an API key provider first.\");\n }\n const res = await fetch(\n agentNativePath(\"/_agent-native/agent-engine/api-key\"),\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ key: envVar, value: trimmed, scope }),\n },\n );\n if (!res.ok) {\n const message = await res\n .json()\n .then((body: { error?: string }) => body?.error)\n .catch(() => null);\n throw new Error(\n message ??\n (res.status === 401\n ? \"Sign in to save a key, or connect Builder instead.\"\n : `Could not save the key (HTTP ${res.status}).`),\n );\n }\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new CustomEvent(CONFIGURED_CHANGED_EVENT));\n }\n}\n"]}
|
|
@@ -141,7 +141,7 @@ export function ApiKeyConnect({ onConnected }) {
|
|
|
141
141
|
setSaving(false);
|
|
142
142
|
}
|
|
143
143
|
}, [apiKey, onConnected, provider, saving]);
|
|
144
|
-
return (_jsxs("div", { className: "rounded-md border border-border bg-background/60 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center gap-1.5 text-[11px] font-medium text-foreground", children: [_jsx(IconKey, { size: 12, strokeWidth: 1.9 }), "Use your own API key"] }), _jsx("p", { className: "mb-2.5 text-[11px] leading-relaxed text-muted-foreground", children: "Stored
|
|
144
|
+
return (_jsxs("div", { className: "rounded-md border border-border bg-background/60 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center gap-1.5 text-[11px] font-medium text-foreground", children: [_jsx(IconKey, { size: 12, strokeWidth: 1.9 }), "Use your own API key"] }), _jsx("p", { className: "mb-2.5 text-[11px] leading-relaxed text-muted-foreground", children: "Stored securely for this app only." }), _jsx("div", { role: "tablist", "aria-label": "API key provider", className: "mb-2 inline-flex rounded-md border border-border bg-muted/40 p-0.5", children: API_KEY_PROVIDERS.map((option) => {
|
|
145
145
|
const selected = option.value === provider;
|
|
146
146
|
return (_jsx("button", { type: "button", role: "tab", "aria-selected": selected, onClick: () => {
|
|
147
147
|
setProvider(option.value);
|
|
@@ -1 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OAAO,CACL,cAAK,SAAS,EAAC,oBAAoB,YACjC,cAAK,SAAS,EAAC,+EAA+E,YAC5F,eAAK,SAAS,EAAC,2BAA2B,aACxC,eAAM,SAAS,EAAC,8GAA8G,YAC5H,KAAC,iBAAiB,IAAC,IAAI,EAAE,EAAE,GAAI,GAC1B,EACP,eAAK,SAAS,EAAC,gBAAgB,aAC7B,YAAG,SAAS,EAAC,qCAAqC,YAC/C,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,GAClD,EACJ,YAAG,SAAS,EAAC,sDAAsD,YAChE,gBAAgB;oCACf,CAAC,CAAC,0CAA0C;oCAC5C,CAAC,CAAC,4DAA4D,GAC9D,IACA,EACL,gBAAgB,CAAC,CAAC,CAAC,CAClB,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,kIAAkI,aAE5I,KAAC,cAAc,IAAC,IAAI,EAAE,EAAE,GAAI,sBAErB,CACV,CAAC,CAAC,CAAC,CACF,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,aAAa,EACtB,SAAS,EAAC,sJAAsJ,oBAGhK,KAAC,cAAc,IAAC,IAAI,EAAE,EAAE,GAAI,IACrB,CACV,IACG,GACF,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Owns: run-error metadata extractors, recovery helpers, RunErrorRecoveryCard,\n// LoopLimitContinueCard, BuilderConnectCta, BuilderSetupCard, ApiKeyConnect,\n// PlanModeCallout, and getLoopLimitMetadata / getRunErrorMetadata exports used\n// by AssistantChatInner.\n\nimport { useState, useEffect, useCallback, useRef } from \"react\";\nimport { useBuilderConnectFlow } from \"../settings/useBuilderStatus.js\";\nimport {\n saveAgentEngineApiKey,\n type AgentEngineProvider,\n} from \"../agent-engine-key.js\";\nimport { cn } from \"../utils.js\";\nimport { writeClipboardText } from \"../clipboard.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport {\n IconLoader2,\n IconCheck,\n IconCopy,\n IconX,\n IconChevronDown,\n IconExternalLink,\n IconKey,\n IconGitFork,\n IconMessage,\n IconGauge,\n IconSettings,\n IconArrowRight,\n IconAlertTriangle,\n IconPlayerPlay,\n IconRefresh,\n IconPlus,\n IconClipboardList,\n} from \"@tabler/icons-react\";\n\n// ─── Type definitions ─────────────────────────────────────────────────────────\n\nexport type LoopLimitInfo = { maxIterations?: number };\n\nexport type RunErrorInfo = {\n message: string;\n details?: string;\n errorCode?: string;\n runId?: string;\n recoverable?: boolean;\n};\n\ninterface AgentLoopSettingsResponse {\n maxIterations: number;\n defaultMaxIterations: number;\n minMaxIterations: number;\n maxMaxIterations: number;\n scope: \"org\" | \"user\" | \"default\";\n source: \"org\" | \"user\" | \"env\" | \"default\";\n canUpdate: boolean;\n orgName?: string | null;\n role?: string | null;\n}\n\n// ─── Metadata extractors ──────────────────────────────────────────────────────\n\nexport function getLoopLimitMetadata(message: unknown): LoopLimitInfo | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { loopLimit?: LoopLimitInfo };\n loopLimit?: LoopLimitInfo;\n }\n | undefined;\n const loopLimit = meta?.custom?.loopLimit ?? meta?.loopLimit;\n if (!loopLimit || typeof loopLimit !== \"object\") return null;\n return {\n ...(typeof loopLimit.maxIterations === \"number\"\n ? { maxIterations: loopLimit.maxIterations }\n : {}),\n };\n}\n\nexport function getRunErrorMetadata(message: unknown): RunErrorInfo | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { runError?: RunErrorInfo; runId?: unknown };\n runError?: RunErrorInfo;\n runId?: unknown;\n }\n | undefined;\n const runError = meta?.custom?.runError ?? meta?.runError;\n if (!runError || typeof runError !== \"object\") return null;\n const messageText =\n typeof runError.message === \"string\" ? runError.message : \"\";\n if (!messageText) return null;\n const runId =\n typeof runError.runId === \"string\"\n ? runError.runId\n : typeof meta?.custom?.runId === \"string\"\n ? meta.custom.runId\n : typeof meta?.runId === \"string\"\n ? meta.runId\n : undefined;\n return {\n message: messageText,\n ...(typeof runError.details === \"string\"\n ? { details: runError.details }\n : {}),\n ...(typeof runError.errorCode === \"string\"\n ? { errorCode: runError.errorCode }\n : {}),\n ...(runId ? { runId } : {}),\n ...(runError.recoverable ? { recoverable: true } : {}),\n };\n}\n\nexport function getRequestModeMetadata(\n message: unknown,\n): \"act\" | \"plan\" | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { requestMode?: unknown };\n requestMode?: unknown;\n }\n | undefined;\n const requestMode = meta?.custom?.requestMode ?? meta?.requestMode;\n return requestMode === \"act\" || requestMode === \"plan\" ? requestMode : null;\n}\n\n// ─── Run error classifiers ────────────────────────────────────────────────────\n\nfunction isBuilderReconnectRunError(info: RunErrorInfo): boolean {\n const code = (info.errorCode ?? \"\").toLowerCase();\n const message = info.message.toLowerCase();\n const isAuthCode =\n code === \"authentication_error\" ||\n code === \"unauthorized\" ||\n code === \"http_401\" ||\n code === \"http_403\";\n return (\n code === \"builder_auth_error\" ||\n message.includes(\"builder authentication failed\") ||\n (isAuthCode &&\n (message.includes(\"invalid token\") ||\n message.includes(\"personal access token\")))\n );\n}\n\nfunction isProviderQueryRunError(info: RunErrorInfo): boolean {\n const text = [info.errorCode, info.message, info.details]\n .filter(Boolean)\n .join(\"\\n\")\n .toLowerCase();\n return (\n text.includes(\"bigquery\") ||\n text.includes(\"sql\") ||\n text.includes(\"query\") ||\n text.includes(\"schema\") ||\n text.includes(\"syntax\") ||\n text.includes(\"unknown column\") ||\n text.includes(\"unknown table\") ||\n text.includes(\"type mismatch\")\n );\n}\n\nfunction isConnectionRecoveryRunError(info: RunErrorInfo): boolean {\n const code = (info.errorCode ?? \"\").toLowerCase();\n const message = info.message.toLowerCase();\n return (\n code === \"connection_error\" ||\n message.includes(\"connection kept failing\") ||\n message.includes(\"automatic recovery attempts\")\n );\n}\n\n// ─── BuilderConnectCta ────────────────────────────────────────────────────────\n// Renders a single row with left-aligned copy and a right-aligned action.\n// Click opens the Builder CLI-auth popup via the shared\n// `useBuilderConnectFlow` hook (which owns the synchronous window.open,\n// the 2s status poll, and the focus-refresh). On success the hook broadcasts\n// a config-change event so the chat clears its local `missingApiKey` gate.\n//\n// Desktop note: when this component runs inside the Electron shell, the\n// window.open call is intercepted by the main process's webview popup handler,\n// which opens the flow in an Electron BrowserWindow that shares the webview's\n// session. See packages/desktop-app/src/main/index.ts.\n\nexport function BuilderConnectCta({\n variant = \"primary\",\n onConnected,\n}: {\n variant?: \"primary\" | \"compact\";\n onConnected?: () => void;\n}) {\n const { configured, orgName, connecting, error, start } =\n useBuilderConnectFlow({\n trackingSource: \"assistant_chat_builder_cta\",\n onConnected,\n });\n\n const containerClass =\n variant === \"compact\"\n ? \"rounded-md border border-border px-3 py-2.5\"\n : \"flex items-center gap-3 rounded-md border border-border px-3 py-3\";\n\n if (configured) {\n return (\n <div className={containerClass}>\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-xs font-medium text-foreground\">Builder.io</div>\n <p className=\"text-[11px] text-muted-foreground mt-0.5\">\n {orgName ? `Connected — ${orgName}` : \"Connected\"}\n </p>\n </div>\n <span className=\"ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500\">\n <IconCheck size={10} />\n Connected\n </span>\n </div>\n );\n }\n\n return (\n <div className={containerClass}>\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-xs font-medium text-foreground\">\n Connect Builder.io\n </div>\n <p className=\"text-[11px] text-muted-foreground mt-0.5 max-w-[220px]\">\n Free credits for LLM, hosting, and more — no API key needed\n </p>\n {error && <p className=\"mt-1 text-[10px] text-destructive\">{error}</p>}\n </div>\n <button\n type=\"button\"\n onClick={() => start()}\n disabled={connecting}\n className=\"ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-foreground px-3 py-1.5 text-[11px] font-medium no-underline text-background hover:opacity-90 disabled:opacity-60 disabled:cursor-wait\"\n aria-busy={connecting}\n >\n {connecting ? (\n <>\n <IconLoader2 size={10} className=\"animate-spin\" />\n Waiting…\n </>\n ) : (\n <>\n Connect\n <IconExternalLink size={10} />\n </>\n )}\n </button>\n </div>\n );\n}\n\n// ─── ApiKeyConnect ────────────────────────────────────────────────────────────\n\nconst API_KEY_PROVIDERS: Array<{\n value: AgentEngineProvider;\n label: string;\n placeholder: string;\n}> = [\n { value: \"anthropic\", label: \"Anthropic\", placeholder: \"sk-ant-…\" },\n { value: \"openai\", label: \"OpenAI\", placeholder: \"sk-…\" },\n];\n\nexport function ApiKeyConnect({ onConnected }: { onConnected?: () => void }) {\n const [provider, setProvider] = useState<AgentEngineProvider>(\"anthropic\");\n const [apiKey, setApiKey] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const active = API_KEY_PROVIDERS.find((p) => p.value === provider)!;\n\n const handleSave = useCallback(async () => {\n if (!apiKey.trim() || saving) return;\n setSaving(true);\n setError(null);\n try {\n await saveAgentEngineApiKey({ provider, apiKey });\n setApiKey(\"\");\n onConnected?.();\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Could not save the key.\");\n } finally {\n setSaving(false);\n }\n }, [apiKey, onConnected, provider, saving]);\n\n return (\n <div className=\"rounded-md border border-border bg-background/60 p-3\">\n <div className=\"mb-2 flex items-center gap-1.5 text-[11px] font-medium text-foreground\">\n <IconKey size={12} strokeWidth={1.9} />\n Use your own API key\n </div>\n <p className=\"mb-2.5 text-[11px] leading-relaxed text-muted-foreground\">\n Stored locally for this app only — no account required.\n </p>\n <div\n role=\"tablist\"\n aria-label=\"API key provider\"\n className=\"mb-2 inline-flex rounded-md border border-border bg-muted/40 p-0.5\"\n >\n {API_KEY_PROVIDERS.map((option) => {\n const selected = option.value === provider;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"tab\"\n aria-selected={selected}\n onClick={() => {\n setProvider(option.value);\n setError(null);\n }}\n className={cn(\n \"rounded px-2.5 py-1 text-[11px] font-medium transition-colors\",\n selected\n ? \"bg-background text-foreground shadow-sm\"\n : \"text-muted-foreground hover:text-foreground\",\n )}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n <div className=\"flex items-center gap-2\">\n <input\n type=\"password\"\n value={apiKey}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={active.placeholder}\n onChange={(e) => {\n setApiKey(e.target.value);\n if (error) setError(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n void handleSave();\n }\n }}\n className=\"h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 focus:ring-offset-background\"\n />\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={!apiKey.trim() || saving}\n className=\"inline-flex h-8 shrink-0 items-center gap-1 rounded-md bg-foreground px-3 text-[11px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60\"\n >\n {saving ? (\n <>\n <IconLoader2 size={11} className=\"animate-spin\" />\n Saving…\n </>\n ) : (\n \"Save\"\n )}\n </button>\n </div>\n {error ? (\n <p className=\"mt-2 text-[11px] text-destructive\">{error}</p>\n ) : null}\n </div>\n );\n}\n\n// ─── BuilderSetupCard ─────────────────────────────────────────────────────────\n\nexport function BuilderSetupCard({\n onConnected,\n bouncePulse,\n}: {\n onConnected?: () => void;\n bouncePulse?: number;\n}) {\n // Progressive disclosure: the card leads with the one-click Builder connect.\n // The bring-your-own-key path stays tucked behind a single link so the chat\n // stays clean for people who connect Builder or never use the side chat at\n // all (they can keep driving the plan from their own coding agent).\n const [keyOpen, setKeyOpen] = useState(false);\n\n const cardRef = useRef<HTMLDivElement>(null);\n // Replay the bounce keyframe each time bouncePulse increments. Toggling the\n // class off-then-on (with a forced reflow) restarts the animation even when\n // the value changes back-to-back.\n useEffect(() => {\n if (!bouncePulse) return;\n const el = cardRef.current;\n if (!el) return;\n el.classList.remove(\"animate-bounce-once\");\n void el.offsetWidth;\n el.classList.add(\"animate-bounce-once\");\n }, [bouncePulse]);\n\n return (\n <div\n ref={cardRef}\n className=\"mx-4 my-6 rounded-lg border border-border bg-card p-5\"\n >\n <div className=\"flex items-center gap-3 mb-3\">\n <div className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted\">\n <IconMessage className=\"h-4.5 w-4.5 text-muted-foreground\" />\n </div>\n <div>\n <h3 className=\"text-sm font-medium text-foreground\">\n Turn on the side chat\n </h3>\n <p className=\"mt-0.5 text-[11px] text-muted-foreground\">\n One click to connect Builder for free hosted access — no API key or\n account needed.\n </p>\n </div>\n </div>\n\n <div className=\"space-y-3\">\n <BuilderConnectCta onConnected={onConnected} />\n\n {keyOpen ? (\n <ApiKeyConnect onConnected={onConnected} />\n ) : (\n <div className=\"text-center\">\n <button\n type=\"button\"\n onClick={() => setKeyOpen(true)}\n className=\"text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline\"\n >\n Or paste your own Anthropic or OpenAI key\n </button>\n </div>\n )}\n\n <p className=\"text-center text-[11px] leading-relaxed text-muted-foreground\">\n You can skip this and keep editing the plan with your own coding\n agent.\n </p>\n </div>\n </div>\n );\n}\n\n// ─── RunErrorRecoveryCard ─────────────────────────────────────────────────────\n\nexport function RunErrorRecoveryCard({\n info,\n onContinue,\n onRetry,\n onFork,\n onDismiss,\n}: {\n info: RunErrorInfo;\n onContinue: () => void;\n onRetry: () => void;\n onFork?: () => void | boolean | Promise<void | boolean>;\n onDismiss: () => void;\n}) {\n const [detailsOpen, setDetailsOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [forking, setForking] = useState(false);\n const [forkError, setForkError] = useState<string | null>(null);\n const builderReconnect = useBuilderConnectFlow({\n trackingSource: \"assistant_chat_reconnect_error\",\n });\n const canRecover = info.recoverable === true;\n const shouldShowBuilderReconnect = isBuilderReconnectRunError(info);\n const builderReconnectResolved =\n shouldShowBuilderReconnect &&\n builderReconnect.hasFetchedStatus &&\n builderReconnect.configured;\n const isQueryError = isProviderQueryRunError(info);\n const isConnectionRecoveryError = isConnectionRecoveryRunError(info);\n const copyLabel =\n info.runId || info.errorCode || info.details ? \"Copy debug\" : \"Copy\";\n const copyDetails = useCallback(() => {\n const text = [\n info.message,\n info.errorCode ? `Code: ${info.errorCode}` : \"\",\n info.runId ? `Run: ${info.runId}` : \"\",\n info.details ? `Details:\\n${info.details}` : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\\n\");\n void writeClipboardText(text).then((ok) => {\n if (!ok) return;\n setCopied(true);\n setTimeout(() => setCopied(false), 1200);\n });\n }, [info]);\n const startNewChat = useCallback(() => {\n window.dispatchEvent(new CustomEvent(\"agent-chat:new-chat\"));\n onDismiss();\n }, [onDismiss]);\n\n const handleFork = useCallback(async () => {\n if (!onFork || forking) return;\n setForking(true);\n setForkError(null);\n try {\n const result = await onFork();\n if (result === false) {\n setForkError(\"Could not fork this chat. Try starting a new chat.\");\n }\n } catch {\n setForkError(\"Could not fork this chat. Try starting a new chat.\");\n } finally {\n setForking(false);\n }\n }, [forking, onFork]);\n\n useEffect(() => {\n if (builderReconnectResolved) {\n onDismiss();\n }\n }, [builderReconnectResolved, onDismiss]);\n\n return (\n <div className=\"rounded-lg border border-amber-500/25 bg-amber-500/[0.06] p-3 text-sm\">\n <div className=\"flex items-start gap-2\">\n <span className=\"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-amber-500/10 text-amber-700 dark:text-amber-300\">\n <IconAlertTriangle size={14} />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"font-medium text-foreground\">\n {canRecover\n ? \"The agent stopped before finishing\"\n : \"The agent hit an error\"}\n </div>\n <p className=\"mt-1 text-xs leading-relaxed text-muted-foreground\">\n {info.message}\n </p>\n {shouldShowBuilderReconnect && !builderReconnectResolved && (\n <p className=\"mt-2 text-xs leading-relaxed text-muted-foreground\">\n The current Builder.io or model-provider credential was rejected.\n Reconnect Builder.io, then retry this message.\n </p>\n )}\n {isConnectionRecoveryError && (\n <p className=\"mt-2 text-xs leading-relaxed text-muted-foreground\">\n If retry lands on the same error, start a new chat session and\n continue from what already changed.\n </p>\n )}\n {(info.runId || info.errorCode || info.details) && (\n <button\n type=\"button\"\n onClick={() => setDetailsOpen((v) => !v)}\n className=\"mt-2 inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground hover:text-foreground\"\n >\n <IconChevronDown\n size={12}\n className={cn(\n \"transition-transform\",\n detailsOpen && \"rotate-180\",\n )}\n />\n Details\n </button>\n )}\n {detailsOpen && (\n <div className=\"mt-2 rounded-md border border-border/60 bg-background/70 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground\">\n {info.runId && <div>run: {info.runId}</div>}\n {info.errorCode && <div>code: {info.errorCode}</div>}\n {info.details && (\n <pre className=\"mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words font-mono\">\n {info.details}\n </pre>\n )}\n </div>\n )}\n </div>\n <button\n type=\"button\"\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/80 hover:text-foreground\"\n >\n <IconX size={14} />\n </button>\n </div>\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n {shouldShowBuilderReconnect && !builderReconnectResolved && (\n <button\n type=\"button\"\n onClick={() => builderReconnect.start()}\n disabled={builderReconnect.connecting}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90 disabled:cursor-wait disabled:opacity-70\"\n >\n {builderReconnect.connecting ? (\n <IconLoader2 size={13} className=\"animate-spin\" />\n ) : (\n <IconExternalLink size={13} />\n )}\n {builderReconnect.connecting\n ? \"Connecting Builder.io\"\n : \"Reconnect Builder.io\"}\n </button>\n )}\n {canRecover && (\n <>\n <button\n type=\"button\"\n onClick={onContinue}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90\"\n >\n <IconPlayerPlay size={13} />\n Continue\n </button>\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n <IconRefresh size={13} />\n {isQueryError ? \"Diagnose and retry\" : \"Retry\"}\n </button>\n </>\n )}\n {canRecover && isConnectionRecoveryError && (\n <button\n type=\"button\"\n onClick={startNewChat}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n <IconPlus size={13} />\n New chat\n </button>\n )}\n {canRecover && onFork && !isConnectionRecoveryError && (\n <button\n type=\"button\"\n onClick={handleFork}\n disabled={forking}\n title=\"Fork this conversation into a separate chat thread.\"\n aria-label=\"Fork this conversation into a separate chat thread\"\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent disabled:cursor-wait disabled:opacity-70\"\n >\n {forking ? (\n <IconLoader2 size={13} className=\"animate-spin\" />\n ) : (\n <IconGitFork size={13} />\n )}\n {forking ? \"Forking...\" : \"Fork chat\"}\n </button>\n )}\n <button\n type=\"button\"\n onClick={copyDetails}\n className=\"ml-auto inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium text-muted-foreground hover:bg-background/80 hover:text-foreground\"\n >\n {copied ? <IconCheck size={13} /> : <IconCopy size={13} />}\n {copied ? \"Copied\" : copyLabel}\n </button>\n </div>\n {shouldShowBuilderReconnect && builderReconnect.error && (\n <p className=\"mt-2 text-xs leading-relaxed text-red-500\">\n {builderReconnect.error}\n </p>\n )}\n {forkError && (\n <p className=\"mt-2 text-xs leading-relaxed text-red-500\">{forkError}</p>\n )}\n </div>\n );\n}\n\n// ─── LoopLimitContinueCard ────────────────────────────────────────────────────\n\nexport function LoopLimitContinueCard({\n info,\n onContinue,\n}: {\n info: LoopLimitInfo;\n onContinue: () => void;\n}) {\n const [settings, setSettings] = useState<AgentLoopSettingsResponse | null>(\n null,\n );\n const [value, setValue] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [saved, setSaved] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const load = useCallback(() => {\n let cancelled = false;\n fetch(agentNativePath(\"/_agent-native/agent-loop-settings\"))\n .then((r) => (r.ok ? r.json() : null))\n .then((data: AgentLoopSettingsResponse | null) => {\n if (cancelled || !data) return;\n setSettings(data);\n setValue(String(data.maxIterations));\n })\n .catch(() => {\n if (!cancelled) setValue(String(info.maxIterations ?? \"\"));\n });\n return () => {\n cancelled = true;\n };\n }, [info.maxIterations]);\n\n useEffect(() => load(), [load]);\n\n const currentLimit = settings?.maxIterations ?? info.maxIterations;\n const numericValue = Number(value);\n const hasPendingChange =\n !!settings &&\n settings.canUpdate &&\n Number.isInteger(numericValue) &&\n numericValue !== settings.maxIterations;\n const scopeLabel =\n settings?.scope === \"org\"\n ? settings.orgName\n ? `${settings.orgName} org`\n : \"org\"\n : \"your account\";\n\n const saveLimit = useCallback(async (): Promise<boolean> => {\n if (!settings?.canUpdate) return false;\n setSaving(true);\n setSaved(false);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(\"/_agent-native/agent-loop-settings\"),\n {\n method: \"PUT\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ maxIterations: numericValue }),\n },\n );\n const body = await res.json().catch(() => ({}));\n if (!res.ok) {\n throw new Error(body?.error ?? `Save failed (${res.status})`);\n }\n setSettings(body as AgentLoopSettingsResponse);\n setValue(String((body as AgentLoopSettingsResponse).maxIterations));\n setSaved(true);\n window.dispatchEvent(\n new CustomEvent(\"agent-loop-settings:changed\", { detail: body }),\n );\n setTimeout(() => setSaved(false), 2000);\n return true;\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Save failed\");\n return false;\n } finally {\n setSaving(false);\n }\n }, [numericValue, settings?.canUpdate]);\n\n const handleContinue = useCallback(async () => {\n if (hasPendingChange) {\n const ok = await saveLimit();\n if (!ok) return;\n }\n onContinue();\n }, [hasPendingChange, onContinue, saveLimit]);\n\n const openSettings = useCallback(() => {\n try {\n window.location.hash = \"agent-limits\";\n } catch {}\n window.dispatchEvent(new CustomEvent(\"agent-panel:open-settings\"));\n }, []);\n\n return (\n <div className=\"rounded-lg border border-amber-500/25 bg-amber-500/[0.06] px-3 py-3 shadow-sm\">\n <div className=\"flex items-start gap-2.5\">\n <span className=\"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400\">\n <IconGauge size={14} />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-foreground\">\n Step limit reached\n </p>\n <p className=\"mt-0.5 text-xs leading-relaxed text-muted-foreground\">\n The agent used{\" \"}\n {currentLimit\n ? `${currentLimit.toLocaleString()} steps`\n : \"all available steps\"}\n . Keep going in a fresh turn, or raise the {scopeLabel} limit first.\n </p>\n </div>\n </div>\n\n <div className=\"mt-3 flex flex-wrap items-end gap-2\">\n <label className=\"min-w-[116px] flex-1 space-y-1\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n Max steps\n </span>\n <input\n type=\"number\"\n min={settings?.minMaxIterations ?? 1}\n max={settings?.maxMaxIterations ?? 1000}\n value={value}\n disabled={!settings?.canUpdate || saving}\n onChange={(e) => {\n setValue(e.target.value);\n setError(null);\n }}\n className=\"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring disabled:opacity-60\"\n />\n </label>\n <button\n type=\"button\"\n onClick={saveLimit}\n disabled={!hasPendingChange || saving}\n className=\"inline-flex h-8 items-center gap-1 rounded-md border border-border px-2.5 text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50\"\n >\n {saving ? (\n <IconLoader2 size={12} className=\"animate-spin\" />\n ) : saved ? (\n <IconCheck size={12} />\n ) : (\n \"Save\"\n )}\n </button>\n <button\n type=\"button\"\n onClick={openSettings}\n className=\"inline-flex h-8 items-center gap-1 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground\"\n >\n <IconSettings size={12} />\n Settings\n </button>\n <button\n type=\"button\"\n onClick={handleContinue}\n disabled={saving}\n className=\"ml-auto inline-flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90 disabled:opacity-60\"\n >\n {hasPendingChange ? \"Save and keep going\" : \"Keep going\"}\n <IconArrowRight size={12} />\n </button>\n </div>\n\n {settings && !settings.canUpdate && (\n <p className=\"mt-2 text-[11px] text-muted-foreground\">\n Only organization owners and admins can change this limit.\n </p>\n )}\n {error && <p className=\"mt-2 text-[11px] text-destructive\">{error}</p>}\n </div>\n );\n}\n\n// ─── PlanModeCallout ──────────────────────────────────────────────────────────\n\nexport function PlanModeCallout({\n canImplementPlan,\n onImplementPlan,\n onSwitchToAct,\n}: {\n canImplementPlan: boolean;\n onImplementPlan: () => void;\n onSwitchToAct: () => void;\n}) {\n return (\n <div className=\"shrink-0 px-3 pt-2\">\n <div className=\"rounded-lg border border-blue-500/25 bg-blue-500/[0.06] px-3 py-2.5 shadow-sm\">\n <div className=\"flex items-center gap-2.5\">\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-blue-500/10 text-blue-600 dark:text-blue-300\">\n <IconClipboardList size={15} />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium text-foreground\">\n {canImplementPlan ? \"Plan ready\" : \"Plan mode is on\"}\n </p>\n <p className=\"mt-0.5 text-xs leading-relaxed text-muted-foreground\">\n {canImplementPlan\n ? \"Switch to Act and run the proposed plan.\"\n : \"The next turn will stay read-only until you switch to Act.\"}\n </p>\n </div>\n {canImplementPlan ? (\n <button\n type=\"button\"\n onClick={onImplementPlan}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90\"\n >\n <IconPlayerPlay size={13} />\n Implement Plan\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={onSwitchToAct}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n Act\n <IconArrowRight size={13} />\n </button>\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"run-recovery.js","sourceRoot":"","sources":["../../../src/client/chat/run-recovery.tsx"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,yBAAyB;AAEzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACL,qBAAqB,GAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,SAAS,EACT,QAAQ,EACR,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AA0B7B,iFAAiF;AAEjF,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,IAAI,GAAI,OAAkC,EAAE,QAKrC,CAAC;IACd,MAAM,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,SAAS,IAAI,IAAI,EAAE,SAAS,CAAC;IAC7D,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO;QACL,GAAG,CAAC,OAAO,SAAS,CAAC,aAAa,K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AAG,SAAS,EAAC,mCAAmC,YAAE,KAAK,GAAK,IAClE,CACP,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF,MAAM,UAAU,eAAe,CAAC,EAC9B,gBAAgB,EAChB,eAAe,EACf,aAAa,GAKd;IACC,OAAO,CACL,cAAK,SAAS,EAAC,oBAAoB,YACjC,cAAK,SAAS,EAAC,+EAA+E,YAC5F,eAAK,SAAS,EAAC,2BAA2B,aACxC,eAAM,SAAS,EAAC,8GAA8G,YAC5H,KAAC,iBAAiB,IAAC,IAAI,EAAE,EAAE,GAAI,GAC1B,EACP,eAAK,SAAS,EAAC,gBAAgB,aAC7B,YAAG,SAAS,EAAC,qCAAqC,YAC/C,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,GAClD,EACJ,YAAG,SAAS,EAAC,sDAAsD,YAChE,gBAAgB;oCACf,CAAC,CAAC,0CAA0C;oCAC5C,CAAC,CAAC,4DAA4D,GAC9D,IACA,EACL,gBAAgB,CAAC,CAAC,CAAC,CAClB,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,kIAAkI,aAE5I,KAAC,cAAc,IAAC,IAAI,EAAE,EAAE,GAAI,sBAErB,CACV,CAAC,CAAC,CAAC,CACF,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,aAAa,EACtB,SAAS,EAAC,sJAAsJ,oBAGhK,KAAC,cAAc,IAAC,IAAI,EAAE,EAAE,GAAI,IACrB,CACV,IACG,GACF,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Owns: run-error metadata extractors, recovery helpers, RunErrorRecoveryCard,\n// LoopLimitContinueCard, BuilderConnectCta, BuilderSetupCard, ApiKeyConnect,\n// PlanModeCallout, and getLoopLimitMetadata / getRunErrorMetadata exports used\n// by AssistantChatInner.\n\nimport { useState, useEffect, useCallback, useRef } from \"react\";\nimport { useBuilderConnectFlow } from \"../settings/useBuilderStatus.js\";\nimport {\n saveAgentEngineApiKey,\n type AgentEngineProvider,\n} from \"../agent-engine-key.js\";\nimport { cn } from \"../utils.js\";\nimport { writeClipboardText } from \"../clipboard.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport {\n IconLoader2,\n IconCheck,\n IconCopy,\n IconX,\n IconChevronDown,\n IconExternalLink,\n IconKey,\n IconGitFork,\n IconMessage,\n IconGauge,\n IconSettings,\n IconArrowRight,\n IconAlertTriangle,\n IconPlayerPlay,\n IconRefresh,\n IconPlus,\n IconClipboardList,\n} from \"@tabler/icons-react\";\n\n// ─── Type definitions ─────────────────────────────────────────────────────────\n\nexport type LoopLimitInfo = { maxIterations?: number };\n\nexport type RunErrorInfo = {\n message: string;\n details?: string;\n errorCode?: string;\n runId?: string;\n recoverable?: boolean;\n};\n\ninterface AgentLoopSettingsResponse {\n maxIterations: number;\n defaultMaxIterations: number;\n minMaxIterations: number;\n maxMaxIterations: number;\n scope: \"org\" | \"user\" | \"default\";\n source: \"org\" | \"user\" | \"env\" | \"default\";\n canUpdate: boolean;\n orgName?: string | null;\n role?: string | null;\n}\n\n// ─── Metadata extractors ──────────────────────────────────────────────────────\n\nexport function getLoopLimitMetadata(message: unknown): LoopLimitInfo | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { loopLimit?: LoopLimitInfo };\n loopLimit?: LoopLimitInfo;\n }\n | undefined;\n const loopLimit = meta?.custom?.loopLimit ?? meta?.loopLimit;\n if (!loopLimit || typeof loopLimit !== \"object\") return null;\n return {\n ...(typeof loopLimit.maxIterations === \"number\"\n ? { maxIterations: loopLimit.maxIterations }\n : {}),\n };\n}\n\nexport function getRunErrorMetadata(message: unknown): RunErrorInfo | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { runError?: RunErrorInfo; runId?: unknown };\n runError?: RunErrorInfo;\n runId?: unknown;\n }\n | undefined;\n const runError = meta?.custom?.runError ?? meta?.runError;\n if (!runError || typeof runError !== \"object\") return null;\n const messageText =\n typeof runError.message === \"string\" ? runError.message : \"\";\n if (!messageText) return null;\n const runId =\n typeof runError.runId === \"string\"\n ? runError.runId\n : typeof meta?.custom?.runId === \"string\"\n ? meta.custom.runId\n : typeof meta?.runId === \"string\"\n ? meta.runId\n : undefined;\n return {\n message: messageText,\n ...(typeof runError.details === \"string\"\n ? { details: runError.details }\n : {}),\n ...(typeof runError.errorCode === \"string\"\n ? { errorCode: runError.errorCode }\n : {}),\n ...(runId ? { runId } : {}),\n ...(runError.recoverable ? { recoverable: true } : {}),\n };\n}\n\nexport function getRequestModeMetadata(\n message: unknown,\n): \"act\" | \"plan\" | null {\n const meta = (message as { metadata?: unknown })?.metadata as\n | {\n custom?: { requestMode?: unknown };\n requestMode?: unknown;\n }\n | undefined;\n const requestMode = meta?.custom?.requestMode ?? meta?.requestMode;\n return requestMode === \"act\" || requestMode === \"plan\" ? requestMode : null;\n}\n\n// ─── Run error classifiers ────────────────────────────────────────────────────\n\nfunction isBuilderReconnectRunError(info: RunErrorInfo): boolean {\n const code = (info.errorCode ?? \"\").toLowerCase();\n const message = info.message.toLowerCase();\n const isAuthCode =\n code === \"authentication_error\" ||\n code === \"unauthorized\" ||\n code === \"http_401\" ||\n code === \"http_403\";\n return (\n code === \"builder_auth_error\" ||\n message.includes(\"builder authentication failed\") ||\n (isAuthCode &&\n (message.includes(\"invalid token\") ||\n message.includes(\"personal access token\")))\n );\n}\n\nfunction isProviderQueryRunError(info: RunErrorInfo): boolean {\n const text = [info.errorCode, info.message, info.details]\n .filter(Boolean)\n .join(\"\\n\")\n .toLowerCase();\n return (\n text.includes(\"bigquery\") ||\n text.includes(\"sql\") ||\n text.includes(\"query\") ||\n text.includes(\"schema\") ||\n text.includes(\"syntax\") ||\n text.includes(\"unknown column\") ||\n text.includes(\"unknown table\") ||\n text.includes(\"type mismatch\")\n );\n}\n\nfunction isConnectionRecoveryRunError(info: RunErrorInfo): boolean {\n const code = (info.errorCode ?? \"\").toLowerCase();\n const message = info.message.toLowerCase();\n return (\n code === \"connection_error\" ||\n message.includes(\"connection kept failing\") ||\n message.includes(\"automatic recovery attempts\")\n );\n}\n\n// ─── BuilderConnectCta ────────────────────────────────────────────────────────\n// Renders a single row with left-aligned copy and a right-aligned action.\n// Click opens the Builder CLI-auth popup via the shared\n// `useBuilderConnectFlow` hook (which owns the synchronous window.open,\n// the 2s status poll, and the focus-refresh). On success the hook broadcasts\n// a config-change event so the chat clears its local `missingApiKey` gate.\n//\n// Desktop note: when this component runs inside the Electron shell, the\n// window.open call is intercepted by the main process's webview popup handler,\n// which opens the flow in an Electron BrowserWindow that shares the webview's\n// session. See packages/desktop-app/src/main/index.ts.\n\nexport function BuilderConnectCta({\n variant = \"primary\",\n onConnected,\n}: {\n variant?: \"primary\" | \"compact\";\n onConnected?: () => void;\n}) {\n const { configured, orgName, connecting, error, start } =\n useBuilderConnectFlow({\n trackingSource: \"assistant_chat_builder_cta\",\n onConnected,\n });\n\n const containerClass =\n variant === \"compact\"\n ? \"rounded-md border border-border px-3 py-2.5\"\n : \"flex items-center gap-3 rounded-md border border-border px-3 py-3\";\n\n if (configured) {\n return (\n <div className={containerClass}>\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-xs font-medium text-foreground\">Builder.io</div>\n <p className=\"text-[11px] text-muted-foreground mt-0.5\">\n {orgName ? `Connected — ${orgName}` : \"Connected\"}\n </p>\n </div>\n <span className=\"ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500\">\n <IconCheck size={10} />\n Connected\n </span>\n </div>\n );\n }\n\n return (\n <div className={containerClass}>\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-xs font-medium text-foreground\">\n Connect Builder.io\n </div>\n <p className=\"text-[11px] text-muted-foreground mt-0.5 max-w-[220px]\">\n Free credits for LLM, hosting, and more — no API key needed\n </p>\n {error && <p className=\"mt-1 text-[10px] text-destructive\">{error}</p>}\n </div>\n <button\n type=\"button\"\n onClick={() => start()}\n disabled={connecting}\n className=\"ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-foreground px-3 py-1.5 text-[11px] font-medium no-underline text-background hover:opacity-90 disabled:opacity-60 disabled:cursor-wait\"\n aria-busy={connecting}\n >\n {connecting ? (\n <>\n <IconLoader2 size={10} className=\"animate-spin\" />\n Waiting…\n </>\n ) : (\n <>\n Connect\n <IconExternalLink size={10} />\n </>\n )}\n </button>\n </div>\n );\n}\n\n// ─── ApiKeyConnect ────────────────────────────────────────────────────────────\n\nconst API_KEY_PROVIDERS: Array<{\n value: AgentEngineProvider;\n label: string;\n placeholder: string;\n}> = [\n { value: \"anthropic\", label: \"Anthropic\", placeholder: \"sk-ant-…\" },\n { value: \"openai\", label: \"OpenAI\", placeholder: \"sk-…\" },\n];\n\nexport function ApiKeyConnect({ onConnected }: { onConnected?: () => void }) {\n const [provider, setProvider] = useState<AgentEngineProvider>(\"anthropic\");\n const [apiKey, setApiKey] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const active = API_KEY_PROVIDERS.find((p) => p.value === provider)!;\n\n const handleSave = useCallback(async () => {\n if (!apiKey.trim() || saving) return;\n setSaving(true);\n setError(null);\n try {\n await saveAgentEngineApiKey({ provider, apiKey });\n setApiKey(\"\");\n onConnected?.();\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Could not save the key.\");\n } finally {\n setSaving(false);\n }\n }, [apiKey, onConnected, provider, saving]);\n\n return (\n <div className=\"rounded-md border border-border bg-background/60 p-3\">\n <div className=\"mb-2 flex items-center gap-1.5 text-[11px] font-medium text-foreground\">\n <IconKey size={12} strokeWidth={1.9} />\n Use your own API key\n </div>\n <p className=\"mb-2.5 text-[11px] leading-relaxed text-muted-foreground\">\n Stored securely for this app only.\n </p>\n <div\n role=\"tablist\"\n aria-label=\"API key provider\"\n className=\"mb-2 inline-flex rounded-md border border-border bg-muted/40 p-0.5\"\n >\n {API_KEY_PROVIDERS.map((option) => {\n const selected = option.value === provider;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"tab\"\n aria-selected={selected}\n onClick={() => {\n setProvider(option.value);\n setError(null);\n }}\n className={cn(\n \"rounded px-2.5 py-1 text-[11px] font-medium transition-colors\",\n selected\n ? \"bg-background text-foreground shadow-sm\"\n : \"text-muted-foreground hover:text-foreground\",\n )}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n <div className=\"flex items-center gap-2\">\n <input\n type=\"password\"\n value={apiKey}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={active.placeholder}\n onChange={(e) => {\n setApiKey(e.target.value);\n if (error) setError(null);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n void handleSave();\n }\n }}\n className=\"h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 focus:ring-offset-background\"\n />\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={!apiKey.trim() || saving}\n className=\"inline-flex h-8 shrink-0 items-center gap-1 rounded-md bg-foreground px-3 text-[11px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60\"\n >\n {saving ? (\n <>\n <IconLoader2 size={11} className=\"animate-spin\" />\n Saving…\n </>\n ) : (\n \"Save\"\n )}\n </button>\n </div>\n {error ? (\n <p className=\"mt-2 text-[11px] text-destructive\">{error}</p>\n ) : null}\n </div>\n );\n}\n\n// ─── BuilderSetupCard ─────────────────────────────────────────────────────────\n\nexport function BuilderSetupCard({\n onConnected,\n bouncePulse,\n}: {\n onConnected?: () => void;\n bouncePulse?: number;\n}) {\n // Progressive disclosure: the card leads with the one-click Builder connect.\n // The bring-your-own-key path stays tucked behind a single link so the chat\n // stays clean for people who connect Builder or never use the side chat at\n // all (they can keep driving the plan from their own coding agent).\n const [keyOpen, setKeyOpen] = useState(false);\n\n const cardRef = useRef<HTMLDivElement>(null);\n // Replay the bounce keyframe each time bouncePulse increments. Toggling the\n // class off-then-on (with a forced reflow) restarts the animation even when\n // the value changes back-to-back.\n useEffect(() => {\n if (!bouncePulse) return;\n const el = cardRef.current;\n if (!el) return;\n el.classList.remove(\"animate-bounce-once\");\n void el.offsetWidth;\n el.classList.add(\"animate-bounce-once\");\n }, [bouncePulse]);\n\n return (\n <div\n ref={cardRef}\n className=\"mx-4 my-6 rounded-lg border border-border bg-card p-5\"\n >\n <div className=\"flex items-center gap-3 mb-3\">\n <div className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted\">\n <IconMessage className=\"h-4.5 w-4.5 text-muted-foreground\" />\n </div>\n <div>\n <h3 className=\"text-sm font-medium text-foreground\">\n Turn on the side chat\n </h3>\n <p className=\"mt-0.5 text-[11px] text-muted-foreground\">\n One click to connect Builder for free hosted access — no API key or\n account needed.\n </p>\n </div>\n </div>\n\n <div className=\"space-y-3\">\n <BuilderConnectCta onConnected={onConnected} />\n\n {keyOpen ? (\n <ApiKeyConnect onConnected={onConnected} />\n ) : (\n <div className=\"text-center\">\n <button\n type=\"button\"\n onClick={() => setKeyOpen(true)}\n className=\"text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline\"\n >\n Or paste your own Anthropic or OpenAI key\n </button>\n </div>\n )}\n\n <p className=\"text-center text-[11px] leading-relaxed text-muted-foreground\">\n You can skip this and keep editing the plan with your own coding\n agent.\n </p>\n </div>\n </div>\n );\n}\n\n// ─── RunErrorRecoveryCard ─────────────────────────────────────────────────────\n\nexport function RunErrorRecoveryCard({\n info,\n onContinue,\n onRetry,\n onFork,\n onDismiss,\n}: {\n info: RunErrorInfo;\n onContinue: () => void;\n onRetry: () => void;\n onFork?: () => void | boolean | Promise<void | boolean>;\n onDismiss: () => void;\n}) {\n const [detailsOpen, setDetailsOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [forking, setForking] = useState(false);\n const [forkError, setForkError] = useState<string | null>(null);\n const builderReconnect = useBuilderConnectFlow({\n trackingSource: \"assistant_chat_reconnect_error\",\n });\n const canRecover = info.recoverable === true;\n const shouldShowBuilderReconnect = isBuilderReconnectRunError(info);\n const builderReconnectResolved =\n shouldShowBuilderReconnect &&\n builderReconnect.hasFetchedStatus &&\n builderReconnect.configured;\n const isQueryError = isProviderQueryRunError(info);\n const isConnectionRecoveryError = isConnectionRecoveryRunError(info);\n const copyLabel =\n info.runId || info.errorCode || info.details ? \"Copy debug\" : \"Copy\";\n const copyDetails = useCallback(() => {\n const text = [\n info.message,\n info.errorCode ? `Code: ${info.errorCode}` : \"\",\n info.runId ? `Run: ${info.runId}` : \"\",\n info.details ? `Details:\\n${info.details}` : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\\n\");\n void writeClipboardText(text).then((ok) => {\n if (!ok) return;\n setCopied(true);\n setTimeout(() => setCopied(false), 1200);\n });\n }, [info]);\n const startNewChat = useCallback(() => {\n window.dispatchEvent(new CustomEvent(\"agent-chat:new-chat\"));\n onDismiss();\n }, [onDismiss]);\n\n const handleFork = useCallback(async () => {\n if (!onFork || forking) return;\n setForking(true);\n setForkError(null);\n try {\n const result = await onFork();\n if (result === false) {\n setForkError(\"Could not fork this chat. Try starting a new chat.\");\n }\n } catch {\n setForkError(\"Could not fork this chat. Try starting a new chat.\");\n } finally {\n setForking(false);\n }\n }, [forking, onFork]);\n\n useEffect(() => {\n if (builderReconnectResolved) {\n onDismiss();\n }\n }, [builderReconnectResolved, onDismiss]);\n\n return (\n <div className=\"rounded-lg border border-amber-500/25 bg-amber-500/[0.06] p-3 text-sm\">\n <div className=\"flex items-start gap-2\">\n <span className=\"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-amber-500/10 text-amber-700 dark:text-amber-300\">\n <IconAlertTriangle size={14} />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"font-medium text-foreground\">\n {canRecover\n ? \"The agent stopped before finishing\"\n : \"The agent hit an error\"}\n </div>\n <p className=\"mt-1 text-xs leading-relaxed text-muted-foreground\">\n {info.message}\n </p>\n {shouldShowBuilderReconnect && !builderReconnectResolved && (\n <p className=\"mt-2 text-xs leading-relaxed text-muted-foreground\">\n The current Builder.io or model-provider credential was rejected.\n Reconnect Builder.io, then retry this message.\n </p>\n )}\n {isConnectionRecoveryError && (\n <p className=\"mt-2 text-xs leading-relaxed text-muted-foreground\">\n If retry lands on the same error, start a new chat session and\n continue from what already changed.\n </p>\n )}\n {(info.runId || info.errorCode || info.details) && (\n <button\n type=\"button\"\n onClick={() => setDetailsOpen((v) => !v)}\n className=\"mt-2 inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground hover:text-foreground\"\n >\n <IconChevronDown\n size={12}\n className={cn(\n \"transition-transform\",\n detailsOpen && \"rotate-180\",\n )}\n />\n Details\n </button>\n )}\n {detailsOpen && (\n <div className=\"mt-2 rounded-md border border-border/60 bg-background/70 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground\">\n {info.runId && <div>run: {info.runId}</div>}\n {info.errorCode && <div>code: {info.errorCode}</div>}\n {info.details && (\n <pre className=\"mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words font-mono\">\n {info.details}\n </pre>\n )}\n </div>\n )}\n </div>\n <button\n type=\"button\"\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/80 hover:text-foreground\"\n >\n <IconX size={14} />\n </button>\n </div>\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n {shouldShowBuilderReconnect && !builderReconnectResolved && (\n <button\n type=\"button\"\n onClick={() => builderReconnect.start()}\n disabled={builderReconnect.connecting}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90 disabled:cursor-wait disabled:opacity-70\"\n >\n {builderReconnect.connecting ? (\n <IconLoader2 size={13} className=\"animate-spin\" />\n ) : (\n <IconExternalLink size={13} />\n )}\n {builderReconnect.connecting\n ? \"Connecting Builder.io\"\n : \"Reconnect Builder.io\"}\n </button>\n )}\n {canRecover && (\n <>\n <button\n type=\"button\"\n onClick={onContinue}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90\"\n >\n <IconPlayerPlay size={13} />\n Continue\n </button>\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n <IconRefresh size={13} />\n {isQueryError ? \"Diagnose and retry\" : \"Retry\"}\n </button>\n </>\n )}\n {canRecover && isConnectionRecoveryError && (\n <button\n type=\"button\"\n onClick={startNewChat}\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n <IconPlus size={13} />\n New chat\n </button>\n )}\n {canRecover && onFork && !isConnectionRecoveryError && (\n <button\n type=\"button\"\n onClick={handleFork}\n disabled={forking}\n title=\"Fork this conversation into a separate chat thread.\"\n aria-label=\"Fork this conversation into a separate chat thread\"\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent disabled:cursor-wait disabled:opacity-70\"\n >\n {forking ? (\n <IconLoader2 size={13} className=\"animate-spin\" />\n ) : (\n <IconGitFork size={13} />\n )}\n {forking ? \"Forking...\" : \"Fork chat\"}\n </button>\n )}\n <button\n type=\"button\"\n onClick={copyDetails}\n className=\"ml-auto inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium text-muted-foreground hover:bg-background/80 hover:text-foreground\"\n >\n {copied ? <IconCheck size={13} /> : <IconCopy size={13} />}\n {copied ? \"Copied\" : copyLabel}\n </button>\n </div>\n {shouldShowBuilderReconnect && builderReconnect.error && (\n <p className=\"mt-2 text-xs leading-relaxed text-red-500\">\n {builderReconnect.error}\n </p>\n )}\n {forkError && (\n <p className=\"mt-2 text-xs leading-relaxed text-red-500\">{forkError}</p>\n )}\n </div>\n );\n}\n\n// ─── LoopLimitContinueCard ────────────────────────────────────────────────────\n\nexport function LoopLimitContinueCard({\n info,\n onContinue,\n}: {\n info: LoopLimitInfo;\n onContinue: () => void;\n}) {\n const [settings, setSettings] = useState<AgentLoopSettingsResponse | null>(\n null,\n );\n const [value, setValue] = useState(\"\");\n const [saving, setSaving] = useState(false);\n const [saved, setSaved] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const load = useCallback(() => {\n let cancelled = false;\n fetch(agentNativePath(\"/_agent-native/agent-loop-settings\"))\n .then((r) => (r.ok ? r.json() : null))\n .then((data: AgentLoopSettingsResponse | null) => {\n if (cancelled || !data) return;\n setSettings(data);\n setValue(String(data.maxIterations));\n })\n .catch(() => {\n if (!cancelled) setValue(String(info.maxIterations ?? \"\"));\n });\n return () => {\n cancelled = true;\n };\n }, [info.maxIterations]);\n\n useEffect(() => load(), [load]);\n\n const currentLimit = settings?.maxIterations ?? info.maxIterations;\n const numericValue = Number(value);\n const hasPendingChange =\n !!settings &&\n settings.canUpdate &&\n Number.isInteger(numericValue) &&\n numericValue !== settings.maxIterations;\n const scopeLabel =\n settings?.scope === \"org\"\n ? settings.orgName\n ? `${settings.orgName} org`\n : \"org\"\n : \"your account\";\n\n const saveLimit = useCallback(async (): Promise<boolean> => {\n if (!settings?.canUpdate) return false;\n setSaving(true);\n setSaved(false);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(\"/_agent-native/agent-loop-settings\"),\n {\n method: \"PUT\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ maxIterations: numericValue }),\n },\n );\n const body = await res.json().catch(() => ({}));\n if (!res.ok) {\n throw new Error(body?.error ?? `Save failed (${res.status})`);\n }\n setSettings(body as AgentLoopSettingsResponse);\n setValue(String((body as AgentLoopSettingsResponse).maxIterations));\n setSaved(true);\n window.dispatchEvent(\n new CustomEvent(\"agent-loop-settings:changed\", { detail: body }),\n );\n setTimeout(() => setSaved(false), 2000);\n return true;\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Save failed\");\n return false;\n } finally {\n setSaving(false);\n }\n }, [numericValue, settings?.canUpdate]);\n\n const handleContinue = useCallback(async () => {\n if (hasPendingChange) {\n const ok = await saveLimit();\n if (!ok) return;\n }\n onContinue();\n }, [hasPendingChange, onContinue, saveLimit]);\n\n const openSettings = useCallback(() => {\n try {\n window.location.hash = \"agent-limits\";\n } catch {}\n window.dispatchEvent(new CustomEvent(\"agent-panel:open-settings\"));\n }, []);\n\n return (\n <div className=\"rounded-lg border border-amber-500/25 bg-amber-500/[0.06] px-3 py-3 shadow-sm\">\n <div className=\"flex items-start gap-2.5\">\n <span className=\"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-amber-500/10 text-amber-600 dark:text-amber-400\">\n <IconGauge size={14} />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-foreground\">\n Step limit reached\n </p>\n <p className=\"mt-0.5 text-xs leading-relaxed text-muted-foreground\">\n The agent used{\" \"}\n {currentLimit\n ? `${currentLimit.toLocaleString()} steps`\n : \"all available steps\"}\n . Keep going in a fresh turn, or raise the {scopeLabel} limit first.\n </p>\n </div>\n </div>\n\n <div className=\"mt-3 flex flex-wrap items-end gap-2\">\n <label className=\"min-w-[116px] flex-1 space-y-1\">\n <span className=\"text-[10px] font-medium uppercase tracking-wide text-muted-foreground\">\n Max steps\n </span>\n <input\n type=\"number\"\n min={settings?.minMaxIterations ?? 1}\n max={settings?.maxMaxIterations ?? 1000}\n value={value}\n disabled={!settings?.canUpdate || saving}\n onChange={(e) => {\n setValue(e.target.value);\n setError(null);\n }}\n className=\"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:ring-1 focus:ring-ring disabled:opacity-60\"\n />\n </label>\n <button\n type=\"button\"\n onClick={saveLimit}\n disabled={!hasPendingChange || saving}\n className=\"inline-flex h-8 items-center gap-1 rounded-md border border-border px-2.5 text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50\"\n >\n {saving ? (\n <IconLoader2 size={12} className=\"animate-spin\" />\n ) : saved ? (\n <IconCheck size={12} />\n ) : (\n \"Save\"\n )}\n </button>\n <button\n type=\"button\"\n onClick={openSettings}\n className=\"inline-flex h-8 items-center gap-1 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground\"\n >\n <IconSettings size={12} />\n Settings\n </button>\n <button\n type=\"button\"\n onClick={handleContinue}\n disabled={saving}\n className=\"ml-auto inline-flex h-8 items-center gap-1 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90 disabled:opacity-60\"\n >\n {hasPendingChange ? \"Save and keep going\" : \"Keep going\"}\n <IconArrowRight size={12} />\n </button>\n </div>\n\n {settings && !settings.canUpdate && (\n <p className=\"mt-2 text-[11px] text-muted-foreground\">\n Only organization owners and admins can change this limit.\n </p>\n )}\n {error && <p className=\"mt-2 text-[11px] text-destructive\">{error}</p>}\n </div>\n );\n}\n\n// ─── PlanModeCallout ──────────────────────────────────────────────────────────\n\nexport function PlanModeCallout({\n canImplementPlan,\n onImplementPlan,\n onSwitchToAct,\n}: {\n canImplementPlan: boolean;\n onImplementPlan: () => void;\n onSwitchToAct: () => void;\n}) {\n return (\n <div className=\"shrink-0 px-3 pt-2\">\n <div className=\"rounded-lg border border-blue-500/25 bg-blue-500/[0.06] px-3 py-2.5 shadow-sm\">\n <div className=\"flex items-center gap-2.5\">\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-blue-500/10 text-blue-600 dark:text-blue-300\">\n <IconClipboardList size={15} />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium text-foreground\">\n {canImplementPlan ? \"Plan ready\" : \"Plan mode is on\"}\n </p>\n <p className=\"mt-0.5 text-xs leading-relaxed text-muted-foreground\">\n {canImplementPlan\n ? \"Switch to Act and run the proposed plan.\"\n : \"The next turn will stay read-only until you switch to Act.\"}\n </p>\n </div>\n {canImplementPlan ? (\n <button\n type=\"button\"\n onClick={onImplementPlan}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-foreground px-3 text-xs font-medium text-background hover:opacity-90\"\n >\n <IconPlayerPlay size={13} />\n Implement Plan\n </button>\n ) : (\n <button\n type=\"button\"\n onClick={onSwitchToAct}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 text-xs font-medium text-foreground hover:bg-accent\"\n >\n Act\n <IconArrowRight size={13} />\n </button>\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -4,6 +4,17 @@ import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js";
|
|
|
4
4
|
import type { ContentPart } from "../sse-event-processor.js";
|
|
5
5
|
import { FilesChangedSummary } from "../tool-cells/index.js";
|
|
6
6
|
export declare const ChatRunningContext: React.Context<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Human-in-the-loop approval bridge. `AssistantChatInner` provides a value that
|
|
9
|
+
* re-issues the turn approving a specific paused tool call (opt-in
|
|
10
|
+
* `needsApproval` actions). When null, the Approve button is not rendered.
|
|
11
|
+
* Deny is handled locally in the affordance, so it needs no bridge.
|
|
12
|
+
*/
|
|
13
|
+
export type ApprovalContextValue = {
|
|
14
|
+
/** Re-issue the turn so the server runs the approved call. */
|
|
15
|
+
onApprove: (approvalKey: string) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const ApprovalContext: React.Context<ApprovalContextValue | null>;
|
|
7
18
|
type ToolDetailSection = "input" | "result";
|
|
8
19
|
export type ToolDetailPayload = {
|
|
9
20
|
section: ToolDetailSection;
|
|
@@ -14,7 +25,7 @@ export type ToolDetailPayload = {
|
|
|
14
25
|
};
|
|
15
26
|
export declare function toolInputPayload(toolName: string, args: Record<string, unknown>): ToolDetailPayload | null;
|
|
16
27
|
export declare function toolResultPayload(result: string | undefined): ToolDetailPayload | null;
|
|
17
|
-
export declare function ToolCallDisplay({ toolName, argsText, args, result, mcpApp, isRunning, structuredMeta, }: {
|
|
28
|
+
export declare function ToolCallDisplay({ toolName, argsText, args, result, mcpApp, isRunning, structuredMeta, approval, }: {
|
|
18
29
|
toolName: string;
|
|
19
30
|
argsText?: string;
|
|
20
31
|
args: Record<string, unknown>;
|
|
@@ -22,10 +33,18 @@ export declare function ToolCallDisplay({ toolName, argsText, args, result, mcpA
|
|
|
22
33
|
mcpApp?: AgentMcpAppPayload;
|
|
23
34
|
isRunning: boolean;
|
|
24
35
|
structuredMeta?: Record<string, unknown>;
|
|
36
|
+
approval?: {
|
|
37
|
+
approvalKey: string;
|
|
38
|
+
dismissed?: boolean;
|
|
39
|
+
};
|
|
25
40
|
}): import("react/jsx-runtime").JSX.Element;
|
|
26
41
|
export declare function ToolCallFallback({ toolName, args, argsText, result, ...rest }: ToolCallMessagePartProps & {
|
|
27
42
|
mcpApp?: AgentMcpAppPayload;
|
|
28
43
|
structuredMeta?: Record<string, unknown>;
|
|
44
|
+
approval?: {
|
|
45
|
+
approvalKey: string;
|
|
46
|
+
dismissed?: boolean;
|
|
47
|
+
};
|
|
29
48
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
49
|
export declare function ReconnectStreamMessage({ content, }: {
|
|
31
50
|
content: ContentPart[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-display.d.ts","sourceRoot":"","sources":["../../../src/client/chat/tool-call-display.tsx"],"names":[],"mappings":"AAGA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAIL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-call-display.d.ts","sourceRoot":"","sources":["../../../src/client/chat/tool-call-display.tsx"],"names":[],"mappings":"AAGA,OAA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AC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACzD,2CA+CA;AAwLD,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,GAAG,IAAI,EACR,EAAE,wBAAwB,GAAG;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACzD,2CAqBA;AAMD,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,GACR,EAAE;IACD,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,2CAsCA;AAKD,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -10,9 +10,10 @@ import { McpAppRenderer } from "../mcp-apps/McpAppRenderer.js";
|
|
|
10
10
|
import { writeClipboardText } from "../clipboard.js";
|
|
11
11
|
import { cn } from "../utils.js";
|
|
12
12
|
import { SmoothMarkdownText, HighlightedCodeBlock, markdownComponents, markdownModule, remarkGfmFn, markdownUrlTransform, } from "./markdown-renderer.js";
|
|
13
|
-
import { IconLoader2, IconCircleX, IconCheck, IconSquareFilled, IconChevronDown, IconCopy, IconSearch, IconArrowsMaximize, IconArrowsMinimize, } from "@tabler/icons-react";
|
|
13
|
+
import { IconLoader2, IconCircleX, IconCheck, IconSquareFilled, IconChevronDown, IconCopy, IconSearch, IconArrowsMaximize, IconArrowsMinimize, IconShieldCheck, IconX, } from "@tabler/icons-react";
|
|
14
14
|
// Exported so AssistantChatInner can provide a context value.
|
|
15
15
|
export const ChatRunningContext = React.createContext(false);
|
|
16
|
+
export const ApprovalContext = React.createContext(null);
|
|
16
17
|
function stringifyToolValue(value, pretty = false) {
|
|
17
18
|
if (typeof value === "string")
|
|
18
19
|
return value;
|
|
@@ -161,8 +162,32 @@ function ToolDetailViewer({ payload }) {
|
|
|
161
162
|
}, [payload.copyText]);
|
|
162
163
|
return (_jsxs("div", { className: "rounded-md border border-border/50 bg-background/60", children: [_jsxs("div", { className: "flex min-h-9 flex-wrap items-center gap-2 border-b border-border/50 px-2.5 py-1.5", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsxs("div", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx("span", { className: "truncate text-[11px] font-medium text-foreground/85", children: payload.title }), payload.lang !== "text" && (_jsx("span", { className: "shrink-0 rounded border border-border/60 px-1 py-0.5 font-mono text-[9px] uppercase leading-none text-muted-foreground", children: payload.lang }))] }) }), _jsx("button", { type: "button", onClick: () => setSearchOpen((v) => !v), "aria-label": `Search ${payload.title.toLowerCase()}`, "aria-pressed": searchOpen, className: cn("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", searchOpen && "bg-accent text-foreground"), children: _jsx(IconSearch, { size: 12 }) }), _jsx("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-label": expanded ? "Shrink code viewer" : "Expand code viewer", "aria-pressed": expanded, className: "inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: expanded ? (_jsx(IconArrowsMinimize, { size: 12 })) : (_jsx(IconArrowsMaximize, { size: 12 })) }), _jsxs("button", { type: "button", onClick: copyValue, className: "inline-flex h-6 items-center gap-1 rounded-md px-1.5 font-sans text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground", children: [copied ? _jsx(IconCheck, { size: 12 }) : _jsx(IconCopy, { size: 12 }), copied ? "Copied" : "Copy"] })] }), searchOpen && (_jsxs("div", { className: "flex items-center gap-2 border-b border-border/50 px-2.5 py-2", children: [_jsx("input", { value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Find", className: "h-7 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus:ring-1 focus:ring-ring" }), _jsx("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: search.trim() ? matchCount : "" })] })), _jsx("div", { className: cn("agent-tool-code overflow-auto font-mono text-[11px] leading-relaxed text-foreground", expanded ? "max-h-[70vh]" : "max-h-72"), children: search.trim() ? (_jsx("pre", { children: _jsx("code", { children: renderHighlightedSearchText(payload.text, search) }) })) : (_jsx(HighlightedCodeBlock, { code: payload.text, lang: payload.lang })) })] }));
|
|
163
164
|
}
|
|
165
|
+
// ─── Human-in-the-loop approval affordance ────────────────────────────────────
|
|
166
|
+
/**
|
|
167
|
+
* Inline Approve/Deny prompt rendered when a `needsApproval` action paused the
|
|
168
|
+
* turn. Approve re-issues the turn with the call's `approvalKey`; Deny dismisses
|
|
169
|
+
* the prompt locally (the action stays un-run).
|
|
170
|
+
*/
|
|
171
|
+
function ApprovalAffordance({ toolName, approval, }) {
|
|
172
|
+
const ctx = React.useContext(ApprovalContext);
|
|
173
|
+
const [approved, setApproved] = useState(false);
|
|
174
|
+
const [denied, setDenied] = useState(false);
|
|
175
|
+
// Once approved, the turn is re-issued; collapse to a quiet note so the user
|
|
176
|
+
// can't double-fire the approval.
|
|
177
|
+
if (approved) {
|
|
178
|
+
return (_jsxs("div", { className: "mt-1.5 text-xs text-muted-foreground", children: ["Approved. Re-running ", toolName, "..."] }));
|
|
179
|
+
}
|
|
180
|
+
// Deny is local-only: the action simply stays un-run.
|
|
181
|
+
if (denied) {
|
|
182
|
+
return (_jsxs("div", { className: "mt-1.5 text-xs text-muted-foreground", children: ["Denied. ", toolName, " did not run."] }));
|
|
183
|
+
}
|
|
184
|
+
return (_jsxs("div", { className: "mt-1.5 flex items-center gap-2 rounded-md border border-border bg-muted/40 px-2.5 py-1.5", children: [_jsx(IconShieldCheck, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "mr-auto text-xs text-muted-foreground", children: ["Approve to run ", toolName, "?"] }), ctx && (_jsxs("button", { type: "button", onClick: () => {
|
|
185
|
+
setApproved(true);
|
|
186
|
+
ctx.onApprove(approval.approvalKey);
|
|
187
|
+
}, className: cn("inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium transition-colors", "bg-foreground text-background hover:bg-foreground/90"), children: [_jsx(IconCheck, { className: "h-3.5 w-3.5" }), "Approve"] })), _jsxs("button", { type: "button", onClick: () => setDenied(true), className: cn("inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconX, { className: "h-3.5 w-3.5" }), "Deny"] })] }));
|
|
188
|
+
}
|
|
164
189
|
// ─── ToolCallDisplay ──────────────────────────────────────────────────────────
|
|
165
|
-
export function ToolCallDisplay({ toolName, argsText, args, result, mcpApp, isRunning, structuredMeta, }) {
|
|
190
|
+
export function ToolCallDisplay({ toolName, argsText, args, result, mcpApp, isRunning, structuredMeta, approval, }) {
|
|
166
191
|
// Delegate to bespoke cells when structured metadata is present.
|
|
167
192
|
// These must be separate components so hook order in ToolCallDisplayGeneric
|
|
168
193
|
// is always stable (no conditional hook calls).
|
|
@@ -176,9 +201,9 @@ export function ToolCallDisplay({ toolName, argsText, args, result, mcpApp, isRu
|
|
|
176
201
|
if (toolKind === "write") {
|
|
177
202
|
return (_jsx(WriteCell, { meta: structuredMeta, isRunning: isRunning }));
|
|
178
203
|
}
|
|
179
|
-
return (_jsx(ToolCallDisplayGeneric, { toolName: toolName, argsText: argsText, args: args, result: result, mcpApp: mcpApp, isRunning: isRunning }));
|
|
204
|
+
return (_jsx(ToolCallDisplayGeneric, { toolName: toolName, argsText: argsText, args: args, result: result, mcpApp: mcpApp, isRunning: isRunning, approval: approval }));
|
|
180
205
|
}
|
|
181
|
-
function ToolCallDisplayGeneric({ toolName, argsText, args, result, mcpApp, isRunning, }) {
|
|
206
|
+
function ToolCallDisplayGeneric({ toolName, argsText, args, result, mcpApp, isRunning, approval, }) {
|
|
182
207
|
const streamRef = useRef(null);
|
|
183
208
|
const isAgentCall = toolName.startsWith("agent:");
|
|
184
209
|
const [expanded, setExpanded] = useState(isAgentCall);
|
|
@@ -250,7 +275,7 @@ function ToolCallDisplayGeneric({ toolName, argsText, args, result, mcpApp, isRu
|
|
|
250
275
|
const isExpanded = isAgentCall ? hasStreamText && expanded : expanded;
|
|
251
276
|
return (_jsxs("div", { className: "my-1 overflow-hidden", children: [mcpApp && _jsx(McpAppRenderer, { app: mcpApp, className: "mb-1.5" }), _jsxs("button", { onClick: () => canExpand && setExpanded(!isExpanded), "aria-expanded": canExpand ? isExpanded : undefined, className: cn("flex items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-mono w-full text-left overflow-hidden", isRunning
|
|
252
277
|
? "bg-muted text-muted-foreground"
|
|
253
|
-
: "bg-muted text-muted-foreground hover:bg-accent"), children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : isAgentError ? (_jsx(IconCircleX, { className: "h-3 w-3 text-destructive" })) : result !== undefined ? (_jsx(IconCheck, { className: "h-3 w-3 text-emerald-500" })) : (_jsx(IconSquareFilled, { className: "h-3 w-3 text-muted-foreground" })) }), _jsx("span", { className: "truncate min-w-0", children: _jsx("span", { className: "font-medium", children: displayName }) }), canExpand && (_jsx(IconChevronDown, { className: cn("ml-auto h-3 w-3 shrink-0 opacity-40", isExpanded && "rotate-180") }))] }), isExpanded && isAgentCall && hasStreamText && (_jsx("div", { ref: streamRef, className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground break-words max-h-48 overflow-y-auto agent-markdown prose prose-sm prose-invert max-w-none", children: markdownModule?.default && remarkGfmFn ? (_jsx(markdownModule.default, { remarkPlugins: [remarkGfmFn], components: markdownComponents, urlTransform: markdownUrlTransform, children: agentStreamText })) : (_jsx("span", { style: { whiteSpace: "pre-wrap" }, children: agentStreamText })) })), isExpanded && !isAgentCall && (hasArgs || result !== undefined) && (_jsxs("div", { className: "mt-1 space-y-2 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground", children: [inputPayload && _jsx(ToolDetailViewer, { payload: inputPayload }), resultPayload && _jsx(ToolDetailViewer, { payload: resultPayload })] }))] }));
|
|
278
|
+
: "bg-muted text-muted-foreground hover:bg-accent"), children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : isAgentError ? (_jsx(IconCircleX, { className: "h-3 w-3 text-destructive" })) : result !== undefined ? (_jsx(IconCheck, { className: "h-3 w-3 text-emerald-500" })) : (_jsx(IconSquareFilled, { className: "h-3 w-3 text-muted-foreground" })) }), _jsx("span", { className: "truncate min-w-0", children: _jsx("span", { className: "font-medium", children: displayName }) }), canExpand && (_jsx(IconChevronDown, { className: cn("ml-auto h-3 w-3 shrink-0 opacity-40", isExpanded && "rotate-180") }))] }), isExpanded && isAgentCall && hasStreamText && (_jsx("div", { ref: streamRef, className: "mt-1 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground break-words max-h-48 overflow-y-auto agent-markdown prose prose-sm prose-invert max-w-none", children: markdownModule?.default && remarkGfmFn ? (_jsx(markdownModule.default, { remarkPlugins: [remarkGfmFn], components: markdownComponents, urlTransform: markdownUrlTransform, children: agentStreamText })) : (_jsx("span", { style: { whiteSpace: "pre-wrap" }, children: agentStreamText })) })), isExpanded && !isAgentCall && (hasArgs || result !== undefined) && (_jsxs("div", { className: "mt-1 space-y-2 rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground", children: [inputPayload && _jsx(ToolDetailViewer, { payload: inputPayload }), resultPayload && _jsx(ToolDetailViewer, { payload: resultPayload })] })), approval && (_jsx(ApprovalAffordance, { toolName: toolName, approval: approval }))] }));
|
|
254
279
|
}
|
|
255
280
|
// ─── ToolCallFallback ──────────────────────────────────────────────────────────
|
|
256
281
|
export function ToolCallFallback({ toolName, args, argsText, result, ...rest }) {
|
|
@@ -260,7 +285,7 @@ export function ToolCallFallback({ toolName, args, argsText, result, ...rest })
|
|
|
260
285
|
? result
|
|
261
286
|
: result !== undefined
|
|
262
287
|
? JSON.stringify(result)
|
|
263
|
-
: undefined, mcpApp: rest.mcpApp, structuredMeta: rest.structuredMeta, isRunning: isRunning }));
|
|
288
|
+
: undefined, mcpApp: rest.mcpApp, structuredMeta: rest.structuredMeta, isRunning: isRunning, approval: rest.approval }));
|
|
264
289
|
}
|
|
265
290
|
// ─── ReconnectStreamMessage ────────────────────────────────────────────────────
|
|
266
291
|
// Renders the agent's in-progress response during reconnection (outside
|
|
@@ -272,7 +297,7 @@ export function ReconnectStreamMessage({ content, }) {
|
|
|
272
297
|
return (_jsx(SmoothMarkdownText, { text: part.text, streaming: chatRunning, resetKey: `reconnect-text-${i}`, statusType: chatRunning ? "running" : "complete" }, `reconnect-text-${i}`));
|
|
273
298
|
}
|
|
274
299
|
if (part.type === "tool-call") {
|
|
275
|
-
return (_jsx(ToolCallDisplay, { toolName: part.toolName, argsText: part.argsText, args: part.args, result: part.result, mcpApp: part.mcpApp, structuredMeta: part.structuredMeta, isRunning: part.result === undefined && chatRunning }, `reconnect-tool-${i}`));
|
|
300
|
+
return (_jsx(ToolCallDisplay, { toolName: part.toolName, argsText: part.argsText, args: part.args, result: part.result, mcpApp: part.mcpApp, structuredMeta: part.structuredMeta, isRunning: part.result === undefined && chatRunning, approval: part.approval }, `reconnect-tool-${i}`));
|
|
276
301
|
}
|
|
277
302
|
return null;
|
|
278
303
|
}) }) }));
|