@ycodium-ai/agent-fake 0.2.2880 → 0.2.2882

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 (2) hide show
  1. package/dist/index.js +10 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -46,6 +46,8 @@ var FAKE_CARD = {
46
46
  },
47
47
  streamChunks: { type: "integer", minimum: 1 },
48
48
  streamIntervalMs: { type: "integer", minimum: 0 },
49
+ // stream 脚本循环切片的源文本;性能探针用它换上可控的长回复,不进设置表单。
50
+ streamText: { type: "string" },
49
51
  // 额度与用量怎么答(见 fakeUsage.ts);不进设置表单,开发与验收时手改实例配置。
50
52
  usageScript: {
51
53
  type: "string",
@@ -318,16 +320,17 @@ var FAKE_STREAM_TEXT = [
318
320
  "The **important** part is that the timeline only re-renders the streaming row, ",
319
321
  "not the whole list, so each delta stays cheap even on a long conversation. "
320
322
  ].join("");
323
+ var STREAM_CHUNK_CHARS = 12;
321
324
  var parseStreamOptions = (input) => {
322
325
  const config = input?.config ?? {};
323
- const chunks = typeof config.streamChunks === "number" && config.streamChunks >= 1 ? Math.floor(config.streamChunks) : 200;
326
+ const customText = typeof config.streamText === "string" && config.streamText !== "" ? config.streamText : null;
327
+ const chunks = typeof config.streamChunks === "number" && config.streamChunks >= 1 ? Math.floor(config.streamChunks) : customText === null ? 200 : Math.ceil(customText.length / STREAM_CHUNK_CHARS);
324
328
  const intervalMs = typeof config.streamIntervalMs === "number" && config.streamIntervalMs >= 0 ? config.streamIntervalMs : 30;
325
- return { chunks, intervalMs };
329
+ return { chunks, intervalMs, text: customText ?? FAKE_STREAM_TEXT };
326
330
  };
327
- var fakeStreamChunk = (index) => {
328
- const size = 12;
329
- const start = index * size % FAKE_STREAM_TEXT.length;
330
- return FAKE_STREAM_TEXT.slice(start, start + size) || FAKE_STREAM_TEXT.slice(0, size);
331
+ var fakeStreamChunk = (text, index) => {
332
+ const start = index * STREAM_CHUNK_CHARS % text.length;
333
+ return text.slice(start, start + STREAM_CHUNK_CHARS) || text.slice(0, STREAM_CHUNK_CHARS);
331
334
  };
332
335
  var parseReplyText = (input) => {
333
336
  const envelope = input;
@@ -564,7 +567,7 @@ var createFakeInstance = (config, host) => {
564
567
  let text = "";
565
568
  for (let index = 0; index < streamOptions.chunks; index++) {
566
569
  if (aborted()) break;
567
- const delta = fakeStreamChunk(index);
570
+ const delta = fakeStreamChunk(streamOptions.text, index);
568
571
  text += delta;
569
572
  emit("content.delta", threadId, { streamKind: "assistant_text", delta }, { turnId });
570
573
  await new Promise((resolve) => setTimeout(resolve, streamOptions.intervalMs));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-fake",
3
- "version": "0.2.2880",
3
+ "version": "0.2.2882",
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.2880",
24
+ "@ycodium-ai/plugin-api": "0.2.2882",
25
25
  "ycodium-executor-testing": "0.0.0"
26
26
  },
27
27
  "ycodium": {