@akagilnc/pi-workflow-roles 0.1.3837 → 0.1.3873

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 (42) hide show
  1. package/dist/acp-host/production-host.js +24606 -24532
  2. package/dist/engine-detour-tool.js +2 -2
  3. package/dist/engine-detour.js +23 -7
  4. package/dist/headless-host/production-host.js +4197 -4139
  5. package/dist/host-descriptions.js +5 -2
  6. package/dist/pi/role-turn-host.js +20 -92
  7. package/dist/public-cli/load-production-acp-host.js +1 -1
  8. package/dist/public-cli/load-production-external-host.js +10 -0
  9. package/dist/public-cli/load-production-headless-host.js +1 -1
  10. package/dist/public-cli/main.js +95 -102
  11. package/dist/public-role-summons.js +7 -49
  12. package/dist/reviewer-agent.js +1 -0
  13. package/dist/reviewer-child-executor.js +3 -2
  14. package/dist/role-activation-flags.js +50 -0
  15. package/dist/role-runtime.js +8 -3
  16. package/package.json +1 -1
  17. package/scripts/build-package.mjs +2 -2
  18. package/src/acp-host/production-host.ts +31 -94
  19. package/src/acp-host/role-turn-host.ts +178 -263
  20. package/src/diagnostic-tail.ts +18 -0
  21. package/src/engine-detour-tool.ts +5 -4
  22. package/src/engine-detour.ts +44 -9
  23. package/src/external-host-turn-loop.ts +172 -0
  24. package/src/headless-host/production-host.ts +10 -7
  25. package/src/headless-host/role-turn-host.ts +271 -263
  26. package/src/host-descriptions.ts +5 -2
  27. package/src/host-session-record.ts +41 -0
  28. package/src/pi/role-turn-host.ts +18 -93
  29. package/src/prepared-role-turn.ts +68 -0
  30. package/src/public-cli/cli.ts +11 -20
  31. package/src/public-cli/load-production-acp-host.ts +2 -1
  32. package/src/public-cli/load-production-external-host.ts +17 -0
  33. package/src/public-cli/load-production-headless-host.ts +2 -1
  34. package/src/public-role-summons.ts +12 -69
  35. package/src/reviewer-agent.ts +12 -1
  36. package/src/reviewer-child-executor.ts +10 -2
  37. package/src/role-activation-flags.ts +53 -0
  38. package/src/{acp-host/role-envelope.ts → role-envelope.ts} +28 -84
  39. package/src/role-runtime-dependencies.ts +91 -0
  40. package/src/role-runtime.ts +14 -4
  41. package/src/{acp-host/session-identity.ts → session-identity.ts} +6 -6
  42. /package/src/{acp-host/mcp-relay.mjs → mcp-relay.mjs} +0 -0
@@ -2,8 +2,8 @@ import { Type } from "typebox";
2
2
  import {
3
3
  ENGINE_DETOUR_TOOL_NAME,
4
4
  engineDetourFailureDiagnostic,
5
- engineNameFromEnv,
6
5
  isEngineDetourFailure,
6
+ resolveEngineName,
7
7
  runEngineDetourOnce
8
8
  } from "./engine-detour.js";
9
9
  const engineDetourArgsSchema = Type.Object(
@@ -71,7 +71,7 @@ function createEngineDetourToolDefinition(input) {
71
71
  };
72
72
  }
73
73
  function registerEngineDetourTool(roleHost, hostActions) {
74
- const engineName = engineNameFromEnv();
74
+ const engineName = resolveEngineName((name) => roleHost.getFlag(name));
75
75
  if (engineName === void 0) {
76
76
  return false;
77
77
  }
@@ -4,12 +4,19 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  const ENGINE_DETOUR_TOOL_NAME = "ak_engine_detour";
6
6
  const AK_ROLE_ENGINE_ENV = "AK_ROLE_ENGINE";
7
+ const ENGINE_FLAG_NAME = "ak-engine";
7
8
  const ENGINE_DETOUR_STAGED_PROMPT_TOKEN = "<<ak-engine-staged-prompt>>";
9
+ function normalizeEngineName(engine) {
10
+ if (engine === void 0) return void 0;
11
+ const trimmed = engine.trim();
12
+ return trimmed === "" ? void 0 : trimmed;
13
+ }
8
14
  function applyEngineChildEnv(childEnv, engine) {
9
15
  delete childEnv[AK_ROLE_ENGINE_ENV];
10
- if (engine !== void 0 && engine.trim() !== "") {
11
- childEnv[AK_ROLE_ENGINE_ENV] = engine.trim();
12
- } else {
16
+ const normalized = normalizeEngineName(engine);
17
+ if (normalized !== void 0) {
18
+ childEnv[AK_ROLE_ENGINE_ENV] = normalized;
19
+ } else if (childEnv !== process.env) {
13
20
  childEnv[AK_ROLE_ENGINE_ENV] = void 0;
14
21
  }
15
22
  }
@@ -149,19 +156,28 @@ function engineDetourFailureDiagnostic(result) {
149
156
  return `\u52B3\u52A1\u5F15\u64CE\u4EE5 code ${result.code} \u9000\u51FA\uFF1A${lastRow}`;
150
157
  }
151
158
  function engineNameFromEnv() {
152
- const raw = process.env[AK_ROLE_ENGINE_ENV];
153
- if (typeof raw !== "string") return void 0;
154
- const trimmed = raw.trim();
155
- return trimmed === "" ? void 0 : trimmed;
159
+ return normalizeEngineName(
160
+ typeof process.env[AK_ROLE_ENGINE_ENV] === "string" ? process.env[AK_ROLE_ENGINE_ENV] : void 0
161
+ );
162
+ }
163
+ function resolveEngineName(getFlag) {
164
+ if (getFlag !== void 0) {
165
+ const flag = getFlag(ENGINE_FLAG_NAME);
166
+ if (typeof flag === "string") return normalizeEngineName(flag);
167
+ }
168
+ return engineNameFromEnv();
156
169
  }
157
170
  export {
158
171
  AK_ROLE_ENGINE_ENV,
159
172
  ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC,
160
173
  ENGINE_DETOUR_STAGED_PROMPT_TOKEN,
161
174
  ENGINE_DETOUR_TOOL_NAME,
175
+ ENGINE_FLAG_NAME,
162
176
  applyEngineChildEnv,
163
177
  engineDetourFailureDiagnostic,
164
178
  engineNameFromEnv,
165
179
  isEngineDetourFailure,
180
+ normalizeEngineName,
181
+ resolveEngineName,
166
182
  runEngineDetourOnce
167
183
  };