@monoes/monomindcli 2.16.13 → 2.16.14

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 (171) hide show
  1. package/README.md +1 -1
  2. package/dist/src/commands/org-control.d.ts +117 -0
  3. package/dist/src/commands/org-control.d.ts.map +1 -0
  4. package/dist/src/commands/org-control.js +274 -0
  5. package/dist/src/commands/org-control.js.map +1 -0
  6. package/dist/src/commands/org-lifecycle.d.ts +7 -0
  7. package/dist/src/commands/org-lifecycle.d.ts.map +1 -0
  8. package/dist/src/commands/org-lifecycle.js +298 -0
  9. package/dist/src/commands/org-lifecycle.js.map +1 -0
  10. package/dist/src/commands/org-manage.d.ts +7 -0
  11. package/dist/src/commands/org-manage.d.ts.map +1 -0
  12. package/dist/src/commands/org-manage.js +357 -0
  13. package/dist/src/commands/org-manage.js.map +1 -0
  14. package/dist/src/commands/org-memory-command.d.ts +3 -0
  15. package/dist/src/commands/org-memory-command.d.ts.map +1 -0
  16. package/dist/src/commands/org-memory-command.js +178 -0
  17. package/dist/src/commands/org-memory-command.js.map +1 -0
  18. package/dist/src/commands/org-observe-approvals.d.ts +8 -0
  19. package/dist/src/commands/org-observe-approvals.d.ts.map +1 -0
  20. package/dist/src/commands/org-observe-approvals.js +211 -0
  21. package/dist/src/commands/org-observe-approvals.js.map +1 -0
  22. package/dist/src/commands/org-observe-checkpoint.d.ts +26 -0
  23. package/dist/src/commands/org-observe-checkpoint.d.ts.map +1 -0
  24. package/dist/src/commands/org-observe-checkpoint.js +180 -0
  25. package/dist/src/commands/org-observe-checkpoint.js.map +1 -0
  26. package/dist/src/commands/org-observe-config.d.ts +8 -0
  27. package/dist/src/commands/org-observe-config.d.ts.map +1 -0
  28. package/dist/src/commands/org-observe-config.js +160 -0
  29. package/dist/src/commands/org-observe-config.js.map +1 -0
  30. package/dist/src/commands/org-observe-gates.d.ts +4 -0
  31. package/dist/src/commands/org-observe-gates.d.ts.map +1 -0
  32. package/dist/src/commands/org-observe-gates.js +182 -0
  33. package/dist/src/commands/org-observe-gates.js.map +1 -0
  34. package/dist/src/commands/org-observe-inbox.d.ts +18 -0
  35. package/dist/src/commands/org-observe-inbox.d.ts.map +1 -0
  36. package/dist/src/commands/org-observe-inbox.js +154 -0
  37. package/dist/src/commands/org-observe-inbox.js.map +1 -0
  38. package/dist/src/commands/org-observe-logs.d.ts +31 -0
  39. package/dist/src/commands/org-observe-logs.d.ts.map +1 -0
  40. package/dist/src/commands/org-observe-logs.js +272 -0
  41. package/dist/src/commands/org-observe-logs.js.map +1 -0
  42. package/dist/src/commands/org-observe-questions.d.ts +8 -0
  43. package/dist/src/commands/org-observe-questions.d.ts.map +1 -0
  44. package/dist/src/commands/org-observe-questions.js +201 -0
  45. package/dist/src/commands/org-observe-questions.js.map +1 -0
  46. package/dist/src/commands/org-observe-report.d.ts +8 -0
  47. package/dist/src/commands/org-observe-report.d.ts.map +1 -0
  48. package/dist/src/commands/org-observe-report.js +366 -0
  49. package/dist/src/commands/org-observe-report.js.map +1 -0
  50. package/dist/src/commands/org-observe-shared.d.ts +20 -0
  51. package/dist/src/commands/org-observe-shared.d.ts.map +1 -0
  52. package/dist/src/commands/org-observe-shared.js +55 -0
  53. package/dist/src/commands/org-observe-shared.js.map +1 -0
  54. package/dist/src/commands/org-observe.d.ts +9 -101
  55. package/dist/src/commands/org-observe.d.ts.map +1 -1
  56. package/dist/src/commands/org-observe.js +12 -1675
  57. package/dist/src/commands/org-observe.js.map +1 -1
  58. package/dist/src/commands/org-poll.d.ts +57 -0
  59. package/dist/src/commands/org-poll.d.ts.map +1 -0
  60. package/dist/src/commands/org-poll.js +194 -0
  61. package/dist/src/commands/org-poll.js.map +1 -0
  62. package/dist/src/commands/org-run.d.ts +3 -0
  63. package/dist/src/commands/org-run.d.ts.map +1 -0
  64. package/dist/src/commands/org-run.js +449 -0
  65. package/dist/src/commands/org-run.js.map +1 -0
  66. package/dist/src/commands/org-serve.d.ts +19 -0
  67. package/dist/src/commands/org-serve.d.ts.map +1 -0
  68. package/dist/src/commands/org-serve.js +395 -0
  69. package/dist/src/commands/org-serve.js.map +1 -0
  70. package/dist/src/commands/org-subcommands-config.d.ts +8 -0
  71. package/dist/src/commands/org-subcommands-config.d.ts.map +1 -0
  72. package/dist/src/commands/org-subcommands-config.js +93 -0
  73. package/dist/src/commands/org-subcommands-config.js.map +1 -0
  74. package/dist/src/commands/org-subcommands-hil.d.ts +11 -0
  75. package/dist/src/commands/org-subcommands-hil.d.ts.map +1 -0
  76. package/dist/src/commands/org-subcommands-hil.js +216 -0
  77. package/dist/src/commands/org-subcommands-hil.js.map +1 -0
  78. package/dist/src/commands/org-subcommands-observe.d.ts +12 -0
  79. package/dist/src/commands/org-subcommands-observe.d.ts.map +1 -0
  80. package/dist/src/commands/org-subcommands-observe.js +249 -0
  81. package/dist/src/commands/org-subcommands-observe.js.map +1 -0
  82. package/dist/src/commands/org-subcommands-runtime.d.ts +12 -0
  83. package/dist/src/commands/org-subcommands-runtime.d.ts.map +1 -0
  84. package/dist/src/commands/org-subcommands-runtime.js +163 -0
  85. package/dist/src/commands/org-subcommands-runtime.js.map +1 -0
  86. package/dist/src/commands/org.d.ts +3 -151
  87. package/dist/src/commands/org.d.ts.map +1 -1
  88. package/dist/src/commands/org.js +43 -2735
  89. package/dist/src/commands/org.js.map +1 -1
  90. package/dist/src/orgrt/daemon-types.d.ts +196 -0
  91. package/dist/src/orgrt/daemon-types.d.ts.map +1 -0
  92. package/dist/src/orgrt/daemon-types.js +38 -0
  93. package/dist/src/orgrt/daemon-types.js.map +1 -0
  94. package/dist/src/orgrt/daemon.d.ts +70 -300
  95. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  96. package/dist/src/orgrt/daemon.js +41 -2536
  97. package/dist/src/orgrt/daemon.js.map +1 -1
  98. package/dist/src/orgrt/idle-watchdog.d.ts +39 -0
  99. package/dist/src/orgrt/idle-watchdog.d.ts.map +1 -0
  100. package/dist/src/orgrt/idle-watchdog.js +289 -0
  101. package/dist/src/orgrt/idle-watchdog.js.map +1 -0
  102. package/dist/src/orgrt/org-reload.d.ts +7 -0
  103. package/dist/src/orgrt/org-reload.d.ts.map +1 -0
  104. package/dist/src/orgrt/org-reload.js +111 -0
  105. package/dist/src/orgrt/org-reload.js.map +1 -0
  106. package/dist/src/orgrt/org-start-steps.d.ts +21 -0
  107. package/dist/src/orgrt/org-start-steps.d.ts.map +1 -0
  108. package/dist/src/orgrt/org-start-steps.js +305 -0
  109. package/dist/src/orgrt/org-start-steps.js.map +1 -0
  110. package/dist/src/orgrt/org-start.d.ts +7 -0
  111. package/dist/src/orgrt/org-start.d.ts.map +1 -0
  112. package/dist/src/orgrt/org-start.js +435 -0
  113. package/dist/src/orgrt/org-start.js.map +1 -0
  114. package/dist/src/orgrt/org-state-file.d.ts +8 -0
  115. package/dist/src/orgrt/org-state-file.d.ts.map +1 -0
  116. package/dist/src/orgrt/org-state-file.js +116 -0
  117. package/dist/src/orgrt/org-state-file.js.map +1 -0
  118. package/dist/src/orgrt/org-stop.d.ts +6 -0
  119. package/dist/src/orgrt/org-stop.d.ts.map +1 -0
  120. package/dist/src/orgrt/org-stop.js +332 -0
  121. package/dist/src/orgrt/org-stop.js.map +1 -0
  122. package/dist/src/orgrt/org-tools.d.ts +11 -0
  123. package/dist/src/orgrt/org-tools.d.ts.map +1 -0
  124. package/dist/src/orgrt/org-tools.js +305 -0
  125. package/dist/src/orgrt/org-tools.js.map +1 -0
  126. package/dist/src/orgrt/role-incarnation.d.ts +18 -0
  127. package/dist/src/orgrt/role-incarnation.d.ts.map +1 -0
  128. package/dist/src/orgrt/role-incarnation.js +374 -0
  129. package/dist/src/orgrt/role-incarnation.js.map +1 -0
  130. package/dist/src/orgrt/role-respawn.d.ts +7 -0
  131. package/dist/src/orgrt/role-respawn.d.ts.map +1 -0
  132. package/dist/src/orgrt/role-respawn.js +318 -0
  133. package/dist/src/orgrt/role-respawn.js.map +1 -0
  134. package/dist/src/orgrt/role-session-opts.d.ts +389 -0
  135. package/dist/src/orgrt/role-session-opts.d.ts.map +1 -0
  136. package/dist/src/orgrt/role-session-opts.js +289 -0
  137. package/dist/src/orgrt/role-session-opts.js.map +1 -0
  138. package/dist/src/orgrt/runner-resolve.d.ts +43 -0
  139. package/dist/src/orgrt/runner-resolve.d.ts.map +1 -0
  140. package/dist/src/orgrt/runner-resolve.js +77 -0
  141. package/dist/src/orgrt/runner-resolve.js.map +1 -0
  142. package/dist/src/orgrt/session-gate.d.ts +34 -0
  143. package/dist/src/orgrt/session-gate.d.ts.map +1 -0
  144. package/dist/src/orgrt/session-gate.js +74 -0
  145. package/dist/src/orgrt/session-gate.js.map +1 -0
  146. package/dist/src/orgrt/session-prompt.d.ts +31 -0
  147. package/dist/src/orgrt/session-prompt.d.ts.map +1 -0
  148. package/dist/src/orgrt/session-prompt.js +115 -0
  149. package/dist/src/orgrt/session-prompt.js.map +1 -0
  150. package/dist/src/orgrt/session-run.d.ts +18 -0
  151. package/dist/src/orgrt/session-run.d.ts.map +1 -0
  152. package/dist/src/orgrt/session-run.js +429 -0
  153. package/dist/src/orgrt/session-run.js.map +1 -0
  154. package/dist/src/orgrt/session-stream.d.ts +21 -0
  155. package/dist/src/orgrt/session-stream.d.ts.map +1 -0
  156. package/dist/src/orgrt/session-stream.js +173 -0
  157. package/dist/src/orgrt/session-stream.js.map +1 -0
  158. package/dist/src/orgrt/session-types.d.ts +219 -0
  159. package/dist/src/orgrt/session-types.d.ts.map +1 -0
  160. package/dist/src/orgrt/session-types.js +2 -0
  161. package/dist/src/orgrt/session-types.js.map +1 -0
  162. package/dist/src/orgrt/session-usage.d.ts +29 -0
  163. package/dist/src/orgrt/session-usage.d.ts.map +1 -0
  164. package/dist/src/orgrt/session-usage.js +64 -0
  165. package/dist/src/orgrt/session-usage.js.map +1 -0
  166. package/dist/src/orgrt/session.d.ts +5 -281
  167. package/dist/src/orgrt/session.d.ts.map +1 -1
  168. package/dist/src/orgrt/session.js +8 -1117
  169. package/dist/src/orgrt/session.js.map +1 -1
  170. package/dist/tsconfig.tsbuildinfo +1 -1
  171. package/package.json +6 -6
@@ -1,276 +1,7 @@
1
- import type { query } from '@anthropic-ai/claude-agent-sdk';
2
- import type { AgentRunner, OrgToolDef } from './agent-runner.js';
3
- import type { OrgBus } from './bus.js';
4
- import type { TaskEvidence } from './completion-gate.js';
5
- import type { RoleFence } from './fence.js';
6
- import type { LoadoutSummary, ResolvedLoadout } from './loadouts.js';
7
- import { Mailbox } from './mailbox.js';
8
- import type { Decision, PolicyEngine } from './policy.js';
9
- import { type TaskProcesses } from './task-cancel.js';
10
- import type { RolePick, TaskPick } from './task-match.js';
11
- import { type DecisionKind, type OrgDef, type OrgRole } from './types.js';
12
- import { SessionLedger } from './session-ledger.js';
13
- /**
14
- * Resolves the extra system-prompt block for a role: its pinned library
15
- * skills and on-demand skill catalog (skill-library.ts) plus the role's own
16
- * `instructions_file`, if any — all optional and independent. A missing or
17
- * unreadable `instructions_file` is skipped (not an error): a role shouldn't
18
- * fail to start a session over a stale/typo'd custom-file path.
19
- */
20
- export declare function resolveRoleExtraGuidance(role: OrgRole, projectRoot?: string): string | undefined;
21
- /** Resolve the model string for a role: explicit adapter_config.model wins;
22
- * otherwise fall back to the vendor/runtime default.
23
- *
24
- * Vendor defaults are read straight off VERCEL_PROVIDERS, which already
25
- * carries a defaultModel per vendor. A second hand-kept table lived here and
26
- * restated all sixteen of them — two lists of per-vendor defaults that would
27
- * eventually disagree, which is precisely the drift #252 was. An empty
28
- * registry default (openai-compatible, which serves arbitrary endpoints) is
29
- * falsy and so falls through to the runtime switch, as it always did. */
30
- export declare function resolveModel(role: OrgRole, runtime?: string, vendor?: string): string;
31
- export type DeliverFn = (from: string, to: string, subject: string, body: string) => Promise<string>;
32
- /** The SDK's `canUseTool` gate, composed from two independent layers: PolicyEngine's
33
- * static config checks (deny/allow lists, path scoping, git level, web allowlist,
34
- * budget), then — only for calls policy would allow — the human-approval guardrail
35
- * (`beforeTool`, i.e. daemon.checkApproval) for whatever action names it treats as
36
- * sensitive (Bash/WebFetch/WebSearch/org_complete). Exported standalone so this
37
- * composition is unit-testable without spinning up a real SDK session: previously
38
- * `beforeTool` was wired into SessionOpts but never actually called from here, so
39
- * none of those sensitive actions ever paused for a human. */
40
- export declare function gatedCanUseTool(policy: PolicyEngine, beforeTool: SessionOpts['beforeTool'], roleId: string, fence?: RoleFence,
41
- /** Optional hook invoked whenever this gate denies a tool call — wired to
42
- * daemon.recordDecision() so denials show up in `org decisions` traces.
43
- * #290: `kind` names WHICH of this function's four deny paths fired, so a
44
- * consumer never has to tell a fence block from a routine pending approval
45
- * by matching the English in the message. */
46
- onDeny?: (toolName: string, input: Record<string, unknown>, decision: Extract<Decision, {
47
- behavior: 'deny';
48
- }>, kind: DecisionKind) => void,
49
- /** ORG-9: reports whether this role has a pending (unresolved) decision gate.
50
- * org_gate is documented as creating a "hard-blocking" checkpoint, but until
51
- * this was wired in nothing actually stopped tool use while a gate sat
52
- * pending — only approvals did that. When set and true, ALL tool calls are
53
- * denied (not just the sensitive subset approvals gate) until the gate is
54
- * resolved, matching the "hard-blocking" description. */
55
- hasPendingGate?: () => boolean): (toolName: string, input: Record<string, unknown>,
56
- /** #289: the harness's id for this call, forwarded to policy.decide so the
57
- * invocation event can be joined to the later tool_result event. */
58
- meta?: {
59
- toolUseId?: string;
60
- }) => Promise<Decision>;
61
- export interface SessionOpts {
62
- org: string;
63
- role: OrgRole;
64
- bus: OrgBus;
65
- policy: PolicyEngine;
66
- mailbox: Mailbox;
67
- cwd: string;
68
- /** Org state directory (`.monomind/orgs/<name>`). Used to pass
69
- * MONOMIND_ORG_DIR to runners that persist per-role state (VercelAgentRunner
70
- * stores session history under `<orgDir>/sessions/`). */
71
- orgDir?: string;
72
- /** Project root for resolving `adapter_config.provider` named providers
73
- * (config search must start at the project root even when the role's
74
- * workspace cwd is an isolated scratch dir). Defaults to opts.cwd. */
75
- orgRoot?: string;
76
- /** Run id of the org run this session belongs to (MONOMIND_ORG_RUN). */
77
- run?: string;
78
- /** M1: build this session's tool-provider tools (role `tool_providers`).
79
- * Called once per session start; the returned set is closed (provider
80
- * processes killed) when the session ends. */
81
- buildProviderTools?: () => Promise<{
82
- tools: OrgToolDef[];
83
- close(): void;
84
- } | undefined>;
85
- deliver: DeliverFn;
86
- askHuman?: (role: string, question: string, blocking?: boolean) => Promise<string>;
87
- /** Coordinator-only: records the run's outcome (daemon persists it to run
88
- * history) — #302: the daemon gathers the facts, calls the completion
89
- * gate, and returns a refusal string instead of recording anything when
90
- * the call is unsatisfiable; `null`/`undefined` means allowed. */
91
- onComplete?: (role: string, outcome: 'achieved' | 'partial' | 'failed', summary: string, blocker?: 'budget' | 'human' | 'external' | 'time', blockerDetail?: string) => string | null | undefined;
92
- /** Present only for the selected coordinator (same gating pattern as
93
- * onComplete) — mid-run role replacement. Returns the JSON-shaped
94
- * RespawnReceipt (see role-slot.ts). */
95
- onRespawnRole?: (callerId: string, args: {
96
- roleId: string;
97
- runtime?: string;
98
- model?: string;
99
- providerName?: string;
100
- budgetTokens?: number;
101
- reason: string;
102
- briefing: string;
103
- }) => Promise<unknown>;
104
- /** Present only for the selected coordinator. Returns the JSON-shaped
105
- * runtime/named-provider listing (see runtime-options.ts). */
106
- onListRuntimeOptions?: () => Promise<unknown>;
107
- /** Search the org's accumulated cross-run memory (memory_namespace). */
108
- recall?: (role: string, query: string) => Promise<string>;
109
- /** Write a memory deliberately: scope 'org' (shared, default) or 'agent' (private to this role). */
110
- remember?: (role: string, content: string, scope: 'org' | 'agent') => Promise<string>;
111
- /** Persist extracted entities/relations/rules into the org's knowledge graph. */
112
- learn?: (role: string, payload: {
113
- nodes?: {
114
- name: string;
115
- type?: string;
116
- description?: string;
117
- }[];
118
- edges?: {
119
- source: string;
120
- target: string;
121
- relation: string;
122
- description?: string;
123
- }[];
124
- rules?: {
125
- rule: string;
126
- context?: string;
127
- }[];
128
- }) => Promise<string>;
129
- /** Top existing KG entity names - injected into the coordinator prompt so
130
- * extraction reuses canonical names instead of minting near-duplicates. */
131
- glossary?: string[];
132
- /** Search the user's Second Brain (project documents + personal global brain). */
133
- searchKnowledge?: (role: string, query: string) => Promise<string>;
134
- /** Guardrail beforeTool hook: checks if a tool call requires approval before execution.
135
- * `input` is the tool's actual call arguments — required so the approval cache can
136
- * key on what's actually being called (e.g. the Bash command, the WebFetch url),
137
- * not just the tool name; see approvals.ts's checkApproval for why. */
138
- beforeTool?: (role: string, toolName: string, input: Record<string, unknown>) => Promise<boolean | null>;
139
- /** Called whenever gatedCanUseTool denies a tool call — wired to daemon.recordDecision()
140
- * so those denials show up in `org decisions` traces. `kind` (#290) says which
141
- * deny path fired, so the trace is machine-readable rather than prose-only. */
142
- onDecision?: (role: string, toolName: string, message: string, kind: DecisionKind) => void;
143
- /** ORG-9: reports whether this role currently has a pending decision gate —
144
- * wired to daemon.listGates(org, 'pending'). When true, gatedCanUseTool
145
- * denies every tool call until the gate is resolved. */
146
- hasPendingGate?: () => boolean;
147
- def?: OrgDef;
148
- maxTurns?: number;
149
- queryFn?: typeof query;
150
- /** Provider-agnostic runner. Takes precedence over queryFn. When unset,
151
- * session.ts builds a ClaudeAgentRunner from queryFn (or the default),
152
- * preserving the previous Claude-only behaviour exactly. */
153
- runner?: AgentRunner;
154
- /** Caller-owned cancellation handle for THIS incarnation. Every session
155
- * attempt runs on its own AbortController linked to this one: aborting it
156
- * aborts the in-flight attempt, which lets the daemon force-stop a specific
157
- * incarnation (org stop, mid-run role replacement's forced-stop step)
158
- * without reaching into runAgentSession's internals. An attempt's own abort
159
- * (the silent-stream kill) never propagates back to it (#256). */
160
- externalAbort?: AbortController;
161
- /** Lets org_task_cancel end this role's task-scoped process for the
162
- * cancelled task (task-cancel.ts). */
163
- taskProcesses?: TaskProcesses;
164
- /** Override how long a session's first stream pull may stay silent before
165
- * the attempt is aborted and retried (tests only; default 4 minutes). */
166
- silentSessionMs?: number;
167
- /** ID of the last message received by this agent (for threading responses). Function to ensure live reading. */
168
- lastMessageId?: () => string | undefined;
169
- /** Callback for each output line — feeds ScrollbackBuffer. */
170
- onOutput?: (line: string) => void;
171
- /** Callback when the SDK assigns a session ID — enables checkpoint resume (P2-13). */
172
- onSessionId?: (id: string) => void;
173
- /** Called once per finished turn (the runner's `result` message), so the
174
- * daemon can check what the role left open before its session parks. */
175
- onTurnEnd?: () => void;
176
- /** SDK session ID persisted in a checkpoint from a prior run — when set, the
177
- * first query() call resumes it instead of starting a fresh conversation
178
- * (P2-13: this is what actually makes checkpoint resume resume). */
179
- resumeSessionId?: string;
180
- /** ADR-O001 D3: the run's task-keyed session records. Every session run is
181
- * recorded here (sessionIdBefore/After) in every scope; only
182
- * `session_scope: 'task'` resumes from it. Omitted = in-memory. */
183
- sessionLedger?: SessionLedger;
184
- /** Circuit breaker config for this role. */
185
- circuitBreaker?: {
186
- threshold: number;
187
- state: {
188
- failures: number;
189
- tripped: boolean;
190
- };
191
- };
192
- /** Called when the coordinator's context window is exhausted. */
193
- onContextLimit?: () => void;
194
- /** MonoFence guardrail instance for this role. */
195
- fence?: RoleFence;
196
- /** Decision gate: creates a hard-blocking human-approval checkpoint. */
197
- onGate?: (role: string, name: string, description: string) => Promise<string>;
198
- /** Task DAG: create a task with dependencies. `loadout` (ADR-O001 D7) is
199
- * the catalog entry the caller selected; only offered when the org has a
200
- * catalog (`loadoutCatalog`). */
201
- createTask?: (role: string, title: string, assignee: string, deps: string[], loadout?: string, brief?: string, pick?: TaskPick) => string;
202
- /** Resolves `assignee: "auto"` on org_task from the title and brief: the
203
- * decision model (or, without one, a keyword match over role titles and
204
- * responsibilities) picks among the agent roles other than `caller`.
205
- * `role: null` = no role fits (or the best ones tie); the caller must name
206
- * one. The pick is recorded on the task (OrgTask.pick). */
207
- pickAssignee?: (title: string, brief: string | undefined, caller: string) => Promise<RolePick>;
208
- /** Called after org_skill_load served one of the role's skills, so the
209
- * daemon can record it against a task that suggested it. */
210
- onSkillLoad?: (role: string, name: string) => void;
211
- /** ADR-O001 D7: the org's loadout catalog. Set only when the org declares
212
- * one; it adds the optional `loadout` argument to org_task/org_plan_graph.
213
- * Unset, those tools are byte-identical to before (same gating idea as
214
- * `requireTaskEvidence`). Identical for every role and every loadout, so
215
- * the tool list — prefix position 0 — never varies with the loadout. */
216
- loadoutCatalog?: LoadoutSummary[];
217
- /** ADR-O001 D7: the loadout THIS session's system prompt is built with.
218
- * Plain data resolved by the caller before the session starts, so it is
219
- * fixed for the session's whole life — every maxTurns/crash restart
220
- * rebuilds the identical prompt, and nothing can edit it mid-session.
221
- * D3 hook: a task-keyed session for (role, taskKey) passes
222
- * `resolveLoadout(def, task.loadout, root)` here. */
223
- loadout?: ResolvedLoadout;
224
- /** ADR-O001 D3 x D7: in task scope each task's session is built with that
225
- * task's recorded loadout (undefined = none selected) instead of the
226
- * incarnation's `loadout`, which then only serves untagged mail. */
227
- loadoutFor?: (taskId: string) => ResolvedLoadout | undefined;
228
- /** Task DAG: mark a task as completed. `evidence` is ADR-O001 D5's
229
- * machine-checkable proof — acceptance commands with their real exit
230
- * codes, pinned to a commit sha. Only demanded when the org sets
231
- * run_config.completion_evidence (see `requireTaskEvidence`). */
232
- completeTask?: (role: string, taskId: string, result?: string, evidence?: TaskEvidence) => string;
233
- /** run_config.completion_evidence: when true, org_task_done advertises the
234
- * evidence argument as required. Off by default, so a role in an org that
235
- * has not opted in sees a byte-identical tool description (D7: the tool
236
- * list is prefix position 0 — changing it for every org would invalidate
237
- * every cached prompt). */
238
- requireTaskEvidence?: boolean;
239
- /** ADR-O001 D6: request an artifact-only review. Set only when the org has
240
- * a role with review_input: 'artifact-only'; otherwise org_review is not
241
- * registered and the tool list is unchanged. */
242
- requestReview?: (role: string, taskId: string, reviewer: string, base?: string) => string;
243
- /** Task DAG: list all tasks, or just `taskId`. */
244
- listTasks?: (taskId?: string) => string;
245
- splitTask?: (role: string, parentId: string, children: {
246
- title: string;
247
- assignee: string;
248
- }[]) => string;
249
- mergeTask?: (role: string, sourceId: string, targetId: string) => string;
250
- cancelTask?: (role: string, taskId: string, reason?: string) => string;
251
- /** Task DAG: mark a 'running' task as waiting on a real-world time (not a
252
- * dependency) — e.g. a scheduled soak test, a CI run, a human-set
253
- * deadline. The idle watchdog skips nudging while any task is actively
254
- * blocked, auto-resumes (re-dispatches) it once the time passes, and
255
- * wakes its assignee to re-check it every recheckAfterMinutes (#329). */
256
- blockTask?: (role: string, taskId: string, untilIso: string, reason?: string, recheckAfterMinutes?: number) => string;
257
- planGraph?: (role: string, specs: {
258
- name: string;
259
- title: string;
260
- assignee: string;
261
- after?: string[];
262
- loadout?: string;
263
- brief?: string;
264
- }[]) => string;
265
- }
266
- /** Role briefing given to each agent session (SDK systemPrompt option).
267
- * `extraGuidance` carries pre-resolved text the caller already loaded from
268
- * disk — the role's library skills and/or its own `instructions_file`,
269
- * if either resolved to something. Kept as a plain string param (not read here)
270
- * so this function stays synchronous/pure and trivially testable. */
271
- export declare function buildRolePrompt(role: OrgRole, def: Pick<OrgDef, 'name' | 'goal'>, roster: string[], glossary?: string[], extraGuidance?: string,
272
- /** M2: one line per endpoint role (endpointBriefingLines) — boss only. */
273
- endpointBriefing?: string[]): string;
1
+ import type { SessionOpts } from './session-types.js';
2
+ export { gatedCanUseTool } from './session-gate.js';
3
+ export { buildRolePrompt, resolveModel, resolveRoleExtraGuidance, } from './session-prompt.js';
4
+ export type { DeliverFn, SessionOpts } from './session-types.js';
274
5
  /**
275
6
  * Runs a role for the life of the org, transparently restarting the
276
7
  * underlying SDK session whenever it ends on its own (`maxTurns` reached)
@@ -282,13 +13,6 @@ endpointBriefing?: string[]): string;
282
13
  * deliver() kept queuing new messages into a mailbox nobody was reading.
283
14
  */
284
15
  export declare function runAgentSession(opts: SessionOpts): Promise<void>;
285
- /** Build the org tool surface as platform-agnostic OrgToolDef[]. The handlers
286
- * close over sessionOpts callbacks (deliver, recall, remember, …) — same
287
- * wiring as the previous inline createSdkMcpServer block, just decoupled from
288
- * the Claude SDK's tool() shape so any AgentRunner can host them.
289
- *
290
- * Behaviour is identical to the old inline definitions: conditional tools are
291
- * gated on their callback being present, org_send/ask_human are always added. */
16
+ export { buildOrgTools } from './org-tools.js';
292
17
  export { AUTO_ASSIGNEE } from './task-tools.js';
293
- export declare function buildOrgTools(opts: SessionOpts): OrgToolDef[];
294
18
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/orgrt/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,KAAK,EAAgB,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAKtE,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,MAAM,EACX,KAAK,OAAO,EAEb,MAAM,YAAY,CAAC;AAqBpB,OAAO,EAIL,aAAa,EACd,MAAM,qBAAqB,CAAC;AAM7B;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAahG;AAED;;;;;;;;0EAQ0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAA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