@eir-labs/coltrane 0.7.3 → 0.7.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.
@@ -1,3 +1,4 @@
1
+ import type { BrowserGrant } from "./genome_schema.js";
1
2
  /** How a granted tool name resolves to something runnable. */
2
3
  export interface ToolProvider {
3
4
  tool: string;
@@ -39,6 +40,17 @@ export declare function mcpServerOf(grant: string): string | null;
39
40
  * config from `mcpServerConfigs` (deployment-registered; coltrane ships its own); everything else —
40
41
  * including an MCP grant for an unconfigured server — is `unknown` (a dead name). */
41
42
  export declare function resolveToolGrants(allowed: readonly string[], registry: ToolProviderRegistry, mcpServerConfigs?: Readonly<Record<string, unknown>>): ResolvedGrants;
43
+ /** Per-agent grant resolution: fold the deny-by-default browser cage this agent's `browser_grant`
44
+ * builds into the mcp server configs, then resolve every grant. This is the ONE place per-agent
45
+ * resolution happens — shared by the invoker's spawn path (claude_invoker) and runGig's dispatch
46
+ * preflight (runtime) so the two resolve against the IDENTICAL environment. A preflight that
47
+ * resolved against a different environment than the chair actually gets would either refuse a
48
+ * runnable gig or wave a doomed one through — the drift this collapses. Structural agent type so
49
+ * it needs no dependency on the full Agent record. */
50
+ export declare function resolveAgentGrants(agent: {
51
+ allowed_tools?: readonly string[] | undefined;
52
+ browser_grant?: BrowserGrant | undefined;
53
+ }, registry: ToolProviderRegistry, mcpServerConfigs?: Readonly<Record<string, unknown>>): ResolvedGrants;
42
54
  /** Fail closed: an agent that grants an unresolvable tool must not be dispatched — a granted tool
43
55
  * with no provider is indistinguishable from a real one until the agent tries (and fails) to call
44
56
  * it. Raising here at dispatch surfaces it as a clear error instead of a confabulated answer. */
@@ -1,14 +1,4 @@
1
- // Tool-grant provider resolution (#185). An agent's `allowed_tools` is a set of grants, each of
2
- // which resolves to one of three provider classes:
3
- // - host-builtin (Read/Write/Edit/Bash/Glob/Grep/WebFetch/WebSearch/…): provided by the Claude
4
- // runtime, governed by --allowedTools + code_tool_access. No MCP server needed.
5
- // - mcp: provided by an MCP server (e.g. a browser server) that must be wired into the spawn's
6
- // --mcp-config. The OSS engine ships this RESOLUTION machinery; a deployment registers the
7
- // actual server config (the server itself is deployment-provided).
8
- // - in_house: a runtime primitive (e.g. output_write) the engine provides directly.
9
- // A grant that resolves to NONE of these is a DEAD NAME — the prompt lists a tool the spawn can't
10
- // provide, so the model confabulates. resolveToolGrants surfaces those as `unknown` so dispatch can
11
- // fail closed instead of launching a spawn that advertises tools it cannot back.
1
+ import { playwrightServerFor } from "./playwright_cage.js";
12
2
  // Host-builtin Claude Code tools — provided by the runtime, not an MCP server. Grants are governed
13
3
  // by --allowedTools + code_tool_access; they never need a provider entry and are never "unknown".
14
4
  const HOST_BUILTINS = new Set([
@@ -90,6 +80,20 @@ export function resolveToolGrants(allowed, registry, mcpServerConfigs = {}) {
90
80
  }
91
81
  return { mcpServers, inHouse, unknown, effectiveAllowed };
92
82
  }
83
+ /** Per-agent grant resolution: fold the deny-by-default browser cage this agent's `browser_grant`
84
+ * builds into the mcp server configs, then resolve every grant. This is the ONE place per-agent
85
+ * resolution happens — shared by the invoker's spawn path (claude_invoker) and runGig's dispatch
86
+ * preflight (runtime) so the two resolve against the IDENTICAL environment. A preflight that
87
+ * resolved against a different environment than the chair actually gets would either refuse a
88
+ * runnable gig or wave a doomed one through — the drift this collapses. Structural agent type so
89
+ * it needs no dependency on the full Agent record. */
90
+ export function resolveAgentGrants(agent, registry, mcpServerConfigs = {}) {
91
+ const browserCage = playwrightServerFor(agent.browser_grant);
92
+ const effectiveConfigs = browserCage
93
+ ? { ...mcpServerConfigs, playwright: browserCage }
94
+ : mcpServerConfigs;
95
+ return resolveToolGrants(agent.allowed_tools ?? [], registry, effectiveConfigs);
96
+ }
93
97
  /** Fail closed: an agent that grants an unresolvable tool must not be dispatched — a granted tool
94
98
  * with no provider is indistinguishable from a real one until the agent tries (and fails) to call
95
99
  * it. Raising here at dispatch surfaces it as a clear error instead of a confabulated answer. */
@@ -1 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EACjB,OAA0B,EAC1B,QAA8B,EAC9B,mBAAsD,EAAE;IAExD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACxE,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,UAAU,SAAS,kCAAkC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B;YAC3G,2FAA2F,CAC9F,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** Engine semver. Keep in lockstep with package.json `version` (enforced by test). */
2
- export declare const COLTRANE_VERSION = "0.7.3";
2
+ export declare const COLTRANE_VERSION = "0.7.4";
3
3
  /**
4
4
  * The commit this engine checkout is sitting on, or null when it can't be determined.
5
5
  *
@@ -17,7 +17,7 @@ import { existsSync, readFileSync, statSync } from "node:fs";
17
17
  import { dirname, join, resolve } from "node:path";
18
18
  import { fileURLToPath } from "node:url";
19
19
  /** Engine semver. Keep in lockstep with package.json `version` (enforced by test). */
20
- export const COLTRANE_VERSION = "0.7.3";
20
+ export const COLTRANE_VERSION = "0.7.4";
21
21
  /**
22
22
  * The commit this engine checkout is sitting on, or null when it can't be determined.
23
23
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eir-labs/coltrane",
3
- "version": "0.7.3",
4
- "description": "A methodology engine \u2014 a typed substrate for defining agents, composing multi-phase standards, dispatching gigs, and sealing every output to a content-addressed ledger. Ships as an MCP server.",
3
+ "version": "0.7.4",
4
+ "description": "A methodology engine a typed substrate for defining agents, composing multi-phase standards, dispatching gigs, and sealing every output to a content-addressed ledger. Ships as an MCP server.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Eir",
@@ -99,4 +99,4 @@
99
99
  "typescript": "^5.6.0",
100
100
  "vitest": "^3.0.0"
101
101
  }
102
- }
102
+ }