@procedures/claude-cli 0.0.0-stage → 0.4.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +92 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/events.d.ts +93 -0
  6. package/dist/events.d.ts.map +1 -0
  7. package/dist/events.js +153 -0
  8. package/dist/events.js.map +1 -0
  9. package/dist/executable.d.ts +28 -0
  10. package/dist/executable.d.ts.map +1 -0
  11. package/dist/executable.js +37 -0
  12. package/dist/executable.js.map +1 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +8 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/module.d.ts +19 -0
  18. package/dist/module.d.ts.map +1 -0
  19. package/dist/module.js +81 -0
  20. package/dist/module.js.map +1 -0
  21. package/dist/procedures/claude/cancel.d.ts +13 -0
  22. package/dist/procedures/claude/cancel.d.ts.map +1 -0
  23. package/dist/procedures/claude/cancel.js +15 -0
  24. package/dist/procedures/claude/cancel.js.map +1 -0
  25. package/dist/procedures/claude/follow.d.ts +15 -0
  26. package/dist/procedures/claude/follow.d.ts.map +1 -0
  27. package/dist/procedures/claude/follow.js +21 -0
  28. package/dist/procedures/claude/follow.js.map +1 -0
  29. package/dist/procedures/claude/index.d.ts +5 -0
  30. package/dist/procedures/claude/index.d.ts.map +1 -0
  31. package/dist/procedures/claude/index.js +5 -0
  32. package/dist/procedures/claude/index.js.map +1 -0
  33. package/dist/procedures/claude/read.d.ts +12 -0
  34. package/dist/procedures/claude/read.d.ts.map +1 -0
  35. package/dist/procedures/claude/read.js +14 -0
  36. package/dist/procedures/claude/read.js.map +1 -0
  37. package/dist/procedures/claude/start.d.ts +14 -0
  38. package/dist/procedures/claude/start.d.ts.map +1 -0
  39. package/dist/procedures/claude/start.js +26 -0
  40. package/dist/procedures/claude/start.js.map +1 -0
  41. package/dist/register.d.ts +6 -0
  42. package/dist/register.d.ts.map +1 -0
  43. package/dist/register.js +8 -0
  44. package/dist/register.js.map +1 -0
  45. package/dist/turn.d.ts +142 -0
  46. package/dist/turn.d.ts.map +1 -0
  47. package/dist/turn.js +208 -0
  48. package/dist/turn.js.map +1 -0
  49. package/dist/types.d.ts +61 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/types.js +61 -0
  52. package/dist/types.js.map +1 -0
  53. package/package.json +78 -3
  54. package/src/events.ts +250 -0
  55. package/src/executable.ts +50 -0
  56. package/src/index.ts +7 -0
  57. package/src/module.ts +116 -0
  58. package/src/procedures/claude/cancel.ts +17 -0
  59. package/src/procedures/claude/follow.ts +26 -0
  60. package/src/procedures/claude/index.ts +4 -0
  61. package/src/procedures/claude/read.ts +16 -0
  62. package/src/procedures/claude/start.ts +28 -0
  63. package/src/register.ts +10 -0
  64. package/src/turn.ts +317 -0
  65. package/src/types.ts +142 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The normaliser of the output of `claude -p --output-format stream-json --verbose`.
3
+ *
4
+ * Each line of that output is one JSON object. The normaliser turns one line into zero or more
5
+ * events of a small, stable set. It is pure: it reads no file and keeps no state.
6
+ */
7
+ /** The start of a session: the `system` line of the CLI. */
8
+ export interface ClaudeMetaEvent {
9
+ readonly type: "meta";
10
+ /** The subtype of the `system` line, for example `init`. */
11
+ readonly subtype?: string;
12
+ readonly sessionId?: string;
13
+ readonly model?: string;
14
+ readonly cwd?: string;
15
+ readonly tools?: readonly string[];
16
+ readonly permissionMode?: string;
17
+ }
18
+ /** A text block of the assistant. */
19
+ export interface ClaudeTextEvent {
20
+ readonly type: "text";
21
+ readonly text: string;
22
+ }
23
+ /** A part of a text block, with `--include-partial-messages`. */
24
+ export interface ClaudeTextDeltaEvent {
25
+ readonly type: "text-delta";
26
+ readonly text: string;
27
+ }
28
+ /** A thinking block of the assistant. The CLI gives an empty block in `-p` mode, and the normaliser drops it. */
29
+ export interface ClaudeThinkingEvent {
30
+ readonly type: "thinking";
31
+ readonly text: string;
32
+ }
33
+ /** A tool call of the assistant. */
34
+ export interface ClaudeToolUseEvent {
35
+ readonly type: "tool-use";
36
+ readonly id?: string;
37
+ readonly name: string;
38
+ readonly input: unknown;
39
+ }
40
+ /** The result of a tool call, as text. */
41
+ export interface ClaudeToolResultEvent {
42
+ readonly type: "tool-result";
43
+ readonly toolUseId?: string;
44
+ readonly output: string;
45
+ readonly isError: boolean;
46
+ }
47
+ /** The last line of a turn: the final text, the session, the cost and the duration. */
48
+ export interface ClaudeResultEvent {
49
+ readonly type: "result";
50
+ /** The subtype, for example `success` or `error_max_turns`. */
51
+ readonly subtype?: string;
52
+ readonly isError: boolean;
53
+ /** The final text of the assistant. */
54
+ readonly text?: string;
55
+ /** The session. Give it to `--resume` for the next turn. */
56
+ readonly sessionId?: string;
57
+ /** The cost of the turn, in US dollars. */
58
+ readonly costUsd?: number;
59
+ readonly durationMs?: number;
60
+ /** The number of model turns. */
61
+ readonly turns?: number;
62
+ readonly usage?: Readonly<Record<string, unknown>>;
63
+ readonly errors?: readonly string[];
64
+ }
65
+ /** A line that is not JSON. The CLI writes its errors and warnings as text. */
66
+ export interface ClaudeLogEvent {
67
+ readonly type: "log";
68
+ readonly text: string;
69
+ }
70
+ /** An error of the turn, for example a process that ended without a result. The normaliser does not make it. */
71
+ export interface ClaudeErrorEvent {
72
+ readonly type: "error";
73
+ readonly message: string;
74
+ }
75
+ /** One normalised event of a turn. */
76
+ export type ClaudeEvent = ClaudeMetaEvent | ClaudeTextEvent | ClaudeTextDeltaEvent | ClaudeThinkingEvent | ClaudeToolUseEvent | ClaudeToolResultEvent | ClaudeResultEvent | ClaudeLogEvent | ClaudeErrorEvent;
77
+ /** The types of the events. */
78
+ export type ClaudeEventType = ClaudeEvent["type"];
79
+ /**
80
+ * This function gives a value as text with a maximum length. It adds `…` when it cuts the text.
81
+ * The normaliser does not cut. A caller uses this function for a short preview.
82
+ */
83
+ export declare function preview(value: unknown, max?: number): string;
84
+ /** This function gives the content of a tool result as text. A block that is not text gives `[type]`. */
85
+ export declare function toolResultText(content: unknown): string;
86
+ /**
87
+ * This function normalises one line of `claude -p --output-format stream-json --verbose`. An
88
+ * empty line or an unknown JSON object gives no event. A line that is not JSON gives a `log` event.
89
+ */
90
+ export declare function normalizeLine(line: string): ClaudeEvent[];
91
+ /** This function normalises each line of a text. */
92
+ export declare function normalizeText(text: string): ClaudeEvent[];
93
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iHAAiH;AACjH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA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CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,gHAAgH;AAChH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,eAAe,GACf,oBAAoB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,CAAC;AAErB,+BAA+B;AAC/B,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AA0BlD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,SAAM,GAAG,MAAM,CAIzD;AAED,yGAAyG;AACzG,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAYvD;AAuED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAuBzD;AAED,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAEzD"}
package/dist/events.js ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The normaliser of the output of `claude -p --output-format stream-json --verbose`.
3
+ *
4
+ * Each line of that output is one JSON object. The normaliser turns one line into zero or more
5
+ * events of a small, stable set. It is pure: it reads no file and keeps no state.
6
+ */
7
+ function isObject(value) {
8
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ }
10
+ function str(value) {
11
+ return typeof value === "string" ? value : undefined;
12
+ }
13
+ function num(value) {
14
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
15
+ }
16
+ /** This function gives the fields whose value is not `undefined`. */
17
+ function defined(fields) {
18
+ return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
19
+ }
20
+ /**
21
+ * This function gives a value as text with a maximum length. It adds `…` when it cuts the text.
22
+ * The normaliser does not cut. A caller uses this function for a short preview.
23
+ */
24
+ export function preview(value, max = 400) {
25
+ const text = typeof value === "string" ? value : JSON.stringify(value);
26
+ if (text === undefined)
27
+ return "";
28
+ return text.length > max ? `${text.slice(0, max)}…` : text;
29
+ }
30
+ /** This function gives the content of a tool result as text. A block that is not text gives `[type]`. */
31
+ export function toolResultText(content) {
32
+ if (typeof content === "string")
33
+ return content;
34
+ if (Array.isArray(content)) {
35
+ return content
36
+ .map((block) => {
37
+ if (typeof block === "string")
38
+ return block;
39
+ if (isObject(block))
40
+ return typeof block["text"] === "string" ? block["text"] : `[${str(block["type"]) ?? "block"}]`;
41
+ return "";
42
+ })
43
+ .join("\n");
44
+ }
45
+ return content === undefined || content === null ? "" : JSON.stringify(content);
46
+ }
47
+ function metaEvent(line) {
48
+ const tools = Array.isArray(line["tools"]) ? line["tools"].filter((tool) => typeof tool === "string") : undefined;
49
+ return defined({
50
+ type: "meta",
51
+ subtype: str(line["subtype"]),
52
+ sessionId: str(line["session_id"]),
53
+ model: str(line["model"]),
54
+ cwd: str(line["cwd"]),
55
+ tools,
56
+ permissionMode: str(line["permissionMode"]),
57
+ });
58
+ }
59
+ function messageEvents(line) {
60
+ const message = line["message"];
61
+ const content = isObject(message) && Array.isArray(message["content"]) ? message["content"] : [];
62
+ const fromAssistant = line["type"] === "assistant";
63
+ const events = [];
64
+ for (const block of content) {
65
+ if (!isObject(block))
66
+ continue;
67
+ const kind = block["type"];
68
+ if (fromAssistant && kind === "text") {
69
+ const text = str(block["text"]);
70
+ if (text)
71
+ events.push({ type: "text", text });
72
+ }
73
+ else if (fromAssistant && kind === "thinking") {
74
+ const text = str(block["thinking"]);
75
+ if (text)
76
+ events.push({ type: "thinking", text });
77
+ }
78
+ else if (kind === "tool_use") {
79
+ const id = str(block["id"]);
80
+ events.push({ type: "tool-use", ...(id !== undefined ? { id } : {}), name: str(block["name"]) ?? "tool", input: block["input"] ?? {} });
81
+ }
82
+ else if (kind === "tool_result") {
83
+ events.push(defined({
84
+ type: "tool-result",
85
+ toolUseId: str(block["tool_use_id"]),
86
+ output: toolResultText(block["content"]),
87
+ isError: block["is_error"] === true,
88
+ }));
89
+ }
90
+ }
91
+ return events;
92
+ }
93
+ function resultEvent(line) {
94
+ const errors = Array.isArray(line["errors"]) ? line["errors"].filter((error) => typeof error === "string") : undefined;
95
+ return defined({
96
+ type: "result",
97
+ subtype: str(line["subtype"]),
98
+ isError: line["is_error"] === true,
99
+ text: str(line["result"]),
100
+ sessionId: str(line["session_id"]),
101
+ costUsd: num(line["total_cost_usd"]) ?? num(line["cost_usd"]),
102
+ durationMs: num(line["duration_ms"]),
103
+ turns: num(line["num_turns"]),
104
+ usage: isObject(line["usage"]) ? line["usage"] : undefined,
105
+ errors: errors !== undefined && errors.length > 0 ? errors : undefined,
106
+ });
107
+ }
108
+ function streamEvents(line) {
109
+ const event = line["event"];
110
+ if (!isObject(event) || event["type"] !== "content_block_delta")
111
+ return [];
112
+ const delta = event["delta"];
113
+ if (!isObject(delta) || delta["type"] !== "text_delta")
114
+ return [];
115
+ const text = str(delta["text"]);
116
+ return text ? [{ type: "text-delta", text }] : [];
117
+ }
118
+ /**
119
+ * This function normalises one line of `claude -p --output-format stream-json --verbose`. An
120
+ * empty line or an unknown JSON object gives no event. A line that is not JSON gives a `log` event.
121
+ */
122
+ export function normalizeLine(line) {
123
+ const trimmed = line.trim();
124
+ if (trimmed.length === 0)
125
+ return [];
126
+ let parsed;
127
+ try {
128
+ parsed = JSON.parse(trimmed);
129
+ }
130
+ catch {
131
+ return [{ type: "log", text: trimmed }];
132
+ }
133
+ if (!isObject(parsed))
134
+ return [];
135
+ switch (parsed["type"]) {
136
+ case "system":
137
+ return [metaEvent(parsed)];
138
+ case "assistant":
139
+ case "user":
140
+ return messageEvents(parsed);
141
+ case "result":
142
+ return [resultEvent(parsed)];
143
+ case "stream_event":
144
+ return streamEvents(parsed);
145
+ default:
146
+ return [];
147
+ }
148
+ }
149
+ /** This function normalises each line of a text. */
150
+ export function normalizeText(text) {
151
+ return text.split("\n").flatMap((line) => normalizeLine(line));
152
+ }
153
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgGH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAOD,qEAAqE;AACrE,SAAS,OAAO,CAAiB,MAAS;IACxC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAgB,CAAC;AAC9G,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,GAAG,GAAG,GAAG;IAC/C,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,G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CAAC,EAAE,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,QAAQ,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,KAAK,WAAW,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;QAC/B,KAAK,QAAQ;YACX,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/B,KAAK,cAAc;YACjB,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Find the `claude` program of Claude Code.
3
+ */
4
+ /** The environment variable that names the `claude` program. It comes before the search. */
5
+ export declare const CLAUDE_ENV = "CLAUDE_BIN";
6
+ /** The options of `findClaude`. Each one has a default from the host. */
7
+ export interface FindClaudeOptions {
8
+ /** The `claude` program. When it is set, the search does not occur. */
9
+ readonly executable?: string | undefined;
10
+ /** The environment (default: `process.env`). */
11
+ readonly env?: Readonly<Record<string, string | undefined>> | undefined;
12
+ /** The operating system (default: `process.platform`). */
13
+ readonly platform?: NodeJS.Platform | undefined;
14
+ /** The function that tells if a file exists (default: `existsSync`). */
15
+ readonly exists?: ((path: string) => boolean) | undefined;
16
+ }
17
+ /**
18
+ * This function gives the paths that the search examines, in order: the folders of the `PATH`,
19
+ * then the install folders of the native installer. On Windows, it looks only for `claude.exe`,
20
+ * because a batch file (`claude.cmd`) does not start without a shell.
21
+ */
22
+ export declare function claudeCandidates(platform: NodeJS.Platform, env: Readonly<Record<string, string | undefined>>): string[];
23
+ /**
24
+ * This function finds the `claude` program. The order is `executable`, then `CLAUDE_BIN`, then
25
+ * the `PATH` and the install folders. It gives `undefined` when it finds none.
26
+ */
27
+ export declare function findClaude(options?: FindClaudeOptions): string | undefined;
28
+ //# sourceMappingURL=executable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,4FAA4F;AAC5F,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,gDAAgD;IAChD,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;IACxE,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;IAChD,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,CASvH;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,GAAG,SAAS,CAO9E"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Find the `claude` program of Claude Code.
3
+ */
4
+ import { existsSync } from "node:fs";
5
+ import { posix, win32 } from "node:path";
6
+ /** The environment variable that names the `claude` program. It comes before the search. */
7
+ export const CLAUDE_ENV = "CLAUDE_BIN";
8
+ /**
9
+ * This function gives the paths that the search examines, in order: the folders of the `PATH`,
10
+ * then the install folders of the native installer. On Windows, it looks only for `claude.exe`,
11
+ * because a batch file (`claude.cmd`) does not start without a shell.
12
+ */
13
+ export function claudeCandidates(platform, env) {
14
+ const windows = platform === "win32";
15
+ const path = windows ? win32 : posix;
16
+ const name = windows ? "claude.exe" : "claude";
17
+ const pathValue = windows ? (env["Path"] ?? env["PATH"]) : env["PATH"];
18
+ const folders = (pathValue ?? "").split(windows ? ";" : ":").filter((folder) => folder.length > 0);
19
+ const home = windows ? (env["USERPROFILE"] ?? env["HOME"]) : env["HOME"];
20
+ const installed = home !== undefined ? [path.join(home, ".local", "bin", name), path.join(home, ".claude", "local", name)] : [];
21
+ return [...folders.map((folder) => path.join(folder, name)), ...installed];
22
+ }
23
+ /**
24
+ * This function finds the `claude` program. The order is `executable`, then `CLAUDE_BIN`, then
25
+ * the `PATH` and the install folders. It gives `undefined` when it finds none.
26
+ */
27
+ export function findClaude(options = {}) {
28
+ if (options.executable !== undefined && options.executable.length > 0)
29
+ return options.executable;
30
+ const env = options.env ?? process.env;
31
+ const override = env[CLAUDE_ENV];
32
+ if (override !== undefined && override.length > 0)
33
+ return override;
34
+ const exists = options.exists ?? existsSync;
35
+ return claudeCandidates(options.platform ?? process.platform, env).find((candidate) => exists(candidate));
36
+ }
37
+ //# sourceMappingURL=executable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable.js","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAcvC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,GAAiD;IAC3G,MAAM,OAAO,GAAG,QAAQ,KAAK,OAAO,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnG,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChI,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAO,GAAsB,EAAE;IACxD,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,UAAU,CAAC;IACjG,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC;IAC5C,OAAO,gBAAgB,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./module.js";
2
+ export * from "./types.js";
3
+ export * from "./events.js";
4
+ export * from "./executable.js";
5
+ export * from "./turn.js";
6
+ export { claudeStart, claudeRead, claudeFollow, claudeCancel } from "./procedures/claude/index.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // The root registers nothing: import "<package>/register", or give the module to createRegistry()
2
+ export * from "./module.js";
3
+ export * from "./types.js";
4
+ export * from "./events.js";
5
+ export * from "./executable.js";
6
+ export * from "./turn.js";
7
+ export { claudeStart, claudeRead, claudeFollow, claudeCancel } from "./procedures/claude/index.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The procedures of @procedures/claude-cli as data. An import of this file registers nothing.
3
+ *
4
+ * Scaffold a procedure with: mark procedure new <name> --path packages/claude-cli
5
+ */
6
+ import { type AnyProcedure, type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
7
+ export declare const claudeStartProcedure: AnyProcedure;
8
+ export declare const claudeReadProcedure: AnyProcedure;
9
+ export declare const claudeFollowProcedure: AnyProcedure;
10
+ export declare const claudeCancelProcedure: AnyProcedure;
11
+ export declare const claudeCliProcedures: AnyProcedure[];
12
+ export declare const claudeCliModule: ProcedureModule;
13
+ export default claudeCliModule;
14
+ /**
15
+ * This function registers the procedures of @procedures/claude-cli in a registry. The default is the
16
+ * global registry.
17
+ */
18
+ export declare function registerClaudeCliProcedures(registry?: ProcedureRegistry): void;
19
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAGvB,MAAM,oBAAoB,CAAC;AA2B5B,eAAO,MAAM,oBAAoB,EAAE,YAaT,CAAC;AAE3B,eAAO,MAAM,mBAAmB,EAAE,YAYR,CAAC;AAE3B,eAAO,MAAM,qBAAqB,EAAE,YAeV,CAAC;AAE3B,eAAO,MAAM,qBAAqB,EAAE,YAaV,CAAC;AAE3B,eAAO,MAAM,mBAAmB,EAAE,YAAY,EAA8F,CAAC;AAE7I,eAAO,MAAM,eAAe,EAAE,eAA6E,CAAC;eAE7F,eAAe;AAE9B;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAElG"}
package/dist/module.js ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The procedures of @procedures/claude-cli as data. An import of this file registers nothing.
3
+ *
4
+ * Scaffold a procedure with: mark procedure new <name> --path packages/claude-cli
5
+ */
6
+ import { defineModule, registerModules, PROCEDURE_REGISTRY, createProcedure, zodAdapter, } from "@procedures/client";
7
+ import { claudeStart } from "./procedures/claude/start.js";
8
+ import { claudeRead } from "./procedures/claude/read.js";
9
+ import { claudeFollow } from "./procedures/claude/follow.js";
10
+ import { claudeCancel } from "./procedures/claude/cancel.js";
11
+ import { ClaudeStartInputSchema, ClaudeStartOutputSchema, ClaudeReadInputSchema, ClaudeReadOutputSchema, ClaudeFollowInputSchema, ClaudeFollowOutputSchema, ClaudeCancelInputSchema, ClaudeCancelOutputSchema, } from "./types.js";
12
+ /** The effects of a read of the output file. The check of the process id reads the turn process. */
13
+ const READS_TURN = { reads: ["fs", "jobs"], writes: [] };
14
+ export const claudeStartProcedure = createProcedure()
15
+ .path(["claude", "start"])
16
+ .input(zodAdapter(ClaudeStartInputSchema))
17
+ .output(zodAdapter(ClaudeStartOutputSchema))
18
+ .meta({
19
+ description: "Start one turn of the Claude Code CLI as a detached process that writes to a file",
20
+ args: ["prompt"],
21
+ shorts: { cwd: "C" },
22
+ output: "json",
23
+ // The agent of the turn can read and change files, start programs and use the network
24
+ effects: { reads: ["fs", "network", "process"], writes: ["fs", "network", "process", "jobs"] },
25
+ })
26
+ .handler(async (input) => claudeStart(input))
27
+ .build();
28
+ export const claudeReadProcedure = createProcedure()
29
+ .path(["claude", "read"])
30
+ .input(zodAdapter(ClaudeReadInputSchema))
31
+ .output(zodAdapter(ClaudeReadOutputSchema))
32
+ .meta({
33
+ description: "Read the new events of a turn from its output file",
34
+ args: ["outputFile"],
35
+ shorts: {},
36
+ output: "json",
37
+ effects: READS_TURN,
38
+ })
39
+ .handler(async (input) => claudeRead(input))
40
+ .build();
41
+ export const claudeFollowProcedure = createProcedure()
42
+ .path(["claude", "follow"])
43
+ .input(zodAdapter(ClaudeFollowInputSchema))
44
+ .output(zodAdapter(ClaudeFollowOutputSchema))
45
+ .meta({
46
+ description: "Follow the output file of a turn and stream its events until the turn ends",
47
+ args: ["outputFile"],
48
+ shorts: {},
49
+ output: "json",
50
+ streaming: true,
51
+ // A turn has no time limit: the stream ends with the turn
52
+ stream: { unbounded: true },
53
+ effects: READS_TURN,
54
+ })
55
+ .handler(claudeFollow)
56
+ .build();
57
+ export const claudeCancelProcedure = createProcedure()
58
+ .path(["claude", "cancel"])
59
+ .input(zodAdapter(ClaudeCancelInputSchema))
60
+ .output(zodAdapter(ClaudeCancelOutputSchema))
61
+ .meta({
62
+ description: "Stop a turn and the processes that it started",
63
+ args: ["pid"],
64
+ shorts: {},
65
+ output: "json",
66
+ // It stops the process tree of the id that it gets
67
+ effects: { reads: ["jobs"], writes: ["jobs"], destructive: true, idempotent: true },
68
+ })
69
+ .handler(async (input) => claudeCancel(input))
70
+ .build();
71
+ export const claudeCliProcedures = [claudeStartProcedure, claudeReadProcedure, claudeFollowProcedure, claudeCancelProcedure];
72
+ export const claudeCliModule = defineModule("@procedures/claude-cli", claudeCliProcedures);
73
+ export default claudeCliModule;
74
+ /**
75
+ * This function registers the procedures of @procedures/claude-cli in a registry. The default is the
76
+ * global registry.
77
+ */
78
+ export function registerClaudeCliProcedures(registry = PROCEDURE_REGISTRY) {
79
+ registerModules(registry, [claudeCliModule]);
80
+ }
81
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAIlB,eAAe,EACf,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,GASzB,MAAM,YAAY,CAAC;AAEpB,oGAAoG;AACpG,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAW,CAAC;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAiB,eAAe,EAAE;KAChE,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,C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,GAAsB,kBAAkB;IAC1F,eAAe,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * claude.cancel procedure
3
+ *
4
+ * This procedure stops a turn and the processes that it started, by the process id of the turn.
5
+ * It also stops a turn that a previous host started.
6
+ */
7
+ import type { ClaudeCancelInput, ClaudeCancelOutput } from "../../types.js";
8
+ /**
9
+ * This function stops the process tree of the turn. It gives `stopped: false` and a reason when
10
+ * the process has ended.
11
+ */
12
+ export declare function claudeCancel(input: ClaudeCancelInput): Promise<ClaudeCancelOutput>;
13
+ //# sourceMappingURL=cancel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/procedures/claude/cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAExF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * claude.cancel procedure
3
+ *
4
+ * This procedure stops a turn and the processes that it started, by the process id of the turn.
5
+ * It also stops a turn that a previous host started.
6
+ */
7
+ import { cancelTurn } from "../../turn.js";
8
+ /**
9
+ * This function stops the process tree of the turn. It gives `stopped: false` and a reason when
10
+ * the process has ended.
11
+ */
12
+ export async function claudeCancel(input) {
13
+ return cancelTurn(input.pid);
14
+ }
15
+ //# sourceMappingURL=cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/procedures/claude/cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB;IACzD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * claude.follow procedure
3
+ *
4
+ * This procedure follows the output file of a turn and streams its events until the turn ends.
5
+ * When the caller stops reading, or its signal aborts, the follow stops. The turn continues.
6
+ */
7
+ import type { ClaudeFollowInput, ClaudeFollowOutput } from "../../types.js";
8
+ /**
9
+ * This function gives each event of the turn. It stops after the result, or after an error event
10
+ * when the process ends without a result.
11
+ */
12
+ export declare function claudeFollow(input: ClaudeFollowInput, ctx?: {
13
+ signal?: AbortSignal | undefined;
14
+ }): AsyncGenerator<ClaudeFollowOutput, void, undefined>;
15
+ //# sourceMappingURL=follow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../src/procedures/claude/follow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;GAGG;AACH,wBAAuB,YAAY,CACjC,KAAK,EAAE,iBAAiB,EACxB,GAAG,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,GACzC,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,SAAS,CAAC,CAQrD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * claude.follow procedure
3
+ *
4
+ * This procedure follows the output file of a turn and streams its events until the turn ends.
5
+ * When the caller stops reading, or its signal aborts, the follow stops. The turn continues.
6
+ */
7
+ import { followTurn } from "../../turn.js";
8
+ /**
9
+ * This function gives each event of the turn. It stops after the result, or after an error event
10
+ * when the process ends without a result.
11
+ */
12
+ export async function* claudeFollow(input, ctx) {
13
+ yield* followTurn({
14
+ outputFile: input.outputFile,
15
+ offset: input.offset,
16
+ pid: input.pid,
17
+ pollMs: input.pollMs,
18
+ signal: ctx?.signal,
19
+ });
20
+ }
21
+ //# sourceMappingURL=follow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow.js","sourceRoot":"","sources":["../../../src/procedures/claude/follow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C;;;GAGG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CACjC,KAAwB,EACxB,GAA0C;IAE1C,KAAK,CAAC,CAAC,UAAU,CAAC;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,GAAG,EAAE,MAAM;KACpB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { claudeStart } from "./start.js";
2
+ export { claudeRead } from "./read.js";
3
+ export { claudeFollow } from "./follow.js";
4
+ export { claudeCancel } from "./cancel.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/claude/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { claudeStart } from "./start.js";
2
+ export { claudeRead } from "./read.js";
3
+ export { claudeFollow } from "./follow.js";
4
+ export { claudeCancel } from "./cancel.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/claude/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * claude.read procedure
3
+ *
4
+ * This procedure reads the new events of a turn from its output file, from a byte offset.
5
+ */
6
+ import type { ClaudeReadInput, ClaudeReadOutput } from "../../types.js";
7
+ /**
8
+ * This function reads the complete lines after `input.offset` and gives their events and the
9
+ * offset for the next read.
10
+ */
11
+ export declare function claudeRead(input: ClaudeReadInput): Promise<ClaudeReadOutput>;
12
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/procedures/claude/read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;GAGG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAElF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * claude.read procedure
3
+ *
4
+ * This procedure reads the new events of a turn from its output file, from a byte offset.
5
+ */
6
+ import { readTurn } from "../../turn.js";
7
+ /**
8
+ * This function reads the complete lines after `input.offset` and gives their events and the
9
+ * offset for the next read.
10
+ */
11
+ export async function claudeRead(input) {
12
+ return readTurn({ outputFile: input.outputFile, offset: input.offset, pid: input.pid });
13
+ }
14
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/procedures/claude/read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAsB;IACrD,OAAO,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC1F,CAAC"}