@indexnetwork/protocol 20.0.0-rc.484.1 → 21.0.0-rc.486.1

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 (56) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/IMPLEMENTATION.md +1 -1
  3. package/dist/agents/index.d.ts +0 -1
  4. package/dist/agents/index.js +0 -1
  5. package/dist/chat/chat.agent.d.ts +0 -6
  6. package/dist/chat/chat.agent.js +0 -94
  7. package/dist/chat/chat.persona.d.ts +1 -2
  8. package/dist/chat/chat.prompt.js +1 -1
  9. package/dist/chat/chat.prompt.modules.d.ts +0 -2
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.js +0 -1
  12. package/dist/mcp/elicitation.builder.d.ts +1 -1
  13. package/dist/mcp/elicitation.dispatcher.d.ts +1 -1
  14. package/dist/questions/index.d.ts +37 -8
  15. package/dist/questions/index.js +38 -2
  16. package/dist/questions/{application/question.agent.d.ts → question.agent.d.ts} +2 -2
  17. package/dist/questions/{application/question.agent.js → question.agent.js} +6 -9
  18. package/dist/questions/{application/question.ask.tool.d.ts → question.ask.tool.d.ts} +2 -2
  19. package/dist/questions/{application/question.ask.tool.js → question.ask.tool.js} +4 -7
  20. package/dist/questions/{application/question.env.d.ts → question.env.d.ts} +1 -4
  21. package/dist/questions/{application/question.env.js → question.env.js} +1 -4
  22. package/dist/questions/{application/question.input.d.ts → question.input.d.ts} +4 -7
  23. package/dist/questions/{application/question.input.js → question.input.js} +1 -1
  24. package/dist/questions/{ports/question.persistence.port.d.ts → question.persistence.port.d.ts} +2 -4
  25. package/dist/questions/{application/question.presets.d.ts → question.presets.d.ts} +2 -5
  26. package/dist/questions/{application/question.presets.js → question.presets.js} +12 -2
  27. package/dist/questions/{domain/question.schema.d.ts → question.schema.d.ts} +43 -47
  28. package/dist/questions/{domain/question.schema.js → question.schema.js} +32 -32
  29. package/dist/questions/{application/question.tools.d.ts → question.tools.d.ts} +2 -2
  30. package/dist/questions/{application/question.tools.js → question.tools.js} +4 -7
  31. package/dist/questions/{ports/question.tools.port.d.ts → question.tools.port.d.ts} +2 -4
  32. package/dist/shared/agent/tool.factory.js +0 -1
  33. package/dist/shared/agent/tool.helpers.d.ts +3 -11
  34. package/dist/shared/agent/tool.helpers.js +1 -2
  35. package/dist/shared/schemas/pending-question.schema.d.ts +1 -1
  36. package/dist/shared/schemas/underspecification.schema.d.ts +1 -1
  37. package/dist/shared/schemas/underspecification.schema.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/chat/reporter.action.contracts.d.ts +0 -36
  40. package/dist/chat/reporter.action.contracts.js +0 -1
  41. package/dist/chat/reporter.action.tools.d.ts +0 -17
  42. package/dist/chat/reporter.action.tools.js +0 -145
  43. package/dist/chat/reporter.persona.d.ts +0 -31
  44. package/dist/chat/reporter.persona.js +0 -207
  45. package/dist/chat/reporter.prompt.d.ts +0 -24
  46. package/dist/chat/reporter.prompt.js +0 -149
  47. package/dist/questions/application/index.d.ts +0 -39
  48. package/dist/questions/application/index.js +0 -41
  49. package/dist/questions/application/question.qud.d.ts +0 -12
  50. package/dist/questions/application/question.qud.js +0 -16
  51. package/dist/questions/domain/index.d.ts +0 -24
  52. package/dist/questions/domain/index.js +0 -24
  53. package/dist/questions/ports/index.d.ts +0 -27
  54. package/dist/questions/ports/index.js +0 -26
  55. /package/dist/questions/{ports/question.persistence.port.js → question.persistence.port.js} +0 -0
  56. /package/dist/questions/{ports/question.tools.port.js → question.tools.port.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -20,6 +20,54 @@ went 6.7.1 → 8.0.2 with no 7.x in between because the whole 7.x line shipped a
20
20
  prereleases between the two promotions. To track every change, read `rc`; to
21
21
  pin a supported release, use `latest`.
22
22
 
23
+ ## 21.0.0 - 2026-08-17
24
+
25
+ ### Removed
26
+
27
+ - **Breaking:** remove the Agent reporter persona. `REPORTER_PERSONA`,
28
+ `REPORTER_PERSONA_ID`, `REPORTER_BRIEFING_KICKOFF`, `REPORTER_TOOL_NAMES`,
29
+ `createReporterTools`, `filterReporterTools` and `narrowReporterTools` are
30
+ gone from the package entry point, along with `reporter.persona.ts`,
31
+ `reporter.prompt.ts` and the `propose_cleanup_actions` tool
32
+ (`reporter.action.tools.ts`, `reporter.action.contracts.ts`). Hosts that named
33
+ the `reporter` persona must pick another; unknown personas already fail closed.
34
+ - **Breaking:** drop `actionToolsEnabled` from `ToolContext`/`ToolDeps`/
35
+ `ResolvedToolContext` and `actionProposalStore` from `ToolDeps`. Both existed
36
+ solely to gate the reporter's cleanup-action tool. `resolveChatContext()` no
37
+ longer accepts or returns `actionToolsEnabled`.
38
+ - Remove `ChatAgent.hasPriorAgentActionProposal()`, the
39
+ ```agent_action_proposal``` fence parser behind it, and
40
+ `IterationContext.hasPriorAgentActionProposal`. The reporter prompt was the
41
+ only consumer, so all of it became dead with the persona.
42
+
43
+ `read_activity_summary` and the whole `activity-projection` module are
44
+ **unchanged** — they are shared utility tools registered for every persona and
45
+ exposed on the MCP server, not reporter-specific.
46
+
47
+ ## 20.0.1 - 2026-08-17
48
+
49
+ ### Changed
50
+
51
+ - Flatten `src/questions/` from four directories to one, matching the same move
52
+ already made in `intents/` and `networks/`, and the flat layout of `chat/`,
53
+ `discovery/`, and `premises/`. The `domain/`, `ports/`, and `application/`
54
+ directories held two,
55
+ two, and six files behind 206 lines of re-export barrel; the three sub-barrels
56
+ re-exported roughly twenty symbols no consumer outside the capability ever
57
+ imported. Files now sit flat and are named for what they are
58
+ (`question.schema`, `question.input`, `question.agent`, `question.presets`,
59
+ `question.env`, `question.tools`, `question.ask.tool`, and the two ports), with
60
+ a single `index.ts` as the capability barrel.
61
+ - Fold the QUD taxonomy constant into `question.presets.ts`, its only consumer,
62
+ retiring the 16-line `question.qud.ts`.
63
+ - Share the negotiation candidate/provenance field shape and their identical
64
+ counterparty-eligibility refinement instead of declaring both twice. The two
65
+ `superRefine` blocks stated the same uptake-only rule in different words; they
66
+ now delegate to one helper, so the invariant has a single definition.
67
+
68
+ The package's exported surface is unchanged — `questions/index.ts` exports the
69
+ same 44 names as before. Only paths private to the capability moved.
70
+
23
71
  ## 20.0.0 - 2026-08-17
24
72
 
25
73
  ### Changed
package/IMPLEMENTATION.md CHANGED
@@ -173,7 +173,7 @@ The intent and community graphs are the exceptions: they are reached through the
173
173
 
174
174
  ### Persisted chat personas
175
175
 
176
- `ChatGraphFactory.withPersona()` keeps the runtime neutral while selecting an exported persona configuration. `SIGNAL_PERSONA`, `REPORTER_PERSONA`, and `ONBOARDING_PERSONA` each own an exact positive tool allowlist; shared tools added later remain unavailable until reviewed. `ONBOARDING_PERSONA` reuses Signal's proposal-only, live-membership-narrowed `create_intent` contract and otherwise exposes only privacy consent, approved self-context preview/confirmation, guided questions, and validated completion. Hosts must persist the exported persona ID on session creation and treat it as authoritative on follow-ups.
176
+ `ChatGraphFactory.withPersona()` keeps the runtime neutral while selecting an exported persona configuration. `SIGNAL_PERSONA` and `ONBOARDING_PERSONA` each own an exact positive tool allowlist; shared tools added later remain unavailable until reviewed. `ONBOARDING_PERSONA` reuses Signal's proposal-only, live-membership-narrowed `create_intent` contract and otherwise exposes only privacy consent, approved self-context preview/confirmation, guided questions, and validated completion. Hosts must persist the exported persona ID on session creation and treat it as authoritative on follow-ups.
177
177
 
178
178
  ## Intents
179
179
 
@@ -15,7 +15,6 @@ export { ChatTitleGenerator, } from "../chat/chat.title.generator.js";
15
15
  export { createChatTools, } from "../chat/chat.tools.js";
16
16
  export { createNegotiatorPersona, NEGOTIATOR_PERSONA_ID, } from "../chat/negotiator.persona.js";
17
17
  export { createOnboardingTools, filterOnboardingTools, narrowOnboardingTools, ONBOARDING_PERSONA, ONBOARDING_PERSONA_ID, ONBOARDING_PROFILE_KICKOFF, ONBOARDING_TOOL_NAMES, } from "../chat/onboarding.persona.js";
18
- export { createReporterTools, filterReporterTools, narrowReporterTools, REPORTER_BRIEFING_KICKOFF, REPORTER_PERSONA, REPORTER_PERSONA_ID, REPORTER_TOOL_NAMES, } from "../chat/reporter.persona.js";
19
18
  export { createSignalTools, filterSignalTools, narrowSignalTools, SIGNAL_NEW_SIGNAL_KICKOFF, SIGNAL_PERSONA, SIGNAL_PERSONA_ID, SIGNAL_TOOL_NAMES, } from "../chat/signal.persona.js";
20
19
  export { createAgentTools, } from "./application/index.js";
21
20
  export { SYSTEM_AGENT_IDS, } from "./domain/index.js";
@@ -6,7 +6,6 @@ export { ChatTitleGenerator, } from "../chat/chat.title.generator.js";
6
6
  export { createChatTools, } from "../chat/chat.tools.js";
7
7
  export { createNegotiatorPersona, NEGOTIATOR_PERSONA_ID, } from "../chat/negotiator.persona.js";
8
8
  export { createOnboardingTools, filterOnboardingTools, narrowOnboardingTools, ONBOARDING_PERSONA, ONBOARDING_PERSONA_ID, ONBOARDING_PROFILE_KICKOFF, ONBOARDING_TOOL_NAMES, } from "../chat/onboarding.persona.js";
9
- export { createReporterTools, filterReporterTools, narrowReporterTools, REPORTER_BRIEFING_KICKOFF, REPORTER_PERSONA, REPORTER_PERSONA_ID, REPORTER_TOOL_NAMES, } from "../chat/reporter.persona.js";
10
9
  export { createSignalTools, filterSignalTools, narrowSignalTools, SIGNAL_NEW_SIGNAL_KICKOFF, SIGNAL_PERSONA, SIGNAL_PERSONA_ID, SIGNAL_TOOL_NAMES, } from "../chat/signal.persona.js";
11
10
  export { createAgentTools, } from "./application/index.js";
12
11
  export { SYSTEM_AGENT_IDS, } from "./domain/index.js";
@@ -195,12 +195,6 @@ export declare class ChatAgent {
195
195
  * Extracts the text content of the most recent HumanMessage.
196
196
  */
197
197
  private static getCurrentUserMessage;
198
- /**
199
- * Detects a prior visible action proposal without considering current-turn
200
- * tool calls. The reporter uses this only to make typed confirmation
201
- * language contextual rather than executable on its own.
202
- */
203
- static hasPriorAgentActionProposal(messages: BaseMessage[]): boolean;
204
198
  /**
205
199
  * Async factory: creates a ChatAgent with resolved user/index context.
206
200
  * Resolves user/network identity from DB during tool initialization.
@@ -19,55 +19,6 @@ import { sanitizeForDebugMeta } from "../shared/observability/debug-meta.sanitiz
19
19
  import { Timed } from "../shared/observability/performance.js";
20
20
  import { requestContext } from "../shared/observability/request-context.js";
21
21
  import { deduplicateQuestions } from "./chat.question-dedup.js";
22
- const AGENT_ACTION_PROPOSAL_FENCE_PATTERN = /```agent_action_proposal\s*\n([\s\S]*?)\n```/g;
23
- const AGENT_ACTION_PROPOSAL_KEYS = new Set(["proposalId", "actions"]);
24
- const AGENT_ACTION_KEYS = new Set([
25
- "type",
26
- "entityId",
27
- "currentState",
28
- "proposedOperation",
29
- "skipped",
30
- "reason",
31
- "description",
32
- "evidence",
33
- ]);
34
- const AGENT_ACTION_OPERATIONS = {
35
- retract_premise: "RETRACT_PREMISE",
36
- narrow_signal: "NARROW_SIGNAL",
37
- pause_signal: "PAUSE_SIGNAL",
38
- };
39
- function isVisibleAgentActionProposal(payload) {
40
- if (!payload || typeof payload !== "object" || Array.isArray(payload))
41
- return false;
42
- const proposal = payload;
43
- if (Object.keys(proposal).some((key) => !AGENT_ACTION_PROPOSAL_KEYS.has(key)))
44
- return false;
45
- if (typeof proposal.proposalId !== "string"
46
- || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(proposal.proposalId)
47
- || !Array.isArray(proposal.actions)
48
- || proposal.actions.length < 1
49
- || proposal.actions.length > 5)
50
- return false;
51
- return proposal.actions.every((rawAction) => {
52
- if (!rawAction || typeof rawAction !== "object" || Array.isArray(rawAction))
53
- return false;
54
- const action = rawAction;
55
- if (Object.keys(action).some((key) => !AGENT_ACTION_KEYS.has(key)))
56
- return false;
57
- if (typeof action.type !== "string" || !(action.type in AGENT_ACTION_OPERATIONS))
58
- return false;
59
- const type = action.type;
60
- if (action.proposedOperation !== AGENT_ACTION_OPERATIONS[type])
61
- return false;
62
- if (typeof action.entityId !== "string" || !action.entityId.trim())
63
- return false;
64
- if (typeof action.currentState !== "string" || !action.currentState.trim())
65
- return false;
66
- if (action.skipped !== undefined && typeof action.skipped !== "boolean")
67
- return false;
68
- return ["reason", "description", "evidence"].every((key) => action[key] === undefined || typeof action[key] === "string");
69
- });
70
- }
71
22
  const logger = protocolLogger("ChatAgent");
72
23
  // Re-export for external consumers
73
24
  export { ITERATION_NUDGE } from "./chat.prompt.js";
@@ -143,48 +94,6 @@ export class ChatAgent {
143
94
  }
144
95
  return undefined;
145
96
  }
146
- /**
147
- * Detects a prior visible action proposal without considering current-turn
148
- * tool calls. The reporter uses this only to make typed confirmation
149
- * language contextual rather than executable on its own.
150
- */
151
- static hasPriorAgentActionProposal(messages) {
152
- let currentHumanIndex = -1;
153
- let previousHumanIndex = -1;
154
- for (let index = messages.length - 1; index >= 0; index -= 1) {
155
- if (messages[index]._getType() !== "human")
156
- continue;
157
- if (currentHumanIndex < 0) {
158
- currentHumanIndex = index;
159
- }
160
- else {
161
- previousHumanIndex = index;
162
- break;
163
- }
164
- }
165
- if (currentHumanIndex < 0 || previousHumanIndex < 0)
166
- return false;
167
- let latestAssistant;
168
- for (let index = currentHumanIndex - 1; index > previousHumanIndex; index -= 1) {
169
- if (messages[index]._getType() === "ai") {
170
- latestAssistant = messages[index];
171
- break;
172
- }
173
- }
174
- if (!latestAssistant || typeof latestAssistant.content !== "string")
175
- return false;
176
- AGENT_ACTION_PROPOSAL_FENCE_PATTERN.lastIndex = 0;
177
- for (const match of latestAssistant.content.matchAll(AGENT_ACTION_PROPOSAL_FENCE_PATTERN)) {
178
- try {
179
- if (isVisibleAgentActionProposal(JSON.parse(match[1])))
180
- return true;
181
- }
182
- catch {
183
- // An invalid prior fence is not visible proposal context.
184
- }
185
- }
186
- return false;
187
- }
188
97
  /**
189
98
  * Async factory: creates a ChatAgent with resolved user/index context.
190
99
  * Resolves user/network identity from DB during tool initialization.
@@ -204,7 +113,6 @@ export class ChatAgent {
204
113
  userId: context.userId,
205
114
  networkId: scopedNetworkId,
206
115
  sessionId: context.sessionId,
207
- actionToolsEnabled: context.actionToolsEnabled,
208
116
  });
209
117
  if (explicitScope.scopeType && explicitScope.scopeId) {
210
118
  resolved.scopeType = explicitScope.scopeType;
@@ -224,7 +132,6 @@ export class ChatAgent {
224
132
  const iterCtx = {
225
133
  recentTools: extractRecentToolCalls(messages),
226
134
  currentMessage: ChatAgent.getCurrentUserMessage(messages),
227
- hasPriorAgentActionProposal: ChatAgent.hasPriorAgentActionProposal(messages),
228
135
  ctx: this.resolvedContext,
229
136
  };
230
137
  const deterministicResponse = this.persona.resolveDeterministicResponse?.(this.resolvedContext, iterCtx);
@@ -583,7 +490,6 @@ export class ChatAgent {
583
490
  const iterCtx = {
584
491
  recentTools: extractRecentToolCalls(messages),
585
492
  currentMessage: ChatAgent.getCurrentUserMessage(messages),
586
- hasPriorAgentActionProposal: ChatAgent.hasPriorAgentActionProposal(messages),
587
493
  ctx: this.resolvedContext,
588
494
  };
589
495
  const deterministicResponse = this.persona.resolveDeterministicResponse?.(this.resolvedContext, iterCtx);
@@ -9,8 +9,7 @@ export interface ChatPersonaLoopBehaviors {
9
9
  * Detect hallucinated ```opportunity / ```intent_proposal code blocks in model
10
10
  * text, auto-invoke the corresponding tool, and strip unbacked blocks from the
11
11
  * final response. Only meaningful for personas whose toolset can legitimately
12
- * produce those blocks — enabled for onboarding, signal and negotiator, off
13
- * for reporter.
12
+ * produce those blocks — enabled for onboarding, signal and negotiator.
14
13
  */
15
14
  hallucinationRecovery: boolean;
16
15
  }
@@ -4,7 +4,7 @@
4
4
  //
5
5
  // Persona-neutral prompt text owned by the agent loop rather than by any one
6
6
  // persona. Each persona builds its own system prompt (see signal.prompt.ts,
7
- // negotiator.prompt.ts, reporter.prompt.ts, onboarding.prompt.ts); what remains
7
+ // negotiator.prompt.ts, onboarding.prompt.ts); what remains
8
8
  // here is only what the loop itself injects regardless of persona.
9
9
  /**
10
10
  * Nudge message injected after SOFT_ITERATION_LIMIT iterations.
@@ -11,8 +11,6 @@ export interface IterationContext {
11
11
  }>;
12
12
  /** Text of the latest user message (for regex matching). */
13
13
  currentMessage?: string;
14
- /** Whether an earlier assistant turn visibly contained a valid action proposal. */
15
- hasPriorAgentActionProposal?: boolean;
16
14
  /** Resolved tool context (user, profile, indexes, etc.). */
17
15
  ctx: ResolvedToolContext;
18
16
  }
package/dist/index.d.ts CHANGED
@@ -35,7 +35,6 @@ export { ChatGraphFactory } from "./agents/index.js";
35
35
  export { type ChatPersonaConfig } from "./agents/index.js";
36
36
  export { NEGOTIATOR_PERSONA_ID, createNegotiatorPersona } from "./agents/index.js";
37
37
  export { SIGNAL_PERSONA_ID, SIGNAL_PERSONA, } from "./agents/index.js";
38
- export { REPORTER_PERSONA_ID, REPORTER_PERSONA, REPORTER_BRIEFING_KICKOFF, } from "./agents/index.js";
39
38
  export { ONBOARDING_PERSONA_ID, ONBOARDING_PERSONA, } from "./agents/index.js";
40
39
  export { RadarGraphFactory } from "./opportunities/index.js";
41
40
  export { HydeGraphFactory } from "./discovery/index.js";
package/dist/index.js CHANGED
@@ -31,7 +31,6 @@ export { DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD, resolveAssignmentNetworkScope, bu
31
31
  export { ChatGraphFactory } from "./agents/index.js";
32
32
  export { NEGOTIATOR_PERSONA_ID, createNegotiatorPersona } from "./agents/index.js";
33
33
  export { SIGNAL_PERSONA_ID, SIGNAL_PERSONA, } from "./agents/index.js";
34
- export { REPORTER_PERSONA_ID, REPORTER_PERSONA, REPORTER_BRIEFING_KICKOFF, } from "./agents/index.js";
35
34
  export { ONBOARDING_PERSONA_ID, ONBOARDING_PERSONA, } from "./agents/index.js";
36
35
  export { RadarGraphFactory } from "./opportunities/index.js";
37
36
  export { HydeGraphFactory } from "./discovery/index.js";
@@ -1,4 +1,4 @@
1
- import type { Question } from "../questions/domain/question.schema.js";
1
+ import type { Question } from "../questions/question.schema.js";
2
2
  type SingleChoiceSchema = {
3
3
  type: "string";
4
4
  enum: string[];
@@ -1,4 +1,4 @@
1
- import type { Question } from "../questions/domain/question.schema.js";
1
+ import type { Question } from "../questions/question.schema.js";
2
2
  import type { ChatMessageWriter } from "../shared/interfaces/chat-message-writer.interface.js";
3
3
  import { buildElicitationCreate } from "./elicitation.builder.js";
4
4
  export type ElicitResultLike = {
@@ -2,12 +2,41 @@
2
2
  * questions — the capability's sole cross-capability surface.
3
3
  *
4
4
  * Anything outside this capability imports from here and nowhere else.
5
- * Supersedes the capabilities/*.facade.ts + questions/public/ pair; the export
6
- * list is the union of the facades it replaces, so the contract is unchanged.
5
+ *
6
+ * ## What lives in the capability
7
+ *
8
+ * - **question.schema** — Zod schemas and derived types for the whole question
9
+ * vocabulary: the public Question shape, generator envelopes, and the
10
+ * detection/provenance/pool/recovery persistence sub-schemas.
11
+ * - **question.input** — per-mode context types, the discriminated
12
+ * QuestionerInput union, and `isValidQuestionerInputContract`, the runtime
13
+ * mirror of that discriminant enforced at queue boundaries.
14
+ * - **question.agent** — QuestionerAgent: stateless, mode-driven generation.
15
+ * - **question.presets** — system prompts and user-message builders per mode.
16
+ * - **question.env** — the QUESTIONER_* env accessors. All reads go through it.
17
+ * - **question.tools** / **question.ask.tool** — foreground adapters: the
18
+ * authenticated MCP read/answer tools, and the blocking chat
19
+ * `ask_user_question` tool.
20
+ * - **question.persistence.port** / **question.tools.port** — the injected
21
+ * host contracts (question CRUD, chat host bridge, tool host capabilities).
22
+ *
23
+ * Ambient generation (recovery, pool, uptake, inflight, push) is scheduled via
24
+ * the backend QuestionerQueue, which consumes the {@link QuestionerEnqueueFn}
25
+ * injected from the composition root.
26
+ *
27
+ * ## Boundary
28
+ *
29
+ * The capability imports from shared/ infrastructure and the negotiations
30
+ * barrel — never from runtime/, host implementations, or other capability
31
+ * internals.
7
32
  */
8
- export type { QuestionerEnqueueFn, } from "./application/question.input.js";
9
- export { createAskUserQuestionTools, createQuestionerTools, INTENT_QUESTION_DAILY_CAP_DEFAULT, INTENT_QUESTION_DAILY_WINDOW_HOURS, intentQuestionDailyCap, isQuestionerEnabled, isUptakeGuardEnabled, isValidQuestionerInputContract, QuestionerAgent, uptakeAuthorityThreshold, } from "./application/index.js";
10
- export type { InflightQuestionerInput, PoolDiscoveryContext, PostStallQuestionerInput, QuestionerEnqueuePayload, QuestionerInput, RecoveryQuestionerInput, UptakeQuestionerInput, } from "./application/index.js";
11
- export type { AskUserQuestionToolDeps, ChatQuestionsHost, PersistableQuestion, PersistedQuestion, QuestionerDatabase, QuestionerToolDeps, QuestionFilters, } from "./ports/index.js";
12
- export { NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, UnderspecificationTypeSchema, } from "./domain/index.js";
13
- export type { NegotiationQuestionCandidate, QuestionOption, NegotiationQuestionProvenance, NegotiationQuestionPurpose, Question, QuestionGenerationResult, QuestionPoolDiscriminator, QuestionPoolPush, QuestionPoolPushRequestReason, QuestionPoolPushRequestStatus, QuestionPoolSnapshot, QuestionPurpose, QuestionRecoverySnapshot, QuestionStrategy, QuestionVoidedReason, UnderspecificationType, } from "./domain/index.js";
33
+ export { QuestionerAgent } from "./question.agent.js";
34
+ export { createAskUserQuestionTools } from "./question.ask.tool.js";
35
+ export { createQuestionerTools } from "./question.tools.js";
36
+ export { INTENT_QUESTION_DAILY_CAP_DEFAULT, INTENT_QUESTION_DAILY_WINDOW_HOURS, intentQuestionDailyCap, isQuestionerEnabled, isUptakeGuardEnabled, uptakeAuthorityThreshold, } from "./question.env.js";
37
+ export { isValidQuestionerInputContract } from "./question.input.js";
38
+ export type { InflightQuestionerInput, PoolDiscoveryContext, PostStallQuestionerInput, QuestionerEnqueueFn, QuestionerEnqueuePayload, QuestionerInput, RecoveryQuestionerInput, UptakeQuestionerInput, } from "./question.input.js";
39
+ export type { ChatQuestionsHost, PersistableQuestion, PersistedQuestion, QuestionerDatabase, QuestionFilters, } from "./question.persistence.port.js";
40
+ export type { AskUserQuestionToolDeps, QuestionerToolDeps } from "./question.tools.port.js";
41
+ export { NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, UnderspecificationTypeSchema, } from "./question.schema.js";
42
+ export type { NegotiationQuestionCandidate, NegotiationQuestionProvenance, NegotiationQuestionPurpose, Question, QuestionGenerationResult, QuestionOption, QuestionPoolDiscriminator, QuestionPoolPush, QuestionPoolPushRequestReason, QuestionPoolPushRequestStatus, QuestionPoolSnapshot, QuestionPurpose, QuestionRecoverySnapshot, QuestionStrategy, QuestionVoidedReason, UnderspecificationType, } from "./question.schema.js";
@@ -1,2 +1,38 @@
1
- export { createAskUserQuestionTools, createQuestionerTools, INTENT_QUESTION_DAILY_CAP_DEFAULT, INTENT_QUESTION_DAILY_WINDOW_HOURS, intentQuestionDailyCap, isQuestionerEnabled, isUptakeGuardEnabled, isValidQuestionerInputContract, QuestionerAgent, uptakeAuthorityThreshold, } from "./application/index.js";
2
- export { NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, UnderspecificationTypeSchema, } from "./domain/index.js";
1
+ /**
2
+ * questions the capability's sole cross-capability surface.
3
+ *
4
+ * Anything outside this capability imports from here and nowhere else.
5
+ *
6
+ * ## What lives in the capability
7
+ *
8
+ * - **question.schema** — Zod schemas and derived types for the whole question
9
+ * vocabulary: the public Question shape, generator envelopes, and the
10
+ * detection/provenance/pool/recovery persistence sub-schemas.
11
+ * - **question.input** — per-mode context types, the discriminated
12
+ * QuestionerInput union, and `isValidQuestionerInputContract`, the runtime
13
+ * mirror of that discriminant enforced at queue boundaries.
14
+ * - **question.agent** — QuestionerAgent: stateless, mode-driven generation.
15
+ * - **question.presets** — system prompts and user-message builders per mode.
16
+ * - **question.env** — the QUESTIONER_* env accessors. All reads go through it.
17
+ * - **question.tools** / **question.ask.tool** — foreground adapters: the
18
+ * authenticated MCP read/answer tools, and the blocking chat
19
+ * `ask_user_question` tool.
20
+ * - **question.persistence.port** / **question.tools.port** — the injected
21
+ * host contracts (question CRUD, chat host bridge, tool host capabilities).
22
+ *
23
+ * Ambient generation (recovery, pool, uptake, inflight, push) is scheduled via
24
+ * the backend QuestionerQueue, which consumes the {@link QuestionerEnqueueFn}
25
+ * injected from the composition root.
26
+ *
27
+ * ## Boundary
28
+ *
29
+ * The capability imports from shared/ infrastructure and the negotiations
30
+ * barrel — never from runtime/, host implementations, or other capability
31
+ * internals.
32
+ */
33
+ export { QuestionerAgent } from "./question.agent.js";
34
+ export { createAskUserQuestionTools } from "./question.ask.tool.js";
35
+ export { createQuestionerTools } from "./question.tools.js";
36
+ export { INTENT_QUESTION_DAILY_CAP_DEFAULT, INTENT_QUESTION_DAILY_WINDOW_HOURS, intentQuestionDailyCap, isQuestionerEnabled, isUptakeGuardEnabled, uptakeAuthorityThreshold, } from "./question.env.js";
37
+ export { isValidQuestionerInputContract } from "./question.input.js";
38
+ export { NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, UnderspecificationTypeSchema, } from "./question.schema.js";
@@ -1,5 +1,5 @@
1
- import { type QuestionGenerationResult } from "../domain/question.schema.js";
2
- import { createStructuredModel } from "../../shared/agent/model.config.js";
1
+ import { type QuestionGenerationResult } from "./question.schema.js";
2
+ import { createStructuredModel } from "../shared/agent/model.config.js";
3
3
  import { type QuestionerInput } from "./question.input.js";
4
4
  export interface QuestionerAgentConfig {
5
5
  /** Optional model config override. */
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  /**
11
- * questions/application/question.agent — QuestionerAgent.
11
+ * questions/question.agent — QuestionerAgent.
12
12
  *
13
13
  * Stateless, mode-driven agent that generates structured decision questions
14
14
  * from arbitrary protocol contexts.
@@ -17,16 +17,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
17
17
  * single public `invoke()` method receives the full context per call.
18
18
  * The LLM model is bound once at construction; the preset (system prompt +
19
19
  * builder) is selected per invocation based on `input.mode`.
20
- *
21
- * IND-547: canonical home — previously questioner/questioner.agent.ts.
22
- * Legacy path is a thin compatibility shim pointing here.
23
20
  */
24
21
  import { HumanMessage, SystemMessage } from "@langchain/core/messages";
25
- import { QuestionGeneratorResponseSchema } from "../domain/question.schema.js";
26
- import { createStructuredModel } from "../../shared/agent/model.config.js";
27
- import { invokeWithAbortSignal } from "../../shared/agent/model-signal.js";
28
- import { protocolLogger } from "../../shared/observability/protocol.logger.js";
29
- import { Timed } from "../../shared/observability/performance.js";
22
+ import { QuestionGeneratorResponseSchema } from "./question.schema.js";
23
+ import { createStructuredModel } from "../shared/agent/model.config.js";
24
+ import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
25
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
26
+ import { Timed } from "../shared/observability/performance.js";
30
27
  import { getPreset } from "./question.presets.js";
31
28
  import { isValidQuestionerInputContract } from "./question.input.js";
32
29
  const logger = protocolLogger("QuestionerAgent");
@@ -1,5 +1,5 @@
1
- import type { DefineTool } from "../../shared/agent/tool.helpers.js";
2
- import type { AskUserQuestionToolDeps } from "../ports/question.tools.port.js";
1
+ import type { DefineTool } from "../shared/agent/tool.helpers.js";
2
+ import type { AskUserQuestionToolDeps } from "./question.tools.port.js";
3
3
  import { QuestionerAgent } from "./question.agent.js";
4
4
  /** Test seam: replace or reset the module-level QuestionerAgent singleton. */
5
5
  export declare function setQuestionerAgentForTesting(agent: QuestionerAgent | null): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * questions/application/question.ask.tool — foreground adapter: chat ask_user_question tool.
2
+ * questions/question.ask.tool — foreground adapter: chat ask_user_question tool.
3
3
  *
4
4
  * Blocking mid-conversation questions for the chat orchestrator
5
5
  * (AskUserQuestion-style human-in-the-loop).
@@ -26,14 +26,11 @@
26
26
  * Foreground adapter: registered by `createChatTools` only when
27
27
  * `deps.chatQuestions` is provided — never part of the MCP tool registry
28
28
  * (MCP clients have their own elicitation surface).
29
- *
30
- * IND-547: canonical home — previously questioner/questioner.ask.tool.ts.
31
- * Legacy path is a thin compatibility shim pointing here.
32
29
  */
33
30
  import { z } from "zod";
34
- import { error, success } from "../../shared/agent/tool.helpers.js";
35
- import { requestContext } from "../../shared/observability/request-context.js";
36
- import { protocolLogger } from "../../shared/observability/protocol.logger.js";
31
+ import { error, success } from "../shared/agent/tool.helpers.js";
32
+ import { requestContext } from "../shared/observability/request-context.js";
33
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
37
34
  import { QuestionerAgent } from "./question.agent.js";
38
35
  import { chatQuestionWaitTimeoutMs } from "./question.env.js";
39
36
  const logger = protocolLogger("AskUserQuestionTool");
@@ -1,5 +1,5 @@
1
1
  /**
2
- * questions/application/question.env — centralized question-generation env accessors.
2
+ * questions/question.env — centralized question-generation env accessors.
3
3
  *
4
4
  * Naming scheme (one prefix, hierarchical):
5
5
  *
@@ -18,9 +18,6 @@
18
18
  * All reads go through this module — do not read these variables via
19
19
  * `process.env` elsewhere. Values are read on every call (no caching) so tests
20
20
  * and long-lived processes observe changes.
21
- *
22
- * IND-547: canonical home — previously questioner/questioner.env.ts.
23
- * Legacy path is a thin compatibility shim pointing here.
24
21
  */
25
22
  export declare const CHAT_QUESTION_WAIT_TIMEOUT_MS_DEFAULT = 240000;
26
23
  export declare const UPTAKE_AUTHORITY_THRESHOLD_DEFAULT = 70;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * questions/application/question.env — centralized question-generation env accessors.
2
+ * questions/question.env — centralized question-generation env accessors.
3
3
  *
4
4
  * Naming scheme (one prefix, hierarchical):
5
5
  *
@@ -18,9 +18,6 @@
18
18
  * All reads go through this module — do not read these variables via
19
19
  * `process.env` elsewhere. Values are read on every call (no caching) so tests
20
20
  * and long-lived processes observe changes.
21
- *
22
- * IND-547: canonical home — previously questioner/questioner.env.ts.
23
- * Legacy path is a thin compatibility shim pointing here.
24
21
  */
25
22
  export const CHAT_QUESTION_WAIT_TIMEOUT_MS_DEFAULT = 240000;
26
23
  export const UPTAKE_AUTHORITY_THRESHOLD_DEFAULT = 70;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * questions/application/question.input — QuestionerAgent input envelope.
2
+ * questions/question.input — QuestionerAgent input envelope.
3
3
  *
4
4
  * Defines per-mode context types (IntentContext, NegotiationContext, …),
5
5
  * the discriminated QuestionerInput union, and the runtime validation guard
@@ -13,13 +13,10 @@
13
13
  * Foreground and ambient adapter entry points inject a `QuestionerEnqueueFn`
14
14
  * (defined here as a port alias) to schedule async generation without
15
15
  * importing the queue implementation.
16
- *
17
- * IND-547: canonical home — previously questioner/questioner.types.ts.
18
- * Legacy path is a thin compatibility shim pointing here.
19
16
  */
20
- import type { ToolScopeType } from "../../shared/agent/tool.scope.js";
21
- import type { NegotiationQuestionCandidate, QuestionMode, QuestionPoolDiscriminator } from "../domain/question.schema.js";
22
- import type { NegotiationConsultationReason } from "../../negotiations/index.js";
17
+ import type { ToolScopeType } from "../shared/agent/tool.scope.js";
18
+ import type { NegotiationQuestionCandidate, QuestionMode, QuestionPoolDiscriminator } from "./question.schema.js";
19
+ import type { NegotiationConsultationReason } from "../negotiations/index.js";
23
20
  /** Intent context — data needed to generate questions about an intent. */
24
21
  export interface IntentContext {
25
22
  intentId: string;
@@ -1,4 +1,4 @@
1
- import { NEGOTIATION_QUESTION_GENERIC_COUNTERPARTY, NEGOTIATION_QUESTION_GENERIC_NETWORK, NEGOTIATION_QUESTION_GENERIC_UPTAKE_ACTIVITY } from "../../negotiations/index.js";
1
+ import { NEGOTIATION_QUESTION_GENERIC_COUNTERPARTY, NEGOTIATION_QUESTION_GENERIC_NETWORK, NEGOTIATION_QUESTION_GENERIC_UPTAKE_ACTIVITY } from "../negotiations/index.js";
2
2
  /** Runtime mirror of the mode/purpose/context discriminant used at queue boundaries. */
3
3
  export function isValidQuestionerInputContract(input) {
4
4
  if (input.purpose === 'recovery') {
@@ -1,13 +1,11 @@
1
1
  /**
2
- * questions/ports/question.persistence.port — question persistence contracts.
2
+ * questions/question.persistence.port — question persistence contracts.
3
3
  *
4
4
  * Protocol-level persistence contract for structured questions generated by
5
5
  * QuestionerAgent. Implementations live in the backend and are injected into
6
6
  * ProtocolDeps.
7
- *
8
- * IND-547: canonical question persistence port.
9
7
  */
10
- import type { Question, QuestionMode, QuestionPurpose, QuestionStrategy, QuestionDetection, QuestionActor, QuestionAnswer, UnderspecificationType } from "../domain/question.schema.js";
8
+ import type { Question, QuestionMode, QuestionPurpose, QuestionStrategy, QuestionDetection, QuestionActor, QuestionAnswer, UnderspecificationType } from "./question.schema.js";
11
9
  /** Shape accepted by `persist()` — everything needed to insert a question row. */
12
10
  export interface PersistableQuestion {
13
11
  detection: QuestionDetection;
@@ -1,13 +1,10 @@
1
1
  /**
2
- * questions/application/question.presets — mode presets for QuestionerAgent.
2
+ * questions/question.presets — mode presets for QuestionerAgent.
3
3
  *
4
4
  * Each preset provides a system prompt and a buildPrompt function that assembles
5
5
  * the user message from a typed context object.
6
- *
7
- * IND-547: canonical home — previously questioner/questioner.presets.ts.
8
- * Legacy path is a thin compatibility shim pointing here.
9
6
  */
10
- import type { QuestionMode, QuestionPurpose } from "../domain/question.schema.js";
7
+ import type { QuestionMode, QuestionPurpose } from "./question.schema.js";
11
8
  export interface QuestionerPreset {
12
9
  /** The LLM system prompt for this mode. */
13
10
  systemPrompt: string;
@@ -1,5 +1,15 @@
1
- import { QUD_UNDERSPECIFICATION_RULES } from "./question.qud.js";
2
- import { consultationPromptFor } from "../../negotiations/index.js";
1
+ import { consultationPromptFor } from "../negotiations/index.js";
2
+ /**
3
+ * Questions Under Discussion taxonomy, appended to every preset's system prompt.
4
+ * Every mode carries it because the structured output schema requires the
5
+ * internal `underspecificationType` field; intent and discovery are the primary
6
+ * consumers of non-null classifications.
7
+ */
8
+ const QUD_UNDERSPECIFICATION_RULES = `QUD underspecification taxonomy. For every structured question, emit a required \`underspecificationType\` field. Use exactly one category only when the question repairs that kind of underspecification:
9
+ - missing_constituent: an absent core participant, entity, or outcome (who/what).
10
+ - missing_constraint: the core target exists, but a ranking boundary is missing (where/when/how/how much).
11
+ - open_alternative_set: an unresolved choice among materially different interpretations or scopes.
12
+ Use null for adjacent, reflective, emergent, or any other question that does not repair underspecification. Strategy and underspecification type are orthogonal: \`strategy\` describes the conversational move; \`underspecificationType\` describes the QUD defect repaired. Never infer one mechanically from the other.`;
3
13
  /**
4
14
  * Shared rule block appended to every questioner system prompt. Enforces that
5
15
  * the generated `prompt` resolves on its own — no demonstratives/anaphora that