lazycodex-ai 5.0.0-beta.57 → 5.0.0-beta.61

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 (105) hide show
  1. package/dist/cli/index.js +420 -336
  2. package/dist/cli-node/index.js +420 -336
  3. package/package.json +1 -1
  4. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  5. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +6885 -249
  6. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  7. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  8. package/packages/omo-codex/plugin/components/bootstrap/src/setup.ts +7 -1
  9. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  10. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  11. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  12. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  13. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  14. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  15. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
  16. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  17. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  18. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  19. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  20. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  21. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  22. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  23. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  24. package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +20 -11
  25. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  26. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  27. package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +1 -1
  28. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  29. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  30. package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +2 -0
  31. package/packages/omo-codex/plugin/components/ulw-loop/directive.md +20 -11
  32. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.d.ts +5 -1
  33. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.js +4 -3
  34. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +5 -1
  35. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +2 -2
  36. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.d.ts +1 -1
  37. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.js +38 -39
  38. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +220 -40
  39. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.d.ts +2 -0
  40. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.js +141 -0
  41. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.d.ts +46 -0
  42. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.js +28 -0
  43. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.d.ts +127 -0
  44. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.js +1 -0
  45. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.d.ts +3 -0
  46. package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.js +3 -0
  47. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.d.ts +1 -0
  48. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.js +21 -4
  49. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.d.ts +2 -0
  50. package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.js +22 -0
  51. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +7 -7
  52. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  53. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +4 -0
  54. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-template.ts +8 -2
  55. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +6 -2
  56. package/packages/omo-codex/plugin/components/ulw-loop/src/cli-subcommands.ts +50 -48
  57. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/factory.ts +183 -0
  58. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/manifest.ts +42 -0
  59. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/types.ts +140 -0
  60. package/packages/omo-codex/plugin/components/ulw-loop/src/sdk.ts +3 -0
  61. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-guard.ts +21 -3
  62. package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-role-guard.ts +22 -0
  63. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-contract.test.ts +137 -0
  64. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-driver-states.test.ts +145 -0
  65. package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-session-context.test.ts +148 -0
  66. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard.test.ts +7 -1
  67. package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-role-matrix.test.ts +113 -0
  68. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  69. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  70. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  71. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  72. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  73. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  74. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  75. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  76. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  77. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  78. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  79. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  80. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  81. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  82. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  83. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  84. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  85. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  86. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  87. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  88. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  89. package/packages/omo-codex/plugin/package-lock.json +12 -12
  90. package/packages/omo-codex/plugin/package.json +1 -1
  91. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +3 -3
  92. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +3 -3
  93. package/packages/omo-codex/plugin/skills/refactor/SKILL.md +3 -3
  94. package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +3 -3
  95. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +3 -3
  96. package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +20 -11
  97. package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +3 -3
  98. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +7 -3
  99. package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +3 -3
  100. package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +3 -3
  101. package/packages/omo-codex/plugin/test/bootstrap-default-role.test.mjs +66 -0
  102. package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +13 -1
  103. package/packages/omo-codex/scripts/install-dist/install-local.mjs +7058 -417
  104. package/packages/prompts-core/prompts/ultrawork/codex.md +20 -11
  105. package/packages/shared-skills/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -1
@@ -0,0 +1,141 @@
1
+ import { checkpointUlwLoop } from "../checkpoint.js";
2
+ import { checkpointTemplate } from "../checkpoint-template.js";
3
+ import { recordEvidence } from "../evidence.js";
4
+ import { ulwLoopAttemptEvidenceDir } from "../paths.js";
5
+ import { addUlwLoopGoal, createUlwLoopPlan, startNextUlwLoop, summarizeUlwLoopPlan } from "../plan-crud.js";
6
+ import { readUlwLoopPlan } from "../plan-io.js";
7
+ import { recordFinalReviewBlockers } from "../review-blockers.js";
8
+ import { UlwLoopError } from "../runtime.js";
9
+ import { statusNextActions } from "../status-next-actions.js";
10
+ import { steerUlwLoop } from "../steering.js";
11
+ import { ULW_LOOP_MANIFEST } from "./manifest.js";
12
+ // The SDK takes inline values only, so a snapshot that is not JSON is a caller error - normalize it
13
+ // to the same stable code the CLI reports instead of letting it surface as a generic failure.
14
+ function validateCodexGoalJson(raw) {
15
+ if (raw === undefined)
16
+ return;
17
+ try {
18
+ JSON.parse(raw);
19
+ }
20
+ catch (error) {
21
+ throw new UlwLoopError(`Invalid codexGoal: ${error instanceof Error ? error.message : "not valid JSON"}`, "ULW_LOOP_CODEX_GOAL_JSON_INVALID", { cause: error });
22
+ }
23
+ }
24
+ function validateContext(context) {
25
+ if (!context.cwd.trim())
26
+ throw new UlwLoopError("cwd is required.", "ULW_LOOP_CWD_REQUIRED");
27
+ if (!context.sessionId.trim())
28
+ throw new UlwLoopError("ULW_LOOP_SESSION_ID_REQUIRED: sessionId is required.", "ULW_LOOP_SESSION_ID_REQUIRED");
29
+ if (context.surface !== "omo-senpi" && context.surface !== "lazycodex")
30
+ throw new UlwLoopError("surface must be omo-senpi or lazycodex.", "ULW_LOOP_SURFACE_INVALID");
31
+ }
32
+ function errorDetails(error) {
33
+ const details = error.details === undefined
34
+ ? undefined
35
+ : Object.fromEntries(Object.entries(error.details).map(([key, value]) => [key, String(value)]));
36
+ return details === undefined
37
+ ? { code: error.code, message: error.message }
38
+ : { code: error.code, message: error.message, details };
39
+ }
40
+ function failure(operation, error) {
41
+ return { ok: false, operation, error: errorDetails(error) };
42
+ }
43
+ function caught(operation, error) {
44
+ return failure(operation, error instanceof UlwLoopError ? error : new UlwLoopError(error.message, "ULW_LOOP_ERROR"));
45
+ }
46
+ function isKnownRequest(request) {
47
+ return ULW_LOOP_MANIFEST.operations.some((operation) => operation.name === request.operation);
48
+ }
49
+ function unreachable(value) {
50
+ throw new UlwLoopError(`Unhandled operation: ${String(value)}`, "ULW_LOOP_OPERATION_UNHANDLED");
51
+ }
52
+ function nextActionsFrom(result) {
53
+ if (!("nextActions" in result) || !Array.isArray(result.nextActions))
54
+ return [];
55
+ return result.nextActions.filter((action) => typeof action === "string").slice(0, 8);
56
+ }
57
+ function checkpointWithValidatedSnapshot(context, scope, args) {
58
+ validateCodexGoalJson(args.codexGoalJson);
59
+ return checkpointUlwLoop(context.cwd, args, scope, { surface: context.surface });
60
+ }
61
+ export function createAgentToolkit(context, deps = {}) {
62
+ validateContext(context);
63
+ const scope = { sessionId: context.sessionId };
64
+ const notify = async (operation, response) => {
65
+ if (deps.hooks?.onOperation !== undefined)
66
+ await deps.hooks.onOperation({ operation, context, response });
67
+ return response;
68
+ };
69
+ const invoke = async (operation, fn) => {
70
+ try {
71
+ const result = await fn();
72
+ const nextActions = typeof result === "object" && result !== null ? nextActionsFrom(result) : [];
73
+ return await notify(operation, { ok: true, operation, result, nextActions });
74
+ }
75
+ catch (error) {
76
+ const response = caught(operation, error instanceof Error ? error : new Error("ULW_LOOP_ERROR"));
77
+ return notify(operation, response);
78
+ }
79
+ };
80
+ const toolkit = {
81
+ dispatch: async (request) => {
82
+ if (!isKnownRequest(request))
83
+ return failure(request.operation, new UlwLoopError(`Unknown operation: ${request.operation}`, "ULW_LOOP_OPERATION_UNKNOWN"));
84
+ switch (request.operation) {
85
+ case "help":
86
+ return toolkit.help();
87
+ case "create-goals":
88
+ return toolkit.createGoals(request.args);
89
+ case "status":
90
+ return toolkit.status();
91
+ case "complete-goals":
92
+ return toolkit.completeGoals(request.args);
93
+ case "checkpoint":
94
+ return toolkit.checkpoint(request.args);
95
+ case "steer":
96
+ return toolkit.steer(request.args);
97
+ case "add-goal":
98
+ return toolkit.addGoal(request.args);
99
+ case "criteria":
100
+ return toolkit.criteria(request.args);
101
+ case "record-evidence":
102
+ return toolkit.recordEvidence(request.args);
103
+ case "record-review-blockers":
104
+ return toolkit.recordReviewBlockers(request.args);
105
+ default:
106
+ return unreachable(request);
107
+ }
108
+ },
109
+ help: () => invoke("help", async () => ULW_LOOP_MANIFEST),
110
+ createGoals: (args) => invoke("create-goals", () => createUlwLoopPlan(context.cwd, args, scope)),
111
+ status: () => invoke("status", async () => {
112
+ const plan = await readUlwLoopPlan(context.cwd, scope);
113
+ const active = plan.goals.find((goal) => goal.id === plan.activeGoalId);
114
+ return {
115
+ plan,
116
+ summary: summarizeUlwLoopPlan(plan),
117
+ nextActions: statusNextActions(plan),
118
+ // Attempt directories are an evidence-layout v2 concept; a v1 plan must not advertise one.
119
+ ...(active === undefined || plan.evidenceLayoutVersion !== 2
120
+ ? {}
121
+ : { currentAttemptDir: ulwLoopAttemptEvidenceDir(active.id, active.attempt, scope) }),
122
+ };
123
+ }),
124
+ completeGoals: (args = {}) => invoke("complete-goals", () => startNextUlwLoop(context.cwd, args, scope)),
125
+ checkpoint: (args) => invoke("checkpoint", () => args.printTemplate === true
126
+ ? checkpointTemplate(context.cwd, scope, args.goalId, { surface: context.surface })
127
+ : checkpointWithValidatedSnapshot(context, scope, args)),
128
+ steer: (args) => invoke("steer", () => steerUlwLoop(context.cwd, args, scope)),
129
+ addGoal: (args) => invoke("add-goal", () => addUlwLoopGoal(context.cwd, args, scope)),
130
+ criteria: (args) => invoke("criteria", async () => {
131
+ const plan = await readUlwLoopPlan(context.cwd, scope);
132
+ const goal = plan.goals.find((candidate) => candidate.id === args.goalId);
133
+ if (goal === undefined)
134
+ throw new UlwLoopError(`Unknown ulw-loop id: ${args.goalId}.`, "ULW_LOOP_GOAL_NOT_FOUND");
135
+ return { goalId: goal.id, criteria: goal.successCriteria };
136
+ }),
137
+ recordEvidence: (args) => invoke("record-evidence", () => recordEvidence(context.cwd, args, scope)),
138
+ recordReviewBlockers: (args) => invoke("record-review-blockers", () => recordFinalReviewBlockers(context.cwd, args, scope)),
139
+ };
140
+ return toolkit;
141
+ }
@@ -0,0 +1,46 @@
1
+ export declare const ULW_LOOP_OPERATIONS: readonly ["help", "create-goals", "status", "complete-goals", "checkpoint", "steer", "add-goal", "criteria", "record-evidence", "record-review-blockers"];
2
+ export type UlwLoopOperation = (typeof ULW_LOOP_OPERATIONS)[number];
3
+ export interface ToolkitOperationManifest {
4
+ readonly name: UlwLoopOperation;
5
+ readonly mutating: boolean;
6
+ }
7
+ export interface ToolkitManifest {
8
+ readonly version: 1;
9
+ readonly name: "ulw-loop";
10
+ readonly operations: readonly ToolkitOperationManifest[];
11
+ }
12
+ export declare const ULW_LOOP_MANIFEST: {
13
+ version: 1;
14
+ name: "ulw-loop";
15
+ operations: ({
16
+ name: "help";
17
+ mutating: false;
18
+ } | {
19
+ name: "create-goals";
20
+ mutating: true;
21
+ } | {
22
+ name: "status";
23
+ mutating: false;
24
+ } | {
25
+ name: "complete-goals";
26
+ mutating: true;
27
+ } | {
28
+ name: "checkpoint";
29
+ mutating: true;
30
+ } | {
31
+ name: "steer";
32
+ mutating: true;
33
+ } | {
34
+ name: "add-goal";
35
+ mutating: true;
36
+ } | {
37
+ name: "criteria";
38
+ mutating: false;
39
+ } | {
40
+ name: "record-evidence";
41
+ mutating: true;
42
+ } | {
43
+ name: "record-review-blockers";
44
+ mutating: true;
45
+ })[];
46
+ };
@@ -0,0 +1,28 @@
1
+ export const ULW_LOOP_OPERATIONS = [
2
+ "help",
3
+ "create-goals",
4
+ "status",
5
+ "complete-goals",
6
+ "checkpoint",
7
+ "steer",
8
+ "add-goal",
9
+ "criteria",
10
+ "record-evidence",
11
+ "record-review-blockers",
12
+ ];
13
+ export const ULW_LOOP_MANIFEST = {
14
+ version: 1,
15
+ name: "ulw-loop",
16
+ operations: [
17
+ { name: "help", mutating: false },
18
+ { name: "create-goals", mutating: true },
19
+ { name: "status", mutating: false },
20
+ { name: "complete-goals", mutating: true },
21
+ { name: "checkpoint", mutating: true },
22
+ { name: "steer", mutating: true },
23
+ { name: "add-goal", mutating: true },
24
+ { name: "criteria", mutating: false },
25
+ { name: "record-evidence", mutating: true },
26
+ { name: "record-review-blockers", mutating: true },
27
+ ],
28
+ };
@@ -0,0 +1,127 @@
1
+ import type { CheckpointUlwLoopArgs, CheckpointUlwLoopResult } from "../checkpoint.js";
2
+ import type { CheckpointTemplate } from "../checkpoint-template.js";
3
+ import type { recordEvidence } from "../evidence.js";
4
+ import type { addUlwLoopGoal, createUlwLoopPlan, startNextUlwLoop, summarizeUlwLoopPlan } from "../plan-crud.js";
5
+ import type { recordFinalReviewBlockers } from "../review-blockers.js";
6
+ import type { steerUlwLoop } from "../steering.js";
7
+ import type { UlwLoopSteeringProposal } from "../steering-types.js";
8
+ import type { UlwLoopToolkitSurface } from "../surface.js";
9
+ import type { UlwLoopPlan } from "../types.js";
10
+ import type { ULW_LOOP_MANIFEST, UlwLoopOperation } from "./manifest.js";
11
+ export type ToolkitSurface = UlwLoopToolkitSurface;
12
+ export interface ToolkitContext {
13
+ readonly cwd: string;
14
+ readonly sessionId: string;
15
+ readonly surface: ToolkitSurface;
16
+ }
17
+ export type CreateGoalsArgs = Parameters<typeof createUlwLoopPlan>[1];
18
+ export type CompleteGoalsArgs = NonNullable<Parameters<typeof startNextUlwLoop>[1]>;
19
+ export type SteerArgs = UlwLoopSteeringProposal;
20
+ export type AddGoalArgs = Parameters<typeof addUlwLoopGoal>[1];
21
+ export type RecordEvidenceArgs = Parameters<typeof recordEvidence>[1];
22
+ export type CriteriaArgs = {
23
+ readonly goalId: string;
24
+ };
25
+ export type CheckpointMutationArgs = CheckpointUlwLoopArgs & {
26
+ readonly printTemplate?: false;
27
+ };
28
+ export type CheckpointTemplateArgs = {
29
+ readonly printTemplate: true;
30
+ readonly goalId?: string;
31
+ };
32
+ export type CheckpointArgs = CheckpointMutationArgs | CheckpointTemplateArgs;
33
+ export type RecordReviewBlockersArgs = Parameters<typeof recordFinalReviewBlockers>[1];
34
+ export type ToolkitDispatchRequest = {
35
+ readonly operation: "help";
36
+ readonly args?: Record<never, never>;
37
+ } | {
38
+ readonly operation: "create-goals";
39
+ readonly args: CreateGoalsArgs;
40
+ } | {
41
+ readonly operation: "status";
42
+ readonly args?: Record<never, never>;
43
+ } | {
44
+ readonly operation: "complete-goals";
45
+ readonly args?: CompleteGoalsArgs;
46
+ } | {
47
+ readonly operation: "checkpoint";
48
+ readonly args: CheckpointArgs;
49
+ } | {
50
+ readonly operation: "steer";
51
+ readonly args: SteerArgs;
52
+ } | {
53
+ readonly operation: "add-goal";
54
+ readonly args: AddGoalArgs;
55
+ } | {
56
+ readonly operation: "criteria";
57
+ readonly args: CriteriaArgs;
58
+ } | {
59
+ readonly operation: "record-evidence";
60
+ readonly args: RecordEvidenceArgs;
61
+ } | {
62
+ readonly operation: "record-review-blockers";
63
+ readonly args: RecordReviewBlockersArgs;
64
+ };
65
+ export interface ToolkitUnknownRequest {
66
+ readonly operation: string;
67
+ readonly args?: Record<never, never>;
68
+ }
69
+ export interface ToolkitError {
70
+ readonly code: string;
71
+ readonly message: string;
72
+ readonly details?: Readonly<Record<string, string>>;
73
+ }
74
+ export interface ToolkitSuccess<Operation extends UlwLoopOperation, Result> {
75
+ readonly ok: true;
76
+ readonly operation: Operation;
77
+ readonly result: Result;
78
+ readonly nextActions: readonly string[];
79
+ readonly warnings?: readonly string[];
80
+ }
81
+ export interface ToolkitFailure<Operation extends string = string> {
82
+ readonly ok: false;
83
+ readonly operation: Operation;
84
+ readonly error: ToolkitError;
85
+ }
86
+ type StatusResult = {
87
+ readonly plan: UlwLoopPlan;
88
+ readonly summary: ReturnType<typeof summarizeUlwLoopPlan>;
89
+ readonly nextActions: readonly string[];
90
+ readonly currentAttemptDir?: string;
91
+ };
92
+ type ResultFor<Operation extends UlwLoopOperation> = Operation extends "help" ? typeof ULW_LOOP_MANIFEST : Operation extends "create-goals" ? Awaited<ReturnType<typeof createUlwLoopPlan>> : Operation extends "status" ? StatusResult : Operation extends "complete-goals" ? Awaited<ReturnType<typeof startNextUlwLoop>> : Operation extends "checkpoint" ? CheckpointUlwLoopResult | CheckpointTemplate : Operation extends "steer" ? Awaited<ReturnType<typeof steerUlwLoop>> : Operation extends "add-goal" ? Awaited<ReturnType<typeof addUlwLoopGoal>> : Operation extends "criteria" ? {
93
+ readonly goalId: string;
94
+ readonly criteria: UlwLoopPlan["goals"][number]["successCriteria"];
95
+ } : Operation extends "record-evidence" ? Awaited<ReturnType<typeof recordEvidence>> : Operation extends "record-review-blockers" ? Awaited<ReturnType<typeof recordFinalReviewBlockers>> : never;
96
+ export type ToolkitResultFor<Operation extends UlwLoopOperation> = ResultFor<Operation>;
97
+ export type ToolkitResponseFor<Operation extends UlwLoopOperation> = ToolkitSuccess<Operation, ResultFor<Operation>> | ToolkitFailure<Operation>;
98
+ export type ToolkitOperationResponse = {
99
+ [Operation in UlwLoopOperation]: ToolkitResponseFor<Operation>;
100
+ }[UlwLoopOperation];
101
+ export type ToolkitDispatchResponse = ToolkitOperationResponse | ToolkitFailure<string>;
102
+ export type ToolkitResponse<Result> = ToolkitSuccess<UlwLoopOperation, Result> | ToolkitFailure<string>;
103
+ export interface ToolkitOperationHookEvent<Operation extends UlwLoopOperation = UlwLoopOperation> {
104
+ readonly operation: Operation;
105
+ readonly context: ToolkitContext;
106
+ readonly response: ToolkitResponseFor<Operation>;
107
+ }
108
+ export interface ToolkitHostHooks {
109
+ readonly onOperation?: <Operation extends UlwLoopOperation>(event: ToolkitOperationHookEvent<Operation>) => void | Promise<void>;
110
+ }
111
+ export interface AgentToolkitDependencies {
112
+ readonly hooks?: ToolkitHostHooks;
113
+ }
114
+ export interface AgentToolkit {
115
+ readonly dispatch: (request: ToolkitDispatchRequest | ToolkitUnknownRequest) => Promise<ToolkitDispatchResponse>;
116
+ readonly help: () => Promise<ToolkitResponseFor<"help">>;
117
+ readonly createGoals: (args: CreateGoalsArgs) => Promise<ToolkitResponseFor<"create-goals">>;
118
+ readonly status: () => Promise<ToolkitResponseFor<"status">>;
119
+ readonly completeGoals: (args?: CompleteGoalsArgs) => Promise<ToolkitResponseFor<"complete-goals">>;
120
+ readonly checkpoint: (args: CheckpointArgs) => Promise<ToolkitResponseFor<"checkpoint">>;
121
+ readonly steer: (args: SteerArgs) => Promise<ToolkitResponseFor<"steer">>;
122
+ readonly addGoal: (args: AddGoalArgs) => Promise<ToolkitResponseFor<"add-goal">>;
123
+ readonly criteria: (args: CriteriaArgs) => Promise<ToolkitResponseFor<"criteria">>;
124
+ readonly recordEvidence: (args: RecordEvidenceArgs) => Promise<ToolkitResponseFor<"record-evidence">>;
125
+ readonly recordReviewBlockers: (args: RecordReviewBlockersArgs) => Promise<ToolkitResponseFor<"record-review-blockers">>;
126
+ }
127
+ export {};
@@ -0,0 +1,3 @@
1
+ export { createAgentToolkit } from "./sdk/factory.js";
2
+ export * from "./sdk/manifest.js";
3
+ export * from "./sdk/types.js";
@@ -0,0 +1,3 @@
1
+ export { createAgentToolkit } from "./sdk/factory.js";
2
+ export * from "./sdk/manifest.js";
3
+ export * from "./sdk/types.js";
@@ -4,5 +4,6 @@ export interface SpawnGuardOptions {
4
4
  readonly lockTimeoutMs?: number;
5
5
  }
6
6
  export declare function applySpawnGuards(payload: PreToolUsePayload, options?: SpawnGuardOptions): string;
7
+ export declare function applySpawnBudgetGuards(payload: PreToolUsePayload, options?: SpawnGuardOptions): string;
7
8
  export declare function runSpawnAdmissionRecorderCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream): Promise<void>;
8
9
  export declare function runSpawnGuardCli(stdin: NodeJS.ReadableStream, stdout: NodeJS.WritableStream): Promise<void>;
@@ -4,12 +4,18 @@ import { dirname, join } from "node:path";
4
4
  import { parsePreToolUsePayload } from "./codex-hook.js";
5
5
  import { isFinalRunCompletionCandidate } from "./goal-status.js";
6
6
  import { ulwLoopAttemptEvidenceDir, ulwLoopDir, ulwLoopStateLockPath } from "./paths.js";
7
+ import { spawnRoleDenial } from "./spawn-role-guard.js";
7
8
  import { isStateLockTimeout, withStateLockSync } from "./state-lock.js";
8
9
  import { GATE_REVIEWER_AGENT_NAMES, REVIEWER_ROLES_BY_SURFACE, resolveToolkitSurface, reviewerRolesFor, } from "./surface.js";
9
10
  // spawn_agent = v1; collaborationspawn_agent = the delimiter-free flattened v2
10
11
  // hook token from codex-rs hook_names.rs; collaboration.spawn_agent = the
11
12
  // dotted token observed live in the task-1 probe (hook-tool-tokens.txt).
12
- const SPAWN_TOOL_TOKENS = new Set(["spawn_agent", "collaborationspawn_agent", "collaboration.spawn_agent"]);
13
+ const SPAWN_TOOL_TOKENS = new Set([
14
+ "spawn_agent",
15
+ "multi_agent_v1.spawn_agent",
16
+ "collaborationspawn_agent",
17
+ "collaboration.spawn_agent",
18
+ ]);
13
19
  export const DEFAULT_FANOUT_LIMIT = 24;
14
20
  const DEFAULT_REVIEW_SPAWN_LIMIT = 3;
15
21
  const GATE_MESSAGE_PATTERN = /lazycodex-gate-reviewer|omo-senpi-gate-reviewer|final gate review/i;
@@ -20,6 +26,16 @@ const REVIEW_AGENT_TYPES = [
20
26
  ];
21
27
  const REVIEW_AGENT_TYPE_SET = new Set(REVIEW_AGENT_TYPES);
22
28
  export function applySpawnGuards(payload, options = {}) {
29
+ if (payload.hook_event_name !== "PreToolUse" || !SPAWN_TOOL_TOKENS.has(payload.tool_name))
30
+ return "";
31
+ if (resolveToolkitSurface() === "lazycodex") {
32
+ const reason = spawnRoleDenial(payload.tool_input);
33
+ if (reason !== null)
34
+ return deny(reason);
35
+ }
36
+ return applySpawnBudgetGuards(payload, options);
37
+ }
38
+ export function applySpawnBudgetGuards(payload, options = {}) {
23
39
  if (payload.hook_event_name !== "PreToolUse" || !SPAWN_TOOL_TOKENS.has(payload.tool_name))
24
40
  return "";
25
41
  const breaker = readAdmissionBreaker(payload.session_id);
@@ -93,15 +109,16 @@ export async function runSpawnGuardCli(stdin, stdout) {
93
109
  for await (const chunk of stdin)
94
110
  chunks.push(Buffer.from(chunk));
95
111
  const payload = parsePreToolUsePayload(Buffer.concat(chunks).toString("utf8"));
96
- if (payload === null)
112
+ if (payload === null) {
113
+ stdout.write(deny("LazyCodex spawn guard received an invalid hook payload; role routing was not verified."));
97
114
  return;
115
+ }
98
116
  const output = applySpawnGuards(payload);
99
117
  if (output.length > 0)
100
118
  stdout.write(output);
101
119
  }
102
120
  catch (error) {
103
- if (error instanceof Error)
104
- return;
121
+ stdout.write(deny(`LazyCodex spawn guard failed: ${error instanceof Error ? error.message : String(error)}`));
105
122
  }
106
123
  }
107
124
  // Read-only fan-out eligibility check. Returns a denial reason when the next
@@ -0,0 +1,2 @@
1
+ export declare const LAZYCODEX_SPAWN_ROLES: ReadonlySet<string>;
2
+ export declare function spawnRoleDenial(input: unknown): string | null;
@@ -0,0 +1,22 @@
1
+ // Explicit selectors, pinned by a test to the bundled role TOMLs. The generated
2
+ // default is a non-fork fallback, not a selector: a user can opt out of owning it.
3
+ export const LAZYCODEX_SPAWN_ROLES = new Set([
4
+ "explorer",
5
+ "lazycodex-clone-fidelity-reviewer",
6
+ "lazycodex-code-reviewer",
7
+ "lazycodex-gate-reviewer",
8
+ "lazycodex-qa-executor",
9
+ "lazycodex-worker-high",
10
+ "lazycodex-worker-low",
11
+ "lazycodex-worker-medium",
12
+ "librarian",
13
+ "metis",
14
+ "momus",
15
+ "plan",
16
+ ]);
17
+ export function spawnRoleDenial(input) {
18
+ const role = typeof input === "object" && input !== null && "agent_type" in input ? input.agent_type : undefined;
19
+ if (typeof role === "string" && LAZYCODEX_SPAWN_ROLES.has(role))
20
+ return null;
21
+ return `LazyCodex requires an explicit registered agent_type: ${[...LAZYCODEX_SPAWN_ROLES].join(", ")}. Received ${JSON.stringify(role) ?? "no agent_type"}. Use the matching role and fork_turns: "none" (V2) or fork_context: false (V1), unless full history is deliberately required. The hook cannot see the tool schema; if agent_type is unavailable, stop and report incompatible role routing rather than spawning a generic agent. Describing a role in message does not select its TOML.`;
22
+ }
@@ -7,20 +7,20 @@
7
7
  "type": "command",
8
8
  "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook user-prompt-submit --with-ultrawork",
9
9
  "timeout": 10,
10
- "statusMessage": "(OmO 5.0.0-beta.57) Checking Ulw-Loop Steering"
10
+ "statusMessage": "(OmO 5.0.0-beta.61) Checking Ulw-Loop Steering"
11
11
  }
12
12
  ]
13
13
  }
14
14
  ],
15
15
  "PostToolUse": [
16
16
  {
17
- "matcher": "^(spawn_agent|collaborationspawn_agent|collaboration\\.spawn_agent)$",
17
+ "matcher": "^(spawn_agent|multi_agent_v1\\.spawn_agent|collaborationspawn_agent|collaboration\\.spawn_agent)$",
18
18
  "hooks": [
19
19
  {
20
20
  "type": "command",
21
21
  "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-tool-use-spawn",
22
22
  "timeout": 5,
23
- "statusMessage": "(OmO 5.0.0-beta.57) Recording Spawn Admission"
23
+ "statusMessage": "(OmO 5.0.0-beta.61) Recording Spawn Admission"
24
24
  }
25
25
  ]
26
26
  }
@@ -33,18 +33,18 @@
33
33
  "type": "command",
34
34
  "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook pre-tool-use",
35
35
  "timeout": 5,
36
- "statusMessage": "(OmO 5.0.0-beta.57) Enforcing Unlimited Ulw-Loop Budget"
36
+ "statusMessage": "(OmO 5.0.0-beta.61) Enforcing Unlimited Ulw-Loop Budget"
37
37
  }
38
38
  ]
39
39
  },
40
40
  {
41
- "matcher": "^(spawn_agent|collaborationspawn_agent|collaboration\\.spawn_agent)$",
41
+ "matcher": "^(spawn_agent|multi_agent_v1\\.spawn_agent|collaborationspawn_agent|collaboration\\.spawn_agent)$",
42
42
  "hooks": [
43
43
  {
44
44
  "type": "command",
45
45
  "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook pre-tool-use-spawn",
46
46
  "timeout": 5,
47
- "statusMessage": "(OmO 5.0.0-beta.57) Guarding Ulw-Loop Spawns"
47
+ "statusMessage": "(OmO 5.0.0-beta.61) Guarding Ulw-Loop Spawns"
48
48
  }
49
49
  ]
50
50
  }
@@ -56,7 +56,7 @@
56
56
  "type": "command",
57
57
  "command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook stop",
58
58
  "timeout": 10,
59
- "statusMessage": "(OmO 5.0.0-beta.57) Checking Ulw-Loop Resume"
59
+ "statusMessage": "(OmO 5.0.0-beta.61) Checking Ulw-Loop Resume"
60
60
  }
61
61
  ]
62
62
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/codex-ulw-loop",
3
- "version": "5.0.0-beta.57",
3
+ "version": "5.0.0-beta.61",
4
4
  "description": "Codex plugin: durable repo-native multi-goal orchestration with embedded success criteria and observable evidence audit.",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.12.1",
@@ -68,3 +68,7 @@ Codex exposes ONE subagent surface per session — check your tool list. GPT-5.6
68
68
  V1 fallback (gpt-5.5, gpt-5.6-luna): `multi_agent_v1.spawn_agent({...,"fork_context":false})`, `multi_agent_v1.send_input` (re-task), `multi_agent_v1.wait_agent({"targets":[...],"timeout_ms":...})`, `multi_agent_v1.close_agent`.
69
69
 
70
70
  When translating `load_skills=[...]`, include the requested skill names in the spawned agent's `message`.
71
+
72
+ ## Driver goal lifecycle
73
+
74
+ The Codex thread goal is a DRIVER the loop instructs, never a gate. `checkpoint` takes an OPTIONAL `--codex-goal-json` snapshot, records it verbatim in the ledger, and never rejects on its status or objective; the advice arrives in `nextActions`. A driver completed early yields advice to `create_goal` again with the plan's objective verbatim; `paused`, `usage_limited`, and `budget_limited` yield resume advice; a differing objective is a warning, not a refusal. Malformed snapshot input is the only failure, reported as `ULW_LOOP_CODEX_GOAL_JSON_INVALID`.
@@ -11,6 +11,10 @@ export interface CheckpointTemplate {
11
11
  readonly guidance?: string;
12
12
  }
13
13
 
14
+ export interface CheckpointTemplateDependencies {
15
+ readonly surface?: UlwLoopToolkitSurface;
16
+ }
17
+
14
18
  function artifactPath(base: string, name: string): string {
15
19
  return `${base}/${name}`;
16
20
  }
@@ -97,8 +101,10 @@ export async function checkpointTemplate(
97
101
  repoRoot: string,
98
102
  scope?: UlwLoopScope,
99
103
  goalId?: string,
104
+ dependencies?: CheckpointTemplateDependencies,
100
105
  ): Promise<CheckpointTemplate> {
101
106
  const plan: UlwLoopPlan = await readUlwLoopPlan(repoRoot, scope);
107
+ const surface = dependencies?.surface ?? resolveToolkitSurface();
102
108
  const targetId = goalId ?? plan.activeGoalId;
103
109
  const active = plan.goals.find((goal) => goal.id === targetId);
104
110
  if (goalId !== undefined && active === undefined)
@@ -110,7 +116,7 @@ export async function checkpointTemplate(
110
116
  "Fill every <replace:...> value with plausible non-empty evidence and use real, non-empty artifact files.",
111
117
  'Passing codex-goal-json example: {"goal":{"objective":"<plan codexObjective verbatim>","status":"complete"}}.',
112
118
  'Passing quality-gate-json example requires gateReview {"by":"category:deep","recommendation":"APPROVE","evidence":"review passed","reportPath":"<attemptDir>/gate-review.md","blockers":[],"notes":[]}, manualQa.artifactRefs objects, iteration, and criteriaCoverage.',
113
- ...(resolveToolkitSurface() === "lazycodex"
119
+ ...(surface === "lazycodex"
114
120
  ? [
115
121
  "Self-review defaults: manualQa.by and gateReview.by are main-session. Alternatives: manualQa.by accepts lazycodex-qa-executor; gateReview.by accepts lazycodex-gate-reviewer, category:deep, category:unspecified-high, or category:unspecified-low. Optional codeReview.by accepts lazycodex-code-reviewer or main-session.",
116
122
  ]
@@ -118,7 +124,7 @@ export async function checkpointTemplate(
118
124
  ...(hasAttempt ? [] : ["This plan is evidence-layout v1; artifacts go under .omo/evidence/."]),
119
125
  ].join(" ");
120
126
  return {
121
- qualityGateTemplate: gateTemplate(resolveToolkitSurface(), attemptDir),
127
+ qualityGateTemplate: gateTemplate(surface, attemptDir),
122
128
  codexGoalTemplate: {
123
129
  goal: { objective: plan.codexObjective ?? "<replace:codex objective>", status: "complete" },
124
130
  },
@@ -17,7 +17,7 @@ import {
17
17
  sameBlockerOccurrences,
18
18
  validateQualityGate,
19
19
  } from "./quality-gate.js";
20
- import { resolveToolkitSurface } from "./surface.js";
20
+ import { resolveToolkitSurface, type UlwLoopToolkitSurface } from "./surface.js";
21
21
  import type {
22
22
  UlwLoopAggregateCompletion,
23
23
  UlwLoopItem,
@@ -35,6 +35,9 @@ export interface CheckpointUlwLoopArgs {
35
35
  readonly codexGoalJson?: string;
36
36
  readonly qualityGateJson?: string;
37
37
  }
38
+ export interface CheckpointUlwLoopDependencies {
39
+ readonly surface?: UlwLoopToolkitSurface;
40
+ }
38
41
  export interface CheckpointUlwLoopResult {
39
42
  readonly plan: UlwLoopPlan;
40
43
  readonly goal: UlwLoopItem;
@@ -151,6 +154,7 @@ export async function checkpointUlwLoop(
151
154
  repoRoot: string,
152
155
  args: CheckpointUlwLoopArgs,
153
156
  scope?: UlwLoopScope,
157
+ dependencies?: CheckpointUlwLoopDependencies,
154
158
  ): Promise<CheckpointUlwLoopResult> {
155
159
  return withUlwLoopMutationLock(repoRoot, scope, async () => {
156
160
  const plan = await readUlwLoopPlan(repoRoot, scope);
@@ -198,7 +202,7 @@ export async function checkpointUlwLoop(
198
202
  qualityGate = validateQualityGate(await readJsonInput(args.qualityGateJson, repoRoot), {
199
203
  repoRoot,
200
204
  fs: QUALITY_GATE_FS,
201
- reviewerSurface: resolveToolkitSurface(),
205
+ reviewerSurface: dependencies?.surface ?? resolveToolkitSurface(),
202
206
  ...(plan.evidenceLayoutVersion === 2
203
207
  ? { currentAttemptDir: ulwLoopAttemptEvidenceDir(goal.id, goal.attempt, scope) }
204
208
  : {}),