@akagilnc/pi-workflow-roles 0.1.5845 → 0.1.5853

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 (66) hide show
  1. package/README.md +4 -4
  2. package/README.zh-CN.md +4 -4
  3. package/dist/acp-host/production-host.js +348 -1254
  4. package/dist/acp-host/role-turn-host.js +4 -98
  5. package/dist/headless-host/production-host.js +15731 -16582
  6. package/dist/headless-host/role-turn-host.js +6 -31
  7. package/dist/migrate-book-topology.js +31 -16
  8. package/dist/navigator-attendance.js +54 -404
  9. package/dist/navigator-invocation-identity.js +0 -2
  10. package/dist/navigator-lookup-host.js +41 -0
  11. package/dist/navigator-lookup.js +68 -0
  12. package/dist/navigator-route-table.js +42 -0
  13. package/dist/package-contracts/navigator-output.js +3 -11
  14. package/dist/packaged-role-registry.js +3 -27
  15. package/dist/public-cli/instruction-seat-run.js +4 -1
  16. package/dist/public-cli/invocation.js +13 -26
  17. package/dist/public-cli/main.js +286 -114
  18. package/dist/public-cli/option-definitions.js +24 -4
  19. package/dist/public-cli/post-admission.js +0 -9
  20. package/dist/public-cli/role-seat-runtime.js +14 -0
  21. package/dist/public-cli/settlement.js +14 -40
  22. package/dist/public-cli/terminal.js +1 -8
  23. package/dist/public-cli/turn-request.js +0 -3
  24. package/dist/public-role-summons.js +0 -1
  25. package/dist/receipt-delivery-policy.js +0 -23
  26. package/dist/role-runtime-dependencies.js +4 -11
  27. package/dist/role-runtime.js +18 -194
  28. package/dist/submission-ledger.js +19 -15
  29. package/dist/ticket-progress.js +23 -5
  30. package/extensions/role-runtime.ts +0 -16
  31. package/package.json +1 -1
  32. package/scripts/build-package.mjs +3 -7
  33. package/src/acp-host/role-turn-host.ts +8 -97
  34. package/src/headless-host/description.ts +0 -2
  35. package/src/headless-host/role-turn-host.ts +7 -32
  36. package/src/host-contracts.ts +5 -7
  37. package/src/navigator-attendance.ts +86 -549
  38. package/src/navigator-invocation-identity.ts +0 -2
  39. package/src/navigator-lookup-host.ts +45 -0
  40. package/src/navigator-lookup.ts +98 -0
  41. package/src/navigator-route-table.ts +92 -0
  42. package/src/package-contracts/navigator-output.ts +4 -15
  43. package/src/packaged-role-registry.ts +3 -32
  44. package/src/public-cli/instruction-seat-run.ts +3 -0
  45. package/src/public-cli/invocation.ts +18 -30
  46. package/src/public-cli/option-definitions.ts +25 -4
  47. package/src/public-cli/post-admission.ts +0 -11
  48. package/src/public-cli/role-seat-runtime.ts +14 -0
  49. package/src/public-cli/settlement.ts +23 -51
  50. package/src/public-cli/terminal.ts +3 -18
  51. package/src/public-cli/turn-request.ts +0 -5
  52. package/src/public-role-summons.ts +0 -8
  53. package/src/receipt-delivery-policy.ts +0 -21
  54. package/src/role-runtime-dependencies.ts +4 -11
  55. package/src/role-runtime.ts +19 -210
  56. package/src/submission-ledger.ts +23 -16
  57. package/src/ticket-progress.ts +32 -5
  58. package/dist/navigator-public-session.js +0 -205
  59. package/dist/navigator-role.js +0 -6
  60. package/dist/navigator-session-contracts.js +0 -227
  61. package/dist/navigator-work-context.js +0 -72
  62. package/resources/navigator-route-playbook.md +0 -33
  63. package/src/navigator-public-session.ts +0 -305
  64. package/src/navigator-role.ts +0 -15
  65. package/src/navigator-session-contracts.ts +0 -320
  66. package/src/navigator-work-context.ts +0 -97
@@ -5,62 +5,8 @@ import { createSerializedRoleTurnHost, driveExternalRoleTurnRounds, disposeExter
5
5
  import { describeErrorIdentity } from "../public-cli/run-lifecycle.js";
6
6
  import { projectThrownFailureLeaf } from "../public-cli/settlement.js";
7
7
  import { copyAndRecordHostDossier, recordNativeSessionPointer, } from "../host-session-record.js";
8
- import { NAVIGATOR_OUTPUT_TOOL_NAME, navigatorProseFromUnknown, } from "../package-contracts/navigator-output.js";
9
8
  import { renderSystemPromptOverride, resolveBoundHostSessionId, } from "../prepared-role-turn.js";
10
9
  import { acpModelId } from "./description.js";
11
- import { isRecord } from "../unknown-value.js";
12
- /**
13
- * #959: collect free-form agent text from ACP session/update stream.
14
- * Used only when the navigator seat spoke prose without calling the output tool.
15
- * ACP agent speech is only agent_message / agent_message_chunk — never user,
16
- * thought, or other *_message kinds (load replay must not poison the bucket).
17
- *
18
- * Standard ACP nests under params.update: { sessionUpdate, content }.
19
- * Flat params.sessionUpdate / string params.update remain accepted for host variants.
20
- */
21
- function acpAgentTextChunk(params) {
22
- let kind;
23
- let content;
24
- let textFallback;
25
- const nested = params.update;
26
- if (isRecord(nested)) {
27
- const record = nested;
28
- kind = record.sessionUpdate;
29
- content = record.content;
30
- textFallback = record.text;
31
- }
32
- else {
33
- kind = params.sessionUpdate ?? nested;
34
- content = params.content;
35
- textFallback = params.text;
36
- }
37
- if (kind !== "agent_message_chunk" && kind !== "agent_message")
38
- return undefined;
39
- if (typeof content === "string" && content.length > 0)
40
- return content;
41
- if (isRecord(content)) {
42
- const record = content;
43
- if (typeof record.text === "string" && record.text.length > 0)
44
- return record.text;
45
- }
46
- if (Array.isArray(content)) {
47
- const parts = [];
48
- for (const part of content) {
49
- if (typeof part === "string" && part.length > 0)
50
- parts.push(part);
51
- else if (typeof part === "object" && part !== null) {
52
- const record = part;
53
- if (typeof record.text === "string" && record.text.length > 0)
54
- parts.push(record.text);
55
- }
56
- }
57
- if (parts.length > 0)
58
- return parts.join("");
59
- }
60
- if (typeof textFallback === "string" && textFallback.length > 0)
61
- return textFallback;
62
- return undefined;
63
- }
64
10
  function acpError(code, message, cause) {
65
11
  return Object.assign(new Error(message, cause === undefined ? undefined : { cause }), { code });
66
12
  }
@@ -228,21 +174,6 @@ export function createAcpRoleTurnHost(config) {
228
174
  else {
229
175
  connection = await config.connect(request);
230
176
  const rpc = (method, params) => connection.request(method, params);
231
- // #959: navigator free-form agent text — only while session/prompt is in flight.
232
- // session/load replays history via session/update; those must not enter the bucket
233
- // (resume / set_model load would otherwise prepend prior turns as "this turn" prose).
234
- const agentProseChunks = [];
235
- let collectAgentProse = false;
236
- connection.onNotification?.((method, params) => {
237
- const isSessionUpdate = method === "session/update";
238
- if (!isSessionUpdate)
239
- return;
240
- if (collectAgentProse) {
241
- const chunk = acpAgentTextChunk(params);
242
- if (chunk !== undefined)
243
- agentProseChunks.push(chunk);
244
- }
245
- });
246
177
  const initialized = await rpc("initialize", {
247
178
  protocolVersion: 1,
248
179
  clientCapabilities: {},
@@ -331,23 +262,11 @@ export function createAcpRoleTurnHost(config) {
331
262
  outputSchema: deliveredSchema,
332
263
  }, "acp-host");
333
264
  let result;
334
- // Open the prose gate only for this prompt round; clear any stale chunks first.
335
- agentProseChunks.length = 0;
336
- collectAgentProse = prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME;
337
- try {
338
- result = await raceAgainstHostAbort(activeConnection.request("session/prompt", {
339
- sessionId: activeSessionId,
340
- prompt: [{ type: "text", text: prompt }],
341
- }), abortSignal, "ACP host aborted");
342
- }
343
- catch (error) {
344
- collectAgentProse = false;
345
- agentProseChunks.length = 0;
346
- throw error;
347
- }
348
- collectAgentProse = false;
265
+ result = await raceAgainstHostAbort(activeConnection.request("session/prompt", {
266
+ sessionId: activeSessionId,
267
+ prompt: [{ type: "text", text: prompt }],
268
+ }), abortSignal, "ACP host aborted");
349
269
  if (result.stopReason === "refusal") {
350
- agentProseChunks.length = 0;
351
270
  reportedFailure = { diagnostic: result.stopReason, details: result };
352
271
  return {
353
272
  status: "terminal",
@@ -359,19 +278,6 @@ export function createAcpRoleTurnHost(config) {
359
278
  },
360
279
  };
361
280
  }
362
- // #959: navigator prose exit when the model spoke without the output tool.
363
- // Tool path still wins via MCP; ingest is a no-op once the tool already sealed.
364
- // Emptiness via shared projector; payload keeps original bytes (LLM 原话过手).
365
- if (prepared.terminatingToolName === NAVIGATOR_OUTPUT_TOOL_NAME) {
366
- const prose = agentProseChunks.join("");
367
- agentProseChunks.length = 0;
368
- if (navigatorProseFromUnknown(prose) !== undefined) {
369
- await prepared.ingestStructuredOutput({ prose });
370
- }
371
- }
372
- else {
373
- agentProseChunks.length = 0;
374
- }
375
281
  return { status: "delivered", stderr: activeConnection.stderr?.() ?? "" };
376
282
  },
377
283
  async afterAccepted() {