@cloud411716/fancy-webnovel 0.1.70 → 0.1.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.70",
3
+ "version": "0.1.72",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -20,22 +20,19 @@ export async function apply(ctx) {
20
20
  const session = invocation.agent.session;
21
21
  const rawInput = invocation.rawInput ? invocation.rawInput.trim() : '';
22
22
 
23
- // ─── TEST: 验证 ctx.get('sessions') 是否可访问 ───────────────────────
23
+ // ─── TEST: 验证直接用 invocation.agent.session 追加事件 ─────────────────
24
24
  {
25
- const sessions = ctx.get('sessions');
26
- notify(session, `[TEST] ctx.get('sessions') = ${sessions ? 'AVAILABLE' : 'UNDEFINED'}`);
27
- if (sessions) {
28
- const s = sessions.active;
29
- notify(session, `[TEST] sessions.active = ${s ? s.id : 'UNDEFINED'}`);
30
- if (s) {
31
- // 追加一个 fake tool/call,看 status bar 是否出现进度
32
- s.append('tool/call', {
33
- callId: 'test-call-1',
34
- name: 'fancy-scan/progress',
35
- arguments: JSON.stringify({ platform: 'test', length: 'test' }),
36
- });
37
- notify(session, '[TEST] 追加了 fake tool/call 事件');
38
- }
25
+ // invocation.agent.session 就是 Session 对象,直接 append
26
+ const s = invocation.agent.session;
27
+ notify(session, `[TEST] session.id = ${s?.id ?? 'UNDEFINED'}`);
28
+ if (s) {
29
+ // 追加一个 fake tool/call,看 status bar 是否出现进度
30
+ s.append('tool/call', {
31
+ callId: 'test-call-1',
32
+ name: 'fancy-scan/progress',
33
+ arguments: JSON.stringify({ platform: 'test', length: 'test' }),
34
+ });
35
+ notify(session, '[TEST] session.append(tool/call) 成功');
39
36
  }
40
37
  }
41
38
  // ─── TEST 结束 ───────────────────────────────────────────────────────
@@ -112,6 +109,26 @@ export async function apply(ctx) {
112
109
 
113
110
  notify(session, scan.notify({ type: 'collecting', platform, length }));
114
111
 
112
+ // ─── TEST: 在采集过程中持续发送 tool/call 事件 ───────────────────────
113
+ {
114
+ const s = invocation.agent.session;
115
+ let count = 0;
116
+ const timers = [];
117
+ for (let i = 0; i < 5; i++) {
118
+ const t = setTimeout(() => {
119
+ count++;
120
+ s.append('tool/call', {
121
+ callId: `progress-${i}`,
122
+ name: 'fancy-scan/progress',
123
+ arguments: JSON.stringify({ platform, length, step: count }),
124
+ });
125
+ notify(session, `[TEST] tool/call #${count} 发送于采集阶段`);
126
+ }, i * 800);
127
+ timers.push(t);
128
+ }
129
+ }
130
+ // ─── TEST 结束 ───────────────────────────────────────────────────────
131
+
115
132
  const scriptResult = await spawnScript(
116
133
  'node',
117
134
  [join(SCAN_SCRIPTS_DIR, 'run-scan.js'),