@happyvertical/smrt-dev-mcp 0.61.5 → 0.62.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.
- package/AGENTS.md +2 -0
- package/README.md +12 -1
- package/agents/agent-skills.md +9 -0
- package/dist/agent-skills.d.ts.map +1 -1
- package/dist/agent-skills.js +7 -0
- package/dist/agent-skills.js.map +1 -1
- package/dist/dev-plane.js +2 -2
- package/dist/{http-Brjn_G5R.js → http-Cm8eDnF_.js} +2 -2
- package/dist/{http-Brjn_G5R.js.map → http-Cm8eDnF_.js.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/knowledge/intents/index.md +1 -1
- package/dist/knowledge/intents/prompts-and-ai-operations.md +1 -1
- package/dist/{knowledge-tD6NTmy1.js → knowledge-CSUS5hbw.js} +2 -2
- package/dist/{knowledge-tD6NTmy1.js.map → knowledge-CSUS5hbw.js.map} +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/smrt-knowledge.okf.md +2 -2
- package/dist/{tool-catalog-CEB611ri.js → tool-catalog-CEJeiUQd.js} +9 -2
- package/dist/tool-catalog-CEJeiUQd.js.map +1 -0
- package/dist/tool-catalog.d.ts +2 -0
- package/dist/tool-catalog.d.ts.map +1 -1
- package/package.json +5 -5
- package/plugin.json +1 -1
- package/skills/smrt-ai-work/SKILL.md +82 -0
- package/skills/smrt-ai-work/evals.json +18 -0
- package/skills/smrt-catalog/SKILL.md +6 -0
- package/dist/tool-catalog-CEB611ri.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -139,6 +139,7 @@ Skill-aware harnesses can parse the frontmatter; other harnesses can ignore it.
|
|
|
139
139
|
- `skills/smrt-catalog/SKILL.md` — catalog router skill (#4708), installed into consumers by `smrt docs:agents`.
|
|
140
140
|
- `skills/smrt-contribute/SKILL.md` — contributor skill (#4709) for forks of this repository; an identical copy is
|
|
141
141
|
checked in at the root `.agents/skills/smrt-contribute/SKILL.md` and a test fails on drift.
|
|
142
|
+
- `skills/smrt-ai-work/SKILL.md` — AI work skill (#5005): prompt, tracked call, workflow definition, handler job contract, and the runs vocabulary.
|
|
142
143
|
|
|
143
144
|
Trigger evals, the registry and install contract, and the drift rule: [agents/agent-skills.md](agents/agent-skills.md).
|
|
144
145
|
|
|
@@ -203,6 +204,7 @@ when `dist` is missing or older, so rebuild `dist` after server edits. Guarded b
|
|
|
203
204
|
- `skills/smrt-code-review/SKILL.md` — downstream SMRT review procedure
|
|
204
205
|
- `skills/smrt-contribute/SKILL.md` — contributor skill (copy at repo-root `.agents/skills/smrt-contribute/`)
|
|
205
206
|
- `skills/smrt-catalog/SKILL.md` — catalog router skill; `skills/smrt-catalog/evals.json` — its trigger eval set
|
|
207
|
+
- `skills/smrt-ai-work/SKILL.md` — AI work skill; `get-agent-skill` serves every name in `AGENT_SKILL_NAMES` (`src/tool-catalog.ts`)
|
|
206
208
|
- `src/tools/generate-smrt-class.ts` — class generation logic and package-ready templates
|
|
207
209
|
- `src/tools/harden-smrt-class.ts` — hardening suggestion; file write only, no database or SQL (#4936)
|
|
208
210
|
- `src/tools/introspect-project.ts` — manifest-first project scanning, falling back to `@happyvertical/smrt-scanner`
|
package/README.md
CHANGED
|
@@ -284,6 +284,17 @@ for deterministic context, inspect the actual diff, and produce a findings-first
|
|
|
284
284
|
review. Native MCP prompt/resource clients can also load the `smrt-code-review`
|
|
285
285
|
prompt or `smrt-dev-mcp://agent-skills/smrt-code-review` resource.
|
|
286
286
|
|
|
287
|
+
### AI work (`smrt-ai-work`)
|
|
288
|
+
|
|
289
|
+
Ask for `get-agent-skill` `name: 'smrt-ai-work'` before adding or explaining AI
|
|
290
|
+
work. It tells an agent to produce a registered prompt (`definePrompt`), a
|
|
291
|
+
tracked call carrying its prompt key (`createTrackedAiClient` with
|
|
292
|
+
`trackedPromptCall`), and for multi-step work a `smrt-workflows` definition
|
|
293
|
+
with a budget; it states the background handler job contract and explains
|
|
294
|
+
runs, events, trajectories, evaluations, tiers, latency, effort, budgets and
|
|
295
|
+
fusions, pointing at the [AI runs](https://happyvertical.github.io/smrt/ai-runs)
|
|
296
|
+
page and the notes the installed packages ship.
|
|
297
|
+
|
|
287
298
|
## Available Tools
|
|
288
299
|
|
|
289
300
|
The server exposes these MCP tools:
|
|
@@ -486,7 +497,7 @@ Return a bundled agent skill as Markdown, with optional referenced files.
|
|
|
486
497
|
|
|
487
498
|
| Parameter | Type | Required | Description |
|
|
488
499
|
|-----------|------|----------|-------------|
|
|
489
|
-
| `name` | `'smrt-code-review'` | Yes | Skill name |
|
|
500
|
+
| `name` | `'smrt-code-review' \| 'smrt-catalog' \| 'smrt-contribute' \| 'smrt-ai-work'` | Yes | Skill name |
|
|
490
501
|
| `includeReferences` | `boolean` | No | Include referenced files (default: true) |
|
|
491
502
|
|
|
492
503
|
### `migration-status`
|
package/agents/agent-skills.md
CHANGED
|
@@ -14,3 +14,12 @@
|
|
|
14
14
|
The repository root checks in an identical copy at `.agents/skills/smrt-contribute/SKILL.md` so a harness
|
|
15
15
|
opening a checkout finds it without the MCP server; `src/agent-skills.test.ts` fails when they drift, so edit
|
|
16
16
|
both together. Trigger evals: `skills/smrt-contribute/evals.json`.
|
|
17
|
+
- `skills/smrt-ai-work/SKILL.md` — AI work skill (#5005). Asked to add AI work it produces a registered prompt
|
|
18
|
+
(`definePrompt`), a tracked call carrying its prompt key (`createTrackedAiClient` + `trackedPromptCall`) and, for
|
|
19
|
+
multi-step work, a `smrt-workflows` definition; it states the handler job contract and explains runs, events,
|
|
20
|
+
trajectories, evaluations, tiers, latency, effort, budgets and fusions from the AI runs page and the package
|
|
21
|
+
notes. `smrt-catalog` routes AI requests to it. It is served by `get-agent-skill` and shipped in the plugin; `docs:agents`
|
|
22
|
+
does not install it (only catalog and contribute). When the vocabulary in `ai-runs.md` changes, edit the skill. It cites
|
|
23
|
+
only what a consuming project reaches: docs site pages (`https://happyvertical.github.io/smrt/<page>`), files under
|
|
24
|
+
`node_modules/@happyvertical/<package>/` that the package's `files` ships, and `.agents/smrt-knowledge/`; the test
|
|
25
|
+
checks each one, and refuses a monorepo path. Trigger evals: `skills/smrt-ai-work/evals.json`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-skills.d.ts","sourceRoot":"","sources":["../src/agent-skills.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;
|
|
1
|
+
{"version":3,"file":"agent-skills.d.ts","sourceRoot":"","sources":["../src/agent-skills.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,KAAK,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAyCD,mEAAmE;AACnE,wBAAgB,4BAA4B,IAAI,MAAM,CAKrD;AAED,wBAAgB,eAAe,IAAI,iBAAiB,EAAE,CAErD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,GAAG,gBAAgB,CAoBnB"}
|
package/dist/agent-skills.js
CHANGED
|
@@ -23,6 +23,13 @@ var AGENT_SKILLS = [
|
|
|
23
23
|
path: "skills/smrt-contribute/SKILL.md",
|
|
24
24
|
skillFile: "skills/smrt-contribute/SKILL.md",
|
|
25
25
|
references: []
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "smrt-ai-work",
|
|
29
|
+
description: "AI work skill: add AI work as a registered prompt, a tracked call and, for multi-step work, a smrt-workflows definition; explain runs, events, evaluations, tiers, latency, effort, budgets and fusions.",
|
|
30
|
+
path: "skills/smrt-ai-work/SKILL.md",
|
|
31
|
+
skillFile: "skills/smrt-ai-work/SKILL.md",
|
|
32
|
+
references: []
|
|
26
33
|
}
|
|
27
34
|
];
|
|
28
35
|
/** Version of the smrt-dev-mcp package that ships these skills. */
|
package/dist/agent-skills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-skills.js","names":[],"sources":["../src/agent-skills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport interface AgentSkillSummary {\n name: string;\n description: string;\n path: string;\n references: string[];\n}\n\nexport interface AgentSkillBundle extends AgentSkillSummary {\n skillMarkdown: string;\n referenceFiles: Array<{\n path: string;\n content: string;\n }>;\n}\n\ninterface AgentSkillDefinition extends AgentSkillSummary {\n skillFile: string;\n}\n\nconst AGENT_SKILLS: AgentSkillDefinition[] = [\n {\n name: 'smrt-code-review',\n description:\n 'Harness-agnostic downstream SMRT code review workflow using smrt-dev-mcp deterministic context and prompt bundles.',\n path: 'skills/smrt-code-review/SKILL.md',\n skillFile: 'skills/smrt-code-review/SKILL.md',\n references: ['skills/smrt-code-review/references/review-output.md'],\n },\n {\n name: 'smrt-catalog',\n description:\n 'Router skill: before writing infrastructure, utility, or integration code in a project that depends on smrt packages, consult the smrt knowledge catalog and reuse the installed package.',\n path: 'skills/smrt-catalog/SKILL.md',\n skillFile: 'skills/smrt-catalog/SKILL.md',\n references: [],\n },\n {\n name: 'smrt-contribute',\n description:\n 'Contributor skill: the fork pull-request procedure for happyvertical/smrt (CONTRIBUTING.md as steps) for agents working in a fork or clone that is not a maintainer session.',\n path: 'skills/smrt-contribute/SKILL.md',\n skillFile: 'skills/smrt-contribute/SKILL.md',\n references: [],\n },\n];\n\n/** Version of the smrt-dev-mcp package that ships these skills. */\nexport function getAgentSkillsPackageVersion(): string {\n const manifest = JSON.parse(readPackageFile('package.json')) as {\n version?: string;\n };\n return manifest.version ?? '0.0.0';\n}\n\nexport function listAgentSkills(): AgentSkillSummary[] {\n return AGENT_SKILLS.map(({ skillFile: _skillFile, ...skill }) => skill);\n}\n\nexport function getAgentSkill(options: {\n name: string;\n includeReferences?: boolean;\n}): AgentSkillBundle {\n const skill = AGENT_SKILLS.find((item) => item.name === options.name);\n if (!skill) {\n throw new Error(`Unknown agent skill: ${options.name}`);\n }\n\n return {\n name: skill.name,\n description: skill.description,\n path: skill.path,\n references: skill.references,\n skillMarkdown: readPackageFile(skill.skillFile),\n referenceFiles:\n options.includeReferences === false\n ? []\n : skill.references.map((path) => ({\n path,\n content: readPackageFile(path),\n })),\n };\n}\n\nfunction readPackageFile(relativePath: string): string {\n const packageRoot = resolvePackageRoot();\n return readFileSync(join(packageRoot, relativePath), 'utf8');\n}\n\nfunction resolvePackageRoot(): string {\n // Works in both source tests (`src/agent-skills.ts`) and built packages\n // (`dist/agent-skills.js`); guard it so packaging layout drift fails clearly.\n const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));\n if (!existsSync(join(packageRoot, 'package.json'))) {\n throw new Error(\n `Unable to resolve smrt-dev-mcp package root from ${import.meta.url}`,\n );\n }\n return packageRoot;\n}\n"],"mappings":";;;;AAuBA,IAAM,eAAuC;CAC3C;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC,qDAAqD;CACpE;CACA;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC;CACf;CACA;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC;CACf;AACF;;AAGA,SAAgB,+BAAuC;CAIrD,OAHiB,KAAK,MAAM,gBAAgB,cAAc,CAGnD,CAAA,CAAS,WAAW;AAC7B;AAEA,SAAgB,kBAAuC;CACrD,OAAO,aAAa,KAAK,EAAE,WAAW,YAAY,GAAG,YAAY,KAAK;AACxE;AAEA,SAAgB,cAAc,SAGT;CACnB,MAAM,QAAQ,aAAa,MAAM,SAAS,KAAK,SAAS,QAAQ,IAAI;CACpE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,wBAAwB,QAAQ,MAAM;CAGxD,OAAO;EACL,MAAM,MAAM;EACZ,aAAa,MAAM;EACnB,MAAM,MAAM;EACZ,YAAY,MAAM;EAClB,eAAe,gBAAgB,MAAM,SAAS;EAC9C,gBACE,QAAQ,sBAAsB,QAC1B,CAAC,IACD,MAAM,WAAW,KAAK,UAAU;GAC9B;GACA,SAAS,gBAAgB,IAAI;EAC/B,EAAE;CACV;AACF;AAEA,SAAS,gBAAgB,cAA8B;CAErD,OAAO,aAAa,KADA,mBACK,GAAa,YAAY,GAAG,MAAM;AAC7D;AAEA,SAAS,qBAA6B;CAGpC,MAAM,cAAc,QAAQ,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC,CAAC;CACnE,IAAI,CAAC,WAAW,KAAK,aAAa,cAAc,CAAC,GAC/C,MAAM,IAAI,MACR,oDAAoD,OAAO,KAAK,KAClE;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"agent-skills.js","names":[],"sources":["../src/agent-skills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport interface AgentSkillSummary {\n name: string;\n description: string;\n path: string;\n references: string[];\n}\n\nexport interface AgentSkillBundle extends AgentSkillSummary {\n skillMarkdown: string;\n referenceFiles: Array<{\n path: string;\n content: string;\n }>;\n}\n\ninterface AgentSkillDefinition extends AgentSkillSummary {\n skillFile: string;\n}\n\nconst AGENT_SKILLS: AgentSkillDefinition[] = [\n {\n name: 'smrt-code-review',\n description:\n 'Harness-agnostic downstream SMRT code review workflow using smrt-dev-mcp deterministic context and prompt bundles.',\n path: 'skills/smrt-code-review/SKILL.md',\n skillFile: 'skills/smrt-code-review/SKILL.md',\n references: ['skills/smrt-code-review/references/review-output.md'],\n },\n {\n name: 'smrt-catalog',\n description:\n 'Router skill: before writing infrastructure, utility, or integration code in a project that depends on smrt packages, consult the smrt knowledge catalog and reuse the installed package.',\n path: 'skills/smrt-catalog/SKILL.md',\n skillFile: 'skills/smrt-catalog/SKILL.md',\n references: [],\n },\n {\n name: 'smrt-contribute',\n description:\n 'Contributor skill: the fork pull-request procedure for happyvertical/smrt (CONTRIBUTING.md as steps) for agents working in a fork or clone that is not a maintainer session.',\n path: 'skills/smrt-contribute/SKILL.md',\n skillFile: 'skills/smrt-contribute/SKILL.md',\n references: [],\n },\n {\n name: 'smrt-ai-work',\n description:\n 'AI work skill: add AI work as a registered prompt, a tracked call and, for multi-step work, a smrt-workflows definition; explain runs, events, evaluations, tiers, latency, effort, budgets and fusions.',\n path: 'skills/smrt-ai-work/SKILL.md',\n skillFile: 'skills/smrt-ai-work/SKILL.md',\n references: [],\n },\n];\n\n/** Version of the smrt-dev-mcp package that ships these skills. */\nexport function getAgentSkillsPackageVersion(): string {\n const manifest = JSON.parse(readPackageFile('package.json')) as {\n version?: string;\n };\n return manifest.version ?? '0.0.0';\n}\n\nexport function listAgentSkills(): AgentSkillSummary[] {\n return AGENT_SKILLS.map(({ skillFile: _skillFile, ...skill }) => skill);\n}\n\nexport function getAgentSkill(options: {\n name: string;\n includeReferences?: boolean;\n}): AgentSkillBundle {\n const skill = AGENT_SKILLS.find((item) => item.name === options.name);\n if (!skill) {\n throw new Error(`Unknown agent skill: ${options.name}`);\n }\n\n return {\n name: skill.name,\n description: skill.description,\n path: skill.path,\n references: skill.references,\n skillMarkdown: readPackageFile(skill.skillFile),\n referenceFiles:\n options.includeReferences === false\n ? []\n : skill.references.map((path) => ({\n path,\n content: readPackageFile(path),\n })),\n };\n}\n\nfunction readPackageFile(relativePath: string): string {\n const packageRoot = resolvePackageRoot();\n return readFileSync(join(packageRoot, relativePath), 'utf8');\n}\n\nfunction resolvePackageRoot(): string {\n // Works in both source tests (`src/agent-skills.ts`) and built packages\n // (`dist/agent-skills.js`); guard it so packaging layout drift fails clearly.\n const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));\n if (!existsSync(join(packageRoot, 'package.json'))) {\n throw new Error(\n `Unable to resolve smrt-dev-mcp package root from ${import.meta.url}`,\n );\n }\n return packageRoot;\n}\n"],"mappings":";;;;AAuBA,IAAM,eAAuC;CAC3C;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC,qDAAqD;CACpE;CACA;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC;CACf;CACA;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC;CACf;CACA;EACE,MAAM;EACN,aACE;EACF,MAAM;EACN,WAAW;EACX,YAAY,CAAC;CACf;AACF;;AAGA,SAAgB,+BAAuC;CAIrD,OAHiB,KAAK,MAAM,gBAAgB,cAAc,CAGnD,CAAA,CAAS,WAAW;AAC7B;AAEA,SAAgB,kBAAuC;CACrD,OAAO,aAAa,KAAK,EAAE,WAAW,YAAY,GAAG,YAAY,KAAK;AACxE;AAEA,SAAgB,cAAc,SAGT;CACnB,MAAM,QAAQ,aAAa,MAAM,SAAS,KAAK,SAAS,QAAQ,IAAI;CACpE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,wBAAwB,QAAQ,MAAM;CAGxD,OAAO;EACL,MAAM,MAAM;EACZ,aAAa,MAAM;EACnB,MAAM,MAAM;EACZ,YAAY,MAAM;EAClB,eAAe,gBAAgB,MAAM,SAAS;EAC9C,gBACE,QAAQ,sBAAsB,QAC1B,CAAC,IACD,MAAM,WAAW,KAAK,UAAU;GAC9B;GACA,SAAS,gBAAgB,IAAI;EAC/B,EAAE;CACV;AACF;AAEA,SAAS,gBAAgB,cAA8B;CAErD,OAAO,aAAa,KADA,mBACK,GAAa,YAAY,GAAG,MAAM;AAC7D;AAEA,SAAS,qBAA6B;CAGpC,MAAM,cAAc,QAAQ,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC,CAAC;CACnE,IAAI,CAAC,WAAW,KAAK,aAAa,cAAc,CAAC,GAC/C,MAAM,IAAI,MACR,oDAAoD,OAAO,KAAK,KAClE;CAEF,OAAO;AACT"}
|
package/dist/dev-plane.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as runtimeMigrationStatus, c as runtimeScheduleHealth, g as loadProjectCore, i as runtimeJobHealth, m as ProjectRuntimeResolutionError, o as runtimeRecentChanges, p as safeErrorMessage, r as runtimeDispatchHealth, s as runtimeRegistryDrift, t as RUNTIME_PROVENANCE } from "./tools-B0uaPTz0.js";
|
|
2
|
-
import { i as SERVER_VERSION, r as SERVER_NAME, t as bearerMatches } from "./http-
|
|
3
|
-
import { n as TOOLS } from "./tool-catalog-
|
|
2
|
+
import { i as SERVER_VERSION, r as SERVER_NAME, t as bearerMatches } from "./http-Cm8eDnF_.js";
|
|
3
|
+
import { n as TOOLS } from "./tool-catalog-CEJeiUQd.js";
|
|
4
4
|
import { i as runtimeSchemaDiff, n as runtimeObject, r as runtimeRegistry } from "./observation-DbB4z-9t.js";
|
|
5
5
|
import { Server, createMcpHandler } from "@modelcontextprotocol/server";
|
|
6
6
|
//#region src/dev-plane.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as runtimeMigrationStatus, c as runtimeScheduleHealth, i as runtimeJobHealth, o as runtimeRecentChanges, r as runtimeDispatchHealth, s as runtimeRegistryDrift } from "./tools-B0uaPTz0.js";
|
|
2
|
-
import { n as TOOLS } from "./tool-catalog-
|
|
2
|
+
import { n as TOOLS } from "./tool-catalog-CEJeiUQd.js";
|
|
3
3
|
import { a as bootRuntime, i as runtimeSchemaDiff, n as runtimeObject, r as runtimeRegistry } from "./observation-DbB4z-9t.js";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
@@ -166,4 +166,4 @@ async function startRuntimeHttpHost(options = {}) {
|
|
|
166
166
|
//#endregion
|
|
167
167
|
export { SERVER_VERSION as i, startRuntimeHttpHost as n, SERVER_NAME as r, bearerMatches as t };
|
|
168
168
|
|
|
169
|
-
//# sourceMappingURL=http-
|
|
169
|
+
//# sourceMappingURL=http-Cm8eDnF_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-Brjn_G5R.js","names":[],"sources":["../src/server-info.ts","../src/http.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport const SERVER_NAME = 'smrt-dev-mcp';\n\nfunction readPackageVersion(): string {\n try {\n const packageRoot = dirname(fileURLToPath(import.meta.url));\n const packageJsonPath = join(packageRoot, '..', 'package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n version?: unknown;\n };\n return typeof packageJson.version === 'string'\n ? packageJson.version\n : '0.0.0';\n } catch {\n return '0.0.0';\n }\n}\n\nexport const SERVER_VERSION = readPackageVersion();\n","/**\n * Standalone Level 2 runtime dev-plane host (#1831).\n *\n * Serves a *positive* read-only tool catalog over the stateless 2026-07-28\n * Streamable HTTP transport (#2147): `createMcpHandler` with `legacy: 'reject'`\n * and `maxSubscriptions: 0`, adapted to Node with `toNodeHandler`. No SSE,\n * no session header, no sticky routing.\n *\n * Security boundary (development only):\n * - binds loopback only; SDK localhost Host/Origin validation runs first;\n * - every request needs `Authorization: Bearer <token>` (constant-time\n * compare) — from `SMRT_DEV_MCP_TOKEN` or minted per process;\n * - no authenticated principal exists here, so scope stays fail-closed\n * global-only exactly as in Level 1;\n * - the catalog never includes generated CRUD, custom actions, `do()`, or\n * tool-backed `is()`.\n */\n\nimport { randomBytes, timingSafeEqual } from 'node:crypto';\nimport {\n createServer as createHttpServer,\n type Server as HttpServer,\n type IncomingMessage,\n type ServerResponse,\n} from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport {\n localhostHostValidation,\n localhostOriginValidation,\n toNodeHandler,\n} from '@modelcontextprotocol/node';\nimport type { CallToolResult } from '@modelcontextprotocol/server';\nimport { createMcpHandler, Server } from '@modelcontextprotocol/server';\nimport { SERVER_NAME, SERVER_VERSION } from './server-info.js';\nimport { TOOLS } from './tool-catalog.js';\nimport { bootRuntime, type RuntimeBoot } from './tools/runtime/boot.js';\nimport {\n runtimeObject,\n runtimeRegistry,\n runtimeSchemaDiff,\n} from './tools/runtime/observation.js';\nimport {\n runtimeDispatchHealth,\n runtimeJobHealth,\n runtimeMigrationStatus,\n runtimeRecentChanges,\n runtimeRegistryDrift,\n runtimeScheduleHealth,\n} from './tools/runtime/tools.js';\n\n/**\n * The complete Level 2 catalog. A tool is exposed over HTTP only if it is\n * named here; the static stdio catalog is deliberately not mounted.\n */\nexport const RUNTIME_HTTP_TOOL_NAMES = [\n 'runtime-registry',\n 'runtime-object',\n 'runtime-schema-diff',\n 'migration-status',\n 'job-health',\n 'schedule-health',\n 'dispatch-health',\n 'recent-changes',\n 'registry-drift',\n] as const;\n\nexport type RuntimeHttpToolName = (typeof RUNTIME_HTTP_TOOL_NAMES)[number];\n\nconst RUNTIME_HTTP_HANDLERS: Record<\n RuntimeHttpToolName,\n (args: Record<string, unknown>) => Promise<unknown>\n> = {\n 'runtime-registry': (args) => runtimeRegistry(args as never),\n 'runtime-object': (args) => runtimeObject(args as never),\n 'runtime-schema-diff': (args) => runtimeSchemaDiff(args as never),\n 'migration-status': (args) => runtimeMigrationStatus(args as never),\n 'job-health': (args) => runtimeJobHealth(args as never),\n 'schedule-health': (args) => runtimeScheduleHealth(args as never),\n 'dispatch-health': (args) => runtimeDispatchHealth(args as never),\n 'recent-changes': (args) => runtimeRecentChanges(args as never),\n 'registry-drift': (args) => runtimeRegistryDrift(args as never),\n};\n\n/** Catalog definitions for the HTTP plane, in catalog order. */\nexport function runtimeHttpTools() {\n const names = new Set<string>(RUNTIME_HTTP_TOOL_NAMES);\n return TOOLS.filter((tool) => names.has(tool.name));\n}\n\n/**\n * Build a fresh protocol server per request (stateless transport contract).\n * `projectRoot` is fixed at host start; per-request `projectPath` arguments\n * are ignored so a client cannot re-point the booted process.\n */\nexport function createRuntimeProtocolServer(projectRoot: string): Server {\n const server = new Server(\n { name: `${SERVER_NAME}-runtime`, version: SERVER_VERSION },\n { capabilities: { tools: {} } },\n );\n server.setRequestHandler('tools/list', async () => ({\n tools: runtimeHttpTools(),\n }));\n server.setRequestHandler('tools/call', async (request) => {\n const name = request.params.name as string;\n const handler = (RUNTIME_HTTP_HANDLERS as Record<string, unknown>)[name];\n if (typeof handler !== 'function') {\n throw new Error(`Unknown runtime tool: ${name}`);\n }\n const { projectPath: _ignored, ...args } = (request.params.arguments ??\n {}) as Record<string, unknown>;\n const result = await (\n handler as (a: Record<string, unknown>) => Promise<unknown>\n )({ ...args, projectPath: projectRoot });\n const text = JSON.stringify(result, null, 2);\n return {\n content: [{ type: 'text', text }],\n structuredContent: result as Record<string, unknown>,\n } satisfies CallToolResult;\n });\n return server;\n}\n\nexport interface RuntimeHttpHostOptions {\n projectRoot?: string;\n /** Loopback interface only; anything else is refused at startup. */\n host?: '127.0.0.1' | 'localhost' | '::1';\n /** `0` (default) picks a free port. */\n port?: number;\n /** Bearer token; defaults to `SMRT_DEV_MCP_TOKEN` or a per-process random token. */\n token?: string;\n /** Path the MCP endpoint is mounted on (default `/mcp`). */\n path?: string;\n}\n\nexport interface RuntimeHttpHost {\n url: string;\n token: string;\n boot: RuntimeBoot;\n close(): Promise<void>;\n}\n\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1']);\n\nexport function bearerMatches(\n header: string | undefined,\n token: string,\n): boolean {\n if (!header?.startsWith('Bearer ')) return false;\n const presented = Buffer.from(header.slice('Bearer '.length));\n const expected = Buffer.from(token);\n return (\n presented.length === expected.length && timingSafeEqual(presented, expected)\n );\n}\n\nfunction deny(res: ServerResponse, status: number, message: string): void {\n res.statusCode = status;\n res.setHeader('content-type', 'application/json');\n if (status === 401) {\n res.setHeader('www-authenticate', 'Bearer realm=\"smrt-dev-mcp runtime\"');\n }\n res.end(JSON.stringify({ error: message }));\n}\n\n/** Start the Level 2 host. Boots the confined runtime before listening. */\nexport async function startRuntimeHttpHost(\n options: RuntimeHttpHostOptions = {},\n): Promise<RuntimeHttpHost> {\n const host = options.host ?? '127.0.0.1';\n if (!LOOPBACK_HOSTS.has(host)) {\n throw new Error(\n 'The runtime dev-plane binds loopback only (127.0.0.1, localhost, ::1).',\n );\n }\n const path = options.path ?? '/mcp';\n const token =\n options.token ??\n process.env.SMRT_DEV_MCP_TOKEN?.trim() ??\n randomBytes(24).toString('base64url');\n if (!token) {\n throw new Error('SMRT_DEV_MCP_TOKEN must not be empty.');\n }\n const projectRoot = options.projectRoot ?? process.cwd();\n const boot = await bootRuntime({ projectRoot });\n\n const mcp = toNodeHandler(\n createMcpHandler(() => createRuntimeProtocolServer(projectRoot), {\n legacy: 'reject',\n maxSubscriptions: 0,\n }),\n );\n const hostGuard = localhostHostValidation();\n const originGuard = localhostOriginValidation();\n\n const httpServer: HttpServer = createHttpServer(\n (req: IncomingMessage, res: ServerResponse) => {\n // Guards answer and end the response themselves when they return false.\n if (!hostGuard(req, res)) return;\n if (!originGuard(req, res)) return;\n const url = new URL(req.url ?? '/', 'http://localhost');\n if (url.pathname !== path) {\n deny(res, 404, 'not found');\n return;\n }\n if (!bearerMatches(req.headers.authorization, token)) {\n deny(res, 401, 'missing or invalid bearer token');\n return;\n }\n void mcp(req, res);\n },\n );\n\n await new Promise<void>((resolve, reject) => {\n httpServer.once('error', reject);\n httpServer.listen(options.port ?? 0, host, () => {\n httpServer.off('error', reject);\n resolve();\n });\n });\n const address = httpServer.address() as AddressInfo;\n const urlHost =\n address.family === 'IPv6' ? `[${address.address}]` : address.address;\n return {\n url: `http://${urlHost}:${address.port}${path}`,\n token,\n boot,\n close: () =>\n new Promise<void>((resolve, reject) => {\n httpServer.closeAllConnections?.();\n httpServer.close((error) => (error ? reject(error) : resolve()));\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,IAAa,cAAc;AAE3B,SAAS,qBAA6B;CACpC,IAAI;EAEF,MAAM,kBAAkB,KADJ,QAAQ,cAAc,OAAO,KAAK,GAAG,CAC5B,GAAa,MAAM,cAAc;EAC9D,MAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;EAGrE,OAAO,OAAO,YAAY,YAAY,WAClC,YAAY,UACZ;CACN,QAAQ;EACN,OAAO;CACT;AACF;AAEA,IAAa,iBAAiB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;ACiCjD,IAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,wBAGF;CACF,qBAAqB,SAAS,gBAAgB,IAAa;CAC3D,mBAAmB,SAAS,cAAc,IAAa;CACvD,wBAAwB,SAAS,kBAAkB,IAAa;CAChE,qBAAqB,SAAS,uBAAuB,IAAa;CAClE,eAAe,SAAS,iBAAiB,IAAa;CACtD,oBAAoB,SAAS,sBAAsB,IAAa;CAChE,oBAAoB,SAAS,sBAAsB,IAAa;CAChE,mBAAmB,SAAS,qBAAqB,IAAa;CAC9D,mBAAmB,SAAS,qBAAqB,IAAa;AAChE;;AAGA,SAAgB,mBAAmB;CACjC,MAAM,QAAQ,IAAI,IAAY,uBAAuB;CACrD,OAAO,MAAM,QAAQ,SAAS,MAAM,IAAI,KAAK,IAAI,CAAC;AACpD;;;;;;AAOA,SAAgB,4BAA4B,aAA6B;CACvE,MAAM,SAAS,IAAI,OACjB;EAAE,MAAM,GAAG,YAAY;EAAW,SAAS;CA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ACjE,CAAC;CACL;AACF"}
|
|
1
|
+
{"version":3,"file":"http-Cm8eDnF_.js","names":[],"sources":["../src/server-info.ts","../src/http.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport const SERVER_NAME = 'smrt-dev-mcp';\n\nfunction readPackageVersion(): string {\n try {\n const packageRoot = dirname(fileURLToPath(import.meta.url));\n const packageJsonPath = join(packageRoot, '..', 'package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n version?: unknown;\n };\n return typeof packageJson.version === 'string'\n ? packageJson.version\n : '0.0.0';\n } catch {\n return '0.0.0';\n }\n}\n\nexport const SERVER_VERSION = readPackageVersion();\n","/**\n * Standalone Level 2 runtime dev-plane host (#1831).\n *\n * Serves a *positive* read-only tool catalog over the stateless 2026-07-28\n * Streamable HTTP transport (#2147): `createMcpHandler` with `legacy: 'reject'`\n * and `maxSubscriptions: 0`, adapted to Node with `toNodeHandler`. No SSE,\n * no session header, no sticky routing.\n *\n * Security boundary (development only):\n * - binds loopback only; SDK localhost Host/Origin validation runs first;\n * - every request needs `Authorization: Bearer <token>` (constant-time\n * compare) — from `SMRT_DEV_MCP_TOKEN` or minted per process;\n * - no authenticated principal exists here, so scope stays fail-closed\n * global-only exactly as in Level 1;\n * - the catalog never includes generated CRUD, custom actions, `do()`, or\n * tool-backed `is()`.\n */\n\nimport { randomBytes, timingSafeEqual } from 'node:crypto';\nimport {\n createServer as createHttpServer,\n type Server as HttpServer,\n type IncomingMessage,\n type ServerResponse,\n} from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport {\n localhostHostValidation,\n localhostOriginValidation,\n toNodeHandler,\n} from '@modelcontextprotocol/node';\nimport type { CallToolResult } from '@modelcontextprotocol/server';\nimport { createMcpHandler, Server } from '@modelcontextprotocol/server';\nimport { SERVER_NAME, SERVER_VERSION } from './server-info.js';\nimport { TOOLS } from './tool-catalog.js';\nimport { bootRuntime, type RuntimeBoot } from './tools/runtime/boot.js';\nimport {\n runtimeObject,\n runtimeRegistry,\n runtimeSchemaDiff,\n} from './tools/runtime/observation.js';\nimport {\n runtimeDispatchHealth,\n runtimeJobHealth,\n runtimeMigrationStatus,\n runtimeRecentChanges,\n runtimeRegistryDrift,\n runtimeScheduleHealth,\n} from './tools/runtime/tools.js';\n\n/**\n * The complete Level 2 catalog. A tool is exposed over HTTP only if it is\n * named here; the static stdio catalog is deliberately not mounted.\n */\nexport const RUNTIME_HTTP_TOOL_NAMES = [\n 'runtime-registry',\n 'runtime-object',\n 'runtime-schema-diff',\n 'migration-status',\n 'job-health',\n 'schedule-health',\n 'dispatch-health',\n 'recent-changes',\n 'registry-drift',\n] as const;\n\nexport type RuntimeHttpToolName = (typeof RUNTIME_HTTP_TOOL_NAMES)[number];\n\nconst RUNTIME_HTTP_HANDLERS: Record<\n RuntimeHttpToolName,\n (args: Record<string, unknown>) => Promise<unknown>\n> = {\n 'runtime-registry': (args) => runtimeRegistry(args as never),\n 'runtime-object': (args) => runtimeObject(args as never),\n 'runtime-schema-diff': (args) => runtimeSchemaDiff(args as never),\n 'migration-status': (args) => runtimeMigrationStatus(args as never),\n 'job-health': (args) => runtimeJobHealth(args as never),\n 'schedule-health': (args) => runtimeScheduleHealth(args as never),\n 'dispatch-health': (args) => runtimeDispatchHealth(args as never),\n 'recent-changes': (args) => runtimeRecentChanges(args as never),\n 'registry-drift': (args) => runtimeRegistryDrift(args as never),\n};\n\n/** Catalog definitions for the HTTP plane, in catalog order. */\nexport function runtimeHttpTools() {\n const names = new Set<string>(RUNTIME_HTTP_TOOL_NAMES);\n return TOOLS.filter((tool) => names.has(tool.name));\n}\n\n/**\n * Build a fresh protocol server per request (stateless transport contract).\n * `projectRoot` is fixed at host start; per-request `projectPath` arguments\n * are ignored so a client cannot re-point the booted process.\n */\nexport function createRuntimeProtocolServer(projectRoot: string): Server {\n const server = new Server(\n { name: `${SERVER_NAME}-runtime`, version: SERVER_VERSION },\n { capabilities: { tools: {} } },\n );\n server.setRequestHandler('tools/list', async () => ({\n tools: runtimeHttpTools(),\n }));\n server.setRequestHandler('tools/call', async (request) => {\n const name = request.params.name as string;\n const handler = (RUNTIME_HTTP_HANDLERS as Record<string, unknown>)[name];\n if (typeof handler !== 'function') {\n throw new Error(`Unknown runtime tool: ${name}`);\n }\n const { projectPath: _ignored, ...args } = (request.params.arguments ??\n {}) as Record<string, unknown>;\n const result = await (\n handler as (a: Record<string, unknown>) => Promise<unknown>\n )({ ...args, projectPath: projectRoot });\n const text = JSON.stringify(result, null, 2);\n return {\n content: [{ type: 'text', text }],\n structuredContent: result as Record<string, unknown>,\n } satisfies CallToolResult;\n });\n return server;\n}\n\nexport interface RuntimeHttpHostOptions {\n projectRoot?: string;\n /** Loopback interface only; anything else is refused at startup. */\n host?: '127.0.0.1' | 'localhost' | '::1';\n /** `0` (default) picks a free port. */\n port?: number;\n /** Bearer token; defaults to `SMRT_DEV_MCP_TOKEN` or a per-process random token. */\n token?: string;\n /** Path the MCP endpoint is mounted on (default `/mcp`). */\n path?: string;\n}\n\nexport interface RuntimeHttpHost {\n url: string;\n token: string;\n boot: RuntimeBoot;\n close(): Promise<void>;\n}\n\nconst LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1']);\n\nexport function bearerMatches(\n header: string | undefined,\n token: string,\n): boolean {\n if (!header?.startsWith('Bearer ')) return false;\n const presented = Buffer.from(header.slice('Bearer '.length));\n const expected = Buffer.from(token);\n return (\n presented.length === expected.length && timingSafeEqual(presented, expected)\n );\n}\n\nfunction deny(res: ServerResponse, status: number, message: string): void {\n res.statusCode = status;\n res.setHeader('content-type', 'application/json');\n if (status === 401) {\n res.setHeader('www-authenticate', 'Bearer realm=\"smrt-dev-mcp runtime\"');\n }\n res.end(JSON.stringify({ error: message }));\n}\n\n/** Start the Level 2 host. Boots the confined runtime before listening. */\nexport async function startRuntimeHttpHost(\n options: RuntimeHttpHostOptions = {},\n): Promise<RuntimeHttpHost> {\n const host = options.host ?? '127.0.0.1';\n if (!LOOPBACK_HOSTS.has(host)) {\n throw new Error(\n 'The runtime dev-plane binds loopback only (127.0.0.1, localhost, ::1).',\n );\n }\n const path = options.path ?? '/mcp';\n const token =\n options.token ??\n process.env.SMRT_DEV_MCP_TOKEN?.trim() ??\n randomBytes(24).toString('base64url');\n if (!token) {\n throw new Error('SMRT_DEV_MCP_TOKEN must not be empty.');\n }\n const projectRoot = options.projectRoot ?? process.cwd();\n const boot = await bootRuntime({ projectRoot });\n\n const mcp = toNodeHandler(\n createMcpHandler(() => createRuntimeProtocolServer(projectRoot), {\n legacy: 'reject',\n maxSubscriptions: 0,\n }),\n );\n const hostGuard = localhostHostValidation();\n const originGuard = localhostOriginValidation();\n\n const httpServer: HttpServer = createHttpServer(\n (req: IncomingMessage, res: ServerResponse) => {\n // Guards answer and end the response themselves when they return false.\n if (!hostGuard(req, res)) return;\n if (!originGuard(req, res)) return;\n const url = new URL(req.url ?? '/', 'http://localhost');\n if (url.pathname !== path) {\n deny(res, 404, 'not found');\n return;\n }\n if (!bearerMatches(req.headers.authorization, token)) {\n deny(res, 401, 'missing or invalid bearer token');\n return;\n }\n void mcp(req, res);\n },\n );\n\n await new Promise<void>((resolve, reject) => {\n httpServer.once('error', reject);\n httpServer.listen(options.port ?? 0, host, () => {\n httpServer.off('error', reject);\n resolve();\n });\n });\n const address = httpServer.address() as AddressInfo;\n const urlHost =\n address.family === 'IPv6' ? `[${address.address}]` : address.address;\n return {\n url: `http://${urlHost}:${address.port}${path}`,\n token,\n boot,\n close: () =>\n new Promise<void>((resolve, reject) => {\n httpServer.closeAllConnections?.();\n httpServer.close((error) => (error ? reject(error) : resolve()));\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,IAAa,cAAc;AAE3B,SAAS,qBAA6B;CACpC,IAAI;EAEF,MAAM,kBAAkB,KADJ,QAAQ,cAAc,OAAO,KAAK,GAAG,CAC5B,GAAa,MAAM,cAAc;EAC9D,MAAM,cA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E9C,MAAM,aAAyB,cAC5B,KAAsB,QAAwB;EAE7C,IAAI,CAAC,UAAU,KAAK,GAAG,GAAG;EAC1B,IAAI,CAAC,YAAY,KAAK,GAAG,GAAG;EAE5B,IAAI,IADY,IAAI,IAAI,OAAO,KAAK,kBAChC,CAAA,CAAI,aAAa,MAAM;GACzB,KAAK,KAAK,KAAK,WAAW;GAC1B;EACF;EACA,IAAI,CAAC,cAAc,IAAI,QAAQ,eAAe,KAAK,GAAG;GACpD,KAAK,KAAK,KAAK,iCAAiC;GAChD;EACF;EACA,IAAS,KAAK,GAAG;CACnB,CACF;CAEA,MAAM,IAAI,SAAe,SAAS,WAAW;EAC3C,WAAW,KAAK,SAAS,MAAM;EAC/B,WAAW,OAAO,QAAQ,QAAQ,GAAG,YAAY;GAC/C,WAAW,IAAI,SAAS,MAAM;GAC9B,QAAQ;EACV,CAAC;CACH,CAAC;CACD,MAAM,UAAU,WAAW,QAAQ;CAGnC,OAAO;EACL,KAAK,UAFL,QAAQ,WAAW,SAAS,IAAI,QAAQ,QAAQ,KAAK,QAAQ,QAEtC,GAAG,QAAQ,OAAO;EACzC;EACA;EACA,aACE,IAAI,SAAe,SAAS,WAAW;GACrC,WAAW,sBAAsB;GACjC,WAAW,OAAO,UAAW,QAAQ,OAAO,KAAK,IAAI,QAAQ,CAAE;EACjE,CAAC;CACL;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { f as redactConnectionString, m as ProjectRuntimeResolutionError } from "./tools-B0uaPTz0.js";
|
|
3
3
|
import { getAgentSkill, listAgentSkills } from "./agent-skills.js";
|
|
4
|
-
import { i as SERVER_VERSION, n as startRuntimeHttpHost, r as SERVER_NAME } from "./http-
|
|
5
|
-
import { n as TOOLS, t as REVIEW_SKILL_NAME } from "./tool-catalog-
|
|
6
|
-
import { a as buildReviewContext, c as compactContextResult, i as buildPackageSpecialistContext, n as buildContext, o as checkKnowledgeFreshness, r as buildKnowledgeIndex, s as checkKnowledgeFreshnessFromIndex, t as buildArchitectureContext } from "./knowledge-
|
|
4
|
+
import { i as SERVER_VERSION, n as startRuntimeHttpHost, r as SERVER_NAME } from "./http-Cm8eDnF_.js";
|
|
5
|
+
import { n as TOOLS, t as REVIEW_SKILL_NAME } from "./tool-catalog-CEJeiUQd.js";
|
|
6
|
+
import { a as buildReviewContext, c as compactContextResult, i as buildPackageSpecialistContext, n as buildContext, o as checkKnowledgeFreshness, r as buildKnowledgeIndex, s as checkKnowledgeFreshnessFromIndex, t as buildArchitectureContext } from "./knowledge-CSUS5hbw.js";
|
|
7
7
|
import { t as reviewSmrtProject } from "./review-smrt-project-ByEwPcor.js";
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -37,6 +37,6 @@ Read this before writing queues, schedulers, mailers, uploaders, tenant filters,
|
|
|
37
37
|
| Inbound and outbound webhooks | [webhooks-and-events](/intents/webhooks-and-events.md) | [smrt-webhooks](/components/smrt-webhooks.md), [smrt-core](/components/smrt-core.md), [smrt-jobs](/components/smrt-jobs.md), [smrt-events](/components/smrt-events.md) | `WebhookDispatcher`, `WebhookAdminService`, `registerWebhookRuntime()`; core `createDispatchBus()` | `import:svix`; `regex:createHmac\(`; `regex:x-[a-z-]*signature` |
|
|
38
38
|
| Search, facts, extracted knowledge | [search-facts-knowledge](/intents/search-facts-knowledge.md) | [smrt-facts](/components/smrt-facts.md), [smrt-content](/components/smrt-content.md), [smrt-ingestion](/components/smrt-ingestion.md), [smrt-core](/components/smrt-core.md) | `FactCollection.reconcile()`, `collection.semanticSearch()`, smrt-ingestion models and `/server` services | `import:@pinecone-database/pinecone`; `import:pgvector`; `import:minisearch`; `import:flexsearch`; `import:lunr`; `regex:cosine_?[sS]imilarity` |
|
|
39
39
|
| Auth, users, sessions | [auth-and-users](/intents/auth-and-users.md) | [smrt-users](/components/smrt-users.md), [smrt-tenancy](/components/smrt-tenancy.md) | `SessionService`, `PasswordCredentialService`, `PermissionResolver`, `LoginAttemptLimiter`, `/sveltekit` handlers | `import:bcrypt`; `import:bcryptjs`; `import:argon2`; `import:jsonwebtoken`; `import:passport`; `import:express-session`; `import:lucia` |
|
|
40
|
-
| Prompts and AI operations | [prompts-and-ai-operations](/intents/prompts-and-ai-operations.md) | [smrt-prompts](/components/smrt-prompts.md), [smrt-core](/components/smrt-core.md), [smrt-agents](/components/smrt-agents.md) | `definePrompt()` + `resolvePrompt()
|
|
40
|
+
| Prompts and AI operations | [prompts-and-ai-operations](/intents/prompts-and-ai-operations.md) | [smrt-prompts](/components/smrt-prompts.md), [smrt-core](/components/smrt-core.md), [smrt-agents](/components/smrt-agents.md) | `definePrompt()` + `resolvePrompt()` + tracked client (`createTrackedAiClient`), `PromptOverrideService`, `@smrt({ ai: { callable } })`, `SmrtObject.is()/do()/describe()` | `import:openai`; `import:@anthropic-ai/sdk`; `import:langchain`; `regex:You are an? [a-z ]+`; `regex:role:\s*['"]system['"]` |
|
|
41
41
|
| Polymorphic links, junctions, trees | [relationships-and-trees](/intents/relationships-and-trees.md) | [smrt-core](/components/smrt-core.md) | `SmrtJunction`/`SmrtJunctionBase`, `SmrtHierarchical`, `SmrtPolymorphicAssociation` | `regex:parent_?[iI]d\s*[:=]`; `regex:WITH RECURSIVE`; `regex:entity_?type` |
|
|
42
42
|
| Local credentials, device tokens and owner sign-in | [local-credentials-and-owner-signin](/intents/local-credentials-and-owner-signin.md) | [smrt-app-runtime](/components/smrt-app-runtime.md), [smrt-users](/components/smrt-users.md) | `openLocalMcpTokenStore()` (`smrt app token`), `claimOwner()` with the loopback `/setup` URL, `SessionService` | `import:keytar`; `import:@napi-rs/keyring`; `regex:security add-generic-password`; `regex:homedir\(\).*(token\|credential)s?[\w.-]*\.json`; `regex:~/\.[\w./-]*(token\|credential)`; `regex:expiresIn\s*:\s*['"]\d+\s*[smhd]['"]` |
|
|
@@ -45,7 +45,7 @@ sources:
|
|
|
45
45
|
|
|
46
46
|
# Entry point
|
|
47
47
|
|
|
48
|
-
Prompts: `definePrompt({ key, template, ai })` registers a namespaced code default; `await resolvePrompt(key, { override })` returns the effective template, profile, model and params after layering code default, config file, app override, tenant override and runtime override field by field. Writes go through `PromptOverrideService` with a host-supplied authorizer; a management screen uses `PromptSettingsService`. AI operations on models: `@smrt({ ai: { callable: ['analyze'] } })` chooses which methods an AI may call, and `SmrtObject` provides `is()`, `do()` and `describe()`. Agents resolve per-tenant provider keys with `resolveAgentAIOptions()` (smrt-agents).[^s3][^s5]
|
|
48
|
+
Prompts: `definePrompt({ key, template, ai })` registers a namespaced code default; `await resolvePrompt(key, { override })` returns the effective template, profile, model and params after layering code default, config file, app override, tenant override and runtime override field by field. Writes go through `PromptOverrideService` with a host-supplied authorizer; a management screen uses `PromptSettingsService`. AI operations on models: `@smrt({ ai: { callable: ['analyze'] } })` chooses which methods an AI may call, and `SmrtObject` provides `is()`, `do()` and `describe()`. Every model call is sent on the tracked client (`createTrackedAiClient({ db, tenantId }).client(trackedPromptCall(resolved))`, or `is()`/`do()`/`describe()`), so it carries its prompt key and is recorded once in `_smrt_ai_usage`; work of several calls is a run with a budget, and multi-step work is a `smrt-workflows` definition. Runs, events, evaluations, tiers, latency, effort, budgets and fusions are defined in `docs/content/ai-runs.md`; the `smrt-ai-work` skill (`get-agent-skill`) walks an agent through it. Agents resolve per-tenant provider keys with `resolveAgentAIOptions()` (smrt-agents).[^s3][^s5]
|
|
49
49
|
|
|
50
50
|
# Why not hand-roll it
|
|
51
51
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TOOLS } from "./tool-catalog-
|
|
1
|
+
import { n as TOOLS } from "./tool-catalog-CEJeiUQd.js";
|
|
2
2
|
import { existsSync, lstatSync, opendirSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, isAbsolute, join, matchesGlob, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -3012,4 +3012,4 @@ function gitignoredTopLevelEntries(directory) {
|
|
|
3012
3012
|
//#endregion
|
|
3013
3013
|
export { OKF_SHIPPED_COMPONENT_PAGE as C, readFrontmatterScalar as D, compareVersions as E, readOkfBundleManifest as O, OKF_INTENT_HOME_PACKAGES as S, checkOkfBundleFreshness as T, OKF_BUNDLE_DIR_NAME as _, buildReviewContext as a, OKF_BUNDLE_MAX_AGE_DAYS as b, compactContextResult as c, listConsumerWorkspaceInstallRoots as d, packageDocPaths as f, smrtReview as g, smrtArchitecture as h, buildPackageSpecialistContext as i, stampPackageVersion as k, coreCompatibleToSnakeCase as l, renderKnowledgeIndexMarkdown as m, buildContext as n, checkKnowledgeFreshness as o, renderFreshnessResult as p, buildKnowledgeIndex as r, checkKnowledgeFreshnessFromIndex as s, buildArchitectureContext as t, diffKnowledgeIndex as u, OKF_BUNDLE_FORMAT as v, OKF_SHIPPED_INTENTS_DIR as w, OKF_BUNDLE_PARENT_DIRS as x, OKF_BUNDLE_MANIFEST as y };
|
|
3014
3014
|
|
|
3015
|
-
//# sourceMappingURL=knowledge-
|
|
3015
|
+
//# sourceMappingURL=knowledge-CSUS5hbw.js.map
|