kiokuko-dsh 0.2.4 → 0.2.6

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 (170) hide show
  1. package/dist/client.cjs +78 -8
  2. package/dist/dsh/agenticreplay-event-mapper.d.ts +7 -0
  3. package/dist/dsh/agenticreplay-event-mapper.d.ts.map +1 -1
  4. package/dist/dsh/agenticreplay-event-mapper.js +52 -13
  5. package/dist/dsh/agenticreplay-event-mapper.js.map +1 -1
  6. package/dist/dsh/agenticreplay-hooks.d.ts.map +1 -1
  7. package/dist/dsh/agenticreplay-hooks.js +10 -1
  8. package/dist/dsh/agenticreplay-hooks.js.map +1 -1
  9. package/dist/dsh/agenticreplay-recorder.d.ts +5 -0
  10. package/dist/dsh/agenticreplay-recorder.d.ts.map +1 -1
  11. package/dist/dsh/agenticreplay-recorder.js +193 -20
  12. package/dist/dsh/agenticreplay-recorder.js.map +1 -1
  13. package/dist/dsh/answer-context.d.ts +8 -6
  14. package/dist/dsh/answer-context.d.ts.map +1 -1
  15. package/dist/dsh/answer-context.js +85 -21
  16. package/dist/dsh/answer-context.js.map +1 -1
  17. package/dist/dsh/coding-workflow/contracts.d.ts +5 -0
  18. package/dist/dsh/coding-workflow/contracts.d.ts.map +1 -1
  19. package/dist/dsh/coding-workflow/contracts.js +20 -3
  20. package/dist/dsh/coding-workflow/contracts.js.map +1 -1
  21. package/dist/dsh/coding-workflow/host.d.ts +4 -1
  22. package/dist/dsh/coding-workflow/host.d.ts.map +1 -1
  23. package/dist/dsh/coding-workflow/host.js +72 -44
  24. package/dist/dsh/coding-workflow/host.js.map +1 -1
  25. package/dist/dsh/coding-workflow/intent.d.ts +8 -0
  26. package/dist/dsh/coding-workflow/intent.d.ts.map +1 -1
  27. package/dist/dsh/coding-workflow/intent.js +33 -2
  28. package/dist/dsh/coding-workflow/intent.js.map +1 -1
  29. package/dist/dsh/coding-workflow/service.d.ts +214 -0
  30. package/dist/dsh/coding-workflow/service.d.ts.map +1 -1
  31. package/dist/dsh/coding-workflow/service.js +86 -6
  32. package/dist/dsh/coding-workflow/service.js.map +1 -1
  33. package/dist/dsh/coding-workflow/store.d.ts.map +1 -1
  34. package/dist/dsh/coding-workflow/store.js +10 -1
  35. package/dist/dsh/coding-workflow/store.js.map +1 -1
  36. package/dist/dsh/core/host.d.ts.map +1 -1
  37. package/dist/dsh/core/host.js +288 -48
  38. package/dist/dsh/core/host.js.map +1 -1
  39. package/dist/dsh/core/tasks.d.ts +7 -0
  40. package/dist/dsh/core/tasks.d.ts.map +1 -1
  41. package/dist/dsh/core/tasks.js +59 -8
  42. package/dist/dsh/core/tasks.js.map +1 -1
  43. package/dist/dsh/decisions/contracts.d.ts +3 -2
  44. package/dist/dsh/decisions/contracts.d.ts.map +1 -1
  45. package/dist/dsh/decisions/contracts.js +1 -1
  46. package/dist/dsh/decisions/contracts.js.map +1 -1
  47. package/dist/dsh/decisions/request-intent.d.ts +121 -0
  48. package/dist/dsh/decisions/request-intent.d.ts.map +1 -0
  49. package/dist/dsh/decisions/request-intent.js +260 -0
  50. package/dist/dsh/decisions/request-intent.js.map +1 -0
  51. package/dist/dsh/decisions/service.d.ts +5 -1
  52. package/dist/dsh/decisions/service.d.ts.map +1 -1
  53. package/dist/dsh/decisions/service.js +2 -1
  54. package/dist/dsh/decisions/service.js.map +1 -1
  55. package/dist/dsh/execution-selection.d.ts +13 -0
  56. package/dist/dsh/execution-selection.d.ts.map +1 -1
  57. package/dist/dsh/execution-selection.js +11 -0
  58. package/dist/dsh/execution-selection.js.map +1 -1
  59. package/dist/dsh/execution-support.d.ts +2 -0
  60. package/dist/dsh/execution-support.d.ts.map +1 -1
  61. package/dist/dsh/execution-support.js +36 -8
  62. package/dist/dsh/execution-support.js.map +1 -1
  63. package/dist/dsh/head-worker-configuration.d.ts +27 -0
  64. package/dist/dsh/head-worker-configuration.d.ts.map +1 -0
  65. package/dist/dsh/head-worker-configuration.js +69 -0
  66. package/dist/dsh/head-worker-configuration.js.map +1 -0
  67. package/dist/dsh/host-adapter/admission.d.ts +4 -1
  68. package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
  69. package/dist/dsh/host-adapter/admission.js +297 -12
  70. package/dist/dsh/host-adapter/admission.js.map +1 -1
  71. package/dist/dsh/host-adapter/routing.d.ts +4 -1
  72. package/dist/dsh/host-adapter/routing.d.ts.map +1 -1
  73. package/dist/dsh/host-adapter/routing.js +42 -23
  74. package/dist/dsh/host-adapter/routing.js.map +1 -1
  75. package/dist/dsh/host-adapter/turn-state.d.ts +6 -0
  76. package/dist/dsh/host-adapter/turn-state.d.ts.map +1 -1
  77. package/dist/dsh/host-adapter/turn-state.js +19 -1
  78. package/dist/dsh/host-adapter/turn-state.js.map +1 -1
  79. package/dist/dsh/host-adapter.d.ts.map +1 -1
  80. package/dist/dsh/host-adapter.js +217 -9
  81. package/dist/dsh/host-adapter.js.map +1 -1
  82. package/dist/dsh/intake-clarification.d.ts +2 -2
  83. package/dist/dsh/intake-clarification.d.ts.map +1 -1
  84. package/dist/dsh/intake-clarification.js +13 -4
  85. package/dist/dsh/intake-clarification.js.map +1 -1
  86. package/dist/dsh/intake-gate.d.ts +5 -0
  87. package/dist/dsh/intake-gate.d.ts.map +1 -1
  88. package/dist/dsh/intake-gate.js +19 -5
  89. package/dist/dsh/intake-gate.js.map +1 -1
  90. package/dist/dsh/lisp/candidate.d.ts +1 -1
  91. package/dist/dsh/lisp/surface.d.ts +1 -1
  92. package/dist/dsh/memory-owner.d.ts +24 -0
  93. package/dist/dsh/memory-owner.d.ts.map +1 -0
  94. package/dist/dsh/memory-owner.js +35 -0
  95. package/dist/dsh/memory-owner.js.map +1 -0
  96. package/dist/dsh/memory-request-fence.d.ts +37 -0
  97. package/dist/dsh/memory-request-fence.d.ts.map +1 -0
  98. package/dist/dsh/memory-request-fence.js +48 -0
  99. package/dist/dsh/memory-request-fence.js.map +1 -0
  100. package/dist/dsh/message-sources.d.ts.map +1 -1
  101. package/dist/dsh/message-sources.js +2 -1
  102. package/dist/dsh/message-sources.js.map +1 -1
  103. package/dist/dsh/model-selection-ui.d.ts +2 -0
  104. package/dist/dsh/model-selection-ui.d.ts.map +1 -1
  105. package/dist/dsh/model-selection-ui.js +69 -5
  106. package/dist/dsh/model-selection-ui.js.map +1 -1
  107. package/dist/dsh/models/contracts.d.ts +30 -2
  108. package/dist/dsh/models/contracts.d.ts.map +1 -1
  109. package/dist/dsh/models/contracts.js +6 -0
  110. package/dist/dsh/models/contracts.js.map +1 -1
  111. package/dist/dsh/models/profiles.d.ts +25 -0
  112. package/dist/dsh/models/profiles.d.ts.map +1 -1
  113. package/dist/dsh/models/profiles.js +34 -1
  114. package/dist/dsh/models/profiles.js.map +1 -1
  115. package/dist/dsh/models/service.d.ts +67 -3
  116. package/dist/dsh/models/service.d.ts.map +1 -1
  117. package/dist/dsh/models/service.js +210 -30
  118. package/dist/dsh/models/service.js.map +1 -1
  119. package/dist/dsh/models/session-selection.d.ts +25 -0
  120. package/dist/dsh/models/session-selection.d.ts.map +1 -0
  121. package/dist/dsh/models/session-selection.js +16 -0
  122. package/dist/dsh/models/session-selection.js.map +1 -0
  123. package/dist/dsh/models/surface.d.ts +1 -0
  124. package/dist/dsh/models/surface.d.ts.map +1 -1
  125. package/dist/dsh/models/surface.js +24 -4
  126. package/dist/dsh/models/surface.js.map +1 -1
  127. package/dist/dsh/native-worker-routing.d.ts +69 -0
  128. package/dist/dsh/native-worker-routing.d.ts.map +1 -0
  129. package/dist/dsh/native-worker-routing.js +147 -0
  130. package/dist/dsh/native-worker-routing.js.map +1 -0
  131. package/dist/dsh/on-demand-intake.d.ts +71 -5
  132. package/dist/dsh/on-demand-intake.d.ts.map +1 -1
  133. package/dist/dsh/on-demand-intake.js +299 -70
  134. package/dist/dsh/on-demand-intake.js.map +1 -1
  135. package/dist/dsh/owned-execution.d.ts +3 -0
  136. package/dist/dsh/owned-execution.d.ts.map +1 -1
  137. package/dist/dsh/owned-execution.js +7 -0
  138. package/dist/dsh/owned-execution.js.map +1 -1
  139. package/dist/dsh/request-memory.d.ts +2 -0
  140. package/dist/dsh/request-memory.d.ts.map +1 -1
  141. package/dist/dsh/request-memory.js +33 -2
  142. package/dist/dsh/request-memory.js.map +1 -1
  143. package/dist/dsh/setup.d.ts +2 -2
  144. package/dist/dsh/setup.d.ts.map +1 -1
  145. package/dist/dsh/setup.js +37 -14
  146. package/dist/dsh/setup.js.map +1 -1
  147. package/dist/dsh/skill-prompts.json +1 -1
  148. package/dist/dsh/standard-skills.d.ts +2 -1
  149. package/dist/dsh/standard-skills.d.ts.map +1 -1
  150. package/dist/dsh/standard-skills.js +2 -1
  151. package/dist/dsh/standard-skills.js.map +1 -1
  152. package/dist/dsh/task-intake.d.ts +6 -0
  153. package/dist/dsh/task-intake.d.ts.map +1 -1
  154. package/dist/dsh/task-intake.js +7 -2
  155. package/dist/dsh/task-intake.js.map +1 -1
  156. package/dist/locale/en.json +1 -1
  157. package/dist/locale/ja.json +1 -1
  158. package/dist/locale/ko.json +1 -1
  159. package/dist/locale/zh-CN.json +1 -1
  160. package/dist/models-client.cjs +78 -8
  161. package/dist/models-client.d.ts.map +1 -1
  162. package/dist/models-client.js +76 -8
  163. package/dist/models-client.js.map +1 -1
  164. package/docs/coding-workflow.md +3 -1
  165. package/docs/dsh-plugin.md +28 -5
  166. package/docs/kiokuko-models.md +47 -0
  167. package/docs/on-demand-intake.md +13 -7
  168. package/migrations/037_native_worker_routing.sql +8 -0
  169. package/package.json +3 -2
  170. package/skills/japanese-translation-for-oss-models/SKILL.md +5 -3
@@ -1,6 +1,7 @@
1
1
  import type { TaskType } from '../../akinator/types.js';
2
2
  import { createTurnState } from '../host-adapter/turn-state.js';
3
3
  import type { DecisionService } from '../decisions/service.js';
4
+ import { type RequestIntentDecision, type RequestIntentInterpretation } from '../decisions/request-intent.js';
4
5
  import { AnswerReviewCoordinator } from '../answer-review/coordinator.js';
5
6
  import { AutoMemoryReviewCoordinator } from '../auto-memory-review.js';
6
7
  import { DshEnnoMemoryRefresh } from '../enno-memory-refresh.js';
@@ -70,7 +71,9 @@ interface AdmissionOwner {
70
71
  readonly gate: DshIntakeGate & {
71
72
  prepareRequestedWork(event: DshPreStepEvent): Promise<DshIntakeGateResult>;
72
73
  };
73
- readonly mapPreStep: (payload: DshNativePreStepPayload, advisoryType?: TaskType) => Promise<DshPreStepEvent>;
74
+ readonly mapPreStep: (payload: DshNativePreStepPayload, advisoryType?: TaskType, requestIntent?: RequestIntentDecision) => Promise<DshPreStepEvent>;
75
+ readonly interpret: (payload: DshNativePreStepPayload) => Promise<RequestIntentInterpretation | undefined>;
76
+ readonly refreshMemoryOwner: (item: TurnRecord, signal: AbortSignal) => Promise<void>;
74
77
  readonly clear: () => void;
75
78
  }
76
79
  export declare function createAdmission({ native, skills, tools, userQuestions, sessions, agents, deepPlanning, modelCatalog, modelCompatibility, modelRoutes, now, runtime, decisions, answerReview, delegation, executionSupport, ennoMemory, memoryFinalizer, autoReview, sessionMirror, akinatorMemoryConfig, memoryRetrievalConfig, completionMode, turnState, getSelection, setSelection, refreshEnnoMemory, executionBinding, captureInitialInput, contextMessages, resolveIdleClose, retireSupersededRun, cancelBoundarySession, isSelectionBlocked, closeTurn, readStateForRun, capabilityCatalog, sessionEventSource, objectRecord, isHumanMessage, textFromMessages, pluginContinuationId, isLoopRecoveryMessage, }: AdmissionDependencies): AdmissionOwner;
@@ -1 +1 @@
1
- {"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../../../src/dsh/host-adapter/admission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAe,MAAM,+BAA+B,CAAA;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAI9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE,OAAO,EAAE,2BAA2B,EAA4B,MAAM,0BAA0B,CAAA;AAEhG,O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,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;IACnJ,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAAA;IAC1G,QAAQ,CAAC,kBAAkB,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrF,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EACtG,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAChF,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,EACnH,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAC1E,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAC3E,qBAAqB,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe,EACrE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,cAAc,EACnE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,GAC9D,EAAE,qBAAqB,GAAG,cAAc,CA26BxC"}
@@ -3,10 +3,12 @@ import { bindMemoryApplication, memoryRetrievalStatus } from '../../memory/appli
3
3
  import { createMemoryReuseRuntime } from '../memory-reuse.js';
4
4
  import { dshTurnRequestId } from '../intake-profile-resolver.js';
5
5
  import { classifyTaskForIntake, selectInstalledSkills } from '../decisions/workflows.js';
6
+ import { classifyRequestIntent, createRequestIntentContext, rebindRequestIntentDecision, requestIntentMessageRefs, requestIntentReferenceIds, requestIntentTaskType } from '../decisions/request-intent.js';
6
7
  import { ANSWER_REVIEW_FORM, hasHumanInput } from '../answer-review/contracts.js';
7
8
  import { refreshContinuedTaskContext } from '../task-intake.js';
8
9
  import { saveSessionNotice } from '../plugin-records.js';
9
10
  import { explicitExecutionMode, initializeExecutionSelection, readExecutionSelection, writeExecutionSelection } from '../execution-selection.js';
11
+ import { getHeadWorkerForSession } from '../models/session-selection.js';
10
12
  import { selectExecution, ExecutionSelectionPending } from '../model-selection-ui.js';
11
13
  import { ennoStateForPreparedTask } from '../../enno-oduno/service.js';
12
14
  import { realpathSync } from 'node:fs';
@@ -28,8 +30,12 @@ import { ENNO_APPLICABLE_TASK_TYPES } from '../../enno-oduno/types.js';
28
30
  import { supersedeBoundaryJobsAtOrBeforeRevisionInTransaction, supersedeOutboxAtOrBeforeRevisionInTransaction } from '../turn-process.js';
29
31
  import { unexecutedRunInput } from '../input-claim.js';
30
32
  import { resetLoopGuardForUserInTransaction } from '../loop-guard.js';
31
- import { codingContinuation } from '../coding-workflow/intent.js';
32
33
  import { readCodingWorkflow } from '../coding-workflow/store.js';
34
+ import { markCodingScopeChange } from '../coding-workflow/service.js';
35
+ import { readExecutionFrame } from '../execution-frame.js';
36
+ import { assertMemoryOwner, createMemoryOwner, memoryOwnerKind } from '../memory-owner.js';
37
+ import { findSecret } from '../../memory/secrets.js';
38
+ import { executionClarification, isContinuationReference } from '../intake-clarification.js';
33
39
  export function createAdmission({ native, skills, tools, userQuestions, sessions, agents, deepPlanning, modelCatalog, modelCompatibility, modelRoutes, now, runtime, decisions, answerReview, delegation, executionSupport, ennoMemory, memoryFinalizer, autoReview, sessionMirror, akinatorMemoryConfig, memoryRetrievalConfig, completionMode, turnState, getSelection, setSelection, refreshEnnoMemory, executionBinding, captureInitialInput, contextMessages, resolveIdleClose, retireSupersededRun, cancelBoundarySession, isSelectionBlocked, closeTurn, readStateForRun, capabilityCatalog, sessionEventSource, objectRecord, isHumanMessage, textFromMessages, pluginContinuationId, isLoopRecoveryMessage, }) {
34
40
  const currentSession = turnState.currentSession;
35
41
  const currentForAgentEvent = turnState.currentForAgentEvent;
@@ -45,6 +51,16 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
45
51
  }).profileHints.taskType;
46
52
  return incomingType !== null && !ENNO_APPLICABLE_TASK_TYPES.includes(incomingType);
47
53
  }
54
+ function eventTurn(event) {
55
+ const data = typeof event.data === 'object' && event.data !== null && !Array.isArray(event.data)
56
+ ? event.data : undefined;
57
+ return Number.isSafeInteger(data?.turn) ? data.turn : undefined;
58
+ }
59
+ function continuesCodingScope(event) {
60
+ const intent = event.requestIntent;
61
+ return !!intent && (intent.relation === 'same_scope_continuation' || intent.relation === 'scope_change')
62
+ && intent.action !== 'answer' && intent.action !== 'unknown';
63
+ }
48
64
  let prepareGeneration = 0;
49
65
  const continuedTurns = new Map();
50
66
  const resumedTurns = new Map();
@@ -83,7 +99,11 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
83
99
  },
84
100
  });
85
101
  }
86
- if (result.admitted && result.prepared.run.status === 'active' && currentSession(event.sessionId)?.prepareGeneration === generation && !delegation.isChild(event.nativeAgent ?? {})) {
102
+ if (result.admitted && event.requestIntent?.relation !== 'scope_change' && result.prepared.run.status === 'active'
103
+ && result.prepared.memoryOwner?.kind === 'execution'
104
+ && currentSession(event.sessionId)?.prepareGeneration === generation && !delegation.isChild(event.nativeAgent ?? {})) {
105
+ assertMemoryOwner(result.prepared.memoryOwner, { agentId: event.agent.id, sessionId: event.sessionId, turn: event.turn,
106
+ requestDigest: canonicalContentHash(event.task), runId: result.prepared.run.runId }, 'execution');
87
107
  await runtime.withDatabase(db => {
88
108
  if (currentSession(event.sessionId)?.prepareGeneration !== generation)
89
109
  return;
@@ -100,6 +120,18 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
100
120
  catch { /* Unsupported or unavailable review source must not veto a native request. */ }
101
121
  }
102
122
  };
123
+ async function hasPendingExecutionDiscussion(sessionId, cwd) {
124
+ return runtime.withDatabase(async (db) => {
125
+ const project = await resolveProjectWorkspaceReadOnly(db, cwd, { allowDirectory: true });
126
+ if (!project)
127
+ return false;
128
+ const activeRuns = db.prepare(`SELECT run_id FROM ledger_runs
129
+ WHERE workspace=? AND dsh_session_id=? AND status='active'`).all(project.workspace, sessionId);
130
+ if (activeRuns.length !== 1)
131
+ return false;
132
+ return readExecutionSelection(db, activeRuns[0].run_id)?.value.discussion !== undefined;
133
+ });
134
+ }
103
135
  const refreshContinuedWorkLease = async (item, expected) => {
104
136
  const expectedWorkUnitId = expected.nextAction === 'execute_work_unit'
105
137
  ? expected.directive?.workUnit?.id
@@ -177,8 +209,10 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
177
209
  return result;
178
210
  }
179
211
  setSelection(runId, stored);
212
+ const savedHeadWorker = await getHeadWorkerForSession(native.get('llm', false), event.sessionId);
180
213
  const selected = await selectExecution({
181
214
  task: event.task, turn: event.turn, signal: event.signal, stored, routes: modelRoutes ?? [],
215
+ ...(savedHeadWorker ? { savedHeadWorker } : {}),
182
216
  ...(event.nativeAgent ? { agent: event.nativeAgent } : {}),
183
217
  ...(userQuestions ? { questions: userQuestions } : {}),
184
218
  ...(modelCatalog ? { llm: modelCatalog } : {}),
@@ -200,7 +234,8 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
200
234
  // context deliveries that finish out of order.
201
235
  const generation = ++prepareGeneration;
202
236
  const prior = currentForAgentEvent(event.agent.id, event.sessionId, undefined, event.nativeSession, event.nativeAgent);
203
- if (prior && prior.turn === event.turn && !prior.closed && prior.task !== event.task && hasHumanInput(event.nativeMessages ?? [])) {
237
+ if (prior && prior.turn === event.turn && !prior.closed && prior.task !== event.task && hasHumanInput(event.nativeMessages ?? [])
238
+ && event.requestIntent?.relation === 'new') {
204
239
  const choice = getSelection(prior.runId);
205
240
  if (choice?.value.status === 'ready')
206
241
  this.supersededChoices.set(`${event.sessionId}\u0000${event.turn}`, choice);
@@ -223,11 +258,33 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
223
258
  profileHints: event.profileHints ?? null,
224
259
  ...(event.deferTaskTypeInference ? { deferTaskTypeInference: true } : {}),
225
260
  evidence: event.evidence ?? null,
261
+ requestIntent: event.requestIntent ?? null,
262
+ requestIntentContextDigest: event.requestIntentContext ? canonicalContentHash(event.requestIntentContext) : null,
263
+ memoryOwner: event.memoryOwner ?? null,
226
264
  skillDiscoveryMode: event.skillDiscoveryMode ?? null,
227
265
  catalogDigest: event.capabilities.digest,
228
266
  });
267
+ const unresolvedBinding = canonicalContentHash({ sessionId: event.sessionId, agentId: event.agent.id,
268
+ turn: event.turn, sourceStartSeq: event.sourceStartSeq ?? null, task: event.task, cwd: event.cwd,
269
+ evidence: event.evidence ?? null, context: event.requestIntentContext ?? null, catalogDigest: event.capabilities.digest,
270
+ skillDiscoveryMode: event.skillDiscoveryMode ?? null });
229
271
  const cached = continuedTurns.get(cacheKey) ?? resumedTurns.get(cacheKey);
230
272
  if (cached !== undefined) {
273
+ if (cached.fingerprint !== fingerprint && 'unresolvedBinding' in cached && cached.unresolvedBinding === unresolvedBinding
274
+ && cached.nativeAgent === event.nativeAgent && cached.nativeSession === event.nativeSession
275
+ && event.requestIntentContext && event.requestIntent
276
+ && continuesCodingScope(event) && rebindRequestIntentDecision(event.requestIntent, event.requestIntentContext)) {
277
+ // A host-owned confirmation may resume before optional interpretation.
278
+ // Resolve that exact unresolved input once; changing resolved input still conflicts.
279
+ const kind = memoryOwnerKind(event.requestIntent, event.profileHints?.taskType);
280
+ const prepared = { ...cached.result.prepared,
281
+ memoryOwner: createMemoryOwner(kind, { agentId: event.agent.id, sessionId: event.sessionId, turn: event.turn,
282
+ requestDigest: canonicalContentHash(event.task), runId: cached.result.prepared.run.runId }) };
283
+ const resolved = await this.choose(event, { ...cached.result, prepared });
284
+ continuedTurns.set(cacheKey, { fingerprint, result: resolved, ...(event.nativeAgent ? { nativeAgent: event.nativeAgent } : {}), ...(event.nativeSession ? { nativeSession: event.nativeSession } : {}) });
285
+ await bindAndRecord(event, resolved, generation);
286
+ return resolved;
287
+ }
231
288
  if (cached.fingerprint !== fingerprint
232
289
  || cached.nativeAgent !== event.nativeAgent
233
290
  || cached.nativeSession !== event.nativeSession) {
@@ -247,12 +304,36 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
247
304
  if (!hasHumanInput(reviewMessages) && reviewMessages.some(message => objectRecord(objectRecord(message)?.source)?.form === ANSWER_REVIEW_FORM)) {
248
305
  if (!previous || !event.nativeAgent || !await answerReview.accept(event.nativeAgent, reviewMessages, event.turn, event.capabilities.digest))
249
306
  throw new Error('Unbound answer review continuation');
250
- const continued = { admitted: true, prepared: previous.prepared, catalog: previous.catalog };
307
+ // Only the coordinator's exact reserved message may carry this owner
308
+ // into another native turn; the request and run remain unchanged.
309
+ const owner = previous.prepared.memoryOwner;
310
+ const prepared = owner ? { ...previous.prepared,
311
+ memoryOwner: createMemoryOwner(owner.kind, { ...owner, turn: event.turn }) } : previous.prepared;
312
+ const continued = { admitted: true, prepared, catalog: previous.catalog };
251
313
  continuedTurns.set(cacheKey, { fingerprint, result: continued, nativeAgent: event.nativeAgent, ...(event.nativeSession === undefined ? {} : { nativeSession: event.nativeSession }) });
252
314
  await bindAndRecord(event, continued, generation);
253
315
  return continued;
254
316
  }
255
317
  if (previous !== undefined && previous.turn === event.turn && !previous.closed) {
318
+ if (previous.task !== event.task && hasHumanInput(event.nativeMessages ?? [])) {
319
+ if (!continuesCodingScope(event))
320
+ return { admitted: false, prepared: previous.prepared, catalog: event.capabilities };
321
+ const workflow = await runtime.withDatabase(db => readCodingWorkflow(db, previous.runId));
322
+ const scopeChanging = !!workflow && event.requestIntent?.relation === 'scope_change';
323
+ if (scopeChanging && event.requestIntent) {
324
+ const evidenceRefs = event.requestIntentContext ? requestIntentReferenceIds(event.requestIntentContext) : [];
325
+ await runtime.withDatabase(db => markCodingScopeChange(db, { runId: previous.runId, sessionId: previous.sessionId, repositoryRoot: previous.repositoryRoot }, `request-intent:${event.sessionId}:${event.turn}:${event.requestIntent.evidence.requestDigest}`, event.requestIntent.evidence.requestDigest, evidenceRefs));
326
+ }
327
+ const ownerKind = event.memoryOwner ?? memoryOwnerKind(event.requestIntent, event.profileHints?.taskType ?? previous.prepared.intake.profile.taskType);
328
+ const prepared = { ...previous.prepared,
329
+ ...(scopeChanging ? { context: null, memoryPolicy: { memoryReasoningRequired: false, contextWithheld: false, withheldReason: null, deliveryEmpty: true } } : {}),
330
+ memoryOwner: createMemoryOwner(ownerKind, { agentId: event.agent.id, sessionId: event.sessionId, turn: event.turn,
331
+ requestDigest: canonicalContentHash(event.task), runId: previous.runId }) };
332
+ const selected = await this.choose(event, { admitted: !event.signal.aborted, prepared, catalog: event.capabilities });
333
+ if (selected.admitted)
334
+ await bindAndRecord(event, selected, generation);
335
+ return selected;
336
+ }
256
337
  // Model routing prepares before native pre-step. Reuse that exact
257
338
  // intake result instead of treating its newly active run as a cold
258
339
  // resume (which deliberately starts without historical context).
@@ -304,7 +385,7 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
304
385
  // Child results and other generated turns continue the admitted Goal.
305
386
  // Only a new human request can replace it without an explicit continuation.
306
387
  const resumeCoding = coding && !['completed', 'cancelled', 'superseded'].includes(coding.state)
307
- && (!hasHumanInput(event.nativeMessages ?? []) || codingContinuation(event.task));
388
+ && (!hasHumanInput(event.nativeMessages ?? []) || continuesCodingScope(event));
308
389
  const continuePrevious = resumeCoding || selection && (selection.status !== 'ready' || selection.mode === 'normal' && previous.failed)
309
390
  ? true : previousWasChat
310
391
  ? event.profileHints?.taskType === 'chat'
@@ -315,6 +396,12 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
315
396
  && (previousState.nextAction !== 'complete' || executionSupport.paused(previous.sessionId));
316
397
  if (continuePrevious) {
317
398
  this.assertCatalog(previous.catalog, event.capabilities);
399
+ const intent = event.requestIntent;
400
+ const scopeChanging = !!coding && intent?.relation === 'scope_change' && intent.action !== 'answer' && intent.action !== 'unknown';
401
+ if (scopeChanging && intent) {
402
+ const evidenceRefs = event.requestIntentContext ? requestIntentReferenceIds(event.requestIntentContext) : [];
403
+ await runtime.withDatabase(db => markCodingScopeChange(db, { runId: previous.runId, sessionId: previous.sessionId, repositoryRoot: previous.repositoryRoot }, `request-intent:${event.sessionId}:${event.turn}:${intent.evidence.requestDigest}`, intent.evidence.requestDigest, evidenceRefs));
404
+ }
318
405
  const refreshedWork = await refreshContinuedWorkLease(previous, previousState);
319
406
  if (refreshedWork !== undefined) {
320
407
  previous.prepared = { ...previous.prepared, ennoOduno: refreshedWork.state };
@@ -322,7 +409,10 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
322
409
  turnState.applyPolicy(previous.runId, next);
323
410
  }
324
411
  let continuedMemory;
325
- if (!ennoMemory.ownsActiveRefresh(previous.prepared.ennoOduno)) {
412
+ if (scopeChanging)
413
+ continuedMemory = { context: null,
414
+ memoryPolicy: { memoryReasoningRequired: false, contextWithheld: false, withheldReason: null, deliveryEmpty: true } };
415
+ else if (!ennoMemory.ownsActiveRefresh(previous.prepared.ennoOduno)) {
326
416
  const captured = previous.prepared, started = performance.now();
327
417
  const inboxIdentity = () => canonicalContentHash([...(event.nativeAgent?.inbox?.nextStep ?? []), ...(event.nativeAgent?.inbox?.nextTurn ?? [])].filter(isHumanMessage));
328
418
  const pendingInput = inboxIdentity();
@@ -349,10 +439,15 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
349
439
  /* Optional retrieval failure retains the previous delivery, whose state is validated before injection. */
350
440
  }
351
441
  }
352
- const continued = await this.choose(event, { admitted: !event.signal.aborted, prepared: continuedMemory ? { ...previous.prepared, ...continuedMemory } : previous.prepared, catalog: event.capabilities });
442
+ const ownerKind = event.memoryOwner ?? memoryOwnerKind(intent, event.profileHints?.taskType ?? previous.prepared.intake.profile.taskType);
443
+ const continuedPrepared = { ...previous.prepared, ...(continuedMemory ?? {}),
444
+ memoryOwner: createMemoryOwner(ownerKind, { agentId: event.agent.id, sessionId: event.sessionId, turn: event.turn,
445
+ requestDigest: canonicalContentHash(event.task), runId: previous.runId }) };
446
+ const continued = await this.choose(event, { admitted: !event.signal.aborted, prepared: continuedPrepared, catalog: event.capabilities });
353
447
  if (continued.admitted) {
354
448
  continuedTurns.set(cacheKey, {
355
449
  fingerprint,
450
+ ...(event.requestIntent?.relation === 'unknown' || event.requestIntent?.action === 'unknown' ? { unresolvedBinding } : {}),
356
451
  result: continued,
357
452
  ...(event.profileHints === undefined ? {} : { profileHints: event.profileHints }),
358
453
  ...(event.nativeAgent === undefined ? {} : { nativeAgent: event.nativeAgent }),
@@ -538,6 +633,49 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
538
633
  }
539
634
  }
540
635
  const gate = new CapturingGate(runtime, userQuestions === undefined ? undefined : createDshIntakeAnswerer(userQuestions), (context) => capabilityCatalog(skills, tools, context), true, akinatorMemoryConfig, decisions, completionMode, memoryRetrievalConfig);
636
+ const refreshMemoryOwner = async (item, signal) => {
637
+ const prepared = item.prepared;
638
+ const owner = prepared.memoryOwner;
639
+ if (!owner || owner.kind !== 'execution')
640
+ throw new KiokukoError('CONFLICT', 'memory_owner_unavailable');
641
+ const ownerIdentity = { agentId: item.agentId, sessionId: item.sessionId, turn: item.turn,
642
+ requestDigest: canonicalContentHash(item.task), runId: item.runId };
643
+ assertMemoryOwner(owner, ownerIdentity, 'execution');
644
+ const started = performance.now();
645
+ const refreshed = await runtime.withDatabase(async (database, embedding) => {
646
+ const assertCurrent = () => {
647
+ signal.throwIfAborted();
648
+ if (currentSession(item.sessionId) !== item || item.prepared !== prepared || item.closed || item.failed
649
+ || item.nativeAgent === undefined || agents?.get(item.nativeAgent.id) !== item.nativeAgent
650
+ || item.nativeSession === undefined || sessions?.get(item.sessionId) !== item.nativeSession) {
651
+ throw new KiokukoError('CONFLICT', 'memory_owner_changed');
652
+ }
653
+ assertMemoryOwner(owner, ownerIdentity, 'execution');
654
+ if (performance.now() - started > 1000 + (decisions.memoryReuse.mode === 'auto' ? decisions.memoryReuse.budgetMs : 0)) {
655
+ throw new KiokukoError('CONFLICT', 'memory_owner_rebuild_deadline');
656
+ }
657
+ };
658
+ if (embedding.mode === 'required')
659
+ throw new KiokukoError('SERVICE_UNAVAILABLE', 'required_embedding_unavailable');
660
+ const capabilities = [...item.catalog.skills, ...item.catalog.tools];
661
+ const memoryReuse = await createMemoryReuseRuntime(decisions, `run:${item.runId}`, signal);
662
+ return refreshContinuedTaskContext({ database, memoryReuse, memoryRetrieval: memoryRetrievalConfig, prepared,
663
+ task: item.memoryInput ?? item.task, capabilities, assertCurrent,
664
+ validateCapabilities: async () => {
665
+ const fresh = await capabilityCatalog(skills, tools, { agent: { id: item.agentId },
666
+ ...(item.nativeAgent ? { nativeAgent: item.nativeAgent } : {}), cwd: item.cwd, signal });
667
+ gate.assertCatalog(item.catalog, fresh);
668
+ assertCurrent();
669
+ } });
670
+ });
671
+ signal.throwIfAborted();
672
+ if (currentSession(item.sessionId) !== item || item.prepared !== prepared)
673
+ throw new KiokukoError('CONFLICT', 'memory_owner_changed');
674
+ item.prepared = { ...prepared, ...refreshed };
675
+ await runtime.withDatabase(database => bindMemoryApplication(database, {
676
+ runId: item.runId, workspace: item.workspace, sessionId: item.sessionId, repositoryRoot: item.repositoryRoot,
677
+ }, item.prepared.intake.profile, item.prepared.context, memoryRetrievalStatus(database, item.workspace, item.prepared.context, item.prepared.memoryPolicy.contextWithheld)));
678
+ };
541
679
  resumeExistingRun = async (event) => runtime.withDatabase(async (database) => {
542
680
  const project = await resolveProjectWorkspaceReadOnly(database, event.cwd, { allowDirectory: true });
543
681
  if (project === undefined)
@@ -554,7 +692,7 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
554
692
  OR (ec.run_id IS NULL AND (json_extract(es.state_json, '$.paused') = 1 OR xs.run_id IS NOT NULL)))
555
693
  AND (cw.run_id IS NULL OR (? = 1 AND json_extract(cw.snapshot_json, '$.state') NOT IN ('completed', 'cancelled', 'superseded')))
556
694
  ORDER BY lr.created_at, lr.run_id LIMIT 2
557
- `).all(project.workspace, event.sessionId, project.repositoryRoot, codingContinuation(event.task) ? 1 : 0);
695
+ `).all(project.workspace, event.sessionId, project.repositoryRoot, continuesCodingScope(event) ? 1 : 0);
558
696
  if (candidates.length === 0)
559
697
  return undefined;
560
698
  if (candidates.length !== 1)
@@ -601,6 +739,10 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
601
739
  });
602
740
  const canonicalCwd = realpathSync(event.cwd);
603
741
  const prepared = {
742
+ memoryOwner: createMemoryOwner(event.memoryOwner ?? memoryOwnerKind(event.requestIntent, intake.profile.taskType), {
743
+ agentId: event.agent.id, sessionId: event.sessionId, turn: event.turn,
744
+ requestDigest: canonicalContentHash(event.task), runId,
745
+ }),
604
746
  project,
605
747
  executionContext: {
606
748
  canonicalCwd,
@@ -631,7 +773,97 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
631
773
  turnState.stageLease(runId, decision.executionLease);
632
774
  return { admitted: !event.signal.aborted, prepared, catalog: event.capabilities };
633
775
  });
634
- const mapPreStep = async (payload, advisoryType) => {
776
+ const requestIntentContextFor = async (input, sessionId, nativeSession, previous, task) => {
777
+ const human = input.messages.filter(isHumanMessage);
778
+ if (!human.length || !task.trim())
779
+ return undefined;
780
+ const sessionHeader = objectRecord(objectRecord(nativeSession)?.header);
781
+ const cwd = typeof sessionHeader?.cwd === 'string' ? sessionHeader.cwd : undefined;
782
+ if (!cwd)
783
+ return undefined;
784
+ const messageRefs = requestIntentMessageRefs(human, task);
785
+ let activeGoal;
786
+ let proposals = [];
787
+ const sameOwner = previous && previous.sessionId === sessionId && previous.nativeAgent === input.agent && previous.nativeSession === nativeSession;
788
+ const persistedRun = sameOwner ? undefined : await runtime.withDatabase(async (database) => {
789
+ const project = await resolveProjectWorkspaceReadOnly(database, cwd, { allowDirectory: true });
790
+ if (!project)
791
+ return undefined;
792
+ const candidates = database.prepare(`SELECT lr.run_id AS runId,
793
+ ec.orchestration_session_id AS orchestrationId
794
+ FROM ledger_runs AS lr
795
+ LEFT JOIN dsh_coding_workflows AS cw ON cw.run_id = lr.run_id
796
+ LEFT JOIN enno_contracts AS ec ON ec.run_id = lr.run_id
797
+ WHERE lr.workspace = ? AND lr.dsh_session_id = ? AND lr.status = 'active'
798
+ AND ((json_extract(cw.snapshot_json, '$.repositoryRoot') = ?
799
+ AND json_extract(cw.snapshot_json, '$.sessionId') = ?
800
+ AND json_extract(cw.snapshot_json, '$.state') NOT IN ('completed', 'cancelled', 'superseded'))
801
+ OR (ec.repository_root = ? AND ec.status NOT IN ('completed', 'cancelled', 'blocked')))
802
+ ORDER BY lr.created_at, lr.run_id LIMIT 2`)
803
+ .all(project.workspace, sessionId, project.repositoryRoot, sessionId, project.repositoryRoot);
804
+ if (candidates.length > 1)
805
+ throw new KiokukoError('CONFLICT', 'Multiple active tasks match this session; refusing to guess');
806
+ return candidates[0] === undefined ? undefined : { ...candidates[0], workspace: project.workspace };
807
+ });
808
+ const runId = sameOwner ? previous.runId : persistedRun?.runId;
809
+ if (runId) {
810
+ const state = await runtime.withDatabase(database => {
811
+ const workflow = readCodingWorkflow(database, runId);
812
+ const definition = workflow?.definition;
813
+ const frame = readExecutionFrame(database, runId);
814
+ const enno = !workflow && persistedRun?.runId === runId && persistedRun.orchestrationId !== null
815
+ ? readEnnoSnapshot(database, { runId, workspace: persistedRun.workspace, orchestrationId: persistedRun.orchestrationId })
816
+ : undefined;
817
+ const active = definition ? {
818
+ runId, workflowRevision: workflow.revision, goalId: definition.goal.goalId,
819
+ goalRevision: definition.goal.revision, scopeRevision: workflow.scopeVersion, ideal: definition.goal.ideal,
820
+ target: definition.goal.target, outOfScope: [...definition.goal.outOfScope], constraints: [...definition.goal.constraints],
821
+ } : workflow ? { runId, workflowRevision: workflow.revision, scopeRevision: workflow.scopeVersion, outOfScope: [], constraints: [] }
822
+ : enno ? {
823
+ runId, workflowRevision: enno.revision, goalRevision: enno.revision, scopeRevision: enno.revision,
824
+ ideal: enno.ideal?.objective ?? enno.handoff.objective,
825
+ ...(enno.handoff.target === null ? {} : { target: enno.handoff.target }),
826
+ outOfScope: [...enno.contract.exclusions], constraints: [...enno.handoff.constraints],
827
+ }
828
+ : sameOwner && previous.prepared.ennoOduno.applicable ? {
829
+ runId,
830
+ ...(previous.prepared.ennoOduno.contractRevision === null ? {} : {
831
+ workflowRevision: previous.prepared.ennoOduno.contractRevision,
832
+ goalRevision: previous.prepared.ennoOduno.contractRevision,
833
+ scopeRevision: previous.prepared.ennoOduno.contractRevision,
834
+ }),
835
+ ...(previous.prepared.ennoOduno.directive?.objective ? { ideal: previous.prepared.ennoOduno.directive.objective } : {}),
836
+ ...(previous.prepared.intake.profile.target ? { target: previous.prepared.intake.profile.target } : {}),
837
+ outOfScope: [],
838
+ constraints: previous.prepared.intake.profile.constraints ? [previous.prepared.intake.profile.constraints] : [],
839
+ } : undefined;
840
+ const candidates = (frame?.conditions ?? []).filter(condition => condition.approval === 'proposed').slice(0, 7)
841
+ .map(condition => ({ id: `condition-${canonicalContentHash([runId, frame.revision, condition.field, condition.text, condition.planRevision])}`,
842
+ revision: condition.planRevision ?? frame.revision, digest: canonicalContentHash(condition),
843
+ text: `${condition.field}: ${condition.text}`, field: condition.field }));
844
+ return { active, candidates };
845
+ });
846
+ activeGoal = state.active;
847
+ proposals = state.candidates;
848
+ }
849
+ const eventSource = sessionEventSource(nativeSession);
850
+ const precedingAssistant = [...eventSource.snapshotEvents()].reverse().find(event => event.type === 'assistant/message'
851
+ && (eventTurn(event) ?? Number.MAX_SAFE_INTEGER) < input.turn);
852
+ if (precedingAssistant && proposals.length < 8) {
853
+ const data = objectRecord(precedingAssistant.data);
854
+ const message = objectRecord(data?.message) ?? data;
855
+ const content = Array.isArray(message?.content) ? message.content : [];
856
+ const text = content.filter((block) => objectRecord(block)?.type === 'text')
857
+ .map((block) => objectRecord(block)?.text).filter((value) => typeof value === 'string').join('\n').trim();
858
+ const messageId = typeof message?.id === 'string' ? message.id : `seq:${precedingAssistant.seq}`;
859
+ if (message?.role === 'assistant' && text && text.length <= 8192 && findSecret(text) === undefined) {
860
+ proposals = [...proposals, { id: `assistant-${canonicalContentHash([sessionId, messageId])}`, revision: null,
861
+ digest: canonicalContentHash(text), text }];
862
+ }
863
+ }
864
+ return createRequestIntentContext({ task, messageRefs, ...(activeGoal ? { activeGoal } : {}), proposals: proposals.slice(0, 8) });
865
+ };
866
+ const mapPreStep = async (payload, advisoryType, suppliedIntent, interpretationOnly = false) => {
635
867
  const nativeSession = payload.agent.session;
636
868
  const registered = nativeSession === undefined && payload.agent.sessionId === undefined
637
869
  ? sessions?.get(payload.agent.id)
@@ -668,7 +900,8 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
668
900
  // model, while any supplied step-local user text still replaces this
669
901
  // fallback and is recorded as the continuation instruction.
670
902
  const reviewing = !hasHumanInput(payload.messages) && payload.messages.some(message => objectRecord(objectRecord(message)?.source)?.form === ANSWER_REVIEW_FORM);
671
- const task = bound?.task ?? (reviewing && previous ? previous.task : textFromMessages(payload.messages, previous?.task));
903
+ const intentTask = hasHumanInput(payload.messages) ? textFromMessages(payload.messages.filter(isHumanMessage), '') : '';
904
+ const task = intentTask.trim() ? intentTask : bound?.task ?? (reviewing && previous ? previous.task : textFromMessages(payload.messages, previous?.task));
672
905
  let profile = (() => {
673
906
  if (bound !== undefined)
674
907
  return bound.profileHints;
@@ -683,20 +916,62 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
683
916
  return inferred === null || previousType === 'chat' && inferred === 'chat' ? { taskType: previousType } : undefined;
684
917
  })();
685
918
  let deferTaskTypeInference = bound?.deferTaskTypeInference ?? (reviewing ? previous?.deferTaskTypeInference : false) ?? false;
686
- if (!reviewing && bound === undefined && !delegation.isChild(payload.agent)) {
919
+ let requestIntentContext;
920
+ let requestIntent;
921
+ const activeRecord = bound ?? previous;
922
+ if (!reviewing && hasHumanInput(payload.messages) && !delegation.isChild(payload.agent) && intentTask.trim()) {
923
+ requestIntentContext = await requestIntentContextFor(payload, sessionId, boundSession, activeRecord, intentTask);
687
924
  const requestId = dshTurnRequestId({ dshSessionId: sessionId, turn: payload.turn });
925
+ const establishedConversation = profile?.taskType === 'chat' && !requestIntentContext?.activeGoal;
926
+ if (requestIntentContext && !establishedConversation) {
927
+ requestIntent = await classifyRequestIntent(decisions, requestId, requestIntentContext, payload.signal);
928
+ }
688
929
  const configuration = await decisions?.bind(requestId, payload.signal);
689
930
  // This profile is inherited from a previous turn, not a current user choice.
690
931
  // Let Laya assess new work, but retain the user's chat choice for an
691
932
  // ambiguous continuation instead of asking the same classification again.
692
933
  const explicit = advisoryType ?? (configuration?.provider === 'laya-coreml' && profile?.taskType !== 'chat' ? undefined : profile?.taskType);
693
- const classification = await classifyTaskForIntake(decisions, requestId, task, explicit, payload.signal);
934
+ const classification = await classifyTaskForIntake(decisions, requestId, intentTask, explicit, payload.signal);
694
935
  deferTaskTypeInference = classification.deferInference;
695
936
  if (classification.taskType)
696
937
  profile = { ...profile, taskType: classification.taskType };
697
938
  else if (deferTaskTypeInference && profile)
698
939
  profile = { ...profile, taskType: null };
699
940
  }
941
+ else if (activeRecord) {
942
+ requestIntent = activeRecord.requestIntent;
943
+ requestIntentContext = activeRecord.requestIntentContext;
944
+ }
945
+ if (suppliedIntent) {
946
+ if (!requestIntentContext)
947
+ throw new KiokukoError('CONFLICT', 'request_intent_context_unavailable');
948
+ const rebound = rebindRequestIntentDecision(suppliedIntent, requestIntentContext);
949
+ if (!rebound)
950
+ throw new KiokukoError('CONFLICT', 'request_intent_evidence_stale');
951
+ if (requestIntent?.source === 'decision-provider' && requestIntent.relation !== 'unknown' && requestIntent.action !== 'unknown'
952
+ && (requestIntent.relation !== rebound.relation || requestIntent.action !== rebound.action)) {
953
+ throw new KiokukoError('CONFLICT', 'request_intent_provider_conflict');
954
+ }
955
+ requestIntent = requestIntent?.source === 'decision-provider' && requestIntent.relation !== 'unknown' && requestIntent.action !== 'unknown'
956
+ ? { ...requestIntent, evidence: rebound.evidence } : rebound;
957
+ }
958
+ const pendingDiscussion = isContinuationReference(intentTask)
959
+ && await hasPendingExecutionDiscussion(sessionId, cwd);
960
+ const establishedConversation = profile?.taskType === 'chat' && !requestIntentContext?.activeGoal;
961
+ if (!interpretationOnly && intentTask.trim() && !pendingDiscussion && !establishedConversation) {
962
+ const clarification = executionClarification(intentTask, requestIntent, requestIntentContext);
963
+ if (clarification)
964
+ throw new KiokukoError('VALIDATION_ERROR', clarification);
965
+ }
966
+ const legacyTaskType = advisoryType !== undefined && advisoryType !== 'chat'
967
+ && !requestIntentContext?.activeGoal && (requestIntentContext?.proposals.length ?? 0) === 0;
968
+ if (requestIntent?.source === 'unresolved' && legacyTaskType)
969
+ requestIntent = undefined;
970
+ if (requestIntent?.source !== 'unresolved') {
971
+ const intentType = requestIntentTaskType(requestIntent, profile?.taskType ?? advisoryType);
972
+ if (intentType !== undefined)
973
+ profile = { ...profile, taskType: intentType };
974
+ }
700
975
  // Coding Lisp choice belongs to the admitted Goal, after all criteria exist.
701
976
  // Task intake never starts Lisp or interrupts an explanation with a mode question.
702
977
  const catalog = await capabilityCatalog(skills, tools, {
@@ -715,6 +990,9 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
715
990
  cwd,
716
991
  ...(profile === undefined ? {} : { profileHints: profile }),
717
992
  ...(deferTaskTypeInference ? { deferTaskTypeInference: true } : {}),
993
+ ...(requestIntent === undefined ? {} : { requestIntent }),
994
+ ...(requestIntentContext === undefined ? {} : { requestIntentContext }),
995
+ memoryOwner: memoryOwnerKind(requestIntent, profile?.taskType),
718
996
  capabilities: catalog,
719
997
  signal: payload.signal,
720
998
  };
@@ -722,6 +1000,13 @@ export function createAdmission({ native, skills, tools, userQuestions, sessions
722
1000
  return {
723
1001
  gate,
724
1002
  mapPreStep,
1003
+ interpret: async (payload) => {
1004
+ const event = await mapPreStep(payload, undefined, undefined, true);
1005
+ if (!event.requestIntentContext || !event.requestIntent)
1006
+ return undefined;
1007
+ return { context: event.requestIntentContext, decision: event.requestIntent };
1008
+ },
1009
+ refreshMemoryOwner,
725
1010
  clear: () => { continuedTurns.clear(); resumedTurns.clear(); },
726
1011
  };
727
1012
  }