@ycodium-ai/agent-fake 0.2.2678 → 0.2.2690

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 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), or `async-question` (on a thread's first turn, the reply plus one non-blocking `user-input.requested` with `responseMode: "message"`)
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"`), or `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)
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
@@ -40,7 +40,9 @@ var FAKE_CARD = {
40
40
  additionalProperties: false,
41
41
  "x-ycodium-form-order": ["replyText"],
42
42
  properties: {
43
- script: { type: "string", enum: ["plain", "approval-tool", "async-question"] },
43
+ script: { type: "string", enum: ["plain", "approval-tool", "async-question", "stream"] },
44
+ streamChunks: { type: "integer", minimum: 1 },
45
+ streamIntervalMs: { type: "integer", minimum: 0 },
44
46
  replyText: {
45
47
  type: "string",
46
48
  "x-ycodium-form": {
@@ -118,8 +120,28 @@ var FAKE_ASYNC_QUESTIONS = [
118
120
  function parseScript(input) {
119
121
  const envelope = input;
120
122
  const script = envelope?.config?.script;
121
- return script === "approval-tool" || script === "async-question" ? script : "plain";
123
+ return script === "approval-tool" || script === "async-question" || script === "stream" ? script : "plain";
122
124
  }
125
+ var FAKE_STREAM_TEXT = [
126
+ "Here is the plan for the change, step by step.\n\n",
127
+ "1. Read the current implementation and note the hot path.\n",
128
+ "2. Move the measurement out of the commit phase.\n",
129
+ "3. Verify the numbers on a production build.\n\n",
130
+ "```ts\nexport function measure(root: HTMLElement) {\n return root.getBoundingClientRect().height;\n}\n```\n\n",
131
+ "The **important** part is that the timeline only re-renders the streaming row, ",
132
+ "not the whole list, so each delta stays cheap even on a long conversation. "
133
+ ].join("");
134
+ var parseStreamOptions = (input) => {
135
+ const config = input?.config ?? {};
136
+ const chunks = typeof config.streamChunks === "number" && config.streamChunks >= 1 ? Math.floor(config.streamChunks) : 200;
137
+ const intervalMs = typeof config.streamIntervalMs === "number" && config.streamIntervalMs >= 0 ? config.streamIntervalMs : 30;
138
+ return { chunks, intervalMs };
139
+ };
140
+ var fakeStreamChunk = (index) => {
141
+ const size = 12;
142
+ const start = index * size % FAKE_STREAM_TEXT.length;
143
+ return FAKE_STREAM_TEXT.slice(start, start + size) || FAKE_STREAM_TEXT.slice(0, size);
144
+ };
123
145
  var parseReplyText = (input) => {
124
146
  const envelope = input;
125
147
  const replyText = envelope?.config?.replyText;
@@ -134,6 +156,7 @@ var createFakeInstance = (config, host) => {
134
156
  const threads = /* @__PURE__ */ new Map();
135
157
  const script = parseScript(config);
136
158
  const replyText = parseReplyText(config);
159
+ const streamOptions = parseStreamOptions(config);
137
160
  const pendingDecisions = /* @__PURE__ */ new Map();
138
161
  let seq = 0;
139
162
  let inflight = null;
@@ -364,6 +387,25 @@ var createFakeInstance = (config, host) => {
364
387
  ]);
365
388
  return { threadId: input.threadId, turnId };
366
389
  }
390
+ if (script === "stream") {
391
+ let text = "";
392
+ for (let index = 0; index < streamOptions.chunks; index++) {
393
+ if (aborted) break;
394
+ const delta = fakeStreamChunk(index);
395
+ text += delta;
396
+ emit(
397
+ "content.delta",
398
+ input.threadId,
399
+ { streamKind: "assistant_text", delta },
400
+ { turnId }
401
+ );
402
+ await new Promise((resolve) => setTimeout(resolve, streamOptions.intervalMs));
403
+ }
404
+ finishTurn(booked, turnId, aborted ? "interrupted" : "completed", [
405
+ { kind: "assistant", text }
406
+ ]);
407
+ return { threadId: input.threadId, turnId };
408
+ }
367
409
  if (script === "approval-tool") {
368
410
  const finalText = await runApprovalToolScript(input.threadId, turnId, signal);
369
411
  finishTurn(booked, turnId, aborted ? "interrupted" : "completed", [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-fake",
3
- "version": "0.2.2678",
3
+ "version": "0.2.2690",
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.2678"
24
+ "@ycodium-ai/plugin-api": "0.2.2690"
25
25
  },
26
26
  "ycodium": {
27
27
  "plugin": "./dist/index.js",