@krapht/ork 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +7 -0
- package/dist/__build_info__-CXXMLvjt.mjs +104 -0
- package/dist/bin.mjs +859 -3037
- package/dist/context-BFGC_C02.mjs +435 -0
- package/dist/find-BcvhT6UN.mjs +47 -0
- package/dist/format-DqpObyMl.mjs +553 -0
- package/dist/in-a-run-BbLhZOFW.mjs +22 -0
- package/dist/limits-BKYAmqCR.mjs +44 -0
- package/dist/mcp-BWsdQyri.mjs +91 -0
- package/dist/output-Q2EdeVUt.mjs +856 -0
- package/dist/pause-DKACDfV1.mjs +65 -0
- package/dist/relay-CbK-Wme9.mjs +122 -0
- package/dist/report-DK4LGqwF.mjs +129 -0
- package/dist/send-C6yr04Fe.mjs +163 -0
- package/dist/{src-DAsOYtoR.mjs → src-CZOVF2yU.mjs} +496 -193
- package/dist/src-Cz1yOUTg.mjs +11841 -0
- package/dist/src-D5ruZFgD.mjs +1973 -0
- package/dist/src-DtN1k-B3.mjs +1899 -0
- package/dist/ui/THIRD_PARTY_LICENSES.txt +631 -0
- package/dist/ui/assets/app-BlDdP396.js +61 -0
- package/dist/ui/assets/app-C722xNZ3.css +1 -0
- package/dist/ui/assets/geist-mono-cyrillic-400-normal-C51Di1Mf.woff2 +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-400-normal-CPJFfJgk.woff +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-500-normal-D2cXvDHF.woff2 +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-500-normal-DfuvdVgn.woff +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-ext-400-normal-CkxHOdCb.woff +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-ext-400-normal-XB2BPmDK.woff2 +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-ext-500-normal-BY1KTvO5.woff +0 -0
- package/dist/ui/assets/geist-mono-cyrillic-ext-500-normal-C7aYOB1D.woff2 +0 -0
- package/dist/ui/assets/geist-mono-latin-400-normal-B2yvC1Cq.woff +0 -0
- package/dist/ui/assets/geist-mono-latin-400-normal-DTRLJnHl.woff2 +0 -0
- package/dist/ui/assets/geist-mono-latin-500-normal-D-GG86Jb.woff +0 -0
- package/dist/ui/assets/geist-mono-latin-500-normal-YINYabwD.woff2 +0 -0
- package/dist/ui/assets/geist-mono-latin-ext-400-normal-CfzLURNc.woff +0 -0
- package/dist/ui/assets/geist-mono-latin-ext-400-normal-DI-rJ0UV.woff2 +0 -0
- package/dist/ui/assets/geist-mono-latin-ext-500-normal-Buglb9-a.woff2 +0 -0
- package/dist/ui/assets/geist-mono-latin-ext-500-normal-CrWEgvU_.woff +0 -0
- package/dist/ui/assets/geist-mono-symbols2-400-normal-BS9BGVxz.woff2 +0 -0
- package/dist/ui/assets/geist-mono-symbols2-400-normal-DjbiTEEA.woff +0 -0
- package/dist/ui/assets/geist-mono-symbols2-500-normal-CmnCPGa0.woff +0 -0
- package/dist/ui/assets/geist-mono-symbols2-500-normal-Q_ksOahU.woff2 +0 -0
- package/dist/ui/assets/geist-mono-vietnamese-400-normal-CKEaXIlx.woff2 +0 -0
- package/dist/ui/assets/geist-mono-vietnamese-400-normal-CZEPLOgu.woff +0 -0
- package/dist/ui/assets/geist-mono-vietnamese-500-normal-Bs29RrUZ.woff2 +0 -0
- package/dist/ui/assets/geist-mono-vietnamese-500-normal-Dx9-epDo.woff +0 -0
- package/dist/ui/assets/geist-sans-latin-400-normal-BOaIZNA2.woff +0 -0
- package/dist/ui/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
- package/dist/ui/assets/geist-sans-latin-500-normal-CN2lyvyL.woff +0 -0
- package/dist/ui/assets/geist-sans-latin-500-normal-uokXdC-Q.woff2 +0 -0
- package/dist/ui/assets/geist-sans-latin-600-normal-CA1yjETN.woff +0 -0
- package/dist/ui/assets/geist-sans-latin-600-normal-DFOURf8L.woff2 +0 -0
- package/dist/ui/assets/index-BiO54L90.css +1 -0
- package/dist/ui/assets/index-BoG6O-Lp.js +10 -0
- package/dist/ui/assets/theme-3xH5jxKs.js +1 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/favicon.svg +4 -0
- package/dist/ui/index.html +30 -0
- package/dist/ui/ork-wordmark-small-on-light.svg +4 -0
- package/dist/ui/ork-wordmark-small.svg +4 -0
- package/dist/ui-CZS1XKla.mjs +160 -0
- package/dist/usage-BIjf9Xdt.mjs +418 -0
- package/dist/watch-B8o4Szd_.mjs +394 -0
- package/package.json +4 -2
- package/dist/src-CJ_zF0Zj.mjs +0 -5433
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import "./src-Cz1yOUTg.mjs";
|
|
2
|
+
import { n as ORK_VERSION } from "./__build_info__-CXXMLvjt.mjs";
|
|
3
|
+
import { a as openMcp, c as refused, o as tool, s as answer } from "./src-D5ruZFgD.mjs";
|
|
4
|
+
import { n as explainNode, p as isNewer } from "./context-BFGC_C02.mjs";
|
|
5
|
+
import { p as runMarkerIn } from "./src-DtN1k-B3.mjs";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
+
// src/commands/mcp.ts
|
|
11
|
+
/**
|
|
12
|
+
* @file `ork mcp`: Ork's tools for Claude Code over stdio (RFC-012), on the
|
|
13
|
+
* same handlers as `ork ui`'s API and the same checks as `ork validate`. They
|
|
14
|
+
* read, check a draft, explain a node's context, and start a run; none
|
|
15
|
+
* answers a decision or acts on a run. Inside a run nothing starts another,
|
|
16
|
+
* and an `ork` older than its caller expects says so on every call. It opens
|
|
17
|
+
* no port and holds no token, and stdout carries only the protocol.
|
|
18
|
+
*/
|
|
19
|
+
const INSTRUCTIONS = "Ork runs workflows of Claude sessions and programs on this machine. These tools read what Ork has (projects, workflows, the workflow format, runs, their events and cost, the decisions waiting on a person), check a workflow as `ork validate` does, and explain what a node's session loads. None answers a decision: a person does, in `ork ui` or their own terminal.";
|
|
20
|
+
const STARTS = " `start_run` starts a run in the background.";
|
|
21
|
+
const explainTool = (opened, home) => tool("explain_context", "What one node's session would load, as `ork context explain` shows it: its agent, instructions, skills and files, layer by layer, with their tokens.", {
|
|
22
|
+
project: z.string().min(1),
|
|
23
|
+
workflow: z.string().min(1).describe("A workflow's name, or a path"),
|
|
24
|
+
node: z.string().min(1)
|
|
25
|
+
}, ({ project, workflow, node }) => {
|
|
26
|
+
const found = opened.fileOf(project, workflow);
|
|
27
|
+
if ("error" in found) return refused(found.error);
|
|
28
|
+
const result = explainNode(found.file, node, found.project.root, home);
|
|
29
|
+
return result.ok ? answer(result.explanation) : refused(result.lines.join("\n"));
|
|
30
|
+
});
|
|
31
|
+
/** Every call refused, when this `ork` is older than its caller needs. */
|
|
32
|
+
const tooOld = (tools, expects) => tools.map((each) => ({
|
|
33
|
+
...each,
|
|
34
|
+
call: () => Promise.resolve(refused(`This needs Ork ${expects} or newer, and this is ${ORK_VERSION}. Ask the person to upgrade, with \`ork upgrade\`.`))
|
|
35
|
+
}));
|
|
36
|
+
/** The server with Ork's tools on it, for stdio here and in tests. */
|
|
37
|
+
const orkMcpServer = (options = {}) => {
|
|
38
|
+
const start = runMarkerIn(options.env ?? process.env) === null;
|
|
39
|
+
const opened = openMcp({
|
|
40
|
+
version: ORK_VERSION,
|
|
41
|
+
start,
|
|
42
|
+
...options.home === void 0 ? {} : { home: options.home },
|
|
43
|
+
...options.script === void 0 ? {} : { script: options.script }
|
|
44
|
+
});
|
|
45
|
+
const all = [...opened.tools, explainTool(opened, options.home)];
|
|
46
|
+
const tools = options.expects !== void 0 && isNewer(options.expects, "0.3.0") ? tooOld(all, options.expects) : all;
|
|
47
|
+
const server = new McpServer({
|
|
48
|
+
name: "ork",
|
|
49
|
+
version: ORK_VERSION
|
|
50
|
+
}, { instructions: start ? `${INSTRUCTIONS}${STARTS}` : INSTRUCTIONS });
|
|
51
|
+
for (const each of tools) server.registerTool(each.name, {
|
|
52
|
+
description: each.description,
|
|
53
|
+
inputSchema: z.strictObject(each.shape),
|
|
54
|
+
annotations: {
|
|
55
|
+
readOnlyHint: each.readOnly,
|
|
56
|
+
openWorldHint: false
|
|
57
|
+
}
|
|
58
|
+
}, async (args) => {
|
|
59
|
+
const { text, isError } = await each.call(args);
|
|
60
|
+
return {
|
|
61
|
+
content: [{
|
|
62
|
+
type: "text",
|
|
63
|
+
text
|
|
64
|
+
}],
|
|
65
|
+
...isError === true ? { isError } : {}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
server,
|
|
70
|
+
close: opened.close
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const mcp = defineCommand({
|
|
74
|
+
meta: {
|
|
75
|
+
name: "mcp",
|
|
76
|
+
description: "Serve Ork's tools to Claude Code over stdio (MCP)"
|
|
77
|
+
},
|
|
78
|
+
args: { expects: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "The oldest Ork the caller works with, such as a plugin"
|
|
81
|
+
} },
|
|
82
|
+
run: async ({ args }) => {
|
|
83
|
+
const { server, close } = orkMcpServer(args.expects === void 0 ? {} : { expects: args.expects });
|
|
84
|
+
const transport = new StdioServerTransport();
|
|
85
|
+
transport.onclose = () => {
|
|
86
|
+
close();
|
|
87
|
+
};
|
|
88
|
+
await server.connect(transport);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
export { mcp };
|