@agntn/harnesses 0.1.1 → 0.2.1
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/README.md +152 -117
- package/dist/_chunks/agents.mjs +2 -30
- package/dist/_chunks/agents.mjs.map +1 -1
- package/dist/_chunks/libs/typebox.mjs +535 -608
- package/dist/_chunks/libs/typebox.mjs.map +1 -1
- package/dist/_chunks/mcp-servers.mjs +5 -34
- package/dist/_chunks/mcp-servers.mjs.map +1 -1
- package/dist/_chunks/mcp.mjs +13 -163
- package/dist/_chunks/mcp.mjs.map +1 -1
- package/dist/_chunks/output.mjs +28 -0
- package/dist/_chunks/output.mjs.map +1 -0
- package/dist/_chunks/{agents-sync.d.mts → prompt-sync.d.mts} +91 -44
- package/dist/_chunks/prompt-sync.d.mts.map +1 -0
- package/dist/_chunks/{agents-sync.mjs → prompt-sync.mjs} +565 -26
- package/dist/_chunks/prompt-sync.mjs.map +1 -0
- package/dist/_chunks/prompts.mjs +28 -0
- package/dist/_chunks/prompts.mjs.map +1 -0
- package/dist/_chunks/tool-operations.mjs +43 -10
- package/dist/_chunks/tool-operations.mjs.map +1 -1
- package/dist/_chunks/tool-schemas.d.mts +17 -13
- package/dist/_chunks/tool-schemas.d.mts.map +1 -1
- package/dist/_chunks/tool-schemas.mjs +4 -0
- package/dist/_chunks/tool-schemas.mjs.map +1 -1
- package/dist/_chunks/types.mjs +1 -1
- package/dist/_chunks/types.mjs.map +1 -1
- package/dist/cli.mjs +6 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +26 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +1 -2
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +176 -1
- package/dist/mcp.mjs.map +1 -0
- package/dist/tool-operations.d.mts +42 -32
- package/dist/tool-operations.d.mts.map +1 -1
- package/dist/tool-operations.mjs +2 -2
- package/dist/tool-schemas.d.mts +2 -2
- package/package.json +24 -21
- package/packages/omp/extensions/harnesses.ts +19 -1
- package/packages/pi/extensions/harnesses.ts +26 -2
- package/packages/shared/tui.ts +22 -1
- package/dist/_chunks/agents-sync.d.mts.map +0 -1
- package/dist/_chunks/agents-sync.mjs.map +0 -1
- package/dist/_chunks/mcp2.mjs +0 -17
- package/dist/_chunks/mcp2.mjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { addMcpServer, getAllHarnesses, getHarness, isHarnessId, listHarnesses, listMcpServers, readAgentsConfig, readMasterMcpServers, removeMcpServer, syncAgentsFiles, syncMcpServers } from "./
|
|
1
|
+
import { addMcpServer, getAllHarnesses, getHarness, isHarnessId, listHarnesses, listMcpServers, readAgentsConfig, readMasterMcpServers, removeMcpServer, syncAgentsFiles, syncMcpServers, syncPromptTemplates } from "./prompt-sync.mjs";
|
|
2
2
|
import "./tool-schemas.mjs";
|
|
3
|
+
import { stripVTControlCharacters } from "node:util";
|
|
3
4
|
import { encode } from "@toon-format/toon";
|
|
4
5
|
const RUN_DEFAULT_TIMEOUT_SECONDS = 600;
|
|
5
6
|
const RUN_MAX_OUTPUT_CHARS = 8e3;
|
|
@@ -54,6 +55,21 @@ function invocationRetry(invocationModes, mode, options) {
|
|
|
54
55
|
const alternateMode = ALTERNATE_INVOCATION_MODE[mode];
|
|
55
56
|
return alternateMode !== void 0 && invocationModes[alternateMode] ? { tools: !options.tools } : void 0;
|
|
56
57
|
}
|
|
58
|
+
const OUTPUT_CONTROLS = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F]/g;
|
|
59
|
+
function plainOutput(output) {
|
|
60
|
+
return stripVTControlCharacters(output).replaceAll("\r\n", "\n").replace(OUTPUT_CONTROLS, " ");
|
|
61
|
+
}
|
|
62
|
+
function runText(outcome, streams) {
|
|
63
|
+
const blocks = [encode(outcome)];
|
|
64
|
+
for (const name of ["stdout", "stderr"]) {
|
|
65
|
+
const output = streams[name];
|
|
66
|
+
if (output !== void 0 && output.length > 0) blocks.push(`${name}:\n${plainOutput(output)}`);
|
|
67
|
+
}
|
|
68
|
+
return [{
|
|
69
|
+
type: "text",
|
|
70
|
+
text: blocks.join("\n\n")
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
57
73
|
function completedRun(harness, result, options, templateArgs) {
|
|
58
74
|
const contentOutcome = {
|
|
59
75
|
id: harness.id,
|
|
@@ -65,28 +81,26 @@ function completedRun(harness, result, options, templateArgs) {
|
|
|
65
81
|
readOnly: options.readOnly,
|
|
66
82
|
exitCode: result.exitCode,
|
|
67
83
|
timedOut: result.timedOut,
|
|
68
|
-
aborted: result.aborted
|
|
69
|
-
stdout: truncate(result.stdout)
|
|
84
|
+
aborted: result.aborted
|
|
70
85
|
};
|
|
86
|
+
const stdout = truncate(result.stdout);
|
|
71
87
|
const stderr = truncate(result.stderr);
|
|
72
88
|
const details = {
|
|
73
89
|
...contentOutcome,
|
|
74
90
|
args: result.args,
|
|
91
|
+
stdout,
|
|
75
92
|
stderr
|
|
76
93
|
};
|
|
77
94
|
if (result.timedOut || result.exitCode !== 0) return {
|
|
78
|
-
content:
|
|
79
|
-
|
|
95
|
+
content: runText(contentOutcome, {
|
|
96
|
+
stdout,
|
|
80
97
|
stderr
|
|
81
98
|
}),
|
|
82
99
|
details,
|
|
83
100
|
isError: true
|
|
84
101
|
};
|
|
85
102
|
return {
|
|
86
|
-
content:
|
|
87
|
-
...contentOutcome,
|
|
88
|
-
stderr
|
|
89
|
-
}),
|
|
103
|
+
content: runText(contentOutcome, stdout.length > 0 ? { stdout } : { stderr }),
|
|
90
104
|
details
|
|
91
105
|
};
|
|
92
106
|
}
|
|
@@ -146,6 +160,8 @@ function harnessInfoResult(id) {
|
|
|
146
160
|
instructions: harness.instructions,
|
|
147
161
|
skills: harness.skills,
|
|
148
162
|
commands: harness.commands,
|
|
163
|
+
promptTemplates: harness.promptTemplates,
|
|
164
|
+
promptTemplateSyncTarget: harness.promptTemplateSyncTarget,
|
|
149
165
|
hooks: harness.hooks,
|
|
150
166
|
persistence: harness.persistence,
|
|
151
167
|
detection: harness.detection,
|
|
@@ -414,6 +430,23 @@ function agentsSync(id, check = false) {
|
|
|
414
430
|
};
|
|
415
431
|
}
|
|
416
432
|
}
|
|
417
|
-
|
|
433
|
+
function promptsSync(id, check = false) {
|
|
434
|
+
if (id !== void 0 && !isHarnessId(id)) return unknownHarness(id);
|
|
435
|
+
try {
|
|
436
|
+
const details = syncPromptTemplates(id !== void 0 && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(), check);
|
|
437
|
+
return {
|
|
438
|
+
content: text(details),
|
|
439
|
+
details
|
|
440
|
+
};
|
|
441
|
+
} catch (error) {
|
|
442
|
+
const details = { error: errorMessage(error) };
|
|
443
|
+
return {
|
|
444
|
+
content: text(details),
|
|
445
|
+
details,
|
|
446
|
+
isError: true
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
export { RUN_DEFAULT_TIMEOUT_SECONDS, RUN_MAX_OUTPUT_CHARS, agentsSync, detectHarnesses, harnessInfo, listHarnessModels, mcpAdd, mcpList, mcpRemove, mcpSync, promptsSync, runHarness, toMcpServerConfig };
|
|
418
451
|
|
|
419
452
|
//# sourceMappingURL=tool-operations.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-operations.mjs","names":["toToon"],"sources":["../../src/tool-operations.ts"],"sourcesContent":["/**\n * Tool executors behind the agent extensions.\n *\n * Each executor returns the text a caller reads plus the structured details a\n * harness can attach to the call. The text is TOON-encoded so the model sees\n * the same compact shape the CLI's --toon flag prints.\n */\nimport { encode as toToon } from \"@toon-format/toon\";\nimport { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from \"./registry.ts\";\nimport {\n addMcpServer,\n listMcpServers,\n readMasterMcpServers,\n removeMcpServer,\n syncMcpServers,\n} from \"./mcp-servers.ts\";\nimport type { McpConfigListing, SyncReport } from \"./mcp-servers.ts\";\nimport { readAgentsConfig, syncAgentsFiles } from \"./agents-sync.ts\";\nimport type { AgentsSyncReport } from \"./agents-sync.ts\";\nexport type { AgentsSyncReport } from \"./agents-sync.ts\";\nexport type { SyncReport } from \"./mcp-servers.ts\";\nexport type { HarnessInvocationModes } from \"./types.ts\";\nimport type { Harness } from \"./harness.ts\";\nimport type {\n AvailableModel,\n HarnessCapabilities,\n HarnessDetection,\n HarnessId,\n HarnessInvocationModes,\n InvokeResult,\n ListModelsResult,\n McpServerConfig,\n PathCandidate,\n ResolvedPaths,\n StorageDescriptor,\n} from \"./types.ts\";\n\n/** Text for the model plus details for the harness, shared by every tool surface. */\nexport interface ToolResult<Details> {\n content: Array<{ type: \"text\"; text: string }>;\n details: Details;\n /** Set when the tool could not answer. */\n isError?: boolean;\n}\n\n/** Install state of one harness on this machine. */\nexport interface HarnessStatus {\n id: HarnessId;\n name: string;\n installed: boolean;\n version: string | null;\n}\n\n/** Every registered harness with its install state, as scanned by {@link detectHarnesses}. */\nexport interface HarnessListing {\n harnesses: HarnessStatus[];\n}\n\n/** Full metadata for one harness, including paths resolved for this platform. */\nexport interface HarnessMetadata {\n id: HarnessId;\n name: string;\n binaries: string[];\n capabilities: HarnessCapabilities;\n invocationModes: HarnessInvocationModes;\n modelListing: boolean;\n modelSelection: boolean;\n config: PathCandidate[];\n sessions: PathCandidate[];\n instructions: PathCandidate[];\n skills: PathCandidate[];\n commands: PathCandidate[];\n hooks: PathCandidate[];\n persistence: StorageDescriptor[];\n detection: HarnessDetection;\n resolved: ResolvedPaths;\n}\n\n/** Returned when the requested harness id is not registered. */\nexport interface UnknownHarness {\n error: string;\n known: HarnessId[];\n}\n\n/** Returned when a direct batch call bypasses the tool schema limits. */\nexport interface HarnessInfoInputError {\n error: string;\n}\n\n/** One harness lookup result. */\nexport type HarnessInfoResult = HarnessMetadata | UnknownHarness;\n\n/** Scalar, batch, or rejected batch details from {@link harnessInfo}. */\nexport type HarnessInfoDetails = HarnessInfoResult | HarnessInfoResult[] | HarnessInfoInputError;\n\nimport { HARNESS_INFO_MAX_ITEMS, RUN_TIMEOUT_DEFAULT_SECONDS } from \"./tool-schemas.ts\";\nexport { HARNESS_INFO_MAX_ITEMS } from \"./tool-schemas.ts\";\n\n/** Default wall-clock budget for one harness run, in seconds. */\nexport const RUN_DEFAULT_TIMEOUT_SECONDS = RUN_TIMEOUT_DEFAULT_SECONDS;\n\n/** The run tool's per-stream cap: harness output is unbounded, model context is not. */\nexport const RUN_MAX_OUTPUT_CHARS = 8000;\n\nfunction text(data: unknown): Array<{ type: \"text\"; text: string }> {\n return [{ type: \"text\", text: toToon(data) }];\n}\n\nfunction unknownHarness(id: string): ToolResult<UnknownHarness> {\n const details: UnknownHarness = { error: `Unknown harness: ${id}`, known: listHarnesses() };\n return { content: text(details), details, isError: true };\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction truncate(output: string): string {\n if (output.length <= RUN_MAX_OUTPUT_CHARS) return output;\n return `${output.slice(0, RUN_MAX_OUTPUT_CHARS)}\\n[truncated ${output.length - RUN_MAX_OUTPUT_CHARS} of ${output.length} characters]`;\n}\n\nfunction modelListingUnavailable(harness: Harness, id: string): RunFailure {\n return {\n error: harness.modelListing\n ? `Harness ${id} does not support filtering its model listing`\n : `Harness ${id} does not support model listing`,\n };\n}\n\ntype RunInvocationOptions = Readonly<{\n model?: string;\n structured: boolean;\n tools: boolean;\n readOnly: boolean;\n}>;\n\ntype InvocationMode = keyof HarnessInvocationModes;\n\nconst ALTERNATE_INVOCATION_MODE: Partial<Record<InvocationMode, InvocationMode>> = {\n advisor: \"agent\",\n advisorStructured: \"agentStructured\",\n agent: \"advisor\",\n agentStructured: \"advisorStructured\",\n};\n\nfunction selectedInvocationMode(\n structured: boolean,\n tools: boolean,\n readOnly: boolean,\n): InvocationMode {\n if (readOnly) return structured ? \"readOnlyStructured\" : \"readOnly\";\n if (tools) return structured ? \"agentStructured\" : \"agent\";\n return structured ? \"advisorStructured\" : \"advisor\";\n}\n\nfunction invocationRetry(\n invocationModes: Readonly<HarnessInvocationModes>,\n mode: InvocationMode,\n options: RunInvocationOptions,\n): RunFailure[\"retry\"] {\n const withoutStructured = selectedInvocationMode(false, options.tools, options.readOnly);\n if (options.structured) {\n if (invocationModes[withoutStructured]) return { structured: false };\n const alternateWithoutStructured = ALTERNATE_INVOCATION_MODE[withoutStructured];\n if (alternateWithoutStructured && invocationModes[alternateWithoutStructured]) {\n return { structured: false, tools: !options.tools };\n }\n }\n\n const alternateMode = ALTERNATE_INVOCATION_MODE[mode];\n return alternateMode !== undefined && invocationModes[alternateMode]\n ? { tools: !options.tools }\n : undefined;\n}\n\nfunction completedRun(\n harness: Harness,\n result: InvokeResult,\n options: RunInvocationOptions,\n templateArgs: readonly string[],\n): ToolResult<RunOutcome> {\n const contentOutcome: Omit<RunOutcome, \"stderr\"> = {\n id: harness.id,\n command: result.command,\n args: [...templateArgs],\n ...(options.model === undefined ? {} : { model: options.model }),\n structured: options.structured,\n tools: options.tools,\n readOnly: options.readOnly,\n exitCode: result.exitCode,\n timedOut: result.timedOut,\n aborted: result.aborted,\n stdout: truncate(result.stdout),\n };\n const stderr = truncate(result.stderr);\n const details: RunOutcome = { ...contentOutcome, args: result.args, stderr };\n if (result.timedOut || result.exitCode !== 0) {\n return { content: text({ ...contentOutcome, stderr }), details, isError: true };\n }\n return {\n content: text(result.stdout.length > 0 ? contentOutcome : { ...contentOutcome, stderr }),\n details,\n };\n}\n\nfunction unsupportedInvocation(\n harness: Harness,\n id: string,\n options: RunInvocationOptions,\n): ToolResult<RunFailure> {\n const error = harness.invocationError(options) ?? `Invalid ${id} invocation`;\n const invocationModes = harness.invocationModes;\n const mode = selectedInvocationMode(options.structured, options.tools, options.readOnly);\n const modelUnsupported =\n options.model !== undefined && harness.invocation?.modelArgs === undefined;\n if (invocationModes[mode] || harness.invocation === null || modelUnsupported) {\n const details: RunFailure = { error };\n return { content: text(details), details, isError: true };\n }\n\n const retry = invocationRetry(invocationModes, mode, options);\n const details: RunFailure = {\n error,\n invocationModes,\n ...(retry === undefined ? {} : { retry }),\n };\n return { content: text(details), details, isError: true };\n}\n\n/**\n * Scans every registered harness for its binaries and version.\n *\n * @returns {ToolResult<HarnessListing>} The complete installation listing.\n */\nexport function detectHarnesses(): ToolResult<HarnessListing> {\n const details: HarnessListing = {\n harnesses: getAllHarnesses().map((harness) => {\n const installed = harness.isInstalled();\n return {\n id: harness.id,\n name: harness.name,\n installed,\n version: installed ? harness.version : null,\n };\n }),\n };\n\n return { content: text(details), details };\n}\n\nfunction harnessInfoResult(id: string): HarnessInfoResult {\n if (!isHarnessId(id)) return unknownHarness(id).details;\n\n const harness = getHarness(id);\n return {\n id: harness.id,\n name: harness.name,\n binaries: harness.binaries,\n capabilities: harness.capabilities,\n invocationModes: harness.invocationModes,\n modelListing: harness.modelListing !== null,\n modelSelection: harness.invocation?.modelArgs !== undefined,\n config: harness.config,\n sessions: harness.sessions,\n instructions: harness.instructions,\n skills: harness.skills,\n commands: harness.commands,\n hooks: harness.hooks,\n persistence: harness.persistence,\n detection: harness.detection,\n resolved: harness.resolve(),\n };\n}\n\n/** One lookup as the model reads it: every path list once, in {@link HarnessMetadata.resolved}. */\ntype HarnessInfoText =\n | Omit<HarnessMetadata, \"config\" | \"sessions\" | \"instructions\" | \"skills\" | \"commands\" | \"hooks\">\n | UnknownHarness;\n\n/**\n * Leaves the path templates out of the text: `resolved` already carries each\n * of them for this machine, so they only doubled every answer.\n *\n * @param result - One lookup result.\n * @returns {HarnessInfoText} The lookup with its path lists shown once.\n */\nfunction harnessInfoText(result: HarnessInfoResult): HarnessInfoText {\n if (\"error\" in result) return result;\n const {\n id,\n name,\n binaries,\n capabilities,\n invocationModes,\n modelListing,\n modelSelection,\n persistence,\n detection,\n resolved,\n } = result;\n return {\n id,\n name,\n binaries,\n capabilities,\n invocationModes,\n modelListing,\n modelSelection,\n persistence,\n detection,\n resolved,\n };\n}\n\n/** Full metadata for one harness, with paths resolved for the current platform. */\nexport function harnessInfo(id: string): ToolResult<HarnessInfoResult>;\n/** Full metadata for several harnesses, preserving input order and errors for each item. */\nexport function harnessInfo(\n ids: readonly string[],\n): ToolResult<HarnessInfoResult[] | HarnessInfoInputError>;\nexport function harnessInfo(input: string | readonly string[]): ToolResult<HarnessInfoDetails>;\nexport function harnessInfo(input: string | readonly string[]): ToolResult<HarnessInfoDetails> {\n if (typeof input === \"string\") {\n const details = harnessInfoResult(input);\n return {\n content: text(harnessInfoText(details)),\n details,\n ...(\"error\" in details ? { isError: true } : {}),\n };\n }\n\n if (input.length < 1 || input.length > HARNESS_INFO_MAX_ITEMS) {\n const details: HarnessInfoInputError = {\n error: `harnesses_info accepts between 1 and ${HARNESS_INFO_MAX_ITEMS} ids`,\n };\n return { content: text(details), details, isError: true };\n }\n\n const details = input.map(harnessInfoResult);\n return {\n content: text(details.map(harnessInfoText)),\n details,\n ...(details.some((result) => \"error\" in result) ? { isError: true } : {}),\n };\n}\n\n/** Options accepted by {@link listHarnessModels}. */\nexport interface ModelsOptions {\n search?: string;\n cwd?: string;\n /** Wall-clock budget in seconds; defaults to {@link RUN_DEFAULT_TIMEOUT_SECONDS}. */\n timeoutSeconds?: number;\n /** Cancel the owned command through the host request signal. */\n signal?: AbortSignal;\n}\n\n/** One completed native model-listing query. */\nexport interface ModelsOutcome {\n id: HarnessId;\n command: string;\n args: string[];\n search?: string;\n models: AvailableModel[];\n exitCode: number | null;\n timedOut: boolean;\n aborted: boolean;\n stderr: string;\n}\n\n/**\n * Lists the models currently available to one harness through its native CLI.\n *\n * @param id - Harness id to query.\n * @param options - Search, working-directory, and timeout options.\n * @returns {Promise<ToolResult<ModelsOutcome | RunFailure>>} The model listing or failure.\n */\nexport async function listHarnessModels(\n id: string,\n options: ModelsOptions = {},\n): Promise<ToolResult<ModelsOutcome | RunFailure>> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n const harness = getHarness(id);\n const built = harness.buildModelListInvocation(options.search);\n if (!built) {\n const details = modelListingUnavailable(harness, id);\n return { content: text(details), details, isError: true };\n }\n\n const timeoutSeconds = options.timeoutSeconds ?? RUN_DEFAULT_TIMEOUT_SECONDS;\n let result: ListModelsResult;\n try {\n result = await harness.listModels({\n search: options.search,\n cwd: options.cwd,\n timeoutMs: timeoutSeconds * 1000,\n signal: options.signal,\n });\n } catch (error) {\n const details: RunFailure = { error: `Failed to list ${id} models: ${errorMessage(error)}` };\n return { content: text(details), details, isError: true };\n }\n\n const details: ModelsOutcome = {\n id: harness.id,\n command: result.command,\n args: result.args,\n ...(options.search === undefined ? {} : { search: options.search }),\n models: result.models,\n exitCode: result.exitCode,\n timedOut: result.timedOut,\n aborted: result.aborted,\n stderr: truncate(result.stderr),\n };\n\n return {\n content: text(details),\n details,\n ...(result.timedOut || result.exitCode !== 0 ? { isError: true } : {}),\n };\n}\n\n/** Options accepted by {@link runHarness}. */\nexport interface RunOptions {\n cwd?: string;\n /** Harness-native model id or selector. */\n model?: string;\n /** Wall-clock budget in seconds; defaults to {@link RUN_DEFAULT_TIMEOUT_SECONDS}. */\n timeoutSeconds?: number;\n /** Cancel the owned command through the host request signal. */\n signal?: AbortSignal;\n /** Use the harness's structured (JSON) output mode instead of plain text. */\n structured?: boolean;\n /** Enable tools; defaults to a native advisor without tools invocation. */\n tools?: boolean;\n /** Require native enforcement of read-only tool access. Implies tools. */\n readOnly?: boolean;\n}\n\n/** One completed (or failed) harness run, with output capped for the model. */\nexport interface RunOutcome {\n id: HarnessId;\n command: string;\n /** Expanded arguments; the model's text keeps \"{prompt}\" instead, it wrote the prompt itself. */\n args: string[];\n model?: string;\n structured: boolean;\n tools: boolean;\n readOnly: boolean;\n exitCode: number | null;\n timedOut: boolean;\n aborted: boolean;\n stdout: string;\n stderr: string;\n}\n\n/** Returned when the harness cannot be run at all. */\nexport interface RunFailure {\n error: string;\n known?: HarnessId[];\n /** Modes accepted by the selected harness when invocation mode caused the failure. */\n invocationModes?: HarnessInvocationModes;\n /** Explicit mode change that makes the same invocation shape executable. */\n retry?: { structured: false; tools?: boolean } | { tools: boolean };\n}\n\nfunction normalizedRunAccess(options: Readonly<RunOptions>): {\n tools: boolean;\n readOnly: boolean;\n} {\n const readOnly = options.readOnly ?? false;\n return { readOnly, tools: readOnly ? true : (options.tools ?? false) };\n}\n\n/**\n * Runs one prompt through a harness's normalized non-interactive invocation.\n *\n * Tool use defaults to a native advisor without tools invocation. Harnesses that\n * cannot disable tools reject that mode; setting `tools` selects their full\n * agent invocation. `model` is translated through the harness-specific recipe.\n * This layer also closes stdin, enforces the timeout, caps the echoed output,\n * and leaves the prompt out of the echoed invocation.\n *\n * @param id - Harness id to run.\n * @param prompt - Prompt sent to the selected harness.\n * @param options - Model, mode, working-directory, and timeout options.\n * @returns {Promise<ToolResult<RunOutcome | RunFailure>>} The capped run outcome or failure.\n */\nexport async function runHarness(\n id: string,\n prompt: string,\n options: RunOptions = {},\n): Promise<ToolResult<RunOutcome | RunFailure>> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n const harness = getHarness(id);\n const structured = options.structured ?? false;\n const { tools, readOnly } = normalizedRunAccess(options);\n const invocationOptions = { model: options.model, structured, tools, readOnly };\n const template = harness.buildInvocation(\"{prompt}\", invocationOptions);\n if (!template) {\n return unsupportedInvocation(harness, id, invocationOptions);\n }\n\n const timeoutSeconds = options.timeoutSeconds ?? RUN_DEFAULT_TIMEOUT_SECONDS;\n\n let result: InvokeResult;\n try {\n result = await harness.invoke(prompt, {\n cwd: options.cwd,\n model: options.model,\n timeoutMs: timeoutSeconds * 1000,\n signal: options.signal,\n structured,\n tools,\n readOnly,\n });\n } catch (error) {\n const details: RunFailure = { error: `Failed to run ${id}: ${errorMessage(error)}` };\n return { content: text(details), details, isError: true };\n }\n\n return completedRun(harness, result, invocationOptions, template.args);\n}\n\n/** MCP server listings for one harness or all of them. */\nexport interface McpListing {\n harnesses: Array<{ id: HarnessId; configs: McpConfigListing[] }>;\n}\n\n/** Marker used only at the tool and CLI boundary, leaving config reads lossless for edits. */\nconst MCP_REDACTED_VALUE = \"<redacted>\";\nconst MCP_CONFIG_ERROR = \"Unable to read or parse MCP config\";\n\nfunction redactMcpValues(values: Readonly<Record<string, string>>): Record<string, string> {\n return Object.fromEntries(Object.keys(values).map((key) => [key, MCP_REDACTED_VALUE]));\n}\n\n/** Result of one MCP config mutation. */\nexport interface McpMutation {\n id: HarnessId;\n path: string;\n action: \"added\" | \"replaced\" | \"removed\" | \"noop\";\n}\n\n/** Flat tool parameters describing one MCP server, shared by every surface. */\nexport interface McpServerParams {\n name: string;\n transport?: McpServerConfig[\"transport\"];\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n}\n\n/**\n * Builds the normalized server shape from flat tool parameters.\n *\n * @param params - Flat MCP server parameters.\n * @returns {McpServerConfig} The normalized server configuration.\n */\nexport function toMcpServerConfig(params: McpServerParams): McpServerConfig {\n const server: McpServerConfig = {\n name: params.name,\n transport: params.transport ?? (params.url ? \"http\" : \"stdio\"),\n };\n if (params.command !== undefined) server.command = params.command;\n if (params.args !== undefined) server.args = params.args;\n if (params.env !== undefined) server.env = params.env;\n if (params.url !== undefined) server.url = params.url;\n if (params.headers !== undefined) server.headers = params.headers;\n return server;\n}\n\n/**\n * Lists configured MCP servers, normalized across harness config dialects.\n *\n * @param id - Optional harness id; omission lists every harness.\n * @returns {ToolResult<McpListing | UnknownHarness>} The normalized listing or id error.\n */\nexport function mcpList(id?: string): ToolResult<McpListing | UnknownHarness> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n const targets = id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses();\n const details: McpListing = {\n harnesses: targets\n .map((harness) => ({\n id: harness.id,\n configs: listMcpServers(harness).map((listing) => ({\n ...listing,\n ...(listing.error === undefined ? {} : { error: MCP_CONFIG_ERROR }),\n servers: listing.servers.map((server) => ({\n ...server,\n ...(server.env === undefined ? {} : { env: redactMcpValues(server.env) }),\n ...(server.headers === undefined ? {} : { headers: redactMcpValues(server.headers) }),\n })),\n })),\n }))\n .filter((entry) => entry.configs.length > 0),\n };\n\n return { content: text(details), details };\n}\n\nfunction mcpMutate(\n id: string,\n mutate: (harness: Harness) => { path: string; action: McpMutation[\"action\"] },\n): ToolResult<McpMutation | RunFailure> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n try {\n const { path, action } = mutate(getHarness(id));\n const details: McpMutation = { id, path, action };\n return { content: text(details), details, ...(action === \"noop\" ? { isError: true } : {}) };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n\n/**\n * Adds or replaces one MCP server in a harness's config.\n *\n * @param id - Target harness id.\n * @param params - Server parameters to normalize and write.\n * @param scope - User or project config scope.\n * @returns {ToolResult<McpMutation | RunFailure>} The mutation outcome or failure.\n */\nexport function mcpAdd(\n id: string,\n params: McpServerParams,\n scope: \"user\" | \"project\" = \"user\",\n): ToolResult<McpMutation | RunFailure> {\n return mcpMutate(id, (harness) => {\n const { path, replaced } = addMcpServer(harness, toMcpServerConfig(params), scope);\n return { path, action: replaced ? \"replaced\" : \"added\" };\n });\n}\n\n/**\n * Removes one MCP server from a harness's config.\n *\n * @param id - Target harness id.\n * @param name - Server name to remove.\n * @param scope - User or project config scope.\n * @returns {ToolResult<McpMutation | RunFailure>} The mutation outcome or failure.\n */\nexport function mcpRemove(\n id: string,\n name: string,\n scope: \"user\" | \"project\" = \"user\",\n): ToolResult<McpMutation | RunFailure> {\n return mcpMutate(id, (harness) => {\n const { path, removed } = removeMcpServer(harness, name, scope);\n return { path, action: removed ? \"removed\" : \"noop\" };\n });\n}\n\n/**\n * Pushes the master MCP list from ~/.config/agntn/mcp.jsonc into harness configs.\n *\n * @param id - Optional harness id; omission targets every harness.\n * @returns {ToolResult<SyncReport | RunFailure>} The sync report or failure.\n */\nexport function mcpSync(id?: string): ToolResult<SyncReport | RunFailure> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n try {\n // Preflight before any write: a typo in excludes must fail the whole run,\n // not silently leave the misspelled harness unprotected.\n const unknown = readMasterMcpServers().excludes.filter((entry) => !isHarnessId(entry));\n if (unknown.length > 0) {\n const details: RunFailure = {\n error: `Master MCP list excludes unknown harnesses: ${unknown.join(\", \")}`,\n known: listHarnesses(),\n };\n return { content: text(details), details, isError: true };\n }\n const details = syncMcpServers(\n id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(),\n );\n return { content: text(details), details };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n\n/**\n * Links every harness's global instructions file to the master AGENTS.md.\n *\n * @param id - Optional harness id; omission targets every harness.\n * @param check - Report intended changes without writing them.\n * @returns {ToolResult<AgentsSyncReport | RunFailure>} The sync report or failure.\n */\nexport function agentsSync(id?: string, check = false): ToolResult<AgentsSyncReport | RunFailure> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n try {\n // Preflight before any write: a typo in excludes must fail the whole run,\n // not silently adopt the harness it was meant to protect.\n const unknown = readAgentsConfig().excludes.filter((entry) => !isHarnessId(entry));\n if (unknown.length > 0) {\n const details: RunFailure = {\n error: `Agents config excludes unknown harnesses: ${unknown.join(\", \")}`,\n known: listHarnesses(),\n };\n return { content: text(details), details, isError: true };\n }\n const details = syncAgentsFiles(\n id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(),\n check,\n );\n return { content: text(details), details };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n"],"mappings":";;;;;;;;EAmGA,MAAa,OAAA,IAAA;;AAGb;AAEA,SAAS,eAA2D,IAAA;CAClE,MAAA,UAAQ;EAAE,OAAM,oBAAA;EAAQ,OAAMA,cAAW;CAAE;CAC7C,OAAA;EAEA,SAAS,KAAA,OAAA;EACP;EAAkC,SAAO;CAA0B;AAAuB;AAC1F,SAAO,aAAA,OAAA;CAAE,OAAA,iBAAqB,QAAA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,eAAA,OAAA,KAAA,KAAA,YAAA,EAAA,IAAA,CAAA,WAAA,EAAA,CAAA,IAAA,gBAAA,CAAA;EACd,OAAM;GACN,SAAO,KAAA,OAAA;GAAE;EAAwB;CAAS,SAAA,OAAS;EAAK,MAAA,UAAA,EAAA,OAAA,aAAA,KAAA,EAAA;EAC1D,OAAA;GACF,SAAA,KAAA,OAAA;;;;;;;;CAUA,IAAA;EAKE,MAAO,UAAU,iBAAiB,CAAA,CAAA,SAAA,QAAA,UAAA,CAAA,YAAA,KAAA,CAAA;EAChC,IAAA,QAAQ,SAAM,GAAA;GACd,MAAO,UAAA;IAAE,OAAA,6CAAA,QAAA,KAAA,IAAA;IAAM,OAAQ,cAAW;GAAqB;GACxD,OAAA;IACH,SAAA,KAAA,OAAA;;;;;;;;;EAUA;CAKE,SAAO,OAAA;EACL,MAAM,UAAQ,EAAA,OAAA,aAAY,KAAgB,EAAA;EAC1C,OAAO;GAAE,SAAA,KAAA,OAAA;GAAM;GAAqC,SAAA;EACrD;CACH"}
|
|
1
|
+
{"version":3,"file":"tool-operations.mjs","names":["toToon"],"sources":["../../src/tool-operations.ts"],"sourcesContent":["/**\n * Tool executors behind the agent extensions.\n *\n * Each executor returns the text a caller reads plus the structured details a\n * harness can attach to the call. The text is TOON-encoded so the model sees\n * the same compact shape the CLI's --toon flag prints. A run's output is the\n * exception: it follows the status block as plain text, not as one TOON string.\n */\nimport { stripVTControlCharacters } from \"node:util\";\nimport { encode as toToon } from \"@toon-format/toon\";\nimport { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from \"./registry.ts\";\nimport {\n addMcpServer,\n listMcpServers,\n readMasterMcpServers,\n removeMcpServer,\n syncMcpServers,\n} from \"./mcp-servers.ts\";\nimport type { McpConfigListing, SyncReport } from \"./mcp-servers.ts\";\nimport { readAgentsConfig, syncAgentsFiles } from \"./agents-sync.ts\";\nimport type { AgentsSyncReport } from \"./agents-sync.ts\";\nexport type { AgentsSyncReport } from \"./agents-sync.ts\";\nexport type { SyncReport } from \"./mcp-servers.ts\";\nexport type { PromptSyncReport } from \"./prompt-sync.ts\";\nexport type { HarnessInvocationModes } from \"./types.ts\";\nimport { syncPromptTemplates } from \"./prompt-sync.ts\";\nimport type { PromptSyncReport } from \"./prompt-sync.ts\";\nimport type { Harness } from \"./harness.ts\";\nimport type {\n AvailableModel,\n HarnessCapabilities,\n HarnessDetection,\n HarnessId,\n HarnessInvocationModes,\n InvokeResult,\n ListModelsResult,\n McpServerConfig,\n PathCandidate,\n PromptTemplateSyncTarget,\n ResolvedPaths,\n StorageDescriptor,\n} from \"./types.ts\";\n\n/** Text for the model plus details for the harness, shared by every tool surface. */\nexport interface ToolResult<Details> {\n content: Array<{ type: \"text\"; text: string }>;\n details: Details;\n /** Set when the tool could not answer. */\n isError?: boolean;\n}\n\n/** Install state of one harness on this machine. */\nexport interface HarnessStatus {\n id: HarnessId;\n name: string;\n installed: boolean;\n version: string | null;\n}\n\n/** Every registered harness with its install state, as scanned by {@link detectHarnesses}. */\nexport interface HarnessListing {\n harnesses: HarnessStatus[];\n}\n\n/** Full metadata for one harness, including paths resolved for this platform. */\nexport interface HarnessMetadata {\n id: HarnessId;\n name: string;\n binaries: string[];\n capabilities: HarnessCapabilities;\n invocationModes: HarnessInvocationModes;\n modelListing: boolean;\n modelSelection: boolean;\n config: PathCandidate[];\n sessions: PathCandidate[];\n instructions: PathCandidate[];\n skills: PathCandidate[];\n commands: PathCandidate[];\n promptTemplates: PathCandidate[];\n promptTemplateSyncTarget: PromptTemplateSyncTarget | null;\n hooks: PathCandidate[];\n persistence: StorageDescriptor[];\n detection: HarnessDetection;\n resolved: ResolvedPaths;\n}\n\n/** Returned when the requested harness id is not registered. */\nexport interface UnknownHarness {\n error: string;\n known: HarnessId[];\n}\n\n/** Returned when a direct batch call bypasses the tool schema limits. */\nexport interface HarnessInfoInputError {\n error: string;\n}\n\n/** One harness lookup result. */\nexport type HarnessInfoResult = HarnessMetadata | UnknownHarness;\n\n/** Scalar, batch, or rejected batch details from {@link harnessInfo}. */\nexport type HarnessInfoDetails = HarnessInfoResult | HarnessInfoResult[] | HarnessInfoInputError;\n\nimport { HARNESS_INFO_MAX_ITEMS, RUN_TIMEOUT_DEFAULT_SECONDS } from \"./tool-schemas.ts\";\nexport { HARNESS_INFO_MAX_ITEMS } from \"./tool-schemas.ts\";\n\n/** Default wall-clock budget for one harness run, in seconds. */\nexport const RUN_DEFAULT_TIMEOUT_SECONDS = RUN_TIMEOUT_DEFAULT_SECONDS;\n\n/** The run tool's per-stream cap: harness output is unbounded, model context is not. */\nexport const RUN_MAX_OUTPUT_CHARS = 8000;\n\nfunction text(data: unknown): Array<{ type: \"text\"; text: string }> {\n return [{ type: \"text\", text: toToon(data) }];\n}\n\nfunction unknownHarness(id: string): ToolResult<UnknownHarness> {\n const details: UnknownHarness = { error: `Unknown harness: ${id}`, known: listHarnesses() };\n return { content: text(details), details, isError: true };\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction truncate(output: string): string {\n if (output.length <= RUN_MAX_OUTPUT_CHARS) return output;\n return `${output.slice(0, RUN_MAX_OUTPUT_CHARS)}\\n[truncated ${output.length - RUN_MAX_OUTPUT_CHARS} of ${output.length} characters]`;\n}\n\nfunction modelListingUnavailable(harness: Harness, id: string): RunFailure {\n return {\n error: harness.modelListing\n ? `Harness ${id} does not support filtering its model listing`\n : `Harness ${id} does not support model listing`,\n };\n}\n\ntype RunInvocationOptions = Readonly<{\n model?: string;\n structured: boolean;\n tools: boolean;\n readOnly: boolean;\n}>;\n\ntype InvocationMode = keyof HarnessInvocationModes;\n\nconst ALTERNATE_INVOCATION_MODE: Partial<Record<InvocationMode, InvocationMode>> = {\n advisor: \"agent\",\n advisorStructured: \"agentStructured\",\n agent: \"advisor\",\n agentStructured: \"advisorStructured\",\n};\n\nfunction selectedInvocationMode(\n structured: boolean,\n tools: boolean,\n readOnly: boolean,\n): InvocationMode {\n if (readOnly) return structured ? \"readOnlyStructured\" : \"readOnly\";\n if (tools) return structured ? \"agentStructured\" : \"agent\";\n return structured ? \"advisorStructured\" : \"advisor\";\n}\n\nfunction invocationRetry(\n invocationModes: Readonly<HarnessInvocationModes>,\n mode: InvocationMode,\n options: RunInvocationOptions,\n): RunFailure[\"retry\"] {\n const withoutStructured = selectedInvocationMode(false, options.tools, options.readOnly);\n if (options.structured) {\n if (invocationModes[withoutStructured]) return { structured: false };\n const alternateWithoutStructured = ALTERNATE_INVOCATION_MODE[withoutStructured];\n if (alternateWithoutStructured && invocationModes[alternateWithoutStructured]) {\n return { structured: false, tools: !options.tools };\n }\n }\n\n const alternateMode = ALTERNATE_INVOCATION_MODE[mode];\n return alternateMode !== undefined && invocationModes[alternateMode]\n ? { tools: !options.tools }\n : undefined;\n}\n\n/** The run as its status block shows it: everything but the two streams. */\ntype RunStatus = Readonly<Omit<RunOutcome, \"args\" | \"stdout\" | \"stderr\">> & {\n readonly args: readonly string[];\n};\n\ntype RunStreams = Readonly<Partial<Pick<RunOutcome, \"stdout\" | \"stderr\">>>;\n\n// oxlint-disable-next-line no-control-regex -- Terminal control bytes are precisely what this boundary removes.\nconst OUTPUT_CONTROLS = /[\\u0000-\\u0008\\u000B-\\u001F\\u007F-\\u009F]/g;\n\n/**\n * Strips what TOON quoting used to escape: terminal sequences and control bytes; CRLF becomes LF.\n *\n * @param output - One capped stream.\n * @returns {string} The stream as plain text.\n */\nfunction plainOutput(output: string): string {\n return stripVTControlCharacters(output).replaceAll(\"\\r\\n\", \"\\n\").replace(OUTPUT_CONTROLS, \" \");\n}\n\n/**\n * Lays the run out for the model: the TOON status block, then each stream under\n * its name as plain text, since quoting a markdown answer into one TOON string\n * escaped every code block and cost about a tenth more tokens.\n *\n * @param outcome - The run without its output.\n * @param streams - The capped streams; empty ones are left out.\n * @returns {Array<{ type: \"text\"; text: string }>} The text handed to the model.\n */\nfunction runText(outcome: RunStatus, streams: RunStreams): Array<{ type: \"text\"; text: string }> {\n const blocks = [toToon(outcome)];\n for (const name of [\"stdout\", \"stderr\"] as const) {\n const output = streams[name];\n if (output !== undefined && output.length > 0) blocks.push(`${name}:\\n${plainOutput(output)}`);\n }\n return [{ type: \"text\", text: blocks.join(\"\\n\\n\") }];\n}\n\nfunction completedRun(\n harness: Harness,\n result: InvokeResult,\n options: RunInvocationOptions,\n templateArgs: readonly string[],\n): ToolResult<RunOutcome> {\n const contentOutcome: Omit<RunOutcome, \"stdout\" | \"stderr\"> = {\n id: harness.id,\n command: result.command,\n args: [...templateArgs],\n ...(options.model === undefined ? {} : { model: options.model }),\n structured: options.structured,\n tools: options.tools,\n readOnly: options.readOnly,\n exitCode: result.exitCode,\n timedOut: result.timedOut,\n aborted: result.aborted,\n };\n const stdout = truncate(result.stdout);\n const stderr = truncate(result.stderr);\n const details: RunOutcome = { ...contentOutcome, args: result.args, stdout, stderr };\n if (result.timedOut || result.exitCode !== 0) {\n return { content: runText(contentOutcome, { stdout, stderr }), details, isError: true };\n }\n return {\n content: runText(contentOutcome, stdout.length > 0 ? { stdout } : { stderr }),\n details,\n };\n}\n\nfunction unsupportedInvocation(\n harness: Harness,\n id: string,\n options: RunInvocationOptions,\n): ToolResult<RunFailure> {\n const error = harness.invocationError(options) ?? `Invalid ${id} invocation`;\n const invocationModes = harness.invocationModes;\n const mode = selectedInvocationMode(options.structured, options.tools, options.readOnly);\n const modelUnsupported =\n options.model !== undefined && harness.invocation?.modelArgs === undefined;\n if (invocationModes[mode] || harness.invocation === null || modelUnsupported) {\n const details: RunFailure = { error };\n return { content: text(details), details, isError: true };\n }\n\n const retry = invocationRetry(invocationModes, mode, options);\n const details: RunFailure = {\n error,\n invocationModes,\n ...(retry === undefined ? {} : { retry }),\n };\n return { content: text(details), details, isError: true };\n}\n\n/**\n * Scans every registered harness for its binaries and version.\n *\n * @returns {ToolResult<HarnessListing>} The complete installation listing.\n */\nexport function detectHarnesses(): ToolResult<HarnessListing> {\n const details: HarnessListing = {\n harnesses: getAllHarnesses().map((harness) => {\n const installed = harness.isInstalled();\n return {\n id: harness.id,\n name: harness.name,\n installed,\n version: installed ? harness.version : null,\n };\n }),\n };\n\n return { content: text(details), details };\n}\n\nfunction harnessInfoResult(id: string): HarnessInfoResult {\n if (!isHarnessId(id)) return unknownHarness(id).details;\n\n const harness = getHarness(id);\n return {\n id: harness.id,\n name: harness.name,\n binaries: harness.binaries,\n capabilities: harness.capabilities,\n invocationModes: harness.invocationModes,\n modelListing: harness.modelListing !== null,\n modelSelection: harness.invocation?.modelArgs !== undefined,\n config: harness.config,\n sessions: harness.sessions,\n instructions: harness.instructions,\n skills: harness.skills,\n commands: harness.commands,\n promptTemplates: harness.promptTemplates,\n promptTemplateSyncTarget: harness.promptTemplateSyncTarget,\n hooks: harness.hooks,\n persistence: harness.persistence,\n detection: harness.detection,\n resolved: harness.resolve(),\n };\n}\n\n/** One lookup as the model reads it: every path list once, in {@link HarnessMetadata.resolved}. */\ntype HarnessInfoText =\n | Omit<\n HarnessMetadata,\n | \"config\"\n | \"sessions\"\n | \"instructions\"\n | \"skills\"\n | \"commands\"\n | \"promptTemplates\"\n | \"promptTemplateSyncTarget\"\n | \"hooks\"\n >\n | UnknownHarness;\n\n/**\n * Leaves the path templates out of the text: `resolved` already carries each\n * of them for this machine, so they only doubled every answer.\n *\n * @param result - One lookup result.\n * @returns {HarnessInfoText} The lookup with its path lists shown once.\n */\nfunction harnessInfoText(result: HarnessInfoResult): HarnessInfoText {\n if (\"error\" in result) return result;\n const {\n id,\n name,\n binaries,\n capabilities,\n invocationModes,\n modelListing,\n modelSelection,\n persistence,\n detection,\n resolved,\n } = result;\n return {\n id,\n name,\n binaries,\n capabilities,\n invocationModes,\n modelListing,\n modelSelection,\n persistence,\n detection,\n resolved,\n };\n}\n\n/** Full metadata for one harness, with paths resolved for the current platform. */\nexport function harnessInfo(id: string): ToolResult<HarnessInfoResult>;\n/** Full metadata for several harnesses, preserving input order and errors for each item. */\nexport function harnessInfo(\n ids: readonly string[],\n): ToolResult<HarnessInfoResult[] | HarnessInfoInputError>;\nexport function harnessInfo(input: string | readonly string[]): ToolResult<HarnessInfoDetails>;\nexport function harnessInfo(input: string | readonly string[]): ToolResult<HarnessInfoDetails> {\n if (typeof input === \"string\") {\n const details = harnessInfoResult(input);\n return {\n content: text(harnessInfoText(details)),\n details,\n ...(\"error\" in details ? { isError: true } : {}),\n };\n }\n\n if (input.length < 1 || input.length > HARNESS_INFO_MAX_ITEMS) {\n const details: HarnessInfoInputError = {\n error: `harnesses_info accepts between 1 and ${HARNESS_INFO_MAX_ITEMS} ids`,\n };\n return { content: text(details), details, isError: true };\n }\n\n const details = input.map(harnessInfoResult);\n return {\n content: text(details.map(harnessInfoText)),\n details,\n ...(details.some((result) => \"error\" in result) ? { isError: true } : {}),\n };\n}\n\n/** Options accepted by {@link listHarnessModels}. */\nexport interface ModelsOptions {\n search?: string;\n cwd?: string;\n /** Wall-clock budget in seconds; defaults to {@link RUN_DEFAULT_TIMEOUT_SECONDS}. */\n timeoutSeconds?: number;\n /** Cancel the owned command through the host request signal. */\n signal?: AbortSignal;\n}\n\n/** One completed native model-listing query. */\nexport interface ModelsOutcome {\n id: HarnessId;\n command: string;\n args: string[];\n search?: string;\n models: AvailableModel[];\n exitCode: number | null;\n timedOut: boolean;\n aborted: boolean;\n stderr: string;\n}\n\n/**\n * Lists the models currently available to one harness through its native CLI.\n *\n * @param id - Harness id to query.\n * @param options - Search, working-directory, and timeout options.\n * @returns {Promise<ToolResult<ModelsOutcome | RunFailure>>} The model listing or failure.\n */\nexport async function listHarnessModels(\n id: string,\n options: ModelsOptions = {},\n): Promise<ToolResult<ModelsOutcome | RunFailure>> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n const harness = getHarness(id);\n const built = harness.buildModelListInvocation(options.search);\n if (!built) {\n const details = modelListingUnavailable(harness, id);\n return { content: text(details), details, isError: true };\n }\n\n const timeoutSeconds = options.timeoutSeconds ?? RUN_DEFAULT_TIMEOUT_SECONDS;\n let result: ListModelsResult;\n try {\n result = await harness.listModels({\n search: options.search,\n cwd: options.cwd,\n timeoutMs: timeoutSeconds * 1000,\n signal: options.signal,\n });\n } catch (error) {\n const details: RunFailure = { error: `Failed to list ${id} models: ${errorMessage(error)}` };\n return { content: text(details), details, isError: true };\n }\n\n const details: ModelsOutcome = {\n id: harness.id,\n command: result.command,\n args: result.args,\n ...(options.search === undefined ? {} : { search: options.search }),\n models: result.models,\n exitCode: result.exitCode,\n timedOut: result.timedOut,\n aborted: result.aborted,\n stderr: truncate(result.stderr),\n };\n\n return {\n content: text(details),\n details,\n ...(result.timedOut || result.exitCode !== 0 ? { isError: true } : {}),\n };\n}\n\n/** Options accepted by {@link runHarness}. */\nexport interface RunOptions {\n cwd?: string;\n /** Harness-native model id or selector. */\n model?: string;\n /** Wall-clock budget in seconds; defaults to {@link RUN_DEFAULT_TIMEOUT_SECONDS}. */\n timeoutSeconds?: number;\n /** Cancel the owned command through the host request signal. */\n signal?: AbortSignal;\n /** Use the harness's structured (JSON) output mode instead of plain text. */\n structured?: boolean;\n /** Enable tools; defaults to a native advisor without tools invocation. */\n tools?: boolean;\n /** Require native enforcement of read-only tool access. Implies tools. */\n readOnly?: boolean;\n}\n\n/** One completed (or failed) harness run, with output capped for the model. */\nexport interface RunOutcome {\n id: HarnessId;\n command: string;\n /** Expanded arguments; the model's text keeps \"{prompt}\" instead, it wrote the prompt itself. */\n args: string[];\n model?: string;\n structured: boolean;\n tools: boolean;\n readOnly: boolean;\n exitCode: number | null;\n timedOut: boolean;\n aborted: boolean;\n stdout: string;\n stderr: string;\n}\n\n/** Returned when the harness cannot be run at all. */\nexport interface RunFailure {\n error: string;\n known?: HarnessId[];\n /** Modes accepted by the selected harness when invocation mode caused the failure. */\n invocationModes?: HarnessInvocationModes;\n /** Explicit mode change that makes the same invocation shape executable. */\n retry?: { structured: false; tools?: boolean } | { tools: boolean };\n}\n\nfunction normalizedRunAccess(options: Readonly<RunOptions>): {\n tools: boolean;\n readOnly: boolean;\n} {\n const readOnly = options.readOnly ?? false;\n return { readOnly, tools: readOnly ? true : (options.tools ?? false) };\n}\n\n/**\n * Runs one prompt through a harness's normalized non-interactive invocation.\n *\n * Tool use defaults to a native advisor without tools invocation. Harnesses that\n * cannot disable tools reject that mode; setting `tools` selects their full\n * agent invocation. `model` is translated through the harness-specific recipe.\n * This layer also closes stdin, enforces the timeout, caps the echoed output,\n * and leaves the prompt out of the echoed invocation.\n *\n * @param id - Harness id to run.\n * @param prompt - Prompt sent to the selected harness.\n * @param options - Model, mode, working-directory, and timeout options.\n * @returns {Promise<ToolResult<RunOutcome | RunFailure>>} The capped run outcome or failure.\n */\nexport async function runHarness(\n id: string,\n prompt: string,\n options: RunOptions = {},\n): Promise<ToolResult<RunOutcome | RunFailure>> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n const harness = getHarness(id);\n const structured = options.structured ?? false;\n const { tools, readOnly } = normalizedRunAccess(options);\n const invocationOptions = { model: options.model, structured, tools, readOnly };\n const template = harness.buildInvocation(\"{prompt}\", invocationOptions);\n if (!template) {\n return unsupportedInvocation(harness, id, invocationOptions);\n }\n\n const timeoutSeconds = options.timeoutSeconds ?? RUN_DEFAULT_TIMEOUT_SECONDS;\n\n let result: InvokeResult;\n try {\n result = await harness.invoke(prompt, {\n cwd: options.cwd,\n model: options.model,\n timeoutMs: timeoutSeconds * 1000,\n signal: options.signal,\n structured,\n tools,\n readOnly,\n });\n } catch (error) {\n const details: RunFailure = { error: `Failed to run ${id}: ${errorMessage(error)}` };\n return { content: text(details), details, isError: true };\n }\n\n return completedRun(harness, result, invocationOptions, template.args);\n}\n\n/** MCP server listings for one harness or all of them. */\nexport interface McpListing {\n harnesses: Array<{ id: HarnessId; configs: McpConfigListing[] }>;\n}\n\n/** Marker used only at the tool and CLI boundary, leaving config reads lossless for edits. */\nconst MCP_REDACTED_VALUE = \"<redacted>\";\nconst MCP_CONFIG_ERROR = \"Unable to read or parse MCP config\";\n\nfunction redactMcpValues(values: Readonly<Record<string, string>>): Record<string, string> {\n return Object.fromEntries(Object.keys(values).map((key) => [key, MCP_REDACTED_VALUE]));\n}\n\n/** Result of one MCP config mutation. */\nexport interface McpMutation {\n id: HarnessId;\n path: string;\n action: \"added\" | \"replaced\" | \"removed\" | \"noop\";\n}\n\n/** Flat tool parameters describing one MCP server, shared by every surface. */\nexport interface McpServerParams {\n name: string;\n transport?: McpServerConfig[\"transport\"];\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n}\n\n/**\n * Builds the normalized server shape from flat tool parameters.\n *\n * @param params - Flat MCP server parameters.\n * @returns {McpServerConfig} The normalized server configuration.\n */\nexport function toMcpServerConfig(params: McpServerParams): McpServerConfig {\n const server: McpServerConfig = {\n name: params.name,\n transport: params.transport ?? (params.url ? \"http\" : \"stdio\"),\n };\n if (params.command !== undefined) server.command = params.command;\n if (params.args !== undefined) server.args = params.args;\n if (params.env !== undefined) server.env = params.env;\n if (params.url !== undefined) server.url = params.url;\n if (params.headers !== undefined) server.headers = params.headers;\n return server;\n}\n\n/**\n * Lists configured MCP servers, normalized across harness config dialects.\n *\n * @param id - Optional harness id; omission lists every harness.\n * @returns {ToolResult<McpListing | UnknownHarness>} The normalized listing or id error.\n */\nexport function mcpList(id?: string): ToolResult<McpListing | UnknownHarness> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n const targets = id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses();\n const details: McpListing = {\n harnesses: targets\n .map((harness) => ({\n id: harness.id,\n configs: listMcpServers(harness).map((listing) => ({\n ...listing,\n ...(listing.error === undefined ? {} : { error: MCP_CONFIG_ERROR }),\n servers: listing.servers.map((server) => ({\n ...server,\n ...(server.env === undefined ? {} : { env: redactMcpValues(server.env) }),\n ...(server.headers === undefined ? {} : { headers: redactMcpValues(server.headers) }),\n })),\n })),\n }))\n .filter((entry) => entry.configs.length > 0),\n };\n\n return { content: text(details), details };\n}\n\nfunction mcpMutate(\n id: string,\n mutate: (harness: Harness) => { path: string; action: McpMutation[\"action\"] },\n): ToolResult<McpMutation | RunFailure> {\n if (!isHarnessId(id)) return unknownHarness(id);\n\n try {\n const { path, action } = mutate(getHarness(id));\n const details: McpMutation = { id, path, action };\n return { content: text(details), details, ...(action === \"noop\" ? { isError: true } : {}) };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n\n/**\n * Adds or replaces one MCP server in a harness's config.\n *\n * @param id - Target harness id.\n * @param params - Server parameters to normalize and write.\n * @param scope - User or project config scope.\n * @returns {ToolResult<McpMutation | RunFailure>} The mutation outcome or failure.\n */\nexport function mcpAdd(\n id: string,\n params: McpServerParams,\n scope: \"user\" | \"project\" = \"user\",\n): ToolResult<McpMutation | RunFailure> {\n return mcpMutate(id, (harness) => {\n const { path, replaced } = addMcpServer(harness, toMcpServerConfig(params), scope);\n return { path, action: replaced ? \"replaced\" : \"added\" };\n });\n}\n\n/**\n * Removes one MCP server from a harness's config.\n *\n * @param id - Target harness id.\n * @param name - Server name to remove.\n * @param scope - User or project config scope.\n * @returns {ToolResult<McpMutation | RunFailure>} The mutation outcome or failure.\n */\nexport function mcpRemove(\n id: string,\n name: string,\n scope: \"user\" | \"project\" = \"user\",\n): ToolResult<McpMutation | RunFailure> {\n return mcpMutate(id, (harness) => {\n const { path, removed } = removeMcpServer(harness, name, scope);\n return { path, action: removed ? \"removed\" : \"noop\" };\n });\n}\n\n/**\n * Pushes the master MCP list from ~/.config/agntn/mcp.jsonc into harness configs.\n *\n * @param id - Optional harness id; omission targets every harness.\n * @returns {ToolResult<SyncReport | RunFailure>} The sync report or failure.\n */\nexport function mcpSync(id?: string): ToolResult<SyncReport | RunFailure> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n try {\n // Preflight before any write: a typo in excludes must fail the whole run,\n // not silently leave the misspelled harness unprotected.\n const unknown = readMasterMcpServers().excludes.filter((entry) => !isHarnessId(entry));\n if (unknown.length > 0) {\n const details: RunFailure = {\n error: `Master MCP list excludes unknown harnesses: ${unknown.join(\", \")}`,\n known: listHarnesses(),\n };\n return { content: text(details), details, isError: true };\n }\n const details = syncMcpServers(\n id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(),\n );\n return { content: text(details), details };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n\n/**\n * Links every harness's global instructions file to the master AGENTS.md.\n *\n * @param id - Optional harness id; omission targets every harness.\n * @param check - Report intended changes without writing them.\n * @returns {ToolResult<AgentsSyncReport | RunFailure>} The sync report or failure.\n */\nexport function agentsSync(id?: string, check = false): ToolResult<AgentsSyncReport | RunFailure> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n try {\n // Preflight before any write: a typo in excludes must fail the whole run,\n // not silently adopt the harness it was meant to protect.\n const unknown = readAgentsConfig().excludes.filter((entry) => !isHarnessId(entry));\n if (unknown.length > 0) {\n const details: RunFailure = {\n error: `Agents config excludes unknown harnesses: ${unknown.join(\", \")}`,\n known: listHarnesses(),\n };\n return { content: text(details), details, isError: true };\n }\n const details = syncAgentsFiles(\n id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(),\n check,\n );\n return { content: text(details), details };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n\n/**\n * Synchronizes canonical Markdown prompt templates into harness destinations.\n *\n * @param id - Optional harness id; omission targets every harness.\n * @param check - Report intended changes without writing them.\n * @returns {ToolResult<PromptSyncReport | RunFailure>} The sync report or failure.\n */\nexport function promptsSync(id?: string, check = false): ToolResult<PromptSyncReport | RunFailure> {\n if (id !== undefined && !isHarnessId(id)) return unknownHarness(id);\n\n try {\n const details = syncPromptTemplates(\n id !== undefined && isHarnessId(id) ? [getHarness(id)] : getAllHarnesses(),\n check,\n );\n return { content: text(details), details };\n } catch (error) {\n const details: RunFailure = { error: errorMessage(error) };\n return { content: text(details), details, isError: true };\n }\n}\n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|
|
12
12
|
*/
|
|
13
|
-
interface McpSchemaBuilder<I, S> {
|
|
13
|
+
export interface McpSchemaBuilder<I, S> {
|
|
14
14
|
Object(properties: Readonly<Record<string, I>>, options?: object): S;
|
|
15
15
|
String(options?: object): I;
|
|
16
16
|
Integer(options?: object): I;
|
|
@@ -21,15 +21,15 @@ interface McpSchemaBuilder<I, S> {
|
|
|
21
21
|
Literal(value: string, options?: object): I;
|
|
22
22
|
Optional(schema: I): I;
|
|
23
23
|
}
|
|
24
|
-
declare const HARNESS_INFO_MAX_ITEMS = 20;
|
|
25
|
-
declare const RUN_TIMEOUT_DEFAULT_SECONDS = 600;
|
|
24
|
+
export declare const HARNESS_INFO_MAX_ITEMS = 20;
|
|
25
|
+
export declare const RUN_TIMEOUT_DEFAULT_SECONDS = 600;
|
|
26
26
|
/**
|
|
27
27
|
* Builds the parameter schemas for all harness tools with the host's TypeBox.
|
|
28
28
|
*
|
|
29
29
|
* @param Type - Host-provided TypeBox-compatible schema builder.
|
|
30
30
|
* @returns {Record<string, S>} Schemas keyed by harness tool operation.
|
|
31
31
|
*/
|
|
32
|
-
declare function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>): {
|
|
32
|
+
export declare function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>): {
|
|
33
33
|
detect: S;
|
|
34
34
|
info: S;
|
|
35
35
|
models: S;
|
|
@@ -37,6 +37,7 @@ declare function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>): {
|
|
|
37
37
|
mcpList: S;
|
|
38
38
|
mcpSync: S;
|
|
39
39
|
agentsSync: S;
|
|
40
|
+
promptsSync: S;
|
|
40
41
|
mcpAdd: S;
|
|
41
42
|
mcpRemove: S;
|
|
42
43
|
};
|
|
@@ -45,16 +46,16 @@ declare function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>): {
|
|
|
45
46
|
* builders' literal types, so hosts annotate their execute callbacks with
|
|
46
47
|
* these instead of TypeBox Static inference.
|
|
47
48
|
*/
|
|
48
|
-
interface InfoParams {
|
|
49
|
+
export interface InfoParams {
|
|
49
50
|
id: string | string[];
|
|
50
51
|
}
|
|
51
|
-
interface ModelsParams {
|
|
52
|
+
export interface ModelsParams {
|
|
52
53
|
id: string;
|
|
53
54
|
search?: string;
|
|
54
55
|
cwd?: string;
|
|
55
56
|
timeoutSeconds?: number;
|
|
56
57
|
}
|
|
57
|
-
interface RunParams {
|
|
58
|
+
export interface RunParams {
|
|
58
59
|
id: string;
|
|
59
60
|
prompt: string;
|
|
60
61
|
cwd?: string;
|
|
@@ -64,17 +65,21 @@ interface RunParams {
|
|
|
64
65
|
tools: boolean;
|
|
65
66
|
readOnly?: boolean;
|
|
66
67
|
}
|
|
67
|
-
interface McpListParams {
|
|
68
|
+
export interface McpListParams {
|
|
68
69
|
id?: string;
|
|
69
70
|
}
|
|
70
|
-
interface McpSyncParams {
|
|
71
|
+
export interface McpSyncParams {
|
|
71
72
|
id?: string;
|
|
72
73
|
}
|
|
73
|
-
interface AgentsSyncParams {
|
|
74
|
+
export interface AgentsSyncParams {
|
|
74
75
|
id?: string;
|
|
75
76
|
check?: boolean;
|
|
76
77
|
}
|
|
77
|
-
interface
|
|
78
|
+
export interface PromptsSyncParams {
|
|
79
|
+
id?: string;
|
|
80
|
+
check?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface McpAddParams {
|
|
78
83
|
id: string;
|
|
79
84
|
name: string;
|
|
80
85
|
command?: string;
|
|
@@ -85,10 +90,9 @@ interface McpAddParams {
|
|
|
85
90
|
headers?: Record<string, string>;
|
|
86
91
|
scope?: "user" | "project";
|
|
87
92
|
}
|
|
88
|
-
interface McpRemoveParams {
|
|
93
|
+
export interface McpRemoveParams {
|
|
89
94
|
id: string;
|
|
90
95
|
name: string;
|
|
91
96
|
scope?: "user" | "project";
|
|
92
97
|
}
|
|
93
|
-
export { AgentsSyncParams, HARNESS_INFO_MAX_ITEMS, InfoParams, McpAddParams, McpListParams, McpRemoveParams, McpSchemaBuilder, McpSyncParams, ModelsParams, RUN_TIMEOUT_DEFAULT_SECONDS, RunParams, harnessToolSchemas };
|
|
94
98
|
//# sourceMappingURL=tool-schemas.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-schemas.d.mts","names":[],"sources":["../../src/tool-schemas.ts"],"mappings":"AAaA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tool-schemas.d.mts","names":[],"sources":["../../src/tool-schemas.ts"],"mappings":"AAaA;;;;;;;;;;;;iBAAiB,iBAAiB,GAAG;EACnC,OAAO,YAAY,SAAS,eAAe,KAAK,mBAAmB;EACnE,OAAO,mBAAmB;EAC1B,QAAQ,mBAAmB;EAC3B,QAAQ,mBAAmB;EAC3B,MAAM,MAAM,GAAG,mBAAmB;EAClC,OAAO,KAAK,GAAG,OAAO,GAAG,mBAAmB;EAC5C,MAAM,kBAAkB,KAAK,mBAAmB;EAChD,QAAQ,eAAe,mBAAmB;EAC1C,SAAS,QAAQ,IAAI;;qBAGV;qBACA;;;;;;;wBAQG,mBAAmB,GAAG,GAAG,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;iBAiKlD;EACf;;iBAGe;EACf;EACA;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf;;iBAGe;EACf;;iBAGe;EACf;EACA;;iBAGe;EACf;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA,UAAU;EACV;;iBAGe;EACf;EACA;EACA"}
|
|
@@ -65,6 +65,10 @@ function harnessToolSchemas(Type) {
|
|
|
65
65
|
id: Type.Optional(harnessId("Harness id; omit to sync every harness")),
|
|
66
66
|
check: Type.Optional(Type.Boolean({ description: "Report what would change without writing anything" }))
|
|
67
67
|
}),
|
|
68
|
+
promptsSync: Type.Object({
|
|
69
|
+
id: Type.Optional(harnessId("Harness id; omit to sync every harness")),
|
|
70
|
+
check: Type.Optional(Type.Boolean({ description: "Report what would change without writing anything" }))
|
|
71
|
+
}),
|
|
68
72
|
mcpAdd: Type.Object({
|
|
69
73
|
id: harnessId("Harness id"),
|
|
70
74
|
name: Type.String({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-schemas.mjs","names":[],"sources":["../../src/tool-schemas.ts"],"sourcesContent":["/**\n * Tool parameter schemas shared by every surface (MCP server, Pi and OMP\n * extensions). Each surface owns a different TypeBox build (the extensions\n * must use their host's facade), so the schemas are a factory over a minimal\n * structural builder instead of importing typebox here.\n */\n\n/**\n * The subset of the TypeBox builder the tool schemas need. `I` is the schema\n * type the builder accepts as input, `S` the (possibly narrower) type it\n * returns; OMP's facade accepts its own `AnySchema` while producing schemas\n * that satisfy the host's stricter `TSchema`.\n */\nexport interface McpSchemaBuilder<I, S> {\n Object(properties: Readonly<Record<string, I>>, options?: object): S;\n String(options?: object): I;\n Integer(options?: object): I;\n Boolean(options?: object): I;\n Array(item: I, options?: object): I;\n Record(key: I, value: I, options?: object): I;\n Union(schemas: readonly I[], options?: object): I;\n Literal(value: string, options?: object): I;\n Optional(schema: I): I;\n}\n\nexport const HARNESS_INFO_MAX_ITEMS = 20;\nexport const RUN_TIMEOUT_DEFAULT_SECONDS = 600;\n\n/**\n * Builds the parameter schemas for all harness tools with the host's TypeBox.\n *\n * @param Type - Host-provided TypeBox-compatible schema builder.\n * @returns {Record<string, S>} Schemas keyed by harness tool operation.\n */\nexport function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>) {\n const harnessId = (description: string) =>\n Type.String({ description, minLength: 1, maxLength: 50, pattern: \"^[a-z][a-z0-9-]*$\" });\n\n const stringRecord = (description: string) =>\n Type.Record(Type.String({ maxLength: 256 }), Type.String({ maxLength: 4096 }), {\n description,\n });\n\n const scope = Type.Optional(\n Type.Union([Type.Literal(\"user\"), Type.Literal(\"project\")], {\n description: \"Which config file to target (default user)\",\n }),\n );\n\n return {\n detect: Type.Object({}),\n info: Type.Object({\n id: Type.Union(\n [\n harnessId(\"Harness id\"),\n Type.Array(harnessId(\"Harness id\"), {\n minItems: 1,\n maxItems: HARNESS_INFO_MAX_ITEMS,\n }),\n ],\n { description: \"Harness id, or a list of ids to inspect in one call\" },\n ),\n }),\n models: Type.Object({\n id: harnessId(\"Harness id\"),\n search: Type.Optional(\n Type.String({\n description: \"Optional native model search filter\",\n minLength: 1,\n maxLength: 1024,\n }),\n ),\n cwd: Type.Optional(\n Type.String({\n description: \"Working directory used while loading harness configuration\",\n minLength: 1,\n maxLength: 4096,\n }),\n ),\n timeoutSeconds: Type.Optional(\n Type.Integer({\n description: `Wall-clock budget in seconds (default ${RUN_TIMEOUT_DEFAULT_SECONDS})`,\n minimum: 1,\n maximum: 3600,\n }),\n ),\n }),\n run: Type.Object({\n id: harnessId(\"Harness id\"),\n prompt: Type.String({\n description: \"Prompt to send to the harness\",\n minLength: 1,\n maxLength: 100000,\n }),\n cwd: Type.Optional(\n Type.String({\n description: \"Working directory for the run\",\n minLength: 1,\n maxLength: 4096,\n }),\n ),\n model: Type.Optional(\n Type.String({\n description: \"Harness-native model id or selector\",\n minLength: 1,\n maxLength: 512,\n }),\n ),\n timeoutSeconds: Type.Optional(\n Type.Integer({\n description: `Wall-clock budget in seconds (default ${RUN_TIMEOUT_DEFAULT_SECONDS})`,\n minimum: 1,\n maximum: 3600,\n }),\n ),\n structured: Type.Optional(\n Type.Boolean({\n description: \"Use the harness's structured (JSON) output mode instead of plain text\",\n }),\n ),\n tools: Type.Boolean({\n description:\n \"Explicit execution mode. Set true when the task needs any harness tools, including Grok native X search. Set false only for an advisor without tools.\",\n }),\n readOnly: Type.Optional(\n Type.Boolean({\n description:\n \"Set with tools=true to require native read-only tool enforcement. Unsupported harnesses reject the run instead of widening access.\",\n }),\n ),\n }),\n mcpList: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to list every harness\")),\n }),\n mcpSync: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to sync every harness\")),\n }),\n agentsSync: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to sync every harness\")),\n check: Type.Optional(\n Type.Boolean({ description: \"Report what would change without writing anything\" }),\n ),\n }),\n mcpAdd: Type.Object({\n id: harnessId(\"Harness id\"),\n name: Type.String({\n description: \"Server name\",\n minLength: 1,\n maxLength: 100,\n pattern: \"^[A-Za-z0-9][A-Za-z0-9_-]*$\",\n }),\n command: Type.Optional(\n Type.String({ description: \"Binary for a stdio server\", minLength: 1, maxLength: 4096 }),\n ),\n args: Type.Optional(\n Type.Array(Type.String({ maxLength: 4096 }), {\n description: \"Arguments for a stdio server\",\n maxItems: 64,\n }),\n ),\n env: Type.Optional(stringRecord(\"Environment variables for a stdio server\")),\n url: Type.Optional(\n Type.String({ description: \"URL for an http/sse server\", minLength: 1, maxLength: 4096 }),\n ),\n transport: Type.Optional(\n Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\"), Type.Literal(\"sse\")], {\n description: \"Transport; inferred from url/command when omitted\",\n }),\n ),\n headers: Type.Optional(stringRecord(\"Headers for an http/sse server\")),\n scope,\n }),\n mcpRemove: Type.Object({\n id: harnessId(\"Harness id\"),\n name: Type.String({\n description: \"Server name\",\n minLength: 1,\n maxLength: 100,\n }),\n scope,\n }),\n };\n}\n\n/**\n * Parameter types matching the schemas above. The generic factory erases the\n * builders' literal types, so hosts annotate their execute callbacks with\n * these instead of TypeBox Static inference.\n */\nexport interface InfoParams {\n id: string | string[];\n}\n\nexport interface ModelsParams {\n id: string;\n search?: string;\n cwd?: string;\n timeoutSeconds?: number;\n}\n\nexport interface RunParams {\n id: string;\n prompt: string;\n cwd?: string;\n model?: string;\n timeoutSeconds?: number;\n structured?: boolean;\n tools: boolean;\n readOnly?: boolean;\n}\n\nexport interface McpListParams {\n id?: string;\n}\n\nexport interface McpSyncParams {\n id?: string;\n}\n\nexport interface AgentsSyncParams {\n id?: string;\n check?: boolean;\n}\n\nexport interface McpAddParams {\n id: string;\n name: string;\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n transport?: \"stdio\" | \"http\" | \"sse\";\n headers?: Record<string, string>;\n scope?: \"user\" | \"project\";\n}\n\nexport interface McpRemoveParams {\n id: string;\n name: string;\n scope?: \"user\" | \"project\";\n}\n"],"mappings":"AAyBA,MAAa,yBAAyB;AACtC,MAAa,8BAA8B;;;;;;EAQ3C,SAAgB;CACd,CAAA;CACgB,MAAA,gBAAA,gBAAA,KAAA,OAAA,KAAA,OAAA,EAAA,WAAA,IAAA,CAAA,GAAA,KAAA,OAAA,EAAA,WAAA,KAAA,CAAA,GAAA,EAAA,YAAA,CAAA;CAAa,MAAA,QAAW,KAAA,SAAA,KAAA,MAAA,CAAA,KAAA,QAAA,MAAA,GAAA,KAAA,QAAA,SAAA,CAAA,GAAA,EAAA,aAAA,6CAAA,CAAA,CAAA;CAAG,OAAA;EAAe,QAAA,KAAS,OAAA,CAAA,CAAA;EAAqB,MAAA,KAAA,OAAA,EAAA,IAAA,KAAA,MAAA,CAAA,UAAA,YAAA,GAAA,KAAA,MAAA,UAAA,YAAA,GAAA;GAExF,UAAM;GAKN,UAAM;EAMN,CAAA,CAAA,GAAA,EAAO,aAAA,sDAAA,CAAA,EAAA,CAAA;EACL,QAAQ,KAAK,OAAO;GACpB,IAAA,UAAW,YACL;GAIE,QAAA,KAAU,SAAA,KAAA,OAAA;IACV,aAAA;IAEJ,WACE;IAGN,WAAa;GACX,CAAA,CAAA;GACA,KAAA,KAAQ,SAAK,KACX,OAAK;IACH,aAAa;IACb,WAAW;IACX,WAAW;GACb,CAAC,CACH;GACA,gBAAU,KACR,SAAK,KAAO,QAAA;IACV,aAAa;IACb,SAAA;IACA,SAAA;GACF,CAAC,CACH;EACA,CAAA;EAEI,KAAA,KAAA,OAAa;GACb,IAAA,UAAS,YAAA;GACT,QAAA,KAAS,OAAA;IACV,aACH;IACD,WAAA;IACD,WAAU;GACR,CAAA;GACA,KAAA,KAAQ,SAAK,KAAO,OAAA;IAClB,aAAa;IACb,WAAW;IACX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,KAAA,QAAW,KAAA;GAAK,GACzF,EAAA,aAAA,oDAAA,CAAA,CAAA;GACA,SAAA,KAAW,SAAK,aACH,gCAAA,CAAA;GAAC;EAAuB,CAAA;EAAsB,WAAK,KAAQ,OAAK;GAAC,IAAG,UAC7E,YAAa;GAGjB,MAAA,KAAS,OAAK;IACd,aAAA;IACD,WAAA;IACD,WAAW;GACT,CAAA;GACA;EACE,CAAA;CACA;AACA;AAEF,SAAA,wBAAA,6BAAA"}
|
|
1
|
+
{"version":3,"file":"tool-schemas.mjs","names":[],"sources":["../../src/tool-schemas.ts"],"sourcesContent":["/**\n * Tool parameter schemas shared by every surface (MCP server, Pi and OMP\n * extensions). Each surface owns a different TypeBox build (the extensions\n * must use their host's facade), so the schemas are a factory over a minimal\n * structural builder instead of importing typebox here.\n */\n\n/**\n * The subset of the TypeBox builder the tool schemas need. `I` is the schema\n * type the builder accepts as input, `S` the (possibly narrower) type it\n * returns; OMP's facade accepts its own `AnySchema` while producing schemas\n * that satisfy the host's stricter `TSchema`.\n */\nexport interface McpSchemaBuilder<I, S> {\n Object(properties: Readonly<Record<string, I>>, options?: object): S;\n String(options?: object): I;\n Integer(options?: object): I;\n Boolean(options?: object): I;\n Array(item: I, options?: object): I;\n Record(key: I, value: I, options?: object): I;\n Union(schemas: readonly I[], options?: object): I;\n Literal(value: string, options?: object): I;\n Optional(schema: I): I;\n}\n\nexport const HARNESS_INFO_MAX_ITEMS = 20;\nexport const RUN_TIMEOUT_DEFAULT_SECONDS = 600;\n\n/**\n * Builds the parameter schemas for all harness tools with the host's TypeBox.\n *\n * @param Type - Host-provided TypeBox-compatible schema builder.\n * @returns {Record<string, S>} Schemas keyed by harness tool operation.\n */\nexport function harnessToolSchemas<I, S>(Type: McpSchemaBuilder<I, S>) {\n const harnessId = (description: string) =>\n Type.String({ description, minLength: 1, maxLength: 50, pattern: \"^[a-z][a-z0-9-]*$\" });\n\n const stringRecord = (description: string) =>\n Type.Record(Type.String({ maxLength: 256 }), Type.String({ maxLength: 4096 }), {\n description,\n });\n\n const scope = Type.Optional(\n Type.Union([Type.Literal(\"user\"), Type.Literal(\"project\")], {\n description: \"Which config file to target (default user)\",\n }),\n );\n\n return {\n detect: Type.Object({}),\n info: Type.Object({\n id: Type.Union(\n [\n harnessId(\"Harness id\"),\n Type.Array(harnessId(\"Harness id\"), {\n minItems: 1,\n maxItems: HARNESS_INFO_MAX_ITEMS,\n }),\n ],\n { description: \"Harness id, or a list of ids to inspect in one call\" },\n ),\n }),\n models: Type.Object({\n id: harnessId(\"Harness id\"),\n search: Type.Optional(\n Type.String({\n description: \"Optional native model search filter\",\n minLength: 1,\n maxLength: 1024,\n }),\n ),\n cwd: Type.Optional(\n Type.String({\n description: \"Working directory used while loading harness configuration\",\n minLength: 1,\n maxLength: 4096,\n }),\n ),\n timeoutSeconds: Type.Optional(\n Type.Integer({\n description: `Wall-clock budget in seconds (default ${RUN_TIMEOUT_DEFAULT_SECONDS})`,\n minimum: 1,\n maximum: 3600,\n }),\n ),\n }),\n run: Type.Object({\n id: harnessId(\"Harness id\"),\n prompt: Type.String({\n description: \"Prompt to send to the harness\",\n minLength: 1,\n maxLength: 100000,\n }),\n cwd: Type.Optional(\n Type.String({\n description: \"Working directory for the run\",\n minLength: 1,\n maxLength: 4096,\n }),\n ),\n model: Type.Optional(\n Type.String({\n description: \"Harness-native model id or selector\",\n minLength: 1,\n maxLength: 512,\n }),\n ),\n timeoutSeconds: Type.Optional(\n Type.Integer({\n description: `Wall-clock budget in seconds (default ${RUN_TIMEOUT_DEFAULT_SECONDS})`,\n minimum: 1,\n maximum: 3600,\n }),\n ),\n structured: Type.Optional(\n Type.Boolean({\n description: \"Use the harness's structured (JSON) output mode instead of plain text\",\n }),\n ),\n tools: Type.Boolean({\n description:\n \"Explicit execution mode. Set true when the task needs any harness tools, including Grok native X search. Set false only for an advisor without tools.\",\n }),\n readOnly: Type.Optional(\n Type.Boolean({\n description:\n \"Set with tools=true to require native read-only tool enforcement. Unsupported harnesses reject the run instead of widening access.\",\n }),\n ),\n }),\n mcpList: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to list every harness\")),\n }),\n mcpSync: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to sync every harness\")),\n }),\n agentsSync: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to sync every harness\")),\n check: Type.Optional(\n Type.Boolean({ description: \"Report what would change without writing anything\" }),\n ),\n }),\n promptsSync: Type.Object({\n id: Type.Optional(harnessId(\"Harness id; omit to sync every harness\")),\n check: Type.Optional(\n Type.Boolean({ description: \"Report what would change without writing anything\" }),\n ),\n }),\n mcpAdd: Type.Object({\n id: harnessId(\"Harness id\"),\n name: Type.String({\n description: \"Server name\",\n minLength: 1,\n maxLength: 100,\n pattern: \"^[A-Za-z0-9][A-Za-z0-9_-]*$\",\n }),\n command: Type.Optional(\n Type.String({ description: \"Binary for a stdio server\", minLength: 1, maxLength: 4096 }),\n ),\n args: Type.Optional(\n Type.Array(Type.String({ maxLength: 4096 }), {\n description: \"Arguments for a stdio server\",\n maxItems: 64,\n }),\n ),\n env: Type.Optional(stringRecord(\"Environment variables for a stdio server\")),\n url: Type.Optional(\n Type.String({ description: \"URL for an http/sse server\", minLength: 1, maxLength: 4096 }),\n ),\n transport: Type.Optional(\n Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\"), Type.Literal(\"sse\")], {\n description: \"Transport; inferred from url/command when omitted\",\n }),\n ),\n headers: Type.Optional(stringRecord(\"Headers for an http/sse server\")),\n scope,\n }),\n mcpRemove: Type.Object({\n id: harnessId(\"Harness id\"),\n name: Type.String({\n description: \"Server name\",\n minLength: 1,\n maxLength: 100,\n }),\n scope,\n }),\n };\n}\n\n/**\n * Parameter types matching the schemas above. The generic factory erases the\n * builders' literal types, so hosts annotate their execute callbacks with\n * these instead of TypeBox Static inference.\n */\nexport interface InfoParams {\n id: string | string[];\n}\n\nexport interface ModelsParams {\n id: string;\n search?: string;\n cwd?: string;\n timeoutSeconds?: number;\n}\n\nexport interface RunParams {\n id: string;\n prompt: string;\n cwd?: string;\n model?: string;\n timeoutSeconds?: number;\n structured?: boolean;\n tools: boolean;\n readOnly?: boolean;\n}\n\nexport interface McpListParams {\n id?: string;\n}\n\nexport interface McpSyncParams {\n id?: string;\n}\n\nexport interface AgentsSyncParams {\n id?: string;\n check?: boolean;\n}\n\nexport interface PromptsSyncParams {\n id?: string;\n check?: boolean;\n}\n\nexport interface McpAddParams {\n id: string;\n name: string;\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n url?: string;\n transport?: \"stdio\" | \"http\" | \"sse\";\n headers?: Record<string, string>;\n scope?: \"user\" | \"project\";\n}\n\nexport interface McpRemoveParams {\n id: string;\n name: string;\n scope?: \"user\" | \"project\";\n}\n"],"mappings":"AAyBA,MAAa,yBAAyB;AACtC,MAAa,8BAA8B;;;;;;EAQ3C,SAAgB;CACd,CAAA;CACgB,MAAA,gBAAA,gBAAA,KAAA,OAAA,KAAA,OAAA,EAAA,WAAA,IAAA,CAAA,GAAA,KAAA,OAAA,EAAA,WAAA,KAAA,CAAA,GAAA,EAAA,YAAA,CAAA;CAAa,MAAA,QAAW,KAAA,SAAA,KAAA,MAAA,CAAA,KAAA,QAAA,MAAA,GAAA,KAAA,QAAA,SAAA,CAAA,GAAA,EAAA,aAAA,6CAAA,CAAA,CAAA;CAAG,OAAA;EAAe,QAAA,KAAS,OAAA,CAAA,CAAA;EAAqB,MAAA,KAAA,OAAA,EAAA,IAAA,KAAA,MAAA,CAAA,UAAA,YAAA,GAAA,KAAA,MAAA,UAAA,YAAA,GAAA;GAExF,UAAM;GAKN,UAAM;EAMN,CAAA,CAAA,GAAA,EAAO,aAAA,sDAAA,CAAA,EAAA,CAAA;EACL,QAAQ,KAAK,OAAO;GACpB,IAAA,UAAW,YACL;GAIE,QAAA,KAAU,SAAA,KAAA,OAAA;IACV,aAAA;IAEJ,WACE;IAGN,WAAa;GACX,CAAA,CAAA;GACA,KAAA,KAAQ,SAAK,KACX,O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AAY;IAGb,WAAA;IACD,WAAa;IACX,SAAI;GACJ,CAAA;GACE,SAAA,KAAa,SAAA,KAAA,OAAA;IACb,aAAW;IACX,WAAW;IACX,WAAS;GACX,CAAC,CAAA;GACD,MAAA,KAAS,SAAK,KACZ,MAAK,KAAO,OAAA,EAAA,WAAA,KAAA,CAAA,GAAA;IAAE,aAAa;IAA6B,UAAA;GAAc,CAAA,CAAA;GAAgB,KACxF,KAAA,SAAA,aAAA,0CAAA,CAAA;GACA,KAAA,KAAM,SAAK,KACT,OAAW;IACT,aAAa;IACb,WAAU;IACX,WACH;GACA,CAAA,CAAA;GACA,WAAU,KAAA,SACH,KAAA,MAAO;IAAE,KAAA,QAAa,OAAA;IAA8B,KAAA,QAAW,MAAA;IAAG,KAAA,QAAW,KAAA;GAAK,GACzF,EAAA,aAAA,oDAAA,CAAA,CAAA;GACA,SAAA,KAAW,SAAK,aACH,gCAAA,CAAA;GAAC;EAAuB,CAAA;EAAsB,WAAK,KAAQ,OAAK;GAAC,IAAG,UAC7E,YAAa;GAGjB,MAAA,KAAS,OAAK;IACd,aAAA;IACD,WAAA;IACD,WAAW;GACT,CAAA;GACA;EACE,CAAA;CACA;AACA;AAEF,SAAA,wBAAA,6BAAA"}
|
package/dist/_chunks/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":["pkg.version"],"sources":["../../package.json","../../src/types.ts"],"sourcesContent":["","import pkg from \"../package.json\" with { type: \"json\" };\n\nexport const version: string = pkg.version;\n\nexport type HarnessId =\n | \"antigravity\"\n | \"codex\"\n | \"gemini\"\n | \"grok\"\n | \"claude\"\n | \"opencode\"\n | \"cursor\"\n | \"freebuff\"\n | \"github-copilot\"\n | \"mastracode\"\n | \"omp\"\n | \"pi\"\n | \"prime-agent\";\nexport type EvidenceLevel = \"official\" | \"community\" | \"inferred\";\nexport type Platform = \"linux\" | \"darwin\" | \"win32\";\n\nexport interface PathCandidate {\n path: string;\n scope: \"user\" | \"project\" | \"system\" | \"data\";\n level: EvidenceLevel;\n platforms?: Platform[];\n note?: string;\n}\n\nexport interface StorageDescriptor {\n format: string;\n level: EvidenceLevel;\n note?: string;\n}\n\nexport interface HarnessCapabilities {\n mcp: boolean;\n vision: boolean;\n /** Audio reaches the model without conversion or MCP. */\n audio: boolean;\n /** Video reaches the model without conversion or MCP. */\n video: boolean;\n tools: boolean;\n streaming: boolean;\n}\n\n/** How to run one prompt through the harness non-interactively. */\nexport interface HarnessInvocation {\n /** Binary to spawn; defaults to the harness's first `binaries` entry. */\n binary?: string;\n /** Full agent argument template; every \"{prompt}\" is replaced with the prompt text. */\n args: string[];\n /** Structured full agent argument template. */\n jsonArgs?: string[];\n /** Advisor argument template without tools; absent when the CLI cannot disable tools. */\n noToolsArgs?: string[];\n /** Structured advisor argument template without tools. */\n noToolsJsonArgs?: string[];\n /** Agent argument template whose native sandbox enforces read-only tool access. */\n readOnlyArgs?: string[];\n /** Structured agent argument template with read-only tool access. */\n readOnlyJsonArgs?: string[];\n /** Lowest CLI version whose read-only enforcement was verified; older or unknown versions reject read-only runs. */\n readOnlyMinVersion?: string;\n /** Arguments appended when a model is selected; every \"{model}\" is replaced. */\n modelArgs?: string[];\n level: EvidenceLevel;\n note?: string;\n}\n\n/** Invocation modes a harness supports without fallback or prompt-only restrictions. */\nexport interface HarnessInvocationModes {\n advisor: boolean;\n advisorStructured: boolean;\n readOnly: boolean;\n readOnlyStructured: boolean;\n agent: boolean;\n agentStructured: boolean;\n}\n\n/** How to ask one harness CLI for the models currently available to it. */\nexport interface HarnessModelListing {\n /** Arguments used when no search filter is supplied. */\n args: string[];\n /** Optional argument template for a search filter; every \"{search}\" is replaced. */\n searchArgs?: string[];\n level: EvidenceLevel;\n note?: string;\n}\n\n/** One model normalized from a harness's native model-listing output. */\nexport interface AvailableModel {\n provider: string;\n id: string;\n contextWindow: number;\n maxOutputTokens: number;\n thinking: boolean;\n images: boolean;\n}\n\n/** Options for querying the models available to one harness. */\nexport interface ListModelsOptions {\n search?: string;\n cwd?: string;\n env?: Record<string, string>;\n /** Milliseconds before cleanup starts. Unset or 0 disables the deadline. */\n timeoutMs?: number;\n /** Cancel with the same process cleanup as a timeout. */\n signal?: AbortSignal;\n}\n\nexport interface InvokeOptions {\n cwd?: string;\n env?: Record<string, string>;\n /** Harness-native model id or selector. */\n model?: string;\n /** Enable the spawned harness's tools; defaults to advisor without tools mode. */\n tools?: boolean;\n /** Require native enforcement of read-only tool access. Implies `tools: true`. */\n readOnly?: boolean;\n /** Milliseconds before cleanup starts. Unset or 0 disables the deadline. */\n timeoutMs?: number;\n /** Cancel with the same process cleanup as a timeout. */\n signal?: AbortSignal;\n /** Use the harness's structured (JSON) output mode instead of plain text. */\n structured?: boolean;\n}\n\nexport interface InvokeResult {\n command: string;\n args: string[];\n stdout: string;\n stderr: string;\n /** Process exit code; null when terminated by a signal, timeout, or cancellation. */\n exitCode: number | null;\n timedOut: boolean;\n /** True when caller cancellation wins over the deadline or completion. */\n aborted: boolean;\n}\n\n/** Result of one native model-listing command. */\nexport interface ListModelsResult extends InvokeResult {\n /** Empty on a successful no-match response or when the command itself failed. */\n models: AvailableModel[];\n}\n\n/** Normalized MCP server entry, shared across every harness dialect. */\nexport interface McpServerConfig {\n name: string;\n transport: \"stdio\" | \"http\" | \"sse\";\n command?: string;\n args?: string[];\n /**\n * Environment for stdio servers. A value that is exactly \"${NAME}\" refers to\n * the variable NAME of the harness environment: dialects with native\n * references keep it, the others resolve it when the entry is written.\n */\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n /** Present only when the harness tracks an on/off state per server. */\n enabled?: boolean;\n}\n\n/** How one harness config file stores its MCP servers. */\nexport interface McpConfigFile extends PathCandidate {\n format: \"json\" | \"toml\";\n /** Object path to the server map inside the file, e.g. [\"mcpServers\"]. */\n key: string[];\n /**\n * Shape of individual entries; \"standard\" is the {command, args, env, url}\n * family
|
|
1
|
+
{"version":3,"file":"types.mjs","names":["pkg.version"],"sources":["../../package.json","../../src/types.ts"],"sourcesContent":["","import pkg from \"../package.json\" with { type: \"json\" };\n\nexport const version: string = pkg.version;\n\nexport type HarnessId =\n | \"antigravity\"\n | \"codex\"\n | \"gemini\"\n | \"grok\"\n | \"claude\"\n | \"opencode\"\n | \"cursor\"\n | \"freebuff\"\n | \"github-copilot\"\n | \"mastracode\"\n | \"omp\"\n | \"pi\"\n | \"prime-agent\";\nexport type EvidenceLevel = \"official\" | \"community\" | \"inferred\";\nexport type Platform = \"linux\" | \"darwin\" | \"win32\";\n\nexport interface PathCandidate {\n path: string;\n scope: \"user\" | \"project\" | \"system\" | \"data\";\n level: EvidenceLevel;\n platforms?: Platform[];\n note?: string;\n}\n\n/** One stable user-scope destination used by prompt template synchronization. */\nexport interface PromptTemplateSyncTarget extends PathCandidate {\n scope: \"user\";\n format: \"markdown\" | \"gemini-toml\";\n}\n\nexport interface StorageDescriptor {\n format: string;\n level: EvidenceLevel;\n note?: string;\n}\n\nexport interface HarnessCapabilities {\n mcp: boolean;\n vision: boolean;\n /** Audio reaches the model without conversion or MCP. */\n audio: boolean;\n /** Video reaches the model without conversion or MCP. */\n video: boolean;\n tools: boolean;\n streaming: boolean;\n}\n\n/** How to run one prompt through the harness non-interactively. */\nexport interface HarnessInvocation {\n /** Binary to spawn; defaults to the harness's first `binaries` entry. */\n binary?: string;\n /** Full agent argument template; every \"{prompt}\" is replaced with the prompt text. */\n args: string[];\n /** Structured full agent argument template. */\n jsonArgs?: string[];\n /** Advisor argument template without tools; absent when the CLI cannot disable tools. */\n noToolsArgs?: string[];\n /** Structured advisor argument template without tools. */\n noToolsJsonArgs?: string[];\n /** Agent argument template whose native sandbox enforces read-only tool access. */\n readOnlyArgs?: string[];\n /** Structured agent argument template with read-only tool access. */\n readOnlyJsonArgs?: string[];\n /** Lowest CLI version whose read-only enforcement was verified; older or unknown versions reject read-only runs. */\n readOnlyMinVersion?: string;\n /** Arguments appended when a model is selected; every \"{model}\" is replaced. */\n modelArgs?: string[];\n level: EvidenceLevel;\n note?: string;\n}\n\n/** Invocation modes a harness supports without fallback or prompt-only restrictions. */\nexport interface HarnessInvocationModes {\n advisor: boolean;\n advisorStructured: boolean;\n readOnly: boolean;\n readOnlyStructured: boolean;\n agent: boolean;\n agentStructured: boolean;\n}\n\n/** How to ask one harness CLI for the models currently available to it. */\nexport interface HarnessModelListing {\n /** Arguments used when no search filter is supplied. */\n args: string[];\n /** Optional argument template for a search filter; every \"{search}\" is replaced. */\n searchArgs?: string[];\n level: EvidenceLevel;\n note?: string;\n}\n\n/** One model normalized from a harness's native model-listing output. */\nexport interface AvailableModel {\n provider: string;\n id: string;\n contextWindow: number;\n maxOutputTokens: number;\n thinking: boolean;\n images: boolean;\n}\n\n/** Options for querying the models available to one harness. */\nexport interface ListModelsOptions {\n search?: string;\n cwd?: string;\n env?: Record<string, string>;\n /** Milliseconds before cleanup starts. Unset or 0 disables the deadline. */\n timeoutMs?: number;\n /** Cancel with the same process cleanup as a timeout. */\n signal?: AbortSignal;\n}\n\nexport interface InvokeOptions {\n cwd?: string;\n env?: Record<string, string>;\n /** Harness-native model id or selector. */\n model?: string;\n /** Enable the spawned harness's tools; defaults to advisor without tools mode. */\n tools?: boolean;\n /** Require native enforcement of read-only tool access. Implies `tools: true`. */\n readOnly?: boolean;\n /** Milliseconds before cleanup starts. Unset or 0 disables the deadline. */\n timeoutMs?: number;\n /** Cancel with the same process cleanup as a timeout. */\n signal?: AbortSignal;\n /** Use the harness's structured (JSON) output mode instead of plain text. */\n structured?: boolean;\n}\n\nexport interface InvokeResult {\n command: string;\n args: string[];\n stdout: string;\n stderr: string;\n /** Process exit code; null when terminated by a signal, timeout, or cancellation. */\n exitCode: number | null;\n timedOut: boolean;\n /** True when caller cancellation wins over the deadline or completion. */\n aborted: boolean;\n}\n\n/** Result of one native model-listing command. */\nexport interface ListModelsResult extends InvokeResult {\n /** Empty on a successful no-match response or when the command itself failed. */\n models: AvailableModel[];\n}\n\n/** Normalized MCP server entry, shared across every harness dialect. */\nexport interface McpServerConfig {\n name: string;\n transport: \"stdio\" | \"http\" | \"sse\";\n command?: string;\n args?: string[];\n /**\n * Environment for stdio servers. A value that is exactly \"${NAME}\" refers to\n * the variable NAME of the harness environment: dialects with native\n * references keep it, the others resolve it when the entry is written.\n */\n env?: Record<string, string>;\n url?: string;\n headers?: Record<string, string>;\n /** Present only when the harness tracks an on/off state per server. */\n enabled?: boolean;\n}\n\n/** How one harness config file stores its MCP servers. */\nexport interface McpConfigFile extends PathCandidate {\n format: \"json\" | \"toml\";\n /** Object path to the server map inside the file, e.g. [\"mcpServers\"]. */\n key: string[];\n /**\n * Shape of individual entries; \"standard\" is the {command, args, env, url}\n * family, \"prime\" is that family with env values as {\"env\": \"NAME\"} references\n * and \"mastracode\" is that family read by its keys alone, type ignored.\n */\n dialect: \"standard\" | \"antigravity\" | \"mastracode\" | \"opencode\" | \"prime\" | \"vscode\";\n}\n\nexport interface HarnessDetection {\n /** Environment variables that indicate running inside this agent. */\n envVars: string[];\n /** Project-level files or directories whose presence indicates this agent. */\n projectMarkers: string[];\n}\n\nexport interface ResolveOptions {\n homeDir?: string;\n projectRoot?: string;\n platform?: Platform;\n}\n\nexport interface ResolvedPaths {\n config: PathCandidate[];\n sessions: PathCandidate[];\n instructions: PathCandidate[];\n skills: PathCandidate[];\n commands: PathCandidate[];\n promptTemplates: PathCandidate[];\n promptTemplateSyncTarget: PromptTemplateSyncTarget | null;\n hooks: PathCandidate[];\n}\n"],"mappings":"ACEA,MAAa,UAAkBA"}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { version } from "./_chunks/types.mjs";
|
|
3
|
-
import { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from "./_chunks/
|
|
3
|
+
import { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from "./_chunks/prompt-sync.mjs";
|
|
4
4
|
import { listHarnessModels } from "./_chunks/tool-operations.mjs";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
|
6
6
|
import { consola } from "consola";
|
|
@@ -164,6 +164,7 @@ const info = defineCommand({
|
|
|
164
164
|
instructions: harness.instructions,
|
|
165
165
|
skills: harness.skills,
|
|
166
166
|
commands: harness.commands,
|
|
167
|
+
promptTemplates: harness.promptTemplates,
|
|
167
168
|
hooks: harness.hooks,
|
|
168
169
|
persistence: harness.persistence,
|
|
169
170
|
detection: harness.detection
|
|
@@ -188,6 +189,7 @@ const info = defineCommand({
|
|
|
188
189
|
renderPathSection("Instructions", harness.instructions);
|
|
189
190
|
renderPathSection("Skills", harness.skills);
|
|
190
191
|
renderPathSection("Commands", harness.commands);
|
|
192
|
+
renderPathSection("Prompt templates", harness.promptTemplates);
|
|
191
193
|
renderPathSection("Hooks", harness.hooks);
|
|
192
194
|
if (harness.persistence.length) {
|
|
193
195
|
consola.log(section("Persistence"));
|
|
@@ -215,6 +217,7 @@ const paths = defineCommand({
|
|
|
215
217
|
renderResolvedPathSection("Instructions", resolved.instructions);
|
|
216
218
|
renderResolvedPathSection("Skills", resolved.skills);
|
|
217
219
|
renderResolvedPathSection("Commands", resolved.commands);
|
|
220
|
+
renderResolvedPathSection("Prompt templates", resolved.promptTemplates);
|
|
218
221
|
renderResolvedPathSection("Hooks", resolved.hooks);
|
|
219
222
|
consola.log("");
|
|
220
223
|
}
|
|
@@ -341,7 +344,8 @@ const main = defineCommand({
|
|
|
341
344
|
run,
|
|
342
345
|
"mcp-servers": () => import("./_chunks/mcp-servers.mjs").then((m) => m.default),
|
|
343
346
|
agents: () => import("./_chunks/agents.mjs").then((m) => m.default),
|
|
344
|
-
|
|
347
|
+
prompts: () => import("./_chunks/prompts.mjs").then((m) => m.default),
|
|
348
|
+
mcp: () => import("./_chunks/mcp.mjs").then((m) => m.default)
|
|
345
349
|
}
|
|
346
350
|
});
|
|
347
351
|
await runMain(main);
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["toToon"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport { encode as toToon } from \"@toon-format/toon\";\nimport { version, type AvailableModel, type InvokeResult } from \"./types.ts\";\nimport { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from \"./registry.ts\";\nimport { listHarnessModels, type ModelsOutcome, type RunFailure } from \"./tool-operations.ts\";\n\nconst s = {\n cyan: (t: string) => `\\x1B[36m${t}\\x1B[0m`,\n hi: (t: string) => `\\x1B[96m${t}\\x1B[0m`,\n green: (t: string) => `\\x1B[32m${t}\\x1B[0m`,\n red: (t: string) => `\\x1B[31m${t}\\x1B[0m`,\n dim: (t: string) => `\\x1B[90m${t}\\x1B[0m`,\n bold: (t: string) => `\\x1B[1m${t}\\x1B[0m`,\n white: (t: string) => `\\x1B[97m${t}\\x1B[0m`,\n};\n\nfunction header(title: string) {\n return `\\n ${s.bold(s.cyan(title))}`;\n}\n\nfunction section(title: string) {\n return `\\n ${s.cyan(\"▸\")} ${s.white(title)}`;\n}\n\nfunction entry(content: string) {\n return ` ${content}`;\n}\n\nfunction renderPathSection(\n title: string,\n entries: readonly {\n readonly path: string;\n readonly scope: string;\n readonly platforms?: readonly string[];\n readonly note?: string;\n }[],\n) {\n if (!entries.length) return;\n consola.log(section(title));\n for (const e of entries) {\n const tags = [s.dim(e.scope)];\n if (e.platforms) tags.push(s.dim(e.platforms.join(\", \")));\n consola.log(entry(`${s.hi(e.path)} ${tags.join(s.dim(\" · \"))}`));\n if (e.note) consola.log(entry(`${s.dim(` ${e.note}`)}`));\n }\n}\n\nconst formatArgs = {\n json: { type: \"boolean\" as const, description: \"Output as JSON\" },\n toon: { type: \"boolean\" as const, description: \"Output as TOON\" },\n};\n\nconst harnessArg = {\n type: \"positional\" as const,\n description: \"Harness id\",\n required: true,\n};\n\nfunction emit(data: unknown, args: Readonly<{ json?: boolean; toon?: boolean }>) {\n if (args.json) {\n console.log(JSON.stringify(data, null, 2));\n return true;\n }\n if (args.toon) {\n console.log(toToon(data));\n return true;\n }\n return false;\n}\n\nfunction resolveHarness(id: string): ReturnType<typeof getHarness> {\n if (!isHarnessId(id)) {\n consola.error(`Unknown harness: ${id}\\nKnown: ${listHarnesses().join(\", \")}`);\n process.exit(1);\n }\n return getHarness(id);\n}\n\nfunction renderResolvedPathSection(\n title: string,\n entries: readonly { readonly path: string }[],\n): void {\n if (entries.length === 0) return;\n consola.log(section(title));\n for (const item of entries) consola.log(entry(s.hi(item.path)));\n}\n\nfunction parsePositiveTimeout(raw: string | undefined): number | null | undefined {\n if (!raw) return undefined;\n const value = Number(raw);\n return Number.isFinite(value) && value > 0 ? value : null;\n}\n\nfunction modelFailureMessage(details: ModelsOutcome | RunFailure): string {\n return \"error\" in details ? details.error : \"Failed to list models\";\n}\n\nfunction modelDescription(model: Readonly<AvailableModel>): string {\n const features: string[] = [];\n if (model.thinking) features.push(\"thinking\");\n if (model.images) features.push(\"images\");\n const suffix = features.length > 0 ? ` · ${features.join(\", \")}` : \"\";\n return `${model.contextWindow} context · ${model.maxOutputTokens} max-out${suffix}`;\n}\n\nfunction renderModels(details: ModelsOutcome): void {\n consola.log(header(`${details.id} models`));\n consola.log(\"\");\n for (const model of details.models) {\n consola.log(\n entry(`${s.hi(`${model.provider}/${model.id}`)} ${s.dim(modelDescription(model))}`),\n );\n }\n if (details.models.length === 0) consola.log(entry(s.dim(\"No models found\")));\n consola.log(\"\");\n}\n\nfunction finishInvocation(result: InvokeResult, timeoutSeconds: number | undefined): never {\n if (result.stdout) process.stdout.write(result.stdout);\n if (result.stderr) process.stderr.write(result.stderr);\n if (result.timedOut) {\n consola.error(`Timed out after ${timeoutSeconds}s`);\n process.exit(124);\n }\n process.exit(result.exitCode ?? 1);\n}\n\nconst list = defineCommand({\n meta: { description: \"List all known harnesses\" },\n args: { ...formatArgs },\n run({ args }) {\n const harnesses = getAllHarnesses();\n const data = harnesses.map((harness) => ({ id: harness.id, name: harness.name }));\n\n if (emit(data, args)) return;\n\n consola.log(header(\"Harnesses\"));\n consola.log(\"\");\n const maxId = Math.max(...data.map((r) => r.id.length));\n for (const { id, name } of data) {\n consola.log(entry(`${s.hi(id.padEnd(maxId))} ${name}`));\n }\n consola.log(\"\");\n },\n});\n\nconst detect = defineCommand({\n meta: { description: \"Detect installed harnesses and versions\" },\n args: { ...formatArgs },\n run({ args }) {\n const harnesses = getAllHarnesses();\n const results = harnesses.map((harness) => {\n const installed = harness.isInstalled();\n const v = installed ? harness.version : null;\n return { id: harness.id, name: harness.name, installed, version: v };\n });\n\n if (emit(results, args)) return;\n\n consola.log(header(\"System Scan\"));\n consola.log(\"\");\n const maxId = Math.max(...results.map((r) => r.id.length));\n for (const r of results) {\n if (r.installed) {\n const ver = r.version ? ` ${s.dim(`v${r.version}`)}` : \"\";\n consola.log(entry(`${s.green(\"●\")} ${s.hi(r.id.padEnd(maxId))} ${r.name}${ver}`));\n } else {\n consola.log(entry(`${s.dim(\"○\")} ${s.dim(r.id.padEnd(maxId))} ${s.dim(r.name)}`));\n }\n }\n consola.log(\"\");\n },\n});\n\nconst info = defineCommand({\n meta: { description: \"Show metadata for a harness\" },\n args: { id: harnessArg, ...formatArgs },\n run({ args }) {\n const harness = resolveHarness(args.id as string);\n\n if (\n emit(\n {\n id: harness.id,\n name: harness.name,\n binaries: harness.binaries,\n capabilities: harness.capabilities,\n invocationModes: harness.invocationModes,\n modelListing: harness.modelListing !== null,\n modelSelection: harness.invocation?.modelArgs !== undefined,\n config: harness.config,\n sessions: harness.sessions,\n instructions: harness.instructions,\n skills: harness.skills,\n commands: harness.commands,\n hooks: harness.hooks,\n persistence: harness.persistence,\n detection: harness.detection,\n },\n args,\n )\n )\n return;\n\n consola.log(header(`${harness.name} ${s.dim(harness.id)}`));\n\n consola.log(section(\"Binaries\"));\n for (const b of harness.binaries) consola.log(entry(s.white(b)));\n\n consola.log(section(\"Capabilities\"));\n const caps = Object.entries(harness.capabilities)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \"));\n consola.log(entry(caps));\n\n consola.log(section(\"Invocation modes\"));\n const modes = Object.entries(harness.invocationModes)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \"));\n consola.log(entry(modes));\n\n consola.log(section(\"Models\"));\n const modelFeatures = {\n listing: harness.modelListing !== null,\n selection: harness.invocation?.modelArgs !== undefined,\n };\n consola.log(\n entry(\n Object.entries(modelFeatures)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \")),\n ),\n );\n\n renderPathSection(\"Config\", harness.config);\n renderPathSection(\"Sessions\", harness.sessions);\n renderPathSection(\"Instructions\", harness.instructions);\n renderPathSection(\"Skills\", harness.skills);\n renderPathSection(\"Commands\", harness.commands);\n renderPathSection(\"Hooks\", harness.hooks);\n\n if (harness.persistence.length) {\n consola.log(section(\"Persistence\"));\n for (const e of harness.persistence) {\n const note = e.note ? ` ${s.dim(e.note)}` : \"\";\n consola.log(entry(`${s.white(e.format)}${note}`));\n }\n }\n\n consola.log(\"\");\n },\n});\n\nconst paths = defineCommand({\n meta: { description: \"Show resolved paths for current platform\" },\n args: { id: harnessArg, ...formatArgs },\n run({ args }) {\n const harness = resolveHarness(args.id as string);\n const resolved = harness.resolve();\n\n if (emit(resolved, args)) return;\n\n consola.log(header(`${harness.name} ${s.dim(process.platform)}`));\n\n renderResolvedPathSection(\"Config\", resolved.config);\n renderResolvedPathSection(\"Sessions\", resolved.sessions);\n renderResolvedPathSection(\"Instructions\", resolved.instructions);\n renderResolvedPathSection(\"Skills\", resolved.skills);\n renderResolvedPathSection(\"Commands\", resolved.commands);\n renderResolvedPathSection(\"Hooks\", resolved.hooks);\n\n consola.log(\"\");\n },\n});\n\nconst models = defineCommand({\n meta: { description: \"List models available to a harness\" },\n args: {\n id: harnessArg,\n search: {\n type: \"positional\" as const,\n description: \"Optional native model search filter\",\n required: false,\n },\n cwd: {\n type: \"string\" as const,\n description: \"Working directory used while loading harness configuration\",\n },\n timeout: { type: \"string\" as const, description: \"Wall-clock budget in seconds\" },\n ...formatArgs,\n },\n async run({ args }) {\n const timeoutSeconds = parsePositiveTimeout(args.timeout);\n if (timeoutSeconds === null) {\n consola.error(`Invalid timeout: ${args.timeout}`);\n process.exitCode = 1;\n return;\n }\n\n const result = await listHarnessModels(args.id as string, {\n search: args.search as string | undefined,\n cwd: args.cwd,\n timeoutSeconds,\n });\n if (emit(result.details, args)) {\n if (result.isError) process.exitCode = 1;\n return;\n }\n if (result.isError || !(\"models\" in result.details)) {\n consola.error(modelFailureMessage(result.details));\n process.exitCode = 1;\n return;\n }\n\n renderModels(result.details);\n },\n});\n\nconst run = defineCommand({\n meta: { description: \"Run one prompt through a harness's non-interactive mode\" },\n args: {\n id: harnessArg,\n prompt: {\n type: \"positional\" as const,\n description: \"Prompt to send to the harness\",\n required: true,\n },\n cwd: { type: \"string\" as const, description: \"Working directory for the run\" },\n model: { type: \"string\" as const, description: \"Harness-native model id or selector\" },\n timeout: { type: \"string\" as const, description: \"Wall-clock budget in seconds\" },\n json: {\n type: \"boolean\" as const,\n description: \"Use the harness's structured (JSON) output mode\",\n },\n tools: {\n type: \"boolean\" as const,\n description: \"Enable tools; default false uses native advisor without tools mode\",\n },\n \"read-only\": {\n type: \"boolean\" as const,\n description: \"Require native read-only tool enforcement; implies --tools\",\n },\n },\n async run({ args }) {\n const harness = resolveHarness(args.id as string);\n const structured = args.json === true;\n const readOnly = args[\"read-only\"] === true;\n const tools = readOnly || args.tools === true;\n\n const invocationOptions = { model: args.model, structured, tools, readOnly };\n if (!harness.buildInvocation(\"\", invocationOptions)) {\n consola.error(harness.invocationError(invocationOptions) ?? \"Invalid invocation\");\n process.exit(1);\n }\n\n const timeoutSeconds = parsePositiveTimeout(args.timeout);\n if (timeoutSeconds === null) {\n consola.error(`Invalid timeout: ${args.timeout}`);\n process.exit(1);\n }\n\n const result = await harness.invoke(args.prompt as string, {\n cwd: args.cwd,\n model: args.model,\n timeoutMs: timeoutSeconds === undefined ? undefined : timeoutSeconds * 1000,\n structured,\n tools,\n readOnly,\n });\n\n finishInvocation(result, timeoutSeconds);\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: \"harnesses\",\n version,\n description: \"Metadata toolkit for AI coding harnesses\",\n },\n subCommands: {\n list,\n detect,\n info,\n paths,\n models,\n run,\n \"mcp-servers\": () => import(\"./commands/mcp-servers.ts\").then((m) => m.default),\n agents: () => import(\"./commands/agents.ts\").then((m) => m.default),\n mcp: () => import(\"./commands/mcp.ts\").then((m) => m.default),\n },\n});\n\nawait runMain(main);\n"],"mappings":";;;;;;;AASA,MAAM,IAAI;CACR,OAAO,MAAc,WAAW,EAAE;CAClC,KAAK,MAAc,WAAW,EAAE;CAChC,QAAQ,MAAc,WAAW,EAAE;CACnC,MAAM,MAAc,WAAW,EAAE;CACjC,MAAM,MAAc,WAAW,EAAE;CACjC,OAAO,MAAc,UAAU,EAAE;CACjC,QAAQ,MAAc,WAAW,EAAE;AACrC;AAEA,SAAS,OAAO,OAAe;CAC7B,OAAO,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC;AACpC;AAEA,SAAS,QAAQ,OAAe;CAC9B,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK;AAC5C;AAEA,SAAS,MAAM,SAAiB;CAC9B,OAAO,OAAO;AAChB;AAEA,SAAS,kBACP,OACA,SAMA;CACA,IAAI,CAAC,QAAQ,QAAQ;CACrB,QAAQ,IAAI,QAAQ,KAAK,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC;EAC5B,IAAI,EAAE,WAAW,KAAK,KAAK,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC;EACxD,QAAQ,IAAI,MAAM,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,KAAK,EAAE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;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,UAAU,eAAe,KAAK,EAAY;EAChD,MAAM,aAAa,KAAK,SAAS;EACjC,MAAM,WAAW,KAAK,iBAAiB;EACvC,MAAM,QAAQ,YAAY,KAAK,UAAU;EAEzC,MAAM,oBAAoB;GAAE,OAAO,KAAK;GAAO;GAAY;GAAO;EAAS;EAC3E,IAAI,CAAC,QAAQ,gBAAgB,IAAI,iBAAiB,GAAG;GACnD,QAAQ,MAAM,QAAQ,gBAAgB,iBAAiB,KAAK,oBAAoB;GAChF,QAAQ,KAAK,CAAC;EAChB;EAEA,MAAM,iBAAiB,qBAAqB,KAAK,OAAO;EACxD,IAAI,mBAAmB,MAAM;GAC3B,QAAQ,MAAM,oBAAoB,KAAK,SAAS;GAChD,QAAQ,KAAK,CAAC;EAChB;EAWA,iBAAiB,MATI,QAAQ,OAAO,KAAK,QAAkB;GACzD,KAAK,KAAK;GACV,OAAO,KAAK;GACZ,WAAW,mBAAmB,KAAA,IAAY,KAAA,IAAY,iBAAiB;GACvE;GACA;GACA;EACF,CAAC,GAEwB,cAAc;CACzC;AACF,CAAC;AAED,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAAM;EACN;EACA,aAAa;CACf;CACA,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA,qBAAqB,OAAO,4BAA4B,CAAC,MAAM,MAAM,EAAE,OAAO;EAC9E,cAAc,OAAO,uBAAuB,CAAC,MAAM,MAAM,EAAE,OAAO;EAClE,WAAW,OAAO,qBAAoB,CAAC,MAAM,MAAM,EAAE,OAAO;CAC9D;AACF,CAAC;AAED,MAAM,QAAQ,IAAI"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["toToon"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand, runMain } from \"citty\";\nimport { consola } from \"consola\";\nimport { encode as toToon } from \"@toon-format/toon\";\nimport { version, type AvailableModel, type InvokeResult } from \"./types.ts\";\nimport { getAllHarnesses, getHarness, isHarnessId, listHarnesses } from \"./registry.ts\";\nimport { listHarnessModels, type ModelsOutcome, type RunFailure } from \"./tool-operations.ts\";\n\nconst s = {\n cyan: (t: string) => `\\x1B[36m${t}\\x1B[0m`,\n hi: (t: string) => `\\x1B[96m${t}\\x1B[0m`,\n green: (t: string) => `\\x1B[32m${t}\\x1B[0m`,\n red: (t: string) => `\\x1B[31m${t}\\x1B[0m`,\n dim: (t: string) => `\\x1B[90m${t}\\x1B[0m`,\n bold: (t: string) => `\\x1B[1m${t}\\x1B[0m`,\n white: (t: string) => `\\x1B[97m${t}\\x1B[0m`,\n};\n\nfunction header(title: string) {\n return `\\n ${s.bold(s.cyan(title))}`;\n}\n\nfunction section(title: string) {\n return `\\n ${s.cyan(\"▸\")} ${s.white(title)}`;\n}\n\nfunction entry(content: string) {\n return ` ${content}`;\n}\n\nfunction renderPathSection(\n title: string,\n entries: readonly {\n readonly path: string;\n readonly scope: string;\n readonly platforms?: readonly string[];\n readonly note?: string;\n }[],\n) {\n if (!entries.length) return;\n consola.log(section(title));\n for (const e of entries) {\n const tags = [s.dim(e.scope)];\n if (e.platforms) tags.push(s.dim(e.platforms.join(\", \")));\n consola.log(entry(`${s.hi(e.path)} ${tags.join(s.dim(\" · \"))}`));\n if (e.note) consola.log(entry(`${s.dim(` ${e.note}`)}`));\n }\n}\n\nconst formatArgs = {\n json: { type: \"boolean\" as const, description: \"Output as JSON\" },\n toon: { type: \"boolean\" as const, description: \"Output as TOON\" },\n};\n\nconst harnessArg = {\n type: \"positional\" as const,\n description: \"Harness id\",\n required: true,\n};\n\nfunction emit(data: unknown, args: Readonly<{ json?: boolean; toon?: boolean }>) {\n if (args.json) {\n console.log(JSON.stringify(data, null, 2));\n return true;\n }\n if (args.toon) {\n console.log(toToon(data));\n return true;\n }\n return false;\n}\n\nfunction resolveHarness(id: string): ReturnType<typeof getHarness> {\n if (!isHarnessId(id)) {\n consola.error(`Unknown harness: ${id}\\nKnown: ${listHarnesses().join(\", \")}`);\n process.exit(1);\n }\n return getHarness(id);\n}\n\nfunction renderResolvedPathSection(\n title: string,\n entries: readonly { readonly path: string }[],\n): void {\n if (entries.length === 0) return;\n consola.log(section(title));\n for (const item of entries) consola.log(entry(s.hi(item.path)));\n}\n\nfunction parsePositiveTimeout(raw: string | undefined): number | null | undefined {\n if (!raw) return undefined;\n const value = Number(raw);\n return Number.isFinite(value) && value > 0 ? value : null;\n}\n\nfunction modelFailureMessage(details: ModelsOutcome | RunFailure): string {\n return \"error\" in details ? details.error : \"Failed to list models\";\n}\n\nfunction modelDescription(model: Readonly<AvailableModel>): string {\n const features: string[] = [];\n if (model.thinking) features.push(\"thinking\");\n if (model.images) features.push(\"images\");\n const suffix = features.length > 0 ? ` · ${features.join(\", \")}` : \"\";\n return `${model.contextWindow} context · ${model.maxOutputTokens} max-out${suffix}`;\n}\n\nfunction renderModels(details: ModelsOutcome): void {\n consola.log(header(`${details.id} models`));\n consola.log(\"\");\n for (const model of details.models) {\n consola.log(\n entry(`${s.hi(`${model.provider}/${model.id}`)} ${s.dim(modelDescription(model))}`),\n );\n }\n if (details.models.length === 0) consola.log(entry(s.dim(\"No models found\")));\n consola.log(\"\");\n}\n\nfunction finishInvocation(result: InvokeResult, timeoutSeconds: number | undefined): never {\n if (result.stdout) process.stdout.write(result.stdout);\n if (result.stderr) process.stderr.write(result.stderr);\n if (result.timedOut) {\n consola.error(`Timed out after ${timeoutSeconds}s`);\n process.exit(124);\n }\n process.exit(result.exitCode ?? 1);\n}\n\nconst list = defineCommand({\n meta: { description: \"List all known harnesses\" },\n args: { ...formatArgs },\n run({ args }) {\n const harnesses = getAllHarnesses();\n const data = harnesses.map((harness) => ({ id: harness.id, name: harness.name }));\n\n if (emit(data, args)) return;\n\n consola.log(header(\"Harnesses\"));\n consola.log(\"\");\n const maxId = Math.max(...data.map((r) => r.id.length));\n for (const { id, name } of data) {\n consola.log(entry(`${s.hi(id.padEnd(maxId))} ${name}`));\n }\n consola.log(\"\");\n },\n});\n\nconst detect = defineCommand({\n meta: { description: \"Detect installed harnesses and versions\" },\n args: { ...formatArgs },\n run({ args }) {\n const harnesses = getAllHarnesses();\n const results = harnesses.map((harness) => {\n const installed = harness.isInstalled();\n const v = installed ? harness.version : null;\n return { id: harness.id, name: harness.name, installed, version: v };\n });\n\n if (emit(results, args)) return;\n\n consola.log(header(\"System Scan\"));\n consola.log(\"\");\n const maxId = Math.max(...results.map((r) => r.id.length));\n for (const r of results) {\n if (r.installed) {\n const ver = r.version ? ` ${s.dim(`v${r.version}`)}` : \"\";\n consola.log(entry(`${s.green(\"●\")} ${s.hi(r.id.padEnd(maxId))} ${r.name}${ver}`));\n } else {\n consola.log(entry(`${s.dim(\"○\")} ${s.dim(r.id.padEnd(maxId))} ${s.dim(r.name)}`));\n }\n }\n consola.log(\"\");\n },\n});\n\nconst info = defineCommand({\n meta: { description: \"Show metadata for a harness\" },\n args: { id: harnessArg, ...formatArgs },\n run({ args }) {\n const harness = resolveHarness(args.id as string);\n\n if (\n emit(\n {\n id: harness.id,\n name: harness.name,\n binaries: harness.binaries,\n capabilities: harness.capabilities,\n invocationModes: harness.invocationModes,\n modelListing: harness.modelListing !== null,\n modelSelection: harness.invocation?.modelArgs !== undefined,\n config: harness.config,\n sessions: harness.sessions,\n instructions: harness.instructions,\n skills: harness.skills,\n commands: harness.commands,\n promptTemplates: harness.promptTemplates,\n hooks: harness.hooks,\n persistence: harness.persistence,\n detection: harness.detection,\n },\n args,\n )\n )\n return;\n\n consola.log(header(`${harness.name} ${s.dim(harness.id)}`));\n\n consola.log(section(\"Binaries\"));\n for (const b of harness.binaries) consola.log(entry(s.white(b)));\n\n consola.log(section(\"Capabilities\"));\n const caps = Object.entries(harness.capabilities)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \"));\n consola.log(entry(caps));\n\n consola.log(section(\"Invocation modes\"));\n const modes = Object.entries(harness.invocationModes)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \"));\n consola.log(entry(modes));\n\n consola.log(section(\"Models\"));\n const modelFeatures = {\n listing: harness.modelListing !== null,\n selection: harness.invocation?.modelArgs !== undefined,\n };\n consola.log(\n entry(\n Object.entries(modelFeatures)\n .map(([k, v]) => (v ? s.green(k) : s.dim(k)))\n .join(s.dim(\" · \")),\n ),\n );\n\n renderPathSection(\"Config\", harness.config);\n renderPathSection(\"Sessions\", harness.sessions);\n renderPathSection(\"Instructions\", harness.instructions);\n renderPathSection(\"Skills\", harness.skills);\n renderPathSection(\"Commands\", harness.commands);\n renderPathSection(\"Prompt templates\", harness.promptTemplates);\n renderPathSection(\"Hooks\", harness.hooks);\n\n if (harness.persistence.length) {\n consola.log(section(\"Persistence\"));\n for (const e of harness.persistence) {\n const note = e.note ? ` ${s.dim(e.note)}` : \"\";\n consola.log(entry(`${s.white(e.format)}${note}`));\n }\n }\n\n consola.log(\"\");\n },\n});\n\nconst paths = defineCommand({\n meta: { description: \"Show resolved paths for current platform\" },\n args: { id: harnessArg, ...formatArgs },\n run({ args }) {\n const harness = resolveHarness(args.id as string);\n const resolved = harness.resolve();\n\n if (emit(resolved, args)) return;\n\n consola.log(header(`${harness.name} ${s.dim(process.platform)}`));\n\n renderResolvedPathSection(\"Config\", resolved.config);\n renderResolvedPathSection(\"Sessions\", resolved.sessions);\n renderResolvedPathSection(\"Instructions\", resolved.instructions);\n renderResolvedPathSection(\"Skills\", resolved.skills);\n renderResolvedPathSection(\"Commands\", resolved.commands);\n renderResolvedPathSection(\"Prompt templates\", resolved.promptTemplates);\n renderResolvedPathSection(\"Hooks\", resolved.hooks);\n\n consola.log(\"\");\n },\n});\n\nconst models = defineCommand({\n meta: { description: \"List models available to a harness\" },\n args: {\n id: harnessArg,\n search: {\n type: \"positional\" as const,\n description: \"Optional native model search filter\",\n required: false,\n },\n cwd: {\n type: \"string\" as const,\n description: \"Working directory used while loading harness configuration\",\n },\n timeout: { type: \"string\" as const, description: \"Wall-clock budget in seconds\" },\n ...formatArgs,\n },\n async run({ args }) {\n const timeoutSeconds = parsePositiveTimeout(args.timeout);\n if (timeoutSeconds === null) {\n consola.error(`Invalid timeout: ${args.timeout}`);\n process.exitCode = 1;\n return;\n }\n\n const result = await listHarnessModels(args.id as string, {\n search: args.search as string | undefined,\n cwd: args.cwd,\n timeoutSeconds,\n });\n if (emit(result.details, args)) {\n if (result.isError) process.exitCode = 1;\n return;\n }\n if (result.isError || !(\"models\" in result.details)) {\n consola.error(modelFailureMessage(result.details));\n process.exitCode = 1;\n return;\n }\n\n renderModels(result.details);\n },\n});\n\nconst run = defineCommand({\n meta: { description: \"Run one prompt through a harness's non-interactive mode\" },\n args: {\n id: harnessArg,\n prompt: {\n type: \"positional\" as const,\n description: \"Prompt to send to the harness\",\n required: true,\n },\n cwd: { type: \"string\" as const, description: \"Working directory for the run\" },\n model: { type: \"string\" as const, description: \"Harness-native model id or selector\" },\n timeout: { type: \"string\" as const, description: \"Wall-clock budget in seconds\" },\n json: {\n type: \"boolean\" as const,\n description: \"Use the harness's structured (JSON) output mode\",\n },\n tools: {\n type: \"boolean\" as const,\n description: \"Enable tools; default false uses native advisor without tools mode\",\n },\n \"read-only\": {\n type: \"boolean\" as const,\n description: \"Require native read-only tool enforcement; implies --tools\",\n },\n },\n async run({ args }) {\n const harness = resolveHarness(args.id as string);\n const structured = args.json === true;\n const readOnly = args[\"read-only\"] === true;\n const tools = readOnly || args.tools === true;\n\n const invocationOptions = { model: args.model, structured, tools, readOnly };\n if (!harness.buildInvocation(\"\", invocationOptions)) {\n consola.error(harness.invocationError(invocationOptions) ?? \"Invalid invocation\");\n process.exit(1);\n }\n\n const timeoutSeconds = parsePositiveTimeout(args.timeout);\n if (timeoutSeconds === null) {\n consola.error(`Invalid timeout: ${args.timeout}`);\n process.exit(1);\n }\n\n const result = await harness.invoke(args.prompt as string, {\n cwd: args.cwd,\n model: args.model,\n timeoutMs: timeoutSeconds === undefined ? undefined : timeoutSeconds * 1000,\n structured,\n tools,\n readOnly,\n });\n\n finishInvocation(result, timeoutSeconds);\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: \"harnesses\",\n version,\n description: \"Metadata toolkit for AI coding harnesses\",\n },\n subCommands: {\n list,\n detect,\n info,\n paths,\n models,\n run,\n \"mcp-servers\": () => import(\"./commands/mcp-servers.ts\").then((m) => m.default),\n agents: () => import(\"./commands/agents.ts\").then((m) => m.default),\n prompts: () => import(\"./commands/prompts.ts\").then((m) => m.default),\n mcp: () => import(\"./commands/mcp.ts\").then((m) => m.default),\n },\n});\n\nawait runMain(main);\n"],"mappings":";;;;;;;AASA,MAAM,IAAI;CACR,OAAO,MAAc,WAAW,EAAE;CAClC,KAAK,MAAc,WAAW,EAAE;CAChC,QAAQ,MAAc,WAAW,EAAE;CACnC,MAAM,MAAc,WAAW,EAAE;CACjC,MAAM,MAAc,WAAW,EAAE;CACjC,OAAO,MAAc,UAAU,EAAE;CACjC,QAAQ,MAAc,WAAW,EAAE;AACrC;AAEA,SAAS,OAAO,OAAe;CAC7B,OAAO,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC;AACpC;AAEA,SAAS,QAAQ,OAAe;CAC9B,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK;AAC5C;AAEA,SAAS,MAAM,SAAiB;CAC9B,OAAO,OAAO;AAChB;AAEA,SAAS,kBACP,OACA,SAMA;CACA,IAAI,CAAC,QAAQ,QAAQ;CACrB,QAAQ,IAAI,QAAQ,KAAK,CAAC;CAC1B,KAAK,MAAM,KAAK,SAAS;EACvB,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC;EAC5B,IAAI,EAAE,WAAW,KAAK,KAAK,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC;EACxD,QAAQ,IAAI,MAAM,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,CAAC,GAAG,CA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