@crewhaus/runtime-core 0.5.1 → 0.5.2
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 +18 -0
- package/dist/index.js +36 -7
- package/package.json +40 -40
package/dist/index.d.ts
CHANGED
|
@@ -375,6 +375,24 @@ export type RunChatLoopOptions = {
|
|
|
375
375
|
permissionMode?: PermissionMode;
|
|
376
376
|
/** Layered rule sources. Defaults to `{ ..., builtin: BUILTIN_DEFAULT_RULES }`. */
|
|
377
377
|
permissionRules?: RuleSet;
|
|
378
|
+
/**
|
|
379
|
+
* #383 — the harness root whose `.crewhaus/settings.json` supplies the
|
|
380
|
+
* `settings`-source permission rules. Every run loads that file at loop
|
|
381
|
+
* start and merges its rules into the `settings` layer (deduped against
|
|
382
|
+
* any settings rules the caller already passed), so operator-persisted
|
|
383
|
+
* standing allows (`crewhaus approvals grant --always`, the Slack "Always
|
|
384
|
+
* allow" button) reach compiled daemons without a recompile. Defaults to
|
|
385
|
+
* `process.cwd()` — the standalone-harness convention. A malformed
|
|
386
|
+
* settings file throws (fail closed, matching the CLI's own reader).
|
|
387
|
+
*
|
|
388
|
+
* `null` DISABLES the load. Sub-agent child loops pass `null`: a child's
|
|
389
|
+
* RuleSet arrives already narrowed by `resolveChildPermissions` from the
|
|
390
|
+
* parent's MERGED rules (the bridge hands the disk-inclusive set to the
|
|
391
|
+
* Task tool), and re-merging the harness file here would let a standing
|
|
392
|
+
* allow in `settings` outrank a replace-mode child's explicit `yaml`
|
|
393
|
+
* deny — widening a deliberately narrowed child.
|
|
394
|
+
*/
|
|
395
|
+
settingsDir?: string | null;
|
|
378
396
|
/**
|
|
379
397
|
* Install a SIGINT handler that aborts the current turn on first press
|
|
380
398
|
* and exits on the second. Defaults to true in REPL mode when stdin is
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { ConfigError, EXIT_CODES, RunFailedError, RuntimeError, isRunFailedError
|
|
|
14
14
|
import { DEFAULT_ROOT_DIR, openEventLog } from "@crewhaus/event-log";
|
|
15
15
|
import { aggregateDecisions, runHooks } from "@crewhaus/hooks-engine";
|
|
16
16
|
import { createFailoverChain, createPolicyRouter, createTierRouter, parseModelString, resolveModel, } from "@crewhaus/model-router";
|
|
17
|
-
import { BUILTIN_DEFAULT_RULES, emptyRuleSet, evaluateJustification, evaluateWithReason, ruleBasedJustificationJudge, } from "@crewhaus/permission-engine";
|
|
17
|
+
import { BUILTIN_DEFAULT_RULES, emptyRuleSet, evaluateJustification, evaluateWithReason, loadSettingsRules, ruleBasedJustificationJudge, } from "@crewhaus/permission-engine";
|
|
18
18
|
import { manage as manageCacheMarkers } from "@crewhaus/prompt-cache-manager";
|
|
19
19
|
import { buildRedactionNotice, classifyText, llmClassifierEnabled, } from "@crewhaus/prompt-injection-detector";
|
|
20
20
|
import { createRateLimiter } from "@crewhaus/rate-limiter";
|
|
@@ -1546,10 +1546,32 @@ export async function runChatLoop(opts) {
|
|
|
1546
1546
|
...(curateConfig !== undefined ? { curate: curateConfig, onCurate: publishCurate } : {}),
|
|
1547
1547
|
});
|
|
1548
1548
|
const permissionMode = opts.permissionMode ?? "default";
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1549
|
+
// #383 — merge the harness's `.crewhaus/settings.json` rules into the
|
|
1550
|
+
// `settings` layer. Compiled bundles emit `settings: []`, so without this
|
|
1551
|
+
// load an operator-persisted standing allow (`approvals grant --always`)
|
|
1552
|
+
// could never reach a daemon; interpreter paths (the CLI) already read the
|
|
1553
|
+
// same file themselves, which the (type, pattern) dedupe absorbs. Loaded
|
|
1554
|
+
// once per run — a park ends the run, so the re-driven run re-reads it.
|
|
1555
|
+
// `settingsDir: null` (sub-agent child loops) skips the load entirely.
|
|
1556
|
+
const permissionRules = (() => {
|
|
1557
|
+
const base = opts.permissionRules ?? {
|
|
1558
|
+
...emptyRuleSet,
|
|
1559
|
+
builtin: BUILTIN_DEFAULT_RULES,
|
|
1560
|
+
};
|
|
1561
|
+
if (opts.settingsDir === null)
|
|
1562
|
+
return base;
|
|
1563
|
+
const diskSettings = loadSettingsRules(opts.settingsDir ?? process.cwd());
|
|
1564
|
+
if (diskSettings.length === 0)
|
|
1565
|
+
return base;
|
|
1566
|
+
const seen = new Set(base.settings.map((r) => `${r.type}${r.pattern}`));
|
|
1567
|
+
return {
|
|
1568
|
+
...base,
|
|
1569
|
+
settings: [
|
|
1570
|
+
...base.settings,
|
|
1571
|
+
...diskSettings.filter((r) => !seen.has(`${r.type}${r.pattern}`)),
|
|
1572
|
+
],
|
|
1573
|
+
};
|
|
1574
|
+
})();
|
|
1553
1575
|
const userInstructions = {
|
|
1554
1576
|
type: "text",
|
|
1555
1577
|
text: opts.instructions,
|
|
@@ -2023,7 +2045,14 @@ export async function runChatLoop(opts) {
|
|
|
2023
2045
|
const inputHash = hashApprovalInput(tu.name, tu.input);
|
|
2024
2046
|
const existing = await approvals.store.get(tu.name, inputHash);
|
|
2025
2047
|
if (existing?.decision === "grant") {
|
|
2026
|
-
// One-shot allow: consume the grant so a later identical call
|
|
2048
|
+
// One-shot allow: consume the grant so a later identical call
|
|
2049
|
+
// re-asks. A STANDING grant (#383, `existing.always`) is consumed
|
|
2050
|
+
// the same way — its standing behavior rides the settings-source
|
|
2051
|
+
// `alwaysAllow` rule the resolving surface persisted, which
|
|
2052
|
+
// pre-decides future calls before this store is ever consulted.
|
|
2053
|
+
// Keeping consumption uniform means deleting that rule fully
|
|
2054
|
+
// revokes the standing allow (no unconsumed record lingers to
|
|
2055
|
+
// pre-approve the parked input until the TTL sweep).
|
|
2027
2056
|
approved = true;
|
|
2028
2057
|
await approvals.store.persist({ ...existing, consumedAt: new Date().toISOString() });
|
|
2029
2058
|
}
|
|
@@ -2076,7 +2105,7 @@ export async function runChatLoop(opts) {
|
|
|
2076
2105
|
class: "approval_pending",
|
|
2077
2106
|
title: "awaiting tool approval",
|
|
2078
2107
|
detail: `\`${tu.name}\` requires approval on a non-interactive surface (${approvalSurface}); the run is parked as approval ${pending.id}`,
|
|
2079
|
-
remediation: `grant or deny approval ${pending.id} out of band (e.g. \`crewhaus approvals grant ${pending.id}\`), then rerun`,
|
|
2108
|
+
remediation: `grant or deny approval ${pending.id} out of band (e.g. \`crewhaus approvals grant ${pending.id}\`; add \`--always\` to allow \`${tu.name}\` from now on), then rerun`,
|
|
2080
2109
|
exitCode: EXIT_CODES.approval_pending,
|
|
2081
2110
|
});
|
|
2082
2111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/runtime-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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.2",
|
|
20
|
+
"@crewhaus/adapter-anthropic": "0.5.2",
|
|
21
|
+
"@crewhaus/agent-context-isolation": "0.5.2",
|
|
22
|
+
"@crewhaus/boundary-classifier": "0.5.2",
|
|
23
|
+
"@crewhaus/circuit-breaker": "0.5.2",
|
|
24
|
+
"@crewhaus/compaction-autocompact": "0.5.2",
|
|
25
|
+
"@crewhaus/compaction-curator": "0.5.2",
|
|
26
|
+
"@crewhaus/compaction-snip": "0.5.2",
|
|
27
|
+
"@crewhaus/cost-tracker": "0.5.2",
|
|
28
|
+
"@crewhaus/egress-classifier": "0.5.2",
|
|
29
|
+
"@crewhaus/errors": "0.5.2",
|
|
30
|
+
"@crewhaus/event-log": "0.5.2",
|
|
31
|
+
"@crewhaus/hooks-engine": "0.5.2",
|
|
32
|
+
"@crewhaus/model-router": "0.5.2",
|
|
33
|
+
"@crewhaus/permission-engine": "0.5.2",
|
|
34
|
+
"@crewhaus/prompt-cache-manager": "0.5.2",
|
|
35
|
+
"@crewhaus/prompt-injection-detector": "0.5.2",
|
|
36
|
+
"@crewhaus/rate-limiter": "0.5.2",
|
|
37
|
+
"@crewhaus/recovery-engine": "0.5.2",
|
|
38
|
+
"@crewhaus/routing-store": "0.5.2",
|
|
39
|
+
"@crewhaus/run-context": "0.5.2",
|
|
40
|
+
"@crewhaus/session-store": "0.5.2",
|
|
41
|
+
"@crewhaus/skills-registry": "0.5.2",
|
|
42
|
+
"@crewhaus/slash-commands": "0.5.2",
|
|
43
|
+
"@crewhaus/state-store": "0.5.2",
|
|
44
|
+
"@crewhaus/tenancy": "0.5.2",
|
|
45
|
+
"@crewhaus/token-budget": "0.5.2",
|
|
46
|
+
"@crewhaus/tool-catalog": "0.5.2",
|
|
47
|
+
"@crewhaus/tool-executor": "0.5.2",
|
|
48
|
+
"@crewhaus/tool-loop-detection": "0.5.2",
|
|
49
|
+
"@crewhaus/tool-orchestrator": "0.5.2",
|
|
50
|
+
"@crewhaus/tool-result-store": "0.5.2",
|
|
51
|
+
"@crewhaus/streaming-tool-executor": "0.5.2",
|
|
52
|
+
"@crewhaus/turn-state-machine": "0.5.2",
|
|
53
|
+
"@crewhaus/trace-event-bus": "0.5.2",
|
|
54
|
+
"@crewhaus/worker-runtime": "0.5.2",
|
|
55
|
+
"@crewhaus/structured-event-printer": "0.5.2",
|
|
56
|
+
"@crewhaus/metrics-collector": "0.5.2",
|
|
57
|
+
"@crewhaus/otel-exporter": "0.5.2",
|
|
58
58
|
"zod-to-json-schema": "^3.23.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|