@ycodium-ai/agent-fake 0.2.2942 → 0.2.2944

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +39 -18
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -4,7 +4,7 @@ A minimal executor plugin. It starts no CLI and replays a fixed event script:
4
4
 
5
5
  - `startSession` emits `session.started`
6
6
  - `sendTurn` emits `turn.started`, one `content.delta`, then `turn.completed` (the host binds the turn by `turn.started`)
7
- - `config.script` picks the script: `plain` (default), `approval-tool` (two approvals before the reply), `async-question` (on a thread's first turn, the reply plus one non-blocking `user-input.requested` with `responseMode: "message"`), `stream` (a Markdown answer in `config.streamChunks` deltas, default 200, one every `config.streamIntervalMs`, default 30; the UI probe `interaction-table.ts` measures streaming with it), `mcp-send` (a turn whose input is a JSON object is passed as the arguments of one real `send_message` call through the built-in MCP server the host handed to `startSession`, the same path a real agent takes; the reply is the tool result, and any other input gets the plain reply), or `visualize` (emits one in-progress builtin tool row, holds for `config.previewHoldMs` milliseconds so the input preview can paint, then one real `visualize_visualize` call on that same server; the tool row’s result is the MCP confirmation text, and the reply is “The figure is in the card above.”)
7
+ - `config.script` picks the script: `plain` (default), `approval-tool` (two approvals before the reply), `async-question` (on a thread's first turn, the reply plus one non-blocking `user-input.requested` with `responseMode: "message"`), `stream` (a Markdown answer in `config.streamChunks` deltas, default 200, one every `config.streamIntervalMs`, default 30; the UI probe `interaction-table.ts` measures streaming with it), `mcp-send` (real calls through the built-in MCP server the host handed to `startSession`, the same path a real agent takes: a turn whose input is a JSON object is passed as the arguments of one `send_message` call, and a JSON array of `{ "tool": "…", "arguments": { … } }` is called step by step, for example `ycodium_plugin_define`, then `ycodium_plugin_run`, then a tool the mounted plugin contributes; the reply has one line per call with its result or error, and any other input gets the plain reply), or `visualize` (emits one in-progress builtin tool row, holds for `config.previewHoldMs` milliseconds so the input preview can paint, then one real `visualize_visualize` call on that same server; the tool row’s result is the MCP confirmation text, and the reply is “The figure is in the card above.”)
8
8
  - `interruptTurn` (or an aborted `AbortSignal`) ends the in-flight turn as `interrupted`
9
9
  - `readThread` returns the bookkeeping the instance recorded
10
10
  - `probe` reports two models, `fake` (default) and `fake-large`
package/dist/index.js CHANGED
@@ -250,6 +250,42 @@ async function callMcpTool(input) {
250
250
  );
251
251
  return called.message?.result;
252
252
  }
253
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
254
+ function parseMcpSendInput(input) {
255
+ let parsed;
256
+ try {
257
+ parsed = JSON.parse(input ?? "");
258
+ } catch {
259
+ return null;
260
+ }
261
+ if (isRecord(parsed)) return [{ tool: "send_message", arguments: parsed }];
262
+ if (!Array.isArray(parsed) || parsed.length === 0) return null;
263
+ const calls = [];
264
+ for (const entry of parsed) {
265
+ if (!isRecord(entry) || typeof entry.tool !== "string" || entry.tool.length === 0) return null;
266
+ const args = entry.arguments ?? {};
267
+ if (!isRecord(args)) return null;
268
+ calls.push({ tool: entry.tool, arguments: args });
269
+ }
270
+ return calls;
271
+ }
272
+ async function runMcpCalls(input) {
273
+ const lines = [];
274
+ for (const call of input.calls) {
275
+ try {
276
+ const result = await callMcpTool({
277
+ fetch: input.fetch,
278
+ server: input.server,
279
+ name: call.tool,
280
+ arguments: call.arguments
281
+ });
282
+ lines.push(`mcp-send ${call.tool}: ${JSON.stringify(result)}`);
283
+ } catch (error) {
284
+ lines.push(`mcp-send ${call.tool} failed: ${String(error)}`);
285
+ }
286
+ }
287
+ return lines.join("\n");
288
+ }
253
289
 
254
290
  // src/visualizeScript.ts
255
291
  var WIRE_NAME = "mcp__ycodium__visualize_visualize";
@@ -480,26 +516,11 @@ var createFakeInstance = (config, host) => {
480
516
  }
481
517
  };
482
518
  const runMcpSendScript = async (booked, input) => {
483
- let args;
484
- try {
485
- args = JSON.parse(input ?? "");
486
- } catch {
487
- return replyText;
488
- }
489
- if (typeof args !== "object" || args === null || Array.isArray(args)) return replyText;
519
+ const calls = parseMcpSendInput(input);
520
+ if (calls === null) return replyText;
490
521
  const server = builtinMcpServer(booked.mcpServers);
491
522
  if (server === null) return "mcp-send: no MCP server was handed to this session";
492
- try {
493
- const result = await callMcpTool({
494
- fetch: host.fetch,
495
- server,
496
- name: "send_message",
497
- arguments: args
498
- });
499
- return `mcp-send: ${JSON.stringify(result)}`;
500
- } catch (error) {
501
- return `mcp-send failed: ${String(error)}`;
502
- }
523
+ return runMcpCalls({ fetch: host.fetch, server, calls });
503
524
  };
504
525
  const runApprovalToolScript = async (threadId, turnId, signal) => {
505
526
  const isAborted = () => signal?.aborted === true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-fake",
3
- "version": "0.2.2942",
3
+ "version": "0.2.2944",
4
4
  "description": "Minimal fake executor for plugin authors and host orchestration tests.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,7 +21,7 @@
21
21
  "@types/node": "24.12.4",
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
- "@ycodium-ai/plugin-api": "0.2.2942",
24
+ "@ycodium-ai/plugin-api": "0.2.2944",
25
25
  "ycodium-executor-testing": "0.0.0"
26
26
  },
27
27
  "ycodium": {