@powerhousedao/clint 6.4.0-next.2 → 6.4.0-next.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.
- package/dist/{build-skills-Bpbbnin0.mjs → build-skills-BTkuL8ne.mjs} +2 -2
- package/dist/{build-skills-Bpbbnin0.mjs.map → build-skills-BTkuL8ne.mjs.map} +1 -1
- package/dist/command-control-Dp41aY0o.mjs +224 -0
- package/dist/command-control-Dp41aY0o.mjs.map +1 -0
- package/dist/{dist-Bd6hUl0J.mjs → dist-BTVqrpN4.mjs} +2 -2
- package/dist/{dist-Bd6hUl0J.mjs.map → dist-BTVqrpN4.mjs.map} +1 -1
- package/dist/{index-CfHcet4v.d.mts → index-DJlqIVLv.d.mts} +13 -10
- package/dist/{index-CfHcet4v.d.mts.map → index-DJlqIVLv.d.mts.map} +1 -1
- package/dist/index.d.mts +227 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/integrations/mastra/index.d.mts +20 -3
- package/dist/integrations/mastra/index.d.mts.map +1 -1
- package/dist/integrations/mastra/index.mjs +25 -3
- package/dist/integrations/mastra/index.mjs.map +1 -1
- package/dist/integrations/powerhouse/index.d.mts +3 -3
- package/dist/integrations/powerhouse/index.mjs +1 -1
- package/dist/{markdown-BUeGwhbR.mjs → markdown-B-HyDpvO.mjs} +471 -39
- package/dist/markdown-B-HyDpvO.mjs.map +1 -0
- package/dist/{powerhouse-3XZmdY3_.mjs → powerhouse-C4O-raTW.mjs} +168 -12
- package/dist/powerhouse-C4O-raTW.mjs.map +1 -0
- package/dist/{proxy-ji3EHzLn.mjs → proxy-DgnOKu1A.mjs} +2 -2
- package/dist/proxy-DgnOKu1A.mjs.map +1 -0
- package/dist/remote-reactor-oBsHphPT.mjs.map +1 -1
- package/dist/{repl-Czb7u0x_.mjs → repl-C4gHgy6P.mjs} +2 -2
- package/dist/{repl-Czb7u0x_.mjs.map → repl-C4gHgy6P.mjs.map} +1 -1
- package/dist/runners/cli-runner.d.mts +5 -2
- package/dist/runners/cli-runner.d.mts.map +1 -1
- package/dist/runners/cli-runner.mjs +21 -7
- package/dist/runners/cli-runner.mjs.map +1 -1
- package/dist/runners/mastra-runner.mjs +1 -1
- package/dist/runners/proxy-runner.mjs +1 -1
- package/dist/{src-BmMd0Wl4.mjs → src-FF3zDJY7.mjs} +606 -53
- package/dist/src-FF3zDJY7.mjs.map +1 -0
- package/dist/{start-BHn9LIyX.mjs → start-CCegR8Pi.mjs} +2 -2
- package/dist/{start-BHn9LIyX.mjs.map → start-CCegR8Pi.mjs.map} +1 -1
- package/dist/testing/index.d.mts +2 -2
- package/dist/testing/index.mjs +1 -1
- package/dist/{types-3TnDjQ1w.d.mts → types-BnPpIAL6.d.mts} +2 -2
- package/dist/{types-3TnDjQ1w.d.mts.map → types-BnPpIAL6.d.mts.map} +1 -1
- package/dist/{types-DbQKfvWc.d.mts → types-CIZtG2TY.d.mts} +219 -13
- package/dist/types-CIZtG2TY.d.mts.map +1 -0
- package/package.json +13 -13
- package/dist/markdown-BUeGwhbR.mjs.map +0 -1
- package/dist/powerhouse-3XZmdY3_.mjs.map +0 -1
- package/dist/proxy-ji3EHzLn.mjs.map +0 -1
- package/dist/src-BmMd0Wl4.mjs.map +0 -1
- package/dist/types-DbQKfvWc.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as renderSkillTemplate } from "./src-FF3zDJY7.mjs";
|
|
2
2
|
import { n as slugToTitle } from "./schema-BEKAZGyT.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -299,4 +299,4 @@ async function buildSkills(options) {
|
|
|
299
299
|
//#endregion
|
|
300
300
|
export { buildSkills };
|
|
301
301
|
|
|
302
|
-
//# sourceMappingURL=build-skills-
|
|
302
|
+
//# sourceMappingURL=build-skills-BTkuL8ne.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-skills-Bpbbnin0.mjs","names":[],"sources":["../src/dev/agent-profiles.ts","../src/dev/skill-builder.ts","../src/dev/skill-copier.ts","../src/dev/build-skills.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing file across multiple include directories.\n */\nfunction findInIncludes(\n includes: string[],\n subdir: string,\n filename: string,\n): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir, filename);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build agent profile instructions by rendering base+specialized template pairs.\n * Writes each profile as a Markdown file in {output}/agents/{ProfileName}.md.\n *\n * @returns Number of profiles built and any warnings.\n */\nexport function buildAgentProfiles(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const profiles = config.agentProfiles;\n if (profiles.length === 0) return { count: 0, warnings: [] };\n\n const profilesSubdir = config.subdirs?.profiles ?? \"agent-profiles\";\n\n log(\"\\n--- Building agent instructions ---\");\n\n const allWarnings: string[] = [];\n let count = 0;\n\n for (const profile of profiles) {\n // Check all section files exist before rendering\n const sectionPaths: string[] = [];\n let missing = false;\n for (const section of profile.sections) {\n const found = findInIncludes(config.include, profilesSubdir, section);\n if (!found) {\n log(` SKIP ${profile.name}: missing section ${section}`);\n missing = true;\n break;\n }\n sectionPaths.push(found);\n }\n if (missing) continue;\n\n const agentContext = { ...config.context, agentName: profile.name };\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n\n const renderedSections: string[] = [];\n for (let i = 0; i < profile.sections.length; i++) {\n const raw = fs.readFileSync(sectionPaths[i], \"utf-8\");\n const result = renderSkillTemplate(raw, agentContext, renderOpts);\n for (const w of result.warnings) {\n const msg = `${profile.name}/${profile.sections[i]}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n renderedSections.push(result.rendered.trim());\n }\n\n const combined = renderedSections.join(\"\\n\\n\") + \"\\n\";\n for (const out of config.output) {\n const agentsDir = path.join(out, \"agent-profiles\");\n fs.mkdirSync(agentsDir, { recursive: true });\n fs.writeFileSync(\n path.join(agentsDir, `${profile.name}.md`),\n combined,\n \"utf-8\",\n );\n }\n\n log(` OK ${profile.name} → ${profile.name}.md (${combined.length} chars)`);\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate, slugToTitle } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing directory across multiple include paths.\n */\nfunction findSubdir(includes: string[], subdir: string): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build SKILL.md files from Handlebars templates in skills-tpl/.\n * Each skill directory produces a SKILL.md + references/ folder.\n *\n * @returns Number of skills built and any warnings.\n */\nexport function buildSkillTemplates(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const skillsTplSubdir = config.subdirs?.skillsTpl ?? \"skills-tpl\";\n const skillsTplDir = findSubdir(config.include, skillsTplSubdir);\n\n log(\"\\n--- Building SKILL.md files (templates) ---\");\n\n if (!skillsTplDir) {\n log(\" No skills-tpl/ directory — skipping.\");\n return { count: 0, warnings: [] };\n }\n\n const skillDirs = fs\n .readdirSync(skillsTplDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n const allWarnings: string[] = [];\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n let count = 0;\n\n for (const skillName of skillDirs) {\n const skillDir = path.join(skillsTplDir, skillName);\n\n // Preamble\n const preamblePath = path.join(skillDir, \".preamble.md\");\n const preambleRaw = fs.existsSync(preamblePath)\n ? fs.readFileSync(preamblePath, \"utf-8\").trim()\n : \"\";\n let preamble = \"\";\n if (preambleRaw) {\n const r = renderSkillTemplate(preambleRaw, config.context, renderOpts);\n preamble = r.rendered;\n for (const w of r.warnings) {\n const msg = `${skillName}/.preamble.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n }\n\n // Scenario files (NN.name.md)\n const scenarioFiles = fs\n .readdirSync(skillDir)\n .filter((f) => /^\\d+\\..*\\.md$/.test(f))\n .sort();\n\n // Result file\n const resultPath = path.join(skillDir, \".result.md\");\n const hasResult = fs.existsSync(resultPath);\n\n if (!preamble && scenarioFiles.length === 0 && !hasResult) {\n log(` SKIP ${skillName}: no content files found`);\n continue;\n }\n\n // Render references into memory\n const files: Map<string, string> = new Map();\n const refLinks: string[] = [];\n\n for (const scenarioFile of scenarioFiles) {\n const content = fs\n .readFileSync(path.join(skillDir, scenarioFile), \"utf-8\")\n .trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/${scenarioFile}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(path.join(\"references\", scenarioFile), r.rendered + \"\\n\");\n const label = slugToTitle(\n scenarioFile.replace(/^\\d+\\./, \"\").replace(/\\.md$/, \"\"),\n );\n refLinks.push(\n `* **${label}** [references/${scenarioFile}](references/${scenarioFile})`,\n );\n }\n\n if (hasResult) {\n const content = fs.readFileSync(resultPath, \"utf-8\").trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.result.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\n path.join(\"references\", \"expected-outcome.md\"),\n r.rendered + \"\\n\",\n );\n refLinks.push(\n `* **Expected Outcome** [references/expected-outcome.md](references/expected-outcome.md)`,\n );\n }\n\n // Build SKILL.md\n const description =\n config.skillDescriptions[skillName] ?? `${slugToTitle(skillName)} tasks`;\n\n const frontmatter = [\n \"---\",\n `name: ${skillName}`,\n `description: \"${description}\"`,\n \"metadata:\",\n \" author: Powerhouse\",\n ' version: \"1.0.0\"',\n \"---\",\n ].join(\"\\n\");\n\n const sections = [preamble];\n if (refLinks.length > 0) {\n sections.push(\"## Specific tasks\\n\\n\" + refLinks.join(\"\\n\"));\n }\n\n const skillMd =\n frontmatter + \"\\n\\n\" + sections.filter(Boolean).join(\"\\n\\n\") + \"\\n\";\n files.set(\"SKILL.md\", skillMd);\n\n // Copy .cli-docs.md if present (render through Handlebars)\n const cliDocsPath = path.join(skillDir, \".cli-docs.md\");\n if (fs.existsSync(cliDocsPath)) {\n const cliDocsRaw = fs.readFileSync(cliDocsPath, \"utf-8\").trim();\n if (cliDocsRaw) {\n const r = renderSkillTemplate(cliDocsRaw, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.cli-docs.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\".cli-docs.md\", r.rendered + \"\\n\");\n }\n }\n\n // Write to all output directories\n for (const out of config.output) {\n const outputDir = path.join(out, \"skills\", skillName);\n for (const [relPath, content] of files) {\n const fullPath = path.join(outputDir, relPath);\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content, \"utf-8\");\n }\n }\n\n log(\n ` OK ${skillName} → SKILL.md + ${scenarioFiles.length + (hasResult ? 1 : 0)} references (${skillMd.length} chars)`,\n );\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Copy external skills from skills-ext/ to the output directory without processing.\n *\n * @returns Number of skills copied.\n */\nexport function copyExternalSkills(config: ResolvedBuildConfig): number {\n const log = config.logger;\n const skillsExtSubdir = config.subdirs?.skillsExt ?? \"skills-ext\";\n\n log(\"\\n--- Copying external skills ---\");\n\n // Search all include dirs for skills-ext/\n let found = false;\n let total = 0;\n\n for (const dir of config.include) {\n const skillsExtDir = path.join(dir, skillsExtSubdir);\n if (!fs.existsSync(skillsExtDir)) continue;\n found = true;\n\n const skillDirs = fs\n .readdirSync(skillsExtDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n for (const skillName of skillDirs) {\n const srcDir = path.join(skillsExtDir, skillName);\n for (const out of config.output) {\n fs.cpSync(srcDir, path.join(out, \"skills\", skillName), {\n recursive: true,\n });\n }\n log(` OK ${skillName} → copied as-is`);\n }\n\n total += skillDirs.length;\n }\n\n if (!found) {\n log(\" No skills-ext/ directory — skipping.\");\n }\n\n return total;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { buildAgentProfiles } from \"./agent-profiles.js\";\nimport { buildSkillTemplates } from \"./skill-builder.js\";\nimport { copyExternalSkills } from \"./skill-copier.js\";\nimport type { AgentProfile, ResolvedBuildConfig } from \"./types.js\";\nimport type { CliMetadata } from \"../core/types.js\";\n\n/**\n * Path-driven skill/profile compilation (ph-clint-dev's pipeline). The paths\n * drive it; a package's `Cli` is an optional extra source (`cli`): its\n * metadata joins the template context as ph-clint-dev did it, so a template\n * can name `{{commands.<id>.description}}` or `{{services.<id>.name}}`.\n * Conventions:\n *\n * <skillsDir>/ include root (default: prompts/ then agents/)\n * agent-profiles/ profile section templates\n * skills-tpl/<skill>/ Handlebars skill templates → SKILL.md\n * skills-ext/<skill>/ external skills copied as-is\n * profiles.json optional [{ name, sections: [...] }]\n *\n * Output: <outDir> (default: dist/skills).\n */\nexport interface BuildSkillsOptions {\n rootDir: string;\n skillsDir?: string;\n agentsDir?: string;\n outDir?: string;\n context?: Record<string, unknown>;\n /**\n * The package's `Cli` (see `loadCli`). Only `getMetadata()` is read, which\n * starts nothing. Its metadata is spread over `context` (ph-clint-dev's\n * order: the Cli wins), its `prompts.skills` give the skill descriptions\n * and its `prompts.agents` the agent profiles; a `profiles.json` entry of\n * the same name replaces the Cli's.\n */\n cli?: { getMetadata(): CliMetadata };\n logger?: (msg: string) => void;\n}\n\nexport interface BuildSkillsResult {\n skills: number;\n profiles: number;\n copied: number;\n warnings: string[];\n outDir: string;\n}\n\nfunction firstExisting(\n rootDir: string,\n candidates: (string | undefined)[],\n): string[] {\n const dirs: string[] = [];\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(rootDir, candidate);\n if (fs.existsSync(abs)) dirs.push(abs);\n }\n return dirs;\n}\n\nfunction readProfilesManifest(include: string[]): AgentProfile[] {\n for (const dir of include) {\n const manifest = path.join(dir, \"profiles.json\");\n if (fs.existsSync(manifest)) {\n try {\n return JSON.parse(fs.readFileSync(manifest, \"utf8\")) as AgentProfile[];\n } catch {\n return [];\n }\n }\n }\n return [];\n}\n\nexport async function buildSkills(\n options: BuildSkillsOptions,\n): Promise<BuildSkillsResult> {\n const log = options.logger ?? console.log;\n const include = firstExisting(options.rootDir, [\n options.skillsDir,\n options.agentsDir,\n \"prompts\",\n \"agents\",\n ]);\n const outDir = path.resolve(options.rootDir, options.outDir ?? \"dist/skills\");\n\n if (include.length === 0) {\n log(\n \"No prompt template directories found (prompts/ or agents/) — nothing to build.\",\n );\n return { skills: 0, profiles: 0, copied: 0, warnings: [], outDir };\n }\n\n const meta = options.cli?.getMetadata();\n const skillDescriptions: Record<string, string> = {};\n for (const [id, skill] of Object.entries(meta?.prompts?.skills ?? {})) {\n skillDescriptions[id] =\n typeof skill === \"string\" ? skill : skill.description;\n }\n const manifestProfiles = readProfilesManifest(include);\n const agentProfiles = [\n ...Object.values(meta?.prompts?.agents ?? {})\n .filter((a) => !manifestProfiles.some((p) => p.name === a.name))\n .map(({ name, sections }) => ({ name, sections })),\n ...manifestProfiles,\n ];\n\n const resolved: ResolvedBuildConfig = {\n include,\n output: [outDir],\n context: { builtAt: new Date().toISOString(), ...options.context, ...meta },\n agentProfiles,\n skillDescriptions,\n clean: true,\n logger: log,\n };\n\n for (const dir of resolved.output) {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true });\n }\n\n const profiles = buildAgentProfiles(resolved);\n const templates = buildSkillTemplates(resolved);\n const copied = copyExternalSkills(resolved);\n\n return {\n skills: templates.count,\n profiles: profiles.count,\n copied,\n warnings: [...profiles.warnings, ...templates.warnings],\n outDir,\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,eACP,UACA,QACA,UACoB;CACpB,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,IAAI,KAAK,KAAK,KAAK,QAAQ,QAAQ;EACzC,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO;CAC/B;AAEF;;;;;;;AAQA,SAAgB,mBAAmB,QAGjC;CACA,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,OAAO;CACxB,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE,OAAO;EAAG,UAAU,CAAC;CAAE;CAE3D,MAAM,iBAAiB,OAAO,SAAS,YAAY;CAEnD,IAAI,uCAAuC;CAE3C,MAAM,cAAwB,CAAC;CAC/B,IAAI,QAAQ;CAEZ,KAAK,MAAM,WAAW,UAAU;EAE9B,MAAM,eAAyB,CAAC;EAChC,IAAI,UAAU;EACd,KAAK,MAAM,WAAW,QAAQ,UAAU;GACtC,MAAM,QAAQ,eAAe,OAAO,SAAS,gBAAgB,OAAO;GACpE,IAAI,CAAC,OAAO;IACV,IAAI,UAAU,QAAQ,KAAK,oBAAoB,SAAS;IACxD,UAAU;IACV;GACF;GACA,aAAa,KAAK,KAAK;EACzB;EACA,IAAI,SAAS;EAEb,MAAM,eAAe;GAAE,GAAG,OAAO;GAAS,WAAW,QAAQ;EAAK;EAClE,MAAM,aAAa,OAAO,gBACtB,EAAE,SAAS,OAAO,cAAc,IAChC,KAAA;EAEJ,MAAM,mBAA6B,CAAC;EACpC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,SAAS,QAAQ,KAAK;GAChD,MAAM,MAAM,GAAG,aAAa,aAAa,IAAI,OAAO;GACpD,MAAM,SAAS,oBAAoB,KAAK,cAAc,UAAU;GAChE,KAAK,MAAM,KAAK,OAAO,UAAU;IAC/B,MAAM,MAAM,GAAG,QAAQ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nD,GAAG,gBACL;CAEA,MAAM,WAAgC;EACpC;EACA,QAAQ,CAAC,MAAM;EACf,SAAS;GAAE,0BAAS,IAAI,KAAK,EAAA,CAAE,YAAY;GAAG,GAAG,QAAQ;GAAS,GAAG;EAAK;EAC1E;EACA;EACA,OAAO;EACP,QAAQ;CACV;CAEA,KAAK,MAAM,OAAO,SAAS,QACzB,IAAI,GAAG,WAAW,GAAG,GAAG,GAAG,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;CAG5D,MAAM,WAAW,mBAAmB,QAAQ;CAC5C,MAAM,YAAY,oBAAoB,QAAQ;CAC9C,MAAM,SAAS,mBAAmB,QAAQ;CAE1C,OAAO;EACL,QAAQ,UAAU;EAClB,UAAU,SAAS;EACnB;EACA,UAAU,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,QAAQ;EACtD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"build-skills-BTkuL8ne.mjs","names":[],"sources":["../src/dev/agent-profiles.ts","../src/dev/skill-builder.ts","../src/dev/skill-copier.ts","../src/dev/build-skills.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing file across multiple include directories.\n */\nfunction findInIncludes(\n includes: string[],\n subdir: string,\n filename: string,\n): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir, filename);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build agent profile instructions by rendering base+specialized template pairs.\n * Writes each profile as a Markdown file in {output}/agents/{ProfileName}.md.\n *\n * @returns Number of profiles built and any warnings.\n */\nexport function buildAgentProfiles(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const profiles = config.agentProfiles;\n if (profiles.length === 0) return { count: 0, warnings: [] };\n\n const profilesSubdir = config.subdirs?.profiles ?? \"agent-profiles\";\n\n log(\"\\n--- Building agent instructions ---\");\n\n const allWarnings: string[] = [];\n let count = 0;\n\n for (const profile of profiles) {\n // Check all section files exist before rendering\n const sectionPaths: string[] = [];\n let missing = false;\n for (const section of profile.sections) {\n const found = findInIncludes(config.include, profilesSubdir, section);\n if (!found) {\n log(` SKIP ${profile.name}: missing section ${section}`);\n missing = true;\n break;\n }\n sectionPaths.push(found);\n }\n if (missing) continue;\n\n const agentContext = { ...config.context, agentName: profile.name };\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n\n const renderedSections: string[] = [];\n for (let i = 0; i < profile.sections.length; i++) {\n const raw = fs.readFileSync(sectionPaths[i], \"utf-8\");\n const result = renderSkillTemplate(raw, agentContext, renderOpts);\n for (const w of result.warnings) {\n const msg = `${profile.name}/${profile.sections[i]}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n renderedSections.push(result.rendered.trim());\n }\n\n const combined = renderedSections.join(\"\\n\\n\") + \"\\n\";\n for (const out of config.output) {\n const agentsDir = path.join(out, \"agent-profiles\");\n fs.mkdirSync(agentsDir, { recursive: true });\n fs.writeFileSync(\n path.join(agentsDir, `${profile.name}.md`),\n combined,\n \"utf-8\",\n );\n }\n\n log(` OK ${profile.name} → ${profile.name}.md (${combined.length} chars)`);\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { renderSkillTemplate, slugToTitle } from \"../index.js\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Find the first existing directory across multiple include paths.\n */\nfunction findSubdir(includes: string[], subdir: string): string | undefined {\n for (const dir of includes) {\n const p = path.join(dir, subdir);\n if (fs.existsSync(p)) return p;\n }\n return undefined;\n}\n\n/**\n * Build SKILL.md files from Handlebars templates in skills-tpl/.\n * Each skill directory produces a SKILL.md + references/ folder.\n *\n * @returns Number of skills built and any warnings.\n */\nexport function buildSkillTemplates(config: ResolvedBuildConfig): {\n count: number;\n warnings: string[];\n} {\n const log = config.logger;\n const skillsTplSubdir = config.subdirs?.skillsTpl ?? \"skills-tpl\";\n const skillsTplDir = findSubdir(config.include, skillsTplSubdir);\n\n log(\"\\n--- Building SKILL.md files (templates) ---\");\n\n if (!skillsTplDir) {\n log(\" No skills-tpl/ directory — skipping.\");\n return { count: 0, warnings: [] };\n }\n\n const skillDirs = fs\n .readdirSync(skillsTplDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n const allWarnings: string[] = [];\n const renderOpts = config.customHelpers\n ? { helpers: config.customHelpers }\n : undefined;\n let count = 0;\n\n for (const skillName of skillDirs) {\n const skillDir = path.join(skillsTplDir, skillName);\n\n // Preamble\n const preamblePath = path.join(skillDir, \".preamble.md\");\n const preambleRaw = fs.existsSync(preamblePath)\n ? fs.readFileSync(preamblePath, \"utf-8\").trim()\n : \"\";\n let preamble = \"\";\n if (preambleRaw) {\n const r = renderSkillTemplate(preambleRaw, config.context, renderOpts);\n preamble = r.rendered;\n for (const w of r.warnings) {\n const msg = `${skillName}/.preamble.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n }\n\n // Scenario files (NN.name.md)\n const scenarioFiles = fs\n .readdirSync(skillDir)\n .filter((f) => /^\\d+\\..*\\.md$/.test(f))\n .sort();\n\n // Result file\n const resultPath = path.join(skillDir, \".result.md\");\n const hasResult = fs.existsSync(resultPath);\n\n if (!preamble && scenarioFiles.length === 0 && !hasResult) {\n log(` SKIP ${skillName}: no content files found`);\n continue;\n }\n\n // Render references into memory\n const files: Map<string, string> = new Map();\n const refLinks: string[] = [];\n\n for (const scenarioFile of scenarioFiles) {\n const content = fs\n .readFileSync(path.join(skillDir, scenarioFile), \"utf-8\")\n .trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/${scenarioFile}: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(path.join(\"references\", scenarioFile), r.rendered + \"\\n\");\n const label = slugToTitle(\n scenarioFile.replace(/^\\d+\\./, \"\").replace(/\\.md$/, \"\"),\n );\n refLinks.push(\n `* **${label}** [references/${scenarioFile}](references/${scenarioFile})`,\n );\n }\n\n if (hasResult) {\n const content = fs.readFileSync(resultPath, \"utf-8\").trim();\n const r = renderSkillTemplate(content, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.result.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\n path.join(\"references\", \"expected-outcome.md\"),\n r.rendered + \"\\n\",\n );\n refLinks.push(\n `* **Expected Outcome** [references/expected-outcome.md](references/expected-outcome.md)`,\n );\n }\n\n // Build SKILL.md\n const description =\n config.skillDescriptions[skillName] ?? `${slugToTitle(skillName)} tasks`;\n\n const frontmatter = [\n \"---\",\n `name: ${skillName}`,\n `description: \"${description}\"`,\n \"metadata:\",\n \" author: Powerhouse\",\n ' version: \"1.0.0\"',\n \"---\",\n ].join(\"\\n\");\n\n const sections = [preamble];\n if (refLinks.length > 0) {\n sections.push(\"## Specific tasks\\n\\n\" + refLinks.join(\"\\n\"));\n }\n\n const skillMd =\n frontmatter + \"\\n\\n\" + sections.filter(Boolean).join(\"\\n\\n\") + \"\\n\";\n files.set(\"SKILL.md\", skillMd);\n\n // Copy .cli-docs.md if present (render through Handlebars)\n const cliDocsPath = path.join(skillDir, \".cli-docs.md\");\n if (fs.existsSync(cliDocsPath)) {\n const cliDocsRaw = fs.readFileSync(cliDocsPath, \"utf-8\").trim();\n if (cliDocsRaw) {\n const r = renderSkillTemplate(cliDocsRaw, config.context, renderOpts);\n for (const w of r.warnings) {\n const msg = `${skillName}/.cli-docs.md: ${w}`;\n allWarnings.push(msg);\n log(` WARN ${msg}`);\n }\n files.set(\".cli-docs.md\", r.rendered + \"\\n\");\n }\n }\n\n // Write to all output directories\n for (const out of config.output) {\n const outputDir = path.join(out, \"skills\", skillName);\n for (const [relPath, content] of files) {\n const fullPath = path.join(outputDir, relPath);\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content, \"utf-8\");\n }\n }\n\n log(\n ` OK ${skillName} → SKILL.md + ${scenarioFiles.length + (hasResult ? 1 : 0)} references (${skillMd.length} chars)`,\n );\n count++;\n }\n\n return { count, warnings: allWarnings };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ResolvedBuildConfig } from \"./types.js\";\n\n/**\n * Copy external skills from skills-ext/ to the output directory without processing.\n *\n * @returns Number of skills copied.\n */\nexport function copyExternalSkills(config: ResolvedBuildConfig): number {\n const log = config.logger;\n const skillsExtSubdir = config.subdirs?.skillsExt ?? \"skills-ext\";\n\n log(\"\\n--- Copying external skills ---\");\n\n // Search all include dirs for skills-ext/\n let found = false;\n let total = 0;\n\n for (const dir of config.include) {\n const skillsExtDir = path.join(dir, skillsExtSubdir);\n if (!fs.existsSync(skillsExtDir)) continue;\n found = true;\n\n const skillDirs = fs\n .readdirSync(skillsExtDir, { withFileTypes: true })\n .filter((d) => d.isDirectory())\n .map((d) => d.name)\n .sort();\n\n for (const skillName of skillDirs) {\n const srcDir = path.join(skillsExtDir, skillName);\n for (const out of config.output) {\n fs.cpSync(srcDir, path.join(out, \"skills\", skillName), {\n recursive: true,\n });\n }\n log(` OK ${skillName} → copied as-is`);\n }\n\n total += skillDirs.length;\n }\n\n if (!found) {\n log(\" No skills-ext/ directory — skipping.\");\n }\n\n return total;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { buildAgentProfiles } from \"./agent-profiles.js\";\nimport { buildSkillTemplates } from \"./skill-builder.js\";\nimport { copyExternalSkills } from \"./skill-copier.js\";\nimport type { AgentProfile, ResolvedBuildConfig } from \"./types.js\";\nimport type { CliMetadata } from \"../core/types.js\";\n\n/**\n * Path-driven skill/profile compilation (ph-clint-dev's pipeline). The paths\n * drive it; a package's `Cli` is an optional extra source (`cli`): its\n * metadata joins the template context as ph-clint-dev did it, so a template\n * can name `{{commands.<id>.description}}` or `{{services.<id>.name}}`.\n * Conventions:\n *\n * <skillsDir>/ include root (default: prompts/ then agents/)\n * agent-profiles/ profile section templates\n * skills-tpl/<skill>/ Handlebars skill templates → SKILL.md\n * skills-ext/<skill>/ external skills copied as-is\n * profiles.json optional [{ name, sections: [...] }]\n *\n * Output: <outDir> (default: dist/skills).\n */\nexport interface BuildSkillsOptions {\n rootDir: string;\n skillsDir?: string;\n agentsDir?: string;\n outDir?: string;\n context?: Record<string, unknown>;\n /**\n * The package's `Cli` (see `loadCli`). Only `getMetadata()` is read, which\n * starts nothing. Its metadata is spread over `context` (ph-clint-dev's\n * order: the Cli wins), its `prompts.skills` give the skill descriptions\n * and its `prompts.agents` the agent profiles; a `profiles.json` entry of\n * the same name replaces the Cli's.\n */\n cli?: { getMetadata(): CliMetadata };\n logger?: (msg: string) => void;\n}\n\nexport interface BuildSkillsResult {\n skills: number;\n profiles: number;\n copied: number;\n warnings: string[];\n outDir: string;\n}\n\nfunction firstExisting(\n rootDir: string,\n candidates: (string | undefined)[],\n): string[] {\n const dirs: string[] = [];\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(rootDir, candidate);\n if (fs.existsSync(abs)) dirs.push(abs);\n }\n return dirs;\n}\n\nfunction readProfilesManifest(include: string[]): AgentProfile[] {\n for (const dir of include) {\n const manifest = path.join(dir, \"profiles.json\");\n if (fs.existsSync(manifest)) {\n try {\n return JSON.parse(fs.readFileSync(manifest, \"utf8\")) as AgentProfile[];\n } catch {\n return [];\n }\n }\n }\n return [];\n}\n\nexport async function buildSkills(\n options: BuildSkillsOptions,\n): Promise<BuildSkillsResult> {\n const log = options.logger ?? console.log;\n const include = firstExisting(options.rootDir, [\n options.skillsDir,\n options.agentsDir,\n \"prompts\",\n \"agents\",\n ]);\n const outDir = path.resolve(options.rootDir, options.outDir ?? \"dist/skills\");\n\n if (include.length === 0) {\n log(\n \"No prompt template directories found (prompts/ or agents/) — nothing to build.\",\n );\n return { skills: 0, profiles: 0, copied: 0, warnings: [], outDir };\n }\n\n const meta = options.cli?.getMetadata();\n const skillDescriptions: Record<string, string> = {};\n for (const [id, skill] of Object.entries(meta?.prompts?.skills ?? {})) {\n skillDescriptions[id] =\n typeof skill === \"string\" ? skill : skill.description;\n }\n const manifestProfiles = readProfilesManifest(include);\n const agentProfiles = [\n ...Object.values(meta?.prompts?.agents ?? {})\n .filter((a) => !manifestProfiles.some((p) => p.name === a.name))\n .map(({ name, sections }) => ({ name, sections })),\n ...manifestProfiles,\n ];\n\n const resolved: ResolvedBuildConfig = {\n include,\n output: [outDir],\n context: { builtAt: new Date().toISOString(), ...options.context, ...meta },\n agentProfiles,\n skillDescriptions,\n clean: true,\n logger: log,\n };\n\n for (const dir of resolved.output) {\n if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true });\n }\n\n const profiles = buildAgentProfiles(resolved);\n const templates = buildSkillTemplates(resolved);\n const copied = copyExternalSkills(resolved);\n\n return {\n skills: templates.count,\n profiles: profiles.count,\n copied,\n warnings: [...profiles.warnings, ...templates.warnings],\n outDir,\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,eACP,UACA,QACA,UACoB;CACpB,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,IAAI,KAAK,KAAK,KAAK,QAAQ,QAAQ;EACzC,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO;CAC/B;AAEF;;;;;;;AAQA,SAAgB,mBAAmB,QAGjC;CACA,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,OAAO;CACxB,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE,OAAO;EAAG,UAAU,CAAC;CAAE;CAE3D,MAAM,iBAAiB,OAAO,SAAS,YAAY;CAEnD,IAAI,uCAAuC;CAE3C,MAAM,cAAwB,CAAC;CAC/B,IAAI,QAAQ;CAEZ,KAAK,MAAM,WAAW,UAAU;EAE9B,MAAM,eAAyB,CAAC;EAChC,IAAI,UAAU;EACd,KAAK,MAAM,WAAW,QAAQ,UAAU;GACtC,MAAM,QAA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+
import { MAX_LINE_BYTES, callControl } from "@powerhousedao/host-core/control-channel";
|
|
6
|
+
//#region src/core/command-control.ts
|
|
7
|
+
/**
|
|
8
|
+
* A CLI's commands over the control channel of the instance that keeps
|
|
9
|
+
* running. A command that needs the reactor or the agent, typed in a second
|
|
10
|
+
* terminal, is sent to that instance ({@link sendCommand}); the instance runs
|
|
11
|
+
* it with what it holds and sends the output and the exit code back
|
|
12
|
+
* ({@link serveCommands}). The calling process starts no reactor and no agent.
|
|
13
|
+
*/
|
|
14
|
+
/** The method of the control channel that runs a command. */
|
|
15
|
+
const COMMAND_METHOD = "command";
|
|
16
|
+
/** What the calling process sends. */
|
|
17
|
+
const commandRequestSchema = z.strictObject({
|
|
18
|
+
/** The CLI the caller is, and its version. */
|
|
19
|
+
cli: z.string().min(1),
|
|
20
|
+
version: z.string(),
|
|
21
|
+
/** The command's id, with its input as the caller's command line gave it
|
|
22
|
+
* (the instance validates it). Without one, `prompt` goes to the agent. */
|
|
23
|
+
command: z.string().min(1).optional(),
|
|
24
|
+
input: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
prompt: z.string().min(1).optional(),
|
|
26
|
+
/** The thread a prompt or a skill continues (`--resume`). */
|
|
27
|
+
resume: z.string().min(1).optional(),
|
|
28
|
+
/** The caller's working folder, and where it stands. */
|
|
29
|
+
workdir: z.string().min(1),
|
|
30
|
+
cwd: z.string().min(1),
|
|
31
|
+
/** How the caller shows output. */
|
|
32
|
+
tty: z.boolean(),
|
|
33
|
+
columns: z.number().int().positive().optional(),
|
|
34
|
+
color: z.boolean(),
|
|
35
|
+
verbose: z.boolean().optional(),
|
|
36
|
+
/** What was piped to the caller, for a command that reads it. */
|
|
37
|
+
stdin: z.string().optional(),
|
|
38
|
+
/** The caller's OS user and process, for the log. */
|
|
39
|
+
caller: z.strictObject({
|
|
40
|
+
user: z.string(),
|
|
41
|
+
pid: z.number().int().nonnegative()
|
|
42
|
+
}),
|
|
43
|
+
/**
|
|
44
|
+
* Whom the caller signs the command's actions as, when it knew already;
|
|
45
|
+
* otherwise the instance asks (`signer`). A claim: the signatures prove
|
|
46
|
+
* the key, the credential the address.
|
|
47
|
+
*/
|
|
48
|
+
signer: z.strictObject({
|
|
49
|
+
user: z.strictObject({
|
|
50
|
+
address: z.string().min(1),
|
|
51
|
+
networkId: z.string(),
|
|
52
|
+
chainId: z.number().int()
|
|
53
|
+
}),
|
|
54
|
+
app: z.strictObject({
|
|
55
|
+
name: z.string(),
|
|
56
|
+
key: z.string().min(1)
|
|
57
|
+
})
|
|
58
|
+
}).optional()
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Where a serving instance's writes are checked (its `hello` says): the
|
|
62
|
+
* switchboard's base URL, and its data folder when the caller may write its
|
|
63
|
+
* credential's record there.
|
|
64
|
+
*/
|
|
65
|
+
const commandStoreSchema = z.object({
|
|
66
|
+
url: z.string().min(1).optional(),
|
|
67
|
+
dataDir: z.string().min(1).optional()
|
|
68
|
+
});
|
|
69
|
+
const LOOPBACK = /^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|::1)$/i;
|
|
70
|
+
/**
|
|
71
|
+
* The store a reactor at `reactorUrl` writes to: its base URL (the address up
|
|
72
|
+
* to `/graphql` or `/d/<drive>`), and `dataDir` when it listens on this
|
|
73
|
+
* machine, where it is taken to be the project's own switchboard. A record
|
|
74
|
+
* written in the wrong folder is a public proof that nobody reads.
|
|
75
|
+
*/
|
|
76
|
+
function commandStoreOf(reactorUrl, dataDir) {
|
|
77
|
+
let url;
|
|
78
|
+
try {
|
|
79
|
+
url = new URL(reactorUrl);
|
|
80
|
+
} catch {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
const cut = url.pathname.search(/\/(graphql|d)(\/|$)/);
|
|
84
|
+
return {
|
|
85
|
+
url: `${url.origin}${cut === -1 ? url.pathname.replace(/\/$/, "") : url.pathname.slice(0, cut)}`,
|
|
86
|
+
...LOOPBACK.test(url.hostname) ? { dataDir } : {}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const resultSchema = z.object({ exitCode: z.number().int() });
|
|
90
|
+
const sameFolder = (a, b) => {
|
|
91
|
+
const [left, right] = [path.resolve(a), path.resolve(b)];
|
|
92
|
+
return process.platform === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Who a forwarded command acts as, as its request names it: the address and
|
|
96
|
+
* session it signs with. Undefined when the request names none (the caller
|
|
97
|
+
* is asked at the first write, or cannot sign).
|
|
98
|
+
*/
|
|
99
|
+
function callerIdentityOf(request) {
|
|
100
|
+
const { signer } = request;
|
|
101
|
+
return signer ? {
|
|
102
|
+
address: signer.user.address,
|
|
103
|
+
label: signer.app.name,
|
|
104
|
+
key: signer.app.key
|
|
105
|
+
} : void 0;
|
|
106
|
+
}
|
|
107
|
+
function callerOf(request) {
|
|
108
|
+
const identity = callerIdentityOf(request);
|
|
109
|
+
return {
|
|
110
|
+
user: request.caller.user,
|
|
111
|
+
pid: request.caller.pid,
|
|
112
|
+
cwd: request.cwd,
|
|
113
|
+
tty: request.tty,
|
|
114
|
+
...request.columns === void 0 ? {} : { columns: request.columns },
|
|
115
|
+
color: request.color,
|
|
116
|
+
...identity ? { identity } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Answers `command` on `channel`: `run` executes one and resolves with its
|
|
121
|
+
* exit code. A request of another CLI, or for another working folder than
|
|
122
|
+
* the instance's, is refused before anything runs.
|
|
123
|
+
*/
|
|
124
|
+
function serveCommands(channel, cli, run) {
|
|
125
|
+
channel.describe({
|
|
126
|
+
cli: cli.name,
|
|
127
|
+
version: cli.version,
|
|
128
|
+
signing: 1,
|
|
129
|
+
...cli.store ? { store: cli.store } : {}
|
|
130
|
+
});
|
|
131
|
+
channel.handle(COMMAND_METHOD, async (params, call) => {
|
|
132
|
+
const parsed = commandRequestSchema.safeParse(params);
|
|
133
|
+
if (!parsed.success) throw new Error(`Bad command request: ${parsed.error.issues.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`).join("; ")}`);
|
|
134
|
+
const request = parsed.data;
|
|
135
|
+
if (request.cli !== cli.name) throw new Error(`This is a running ${cli.name}; it runs no commands of "${request.cli}".`);
|
|
136
|
+
if (!sameFolder(request.workdir, cli.workdir)) throw new Error(`This ${cli.name} works in ${cli.workdir}; the command is for ${request.workdir}.`);
|
|
137
|
+
if (request.command === void 0 === (request.prompt === void 0)) throw new Error("Bad command request: one of `command` and `prompt` is needed.");
|
|
138
|
+
return { exitCode: await run({
|
|
139
|
+
request,
|
|
140
|
+
caller: callerOf(request),
|
|
141
|
+
signal: call.signal,
|
|
142
|
+
stdout: (text) => call.write("stdout", text),
|
|
143
|
+
stderr: (text) => call.write("stderr", text),
|
|
144
|
+
asks: call.asks,
|
|
145
|
+
ask: (kind, payload) => call.ask(kind, payload)
|
|
146
|
+
}) };
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/** Thrown when a request is too long to send; the message says what to do. */
|
|
150
|
+
var CommandTooLarge = class extends Error {
|
|
151
|
+
constructor(what, hasStdin) {
|
|
152
|
+
super(`${what} was not sent to the running instance: with its input it is longer than a request may be (${Math.floor(MAX_LINE_BYTES / 1024)} KiB).` + (hasStdin ? " Its piped input is sent along; pass a large input as a file instead." : ""));
|
|
153
|
+
this.name = "CommandTooLarge";
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** The caller's side of a request: this process, and how it shows output. */
|
|
157
|
+
function describeCaller() {
|
|
158
|
+
const tty = process.stdout.isTTY === true;
|
|
159
|
+
const { columns } = process.stdout;
|
|
160
|
+
let user = "";
|
|
161
|
+
try {
|
|
162
|
+
user = os.userInfo().username;
|
|
163
|
+
} catch {}
|
|
164
|
+
return {
|
|
165
|
+
cwd: process.cwd(),
|
|
166
|
+
tty,
|
|
167
|
+
...tty && typeof columns === "number" && columns > 0 ? { columns } : {},
|
|
168
|
+
color: process.env.FORCE_COLOR !== void 0 ? process.env.FORCE_COLOR !== "0" : tty && process.env.NO_COLOR === void 0,
|
|
169
|
+
caller: {
|
|
170
|
+
user,
|
|
171
|
+
pid: process.pid
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Runs `request` in the instance behind `control`: its output goes to
|
|
177
|
+
* `stdout` and `stderr` as it arrives, and the promise resolves with the
|
|
178
|
+
* command's exit code. Aborting `signal` cancels the command there. Rejects
|
|
179
|
+
* with a `ControlError` as `callControl` does, or {@link CommandTooLarge}
|
|
180
|
+
* before anything is sent.
|
|
181
|
+
*/
|
|
182
|
+
async function sendCommand(control, request, io) {
|
|
183
|
+
if (Buffer.byteLength(JSON.stringify(request)) > MAX_LINE_BYTES - 1024) throw new CommandTooLarge(request.command ?? "The prompt", request.stdin !== void 0);
|
|
184
|
+
const result = await callControl(control, COMMAND_METHOD, request, {
|
|
185
|
+
onOutput: (stream, data) => stream === "stdout" ? io.stdout(data) : io.stderr(data),
|
|
186
|
+
...io.signal ? { signal: io.signal } : {},
|
|
187
|
+
...io.onAsk && io.asks ? {
|
|
188
|
+
onAsk: io.onAsk,
|
|
189
|
+
asks: io.asks
|
|
190
|
+
} : {}
|
|
191
|
+
});
|
|
192
|
+
const parsed = resultSchema.safeParse(result);
|
|
193
|
+
return parsed.success ? parsed.data.exitCode : 1;
|
|
194
|
+
}
|
|
195
|
+
/** Everything `stream` delivers until it ends, as text. */
|
|
196
|
+
async function readToEnd(stream) {
|
|
197
|
+
const chunks = [];
|
|
198
|
+
for await (const chunk of stream) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
199
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
200
|
+
}
|
|
201
|
+
/** What is piped to this process; undefined when stdin is a terminal. */
|
|
202
|
+
function readPipedStdin() {
|
|
203
|
+
if (process.stdin.isTTY) return Promise.resolve(void 0);
|
|
204
|
+
return readToEnd(process.stdin);
|
|
205
|
+
}
|
|
206
|
+
/** Resolves or rejects as `work` does, or rejects once `signal` aborts. */
|
|
207
|
+
function untilAborted(work, signal) {
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
const stop = () => reject(/* @__PURE__ */ new Error("The command was cancelled."));
|
|
210
|
+
if (signal.aborted) {
|
|
211
|
+
work.catch(() => void 0);
|
|
212
|
+
stop();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
216
|
+
work.then(resolve, reject).finally(() => {
|
|
217
|
+
signal.removeEventListener("abort", stop);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
export { commandStoreOf as a, readPipedStdin as c, untilAborted as d, commandRequestSchema as i, sendCommand as l, CommandTooLarge as n, commandStoreSchema as o, callerIdentityOf as r, describeCaller as s, COMMAND_METHOD as t, serveCommands as u };
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=command-control-Dp41aY0o.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-control-Dp41aY0o.mjs","names":[],"sources":["../src/core/command-control.ts"],"sourcesContent":["import {\n callControl,\n MAX_LINE_BYTES,\n type CallControlOptions,\n type ControlCall,\n type ControlChannel,\n type ControlRecord,\n} from \"@powerhousedao/host-core/control-channel\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\nimport { COMMAND_SIGNING } from \"./forwarded-signing.js\";\nimport type { CallerIdentity, CommandCaller } from \"./types.js\";\n\n/**\n * A CLI's commands over the control channel of the instance that keeps\n * running. A command that needs the reactor or the agent, typed in a second\n * terminal, is sent to that instance ({@link sendCommand}); the instance runs\n * it with what it holds and sends the output and the exit code back\n * ({@link serveCommands}). The calling process starts no reactor and no agent.\n */\n\n/** The method of the control channel that runs a command. */\nexport const COMMAND_METHOD = \"command\";\n\n/** What the calling process sends. */\nexport const commandRequestSchema = z.strictObject({\n /** The CLI the caller is, and its version. */\n cli: z.string().min(1),\n version: z.string(),\n /** The command's id, with its input as the caller's command line gave it\n * (the instance validates it). Without one, `prompt` goes to the agent. */\n command: z.string().min(1).optional(),\n input: z.record(z.string(), z.unknown()).optional(),\n prompt: z.string().min(1).optional(),\n /** The thread a prompt or a skill continues (`--resume`). */\n resume: z.string().min(1).optional(),\n /** The caller's working folder, and where it stands. */\n workdir: z.string().min(1),\n cwd: z.string().min(1),\n /** How the caller shows output. */\n tty: z.boolean(),\n columns: z.number().int().positive().optional(),\n color: z.boolean(),\n verbose: z.boolean().optional(),\n /** What was piped to the caller, for a command that reads it. */\n stdin: z.string().optional(),\n /** The caller's OS user and process, for the log. */\n caller: z.strictObject({\n user: z.string(),\n pid: z.number().int().nonnegative(),\n }),\n /**\n * Whom the caller signs the command's actions as, when it knew already;\n * otherwise the instance asks (`signer`). A claim: the signatures prove\n * the key, the credential the address.\n */\n signer: z\n .strictObject({\n user: z.strictObject({\n address: z.string().min(1),\n networkId: z.string(),\n chainId: z.number().int(),\n }),\n app: z.strictObject({ name: z.string(), key: z.string().min(1) }),\n })\n .optional(),\n});\nexport type CommandRequest = z.infer<typeof commandRequestSchema>;\n\n/**\n * Where a serving instance's writes are checked (its `hello` says): the\n * switchboard's base URL, and its data folder when the caller may write its\n * credential's record there.\n */\nexport const commandStoreSchema = z.object({\n url: z.string().min(1).optional(),\n dataDir: z.string().min(1).optional(),\n});\nexport type CommandStore = z.infer<typeof commandStoreSchema>;\n\nconst LOOPBACK = /^(localhost|127(?:\\.\\d{1,3}){3}|\\[::1\\]|::1)$/i;\n\n/**\n * The store a reactor at `reactorUrl` writes to: its base URL (the address up\n * to `/graphql` or `/d/<drive>`), and `dataDir` when it listens on this\n * machine, where it is taken to be the project's own switchboard. A record\n * written in the wrong folder is a public proof that nobody reads.\n */\nexport function commandStoreOf(\n reactorUrl: string,\n dataDir: string,\n): CommandStore {\n let url: URL;\n try {\n url = new URL(reactorUrl);\n } catch {\n return {};\n }\n const cut = url.pathname.search(/\\/(graphql|d)(\\/|$)/);\n const base = `${url.origin}${cut === -1 ? url.pathname.replace(/\\/$/, \"\") : url.pathname.slice(0, cut)}`;\n return {\n url: base,\n ...(LOOPBACK.test(url.hostname) ? { dataDir } : {}),\n };\n}\n\nconst resultSchema = z.object({ exitCode: z.number().int() });\n\n/** One command an instance runs for a caller. */\nexport interface ForwardedCommand {\n request: CommandRequest;\n caller: CommandCaller;\n /** Aborted when the caller cancels or goes away. */\n signal: AbortSignal;\n /** Raw output to the caller's stdout and stderr. */\n stdout(text: string): void;\n stderr(text: string): void;\n /** What the caller answers while the command runs (`ControlCall.asks`). */\n asks: ReadonlySet<string>;\n /** Asks the caller (`ControlCall.ask`). */\n ask(kind: string, payload?: unknown): Promise<unknown>;\n}\n\nconst sameFolder = (a: string, b: string) => {\n const [left, right] = [path.resolve(a), path.resolve(b)];\n return process.platform === \"win32\"\n ? left.toLowerCase() === right.toLowerCase()\n : left === right;\n};\n\n/**\n * Who a forwarded command acts as, as its request names it: the address and\n * session it signs with. Undefined when the request names none (the caller\n * is asked at the first write, or cannot sign).\n */\nexport function callerIdentityOf(\n request: CommandRequest,\n): CallerIdentity | undefined {\n const { signer } = request;\n return signer\n ? {\n address: signer.user.address,\n label: signer.app.name,\n key: signer.app.key,\n }\n : undefined;\n}\n\nfunction callerOf(request: CommandRequest): CommandCaller {\n const identity = callerIdentityOf(request);\n return {\n user: request.caller.user,\n pid: request.caller.pid,\n cwd: request.cwd,\n tty: request.tty,\n ...(request.columns === undefined ? {} : { columns: request.columns }),\n color: request.color,\n ...(identity ? { identity } : {}),\n };\n}\n\n/**\n * Answers `command` on `channel`: `run` executes one and resolves with its\n * exit code. A request of another CLI, or for another working folder than\n * the instance's, is refused before anything runs.\n */\nexport function serveCommands(\n channel: ControlChannel,\n cli: { name: string; version: string; workdir: string; store?: CommandStore },\n run: (command: ForwardedCommand) => Promise<number>,\n): void {\n channel.describe({\n cli: cli.name,\n version: cli.version,\n signing: COMMAND_SIGNING,\n ...(cli.store ? { store: cli.store } : {}),\n });\n channel.handle(COMMAND_METHOD, async (params: unknown, call: ControlCall) => {\n const parsed = commandRequestSchema.safeParse(params);\n if (!parsed.success) {\n throw new Error(\n `Bad command request: ${parsed.error.issues.map((i) => `${i.path.join(\".\") || \"<root>\"}: ${i.message}`).join(\"; \")}`,\n );\n }\n const request = parsed.data;\n if (request.cli !== cli.name) {\n throw new Error(\n `This is a running ${cli.name}; it runs no commands of \"${request.cli}\".`,\n );\n }\n if (!sameFolder(request.workdir, cli.workdir)) {\n throw new Error(\n `This ${cli.name} works in ${cli.workdir}; the command is for ${request.workdir}.`,\n );\n }\n if ((request.command === undefined) === (request.prompt === undefined)) {\n throw new Error(\n \"Bad command request: one of `command` and `prompt` is needed.\",\n );\n }\n const exitCode = await run({\n request,\n caller: callerOf(request),\n signal: call.signal,\n stdout: (text) => call.write(\"stdout\", text),\n stderr: (text) => call.write(\"stderr\", text),\n asks: call.asks,\n ask: (kind, payload) => call.ask(kind, payload),\n });\n return { exitCode };\n });\n}\n\n/** Thrown when a request is too long to send; the message says what to do. */\nexport class CommandTooLarge extends Error {\n constructor(what: string, hasStdin: boolean) {\n super(\n `${what} was not sent to the running instance: with its input it is longer than a request may be (${Math.floor(MAX_LINE_BYTES / 1024)} KiB).` +\n (hasStdin\n ? \" Its piped input is sent along; pass a large input as a file instead.\"\n : \"\"),\n );\n this.name = \"CommandTooLarge\";\n }\n}\n\n/** The caller's side of a request: this process, and how it shows output. */\nexport function describeCaller(): Pick<\n CommandRequest,\n \"cwd\" | \"tty\" | \"columns\" | \"color\" | \"caller\"\n> {\n const tty = process.stdout.isTTY === true;\n const { columns } = process.stdout;\n let user = \"\";\n try {\n user = os.userInfo().username;\n } catch {\n // no entry for this uid; the pid still names the caller\n }\n return {\n cwd: process.cwd(),\n tty,\n ...(tty && typeof columns === \"number\" && columns > 0 ? { columns } : {}),\n color:\n process.env.FORCE_COLOR !== undefined\n ? process.env.FORCE_COLOR !== \"0\"\n : tty && process.env.NO_COLOR === undefined,\n caller: { user, pid: process.pid },\n };\n}\n\n/**\n * Runs `request` in the instance behind `control`: its output goes to\n * `stdout` and `stderr` as it arrives, and the promise resolves with the\n * command's exit code. Aborting `signal` cancels the command there. Rejects\n * with a `ControlError` as `callControl` does, or {@link CommandTooLarge}\n * before anything is sent.\n */\nexport async function sendCommand(\n control: ControlRecord,\n request: CommandRequest,\n io: {\n stdout: (text: string) => void;\n stderr: (text: string) => void;\n signal?: AbortSignal;\n /** Answers what the instance asks while the command runs. */\n onAsk?: CallControlOptions[\"onAsk\"];\n asks?: readonly string[];\n },\n): Promise<number> {\n // The line also holds the token and the envelope.\n if (Buffer.byteLength(JSON.stringify(request)) > MAX_LINE_BYTES - 1024) {\n throw new CommandTooLarge(\n request.command ?? \"The prompt\",\n request.stdin !== undefined,\n );\n }\n const result = await callControl(control, COMMAND_METHOD, request, {\n onOutput: (stream, data) =>\n stream === \"stdout\" ? io.stdout(data) : io.stderr(data),\n ...(io.signal ? { signal: io.signal } : {}),\n ...(io.onAsk && io.asks ? { onAsk: io.onAsk, asks: io.asks } : {}),\n });\n const parsed = resultSchema.safeParse(result);\n return parsed.success ? parsed.data.exitCode : 1;\n}\n\n/** Everything `stream` delivers until it ends, as text. */\nexport async function readToEnd(\n stream: NodeJS.ReadableStream,\n): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n }\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\n/** What is piped to this process; undefined when stdin is a terminal. */\nexport function readPipedStdin(): Promise<string | undefined> {\n if (process.stdin.isTTY) return Promise.resolve(undefined);\n return readToEnd(process.stdin);\n}\n\n/** Resolves or rejects as `work` does, or rejects once `signal` aborts. */\nexport function untilAborted<T>(\n work: Promise<T>,\n signal: AbortSignal,\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const stop = () => reject(new Error(\"The command was cancelled.\"));\n if (signal.aborted) {\n // `work` runs on without a listener for its end.\n work.catch(() => undefined);\n stop();\n return;\n }\n signal.addEventListener(\"abort\", stop, { once: true });\n work.then(resolve, reject).finally(() => {\n signal.removeEventListener(\"abort\", stop);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAa,iBAAiB;;AAG9B,MAAa,uBAAuB,EAAE,aAAa;;CAEjD,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACrB,SAAS,EAAE,OAAO;;;CAGlB,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CACpC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS;CAClD,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;CAEnC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;CAEnC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;;CAErB,KAAK,EAAE,QAAQ;CACf,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;CAC9C,OAAO,EAAE,QAAQ;CACjB,SAAS,EAAE,QAAQ,CAAC,CAAC,SAAS;;CAE9B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;;CAE3B,QAAQ,EAAE,aAAa;EACrB,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CACpC,CAAC;;;;;;CAMD,QAAQ,EACL,aAAa;EACZ,MAAM,EAAE,aAAa;GACnB,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;GACzB,WAAW,EAAE,OAAO;GACpB,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI;EAC1B,CAAC;EACD,KAAK,EAAE,aAAa;GAAE,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B;CACjB,MAAM,SAAmB,CAAC;CAC1B,WAAW,MAAM,SAAS,QACxB,OAAO,KAAK,OAAO,UAAU,WAAW,OAAO,KAAK,KAAK,IAAI,KAAK;CAEpE,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAM;AAC9C;;AAGA,SAAgB,iBAA8C;CAC5D,IAAI,QAAQ,MAAM,OAAO,OAAO,QAAQ,QAAQ,KAAA,CAAS;CACzD,OAAO,UAAU,QAAQ,KAAK;AAChC;;AAGA,SAAgB,aACd,MACA,QACY;CACZ,OAAO,IAAI,SAAY,SAAS,WAAW;EACzC,MAAM,aAAa,uBAAO,IAAI,MAAM,4BAA4B,CAAC;EACjE,IAAI,OAAO,SAAS;GAElB,KAAK,YAAY,KAAA,CAAS;GAC1B,KAAK;GACL;EACF;EACA,OAAO,iBAAiB,SAAS,MAAM,EAAE,MAAM,KAAK,CAAC;EACrD,KAAK,KAAK,SAAS,MAAM,CAAC,CAAC,cAAc;GACvC,OAAO,oBAAoB,SAAS,IAAI;EAC1C,CAAC;CACH,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as buildAuthHeaders, d as AttachmentPending, f as AttachmentTransferError, g as SizeMismatch, h as ReservationNotFound, l as AttachmentAlreadyExists, p as HashMismatch, u as AttachmentNotFound, v as createRef, y as parseRef } from "./powerhouse-
|
|
1
|
+
import { _ as buildAuthHeaders, d as AttachmentPending, f as AttachmentTransferError, g as SizeMismatch, h as ReservationNotFound, l as AttachmentAlreadyExists, p as HashMismatch, u as AttachmentNotFound, v as createRef, y as parseRef } from "./powerhouse-C4O-raTW.mjs";
|
|
2
2
|
import "node:fs";
|
|
3
3
|
import "node:path";
|
|
4
4
|
import "node:crypto";
|
|
@@ -652,4 +652,4 @@ function createRemoteAttachmentService(config) {
|
|
|
652
652
|
//#endregion
|
|
653
653
|
export { createRemoteAttachmentService };
|
|
654
654
|
|
|
655
|
-
//# sourceMappingURL=dist-
|
|
655
|
+
//# sourceMappingURL=dist-BTVqrpN4.mjs.map
|