@pmndre/pine 0.0.0-stage → 0.22.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 (151) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -2
  3. package/bin/pine.js +27 -0
  4. package/docs/SKILL.md +234 -0
  5. package/docs/references/agents.md +454 -0
  6. package/docs/references/coding.md +311 -0
  7. package/docs/references/computer.md +212 -0
  8. package/docs/references/configuration.md +310 -0
  9. package/docs/references/events.md +267 -0
  10. package/docs/references/mcp.md +420 -0
  11. package/docs/references/operations.md +394 -0
  12. package/docs/references/overview.md +195 -0
  13. package/docs/references/security.md +896 -0
  14. package/docs/references/setup.md +385 -0
  15. package/docs/references/sources.md +772 -0
  16. package/docs/references/stack.md +121 -0
  17. package/docs/references/tui.md +575 -0
  18. package/examples/home/.env.example +7 -0
  19. package/examples/home/USER.md +4 -0
  20. package/examples/home/agents/main/agent.json +4 -0
  21. package/examples/home/agents/main/workspace/AGENTS.md +14 -0
  22. package/examples/home/agents/main/workspace/MEMORY.md +4 -0
  23. package/examples/home/agents/main/workspace/SOUL.md +4 -0
  24. package/examples/home/models.json +62 -0
  25. package/examples/home/pine.json +34 -0
  26. package/examples/home/skills/README.txt +7 -0
  27. package/examples/launchd/com.pine.daemon.plist +32 -0
  28. package/examples/systemd/pine.service +22 -0
  29. package/mcp/browser.d.ts +99 -0
  30. package/mcp/browser.js +496 -0
  31. package/mcp/commands.d.ts +20 -0
  32. package/mcp/commands.js +88 -0
  33. package/mcp/computer.d.ts +139 -0
  34. package/mcp/computer.js +698 -0
  35. package/mcp/computer.swift +989 -0
  36. package/mcp/lib.d.ts +23 -0
  37. package/mcp/lib.js +52 -0
  38. package/mcp/web.d.ts +6 -0
  39. package/mcp/web.js +140 -0
  40. package/package.json +32 -4
  41. package/src/access.d.ts +112 -0
  42. package/src/access.js +438 -0
  43. package/src/actions.d.ts +75 -0
  44. package/src/actions.js +167 -0
  45. package/src/admin.d.ts +167 -0
  46. package/src/admin.js +625 -0
  47. package/src/agent-admin.d.ts +24 -0
  48. package/src/agent-admin.js +55 -0
  49. package/src/agents.d.ts +540 -0
  50. package/src/agents.js +2776 -0
  51. package/src/background.d.ts +29 -0
  52. package/src/background.js +100 -0
  53. package/src/cli.d.ts +2 -0
  54. package/src/cli.js +777 -0
  55. package/src/computer.d.ts +30 -0
  56. package/src/computer.js +32 -0
  57. package/src/config.d.ts +396 -0
  58. package/src/config.js +549 -0
  59. package/src/dev/claude-model.d.ts +37 -0
  60. package/src/dev/claude-model.js +204 -0
  61. package/src/env-file.d.ts +4 -0
  62. package/src/env-file.js +40 -0
  63. package/src/goals.d.ts +133 -0
  64. package/src/goals.js +316 -0
  65. package/src/http.d.ts +46 -0
  66. package/src/http.js +509 -0
  67. package/src/limiter.d.ts +32 -0
  68. package/src/limiter.js +84 -0
  69. package/src/login.d.ts +23 -0
  70. package/src/login.js +130 -0
  71. package/src/manual.d.ts +61 -0
  72. package/src/manual.js +443 -0
  73. package/src/mcp-config.d.ts +49 -0
  74. package/src/mcp-config.js +182 -0
  75. package/src/models.d.ts +90 -0
  76. package/src/models.js +274 -0
  77. package/src/net.d.ts +50 -0
  78. package/src/net.js +150 -0
  79. package/src/pine.d.ts +32 -0
  80. package/src/pine.js +134 -0
  81. package/src/programs.d.ts +123 -0
  82. package/src/programs.js +412 -0
  83. package/src/router.d.ts +56 -0
  84. package/src/router.js +164 -0
  85. package/src/sandbox-fs.d.ts +34 -0
  86. package/src/sandbox-fs.js +186 -0
  87. package/src/sandbox-linux.d.ts +96 -0
  88. package/src/sandbox-linux.js +297 -0
  89. package/src/sandbox-setup.d.ts +70 -0
  90. package/src/sandbox-setup.js +216 -0
  91. package/src/security.d.ts +238 -0
  92. package/src/security.js +660 -0
  93. package/src/skills.d.ts +67 -0
  94. package/src/skills.js +163 -0
  95. package/src/snapshots.d.ts +68 -0
  96. package/src/snapshots.js +306 -0
  97. package/src/source-types.d.ts +61 -0
  98. package/src/source-types.js +1 -0
  99. package/src/sources/command.d.ts +4 -0
  100. package/src/sources/command.js +77 -0
  101. package/src/sources/folder.d.ts +6 -0
  102. package/src/sources/folder.js +116 -0
  103. package/src/sources/ftp.d.ts +4 -0
  104. package/src/sources/ftp.js +307 -0
  105. package/src/sources/http.d.ts +4 -0
  106. package/src/sources/http.js +201 -0
  107. package/src/sources/mqtt.d.ts +18 -0
  108. package/src/sources/mqtt.js +97 -0
  109. package/src/sources/telegram.d.ts +22 -0
  110. package/src/sources/telegram.js +283 -0
  111. package/src/sources/webhook.d.ts +4 -0
  112. package/src/sources/webhook.js +52 -0
  113. package/src/sources.d.ts +344 -0
  114. package/src/sources.js +966 -0
  115. package/src/store.d.ts +99 -0
  116. package/src/store.js +277 -0
  117. package/src/timers.d.ts +83 -0
  118. package/src/timers.js +318 -0
  119. package/src/tools.d.ts +11 -0
  120. package/src/tools.js +1297 -0
  121. package/src/tui/app.d.ts +305 -0
  122. package/src/tui/app.js +3195 -0
  123. package/src/tui/client.d.ts +236 -0
  124. package/src/tui/client.js +131 -0
  125. package/src/tui/code-pane.d.ts +68 -0
  126. package/src/tui/code-pane.js +535 -0
  127. package/src/tui/highlight.d.ts +8 -0
  128. package/src/tui/highlight.js +86 -0
  129. package/src/tui/picture.d.ts +206 -0
  130. package/src/tui/picture.js +801 -0
  131. package/src/tui/run.d.ts +8 -0
  132. package/src/tui/run.js +97 -0
  133. package/src/tui/theme.d.ts +32 -0
  134. package/src/tui/theme.js +128 -0
  135. package/src/tui/undo.d.ts +5 -0
  136. package/src/tui/undo.js +50 -0
  137. package/src/tui/voice.d.ts +49 -0
  138. package/src/tui/voice.js +155 -0
  139. package/src/tui/voice.swift +223 -0
  140. package/src/types.d.ts +139 -0
  141. package/src/types.js +1 -0
  142. package/src/undo.d.ts +224 -0
  143. package/src/undo.js +465 -0
  144. package/src/update.d.ts +35 -0
  145. package/src/update.js +130 -0
  146. package/src/util.d.ts +65 -0
  147. package/src/util.js +171 -0
  148. package/src/watching.d.ts +20 -0
  149. package/src/watching.js +68 -0
  150. package/src/workspace-view.d.ts +72 -0
  151. package/src/workspace-view.js +221 -0
@@ -0,0 +1,305 @@
1
+ import { type SelectItem, type Terminal, TuiAltScreen } from "@earendil-works/pi-tui";
2
+ import { type VoiceTools } from "./voice.ts";
3
+ import type { Client } from "./client.ts";
4
+ import { type SoundPlayer } from "./picture.ts";
5
+ export interface LinkSpan {
6
+ line: number;
7
+ from: number;
8
+ to: number;
9
+ url: string;
10
+ }
11
+ /**
12
+ * Web addresses in a block of plain screen lines, with the cells each one covers. A long address
13
+ * is wrapped over several lines; a line that runs to the right edge is read together with the next,
14
+ * and every piece of the address points to the whole of it.
15
+ */
16
+ export declare function findLinks(lines: string[], width: number): LinkSpan[];
17
+ /** The address under a cell, if any. */
18
+ export declare function urlAt(lines: string[], y: number, x: number, width: number): string | undefined;
19
+ /**
20
+ * Text that a terminal pastes when files are dropped on it: one or more paths, with spaces
21
+ * escaped or the path in quotes, sometimes as file:// URLs. Returns the files (with `folders`: the folders) only when every
22
+ * piece of the text is an existing one; otherwise the text is ordinary input.
23
+ */
24
+ export declare function droppedFiles(text: string, folders?: boolean): string[] | null;
25
+ /**
26
+ * Entries that match what was typed: every word must occur somewhere in the name or description,
27
+ * in any position ("dee" finds opencode-go/deepseek-v4.1-flash). If nothing matches that way,
28
+ * fall back to loose matching so a typo still finds something.
29
+ */
30
+ export declare function searchItems(items: SelectItem[], query: string): SelectItem[];
31
+ /** The files a message points at: every "@path" in it, with the lines after a "#" if any ("src/a.ts#20-45"). */
32
+ export declare function mentionsIn(text: string): string[];
33
+ /**
34
+ * The screen, with one addition: while a menu or question is open, a click next to it goes to the
35
+ * app (which closes the menu) instead of to whatever lies underneath.
36
+ */
37
+ declare class Screen extends TuiAltScreen {
38
+ onOutside?: (e: any) => boolean;
39
+ /** The terminal said that its window came to the front, or went from it. */
40
+ onFocus?: (focused: boolean) => void;
41
+ constructor(...args: ConstructorParameters<typeof TuiAltScreen>);
42
+ protected dispatchMouseToOverlay(event: any): any;
43
+ /**
44
+ * A real picture is drawn above all text, so it would lie across a menu opened over it. Pictures
45
+ * that a menu or dialog covers are drawn as text for as long as it is there.
46
+ */
47
+ protected compositeOverlays(lines: string[], width: number, height: number): string[];
48
+ }
49
+ export interface TuiOptions {
50
+ client: Client;
51
+ terminal: Terminal;
52
+ /** Called once when the user quits. */
53
+ onQuit?: () => void | Promise<void>;
54
+ /** Shown in the footer, for example "embedded daemon". */
55
+ mode?: string;
56
+ /** Hands a video or sound file to a player when "open in player" is clicked. Default: the system's player. */
57
+ openFile?: (file: string) => void;
58
+ /** What plays a sound in the conversation. Default: what the system has (see soundPlayer). */
59
+ soundPlayer?: SoundPlayer;
60
+ /** What listens when the owner dictates a message. Default: what the system has (see voiceTools). */
61
+ voice?: VoiceTools;
62
+ /** Opens a web address when it is clicked. Default: the system's browser. */
63
+ openUrl?: (url: string) => void;
64
+ /** Saves the picture that is on the clipboard as a file and resolves with its path, or with nothing when there is none. Default: the system's clipboard. */
65
+ clipboardImage?: () => Promise<string | undefined>;
66
+ /** Puts text on the clipboard; resolves with true, or with what went wrong. Default: the system's clipboard program. */
67
+ copy?: (text: string) => Promise<true | string>;
68
+ /** Lets the user pick a folder; resolves with nothing when they do not. Default: the system's folder chooser (macOS). */
69
+ chooseFolder?: () => Promise<string | undefined>;
70
+ /** The folder pine was started in, offered in the folder menu. Default: the process's. */
71
+ cwd?: string;
72
+ /** MCP server administration that needs this machine: connection states and browser sign-in. */
73
+ mcp?: {
74
+ /** The configured servers. `states` also asks each one whether it connects, which takes a moment. */
75
+ list(states?: boolean): Promise<Array<{
76
+ name: string;
77
+ scope: string;
78
+ session?: string;
79
+ agents: string[];
80
+ target: string;
81
+ state?: string;
82
+ }>>;
83
+ login(name: string, onOutput: (text: string) => void): Promise<number>;
84
+ };
85
+ }
86
+ /** The terminal UI: one tab per conversation, a live event tab, slash commands, approval prompts. */
87
+ export declare class PineTui {
88
+ client: Client;
89
+ tui: Screen;
90
+ private editor;
91
+ private header;
92
+ private status;
93
+ private footer;
94
+ private dock;
95
+ private tabs;
96
+ private active;
97
+ private nextTabId;
98
+ private agents;
99
+ private commands;
100
+ private connected;
101
+ private notice;
102
+ private noticeTimer?;
103
+ /** Dictating a message: what listens, what stood in the input before, and how far it is. */
104
+ private voice?;
105
+ private voiceTools?;
106
+ /** The language to listen for, when the owner named one (/voice de-DE). Default: the system's. */
107
+ private voiceLanguage?;
108
+ private spinner?;
109
+ private watching?;
110
+ private frame;
111
+ private unsubscribe?;
112
+ /** `waits`: a question to the owner that is still open on the daemon's side. A click beside it does not close it. */
113
+ private dialog?;
114
+ /** When a menu or question last closed. A key that closed it is not also a key for what lies under it. */
115
+ private dialogClosedAt;
116
+ /** Videos fetched from the daemon, as files for ffmpeg and the player. Removed when the UI closes. */
117
+ private mediaDir?;
118
+ private mediaCount;
119
+ private headerHits;
120
+ private footerHits;
121
+ private attachHits;
122
+ private attach;
123
+ private sessionModes;
124
+ private lastCtrlC;
125
+ private taints;
126
+ /** The pinned conversations of the agents that have a tab ("agent:session"): a tab of one shows the mark of a kept conversation. */
127
+ private pins;
128
+ private bypassWhenTainted;
129
+ private opts;
130
+ private stopped;
131
+ /** While the tabs of last time are being opened again. */
132
+ private restoring;
133
+ /** The pane beside a conversation: changes, files, tool output. */
134
+ private code;
135
+ private codeOpen;
136
+ private codeRule;
137
+ /** Whether the terminal's window is in front (terminals that do not say are taken to be). */
138
+ private focused;
139
+ /** Whether to call for attention when something ends or waits while the window is not in front. */
140
+ private notify;
141
+ constructor(opts: TuiOptions);
142
+ start(): Promise<void>;
143
+ /** Remember which conversations are open, so that the next start opens the same tabs. */
144
+ private saveTabs;
145
+ stop(): Promise<void>;
146
+ /** What is on screen, without colours. For tests and debugging. */
147
+ screen(): string[];
148
+ private newTab;
149
+ openTab(agent: string, session: string): Promise<void>;
150
+ /**
151
+ * Open a tab on one task, typically a sub-agent: what it was given, what it thought and wrote,
152
+ * every tool call with the start of its result. A running task is followed live.
153
+ */
154
+ openTask(id: number): Promise<void>;
155
+ private taskSummary;
156
+ private renderEntry;
157
+ private openEvents;
158
+ private activate;
159
+ private cycle;
160
+ /**
161
+ * The tab of a conversation other than an agent's main one is closed: what it was subscribed to
162
+ * on its own ends, the conversation itself stays in the agent's list. (The main conversation is
163
+ * the agent; its subscriptions stay.)
164
+ */
165
+ private endLocal;
166
+ private closeTab;
167
+ /** Open or close the pane beside the conversation, optionally on one of its views. */
168
+ private showCode;
169
+ /** Give a conversation a folder to work in, or with `null` take it back to the agent's own workspace. */
170
+ private setFolder;
171
+ private pickFolder;
172
+ /**
173
+ * `pine <folder>`: a tab on the conversation that works in that folder. The one that already
174
+ * does is opened again; otherwise the main agent gets a new conversation named after the folder.
175
+ */
176
+ openFolder(dir: string): Promise<void>;
177
+ private add;
178
+ private say;
179
+ /** A place for what a model thinks. Opening and closing it keeps it in the window. */
180
+ private thought;
181
+ /** The row of the conversation at which a component begins; without one, how many rows there are. */
182
+ private rowOf;
183
+ /** A task's model stopped thinking: what it thought is closed, or stays open if somebody opened it. */
184
+ private endThought;
185
+ /** Ask what the commands of the conversation in front left running. Quietly: a daemon that does not answer changes nothing. */
186
+ private pollPrograms;
187
+ /** The agent's list of steps (its `todo` tool), drawn: done, in work, still to do. */
188
+ private stepsText;
189
+ /** Show the list where the conversation is: the same block while one task keeps changing it, a new one for the next task. */
190
+ private showSteps;
191
+ /** A line that opens something on a click. */
192
+ private button;
193
+ /**
194
+ * Reserve a place for a picture and fill it once the picture is fetched and prepared, so it lands
195
+ * where it belongs however long that takes. Display only: nothing here reaches a model.
196
+ */
197
+ private picture;
198
+ private fill;
199
+ /** A video or sound that came over the API needs to be a file for ffmpeg and for the player. Kept until the UI closes. */
200
+ private keepVideo;
201
+ private video;
202
+ /**
203
+ * The pictures an answer points at with ![caption](target). A file in the agent's workspace is
204
+ * shown at once. A web address is not fetched until it is clicked: an address can carry
205
+ * information out, and an answer may repeat what a web page told the agent to write.
206
+ */
207
+ private answerPictures;
208
+ /** An event that woke the agent, shown as what it is and not as something you typed: the source, and the start of what it reported. */
209
+ private eventLine;
210
+ private user;
211
+ /** Context and cache figures of a finished task, for the bottom bar. */
212
+ private takeStats;
213
+ /**
214
+ * /undo and /redo. The daemon does it; here the conversation is shown anew, since the lines on
215
+ * screen are not its history any more, with what happened said below it. After an undo the
216
+ * message's text is in the input again, to be changed and sent.
217
+ */
218
+ private undo;
219
+ private renderPast;
220
+ private flash;
221
+ /** Whether this system has voice input. Where it has none, nothing offers it. */
222
+ private canListen;
223
+ /**
224
+ * Dictate the message, or end dictating. What is heard is put into the input, after what was
225
+ * typed there, as it is heard. It is text like typed text: the owner reads it, changes it, and
226
+ * sends it with enter. Nothing that was heard is ever sent by itself.
227
+ */
228
+ private dictate;
229
+ /** End dictating where it stands: what is in the input stays, nothing more is put into it. */
230
+ private endDictating;
231
+ /** Keys the app handles before the editor sees them. Returns true when the key is used up. */
232
+ private onKey;
233
+ /** A click on a web address. Only the web: nothing an answer contains may launch a program or open a file. */
234
+ private open;
235
+ /**
236
+ * Send what was typed. While the agent works, a message goes into that work at its next step
237
+ * ("steer"), so a correction lands without stopping anything; "queue" keeps it for afterwards.
238
+ */
239
+ private submit;
240
+ private attachFile;
241
+ /** Open a list over the conversation and resolve with what was chosen. */
242
+ private pick;
243
+ private pickAgent;
244
+ /** What a tab shows after its conversation was reset: nothing of what was said. */
245
+ private freshen;
246
+ private pickSession;
247
+ private pickModel;
248
+ private pickReasoning;
249
+ private pickMode;
250
+ private isTainted;
251
+ private setMode;
252
+ private adopt;
253
+ /**
254
+ * Call for the owner's attention while they are looking at something else: the terminal's bell
255
+ * and a notification through the terminal (OSC 9, which Ghostty, iTerm and others show as a
256
+ * system notification). The text is pine's own; nothing an agent or a page wrote goes into it.
257
+ */
258
+ private attention;
259
+ /**
260
+ * The picture on the clipboard (a screenshot, say), saved as a file to attach. A terminal pastes
261
+ * text only, so the clipboard is asked directly, on the machine the UI runs on.
262
+ */
263
+ private clipboardImage;
264
+ private copyText;
265
+ /**
266
+ * The conversation as Markdown: what was said, in order. With `full`, also what the agent thought
267
+ * and which tools it called, read from each task's record.
268
+ */
269
+ private markdownOf;
270
+ /**
271
+ * esc stops what is running. A message typed while the agent worked starts the moment that
272
+ * work stops, and the status line says "working" again: a second esc, pressed because nothing
273
+ * seemed to happen, would stop that message too. So for a few seconds after a stop, esc leaves
274
+ * alone a message that was waiting when it was pressed.
275
+ */
276
+ private stopRunning;
277
+ private defineCommands;
278
+ private run;
279
+ private help;
280
+ private ask;
281
+ /** Forget the questions the daemon no longer has open: their cards say so, and a dialog for one closes. */
282
+ private dropAnswered;
283
+ private closeDialog;
284
+ private answer;
285
+ private tabFor;
286
+ private onEvent;
287
+ /** One line on where a goal stands, with the judge's reason under it; `full` adds the objective. */
288
+ private goalLine;
289
+ /** The daemon reports on a goal: it was set, a round was judged, it stopped or was cleared. */
290
+ private goalEvent;
291
+ /** /goal: show it, set it, or pause, resume or clear it. All of it is the daemon's doing. */
292
+ private goal;
293
+ /** Show one live event of a task in a tab. `depth` is counted from what the tab shows: 0 is its own task. */
294
+ private live;
295
+ private logEvent;
296
+ /** Ask again which conversations of the agents on screen are pinned. */
297
+ private refreshPins;
298
+ private refreshTaints;
299
+ private bypassPaused;
300
+ private renderHeader;
301
+ private renderAttachments;
302
+ private renderStatus;
303
+ private renderFooter;
304
+ }
305
+ export {};