@powerhousedao/clint 0.0.0-stage → 6.2.3-dev.56
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/LICENSE +661 -0
- package/dist/build-skills-CZ9W1mzT.mjs +293 -0
- package/dist/build-skills-CZ9W1mzT.mjs.map +1 -0
- package/dist/dist-Bkncsczn.mjs +1628 -0
- package/dist/dist-Bkncsczn.mjs.map +1 -0
- package/dist/drive-CNCPoCNs.mjs +82 -0
- package/dist/drive-CNCPoCNs.mjs.map +1 -0
- package/dist/esm-QcrYJquX.mjs +13140 -0
- package/dist/esm-QcrYJquX.mjs.map +1 -0
- package/dist/events-DkzJFZeW.mjs +237 -0
- package/dist/events-DkzJFZeW.mjs.map +1 -0
- package/dist/folders-mLL9D5Ck.mjs +254 -0
- package/dist/folders-mLL9D5Ck.mjs.map +1 -0
- package/dist/index.d.mts +1005 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/local-signer-EFzJV3bn.mjs +128 -0
- package/dist/local-signer-EFzJV3bn.mjs.map +1 -0
- package/dist/markdown-C1TFXoB6.mjs +275 -0
- package/dist/markdown-C1TFXoB6.mjs.map +1 -0
- package/dist/reactor-BoCnlaAa.mjs +51 -0
- package/dist/reactor-BoCnlaAa.mjs.map +1 -0
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/runners/clint-runner.d.mts +109 -0
- package/dist/runners/clint-runner.d.mts.map +1 -0
- package/dist/runners/clint-runner.mjs +202 -0
- package/dist/runners/clint-runner.mjs.map +1 -0
- package/dist/runners/mastra-runner.d.mts +100 -0
- package/dist/runners/mastra-runner.d.mts.map +1 -0
- package/dist/runners/mastra-runner.mjs +309 -0
- package/dist/runners/mastra-runner.mjs.map +1 -0
- package/dist/services-BvLvP5Qh.mjs +1210 -0
- package/dist/services-BvLvP5Qh.mjs.map +1 -0
- package/dist/src-BlXB-Yec.mjs +5061 -0
- package/dist/src-BlXB-Yec.mjs.map +1 -0
- package/dist/start-CKRhuB1Y.mjs +1526 -0
- package/dist/start-CKRhuB1Y.mjs.map +1 -0
- package/dist/stdin-BjAO9gPK.mjs +17 -0
- package/dist/stdin-BjAO9gPK.mjs.map +1 -0
- package/dist/stream-DVuufwIj.mjs +148 -0
- package/dist/stream-DVuufwIj.mjs.map +1 -0
- package/dist/subscriptions-CfiflAsI.mjs +38 -0
- package/dist/subscriptions-CfiflAsI.mjs.map +1 -0
- package/dist/switchboard-DAS-5x53.mjs +48 -0
- package/dist/switchboard-DAS-5x53.mjs.map +1 -0
- package/dist/types-DrLfp2dR.d.mts +1766 -0
- package/dist/types-DrLfp2dR.d.mts.map +1 -0
- package/package.json +95 -3
- package/README.md +0 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { St as ServiceManager } from "../types-DrLfp2dR.mjs";
|
|
2
|
+
import { HostDefinition, RunnerContext } from "@powerhousedao/host-core";
|
|
3
|
+
//#region src/runners/clint-runner.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* clint-runner (P5.4): the clint framework shell as a compound-kind runner.
|
|
6
|
+
* Children declared in hosts/cli/host.js are SCHEDULED as clint services —
|
|
7
|
+
* each member runs as `ph-cli run <member>` in its own (hidden) process with
|
|
8
|
+
* state files, logs, readiness patterns and restart policies from the ported
|
|
9
|
+
* services manager; `lifecycle: "detached"` (the default, clint's own
|
|
10
|
+
* posture) leaves children running when the shell exits and re-attaches on
|
|
11
|
+
* the next run, `"attached"` tears them down vetra-style.
|
|
12
|
+
*
|
|
13
|
+
* The agents manager (config.agents) maps names to OpenAI-compatible
|
|
14
|
+
* endpoints — a sibling host reference resolves through that host's
|
|
15
|
+
* runner.port (the mastra-runner serves /v1 there). `dev` adds a line chat
|
|
16
|
+
* loop against the first agent; the full ink REPL remains the library path
|
|
17
|
+
* (defineCli) for implementation projects, as scaffolded clint CLIs use it
|
|
18
|
+
* natively — noted in the phase-5 WBS.
|
|
19
|
+
*/
|
|
20
|
+
export declare const kind = "compound";
|
|
21
|
+
export declare const hostSchema: import("zod").ZodObject<{
|
|
22
|
+
name: import("zod").ZodString;
|
|
23
|
+
runner: import("zod").ZodObject<{
|
|
24
|
+
module: import("zod").ZodString;
|
|
25
|
+
defaultVerb: import("zod").ZodOptional<import("zod").ZodString>;
|
|
26
|
+
port: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
27
|
+
}, import("zod/v4/core").$loose>;
|
|
28
|
+
children: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
29
|
+
host: import("zod").ZodString;
|
|
30
|
+
plugins: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
31
|
+
runner: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
32
|
+
config: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
33
|
+
reactor: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
34
|
+
backends: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
35
|
+
kind: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
36
|
+
"in-process": "in-process";
|
|
37
|
+
remote: "remote";
|
|
38
|
+
worker: "worker";
|
|
39
|
+
}>>;
|
|
40
|
+
storage: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
41
|
+
kind: import("zod").ZodEnum<{
|
|
42
|
+
idb: "idb";
|
|
43
|
+
memory: "memory";
|
|
44
|
+
path: "path";
|
|
45
|
+
postgres: "postgres";
|
|
46
|
+
}>;
|
|
47
|
+
dataDir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
48
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
49
|
+
}, import("zod/v4/core").$strict>>;
|
|
50
|
+
readModel: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
51
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
52
|
+
}, import("zod/v4/core").$strict>>;
|
|
53
|
+
packages: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
54
|
+
cdnUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
55
|
+
specs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
56
|
+
dynamic: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
57
|
+
}, import("zod/v4/core").$strict>>;
|
|
58
|
+
remote: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
59
|
+
host: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
|
+
}, import("zod/v4/core").$strict>>;
|
|
62
|
+
}, import("zod/v4/core").$strict>>>;
|
|
63
|
+
placement: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
64
|
+
primary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
65
|
+
default: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
66
|
+
}, import("zod/v4/core").$strict>>;
|
|
67
|
+
workflows: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
68
|
+
protocol: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
69
|
+
featureFlags: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
70
|
+
documentDecisions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
71
|
+
authEnforcement: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
72
|
+
authGroups: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
73
|
+
authConditions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
74
|
+
}, import("zod/v4/core").$strict>>;
|
|
75
|
+
createSignaturePolicy: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
76
|
+
legacy: "legacy";
|
|
77
|
+
"v2-required": "v2-required";
|
|
78
|
+
}>>;
|
|
79
|
+
unsupportedStoredDocuments: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
80
|
+
"read-only": "read-only";
|
|
81
|
+
refuse: "refuse";
|
|
82
|
+
}>>;
|
|
83
|
+
}, import("zod/v4/core").$strict>>;
|
|
84
|
+
}, import("zod/v4/core").$strict>>;
|
|
85
|
+
}, import("zod/v4/core").$strict>>;
|
|
86
|
+
config: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
87
|
+
profile: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
88
|
+
appId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
89
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
90
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
91
|
+
icon: import("zod").ZodOptional<import("zod").ZodString>;
|
|
92
|
+
}, import("zod/v4/core").$strict>>;
|
|
93
|
+
}, import("zod/v4/core").$loose>;
|
|
94
|
+
export interface CliRunHandle {
|
|
95
|
+
services: ServiceManager;
|
|
96
|
+
agents: Record<string, string>;
|
|
97
|
+
shutdown: () => Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
export declare function run(host: HostDefinition, ctx: RunnerContext): Promise<CliRunHandle>;
|
|
100
|
+
export declare const serve: typeof run;
|
|
101
|
+
/** dev = services up + the line chat shell (blocks until /exit). */
|
|
102
|
+
export declare function dev(host: HostDefinition, ctx: RunnerContext): Promise<void>;
|
|
103
|
+
/** build = forward build to each member host that exports it (fail loud on
|
|
104
|
+
* members that do not — a silent skip would report success on an unbuilt
|
|
105
|
+
* set), same posture as the generic compound. */
|
|
106
|
+
export declare function build(host: HostDefinition, ctx: RunnerContext): Promise<void>;
|
|
107
|
+
//#endregion
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=clint-runner.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clint-runner.d.mts","names":[],"sources":["../../src/runners/clint-runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAyCa;qBAEA,0BAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAAqB;iBA8F3B;EACf,UAAU;EACV,QAAQ;EACR,gBAAgB;;wBAwJI,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;qBAaE,cAAK;;wBAGI,IACpB,MAAM,gBACN,KAAK,gBACJ;;;;wBASmB,MACpB,MAAM,gBACN,KAAK,gBACJ"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { n as defineService, t as createServiceManager, x as isPortFree } from "../services-BvLvP5Qh.mjs";
|
|
2
|
+
import { r as formatStatus, t as createEventBus } from "../events-DkzJFZeW.mjs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { createInterface } from "node:readline";
|
|
8
|
+
import { compoundHostSchema, defaultUserDataDir, loadHost, probeRun, resolveUserDataPlaceholders } from "@powerhousedao/host-core";
|
|
9
|
+
//#region src/runners/clint-runner.ts
|
|
10
|
+
/**
|
|
11
|
+
* clint-runner (P5.4): the clint framework shell as a compound-kind runner.
|
|
12
|
+
* Children declared in hosts/cli/host.js are SCHEDULED as clint services —
|
|
13
|
+
* each member runs as `ph-cli run <member>` in its own (hidden) process with
|
|
14
|
+
* state files, logs, readiness patterns and restart policies from the ported
|
|
15
|
+
* services manager; `lifecycle: "detached"` (the default, clint's own
|
|
16
|
+
* posture) leaves children running when the shell exits and re-attaches on
|
|
17
|
+
* the next run, `"attached"` tears them down vetra-style.
|
|
18
|
+
*
|
|
19
|
+
* The agents manager (config.agents) maps names to OpenAI-compatible
|
|
20
|
+
* endpoints — a sibling host reference resolves through that host's
|
|
21
|
+
* runner.port (the mastra-runner serves /v1 there). `dev` adds a line chat
|
|
22
|
+
* loop against the first agent; the full ink REPL remains the library path
|
|
23
|
+
* (defineCli) for implementation projects, as scaffolded clint CLIs use it
|
|
24
|
+
* natively — noted in the phase-5 WBS.
|
|
25
|
+
*/
|
|
26
|
+
const kind = "compound";
|
|
27
|
+
const hostSchema = compoundHostSchema;
|
|
28
|
+
const DEFAULT_READINESS = "https?://|listening|ready";
|
|
29
|
+
/** Resolve the project's ph-cli entry the same way host-core resolves runner
|
|
30
|
+
* modules: from the PROJECT's dependency tree. */
|
|
31
|
+
function resolvePhCliEntry(projectRoot) {
|
|
32
|
+
const pkgPath = createRequire(pathToFileURL(path.join(projectRoot, "package.json")).href).resolve("@powerhousedao/ph-cli/package.json");
|
|
33
|
+
return path.join(path.dirname(pkgPath), "dist", "cli.mjs");
|
|
34
|
+
}
|
|
35
|
+
function childServices(host, ctx, phCliEntry) {
|
|
36
|
+
const children = host.children ?? {};
|
|
37
|
+
return Object.entries(children).map(([name, wrapper]) => defineService({
|
|
38
|
+
id: name,
|
|
39
|
+
name,
|
|
40
|
+
command: () => `node "${phCliEntry}" run ${wrapper.host}`,
|
|
41
|
+
env: () => ({
|
|
42
|
+
FEATURE_UNIFORM_RUNNERS_ENABLED: "1",
|
|
43
|
+
PH_USER_DATA_DIR: defaultUserDataDir(ctx.projectRoot, ctx.env)
|
|
44
|
+
}),
|
|
45
|
+
readiness: {
|
|
46
|
+
patterns: [{
|
|
47
|
+
name: "up",
|
|
48
|
+
pattern: new RegExp(wrapper.config?.readiness?.pattern ?? DEFAULT_READINESS, "i")
|
|
49
|
+
}],
|
|
50
|
+
timeout: wrapper.config?.readiness?.timeout ?? 18e4
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
async function resolveAgentEndpoint(ref, ctx) {
|
|
55
|
+
if (ref.url) return ref.url.replace(/\/$/, "");
|
|
56
|
+
if (ref.host) {
|
|
57
|
+
const port = (await loadHost(ctx.projectRoot, ref.host)).host.runner.port ?? 4910;
|
|
58
|
+
return `http://127.0.0.1:${String(port)}/v1`;
|
|
59
|
+
}
|
|
60
|
+
throw new Error("agents entries need { host } or { url }");
|
|
61
|
+
}
|
|
62
|
+
function readProjectName(projectRoot, fallback) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8")).name ?? fallback;
|
|
65
|
+
} catch {
|
|
66
|
+
return fallback;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function startShell(host, ctx) {
|
|
70
|
+
const userData = defaultUserDataDir(ctx.projectRoot, ctx.env);
|
|
71
|
+
const resolved = resolveUserDataPlaceholders(host, userData);
|
|
72
|
+
const config = resolved.config ?? {};
|
|
73
|
+
const lifecycle = resolved.runner.lifecycle ?? "detached";
|
|
74
|
+
const phCliEntry = resolvePhCliEntry(ctx.projectRoot);
|
|
75
|
+
const children = resolved.children ?? {};
|
|
76
|
+
const projectName = readProjectName(ctx.projectRoot, resolved.name);
|
|
77
|
+
const definitions = childServices(resolved, ctx, phCliEntry);
|
|
78
|
+
const eventBus = createEventBus();
|
|
79
|
+
const servicesDir = path.join(ctx.projectRoot, ".ph", "services");
|
|
80
|
+
const services = createServiceManager(definitions, {
|
|
81
|
+
config: {},
|
|
82
|
+
servicesDir,
|
|
83
|
+
eventBus
|
|
84
|
+
});
|
|
85
|
+
const names = definitions.map((d) => d.id);
|
|
86
|
+
const ordered = [...(config.startOrder ?? []).filter((n) => names.includes(n)), ...names.filter((n) => !(config.startOrder ?? []).includes(n))];
|
|
87
|
+
for (const id of ordered) {
|
|
88
|
+
const wrapper = children[id];
|
|
89
|
+
const member = await loadHost(ctx.projectRoot, wrapper.host);
|
|
90
|
+
const record = probeRun(ctx.projectRoot, member.host.name, projectName);
|
|
91
|
+
if (record.status === "live") {
|
|
92
|
+
console.log(`[${resolved.name}] ${id}: already running (pid ${record.record.pid}) — re-attached`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const memberPort = typeof wrapper.runner?.port === "number" ? wrapper.runner.port : typeof member.host.runner.port === "number" ? member.host.runner.port : void 0;
|
|
96
|
+
if (memberPort !== void 0 && !await isPortFree(memberPort)) {
|
|
97
|
+
console.log(`[${resolved.name}] ${id}: port ${memberPort} already serving — re-attached`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (services.list(id).some((s) => s.status === "ready" || s.status === "starting")) {
|
|
101
|
+
console.log(`[${resolved.name}] ${id}: already running — re-attached`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
console.log(`[${resolved.name}] starting ${id}…`);
|
|
105
|
+
await services.start(id, {
|
|
106
|
+
workdir: ctx.projectRoot,
|
|
107
|
+
cwd: ctx.projectRoot
|
|
108
|
+
});
|
|
109
|
+
const status = services.list(id).find((s) => s.serviceId === id);
|
|
110
|
+
if (status) console.log(` ${formatStatus(status)}`);
|
|
111
|
+
}
|
|
112
|
+
const agents = {};
|
|
113
|
+
for (const [name, ref] of Object.entries(config.agents ?? {})) agents[name] = await resolveAgentEndpoint(ref, ctx);
|
|
114
|
+
if (Object.keys(agents).length > 0) console.log(`[${resolved.name}] agents: ${Object.entries(agents).map(([n, u]) => `${n} → ${u}`).join(", ")}`);
|
|
115
|
+
const shutdown = async () => {
|
|
116
|
+
if (lifecycle === "attached") for (const id of names) try {
|
|
117
|
+
await services.stop(id);
|
|
118
|
+
} catch {}
|
|
119
|
+
else console.log(`[${resolved.name}] detached lifecycle: children keep running (stop them with the ${resolved.name} service commands or taskkill).`);
|
|
120
|
+
};
|
|
121
|
+
if (lifecycle === "attached") {
|
|
122
|
+
const onSignal = () => {
|
|
123
|
+
shutdown().finally(() => process.exit(130));
|
|
124
|
+
};
|
|
125
|
+
process.once("SIGINT", onSignal);
|
|
126
|
+
process.once("SIGTERM", onSignal);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
services,
|
|
130
|
+
agents,
|
|
131
|
+
shutdown
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Minimal line chat against an agent's OpenAI-compatible endpoint. */
|
|
135
|
+
async function chatLoop(agents) {
|
|
136
|
+
const [agentName, endpoint] = Object.entries(agents)[0] ?? [];
|
|
137
|
+
if (!agentName || !endpoint) {
|
|
138
|
+
console.log("No agents configured (config.agents) — chat unavailable.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
console.log(`Chatting with ${agentName} (${endpoint}). /exit to quit.`);
|
|
142
|
+
const rl = createInterface({
|
|
143
|
+
input: process.stdin,
|
|
144
|
+
output: process.stdout
|
|
145
|
+
});
|
|
146
|
+
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
147
|
+
for (;;) {
|
|
148
|
+
const line = (await ask("> ")).trim();
|
|
149
|
+
if (line === "/exit" || line === "exit") break;
|
|
150
|
+
if (!line) continue;
|
|
151
|
+
try {
|
|
152
|
+
const res = await fetch(`${endpoint}/chat/completions`, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
headers: { "content-type": "application/json" },
|
|
155
|
+
body: JSON.stringify({ messages: [{
|
|
156
|
+
role: "user",
|
|
157
|
+
content: line
|
|
158
|
+
}] })
|
|
159
|
+
});
|
|
160
|
+
const body = await res.json();
|
|
161
|
+
console.log(body.choices?.[0]?.message?.content ?? `[error] ${body.error?.message ?? res.status}`);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.log(`[transport error] ${String(error)}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
rl.close();
|
|
167
|
+
}
|
|
168
|
+
async function run(host, ctx) {
|
|
169
|
+
const handle = await startShell(host, ctx);
|
|
170
|
+
console.log(`[${host.name}] services up. (ph run ${host.name} dev for the chat shell; Ctrl+C ${host.runner.lifecycle === "attached" ? "stops the children" : "leaves children running"}.)`);
|
|
171
|
+
return handle;
|
|
172
|
+
}
|
|
173
|
+
const serve = run;
|
|
174
|
+
/** dev = services up + the line chat shell (blocks until /exit). */
|
|
175
|
+
async function dev(host, ctx) {
|
|
176
|
+
const handle = await startShell(host, ctx);
|
|
177
|
+
await chatLoop(handle.agents);
|
|
178
|
+
await handle.shutdown();
|
|
179
|
+
}
|
|
180
|
+
/** build = forward build to each member host that exports it (fail loud on
|
|
181
|
+
* members that do not — a silent skip would report success on an unbuilt
|
|
182
|
+
* set), same posture as the generic compound. */
|
|
183
|
+
async function build(host, ctx) {
|
|
184
|
+
const { getVerb, resolveRunnerModule, validateHost } = await import("@powerhousedao/host-core");
|
|
185
|
+
const children = host.children ?? {};
|
|
186
|
+
for (const [name, wrapper] of Object.entries(children)) {
|
|
187
|
+
const member = await loadHost(ctx.projectRoot, wrapper.host);
|
|
188
|
+
const specifier = member.host.runner.module;
|
|
189
|
+
const runner = await resolveRunnerModule(ctx.projectRoot, specifier);
|
|
190
|
+
validateHost(runner, specifier, member.host, `hosts/${wrapper.host}/host.js`);
|
|
191
|
+
const fn = getVerb(runner, specifier, "build");
|
|
192
|
+
console.log(`[${host.name}] build → ${name} (${wrapper.host})`);
|
|
193
|
+
await fn(member.host, {
|
|
194
|
+
...ctx,
|
|
195
|
+
verb: "build"
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
export { build, dev, hostSchema, kind, run, serve };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=clint-runner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clint-runner.mjs","names":[],"sources":["../../src/runners/clint-runner.ts"],"sourcesContent":["import { createInterface } from \"node:readline\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n compoundHostSchema,\n defaultUserDataDir,\n loadHost,\n probeRun,\n resolveUserDataPlaceholders,\n type HostDefinition,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport fs from \"node:fs\";\nimport { createEventBus } from \"../core/events.js\";\nimport { isPortFree } from \"../core/preflight.js\";\nimport {\n createServiceManager,\n defineService,\n resolveServiceName,\n} from \"../core/services.js\";\nimport { formatStatus } from \"../core/service-command.js\";\nimport type { ServiceDefinition, ServiceManager } from \"../core/types.js\";\n\n/**\n * clint-runner (P5.4): the clint framework shell as a compound-kind runner.\n * Children declared in hosts/cli/host.js are SCHEDULED as clint services —\n * each member runs as `ph-cli run <member>` in its own (hidden) process with\n * state files, logs, readiness patterns and restart policies from the ported\n * services manager; `lifecycle: \"detached\"` (the default, clint's own\n * posture) leaves children running when the shell exits and re-attaches on\n * the next run, `\"attached\"` tears them down vetra-style.\n *\n * The agents manager (config.agents) maps names to OpenAI-compatible\n * endpoints — a sibling host reference resolves through that host's\n * runner.port (the mastra-runner serves /v1 there). `dev` adds a line chat\n * loop against the first agent; the full ink REPL remains the library path\n * (defineCli) for implementation projects, as scaffolded clint CLIs use it\n * natively — noted in the phase-5 WBS.\n */\n\nexport const kind = \"compound\";\n\nexport const hostSchema = compoundHostSchema;\n\ninterface ChildWrapper {\n host: string;\n runner?: { port?: number } & Record<string, unknown>;\n config?: { readiness?: { pattern?: string; timeout?: number } } & Record<\n string,\n unknown\n >;\n}\n\ninterface AgentRef {\n host?: string;\n url?: string;\n}\n\ninterface CliHostConfig {\n agents?: Record<string, AgentRef>;\n startOrder?: string[];\n}\n\n// A URL in stdout is the universal \"I am serving\" signal across member kinds\n// (switchboard prints \"MCP server available at http://…\", preview \"Local:\",\n// the agent \"agent API … http://…\").\nconst DEFAULT_READINESS = \"https?://|listening|ready\";\n\n/** Resolve the project's ph-cli entry the same way host-core resolves runner\n * modules: from the PROJECT's dependency tree. */\nfunction resolvePhCliEntry(projectRoot: string): string {\n const require_ = createRequire(\n pathToFileURL(path.join(projectRoot, \"package.json\")).href,\n );\n const pkgPath = require_.resolve(\"@powerhousedao/ph-cli/package.json\");\n return path.join(path.dirname(pkgPath), \"dist\", \"cli.mjs\");\n}\n\nfunction childServices(\n host: HostDefinition,\n ctx: RunnerContext,\n phCliEntry: string,\n): ServiceDefinition<Record<string, unknown>>[] {\n const children = (host.children ?? {}) as Record<string, ChildWrapper>;\n return Object.entries(children).map(([name, wrapper]) =>\n defineService({\n id: name,\n name,\n command: () => `node \"${phCliEntry}\" run ${wrapper.host}`,\n env: () => ({\n FEATURE_UNIFORM_RUNNERS_ENABLED: \"1\",\n PH_USER_DATA_DIR: defaultUserDataDir(ctx.projectRoot, ctx.env),\n }),\n readiness: {\n patterns: [\n {\n name: \"up\",\n pattern: new RegExp(\n wrapper.config?.readiness?.pattern ?? DEFAULT_READINESS,\n \"i\",\n ),\n },\n ],\n timeout: wrapper.config?.readiness?.timeout ?? 180_000,\n },\n }),\n );\n}\n\nasync function resolveAgentEndpoint(\n ref: AgentRef,\n ctx: RunnerContext,\n): Promise<string> {\n if (ref.url) return ref.url.replace(/\\/$/, \"\");\n if (ref.host) {\n const sibling = await loadHost(ctx.projectRoot, ref.host);\n const port = sibling.host.runner.port ?? 4910;\n return `http://127.0.0.1:${String(port)}/v1`;\n }\n throw new Error(\"agents entries need { host } or { url }\");\n}\n\nfunction readProjectName(projectRoot: string, fallback: string): string {\n try {\n return (\n (\n JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { name?: string }\n ).name ?? fallback\n );\n } catch {\n return fallback;\n }\n}\n\nexport interface CliRunHandle {\n services: ServiceManager;\n agents: Record<string, string>;\n shutdown: () => Promise<void>;\n}\n\nasync function startShell(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<CliRunHandle> {\n const userData = defaultUserDataDir(ctx.projectRoot, ctx.env);\n const resolved = resolveUserDataPlaceholders(host, userData);\n const config = (resolved.config ?? {}) as CliHostConfig;\n const lifecycle =\n (resolved.runner.lifecycle as string | undefined) ?? \"detached\";\n\n const phCliEntry = resolvePhCliEntry(ctx.projectRoot);\n const children = (resolved.children ?? {}) as Record<string, ChildWrapper>;\n const projectName = readProjectName(ctx.projectRoot, resolved.name);\n const definitions = childServices(resolved, ctx, phCliEntry);\n const eventBus = createEventBus();\n const servicesDir = path.join(ctx.projectRoot, \".ph\", \"services\");\n const services = createServiceManager(definitions, {\n config: {},\n servicesDir,\n eventBus,\n });\n\n // Start order: config.startOrder first, then declaration order.\n const names = definitions.map((d) => d.id);\n const ordered = [\n ...(config.startOrder ?? []).filter((n) => names.includes(n)),\n ...names.filter((n) => !(config.startOrder ?? []).includes(n)),\n ];\n for (const id of ordered) {\n // Re-attach checks, strongest first. (1) The member's OWN run record —\n // written with the member process's real pid (mastra-runner, the generic\n // compound). (2) Port occupancy for record-less bridge members. (3) The\n // service state file — weakest on Windows, where it records the cmd shim\n // pid, which dies on console teardown while the node grandchild survives.\n const wrapper = children[id];\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n const record = probeRun(ctx.projectRoot, member.host.name, projectName);\n if (record.status === \"live\") {\n console.log(\n `[${resolved.name}] ${id}: already running (pid ${record.record.pid}) — re-attached`,\n );\n continue;\n }\n const memberPort =\n typeof wrapper.runner?.port === \"number\"\n ? wrapper.runner.port\n : typeof member.host.runner.port === \"number\"\n ? member.host.runner.port\n : undefined;\n if (memberPort !== undefined && !(await isPortFree(memberPort))) {\n console.log(\n `[${resolved.name}] ${id}: port ${memberPort} already serving — re-attached`,\n );\n continue;\n }\n const already = services\n .list(id)\n .some((s) => s.status === \"ready\" || s.status === \"starting\");\n if (already) {\n console.log(`[${resolved.name}] ${id}: already running — re-attached`);\n continue;\n }\n console.log(`[${resolved.name}] starting ${id}…`);\n await services.start(id, {\n workdir: ctx.projectRoot,\n cwd: ctx.projectRoot,\n });\n const status = services.list(id).find((s) => s.serviceId === id);\n if (status) console.log(` ${formatStatus(status)}`);\n }\n\n const agents: Record<string, string> = {};\n for (const [name, ref] of Object.entries(config.agents ?? {})) {\n agents[name] = await resolveAgentEndpoint(ref, ctx);\n }\n if (Object.keys(agents).length > 0) {\n console.log(\n `[${resolved.name}] agents: ${Object.entries(agents)\n .map(([n, u]) => `${n} → ${u}`)\n .join(\", \")}`,\n );\n }\n\n const shutdown = async () => {\n if (lifecycle === \"attached\") {\n for (const id of names) {\n try {\n await services.stop(id);\n } catch {\n // already stopped\n }\n }\n } else {\n console.log(\n `[${resolved.name}] detached lifecycle: children keep running ` +\n `(stop them with the ${resolved.name} service commands or taskkill).`,\n );\n }\n };\n\n if (lifecycle === \"attached\") {\n const onSignal = () => {\n void shutdown().finally(() => process.exit(130));\n };\n process.once(\"SIGINT\", onSignal);\n process.once(\"SIGTERM\", onSignal);\n }\n\n return { services, agents, shutdown };\n}\n\n/** Minimal line chat against an agent's OpenAI-compatible endpoint. */\nasync function chatLoop(agents: Record<string, string>): Promise<void> {\n const [agentName, endpoint] = Object.entries(agents)[0] ?? [];\n if (!agentName || !endpoint) {\n console.log(\"No agents configured (config.agents) — chat unavailable.\");\n return;\n }\n console.log(`Chatting with ${agentName} (${endpoint}). /exit to quit.`);\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const ask = (q: string) =>\n new Promise<string>((resolve) => rl.question(q, resolve));\n for (;;) {\n const line = (await ask(\"> \")).trim();\n if (line === \"/exit\" || line === \"exit\") break;\n if (!line) continue;\n try {\n const res = await fetch(`${endpoint}/chat/completions`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n messages: [{ role: \"user\", content: line }],\n }),\n });\n const body = (await res.json()) as {\n choices?: { message?: { content?: string } }[];\n error?: { message?: string };\n };\n console.log(\n body.choices?.[0]?.message?.content ??\n `[error] ${body.error?.message ?? res.status}`,\n );\n } catch (error) {\n console.log(`[transport error] ${String(error)}`);\n }\n }\n rl.close();\n}\n\nexport async function run(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<CliRunHandle> {\n const handle = await startShell(host, ctx);\n console.log(\n `[${host.name}] services up. ` +\n `(ph run ${host.name} dev for the chat shell; Ctrl+C ${\n (host.runner.lifecycle as string | undefined) === \"attached\"\n ? \"stops the children\"\n : \"leaves children running\"\n }.)`,\n );\n return handle;\n}\n\nexport const serve = run;\n\n/** dev = services up + the line chat shell (blocks until /exit). */\nexport async function dev(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<void> {\n const handle = await startShell(host, ctx);\n await chatLoop(handle.agents);\n await handle.shutdown();\n}\n\n/** build = forward build to each member host that exports it (fail loud on\n * members that do not — a silent skip would report success on an unbuilt\n * set), same posture as the generic compound. */\nexport async function build(\n host: HostDefinition,\n ctx: RunnerContext,\n): Promise<void> {\n const { getVerb, resolveRunnerModule, validateHost } =\n await import(\"@powerhousedao/host-core\");\n const children = (host.children ?? {}) as Record<string, ChildWrapper>;\n for (const [name, wrapper] of Object.entries(children)) {\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n const specifier = member.host.runner.module;\n const runner = await resolveRunnerModule(ctx.projectRoot, specifier);\n validateHost(\n runner,\n specifier,\n member.host,\n `hosts/${wrapper.host}/host.js`,\n );\n const fn = getVerb(runner, specifier, \"build\");\n console.log(`[${host.name}] build → ${name} (${wrapper.host})`);\n await fn(member.host, { ...ctx, verb: \"build\" });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,OAAO;AAEpB,MAAa,aAAa;AAwB1B,MAAM,oBAAoB;;;AAI1B,SAAS,kBAAkB,aAA6B;CAItD,MAAM,UAHW,cACf,cAAc,KAAK,KAAK,aAAa,cAAc,CAAC,CAAC,CAAC,IAEjC,CAAC,CAAC,QAAQ,oCAAoC;CACrE,OAAO,KAAK,KAAK,KAAK,QAAQ,OAAO,GAAG,QAAQ,SAAS;AAC3D;AAEA,SAAS,cACP,MACA,KACA,YAC8C;CAC9C,MAAM,WAAY,KAAK,YAAY,CAAC;CACpC,OAAO,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,aAC1C,cAAc;EACZ,IAAI;EACJ;EACA,eAAe,SAAS,WAAW,QAAQ,QAAQ;EACnD,YAAY;GACV,iCAAiC;GACjC,kBAAkB,mBAAmB,IAAI,aAAa,IAAI,GAAG;EAC/D;EACA,WAAW;GACT,UAAU,CACR;IACE,MAAM;IACN,SAAS,IAAI,OACX,QAAQ,QAAQ,WAAW,WAAW,mBACtC,GACF;GACF,CACF;GACA,SAAS,QAAQ,QAAQ,WAAW,WAAW;EACjD;CACF,CAAC,CACH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core";
|
|
2
|
+
//#region src/runners/mastra-runner.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* mastra-runner (P5.6): the headless agent host. Its reactor is a REMOTE
|
|
5
|
+
* attach — a lone `remote` backend naming a running switchboard (by sibling
|
|
6
|
+
* host reference or URL); it depends on that switchboard and never starts
|
|
7
|
+
* one. `run`/`serve` expose an OpenAI-compatible chat-completions endpoint
|
|
8
|
+
* (streaming SSE + non-streaming, stateless baseline — the caller owns
|
|
9
|
+
* session state); without a configured model it answers as the DEMO agent.
|
|
10
|
+
* `build` compiles skills and agent profiles (ph-clint-dev's pipeline,
|
|
11
|
+
* ported).
|
|
12
|
+
*/
|
|
13
|
+
export declare const kind = "reactor";
|
|
14
|
+
export declare const hostSchema: import("zod").ZodObject<{
|
|
15
|
+
name: import("zod").ZodString;
|
|
16
|
+
runner: import("zod").ZodObject<{
|
|
17
|
+
module: import("zod").ZodString;
|
|
18
|
+
defaultVerb: import("zod").ZodOptional<import("zod").ZodString>;
|
|
19
|
+
port: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
20
|
+
}, import("zod/v4/core").$loose>;
|
|
21
|
+
config: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
22
|
+
profile: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
23
|
+
appId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
24
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
25
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
26
|
+
icon: import("zod").ZodOptional<import("zod").ZodString>;
|
|
27
|
+
}, import("zod/v4/core").$strict>>;
|
|
28
|
+
reactor: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
29
|
+
backends: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
30
|
+
kind: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
31
|
+
"in-process": "in-process";
|
|
32
|
+
remote: "remote";
|
|
33
|
+
worker: "worker";
|
|
34
|
+
}>>;
|
|
35
|
+
storage: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
36
|
+
kind: import("zod").ZodEnum<{
|
|
37
|
+
idb: "idb";
|
|
38
|
+
memory: "memory";
|
|
39
|
+
path: "path";
|
|
40
|
+
postgres: "postgres";
|
|
41
|
+
}>;
|
|
42
|
+
dataDir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
43
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
44
|
+
}, import("zod/v4/core").$strict>>;
|
|
45
|
+
readModel: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
46
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
47
|
+
}, import("zod/v4/core").$strict>>;
|
|
48
|
+
packages: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
49
|
+
cdnUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
|
+
specs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
51
|
+
dynamic: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
52
|
+
}, import("zod/v4/core").$strict>>;
|
|
53
|
+
remote: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
54
|
+
host: import("zod").ZodOptional<import("zod").ZodString>;
|
|
55
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
56
|
+
}, import("zod/v4/core").$strict>>;
|
|
57
|
+
}, import("zod/v4/core").$strict>>>;
|
|
58
|
+
placement: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
59
|
+
primary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
default: import("zod").ZodOptional<import("zod").ZodObject<{}, import("zod/v4/core").$loose>>;
|
|
61
|
+
}, import("zod/v4/core").$strict>>;
|
|
62
|
+
workflows: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
63
|
+
protocol: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
64
|
+
featureFlags: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
65
|
+
documentDecisions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
66
|
+
authEnforcement: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
67
|
+
authGroups: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
68
|
+
authConditions: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
69
|
+
}, import("zod/v4/core").$strict>>;
|
|
70
|
+
createSignaturePolicy: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
71
|
+
legacy: "legacy";
|
|
72
|
+
"v2-required": "v2-required";
|
|
73
|
+
}>>;
|
|
74
|
+
unsupportedStoredDocuments: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
75
|
+
"read-only": "read-only";
|
|
76
|
+
refuse: "refuse";
|
|
77
|
+
}>>;
|
|
78
|
+
}, import("zod/v4/core").$strict>>;
|
|
79
|
+
}, import("zod/v4/core").$strict>>;
|
|
80
|
+
}, import("zod/v4/core").$loose>;
|
|
81
|
+
type ChatMessage = {
|
|
82
|
+
role: string;
|
|
83
|
+
content: unknown;
|
|
84
|
+
};
|
|
85
|
+
/** Baseline stateless mapping: the last user message is the prompt (string
|
|
86
|
+
* or OpenAI content-part arrays flattened to their text parts). */
|
|
87
|
+
export declare function promptFromMessages(messages: ChatMessage[]): string;
|
|
88
|
+
export interface AgentServeHandle {
|
|
89
|
+
port: number;
|
|
90
|
+
endpoints: Record<string, string>;
|
|
91
|
+
ready: Promise<void>;
|
|
92
|
+
shutdown: () => Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
export declare function run(host: HostDefinition, ctx: RunnerContext): Promise<AgentServeHandle>;
|
|
95
|
+
export declare const serve: typeof run;
|
|
96
|
+
/** `build` — skill + agent-profile compilation (ph-clint-dev's pipeline). */
|
|
97
|
+
export declare function build(host: HostDefinition, ctx: RunnerContext): Promise<void>;
|
|
98
|
+
//#endregion
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=mastra-runner.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra-runner.d.mts","names":[],"sources":["../../src/runners/mastra-runner.ts"],"mappings":";;;;;;;;;;;;qBAoCa;qBAEA,0BAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAAoB;KAkDtC;EAAgB;EAAc;;;;wBAInB,mBAAmB,UAAU;iBAqC5B;EACf;EACA,WAAW;EACX,OAAO;EACP,gBAAgB;;wBA2MI,IACpB,MAAM,gBACN,KAAK,gBACJ,QAAQ;qBAIE,cAAK;;wBAGI,MACpB,MAAM,gBACN,KAAK,gBACJ"}
|