@kody-ade/kody-engine 0.4.636 → 0.4.638

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/bin/kody.js +42 -2
  2. package/package.json +1 -1
package/dist/bin/kody.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@kody-ade/kody-engine",
18
- version: "0.4.636",
18
+ version: "0.4.638",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
20
20
  license: "MIT",
21
21
  repository: {
@@ -181,6 +181,25 @@ var init_completionGuard = __esm({
181
181
  });
182
182
 
183
183
  // src/submitStateGuard.ts
184
+ function createSubmitStateActivityGuard() {
185
+ let hasActivity = false;
186
+ return {
187
+ recordToolUse: async (input) => {
188
+ if (input?.tool_name !== SUBMIT_STATE_TOOL) hasActivity = true;
189
+ return {};
190
+ },
191
+ requireActivity: async () => hasActivity ? {} : {
192
+ decision: "block",
193
+ reason: ACTIVITY_REQUIRED_REASON
194
+ }
195
+ };
196
+ }
197
+ function createPostSubmitToolGuard(getSubmitted) {
198
+ return async () => getSubmitted() ? {
199
+ decision: "block",
200
+ reason: STATE_ALREADY_SUBMITTED_REASON
201
+ } : {};
202
+ }
184
203
  function createSubmitStateStopHook(getSubmitted) {
185
204
  let finalChanceGiven = false;
186
205
  return async () => {
@@ -193,11 +212,14 @@ function createSubmitStateStopHook(getSubmitted) {
193
212
  };
194
213
  };
195
214
  }
196
- var FINAL_STATE_CHANCE_REASON;
215
+ var FINAL_STATE_CHANCE_REASON, STATE_ALREADY_SUBMITTED_REASON, ACTIVITY_REQUIRED_REASON, SUBMIT_STATE_TOOL;
197
216
  var init_submitStateGuard = __esm({
198
217
  "src/submitStateGuard.ts"() {
199
218
  "use strict";
200
219
  FINAL_STATE_CHANCE_REASON = "Before finishing, call `submit_state` exactly once with the next non-empty `cursor`, compact durable `data`, and the correct `done` value. Do not perform more work; submit only the continuation state now.";
220
+ STATE_ALREADY_SUBMITTED_REASON = "Continuation state is already submitted for this cycle. Do not call more tools or perform more work; return your final response now.";
221
+ ACTIVITY_REQUIRED_REASON = "Do not submit continuation state yet. First use a tool to observe current evidence or perform the next responsibility action for this cycle.";
222
+ SUBMIT_STATE_TOOL = "mcp__kody-submit__submit_state";
201
223
  }
202
224
  });
203
225
 
@@ -4437,6 +4459,8 @@ async function runAgent(opts) {
4437
4459
  const outputContractPostWriteHook = opts.outputContract ? createOutputContractPostWriteHook(opts.outputContract) : null;
4438
4460
  const outputContractStopHook = opts.outputContract ? createOutputContractStopHook(opts.outputContract) : null;
4439
4461
  const submitStateStopHook = opts.enableSubmitTool ? createSubmitStateStopHook(() => getSubmitted?.()) : null;
4462
+ const postSubmitToolGuard = opts.enableSubmitTool ? createPostSubmitToolGuard(() => getSubmitted?.()) : null;
4463
+ const submitStateActivityGuard = opts.enableSubmitTool ? createSubmitStateActivityGuard() : null;
4440
4464
  let finalSafeToReplay = true;
4441
4465
  for (let attempt = 0; ; attempt++) {
4442
4466
  let ndjsonWriteFailed = false;
@@ -4475,11 +4499,22 @@ async function runAgent(opts) {
4475
4499
  env,
4476
4500
  hooks: {
4477
4501
  PreToolUse: [
4502
+ ...postSubmitToolGuard ? [
4503
+ {
4504
+ hooks: [postSubmitToolGuard]
4505
+ }
4506
+ ] : [],
4478
4507
  ...completionGuard ? [
4479
4508
  {
4480
4509
  hooks: [completionGuard]
4481
4510
  }
4482
4511
  ] : [],
4512
+ ...submitStateActivityGuard ? [
4513
+ {
4514
+ matcher: "mcp__kody-submit__submit_state",
4515
+ hooks: [submitStateActivityGuard.requireActivity]
4516
+ }
4517
+ ] : [],
4483
4518
  {
4484
4519
  matcher: "Agent",
4485
4520
  hooks: [enforceSubagentModelInheritance]
@@ -4490,6 +4525,11 @@ async function runAgent(opts) {
4490
4525
  }
4491
4526
  ],
4492
4527
  PostToolUse: [
4528
+ ...submitStateActivityGuard ? [
4529
+ {
4530
+ hooks: [submitStateActivityGuard.recordToolUse]
4531
+ }
4532
+ ] : [],
4493
4533
  {
4494
4534
  matcher: "Agent",
4495
4535
  hooks: [subagentInvocationHook]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.636",
3
+ "version": "0.4.638",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
5
5
  "license": "MIT",
6
6
  "repository": {