@tangle-network/agent-app 0.16.1 → 0.18.0

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.
@@ -0,0 +1,136 @@
1
+ import { AgentProfileFileMount } from '@tangle-network/sandbox';
2
+
3
+ /**
4
+ * Unified skill + corpus mounter for agent products.
5
+ *
6
+ * Every agent product hand-rolls the same two file-mount systems and then
7
+ * drifts on the seams between them. (1) An ALWAYS-MOUNTED markdown corpus —
8
+ * (`skills/<slug>/SKILL.md`, `doctrine` and `knowledge` markdown trees) — discovered
9
+ * by a Vite `?raw` glob in the Worker bundle and by Node `fs` under the eval
10
+ * CLI, then projected into `resources.files`. (2) A TIER-GATED installable
11
+ * registry — a hand-authored array of `SkillEntry` whose free tier mounts at
12
+ * the harness skill-discovery path and whose paid tier is installed on demand.
13
+ * Both ride the same `resources.files` channel but use different provenance
14
+ * (file-backed vs inline), different mount paths (relative corpus path vs
15
+ * `~/.claude/skills/<id>/SKILL.md`), and different selection rules. This module
16
+ * makes both DATA: a corpus loader that accepts a Vite glob-result map (or an
17
+ * fs fallback), a registry adapter that tier-gates, and a single
18
+ * `composeShellResources` that projects either onto the SDK file-mount shape.
19
+ *
20
+ * Substrate-free over storage, exact over the SDK boundary: the only inbound
21
+ * seam is the glob-result map the consumer passes in (its call site keeps the
22
+ * literal `import.meta.glob` Vite must static-analyze); the only outbound seam
23
+ * is `@tangle-network/sandbox`'s `AgentProfileFileMount[]`, the exact shape the
24
+ * agent profile's `resources.files` consumes. Node builtins are resolved lazily
25
+ * via `process.getBuiltinModule` so a static `node:*` import never reaches the
26
+ * Vite SSR bundle.
27
+ */
28
+
29
+ /** A Vite eager `?raw` glob result: glob key -> raw file body. The consumer
30
+ * produces this by calling `import.meta.glob('<lit>', { eager: true, query:
31
+ * '?raw', import: 'default' })` at its own call site — the literal must stay
32
+ * literal so Vite can static-analyze it; passing the result here keeps that
33
+ * constraint at the edge and the loader substrate-free. */
34
+ type GlobModules = Record<string, string>;
35
+ /** One markdown document discovered from the corpus. */
36
+ interface CorpusEntry {
37
+ /** Slug derived from the glob key (folder slug for `SKILL.md` layouts, or the
38
+ * normalized relative path for flat `*.md` layouts). */
39
+ id: string;
40
+ /** Glob/fs key the entry was loaded from, normalized to a stable relative
41
+ * form (leading `./` and absolute prefixes stripped). */
42
+ key: string;
43
+ /** Raw markdown body (including any frontmatter). */
44
+ content: string;
45
+ }
46
+ /** A hand-authored, tier-gated installable skill. Mirrors the per-product
47
+ * registry entry (gtm/insurance `SkillEntry`); the runtime's certified `skill`
48
+ * artifact kind is unrelated. `skillMd` is the inline body — file provenance
49
+ * does not apply to the registry. */
50
+ interface SkillEntry {
51
+ id: string;
52
+ name: string;
53
+ description: string;
54
+ author?: {
55
+ name: string;
56
+ url?: string;
57
+ };
58
+ source?: string;
59
+ category?: string;
60
+ tags?: string[];
61
+ /** Gate keyword. `composeShellResources`/`registrySkills` treat `free` as
62
+ * always-mounted; everything else is install-on-demand. */
63
+ tier: string;
64
+ skillMd: string;
65
+ }
66
+ /** Harness skill-discovery path the Claude Code / OpenCode backend reads
67
+ * natively. The registry mounts here; the corpus mounts at its relative path. */
68
+ declare function skillMountPath(id: string): string;
69
+ /** Options for {@link loadMarkdownCorpus}. */
70
+ interface LoadCorpusOptions {
71
+ /** The anchor folder name that appears in both glob keys and fs paths
72
+ * (`skills`, `doctrine`, `knowledge`). Used to normalize keys + derive ids. */
73
+ anchor: string;
74
+ /** Vite glob-result map. When present and non-empty it is authoritative and
75
+ * the fs path is skipped. Omit it (or pass an empty map) only outside Vite. */
76
+ globModules?: GlobModules;
77
+ /** Absolute or `import.meta.url`-relative base dir the fs fallback walks when
78
+ * `globModules` is empty. Required for the fs path to run; without it the fs
79
+ * fallback returns no entries (Workers never need it). */
80
+ fsBaseDir?: string;
81
+ /** Walk strategy for the fs fallback. `nested` finds `<dir>/<slug>/SKILL.md`
82
+ * one level deep; `flat` recurses for every `*.md`. Default: `flat`. */
83
+ fsLayout?: 'nested' | 'flat';
84
+ /** Drop an entry by its normalized key after load. Covers the per-product
85
+ * skip lists (corpus index/log files, scaffold templates, allow-lists). */
86
+ skip?: (normalizedKey: string) => boolean;
87
+ }
88
+ /** Outcome of {@link loadMarkdownCorpus}: the entries plus which path produced
89
+ * them, so a caller can fail loud when both are empty rather than silently
90
+ * mounting nothing. */
91
+ interface CorpusLoadResult {
92
+ source: 'vite' | 'fs' | 'empty';
93
+ entries: CorpusEntry[];
94
+ }
95
+ /**
96
+ * Load a markdown corpus, preferring a Vite glob-result map and falling back to
97
+ * a Node fs walk. Selection is by non-empty glob result — never an env flag.
98
+ * Entries are normalized, optionally skip-filtered, and sorted by id for
99
+ * determinism. The `import.meta.glob` literal stays at the CONSUMER call site
100
+ * (passed in as `globModules`); this loader never constructs a glob.
101
+ */
102
+ declare function loadMarkdownCorpus(options: LoadCorpusOptions, importMetaUrl?: string): CorpusLoadResult;
103
+ /** Project corpus entries onto SDK file mounts at a relative path under
104
+ * `<anchor>/`. Always-mounted: the corpus is the agent's baseline knowledge. */
105
+ declare function corpusSkills(corpus: CorpusEntry[], anchor: string): AgentProfileFileMount[];
106
+ /** Project the registry's free-tier (or `tier`-matched) entries onto SDK file
107
+ * mounts at the harness skill-discovery path. Tier-gating is the registry's
108
+ * only selection rule — paid skills are installed on demand, not at boot. */
109
+ declare function registrySkills(registry: SkillEntry[], tier?: string): AgentProfileFileMount[];
110
+ /** Inputs to {@link composeShellResources}. Each channel is optional so a
111
+ * product mounts only the systems it has — corpus-only, registry-only, or
112
+ * both — without conflating them. */
113
+ interface ComposeShellResourcesInput {
114
+ /** Corpus mounts (always-mounted baseline). Pass the result of
115
+ * {@link corpusSkills}, or a hand-built mount list. */
116
+ skills?: AgentProfileFileMount[];
117
+ /** Knowledge-corpus mounts (a second always-mounted corpus, e.g. a domain
118
+ * knowledge pack distinct from the skills corpus). */
119
+ knowledge?: AgentProfileFileMount[];
120
+ /** Evolvable / learned-guidance mounts (single-file corpora). */
121
+ evolvable?: AgentProfileFileMount[];
122
+ /** Registry mounts (tier-gated). Pass the result of {@link registrySkills}. */
123
+ registry?: AgentProfileFileMount[];
124
+ /** Final skip filter applied to the composed mount list by mount `path`. */
125
+ predicate?: (mount: AgentProfileFileMount) => boolean;
126
+ }
127
+ /**
128
+ * Compose every mount channel into one `resources.files`-ready array. Corpus
129
+ * channels come first (baseline), the tier-gated registry last (so a registry
130
+ * entry can override a corpus entry that mounts at the same path). The result
131
+ * is exactly `AgentProfileFileMount[]` — assign it straight into
132
+ * `profile.resources.files` with no cast.
133
+ */
134
+ declare function composeShellResources(input: ComposeShellResourcesInput): AgentProfileFileMount[];
135
+
136
+ export { type ComposeShellResourcesInput, type CorpusEntry, type CorpusLoadResult, type GlobModules, type LoadCorpusOptions, type SkillEntry, composeShellResources, corpusSkills, loadMarkdownCorpus, registrySkills, skillMountPath };
@@ -0,0 +1,131 @@
1
+ // src/skills/index.ts
2
+ function inlineResource(name, content) {
3
+ return { kind: "inline", name, content };
4
+ }
5
+ function skillMountPath(id) {
6
+ return `~/.claude/skills/${id}/SKILL.md`;
7
+ }
8
+ function normalizeKey(key, anchor) {
9
+ const marker = `${anchor}/`;
10
+ const at = key.lastIndexOf(marker);
11
+ if (at >= 0) return key.slice(at);
12
+ return key.startsWith("./") ? key.slice(2) : key;
13
+ }
14
+ function toCorpusId(normalizedKey, anchor) {
15
+ const nested = normalizedKey.match(new RegExp(`${anchor}/([^/]+)/SKILL\\.md$`));
16
+ if (nested) return nested[1];
17
+ const flat = normalizedKey.match(new RegExp(`${anchor}/(.+)\\.md$`));
18
+ if (flat) return flat[1];
19
+ return normalizedKey;
20
+ }
21
+ function nodeBuiltins() {
22
+ const getBuiltin = globalThis.process?.getBuiltinModule;
23
+ if (typeof getBuiltin !== "function") return void 0;
24
+ return {
25
+ fs: getBuiltin("node:fs"),
26
+ path: getBuiltin("node:path"),
27
+ url: getBuiltin("node:url")
28
+ };
29
+ }
30
+ function fsWalkFlat(builtins, root) {
31
+ const { fs, path } = builtins;
32
+ const out = {};
33
+ if (!fs.existsSync(root)) return out;
34
+ const walk = (dir) => {
35
+ let entries;
36
+ try {
37
+ entries = fs.readdirSync(dir, { withFileTypes: true });
38
+ } catch {
39
+ return;
40
+ }
41
+ for (const entry of entries) {
42
+ if (entry.name.startsWith(".")) continue;
43
+ const full = path.join(dir, entry.name);
44
+ if (entry.isDirectory()) walk(full);
45
+ else if (entry.isFile() && entry.name.endsWith(".md")) out[full] = fs.readFileSync(full, "utf8");
46
+ }
47
+ };
48
+ walk(root);
49
+ return out;
50
+ }
51
+ function fsWalkNested(builtins, root) {
52
+ const { fs, path } = builtins;
53
+ const out = {};
54
+ if (!fs.existsSync(root)) return out;
55
+ let entries;
56
+ try {
57
+ entries = fs.readdirSync(root, { withFileTypes: true });
58
+ } catch {
59
+ return out;
60
+ }
61
+ for (const entry of entries) {
62
+ if (!entry.isDirectory()) continue;
63
+ const skillFile = path.join(root, entry.name, "SKILL.md");
64
+ if (!fs.existsSync(skillFile)) continue;
65
+ out[skillFile] = fs.readFileSync(skillFile, "utf8");
66
+ }
67
+ return out;
68
+ }
69
+ function resolveFsBase(builtins, fsBaseDir, importMetaUrl) {
70
+ const { path, url } = builtins;
71
+ if (path.isAbsolute(fsBaseDir)) return fsBaseDir;
72
+ const here = importMetaUrl ? path.dirname(url.fileURLToPath(importMetaUrl)) : process.cwd();
73
+ return path.join(here, fsBaseDir);
74
+ }
75
+ function loadMarkdownCorpus(options, importMetaUrl) {
76
+ const { anchor, globModules, fsBaseDir, fsLayout = "flat", skip } = options;
77
+ let modules;
78
+ let source;
79
+ if (globModules && Object.keys(globModules).length > 0) {
80
+ modules = globModules;
81
+ source = "vite";
82
+ } else {
83
+ const builtins = nodeBuiltins();
84
+ if (builtins && fsBaseDir) {
85
+ const root = resolveFsBase(builtins, fsBaseDir, importMetaUrl);
86
+ modules = fsLayout === "nested" ? fsWalkNested(builtins, root) : fsWalkFlat(builtins, root);
87
+ source = Object.keys(modules).length > 0 ? "fs" : "empty";
88
+ } else {
89
+ modules = {};
90
+ source = "empty";
91
+ }
92
+ }
93
+ const entries = [];
94
+ for (const [rawKey, content] of Object.entries(modules)) {
95
+ if (typeof content !== "string") continue;
96
+ const key = normalizeKey(rawKey, anchor);
97
+ if (skip && skip(key)) continue;
98
+ entries.push({ id: toCorpusId(key, anchor), key, content });
99
+ }
100
+ entries.sort((a, b) => a.id.localeCompare(b.id));
101
+ return { source, entries };
102
+ }
103
+ function corpusSkills(corpus, anchor) {
104
+ return corpus.map(
105
+ (entry) => ({
106
+ path: `${anchor}/${entry.id}.md`,
107
+ resource: inlineResource(`${anchor}-${entry.id}`, entry.content)
108
+ })
109
+ ).sort((a, b) => a.path.localeCompare(b.path));
110
+ }
111
+ function registrySkills(registry, tier = "free") {
112
+ return registry.filter((s) => s.tier === tier).map(
113
+ (s) => ({
114
+ path: skillMountPath(s.id),
115
+ resource: inlineResource(s.id, s.skillMd)
116
+ })
117
+ ).sort((a, b) => a.path.localeCompare(b.path));
118
+ }
119
+ function composeShellResources(input) {
120
+ const { skills = [], knowledge = [], evolvable = [], registry = [], predicate } = input;
121
+ const composed = [...skills, ...knowledge, ...evolvable, ...registry];
122
+ return predicate ? composed.filter(predicate) : composed;
123
+ }
124
+ export {
125
+ composeShellResources,
126
+ corpusSkills,
127
+ loadMarkdownCorpus,
128
+ registrySkills,
129
+ skillMountPath
130
+ };
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/skills/index.ts"],"sourcesContent":["/**\n * Unified skill + corpus mounter for agent products.\n *\n * Every agent product hand-rolls the same two file-mount systems and then\n * drifts on the seams between them. (1) An ALWAYS-MOUNTED markdown corpus —\n * (`skills/<slug>/SKILL.md`, `doctrine` and `knowledge` markdown trees) — discovered\n * by a Vite `?raw` glob in the Worker bundle and by Node `fs` under the eval\n * CLI, then projected into `resources.files`. (2) A TIER-GATED installable\n * registry — a hand-authored array of `SkillEntry` whose free tier mounts at\n * the harness skill-discovery path and whose paid tier is installed on demand.\n * Both ride the same `resources.files` channel but use different provenance\n * (file-backed vs inline), different mount paths (relative corpus path vs\n * `~/.claude/skills/<id>/SKILL.md`), and different selection rules. This module\n * makes both DATA: a corpus loader that accepts a Vite glob-result map (or an\n * fs fallback), a registry adapter that tier-gates, and a single\n * `composeShellResources` that projects either onto the SDK file-mount shape.\n *\n * Substrate-free over storage, exact over the SDK boundary: the only inbound\n * seam is the glob-result map the consumer passes in (its call site keeps the\n * literal `import.meta.glob` Vite must static-analyze); the only outbound seam\n * is `@tangle-network/sandbox`'s `AgentProfileFileMount[]`, the exact shape the\n * agent profile's `resources.files` consumes. Node builtins are resolved lazily\n * via `process.getBuiltinModule` so a static `node:*` import never reaches the\n * Vite SSR bundle.\n */\n\nimport type { AgentProfileFileMount, AgentProfileResourceRef } from '@tangle-network/sandbox'\n\n/** Construct the inline arm of the SDK's `AgentProfileResourceRef`. Inlined here\n * so this leaf subpath stays type-only over `@tangle-network/sandbox` — it\n * carries no runtime dependency on the SDK, just its file-mount type contract. */\nfunction inlineResource(name: string, content: string): AgentProfileResourceRef {\n return { kind: 'inline', name, content }\n}\n\n/** A Vite eager `?raw` glob result: glob key -> raw file body. The consumer\n * produces this by calling `import.meta.glob('<lit>', { eager: true, query:\n * '?raw', import: 'default' })` at its own call site — the literal must stay\n * literal so Vite can static-analyze it; passing the result here keeps that\n * constraint at the edge and the loader substrate-free. */\nexport type GlobModules = Record<string, string>\n\n/** One markdown document discovered from the corpus. */\nexport interface CorpusEntry {\n /** Slug derived from the glob key (folder slug for `SKILL.md` layouts, or the\n * normalized relative path for flat `*.md` layouts). */\n id: string\n /** Glob/fs key the entry was loaded from, normalized to a stable relative\n * form (leading `./` and absolute prefixes stripped). */\n key: string\n /** Raw markdown body (including any frontmatter). */\n content: string\n}\n\n/** A hand-authored, tier-gated installable skill. Mirrors the per-product\n * registry entry (gtm/insurance `SkillEntry`); the runtime's certified `skill`\n * artifact kind is unrelated. `skillMd` is the inline body — file provenance\n * does not apply to the registry. */\nexport interface SkillEntry {\n id: string\n name: string\n description: string\n author?: { name: string; url?: string }\n source?: string\n category?: string\n tags?: string[]\n /** Gate keyword. `composeShellResources`/`registrySkills` treat `free` as\n * always-mounted; everything else is install-on-demand. */\n tier: string\n skillMd: string\n}\n\n/** Harness skill-discovery path the Claude Code / OpenCode backend reads\n * natively. The registry mounts here; the corpus mounts at its relative path. */\nexport function skillMountPath(id: string): string {\n return `~/.claude/skills/${id}/SKILL.md`\n}\n\n/** Strip a glob/fs key down to a stable relative form: drop a leading `./`,\n * and for an absolute fs path keep only the tail from the last anchor segment\n * the pattern implies. We normalize on the trailing `<dir>/.../*.md` so the\n * Vite key (`./skills/x/SKILL.md`) and the fs key (`/abs/.../skills/x/SKILL.md`)\n * collapse to the same value. */\nfunction normalizeKey(key: string, anchor: string): string {\n const marker = `${anchor}/`\n const at = key.lastIndexOf(marker)\n if (at >= 0) return key.slice(at)\n return key.startsWith('./') ? key.slice(2) : key\n}\n\n/** Folder-slug for a `<anchor>/<slug>/SKILL.md` layout; falls back to the\n * normalized key (sans `<anchor>/` prefix, sans `.md`) for flat layouts. */\nfunction toCorpusId(normalizedKey: string, anchor: string): string {\n const nested = normalizedKey.match(new RegExp(`${anchor}/([^/]+)/SKILL\\\\.md$`))\n if (nested) return nested[1]!\n const flat = normalizedKey.match(new RegExp(`${anchor}/(.+)\\\\.md$`))\n if (flat) return flat[1]!\n return normalizedKey\n}\n\n/** Resolve Node builtins lazily. `process.getBuiltinModule` (Node 22+) is\n * absent in workerd, so this returns undefined there and the fs path is never\n * taken — Workers always reach the loader through the Vite glob map. A static\n * `import 'node:fs'` would break Vite SSR bundling in the consumer apps, so it\n * is deliberately avoided. */\nfunction nodeBuiltins():\n | { fs: typeof import('node:fs'); path: typeof import('node:path'); url: typeof import('node:url') }\n | undefined {\n const getBuiltin = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } })\n .process?.getBuiltinModule\n if (typeof getBuiltin !== 'function') return undefined\n return {\n fs: getBuiltin('node:fs') as typeof import('node:fs'),\n path: getBuiltin('node:path') as typeof import('node:path'),\n url: getBuiltin('node:url') as typeof import('node:url'),\n }\n}\n\n/** Options for {@link loadMarkdownCorpus}. */\nexport interface LoadCorpusOptions {\n /** The anchor folder name that appears in both glob keys and fs paths\n * (`skills`, `doctrine`, `knowledge`). Used to normalize keys + derive ids. */\n anchor: string\n /** Vite glob-result map. When present and non-empty it is authoritative and\n * the fs path is skipped. Omit it (or pass an empty map) only outside Vite. */\n globModules?: GlobModules\n /** Absolute or `import.meta.url`-relative base dir the fs fallback walks when\n * `globModules` is empty. Required for the fs path to run; without it the fs\n * fallback returns no entries (Workers never need it). */\n fsBaseDir?: string\n /** Walk strategy for the fs fallback. `nested` finds `<dir>/<slug>/SKILL.md`\n * one level deep; `flat` recurses for every `*.md`. Default: `flat`. */\n fsLayout?: 'nested' | 'flat'\n /** Drop an entry by its normalized key after load. Covers the per-product\n * skip lists (corpus index/log files, scaffold templates, allow-lists). */\n skip?: (normalizedKey: string) => boolean\n}\n\n/** Outcome of {@link loadMarkdownCorpus}: the entries plus which path produced\n * them, so a caller can fail loud when both are empty rather than silently\n * mounting nothing. */\nexport interface CorpusLoadResult {\n source: 'vite' | 'fs' | 'empty'\n entries: CorpusEntry[]\n}\n\nfunction fsWalkFlat(\n builtins: NonNullable<ReturnType<typeof nodeBuiltins>>,\n root: string,\n): GlobModules {\n const { fs, path } = builtins\n const out: GlobModules = {}\n if (!fs.existsSync(root)) return out\n const walk = (dir: string) => {\n let entries: import('node:fs').Dirent[]\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n if (entry.name.startsWith('.')) continue\n const full = path.join(dir, entry.name)\n if (entry.isDirectory()) walk(full)\n else if (entry.isFile() && entry.name.endsWith('.md')) out[full] = fs.readFileSync(full, 'utf8')\n }\n }\n walk(root)\n return out\n}\n\nfunction fsWalkNested(\n builtins: NonNullable<ReturnType<typeof nodeBuiltins>>,\n root: string,\n): GlobModules {\n const { fs, path } = builtins\n const out: GlobModules = {}\n if (!fs.existsSync(root)) return out\n let entries: import('node:fs').Dirent[]\n try {\n entries = fs.readdirSync(root, { withFileTypes: true })\n } catch {\n return out\n }\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n const skillFile = path.join(root, entry.name, 'SKILL.md')\n if (!fs.existsSync(skillFile)) continue\n out[skillFile] = fs.readFileSync(skillFile, 'utf8')\n }\n return out\n}\n\n/** Resolve `fsBaseDir` against `import.meta.url` when relative-looking, so a\n * consumer can pass a bare folder name (`'skills'`) and have it land beside\n * the calling module. Absolute paths pass through. */\nfunction resolveFsBase(\n builtins: NonNullable<ReturnType<typeof nodeBuiltins>>,\n fsBaseDir: string,\n importMetaUrl?: string,\n): string {\n const { path, url } = builtins\n if (path.isAbsolute(fsBaseDir)) return fsBaseDir\n const here = importMetaUrl\n ? path.dirname(url.fileURLToPath(importMetaUrl))\n : process.cwd()\n return path.join(here, fsBaseDir)\n}\n\n/**\n * Load a markdown corpus, preferring a Vite glob-result map and falling back to\n * a Node fs walk. Selection is by non-empty glob result — never an env flag.\n * Entries are normalized, optionally skip-filtered, and sorted by id for\n * determinism. The `import.meta.glob` literal stays at the CONSUMER call site\n * (passed in as `globModules`); this loader never constructs a glob.\n */\nexport function loadMarkdownCorpus(\n options: LoadCorpusOptions,\n importMetaUrl?: string,\n): CorpusLoadResult {\n const { anchor, globModules, fsBaseDir, fsLayout = 'flat', skip } = options\n\n let modules: GlobModules\n let source: CorpusLoadResult['source']\n if (globModules && Object.keys(globModules).length > 0) {\n modules = globModules\n source = 'vite'\n } else {\n const builtins = nodeBuiltins()\n if (builtins && fsBaseDir) {\n const root = resolveFsBase(builtins, fsBaseDir, importMetaUrl)\n modules = fsLayout === 'nested' ? fsWalkNested(builtins, root) : fsWalkFlat(builtins, root)\n source = Object.keys(modules).length > 0 ? 'fs' : 'empty'\n } else {\n modules = {}\n source = 'empty'\n }\n }\n\n const entries: CorpusEntry[] = []\n for (const [rawKey, content] of Object.entries(modules)) {\n if (typeof content !== 'string') continue\n const key = normalizeKey(rawKey, anchor)\n if (skip && skip(key)) continue\n entries.push({ id: toCorpusId(key, anchor), key, content })\n }\n entries.sort((a, b) => a.id.localeCompare(b.id))\n return { source, entries }\n}\n\n/** Project corpus entries onto SDK file mounts at a relative path under\n * `<anchor>/`. Always-mounted: the corpus is the agent's baseline knowledge. */\nexport function corpusSkills(corpus: CorpusEntry[], anchor: string): AgentProfileFileMount[] {\n return corpus\n .map(\n (entry) =>\n ({\n path: `${anchor}/${entry.id}.md`,\n resource: inlineResource(`${anchor}-${entry.id}`, entry.content),\n }) satisfies AgentProfileFileMount,\n )\n .sort((a, b) => a.path.localeCompare(b.path))\n}\n\n/** Project the registry's free-tier (or `tier`-matched) entries onto SDK file\n * mounts at the harness skill-discovery path. Tier-gating is the registry's\n * only selection rule — paid skills are installed on demand, not at boot. */\nexport function registrySkills(\n registry: SkillEntry[],\n tier: string = 'free',\n): AgentProfileFileMount[] {\n return registry\n .filter((s) => s.tier === tier)\n .map(\n (s) =>\n ({\n path: skillMountPath(s.id),\n resource: inlineResource(s.id, s.skillMd),\n }) satisfies AgentProfileFileMount,\n )\n .sort((a, b) => a.path.localeCompare(b.path))\n}\n\n/** Inputs to {@link composeShellResources}. Each channel is optional so a\n * product mounts only the systems it has — corpus-only, registry-only, or\n * both — without conflating them. */\nexport interface ComposeShellResourcesInput {\n /** Corpus mounts (always-mounted baseline). Pass the result of\n * {@link corpusSkills}, or a hand-built mount list. */\n skills?: AgentProfileFileMount[]\n /** Knowledge-corpus mounts (a second always-mounted corpus, e.g. a domain\n * knowledge pack distinct from the skills corpus). */\n knowledge?: AgentProfileFileMount[]\n /** Evolvable / learned-guidance mounts (single-file corpora). */\n evolvable?: AgentProfileFileMount[]\n /** Registry mounts (tier-gated). Pass the result of {@link registrySkills}. */\n registry?: AgentProfileFileMount[]\n /** Final skip filter applied to the composed mount list by mount `path`. */\n predicate?: (mount: AgentProfileFileMount) => boolean\n}\n\n/**\n * Compose every mount channel into one `resources.files`-ready array. Corpus\n * channels come first (baseline), the tier-gated registry last (so a registry\n * entry can override a corpus entry that mounts at the same path). The result\n * is exactly `AgentProfileFileMount[]` — assign it straight into\n * `profile.resources.files` with no cast.\n */\nexport function composeShellResources(input: ComposeShellResourcesInput): AgentProfileFileMount[] {\n const { skills = [], knowledge = [], evolvable = [], registry = [], predicate } = input\n const composed = [...skills, ...knowledge, ...evolvable, ...registry]\n return predicate ? composed.filter(predicate) : composed\n}\n"],"mappings":";AA+BA,SAAS,eAAe,MAAc,SAA0C;AAC9E,SAAO,EAAE,MAAM,UAAU,MAAM,QAAQ;AACzC;AAyCO,SAAS,eAAe,IAAoB;AACjD,SAAO,oBAAoB,EAAE;AAC/B;AAOA,SAAS,aAAa,KAAa,QAAwB;AACzD,QAAM,SAAS,GAAG,MAAM;AACxB,QAAM,KAAK,IAAI,YAAY,MAAM;AACjC,MAAI,MAAM,EAAG,QAAO,IAAI,MAAM,EAAE;AAChC,SAAO,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAC/C;AAIA,SAAS,WAAW,eAAuB,QAAwB;AACjE,QAAM,SAAS,cAAc,MAAM,IAAI,OAAO,GAAG,MAAM,sBAAsB,CAAC;AAC9E,MAAI,OAAQ,QAAO,OAAO,CAAC;AAC3B,QAAM,OAAO,cAAc,MAAM,IAAI,OAAO,GAAG,MAAM,aAAa,CAAC;AACnE,MAAI,KAAM,QAAO,KAAK,CAAC;AACvB,SAAO;AACT;AAOA,SAAS,eAEK;AACZ,QAAM,aAAc,WACjB,SAAS;AACZ,MAAI,OAAO,eAAe,WAAY,QAAO;AAC7C,SAAO;AAAA,IACL,IAAI,WAAW,SAAS;AAAA,IACxB,MAAM,WAAW,WAAW;AAAA,IAC5B,KAAK,WAAW,UAAU;AAAA,EAC5B;AACF;AA8BA,SAAS,WACP,UACA,MACa;AACb,QAAM,EAAE,IAAI,KAAK,IAAI;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ACzB,SAAO,SACJ,OAAO,CAAC,MAAM,EAAE,SAAS,IAAI,EAC7B;AAAA,IACC,CAAC,OACE;AAAA,MACC,MAAM,eAAe,EAAE,EAAE;AAAA,MACzB,UAAU,eAAe,EAAE,IAAI,EAAE,OAAO;AAAA,IAC1C;AAAA,EACJ,EACC,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAChD;AA2BO,SAAS,sBAAsB,OAA4D;AAChG,QAAM,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,GAAG,YAAY,CAAC,GAAG,WAAW,CAAC,GAAG,UAAU,IAAI;AAClF,QAAM,WAAW,CAAC,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ;AACpE,SAAO,YAAY,SAAS,OAAO,SAAS,IAAI;AAClD;","names":[]}
@@ -197,6 +197,42 @@ interface AgentActivityPanelProps {
197
197
  */
198
198
  declare function AgentActivityPanel({ fetchActivity, renderMissionRef, title, emptyLabel }: AgentActivityPanelProps): react.JSX.Element;
199
199
 
200
+ /**
201
+ * `SeatPaywall` — the shared "unlock this product" screen every agent app
202
+ * shows when a user has no active seat and has spent past the free tier. One
203
+ * component, adopted by all five products (gtm / creative / tax / legal /
204
+ * insurance) in ~2 lines.
205
+ *
206
+ * Copy contract (design §6.8): the included monthly AI usage is framed as a
207
+ * BENEFIT the buyer receives — never the ratio, never the word "margin", never
208
+ * "we debit 50%". Surface the allowance, hide the economics.
209
+ *
210
+ * Styling contract matches the rest of `web-react`: Tailwind classes over the
211
+ * shared design tokens (`bg-card`, `border-border`, `text-muted-foreground`,
212
+ * `bg-primary`, …); glyphs are inline SVGs; no icon or UI library.
213
+ */
214
+
215
+ interface SeatPaywallProps {
216
+ /** Human product name shown in the headline, e.g. "Creative". */
217
+ product: string;
218
+ /** Fired when the user clicks the unlock CTA — route them to checkout. */
219
+ onCheckout: () => void;
220
+ /** Monthly seat price in whole dollars. Default 100. */
221
+ priceUsd?: number;
222
+ /** Included monthly AI usage in whole dollars. Default 50. */
223
+ includedUsageUsd?: number;
224
+ /** Optional one-line value prop under the headline. */
225
+ tagline?: string;
226
+ /** CTA label. Default "Unlock {product}". */
227
+ ctaLabel?: string;
228
+ }
229
+ /**
230
+ * Centered card paywall. The price line reads
231
+ * "$100/mo · includes $50/mo of AI usage" so the included allowance anchors the
232
+ * value without ever exposing the ratio.
233
+ */
234
+ declare function SeatPaywall({ product, onCheckout, priceUsd, includedUsageUsd, tagline, ctaLabel, }: SeatPaywallProps): ReactNode;
235
+
200
236
  interface ChatMessageMetrics {
201
237
  modelUsed?: string;
202
238
  promptTokens?: number;
@@ -317,4 +353,4 @@ type ToolDetailRenderers = Record<string, (call: ChatToolCallInfo, message: Chat
317
353
  */
318
354
  declare function ChatMessages({ messages, models, renderMarkdown, renderExtras, userLabel, agentLabel, loading, approval, onToolCallClick, toolRenderers, }: ChatMessagesProps): react.JSX.Element;
319
355
 
320
- export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, type ChatMessageMetrics, ChatMessages, type ChatMessagesProps, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ConsumeChatStreamResult, EffortPicker, type EffortPickerProps, FlowWaterfall, type FlowWaterfallProps, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, type ProposalApprovalHandlers, ProviderLogo, type ProviderLogoProps, RunDrillIn, type RunDrillInProps, type SmoothRevealOptions, type StreamChatOptions, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type WaterfallRow, activityTone, consumeChatStream, dispatchChatStreamLine, formatActivityCost, formatActivityDuration, formatModelCost, formatTokensPerSecond, mergeActivityPages, nextRevealCount, pendingApprovalOf, streamChatTurn, useSmoothText, waterfallLayout };
356
+ export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, type ChatMessageMetrics, ChatMessages, type ChatMessagesProps, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ConsumeChatStreamResult, EffortPicker, type EffortPickerProps, FlowWaterfall, type FlowWaterfallProps, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, type ProposalApprovalHandlers, ProviderLogo, type ProviderLogoProps, RunDrillIn, type RunDrillInProps, SeatPaywall, type SeatPaywallProps, type SmoothRevealOptions, type StreamChatOptions, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type WaterfallRow, activityTone, consumeChatStream, dispatchChatStreamLine, formatActivityCost, formatActivityDuration, formatModelCost, formatTokensPerSecond, mergeActivityPages, nextRevealCount, pendingApprovalOf, streamChatTurn, useSmoothText, waterfallLayout };