Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Parse partial provider-style tool input

rcourtmanfd189218285b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index e81708e6db..39bb89aaef 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -622,11 +622,16 @@ runtime cost control, and shared AI transport surfaces.
row instead of persisting a failed tool card. If a terminal `tool_end`
reaches the browser without a matching pending row, the frontend must still
append the completed row instead of dropping the only visible tool evidence.
- While streamed arguments are still invalid or incomplete JSON, the frontend
- must use the `raw_input`
+ While streamed arguments are still invalid, incomplete JSON, or incomplete
+ provider-style function-call input, the frontend must use the `raw_input`
fragment to show a safe partial command/path/query summary instead of a
blank `{}` request row, then replace it with the structured summary once
- parsing succeeds.
+ parsing succeeds. The 2026-06-07 Pulse slice rechecked OpenCode
+ `origin/dev` commit `effd27b23900720a53e965396ff1a105c1f7e9c8`:
+ `packages/opencode/src/session/processor.ts` lines 431-451 append
+ `tool-input-delta` text to the same call, and
+ `packages/opencode/src/cli/cmd/tui/context/sync-v2.tsx` lines 276-294
+ render and mutate that pending tool part as input arrives.
The referenced OpenCode source at fetched `origin/dev` commit
`1399323b78a04229d9bfe00c7436d7f41770fda8` keeps tool invocations as durable
message parts in `packages/opencode/src/session/processor.ts`
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 646d96c61a..1317ebae55 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -551,12 +551,15 @@ payload shape change when the portal presents compact client rows.
fast UX iteration against the real stream reducer. That fixture may
short-circuit `frontend-modern/src/api/aiChat.ts` only in Vite dev or test
mode, only for reserved `/fixture ...` prompts, and only by calling the
- normal `AIChatAPI.chat` event callback with the generated
- `AIChatStreamEvent` union (`session`, `workflow_state`, `thinking`,
- `tool_start`, `tool_progress`, `tool_end`, `content`, `done`). It must not
- open a backend session, mutate persisted chat history, add browser-only
- stream event shapes, or become a production fallback for provider or VPN
- failures.
+ normal `AIChatAPI.chat` event callback with the generated
+ `AIChatStreamEvent` union (`session`, `workflow_state`, `thinking`,
+ `tool_start`, `tool_progress`, `tool_end`, `content`, `done`). It must not
+ open a backend session, mutate persisted chat history, add browser-only
+ stream event shapes, or become a production fallback for provider or VPN
+ failures. At least one fixture-backed Assistant tool sequence must exercise
+ the OpenCode-parity raw tool-input path by starting with incomplete
+ provider-style `raw_input`, then mutating the same tool row with completed
+ arguments through the normal `tool_progress` event.
34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.
Legacy Assistant SSE routes in this handler that still use the older
execute envelope, including `/api/ai/execute/stream` and
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.ts
index c67c08875b..1da6917ac9 100644
--- a/frontend-modern/src/api/__tests__/aiChat.test.ts
+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts
@@ -129,6 +129,8 @@ describe('AIChatAPI', () => {
data: {
id: 'fixture-tool-devices',
name: 'pulse_read',
+ input: '{}',
+ raw_input: 'pulse_read(target_host="current_resource", command="ls /dev | wc',
},
});
expect(onEvent.mock.calls[7][0]).toMatchObject({
diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.ts
index 2750c7e93c..38bce69212 100644
--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts
+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts
@@ -94,10 +94,8 @@ const buildDeviceCountFixtureEvents = (model?: string): AIChatStreamEvent[] => [
data: {
id: 'fixture-tool-devices',
name: 'pulse_read',
- input:
- '{"target_host":"current_resource","command":"ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE"}',
- raw_input:
- 'pulse_read(target_host="current_resource", command="ls /dev | wc -l && lsblk -d -o NAME,TYPE,SIZE")',
+ input: '{}',
+ raw_input: 'pulse_read(target_host="current_resource", command="ls /dev | wc',
},
},
{
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
index dc0fbe3be6..de13e70bed 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx
@@ -658,6 +658,22 @@ describe('PendingToolBlock', () => {
expect(screen.queryByText(/pulse_read\(/)).not.toBeInTheDocument();
});
+ it('uses raw partial provider-style input while pending Pulse read arguments are still streaming', () => {
+ render(() => (
+ <PendingToolBlock
+ tool={makePending({
+ name: 'pulse_read',
+ input: '{}',
+ rawInput: 'pulse_read(target_host="current_resource", command="ls /dev | wc',
+ })}
+ />
+ ));
+
+ expect(screen.getByText('Inspect devices on current resource')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool command')).toHaveTextContent('$ ls /dev | wc');
+ expect(screen.queryByText(/pulse_read\(/)).not.toBeInTheDocument();
+ });
+
it('uses raw partial input while pending Pulse read command JSON is still streaming', () => {
render(() => (
<PendingToolBlock
diff --git a/frontend-modern/src/components/AI/Chat/toolPresentation.ts b/frontend-modern/src/components/AI/Chat/toolPresentation.ts
index 12e50f0ab3..94a802c18f 100644
--- a/frontend-modern/src/components/AI/Chat/toolPresentation.ts
+++ b/frontend-modern/src/components/AI/Chat/toolPresentation.ts
@@ -197,14 +197,27 @@ const formatCommandActivitySummary = (record: Record<string, unknown>, mode: 're
return `$ ${inlineValue(command, 64)}${target}`;
};
-const parseFunctionStyleToolInput = (input: string) => {
- const match = /^([a-zA-Z_][a-zA-Z0-9_]*)\s*\(([\s\S]*)\)\s*$/.exec(input.trim());
+const parseFunctionStyleToolInput = (input: string, options?: { allowPartial?: boolean }) => {
+ const trimmed = input.trim();
+ const allowPartial = options?.allowPartial === true;
+ const match = (
+ allowPartial
+ ? /^([a-zA-Z_][a-zA-Z0-9_]*)\s*\(([\s\S]*)$/
+ : /^([a-zA-Z_][a-zA-Z0-9_]*)\s*\(([\s\S]*)\)\s*$/
+ ).exec(trimmed);
if (!match) return null;
const args: Record<string, unknown> = {};
- const body = match[2] || '';
+ let body = match[2] || '';
+ const rightTrimmed = body.trimEnd();
+ if (allowPartial && rightTrimmed.endsWith(')')) {
+ body = rightTrimmed.slice(0, -1);
+ }
let index = 0;
+ const partialResult = () =>
+ allowPartial && Object.keys(args).length > 0 ? { name: match[1], args } : null;
+
const skipWhitespace = () => {
while (index < body.length && /\s/.test(body[index])) index += 1;
};
@@ -220,6 +233,10 @@ const parseFunctionStyleToolInput = (input: string) => {
index += 2;
continue;
}
+ if (allowPartial) {
+ index += 1;
+ break;
+ }
return null;
}
if (char === quote) {
@@ -229,7 +246,7 @@ const parseFunctionStyleToolInput = (input: string) => {
value += char;
index += 1;
}
- return null;
+ return allowPartial ? value : null;
};
while (index < body.length) {
@@ -242,14 +259,15 @@ const parseFunctionStyleToolInput = (input: string) => {
}
const keyMatch = /^[a-zA-Z_][a-zA-Z0-9_]*/.exec(body.slice(index));
- if (!keyMatch) return null;
+ if (!keyMatch) return partialResult();
const key = keyMatch[0];
index += key.length;
skipWhitespace();
- if (body[index] !== '=') return null;
+ if (body[index] !== '=') return partialResult();
index += 1;
skipWhitespace();
+ if (index >= body.length) return partialResult();
const quote = body[index];
let value: unknown;
@@ -258,9 +276,15 @@ const parseFunctionStyleToolInput = (input: string) => {
if (value === null) return null;
} else {
const start = index;
- while (index < body.length && body[index] !== ',') index += 1;
+ while (
+ index < body.length &&
+ body[index] !== ',' &&
+ (allowPartial ? body[index] !== ')' : true)
+ ) {
+ index += 1;
+ }
const rawValue = body.slice(start, index).trim();
- if (!rawValue) return null;
+ if (!rawValue) return partialResult();
if (rawValue === 'true') value = true;
else if (rawValue === 'false') value = false;
else if (rawValue === 'null') value = null;
@@ -270,9 +294,17 @@ const parseFunctionStyleToolInput = (input: string) => {
args[key] = value;
skipWhitespace();
- if (index < body.length && body[index] !== ',') return null;
+ if (body[index] === ',') {
+ index += 1;
+ continue;
+ }
+ if (allowPartial && body[index] === ')') break;
+ if (index < body.length) {
+ return partialResult();
+ }
}
+ if (allowPartial && Object.keys(args).length === 0) return null;
return { name: match[1], args };
};
@@ -294,6 +326,11 @@ const parseStructuredInputRecord = (input: string) => {
return { name: functionCall.name, record: functionCall.args };
}
+ const partialFunctionCall = parseFunctionStyleToolInput(trimmed, { allowPartial: true });
+ if (partialFunctionCall) {
+ return { name: partialFunctionCall.name, record: partialFunctionCall.args };
+ }
+
return null;
};
@@ -480,7 +517,7 @@ export const parseToolInputSummary = (input: string, toolName?: string, rawInput
if (!trimmed) return '';
const directSummary = parseStructuredInputSummary(trimmed, toolName, rawInput);
- if (directSummary) {
+ if (directSummary && !isPlaceholderToolInputSummary(directSummary)) {
return directSummary;
}
@@ -491,6 +528,10 @@ export const parseToolInputSummary = (input: string, toolName?: string, rawInput
}
}
+ if (directSummary) {
+ return directSummary;
+ }
+
return formatIdentifierLabel(trimmed, { maxLength: 28 });
};