@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.
- package/README.md +1 -1
- package/dist/src/commands/org-control.d.ts +117 -0
- package/dist/src/commands/org-control.d.ts.map +1 -0
- package/dist/src/commands/org-control.js +274 -0
- package/dist/src/commands/org-control.js.map +1 -0
- package/dist/src/commands/org-lifecycle.d.ts +7 -0
- package/dist/src/commands/org-lifecycle.d.ts.map +1 -0
- package/dist/src/commands/org-lifecycle.js +298 -0
- package/dist/src/commands/org-lifecycle.js.map +1 -0
- package/dist/src/commands/org-manage.d.ts +7 -0
- package/dist/src/commands/org-manage.d.ts.map +1 -0
- package/dist/src/commands/org-manage.js +357 -0
- package/dist/src/commands/org-manage.js.map +1 -0
- package/dist/src/commands/org-memory-command.d.ts +3 -0
- package/dist/src/commands/org-memory-command.d.ts.map +1 -0
- package/dist/src/commands/org-memory-command.js +178 -0
- package/dist/src/commands/org-memory-command.js.map +1 -0
- package/dist/src/commands/org-observe-approvals.d.ts +8 -0
- package/dist/src/commands/org-observe-approvals.d.ts.map +1 -0
- package/dist/src/commands/org-observe-approvals.js +211 -0
- package/dist/src/commands/org-observe-approvals.js.map +1 -0
- package/dist/src/commands/org-observe-checkpoint.d.ts +26 -0
- package/dist/src/commands/org-observe-checkpoint.d.ts.map +1 -0
- package/dist/src/commands/org-observe-checkpoint.js +180 -0
- package/dist/src/commands/org-observe-checkpoint.js.map +1 -0
- package/dist/src/commands/org-observe-config.d.ts +8 -0
- package/dist/src/commands/org-observe-config.d.ts.map +1 -0
- package/dist/src/commands/org-observe-config.js +160 -0
- package/dist/src/commands/org-observe-config.js.map +1 -0
- package/dist/src/commands/org-observe-gates.d.ts +4 -0
- package/dist/src/commands/org-observe-gates.d.ts.map +1 -0
- package/dist/src/commands/org-observe-gates.js +182 -0
- package/dist/src/commands/org-observe-gates.js.map +1 -0
- package/dist/src/commands/org-observe-inbox.d.ts +18 -0
- package/dist/src/commands/org-observe-inbox.d.ts.map +1 -0
- package/dist/src/commands/org-observe-inbox.js +154 -0
- package/dist/src/commands/org-observe-inbox.js.map +1 -0
- package/dist/src/commands/org-observe-logs.d.ts +31 -0
- package/dist/src/commands/org-observe-logs.d.ts.map +1 -0
- package/dist/src/commands/org-observe-logs.js +272 -0
- package/dist/src/commands/org-observe-logs.js.map +1 -0
- package/dist/src/commands/org-observe-questions.d.ts +8 -0
- package/dist/src/commands/org-observe-questions.d.ts.map +1 -0
- package/dist/src/commands/org-observe-questions.js +201 -0
- package/dist/src/commands/org-observe-questions.js.map +1 -0
- package/dist/src/commands/org-observe-report.d.ts +8 -0
- package/dist/src/commands/org-observe-report.d.ts.map +1 -0
- package/dist/src/commands/org-observe-report.js +366 -0
- package/dist/src/commands/org-observe-report.js.map +1 -0
- package/dist/src/commands/org-observe-shared.d.ts +20 -0
- package/dist/src/commands/org-observe-shared.d.ts.map +1 -0
- package/dist/src/commands/org-observe-shared.js +55 -0
- package/dist/src/commands/org-observe-shared.js.map +1 -0
- package/dist/src/commands/org-observe.d.ts +9 -101
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +12 -1675
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org-poll.d.ts +57 -0
- package/dist/src/commands/org-poll.d.ts.map +1 -0
- package/dist/src/commands/org-poll.js +194 -0
- package/dist/src/commands/org-poll.js.map +1 -0
- package/dist/src/commands/org-run.d.ts +3 -0
- package/dist/src/commands/org-run.d.ts.map +1 -0
- package/dist/src/commands/org-run.js +449 -0
- package/dist/src/commands/org-run.js.map +1 -0
- package/dist/src/commands/org-serve.d.ts +19 -0
- package/dist/src/commands/org-serve.d.ts.map +1 -0
- package/dist/src/commands/org-serve.js +395 -0
- package/dist/src/commands/org-serve.js.map +1 -0
- package/dist/src/commands/org-subcommands-config.d.ts +8 -0
- package/dist/src/commands/org-subcommands-config.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-config.js +93 -0
- package/dist/src/commands/org-subcommands-config.js.map +1 -0
- package/dist/src/commands/org-subcommands-hil.d.ts +11 -0
- package/dist/src/commands/org-subcommands-hil.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-hil.js +216 -0
- package/dist/src/commands/org-subcommands-hil.js.map +1 -0
- package/dist/src/commands/org-subcommands-observe.d.ts +12 -0
- package/dist/src/commands/org-subcommands-observe.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-observe.js +249 -0
- package/dist/src/commands/org-subcommands-observe.js.map +1 -0
- package/dist/src/commands/org-subcommands-runtime.d.ts +12 -0
- package/dist/src/commands/org-subcommands-runtime.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-runtime.js +163 -0
- package/dist/src/commands/org-subcommands-runtime.js.map +1 -0
- package/dist/src/commands/org.d.ts +3 -151
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +43 -2735
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/orgrt/daemon-types.d.ts +196 -0
- package/dist/src/orgrt/daemon-types.d.ts.map +1 -0
- package/dist/src/orgrt/daemon-types.js +38 -0
- package/dist/src/orgrt/daemon-types.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +70 -300
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +41 -2536
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/idle-watchdog.d.ts +39 -0
- package/dist/src/orgrt/idle-watchdog.d.ts.map +1 -0
- package/dist/src/orgrt/idle-watchdog.js +289 -0
- package/dist/src/orgrt/idle-watchdog.js.map +1 -0
- package/dist/src/orgrt/org-reload.d.ts +7 -0
- package/dist/src/orgrt/org-reload.d.ts.map +1 -0
- package/dist/src/orgrt/org-reload.js +111 -0
- package/dist/src/orgrt/org-reload.js.map +1 -0
- package/dist/src/orgrt/org-start-steps.d.ts +21 -0
- package/dist/src/orgrt/org-start-steps.d.ts.map +1 -0
- package/dist/src/orgrt/org-start-steps.js +305 -0
- package/dist/src/orgrt/org-start-steps.js.map +1 -0
- package/dist/src/orgrt/org-start.d.ts +7 -0
- package/dist/src/orgrt/org-start.d.ts.map +1 -0
- package/dist/src/orgrt/org-start.js +435 -0
- package/dist/src/orgrt/org-start.js.map +1 -0
- package/dist/src/orgrt/org-state-file.d.ts +8 -0
- package/dist/src/orgrt/org-state-file.d.ts.map +1 -0
- package/dist/src/orgrt/org-state-file.js +116 -0
- package/dist/src/orgrt/org-state-file.js.map +1 -0
- package/dist/src/orgrt/org-stop.d.ts +6 -0
- package/dist/src/orgrt/org-stop.d.ts.map +1 -0
- package/dist/src/orgrt/org-stop.js +332 -0
- package/dist/src/orgrt/org-stop.js.map +1 -0
- package/dist/src/orgrt/org-tools.d.ts +11 -0
- package/dist/src/orgrt/org-tools.d.ts.map +1 -0
- package/dist/src/orgrt/org-tools.js +305 -0
- package/dist/src/orgrt/org-tools.js.map +1 -0
- package/dist/src/orgrt/role-incarnation.d.ts +18 -0
- package/dist/src/orgrt/role-incarnation.d.ts.map +1 -0
- package/dist/src/orgrt/role-incarnation.js +374 -0
- package/dist/src/orgrt/role-incarnation.js.map +1 -0
- package/dist/src/orgrt/role-respawn.d.ts +7 -0
- package/dist/src/orgrt/role-respawn.d.ts.map +1 -0
- package/dist/src/orgrt/role-respawn.js +318 -0
- package/dist/src/orgrt/role-respawn.js.map +1 -0
- package/dist/src/orgrt/role-session-opts.d.ts +389 -0
- package/dist/src/orgrt/role-session-opts.d.ts.map +1 -0
- package/dist/src/orgrt/role-session-opts.js +289 -0
- package/dist/src/orgrt/role-session-opts.js.map +1 -0
- package/dist/src/orgrt/runner-resolve.d.ts +43 -0
- package/dist/src/orgrt/runner-resolve.d.ts.map +1 -0
- package/dist/src/orgrt/runner-resolve.js +77 -0
- package/dist/src/orgrt/runner-resolve.js.map +1 -0
- package/dist/src/orgrt/session-gate.d.ts +34 -0
- package/dist/src/orgrt/session-gate.d.ts.map +1 -0
- package/dist/src/orgrt/session-gate.js +74 -0
- package/dist/src/orgrt/session-gate.js.map +1 -0
- package/dist/src/orgrt/session-prompt.d.ts +31 -0
- package/dist/src/orgrt/session-prompt.d.ts.map +1 -0
- package/dist/src/orgrt/session-prompt.js +115 -0
- package/dist/src/orgrt/session-prompt.js.map +1 -0
- package/dist/src/orgrt/session-run.d.ts +18 -0
- package/dist/src/orgrt/session-run.d.ts.map +1 -0
- package/dist/src/orgrt/session-run.js +429 -0
- package/dist/src/orgrt/session-run.js.map +1 -0
- package/dist/src/orgrt/session-stream.d.ts +21 -0
- package/dist/src/orgrt/session-stream.d.ts.map +1 -0
- package/dist/src/orgrt/session-stream.js +173 -0
- package/dist/src/orgrt/session-stream.js.map +1 -0
- package/dist/src/orgrt/session-types.d.ts +219 -0
- package/dist/src/orgrt/session-types.d.ts.map +1 -0
- package/dist/src/orgrt/session-types.js +2 -0
- package/dist/src/orgrt/session-types.js.map +1 -0
- package/dist/src/orgrt/session-usage.d.ts +29 -0
- package/dist/src/orgrt/session-usage.d.ts.map +1 -0
- package/dist/src/orgrt/session-usage.js +64 -0
- package/dist/src/orgrt/session-usage.js.map +1 -0
- package/dist/src/orgrt/session.d.ts +5 -281
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +8 -1117
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// packages/@monomind/cli/src/orgrt/role-session-opts.ts
|
|
2
|
+
// Extracted from daemon.ts — the SessionOpts one role incarnation runs with
|
|
3
|
+
// (every daemon callback its org tools reach) and the org_complete gate.
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { checkCompletion } from './completion-gate.js';
|
|
6
|
+
import * as decisionOps from './decisions.js';
|
|
7
|
+
import { openTaskCount } from './decisions.js';
|
|
8
|
+
import { loadoutCatalog, resolveLoadout } from './loadouts.js';
|
|
9
|
+
import * as questionOps from './questions.js';
|
|
10
|
+
import { endTurn, withTrace } from './role-trace.js';
|
|
11
|
+
import { resolveRoleRunner } from './runner-resolve.js';
|
|
12
|
+
import { effectiveToolProviders } from './skill-library.js';
|
|
13
|
+
import { resolveAutoAssignee } from './task-match.js';
|
|
14
|
+
import { ORG_DIR } from './types.js';
|
|
15
|
+
/** #302: the `org_complete` consent gate's emit-and-return logic, extracted
|
|
16
|
+
* (matching `resolvedIdleNudgeCount`'s and `runOutcomeResult`'s precedent)
|
|
17
|
+
* so it is unit-testable without a live daemon, a running org, or the SDK's
|
|
18
|
+
* own tool-calling loop — none of which a test can drive directly, since
|
|
19
|
+
* `queryFn` replaces the whole SDK `query()`, tool orchestration included.
|
|
20
|
+
* `onComplete` gathers the facts (needs `this`/`running`) and calls this;
|
|
21
|
+
* this does the one decision (`checkCompletion`) and its two possible
|
|
22
|
+
* side effects. Returns the refusal string, or `null` to allow — exactly
|
|
23
|
+
* what the org_complete tool handler (session.ts) relays as the result. */
|
|
24
|
+
export function resolveOrgComplete(bus, role, outcome, summary, blocker, blockerDetail, runFacts) {
|
|
25
|
+
const refusal = checkCompletion({ outcome, blocker, blockerDetail, ...runFacts });
|
|
26
|
+
if (refusal) {
|
|
27
|
+
// Visible in `org logs` — a silent refusal reads to an operator as a
|
|
28
|
+
// hung boss, not a boss that was told no.
|
|
29
|
+
bus.emit({
|
|
30
|
+
type: 'audit',
|
|
31
|
+
from: role,
|
|
32
|
+
reason: 'org-complete-refused',
|
|
33
|
+
msg: refusal,
|
|
34
|
+
data: { outcome, blocker, blockerDetail },
|
|
35
|
+
});
|
|
36
|
+
return refusal;
|
|
37
|
+
}
|
|
38
|
+
// #302 AC6: the blocker must show up in RENDERED output, not just `data`
|
|
39
|
+
// — `org logs`'s formatter prints an event's `msg` verbatim and never
|
|
40
|
+
// looks at `data`, so a blocker recorded only there would satisfy a unit
|
|
41
|
+
// assertion and never reach a human reading the actual log.
|
|
42
|
+
const blockerSuffix = blocker
|
|
43
|
+
? ` (blocker: ${blocker}${blockerDetail ? ` — ${blockerDetail}` : ''})`
|
|
44
|
+
: '';
|
|
45
|
+
bus.emit({
|
|
46
|
+
type: 'status',
|
|
47
|
+
from: role,
|
|
48
|
+
reason: 'org-complete',
|
|
49
|
+
msg: `run outcome: ${outcome}${blockerSuffix}`,
|
|
50
|
+
data: { outcome, summary, blocker, blockerDetail },
|
|
51
|
+
});
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/** The sessionOpts built inside spawnRoleIncarnation (role-incarnation.ts). */
|
|
55
|
+
export function buildRoleSessionOpts(daemon, name, running, role, roleCwd, runtime, abort, loadout, policy, mailbox, roleCheckpoint) {
|
|
56
|
+
const { def, bus, run } = running;
|
|
57
|
+
return {
|
|
58
|
+
org: name,
|
|
59
|
+
role,
|
|
60
|
+
bus,
|
|
61
|
+
policy,
|
|
62
|
+
mailbox,
|
|
63
|
+
taskProcesses: runtime.taskProcesses,
|
|
64
|
+
cwd: roleCwd,
|
|
65
|
+
def,
|
|
66
|
+
// Pass the org state directory so runners that persist per-role state
|
|
67
|
+
// (VercelAgentRunner session files) write under .monomind/orgs/<name>
|
|
68
|
+
// instead of polluting the workspace cwd.
|
|
69
|
+
orgDir: join(daemon.root, ORG_DIR, name),
|
|
70
|
+
// Project root for named-provider (`adapter_config.provider`) config
|
|
71
|
+
// lookup — role cwd may be an isolated workspace with no config file.
|
|
72
|
+
orgRoot: daemon.root,
|
|
73
|
+
run,
|
|
74
|
+
// M1: role tool providers — listed at session start, processes spawned
|
|
75
|
+
// lazily on first call and killed when the session ends.
|
|
76
|
+
buildProviderTools: async () => {
|
|
77
|
+
const providers = effectiveToolProviders(role, daemon.root);
|
|
78
|
+
if (providers.length === 0)
|
|
79
|
+
return undefined;
|
|
80
|
+
return daemon.toolProviders.buildRoleTools({
|
|
81
|
+
ctx: { org: name, run, role: role.id, root: daemon.root },
|
|
82
|
+
providers,
|
|
83
|
+
trace: () => daemon.roleTrace(name, role.id),
|
|
84
|
+
bus,
|
|
85
|
+
cwd: roleCwd,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
maxTurns: role.max_turns_per_message ?? def.run_config.max_turns_per_message,
|
|
89
|
+
resumeSessionId: roleCheckpoint?.sessionId,
|
|
90
|
+
sessionLedger: running.sessionLedger,
|
|
91
|
+
// ADR-O001 D3 x D7: a task-scoped session is built with its task's own
|
|
92
|
+
// recorded loadout. Unresolvable → no loadout, loudly (as at spawn).
|
|
93
|
+
loadoutFor: (taskId) => {
|
|
94
|
+
const name = running.taskDag?.get(taskId)?.loadout;
|
|
95
|
+
if (!name)
|
|
96
|
+
return undefined;
|
|
97
|
+
try {
|
|
98
|
+
return resolveLoadout(def, name, daemon.root);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
bus.emit({
|
|
102
|
+
type: 'audit',
|
|
103
|
+
from: role.id,
|
|
104
|
+
reason: 'loadout-unresolvable',
|
|
105
|
+
msg: `task ${taskId} session built without loadout "${name}": ${err instanceof Error ? err.message : err}`,
|
|
106
|
+
data: { loadout: name, taskId },
|
|
107
|
+
});
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
lastMessageId: () => runtime.lastMessageId,
|
|
112
|
+
onOutput: (line) => runtime.scrollback.push(line),
|
|
113
|
+
onSessionId: (id) => {
|
|
114
|
+
runtime.sessionId = id;
|
|
115
|
+
},
|
|
116
|
+
onTurnEnd: () => {
|
|
117
|
+
endTurn(running, role.id);
|
|
118
|
+
decisionOps.nudgeOpenTasksAtTurnEnd(running, role.id);
|
|
119
|
+
},
|
|
120
|
+
// #327: the role's org_send mail carries its chain at the next hop.
|
|
121
|
+
deliver: (from, to, subject, body) => daemon.deliver(name, from, to, subject, withTrace(body, daemon.roleTrace(name, role.id))),
|
|
122
|
+
askHuman: (r, question, blocking) => daemon.askHuman(name, r, question, blocking),
|
|
123
|
+
onGate: (r, gateName, gateDesc) => daemon.createGate(name, r, gateName, gateDesc),
|
|
124
|
+
circuitBreaker: (() => {
|
|
125
|
+
const cb = def.run_config.circuit_breaker;
|
|
126
|
+
if (!cb)
|
|
127
|
+
return undefined;
|
|
128
|
+
return { threshold: cb.failure_threshold ?? 5, state: { failures: 0, tripped: false } };
|
|
129
|
+
})(),
|
|
130
|
+
beforeTool: (r, toolName, input) => daemon.checkApproval(name, r, toolName, input),
|
|
131
|
+
fence: running.fences?.get(role.id),
|
|
132
|
+
// ORG-1: gatedCanUseTool denials are a natural decision point — record them so
|
|
133
|
+
// `org decisions` shows real traces instead of always reporting none.
|
|
134
|
+
onDecision: (r, toolName, message, kind) => {
|
|
135
|
+
daemon.recordDecision(name, r, {
|
|
136
|
+
type: 'tool',
|
|
137
|
+
kind,
|
|
138
|
+
context: `tool call: ${toolName}`,
|
|
139
|
+
reasoning: message,
|
|
140
|
+
outcome: 'denied',
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
// ORG-9: decision gates are documented as "hard-blocking" — make that
|
|
144
|
+
// true by actually denying tool use while this role has a pending gate,
|
|
145
|
+
// the same way pending approvals already do.
|
|
146
|
+
hasPendingGate: () => daemon.listGates(name, 'pending').some((g) => g.roleId === role.id),
|
|
147
|
+
// #302: refuse an unsatisfiable org_complete BEFORE the 'org-complete'
|
|
148
|
+
// status event ever exists — the bus subscriber at the top of this
|
|
149
|
+
// function auto-stops the run on that event alone, so a refusal that
|
|
150
|
+
// still emitted it would be undone by the very next tick regardless of
|
|
151
|
+
// what this function returns to the tool handler.
|
|
152
|
+
onComplete: role.id === running.bossRoleId
|
|
153
|
+
? (r, outcome, summary, blocker, blockerDetail) => {
|
|
154
|
+
let maxBudgetFraction = 0;
|
|
155
|
+
for (const rt of running.agents.values()) {
|
|
156
|
+
const p = rt.policy;
|
|
157
|
+
if (p.policy.maxTokens)
|
|
158
|
+
maxBudgetFraction = Math.max(maxBudgetFraction, p.usage / p.policy.maxTokens);
|
|
159
|
+
if (p.policy.maxUsd)
|
|
160
|
+
maxBudgetFraction = Math.max(maxBudgetFraction, p.usageUsd / p.policy.maxUsd);
|
|
161
|
+
}
|
|
162
|
+
// Same predicates the idle watchdog uses for its own
|
|
163
|
+
// legitimate-wait check (:1316-1328) — a pending gate or an
|
|
164
|
+
// unanswered question is the same "genuinely waiting on a
|
|
165
|
+
// human" fact either way.
|
|
166
|
+
const pendingHumanWaits = daemon.listGates(name, 'pending').length +
|
|
167
|
+
questionOps.pendingBlockingQuestions(daemon.root, name).length;
|
|
168
|
+
return resolveOrgComplete(bus, r, outcome, summary, blocker, blockerDetail, {
|
|
169
|
+
mode: def.run_config.completion ?? 'boss',
|
|
170
|
+
maxBudgetFraction,
|
|
171
|
+
pendingHumanWaits,
|
|
172
|
+
hasActiveBlock: running.taskDag?.hasActiveBlock(Date.now()) ?? false,
|
|
173
|
+
hasPendingWork: running.taskDag?.hasPendingWork() ?? false,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
: undefined,
|
|
177
|
+
// #11: a boss that overflows its context window isn't a crash (it keeps
|
|
178
|
+
// returning +0-token errors forever), so without this the idle watchdog
|
|
179
|
+
// just nudges it for ~30 min before idle-stopping. Restart the whole org
|
|
180
|
+
// with fresh sessions instead — bounded by MAX_BOSS_RESTARTS.
|
|
181
|
+
onContextLimit: role.id === running.bossRoleId ? () => daemon.scheduleBossRestart(name) : undefined,
|
|
182
|
+
onListRuntimeOptions: role.id === running.bossRoleId && (def.run_config.max_role_respawns ?? 0) > 0
|
|
183
|
+
? () => daemon.listRuntimeOptions()
|
|
184
|
+
: undefined,
|
|
185
|
+
onRespawnRole: role.id === running.bossRoleId && (def.run_config.max_role_respawns ?? 0) > 0
|
|
186
|
+
? (callerId, args) => daemon.respawnRole(name, callerId, args)
|
|
187
|
+
: undefined,
|
|
188
|
+
recall: async (r, q) => {
|
|
189
|
+
const answer = await daemon.recallOrgMemory(name, def, q, r);
|
|
190
|
+
bus.emit({
|
|
191
|
+
type: 'status',
|
|
192
|
+
from: r,
|
|
193
|
+
reason: 'org-recall',
|
|
194
|
+
msg: `recall: ${q.slice(0, 80)}`,
|
|
195
|
+
data: { hits: answer.hits },
|
|
196
|
+
});
|
|
197
|
+
return answer.text;
|
|
198
|
+
},
|
|
199
|
+
searchKnowledge: async (r, q) => {
|
|
200
|
+
const answer = await daemon.searchProjectKnowledge(q);
|
|
201
|
+
bus.emit({
|
|
202
|
+
type: 'status',
|
|
203
|
+
from: r,
|
|
204
|
+
reason: 'knowledge-search',
|
|
205
|
+
msg: `knowledge: ${q.slice(0, 80)}`,
|
|
206
|
+
data: { hits: answer.hits },
|
|
207
|
+
});
|
|
208
|
+
return answer.text;
|
|
209
|
+
},
|
|
210
|
+
glossary: running.glossary,
|
|
211
|
+
remember: async (r, content, scope) => {
|
|
212
|
+
const text = await daemon.rememberOrgMemory(name, def, r, content, scope, run);
|
|
213
|
+
bus.emit({
|
|
214
|
+
type: 'status',
|
|
215
|
+
from: r,
|
|
216
|
+
reason: 'org-remember',
|
|
217
|
+
msg: `remember (${scope}): ${content.slice(0, 80)}`,
|
|
218
|
+
data: { scope },
|
|
219
|
+
});
|
|
220
|
+
return text;
|
|
221
|
+
},
|
|
222
|
+
learn: async (r, payload) => {
|
|
223
|
+
const text = await daemon.learnOrgKnowledge(name, run, payload);
|
|
224
|
+
bus.emit({
|
|
225
|
+
type: 'status',
|
|
226
|
+
from: r,
|
|
227
|
+
reason: 'org-learn',
|
|
228
|
+
msg: `learn: ${text.slice(0, 120)}`,
|
|
229
|
+
data: {
|
|
230
|
+
nodes: payload.nodes?.length ?? 0,
|
|
231
|
+
edges: payload.edges?.length ?? 0,
|
|
232
|
+
rules: payload.rules?.length ?? 0,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
return text;
|
|
236
|
+
},
|
|
237
|
+
createTask: (r, title, assignee, deps, loadout, brief, pick) => {
|
|
238
|
+
return daemon.dagCreateTask(name, r, title, assignee, deps, loadout, brief, pick);
|
|
239
|
+
},
|
|
240
|
+
pickAssignee: resolveAutoAssignee(def, (id) => openTaskCount(daemon.orgs.get(name), id), () => daemon.orgs.get(name)?.taskDag?.all() ?? []),
|
|
241
|
+
onSkillLoad: (r, skill) => decisionOps.recordSkillLoad(daemon.orgs.get(name), r, skill),
|
|
242
|
+
// ADR-O001 D7: only an org with a catalog gets the `loadout` argument;
|
|
243
|
+
// the session itself is built with the loadout frozen above.
|
|
244
|
+
loadoutCatalog: loadoutCatalog(def),
|
|
245
|
+
loadout,
|
|
246
|
+
completeTask: (r, taskId, result, evidence) => {
|
|
247
|
+
return daemon.dagCompleteTask(name, r, taskId, result, evidence);
|
|
248
|
+
},
|
|
249
|
+
// ADR-O001 D5: only an org that opted in advertises the evidence
|
|
250
|
+
// argument, so every other org's tool list stays byte-identical.
|
|
251
|
+
requireTaskEvidence: def.run_config.completion_evidence === true && role.deliberative !== true,
|
|
252
|
+
// ADR-O001 D6: only an org with an artifact-only reviewer gets org_review,
|
|
253
|
+
// so every other org's tool list stays byte-identical.
|
|
254
|
+
requestReview: def.roles.some((r) => r.review_input === 'artifact-only')
|
|
255
|
+
? (r, taskId, reviewer, base) => daemon.dagRequestReview(name, r, taskId, reviewer, base)
|
|
256
|
+
: undefined,
|
|
257
|
+
listTasks: (taskId) => decisionOps.dagListTasks(daemon, name, taskId),
|
|
258
|
+
splitTask: (r, parentId, children) => {
|
|
259
|
+
return daemon.dagSplitTask(name, r, parentId, children);
|
|
260
|
+
},
|
|
261
|
+
mergeTask: (r, sourceId, targetId) => {
|
|
262
|
+
return daemon.dagMergeTask(name, r, sourceId, targetId);
|
|
263
|
+
},
|
|
264
|
+
cancelTask: (r, taskId, reason) => {
|
|
265
|
+
return daemon.dagCancelTask(name, r, taskId, reason);
|
|
266
|
+
},
|
|
267
|
+
blockTask: (r, taskId, untilIso, reason, every) => {
|
|
268
|
+
return daemon.dagBlockTask(name, r, taskId, untilIso, reason, every);
|
|
269
|
+
},
|
|
270
|
+
planGraph: (r, specs) => {
|
|
271
|
+
return daemon.dagPlanGraph(name, r, specs);
|
|
272
|
+
},
|
|
273
|
+
queryFn: daemon.opts.queryFn,
|
|
274
|
+
// Runner resolution: explicit opts.runner > role `runtime` field >
|
|
275
|
+
// org def `runtime` field > MONOMIND_RUNTIME env (opencode/kimicode) >
|
|
276
|
+
// undefined (session.ts falls back to ClaudeAgentRunner via queryFn).
|
|
277
|
+
// Leaving it undefined for the default path is what keeps
|
|
278
|
+
// Claude/Antigravity orgs byte-for-byte unchanged. Session opts are
|
|
279
|
+
// built per role here, so each role gets its own runner.
|
|
280
|
+
runner: daemon.opts.runner ??
|
|
281
|
+
resolveRoleRunner(role.runtime, def.runtime, role.provider?.kind, undefined, role.provider),
|
|
282
|
+
// Lets respawnRole force-stop THIS specific incarnation (mid-run role
|
|
283
|
+
// replacement's forced-stop step) without reaching into runAgentSession's
|
|
284
|
+
// internals.
|
|
285
|
+
externalAbort: abort,
|
|
286
|
+
silentSessionMs: daemon.opts.silentSessionMs,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=role-session-opts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role-session-opts.js","sourceRoot":"","sources":["../../../src/orgrt/role-session-opts.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,4EAA4E;AAC5E,yEAAyE;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAwB,eAAe,EAAqB,MAAM,sBAAsB,CAAC;AAGhG,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/D,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,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E;QACtE,0EAA0E;QAC1E,aAAa;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentRunner } from './agent-runner.js';
|
|
2
|
+
import type { ProviderConfig } from './types.js';
|
|
3
|
+
/** Resolve which AgentRunner hosts an org's role sessions.
|
|
4
|
+
* Precedence: role `runtime` field > org def `runtime` field >
|
|
5
|
+
* MONOMIND_RUNTIME env > auto-resolve from provider kind > undefined (the
|
|
6
|
+
* default path, where session.ts falls back to ClaudeAgentRunner). Returning
|
|
7
|
+
* undefined for the default path keeps Claude/Antigravity orgs byte-for-byte
|
|
8
|
+
* unchanged. Callers pass `role.runtime ?? def.runtime` as `orgRuntime`
|
|
9
|
+
* (see resolveRoleRunner). */
|
|
10
|
+
export type RuntimeKind = 'claude' | 'kimicode' | 'opencode' | 'vercel' | 'codex' | 'antigravity' | 'grok' | 'qwen' | 'crush' | 'copilot' | 'pi'
|
|
11
|
+
/** Opt-in alternate to 'pi': keeps the pi subprocess alive for the whole
|
|
12
|
+
* mailbox session (--mode rpc) instead of spawning fresh per turn — see
|
|
13
|
+
* pi-rpc-runner.ts's header for the protocol source (live-verified
|
|
14
|
+
* against pi v0.73.1, issue #179). Prefer plain 'pi' unless you
|
|
15
|
+
* specifically want session-lifetime context continuity. */
|
|
16
|
+
| 'pi-rpc'
|
|
17
|
+
/** Opt-in alternate to 'qwen': keeps the qwen subprocess alive for the
|
|
18
|
+
* whole mailbox session (--input-format/--output-format stream-json)
|
|
19
|
+
* instead of spawning fresh per turn — see qwen-rpc-runner.ts's header
|
|
20
|
+
* for the protocol source (live-verified against qwen-code v0.21.13,
|
|
21
|
+
* issue #182). One gap not independently re-verified: whether `result`
|
|
22
|
+
* fires exactly once per turn even when qwen runs several of its own
|
|
23
|
+
* native tools in sequence first (inferred by symmetry with the non-RPC
|
|
24
|
+
* QwenAgentRunner, not separately live-tested for this runner). Prefer
|
|
25
|
+
* plain 'qwen' unless you specifically want session-lifetime context
|
|
26
|
+
* continuity. */
|
|
27
|
+
| 'qwen-rpc'
|
|
28
|
+
/** Nous Research's Hermes Agent CLI (`hermes`), spawned fresh per
|
|
29
|
+
* tool-call round like 'codex' — but with NO session-resume flag in
|
|
30
|
+
* headless mode (see hermes-runner.ts's header): every round resends the
|
|
31
|
+
* full transcript, and args.resume across mailbox messages cannot be
|
|
32
|
+
* honored. Docs-only verified, streamsIncrementally: false — see
|
|
33
|
+
* runner-registry.ts. */
|
|
34
|
+
| 'hermes';
|
|
35
|
+
export type ProviderKind = 'subscription' | 'api-key' | 'base-url' | 'bedrock' | 'vertex' | 'gemini' | 'openai' | 'vercel-api-key' | 'codex' | 'antigravity';
|
|
36
|
+
export declare function resolveRunner(orgRuntime?: RuntimeKind, providerKind?: ProviderKind, provider?: ProviderConfig): AgentRunner | undefined;
|
|
37
|
+
/** Per-session variant: a role's own `runtime` field wins over the org-level
|
|
38
|
+
* one (and the env var) — including `role.runtime === 'claude'`, which forces
|
|
39
|
+
* the default Claude path even when the org/env select another runtime.
|
|
40
|
+
* Roles without a `runtime` inherit the org-level resolution unchanged.
|
|
41
|
+
* If no explicit runtime is set, auto-resolve from the provider kind. */
|
|
42
|
+
export declare function resolveRoleRunner(roleRuntime?: RuntimeKind, orgRuntime?: RuntimeKind, roleProviderKind?: ProviderKind, orgProviderKind?: ProviderKind, roleProvider?: ProviderConfig): AgentRunner | undefined;
|
|
43
|
+
//# sourceMappingURL=runner-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-resolve.d.ts","sourceRoot":"","sources":["../../../src/orgrt/runner-resolve.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;+BAM+B;AAC/B,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,GACR,OAAO,GACP,aAAa,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,IAAI;AACN;;;;6DAI6D;GAC3D,QAAQ;AACV;;;;;;;;;kBASkB;GAChB,UAAU;AACZ;;;;;0BAK0B;GACxB,QAAQ,CAAC;AACb,MAAM,MAAM,YAAY,GACpB,cAAc,GACd,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,OAAO,GACP,aAAa,CAAC;AAUlB,wBAAgB,aAAa,CAC3B,UAAU,CAAC,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,YAAY,EAC3B,QAAQ,CAAC,EAAE,cAAc,GACxB,WAAW,GAAG,SAAS,CA8BzB;AAED;;;;0EAI0E;AAC1E,wBAAgB,iBAAiB,CAC/B,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,WAAW,EACxB,gBAAgB,CAAC,EAAE,YAAY,EAC/B,eAAe,CAAC,EAAE,YAAY,EAC9B,YAAY,CAAC,EAAE,cAAc,GAC5B,WAAW,GAAG,SAAS,CAIzB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AntigravityAgentRunner } from './antigravity-runner.js';
|
|
2
|
+
import { CodexAgentRunner } from './codex-runner.js';
|
|
3
|
+
import { CopilotAgentRunner } from './copilot-runner.js';
|
|
4
|
+
import { CrushAgentRunner } from './crush-runner.js';
|
|
5
|
+
import { GrokAgentRunner } from './grok-runner.js';
|
|
6
|
+
import { HermesAgentRunner } from './hermes-runner.js';
|
|
7
|
+
import { KimiCodeAgentRunner } from './kimicode-runner.js';
|
|
8
|
+
import { OpencodeAgentRunner } from './opencode-runner.js';
|
|
9
|
+
import { PiRpcAgentRunner } from './pi-rpc-runner.js';
|
|
10
|
+
import { PiAgentRunner } from './pi-runner.js';
|
|
11
|
+
import { QwenRpcAgentRunner } from './qwen-rpc-runner.js';
|
|
12
|
+
import { QwenAgentRunner } from './qwen-runner.js';
|
|
13
|
+
import { VercelAgentRunner } from './vercel-runner.js';
|
|
14
|
+
/** Auto-resolve runtime from provider kind. Returns undefined for Claude default. */
|
|
15
|
+
function autoRuntimeFromProvider(kind) {
|
|
16
|
+
if (kind === 'vercel-api-key')
|
|
17
|
+
return 'vercel';
|
|
18
|
+
if (kind === 'codex')
|
|
19
|
+
return 'codex';
|
|
20
|
+
if (kind === 'antigravity')
|
|
21
|
+
return 'antigravity';
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
export function resolveRunner(orgRuntime, providerKind, provider) {
|
|
25
|
+
const selected = orgRuntime ??
|
|
26
|
+
autoRuntimeFromProvider(providerKind) ??
|
|
27
|
+
process.env.MONOMIND_RUNTIME;
|
|
28
|
+
if (selected === 'opencode')
|
|
29
|
+
return new OpencodeAgentRunner();
|
|
30
|
+
if (selected === 'kimicode')
|
|
31
|
+
return new KimiCodeAgentRunner();
|
|
32
|
+
if (selected === 'vercel')
|
|
33
|
+
return new VercelAgentRunner();
|
|
34
|
+
if (selected === 'codex')
|
|
35
|
+
return new CodexAgentRunner();
|
|
36
|
+
if (selected === 'antigravity')
|
|
37
|
+
return new AntigravityAgentRunner();
|
|
38
|
+
if (selected === 'grok')
|
|
39
|
+
return new GrokAgentRunner();
|
|
40
|
+
if (selected === 'qwen')
|
|
41
|
+
return new QwenAgentRunner();
|
|
42
|
+
if (selected === 'crush') {
|
|
43
|
+
// Issue #177: usage-proxy accounting is opt-in via provider.usageProxy +
|
|
44
|
+
// provider.baseUrl (the upstream the crush CLI's own provider config
|
|
45
|
+
// points at). Absent either, CrushAgentRunner falls back to its
|
|
46
|
+
// documented 0-token behavior — this never blocks a turn either way.
|
|
47
|
+
if (provider?.usageProxy && provider.baseUrl) {
|
|
48
|
+
return new CrushAgentRunner({
|
|
49
|
+
usageProxy: { upstreamBaseUrl: provider.baseUrl, baseUrlEnvVar: provider.usageProxyEnvVar },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return new CrushAgentRunner();
|
|
53
|
+
}
|
|
54
|
+
if (selected === 'copilot')
|
|
55
|
+
return new CopilotAgentRunner();
|
|
56
|
+
if (selected === 'pi')
|
|
57
|
+
return new PiAgentRunner();
|
|
58
|
+
if (selected === 'pi-rpc')
|
|
59
|
+
return new PiRpcAgentRunner();
|
|
60
|
+
if (selected === 'qwen-rpc')
|
|
61
|
+
return new QwenRpcAgentRunner();
|
|
62
|
+
if (selected === 'hermes')
|
|
63
|
+
return new HermesAgentRunner();
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
/** Per-session variant: a role's own `runtime` field wins over the org-level
|
|
67
|
+
* one (and the env var) — including `role.runtime === 'claude'`, which forces
|
|
68
|
+
* the default Claude path even when the org/env select another runtime.
|
|
69
|
+
* Roles without a `runtime` inherit the org-level resolution unchanged.
|
|
70
|
+
* If no explicit runtime is set, auto-resolve from the provider kind. */
|
|
71
|
+
export function resolveRoleRunner(roleRuntime, orgRuntime, roleProviderKind, orgProviderKind, roleProvider) {
|
|
72
|
+
const explicit = roleRuntime ?? orgRuntime;
|
|
73
|
+
if (explicit)
|
|
74
|
+
return resolveRunner(explicit, undefined, roleProvider);
|
|
75
|
+
return resolveRunner(undefined, roleProviderKind ?? orgProviderKind, roleProvider);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=runner-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-resolve.js","sourceRoot":"","sources":["../../../src/orgrt/runner-resolve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAm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gBAAgB,IAAI,eAAe,EAAE,YAAY,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RoleFence } from './fence.js';
|
|
2
|
+
import type { Decision, PolicyEngine } from './policy.js';
|
|
3
|
+
import type { SessionOpts } from './session-types.js';
|
|
4
|
+
import type { DecisionKind } from './types.js';
|
|
5
|
+
/** The SDK's `canUseTool` gate, composed from two independent layers: PolicyEngine's
|
|
6
|
+
* static config checks (deny/allow lists, path scoping, git level, web allowlist,
|
|
7
|
+
* budget), then — only for calls policy would allow — the human-approval guardrail
|
|
8
|
+
* (`beforeTool`, i.e. daemon.checkApproval) for whatever action names it treats as
|
|
9
|
+
* sensitive (Bash/WebFetch/WebSearch/org_complete). Exported standalone so this
|
|
10
|
+
* composition is unit-testable without spinning up a real SDK session: previously
|
|
11
|
+
* `beforeTool` was wired into SessionOpts but never actually called from here, so
|
|
12
|
+
* none of those sensitive actions ever paused for a human. */
|
|
13
|
+
export declare function gatedCanUseTool(policy: PolicyEngine, beforeTool: SessionOpts['beforeTool'], roleId: string, fence?: RoleFence,
|
|
14
|
+
/** Optional hook invoked whenever this gate denies a tool call — wired to
|
|
15
|
+
* daemon.recordDecision() so denials show up in `org decisions` traces.
|
|
16
|
+
* #290: `kind` names WHICH of this function's four deny paths fired, so a
|
|
17
|
+
* consumer never has to tell a fence block from a routine pending approval
|
|
18
|
+
* by matching the English in the message. */
|
|
19
|
+
onDeny?: (toolName: string, input: Record<string, unknown>, decision: Extract<Decision, {
|
|
20
|
+
behavior: 'deny';
|
|
21
|
+
}>, kind: DecisionKind) => void,
|
|
22
|
+
/** ORG-9: reports whether this role has a pending (unresolved) decision gate.
|
|
23
|
+
* org_gate is documented as creating a "hard-blocking" checkpoint, but until
|
|
24
|
+
* this was wired in nothing actually stopped tool use while a gate sat
|
|
25
|
+
* pending — only approvals did that. When set and true, ALL tool calls are
|
|
26
|
+
* denied (not just the sensitive subset approvals gate) until the gate is
|
|
27
|
+
* resolved, matching the "hard-blocking" description. */
|
|
28
|
+
hasPendingGate?: () => boolean): (toolName: string, input: Record<string, unknown>,
|
|
29
|
+
/** #289: the harness's id for this call, forwarded to policy.decide so the
|
|
30
|
+
* invocation event can be joined to the later tool_result event. */
|
|
31
|
+
meta?: {
|
|
32
|
+
toolUseId?: string;
|
|
33
|
+
}) => Promise<Decision>;
|
|
34
|
+
//# sourceMappingURL=session-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-gate.d.ts","sourceRoot":"","sources":["../../../src/orgrt/session-gate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;+DAO+D;AAC/D,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,EACrC,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,SAAS;AACjB;;;;8CAI8C;AAC9C,MAAM,CAAC,EAAE,CACP,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,EACjD,IAAI,EAAE,YAAY,KACf,IAAI;AACT;;;;;0DAK0D;AAC1D,cAAc,CAAC,EAAE,MAAM,OAAO,GAC7B,CACD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;AAC9B;qEACqE;AACrE,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KAC1B,OAAO,CAAC,QAAQ,CAAC,CAsDrB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { scanInput } from './fence.js';
|
|
2
|
+
/** The SDK's `canUseTool` gate, composed from two independent layers: PolicyEngine's
|
|
3
|
+
* static config checks (deny/allow lists, path scoping, git level, web allowlist,
|
|
4
|
+
* budget), then — only for calls policy would allow — the human-approval guardrail
|
|
5
|
+
* (`beforeTool`, i.e. daemon.checkApproval) for whatever action names it treats as
|
|
6
|
+
* sensitive (Bash/WebFetch/WebSearch/org_complete). Exported standalone so this
|
|
7
|
+
* composition is unit-testable without spinning up a real SDK session: previously
|
|
8
|
+
* `beforeTool` was wired into SessionOpts but never actually called from here, so
|
|
9
|
+
* none of those sensitive actions ever paused for a human. */
|
|
10
|
+
export function gatedCanUseTool(policy, beforeTool, roleId, fence,
|
|
11
|
+
/** Optional hook invoked whenever this gate denies a tool call — wired to
|
|
12
|
+
* daemon.recordDecision() so denials show up in `org decisions` traces.
|
|
13
|
+
* #290: `kind` names WHICH of this function's four deny paths fired, so a
|
|
14
|
+
* consumer never has to tell a fence block from a routine pending approval
|
|
15
|
+
* by matching the English in the message. */
|
|
16
|
+
onDeny,
|
|
17
|
+
/** ORG-9: reports whether this role has a pending (unresolved) decision gate.
|
|
18
|
+
* org_gate is documented as creating a "hard-blocking" checkpoint, but until
|
|
19
|
+
* this was wired in nothing actually stopped tool use while a gate sat
|
|
20
|
+
* pending — only approvals did that. When set and true, ALL tool calls are
|
|
21
|
+
* denied (not just the sensitive subset approvals gate) until the gate is
|
|
22
|
+
* resolved, matching the "hard-blocking" description. */
|
|
23
|
+
hasPendingGate) {
|
|
24
|
+
return async (toolName, input, meta) => {
|
|
25
|
+
if (hasPendingGate?.()) {
|
|
26
|
+
const decision = {
|
|
27
|
+
behavior: 'deny',
|
|
28
|
+
message: `Tool "${toolName}" is blocked — awaiting gate resolution. A decision gate is pending; wait for a human to approve or reject it via 'monomind org gate-approve/gate-reject'.`,
|
|
29
|
+
};
|
|
30
|
+
onDeny?.(toolName, input, decision, 'gate-pending');
|
|
31
|
+
return decision;
|
|
32
|
+
}
|
|
33
|
+
if (fence) {
|
|
34
|
+
const text = typeof input.command === 'string'
|
|
35
|
+
? input.command
|
|
36
|
+
: typeof input.content === 'string'
|
|
37
|
+
? input.content
|
|
38
|
+
: typeof input.url === 'string'
|
|
39
|
+
? input.url
|
|
40
|
+
: JSON.stringify(input);
|
|
41
|
+
const fenceDecision = await scanInput(fence.instance, text, fence.abortThreshold);
|
|
42
|
+
if (fenceDecision.behavior === 'deny') {
|
|
43
|
+
onDeny?.(toolName, input, fenceDecision, 'fence-block');
|
|
44
|
+
return fenceDecision;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const decision = await policy.decide(toolName, input, meta?.toolUseId);
|
|
48
|
+
if (decision.behavior === 'deny') {
|
|
49
|
+
onDeny?.(toolName, input, decision, 'policy-deny');
|
|
50
|
+
return decision;
|
|
51
|
+
}
|
|
52
|
+
if (!beforeTool)
|
|
53
|
+
return decision;
|
|
54
|
+
const approved = await beforeTool(roleId, toolName, input);
|
|
55
|
+
if (approved === false) {
|
|
56
|
+
const denied = {
|
|
57
|
+
behavior: 'deny',
|
|
58
|
+
message: `Tool "${toolName}" was denied by guardrail approval`,
|
|
59
|
+
};
|
|
60
|
+
onDeny?.(toolName, input, denied, 'approval-denied');
|
|
61
|
+
return denied;
|
|
62
|
+
}
|
|
63
|
+
if (approved === null) {
|
|
64
|
+
const pending = {
|
|
65
|
+
behavior: 'deny',
|
|
66
|
+
message: `Tool "${toolName}" is pending human approval — it will be available once approved or denied via 'monomind org approve/deny'.`,
|
|
67
|
+
};
|
|
68
|
+
onDeny?.(toolName, input, pending, 'approval-pending');
|
|
69
|
+
return pending;
|
|
70
|
+
}
|
|
71
|
+
return decision;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=session-gate.js.map
|
|
@@ -0,0 +1 @@
|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aAAa,CAAC,CAAC;gBACxD,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QACvE,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,OAAO,QAAQ,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3D,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,MAAM,MAAM,GAAa;gBACvB,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,SAAS,QAAQ,oCAAoC;aAC/D,CAAC;YACF,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;YACrD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,MAAM,OAAO,GAAa;gBACxB,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,SAAS,QAAQ,6GAA6G;aACxI,CAAC;YACF,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;YACvD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SessionOpts } from './session-types.js';
|
|
2
|
+
import type { OrgDef, OrgRole } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the extra system-prompt block for a role: its pinned library
|
|
5
|
+
* skills and on-demand skill catalog (skill-library.ts) plus the role's own
|
|
6
|
+
* `instructions_file`, if any — all optional and independent. A missing or
|
|
7
|
+
* unreadable `instructions_file` is skipped (not an error): a role shouldn't
|
|
8
|
+
* fail to start a session over a stale/typo'd custom-file path.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveRoleExtraGuidance(role: OrgRole, projectRoot?: string): string | undefined;
|
|
11
|
+
/** Resolve the model string for a role: explicit adapter_config.model wins;
|
|
12
|
+
* otherwise fall back to the vendor/runtime default.
|
|
13
|
+
*
|
|
14
|
+
* Vendor defaults are read straight off VERCEL_PROVIDERS, which already
|
|
15
|
+
* carries a defaultModel per vendor. A second hand-kept table lived here and
|
|
16
|
+
* restated all sixteen of them — two lists of per-vendor defaults that would
|
|
17
|
+
* eventually disagree, which is precisely the drift #252 was. An empty
|
|
18
|
+
* registry default (openai-compatible, which serves arbitrary endpoints) is
|
|
19
|
+
* falsy and so falls through to the runtime switch, as it always did. */
|
|
20
|
+
export declare function resolveModel(role: OrgRole, runtime?: string, vendor?: string): string;
|
|
21
|
+
/** Role briefing given to each agent session (SDK systemPrompt option).
|
|
22
|
+
* `extraGuidance` carries pre-resolved text the caller already loaded from
|
|
23
|
+
* disk — the role's library skills and/or its own `instructions_file`,
|
|
24
|
+
* if either resolved to something. Kept as a plain string param (not read here)
|
|
25
|
+
* so this function stays synchronous/pure and trivially testable. */
|
|
26
|
+
export declare function buildRolePrompt(role: OrgRole, def: Pick<OrgDef, 'name' | 'goal'>, roster: string[], glossary?: string[], extraGuidance?: string,
|
|
27
|
+
/** M2: one line per endpoint role (endpointBriefingLines) — boss only. */
|
|
28
|
+
endpointBriefing?: string[]): string;
|
|
29
|
+
/** The system prompt one session of this role is built with. */
|
|
30
|
+
export declare function rolePromptFor(opts: SessionOpts): string;
|
|
31
|
+
//# sourceMappingURL=session-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-prompt.d.ts","sourceRoot":"","sources":["../../../src/orgrt/session-prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGlD;;;;;;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,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBrF;AAED;;;;sEAIsE;AACtE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAClC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,EACnB,aAAa,CAAC,EAAE,MAAM;AACtB,0EAA0E;AAC1E,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,MAAM,CA8BR;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAavD"}
|