|
| 1 | +/** |
| 2 | + * Grant *requirements* for installers — not live grants. |
| 3 | + * |
| 4 | + * Mirrored under `package.json` → `interchange.grantRequirements` so a |
| 5 | + * host installer can read npm metadata without executing code. The typed |
| 6 | + * export is the in-repo SSOT; keep package.json in lockstep. |
| 7 | + * |
| 8 | + * Shape matches Interchange definition grant requirements |
| 9 | + * (`resource` + `action` + `source`). Control plane materializes grants |
| 10 | + * onto the workflow principal at deploy/launch. |
| 11 | + */ |
| 12 | + |
| 13 | +export type MemoryGrantSource = "tenant" | "creator" | "invoker"; |
| 14 | + |
| 15 | +/** Package surfaces that need the requirement when installed. */ |
| 16 | +export type MemoryGrantSurface = "tools" | "distiller" | "routes"; |
| 17 | + |
| 18 | +export type MemoryGrantRequirement = { |
| 19 | + readonly resource: string; |
| 20 | + readonly action: string; |
| 21 | + /** Recommended authority source; installer/deploy may override. */ |
| 22 | + readonly source: MemoryGrantSource; |
| 23 | + readonly surfaces: readonly MemoryGrantSurface[]; |
| 24 | +}; |
| 25 | + |
| 26 | +/** |
| 27 | + * Minimum capability grants for memory tools / routes / process helpers. |
| 28 | + * Document-tag access (`memory.doc:…`, `memory.space:…`) is separate and |
| 29 | + * minted per document — not package install requirements. |
| 30 | + */ |
| 31 | +export const MEMORY_GRANT_REQUIREMENTS = [ |
| 32 | + { |
| 33 | + resource: "memory", |
| 34 | + action: "add", |
| 35 | + source: "tenant", |
| 36 | + surfaces: ["tools", "distiller", "routes"], |
| 37 | + }, |
| 38 | + { |
| 39 | + resource: "memory", |
| 40 | + action: "search", |
| 41 | + source: "tenant", |
| 42 | + surfaces: ["tools", "distiller", "routes"], |
| 43 | + }, |
| 44 | +] as const satisfies readonly MemoryGrantRequirement[]; |
| 45 | + |
| 46 | +/** Compact `resource:action` form used on agent `capabilities` arrays. */ |
| 47 | +export const MEMORY_CAPABILITY_IDS = MEMORY_GRANT_REQUIREMENTS.map( |
| 48 | + (r) => `${r.resource}:${r.action}` as const, |
| 49 | +); |
0 commit comments