@crewhaus/runtime-core 0.5.3 → 0.5.4
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/dist/index.d.ts +46 -1
- package/dist/index.js +242 -5
- package/package.json +40 -40
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,51 @@ export type { CreateJanitorOptions, Janitor, JanitorBuiltinStepName, JanitorRese
|
|
|
126
126
|
export { AGENT_IDENTITY_SCHEMA_VERSION, DEFAULT_IDENTITY_DIR, IDENTITY_FILENAME, agentFingerprint, loadOrCreateAgentIdentity, } from "./identity";
|
|
127
127
|
export type { AgentIdentityFile } from "./identity";
|
|
128
128
|
export { type ApprovalDecision, type PendingApproval, type PendingApprovalStore, type PendingApprovalStoreOptions, createPendingApprovalStore, evictExpiredApprovals, generateApprovalId, hashApprovalInput, } from "@crewhaus/session-store";
|
|
129
|
+
/**
|
|
130
|
+
* How long after an operator's DECISION a grant may still satisfy a call the
|
|
131
|
+
* model has re-worded. Generous enough for a resume (which follows the grant
|
|
132
|
+
* within seconds on every surface), short enough that an unspent grant cannot
|
|
133
|
+
* be replayed onto an unrelated turn an hour later.
|
|
134
|
+
*/
|
|
135
|
+
export declare const REPLAYABLE_GRANT_MAX_AGE_MS: number;
|
|
136
|
+
/**
|
|
137
|
+
* #400 — find the grant an operator made for a call this run has since
|
|
138
|
+
* REGENERATED differently.
|
|
139
|
+
*
|
|
140
|
+
* Only ever consulted after the exact-hash lookup misses, so the normal path
|
|
141
|
+
* (a byte-identical re-issue) is untouched. Every condition below is load-
|
|
142
|
+
* bearing; together they are what keeps a replay from becoming a standing
|
|
143
|
+
* allow:
|
|
144
|
+
*
|
|
145
|
+
* - `sessionId` — a grant never leaks into another conversation.
|
|
146
|
+
* - `toolName` — a grant for one tool never authorizes another.
|
|
147
|
+
* - `decision === "grant"` and no `consumedAt` — one-shot means one shot.
|
|
148
|
+
* - `runId !== <this run>` — the grant must come from a PRIOR run, i.e.
|
|
149
|
+
* this really is a resume. Without it a run could park, be granted, and
|
|
150
|
+
* then spend that grant on a *second, different* call inside the same
|
|
151
|
+
* run — turning one approval into a tool-wide licence for the turn.
|
|
152
|
+
* - `input !== undefined` — the record must actually carry what was
|
|
153
|
+
* approved. `PendingApproval.input` is optional and unvalidated, so a
|
|
154
|
+
* record written by an older or foreign writer has nothing to replay; the
|
|
155
|
+
* honest answer there is to park, not to guess.
|
|
156
|
+
*
|
|
157
|
+
* Newest-first, so when several grants are outstanding the most recent
|
|
158
|
+
* decision wins — the same "latest decision" posture the store's own `get`
|
|
159
|
+
* takes.
|
|
160
|
+
*
|
|
161
|
+
* `list` is optional on the injected store: a caller that supplies a minimal
|
|
162
|
+
* `{persist,get,resolve}` store simply never replays and keeps the pre-#400
|
|
163
|
+
* behaviour, rather than failing.
|
|
164
|
+
*/
|
|
165
|
+
export declare function findReplayableGrant(store: Pick<PendingApprovalStore, "persist" | "get" | "resolve"> & Partial<Pick<PendingApprovalStore, "list">>, where: {
|
|
166
|
+
readonly toolName: string;
|
|
167
|
+
readonly sessionId: string;
|
|
168
|
+
readonly runId: string;
|
|
169
|
+
/** Epoch ms; the freshness window is measured from the DECISION. */
|
|
170
|
+
readonly now?: number;
|
|
171
|
+
/** Override the window (tests). */
|
|
172
|
+
readonly maxAgeMs?: number;
|
|
173
|
+
}): Promise<PendingApproval | undefined>;
|
|
129
174
|
export { type AlertBreachPayload, type AlertSink, type AttachDefaultSubscribersOptions, attachDefaultSubscribers, } from "./observability";
|
|
130
175
|
export { type AttachedSloMonitor, type AttachSloMonitorOptions, type SloBreach, type SloMitigationEvent, type SloMitigationRung, type SloMitigationSink, type SloTargets, type SloWindowMetrics, DEFAULT_SLO_WINDOW_MS, MIN_SLO_SAMPLES, SloWindow, attachSloMonitor, detectSloBreaches, } from "./slo-monitor";
|
|
131
176
|
export { type AttachIncidentCollectorOptions, type IncidentCapture, type IncidentTriggerKind, attachIncidentCollector, classifyIncidentTrigger, } from "./incident-collector";
|
|
@@ -1134,7 +1179,7 @@ export type RunChatLoopOptions = {
|
|
|
1134
1179
|
* from the full `PendingApprovalStore` so a caller may inject a minimal
|
|
1135
1180
|
* store; the concrete `createPendingApprovalStore` satisfies it.
|
|
1136
1181
|
*/
|
|
1137
|
-
readonly store: Pick<PendingApprovalStore, "persist" | "get" | "resolve"
|
|
1182
|
+
readonly store: Pick<PendingApprovalStore, "persist" | "get" | "resolve"> & Partial<Pick<PendingApprovalStore, "list">>;
|
|
1138
1183
|
readonly notify?: (approval: PendingApproval) => Promise<void>;
|
|
1139
1184
|
readonly surface?: string;
|
|
1140
1185
|
};
|
package/dist/index.js
CHANGED
|
@@ -413,6 +413,91 @@ export { AGENT_IDENTITY_SCHEMA_VERSION, DEFAULT_IDENTITY_DIR, IDENTITY_FILENAME,
|
|
|
413
413
|
// build the store + input hash it passes as `RunChatLoopOptions.approvals`
|
|
414
414
|
// without depending on session-store directly.
|
|
415
415
|
export { createPendingApprovalStore, evictExpiredApprovals, generateApprovalId, hashApprovalInput, } from "@crewhaus/session-store";
|
|
416
|
+
/**
|
|
417
|
+
* How long after an operator's DECISION a grant may still satisfy a call the
|
|
418
|
+
* model has re-worded. Generous enough for a resume (which follows the grant
|
|
419
|
+
* within seconds on every surface), short enough that an unspent grant cannot
|
|
420
|
+
* be replayed onto an unrelated turn an hour later.
|
|
421
|
+
*/
|
|
422
|
+
export const REPLAYABLE_GRANT_MAX_AGE_MS = 15 * 60 * 1000;
|
|
423
|
+
/**
|
|
424
|
+
* #400 — find the grant an operator made for a call this run has since
|
|
425
|
+
* REGENERATED differently.
|
|
426
|
+
*
|
|
427
|
+
* Only ever consulted after the exact-hash lookup misses, so the normal path
|
|
428
|
+
* (a byte-identical re-issue) is untouched. Every condition below is load-
|
|
429
|
+
* bearing; together they are what keeps a replay from becoming a standing
|
|
430
|
+
* allow:
|
|
431
|
+
*
|
|
432
|
+
* - `sessionId` — a grant never leaks into another conversation.
|
|
433
|
+
* - `toolName` — a grant for one tool never authorizes another.
|
|
434
|
+
* - `decision === "grant"` and no `consumedAt` — one-shot means one shot.
|
|
435
|
+
* - `runId !== <this run>` — the grant must come from a PRIOR run, i.e.
|
|
436
|
+
* this really is a resume. Without it a run could park, be granted, and
|
|
437
|
+
* then spend that grant on a *second, different* call inside the same
|
|
438
|
+
* run — turning one approval into a tool-wide licence for the turn.
|
|
439
|
+
* - `input !== undefined` — the record must actually carry what was
|
|
440
|
+
* approved. `PendingApproval.input` is optional and unvalidated, so a
|
|
441
|
+
* record written by an older or foreign writer has nothing to replay; the
|
|
442
|
+
* honest answer there is to park, not to guess.
|
|
443
|
+
*
|
|
444
|
+
* Newest-first, so when several grants are outstanding the most recent
|
|
445
|
+
* decision wins — the same "latest decision" posture the store's own `get`
|
|
446
|
+
* takes.
|
|
447
|
+
*
|
|
448
|
+
* `list` is optional on the injected store: a caller that supplies a minimal
|
|
449
|
+
* `{persist,get,resolve}` store simply never replays and keeps the pre-#400
|
|
450
|
+
* behaviour, rather than failing.
|
|
451
|
+
*/
|
|
452
|
+
export async function findReplayableGrant(store, where) {
|
|
453
|
+
if (typeof store.list !== "function")
|
|
454
|
+
return undefined;
|
|
455
|
+
let all;
|
|
456
|
+
try {
|
|
457
|
+
all = await store.list();
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
// A read that fails must not fail the tool call: park as before.
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
463
|
+
const now = where.now ?? Date.now();
|
|
464
|
+
const maxAgeMs = where.maxAgeMs ?? REPLAYABLE_GRANT_MAX_AGE_MS;
|
|
465
|
+
const matches = all.filter((a) => {
|
|
466
|
+
if (a.toolName !== where.toolName)
|
|
467
|
+
return false;
|
|
468
|
+
if (a.sessionId !== where.sessionId)
|
|
469
|
+
return false;
|
|
470
|
+
if (a.decision !== "grant")
|
|
471
|
+
return false;
|
|
472
|
+
if (a.consumedAt !== undefined)
|
|
473
|
+
return false;
|
|
474
|
+
if (a.runId === where.runId)
|
|
475
|
+
return false;
|
|
476
|
+
if (a.input === undefined)
|
|
477
|
+
return false;
|
|
478
|
+
// FRESHNESS, measured from the DECISION — not from the park.
|
|
479
|
+
//
|
|
480
|
+
// Without it a grant that was never spent sits in a long-lived session
|
|
481
|
+
// forever and is replayed onto an unrelated later turn: the operator
|
|
482
|
+
// asked for X an hour ago, approved it, the resume happened not to call
|
|
483
|
+
// the tool, and now an unrelated request runs X. Bounding from
|
|
484
|
+
// `decidedAt` is what makes the window track the approve→resume gap
|
|
485
|
+
// (seconds: the Slack button resumes immediately, and a CLI grant is
|
|
486
|
+
// followed by `runs resume`) rather than the park→approve gap, which is
|
|
487
|
+
// human-paced and may be hours.
|
|
488
|
+
//
|
|
489
|
+
// A grant older than this is not discarded — it stays a valid record for
|
|
490
|
+
// the EXACT-hash path, which is unbounded. Only the fuzzy replay is
|
|
491
|
+
// time-boxed.
|
|
492
|
+
const decidedAt = a.decidedAt !== undefined ? Date.parse(a.decidedAt) : Number.NaN;
|
|
493
|
+
if (!Number.isFinite(decidedAt))
|
|
494
|
+
return false;
|
|
495
|
+
return now - decidedAt <= maxAgeMs;
|
|
496
|
+
});
|
|
497
|
+
// `list()` is newest-first by contract, but sort defensively rather than
|
|
498
|
+
// trust the ordering of a store a caller injected.
|
|
499
|
+
return [...matches].sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0];
|
|
500
|
+
}
|
|
416
501
|
// Ops item 31 — alert watchdog seams re-exported so the CLI/codegen can build
|
|
417
502
|
// the durable + off-box alert sink (audit append + settings.json alert hook /
|
|
418
503
|
// webhook) it passes as `RunChatLoopOptions.alertSink`.
|
|
@@ -1814,6 +1899,9 @@ export async function runChatLoop(opts) {
|
|
|
1814
1899
|
// justification gate, and the justification audit sink. Tools that
|
|
1815
1900
|
// declare the field in their own schema are NOT in this set — for them
|
|
1816
1901
|
// the field is genuine tool input everywhere.
|
|
1902
|
+
// #400 — approval ids this RUN has already replayed. Claimed synchronously
|
|
1903
|
+
// so two concurrent tool calls cannot both spend one one-shot grant.
|
|
1904
|
+
const replayedApprovalIds = new Set();
|
|
1817
1905
|
const justificationInjectedTools = new Set(advertisedTools
|
|
1818
1906
|
.filter(({ advertised }) => advertised.justificationInjected)
|
|
1819
1907
|
.map(({ tool }) => tool.name));
|
|
@@ -1974,7 +2062,13 @@ export async function runChatLoop(opts) {
|
|
|
1974
2062
|
* Used by both the partitioned (post-stream) path and the streaming
|
|
1975
2063
|
* path so the permission/abort/store contract is uniform.
|
|
1976
2064
|
*/
|
|
1977
|
-
async function executeOneToolUse(
|
|
2065
|
+
async function executeOneToolUse(tuAsRequested) {
|
|
2066
|
+
// REBINDABLE on purpose (#400): a replayed approval substitutes the
|
|
2067
|
+
// operator-approved input for the model's regenerated one, and every
|
|
2068
|
+
// consumer below — the validator, the executor, the justification gate,
|
|
2069
|
+
// the egress classifier, the result record — reads through `tu`. Rebinding
|
|
2070
|
+
// here is what makes the substitution reach all of them instead of one.
|
|
2071
|
+
let tu = tuAsRequested;
|
|
1978
2072
|
// End the "thinking" wait — but only when no tool is already mid-flight.
|
|
1979
2073
|
// The streaming executor dispatches concurrency-safe tools with overlap, so
|
|
1980
2074
|
// an unconditional stop here would tear down a sibling tool's live spinner;
|
|
@@ -2008,7 +2102,30 @@ export async function runChatLoop(opts) {
|
|
|
2008
2102
|
});
|
|
2009
2103
|
const t0Tool = performance.now();
|
|
2010
2104
|
const tool = toolByName.get(tu.name);
|
|
2011
|
-
|
|
2105
|
+
// #400 — set when this call ran the input an operator APPROVED rather
|
|
2106
|
+
// than the one the model regenerated. Function-scoped so `finish` (the
|
|
2107
|
+
// single choke point every result passes through) can tell the model,
|
|
2108
|
+
// whichever return path fires.
|
|
2109
|
+
let replayedFrom;
|
|
2110
|
+
const finish = async (resultIn) => {
|
|
2111
|
+
let result = resultIn;
|
|
2112
|
+
// Say so IN THE RESULT. The assistant message still shows the input the
|
|
2113
|
+
// model asked for, so without this the model would reason about an
|
|
2114
|
+
// action that did not happen — and might "correct" itself by re-issuing
|
|
2115
|
+
// the call it thinks failed.
|
|
2116
|
+
if (replayedFrom !== undefined) {
|
|
2117
|
+
const notice = `[approval ${replayedFrom.id} was granted for a different wording of this call; the APPROVED input was executed, not the one you just sent. Read the result as the outcome of the approved action.]`;
|
|
2118
|
+
// Block content (images, structured blocks) is just as capable of
|
|
2119
|
+
// misleading the model as a string, so the notice rides both shapes —
|
|
2120
|
+
// prepended as its own text block when the content is an array.
|
|
2121
|
+
result =
|
|
2122
|
+
typeof result.content === "string"
|
|
2123
|
+
? { ...result, content: `${notice}\n${result.content}` }
|
|
2124
|
+
: {
|
|
2125
|
+
...result,
|
|
2126
|
+
content: [{ type: "text", text: notice }, ...(result.content ?? [])],
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2012
2129
|
await logEvent("tool_result", {
|
|
2013
2130
|
toolUseId: tu.id,
|
|
2014
2131
|
content: typeof result.content === "string"
|
|
@@ -2072,7 +2189,7 @@ export async function runChatLoop(opts) {
|
|
|
2072
2189
|
// DOES (rule matching, approval hashing, egress, execution) consumes
|
|
2073
2190
|
// this; surfaces that record what the model DID keep `tu.input`. See the
|
|
2074
2191
|
// `justificationInjectedTools` comment at loop start for the full split.
|
|
2075
|
-
|
|
2192
|
+
let operativeInput = operativeToolInput(tu.name, tu.input);
|
|
2076
2193
|
const decisionDetails = evaluateWithReason({
|
|
2077
2194
|
toolName: tu.name,
|
|
2078
2195
|
input: operativeInput,
|
|
@@ -2110,7 +2227,48 @@ export async function runChatLoop(opts) {
|
|
|
2110
2227
|
// forever. The persisted record still carries the full `tu.input`
|
|
2111
2228
|
// below so the approving operator SEES the justification.
|
|
2112
2229
|
const inputHash = hashApprovalInput(tu.name, operativeInput);
|
|
2113
|
-
|
|
2230
|
+
let existing = await approvals.store.get(tu.name, inputHash);
|
|
2231
|
+
// #400 — THE RESUMED CALL IS NOT THE PARKED CALL.
|
|
2232
|
+
//
|
|
2233
|
+
// A grant is keyed on whole-input equality, which silently assumes the
|
|
2234
|
+
// resumed run re-issues a byte-identical tool call. It does not: resume
|
|
2235
|
+
// re-drives the turn, the model regenerates the call, and
|
|
2236
|
+
// `sanitizeOrphanToolUses` has stripped the parked `tool_use` from the
|
|
2237
|
+
// replayed transcript — so the model is generating it FRESH and may
|
|
2238
|
+
// word any field differently. One re-worded argument moves the hash,
|
|
2239
|
+
// `get` misses, and the run parks AGAIN under a new id. Approve →
|
|
2240
|
+
// regenerate → re-park, forever: a plain one-shot grant could never
|
|
2241
|
+
// satisfy a model-driven tool, leaving `--always` (a STANDING allow on
|
|
2242
|
+
// a quota-spending or irreversible tool) as the only thing that landed
|
|
2243
|
+
// a single call.
|
|
2244
|
+
//
|
|
2245
|
+
// So when the exact key misses, look for the grant the operator
|
|
2246
|
+
// actually made — same session, same tool, still unspent — and run THE
|
|
2247
|
+
// INPUT THEY APPROVED rather than the one the model just regenerated.
|
|
2248
|
+
// Substituting is what keeps the security property intact: the
|
|
2249
|
+
// operator authorized a specific action shown to them on the approval
|
|
2250
|
+
// card, and that action is what executes. Honouring the grant for the
|
|
2251
|
+
// regenerated input instead would let a re-worded `place_call` dial a
|
|
2252
|
+
// different number under an approval for the first.
|
|
2253
|
+
if (existing === null) {
|
|
2254
|
+
const replay = await findReplayableGrant(approvals.store, {
|
|
2255
|
+
toolName: tu.name,
|
|
2256
|
+
sessionId,
|
|
2257
|
+
runId: bus.runId,
|
|
2258
|
+
now: Date.now(),
|
|
2259
|
+
});
|
|
2260
|
+
// CLAIM IT SYNCHRONOUSLY. The lookup reads and the consuming
|
|
2261
|
+
// `persist` writes, and up to `maxConcurrentTools` ask-gated calls
|
|
2262
|
+
// run through this gate at once — so without a claim two parallel
|
|
2263
|
+
// calls both find the same unconsumed grant and both execute. The
|
|
2264
|
+
// set is per-run and in-process, which is where that race is;
|
|
2265
|
+
// across processes the store's `consumedAt` remains the authority.
|
|
2266
|
+
if (replay !== undefined && !replayedApprovalIds.has(replay.id)) {
|
|
2267
|
+
replayedApprovalIds.add(replay.id);
|
|
2268
|
+
replayedFrom = replay;
|
|
2269
|
+
existing = replay;
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2114
2272
|
if (existing?.decision === "grant") {
|
|
2115
2273
|
// One-shot allow: consume the grant so a later identical call
|
|
2116
2274
|
// re-asks. A STANDING grant (#383, `existing.always`) is consumed
|
|
@@ -2121,7 +2279,86 @@ export async function runChatLoop(opts) {
|
|
|
2121
2279
|
// revokes the standing allow (no unconsumed record lingers to
|
|
2122
2280
|
// pre-approve the parked input until the TTL sweep).
|
|
2123
2281
|
approved = true;
|
|
2124
|
-
|
|
2282
|
+
if (replayedFrom !== undefined) {
|
|
2283
|
+
// Run WHAT WAS APPROVED. `tu.input` is the model's regenerated
|
|
2284
|
+
// wording; the record carries the input the operator saw and said
|
|
2285
|
+
// yes to, and that is the one with an authorization behind it.
|
|
2286
|
+
const approvedInput = replayedFrom.input;
|
|
2287
|
+
const approvedOperative = operativeToolInput(tu.name, approvedInput);
|
|
2288
|
+
// Re-evaluate POLICY against what will actually run. The approved
|
|
2289
|
+
// input passed these rules in the run that parked it, but the
|
|
2290
|
+
// rules are read fresh each loop and an operator may have tightened
|
|
2291
|
+
// them since — and a grant is permission from a human, not an
|
|
2292
|
+
// exemption from the spec. A rule that now DENIES wins.
|
|
2293
|
+
const recheck = evaluateWithReason({
|
|
2294
|
+
toolName: tu.name,
|
|
2295
|
+
input: approvedOperative,
|
|
2296
|
+
readOnly: tool.readOnly,
|
|
2297
|
+
destructive: tool.destructive,
|
|
2298
|
+
requiresSandbox: tool.requiresSandbox,
|
|
2299
|
+
}, permissionMode, permissionRules, { sandboxAvailable: opts.sandboxAvailable === true });
|
|
2300
|
+
if (recheck.decision === "deny") {
|
|
2301
|
+
approved = false;
|
|
2302
|
+
denialMessage =
|
|
2303
|
+
`tool denied: approval ${replayedFrom.id} was granted, but \`${tu.name}\` is now denied by permission policy` +
|
|
2304
|
+
`${recheck.reason !== undefined ? ` (${recheck.reason})` : ""}.`;
|
|
2305
|
+
// The grant is NOT spent on a call that never ran, and the
|
|
2306
|
+
// result must not claim an approved input executed.
|
|
2307
|
+
replayedFrom = undefined;
|
|
2308
|
+
}
|
|
2309
|
+
else {
|
|
2310
|
+
tu = { ...tu, input: approvedInput };
|
|
2311
|
+
operativeInput = approvedOperative;
|
|
2312
|
+
// The `pre-tool` hook already judged the input the MODEL sent,
|
|
2313
|
+
// several steps above. A hook that can deny must judge what will
|
|
2314
|
+
// actually RUN, so re-fire it against the substituted input.
|
|
2315
|
+
const replayHook = await fireHook("pre-tool", {
|
|
2316
|
+
id: tu.id,
|
|
2317
|
+
name: tu.name,
|
|
2318
|
+
input: tu.input,
|
|
2319
|
+
});
|
|
2320
|
+
if (!replayHook.allowed) {
|
|
2321
|
+
approved = false;
|
|
2322
|
+
denialMessage = `[blocked by hook] ${replayHook.reason ?? "denied"}`;
|
|
2323
|
+
replayedFrom = undefined;
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
if (approved) {
|
|
2328
|
+
// Consume only once the call is really going to run: a replay the
|
|
2329
|
+
// policy or a hook then refused must leave the operator's grant
|
|
2330
|
+
// unspent, or they have to approve the same action twice.
|
|
2331
|
+
await approvals.store.persist({
|
|
2332
|
+
...existing,
|
|
2333
|
+
consumedAt: new Date().toISOString(),
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
if (replayedFrom !== undefined && approved) {
|
|
2337
|
+
bus.publish({
|
|
2338
|
+
...bus.envelope(),
|
|
2339
|
+
kind: "permission_decision",
|
|
2340
|
+
toolName: tu.name,
|
|
2341
|
+
decision: "allow",
|
|
2342
|
+
mode: permissionMode,
|
|
2343
|
+
reason: `approval ${replayedFrom.id} replayed: executing the APPROVED input, not the regenerated one`,
|
|
2344
|
+
});
|
|
2345
|
+
runContext.logger.info("tool approval replayed", {
|
|
2346
|
+
approvalId: replayedFrom.id,
|
|
2347
|
+
toolName: tu.name,
|
|
2348
|
+
detail: "the resumed turn regenerated a different input; the operator-approved input was executed instead",
|
|
2349
|
+
});
|
|
2350
|
+
// The durable `tool_use` record holds what the MODEL asked for —
|
|
2351
|
+
// correct, that is what the model did — but nothing yet recorded
|
|
2352
|
+
// what RAN, and an audit trail showing only the discarded input is
|
|
2353
|
+
// worse than one showing both.
|
|
2354
|
+
await logEvent("tool_use", {
|
|
2355
|
+
id: tu.id,
|
|
2356
|
+
name: tu.name,
|
|
2357
|
+
input: replayedFrom.input,
|
|
2358
|
+
approvalReplayedFrom: replayedFrom.id,
|
|
2359
|
+
requestedInput: tuAsRequested.input,
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2125
2362
|
}
|
|
2126
2363
|
else if (existing?.decision === "deny") {
|
|
2127
2364
|
approved = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/runtime-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Minimal runtime imported by generated harness bundles",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,45 +16,45 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anthropic-ai/sdk": "^0.96.0",
|
|
19
|
-
"@crewhaus/abort-controller": "0.5.
|
|
20
|
-
"@crewhaus/adapter-anthropic": "0.5.
|
|
21
|
-
"@crewhaus/agent-context-isolation": "0.5.
|
|
22
|
-
"@crewhaus/boundary-classifier": "0.5.
|
|
23
|
-
"@crewhaus/circuit-breaker": "0.5.
|
|
24
|
-
"@crewhaus/compaction-autocompact": "0.5.
|
|
25
|
-
"@crewhaus/compaction-curator": "0.5.
|
|
26
|
-
"@crewhaus/compaction-snip": "0.5.
|
|
27
|
-
"@crewhaus/cost-tracker": "0.5.
|
|
28
|
-
"@crewhaus/egress-classifier": "0.5.
|
|
29
|
-
"@crewhaus/errors": "0.5.
|
|
30
|
-
"@crewhaus/event-log": "0.5.
|
|
31
|
-
"@crewhaus/hooks-engine": "0.5.
|
|
32
|
-
"@crewhaus/model-router": "0.5.
|
|
33
|
-
"@crewhaus/permission-engine": "0.5.
|
|
34
|
-
"@crewhaus/prompt-cache-manager": "0.5.
|
|
35
|
-
"@crewhaus/prompt-injection-detector": "0.5.
|
|
36
|
-
"@crewhaus/rate-limiter": "0.5.
|
|
37
|
-
"@crewhaus/recovery-engine": "0.5.
|
|
38
|
-
"@crewhaus/routing-store": "0.5.
|
|
39
|
-
"@crewhaus/run-context": "0.5.
|
|
40
|
-
"@crewhaus/session-store": "0.5.
|
|
41
|
-
"@crewhaus/skills-registry": "0.5.
|
|
42
|
-
"@crewhaus/slash-commands": "0.5.
|
|
43
|
-
"@crewhaus/state-store": "0.5.
|
|
44
|
-
"@crewhaus/tenancy": "0.5.
|
|
45
|
-
"@crewhaus/token-budget": "0.5.
|
|
46
|
-
"@crewhaus/tool-catalog": "0.5.
|
|
47
|
-
"@crewhaus/tool-executor": "0.5.
|
|
48
|
-
"@crewhaus/tool-loop-detection": "0.5.
|
|
49
|
-
"@crewhaus/tool-orchestrator": "0.5.
|
|
50
|
-
"@crewhaus/tool-result-store": "0.5.
|
|
51
|
-
"@crewhaus/streaming-tool-executor": "0.5.
|
|
52
|
-
"@crewhaus/turn-state-machine": "0.5.
|
|
53
|
-
"@crewhaus/trace-event-bus": "0.5.
|
|
54
|
-
"@crewhaus/worker-runtime": "0.5.
|
|
55
|
-
"@crewhaus/structured-event-printer": "0.5.
|
|
56
|
-
"@crewhaus/metrics-collector": "0.5.
|
|
57
|
-
"@crewhaus/otel-exporter": "0.5.
|
|
19
|
+
"@crewhaus/abort-controller": "0.5.4",
|
|
20
|
+
"@crewhaus/adapter-anthropic": "0.5.4",
|
|
21
|
+
"@crewhaus/agent-context-isolation": "0.5.4",
|
|
22
|
+
"@crewhaus/boundary-classifier": "0.5.4",
|
|
23
|
+
"@crewhaus/circuit-breaker": "0.5.4",
|
|
24
|
+
"@crewhaus/compaction-autocompact": "0.5.4",
|
|
25
|
+
"@crewhaus/compaction-curator": "0.5.4",
|
|
26
|
+
"@crewhaus/compaction-snip": "0.5.4",
|
|
27
|
+
"@crewhaus/cost-tracker": "0.5.4",
|
|
28
|
+
"@crewhaus/egress-classifier": "0.5.4",
|
|
29
|
+
"@crewhaus/errors": "0.5.4",
|
|
30
|
+
"@crewhaus/event-log": "0.5.4",
|
|
31
|
+
"@crewhaus/hooks-engine": "0.5.4",
|
|
32
|
+
"@crewhaus/model-router": "0.5.4",
|
|
33
|
+
"@crewhaus/permission-engine": "0.5.4",
|
|
34
|
+
"@crewhaus/prompt-cache-manager": "0.5.4",
|
|
35
|
+
"@crewhaus/prompt-injection-detector": "0.5.4",
|
|
36
|
+
"@crewhaus/rate-limiter": "0.5.4",
|
|
37
|
+
"@crewhaus/recovery-engine": "0.5.4",
|
|
38
|
+
"@crewhaus/routing-store": "0.5.4",
|
|
39
|
+
"@crewhaus/run-context": "0.5.4",
|
|
40
|
+
"@crewhaus/session-store": "0.5.4",
|
|
41
|
+
"@crewhaus/skills-registry": "0.5.4",
|
|
42
|
+
"@crewhaus/slash-commands": "0.5.4",
|
|
43
|
+
"@crewhaus/state-store": "0.5.4",
|
|
44
|
+
"@crewhaus/tenancy": "0.5.4",
|
|
45
|
+
"@crewhaus/token-budget": "0.5.4",
|
|
46
|
+
"@crewhaus/tool-catalog": "0.5.4",
|
|
47
|
+
"@crewhaus/tool-executor": "0.5.4",
|
|
48
|
+
"@crewhaus/tool-loop-detection": "0.5.4",
|
|
49
|
+
"@crewhaus/tool-orchestrator": "0.5.4",
|
|
50
|
+
"@crewhaus/tool-result-store": "0.5.4",
|
|
51
|
+
"@crewhaus/streaming-tool-executor": "0.5.4",
|
|
52
|
+
"@crewhaus/turn-state-machine": "0.5.4",
|
|
53
|
+
"@crewhaus/trace-event-bus": "0.5.4",
|
|
54
|
+
"@crewhaus/worker-runtime": "0.5.4",
|
|
55
|
+
"@crewhaus/structured-event-printer": "0.5.4",
|
|
56
|
+
"@crewhaus/metrics-collector": "0.5.4",
|
|
57
|
+
"@crewhaus/otel-exporter": "0.5.4",
|
|
58
58
|
"zod-to-json-schema": "^3.23.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|