@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
package/src/actions.js ADDED
@@ -0,0 +1,167 @@
1
+ // What a tool call is.
2
+ //
3
+ // One function sorts every tool call into a class, and the gate (src/agents.ts) decides per
4
+ // class and mode. What is critical is put to the owner in every conversation; after outside
5
+ // content, so is what sends something out. No model judges an action.
6
+ import os from "node:os";
7
+ import path from "node:path";
8
+ import { reaches, verbs } from "./access.js";
9
+ import { isInside, ownFileOf, realish, tilde } from "./security.js";
10
+ /** Tools that only look. */
11
+ export const LOOK_TOOLS = ["read", "grep", "find", "ls", "state_get", "sources", "tool_search", "manual", "schedules", "mcp_servers", "skills", "stop_program", "question", "todo", "agents", "settings", "routes"];
12
+ /** Tools that change pine's setup or ask for access. Each asks the owner where it matters, so the gate does not ask again. */
13
+ export const SETUP_TOOLS = ["request_access", "add_mcp_server", "remove_mcp_server", "add_source", "remove_source", "add_source_type", "remove_source_type", "add_skill", "remove_skill", "add_schedule", "remove_schedule", "create_agent", "update_agent", "remove_agent", "set_setting", "add_route", "remove_route", "add_model_server", "remove_model_server"];
14
+ /**
15
+ * Files and folders in the owner's home that make other programs run, or that are the keys to
16
+ * the account. Writing one is never routine, whatever the conversation has read.
17
+ */
18
+ const PROTECTED_HOME = [
19
+ ".zshrc", ".zshenv", ".zprofile", ".zlogin", ".bashrc", ".bash_profile", ".bash_login", ".profile", ".envrc",
20
+ ".config/fish", ".ssh", ".gnupg", ".aws", ".azure", ".kube", ".config/gcloud", ".docker/config.json", ".netrc", ".npmrc", ".yarnrc", ".yarnrc.yml", ".pypirc",
21
+ ".gitconfig", ".config/git", "Library/LaunchAgents", ".config/systemd", ".config/autostart",
22
+ ];
23
+ /** Parts of a path that mean the same anywhere: a repository's hooks and configuration run programs for whoever uses git there. */
24
+ const PROTECTED_ANYWHERE = /(^|\/)\.git\/(hooks(\/|$)|config$)|(^|\/)\.husky(\/|$)/;
25
+ /** The same names as they appear in a command line. */
26
+ const PROTECTED_IN_COMMAND = /(^|[\s"'=/~])(\.(zshrc|zshenv|zprofile|bashrc|bash_profile|profile|netrc|npmrc|pypirc|gitconfig)\b|\.ssh\/|\.gnupg\/|\.aws\/|\.kube\/|LaunchAgents\/|\.git\/hooks\/|\.git\/config\b|authorized_keys\b)/;
27
+ /** Whether a file is one of the protected ones. */
28
+ export function isProtectedPath(p) {
29
+ const home = realish(os.homedir());
30
+ if (PROTECTED_ANYWHERE.test(p))
31
+ return true;
32
+ return PROTECTED_HOME.some((rel) => isInside(path.join(home, rel), p));
33
+ }
34
+ /** Commands that only look, as far as their name says. */
35
+ const READ_ONLY = new Set(["ls", "cat", "head", "tail", "wc", "pwd", "echo", "printf", "date", "whoami", "id", "uname", "hostname", "which", "type", "file", "stat", "du", "df", "ps", "lsof", "env", "printenv", "grep", "rg", "find", "fd", "tree", "sort", "uniq", "cut", "tr", "diff", "cmp", "basename", "dirname", "realpath", "true", "test", "sleep", "jq", "nproc", "uptime"]);
36
+ const READ_ONLY_GIT = new Set(["status", "diff", "log", "show", "blame", "ls-files", "rev-parse", "describe", "shortlog", "remote", "branch", "tag", "stash list"]);
37
+ /**
38
+ * Whether a command line only looks. Deliberately narrow: anything that could write (a
39
+ * redirect, a substitution, an option that runs or deletes) is not one. A wrong "no" costs a
40
+ * question; a wrong "yes" would let an action through unseen.
41
+ */
42
+ export function readOnlyCommand(command) {
43
+ const text = command.trim();
44
+ if (!text || /[<>`]|\$\(|\$\{|\n/.test(text))
45
+ return false;
46
+ for (const part of text.split(/\s*(?:&&|\|\||;|\|)\s*/)) {
47
+ const words = part.trim().split(/\s+/);
48
+ const name = words[0]?.split("/").pop() ?? "";
49
+ if (!name)
50
+ return false;
51
+ if (name === "git") {
52
+ const sub = words.slice(1).find((w) => !w.startsWith("-")) ?? "";
53
+ if (!READ_ONLY_GIT.has(sub))
54
+ return false;
55
+ // "git branch -D x", "git remote add", "git tag -d": the same word, another thing.
56
+ if (/\s(-[dDmM]\b|--delete\b|--force\b|add\b|remove\b|rm\b|set-url\b|rename\b)/.test(part))
57
+ return false;
58
+ continue;
59
+ }
60
+ if (!READ_ONLY.has(name))
61
+ return false;
62
+ if (name === "find" && /\s-(delete|exec|execdir|ok|fprint)/.test(part))
63
+ return false;
64
+ if ((name === "sort" || name === "tree" || name === "uniq") && /\s-o\b|\s--output/.test(part))
65
+ return false;
66
+ if (name === "env" && words.length > 1)
67
+ return false;
68
+ }
69
+ return true;
70
+ }
71
+ /** Why a command line is critical, or undefined. Patterns, so they are a net and not a wall: what they catch is put to the owner. */
72
+ export function criticalCommand(command) {
73
+ const c = command;
74
+ if (/\b(curl|wget|fetch)\b[^|;&\n]*\|\s*(sudo\s+)?(ba|z|da|k)?sh\b|\b(curl|wget)\b[^|;&\n]*\|\s*(sudo\s+)?(python\d?|node|perl|ruby)\b/.test(c))
75
+ return "downloads a program and runs it in one step";
76
+ if (/\brm\s+(-[a-zA-Z]*\s+)*-[a-zA-Z]*[rR][a-zA-Z]*\s+(-[a-zA-Z]*\s+)*["']?(\/|~|\$HOME|\/Users\/[^/\s"']+|\/home\/[^/\s"']+)\/?["']?(\s|$)/.test(c))
77
+ return "deletes a home folder or the whole disk";
78
+ if (/\bgit\s+push\b[^\n;&|]*(\s--force\b|\s-f\b|\s--force-with-lease\b|\s\+\S)/.test(c))
79
+ return "rewrites what was pushed (force push)";
80
+ if (/\bgit\s+(reset\s+--hard|clean\s+-[a-zA-Z]*f|checkout\s+--\s+\.|restore\s+\.)/.test(c))
81
+ return "throws away changes that were not committed";
82
+ if (/\bsudo\b/.test(c))
83
+ return "runs with administrator rights";
84
+ if (!readOnlyCommand(c) && PROTECTED_IN_COMMAND.test(c))
85
+ return "touches a file that makes other programs run or holds the keys to the account";
86
+ if (/\b(chmod|chown)\s+-[a-zA-Z]*R[a-zA-Z]*\s+\S+\s+(\/|~|\$HOME)\/?(\s|$)/.test(c))
87
+ return "changes the permissions of a whole home folder or disk";
88
+ if (/\blaunchctl\s+(load|bootstrap|submit)\b|\bsystemctl\s+(--user\s+)?enable\b|\bcrontab\s+(?!-l\b)\S/.test(c))
89
+ return "installs something that keeps running or starts by itself";
90
+ return undefined;
91
+ }
92
+ /**
93
+ * What a shell without a sandbox ("auto" and "bypass" mode) is refused because it is pine's own:
94
+ * pine's home (configuration, secrets, the other agents' folders), writing pine's program files,
95
+ * the pine program, and pine's control port. In a sandbox the operating system keeps these closed. Here it is this reading
96
+ * of the command line, so it is a net and not a wall: what a script or a variable holds is not
97
+ * seen, and a command that walks a whole folder is not followed into it.
98
+ */
99
+ export function pineOwn(command, o) {
100
+ const where = { cwd: o.cwd, shellHome: o.ownerHome, ownerHome: o.ownerHome };
101
+ const closed = (p) => isInside(o.home, p) && !o.own.some((r) => isInside(r, p));
102
+ // A path with ".." is read from where the shell starts. After a "cd" that is no longer where
103
+ // the command is, so only what stands up to the first one is read that way.
104
+ const moved = /(^|[;&|(\n])\s*(cd|pushd)\s+("[^"]*"|'[^']*'|[^\s;&|)]+)/.exec(command);
105
+ const start = moved ? command.slice(0, moved.index + moved[0].length) : command;
106
+ const named = [...reaches(command, where).filter((r) => !r.text.startsWith("..")), ...reaches(start, where).filter((r) => r.text.startsWith(".."))];
107
+ const hit = named.find((r) => closed(realish(r.path)));
108
+ if (hit)
109
+ return `${hit.text} is part of pine itself, which is closed to every agent in every mode`;
110
+ // pine's program files can be read. What a command plainly writes there (a redirect, touch, rm, cp to it) is not run.
111
+ const written = named.find((r) => r.write && isInside(o.code, realish(r.path)));
112
+ if (written)
113
+ return `${written.text} is part of pine's own code, which agents cannot change`;
114
+ if (verbs(command).some((v) => v === "pine" || v === "pine.js") || /(^|[\s"'/])bin\/pine\.js(\s|$)/.test(command))
115
+ return "the pine program is your owner's way to run and change pine, and not for agents";
116
+ if (o.port && new RegExp(`(localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|\\[?::1\\]?)(:|\\s+)${o.port}\\b`).test(command))
117
+ return `port ${o.port} on this computer is pine's own control port, which is closed to every agent`;
118
+ return undefined;
119
+ }
120
+ /** What an agent is told when `pineOwn` refuses a command. */
121
+ export const pineOwnRefusal = (why) => `Not run: ${why}. Do not look for another way. What pine holds for you, your tools tell you (sources, schedules, mcp_servers, skills, manual).`;
122
+ /** Sort a tool call into its class. The one place that knows. */
123
+ export function classify(tool, input, ctx) {
124
+ if (ctx.sends)
125
+ return { cls: "send" };
126
+ if (tool === "add_skill")
127
+ return { cls: "own", note: "a skill is part of what the agent is told" };
128
+ // Subscribing changes what wakes the agent. The gate asks about it where the conversation has read outside content.
129
+ if (SETUP_TOOLS.includes(tool) || tool === "subscribe" || tool === "unsubscribe")
130
+ return { cls: "setup" };
131
+ if (LOOK_TOOLS.includes(tool))
132
+ return { cls: "look" };
133
+ // App control. Looking at an app only reads. Acting in one is what the owner said yes to, app by
134
+ // app, for the conversation: it is not asked about click by click. An owner who wants each
135
+ // action looked at sets "approve" on the server.
136
+ if (ctx.app)
137
+ return ctx.app.look ? { cls: "look" } : ctx.mcp?.watched ? { cls: "send", note: "a tool of a server that acts on your behalf" } : { cls: "local", note: "acts in an app the owner allowed for this conversation" };
138
+ if (ctx.mcp)
139
+ return ctx.mcp.readOnly ? { cls: "look" } : ctx.mcp.watched ? { cls: "send", note: "a tool of a server that acts on your behalf" } : { cls: "local" };
140
+ if (tool === "bash") {
141
+ const command = String(input?.command ?? "");
142
+ const critical = criticalCommand(command) ?? (readOnlyCommand(command) ? undefined : ctx.names?.(command));
143
+ if (critical)
144
+ return { cls: "critical", note: critical };
145
+ if (readOnlyCommand(command))
146
+ return { cls: "look" };
147
+ return { cls: ctx.shellReaches ? "reach" : "local" };
148
+ }
149
+ if (tool === "write" || tool === "edit") {
150
+ const given = typeof input?.path === "string" && input.path ? input.path : ".";
151
+ if (ownFileOf(ctx.roots, given, ctx.cwd))
152
+ return { cls: "own", note: "the agent's own memory or instructions" };
153
+ const target = tilde(given);
154
+ const p = realish(path.isAbsolute(target) ? target : path.join(ctx.cwd, target));
155
+ if (isProtectedPath(p))
156
+ return { cls: "critical", note: "a file that makes other programs run or holds the keys to the account" };
157
+ const mine = [ctx.roots.workspace, ctx.roots.sandboxHome, ...(ctx.roots.folder ? [ctx.roots.folder] : [])];
158
+ return { cls: mine.some((r) => isInside(r, p)) ? "local" : "reach" };
159
+ }
160
+ if (tool === "download")
161
+ return { cls: ctx.reachable(input?.url) ? "local" : "reach" };
162
+ if (tool === "delegate")
163
+ return { cls: ctx.canSendOut(String(input?.agent ?? "")) ? "send" : "local", note: "hands a task to an agent that can send things out" };
164
+ return { cls: "local" };
165
+ }
166
+ /** What an agent is told when it tries to act while its owner has it planning. */
167
+ export const PLAN_REFUSAL = "Not done: you are in plan mode. In plan mode you look, read, search and ask, and nothing is changed, run or sent. Do not try another way to do it. When you have seen enough, answer with your plan: what you would do, in which order, in which files, and what could go wrong. Your owner reads it and switches the mode when it is to be carried out.";
package/src/admin.d.ts ADDED
@@ -0,0 +1,167 @@
1
+ import { type AgentConfig, type PineConfig, type RouteConfig } from "./config.ts";
2
+ import type { Kv, TaskStore } from "./store.ts";
3
+ export declare const THINKING: string[];
4
+ /** What can be changed about an agent. Everything is optional; what is left out stays. */
5
+ export interface AgentChange {
6
+ description?: string;
7
+ /** The whole new text of its instruction file (AGENTS.md in its workspace). */
8
+ instructions?: string;
9
+ /** The whole new text of its SOUL.md: who it is, its character and tone. */
10
+ soul?: string;
11
+ /** "default" goes back to pine's default model. */
12
+ model?: string;
13
+ thinking?: string;
14
+ /** A mode, or "default" for what pine gives an agent that names none (auto for the main agent, safe for the others). */
15
+ mode?: string;
16
+ tools?: string[];
17
+ /** Agents it may hand work to; "*" is every agent. */
18
+ delegates?: string[];
19
+ network?: boolean;
20
+ /** Folders outside its workspace it may read from now on. */
21
+ read?: string[];
22
+ /** Folders outside its workspace it may read and change from now on. */
23
+ write?: string[];
24
+ /** Folders to take out of both lists again. */
25
+ forget?: string[];
26
+ }
27
+ /**
28
+ * Check a change to an agent and say what it does, line by line, with what makes it wider.
29
+ * Nothing is written. Throws with what is wrong and how it would be right.
30
+ */
31
+ export declare function checkAgentChange(cfg: PineConfig, agent: AgentConfig, change: AgentChange, models: string[]): {
32
+ lines: string[];
33
+ warnings: string[];
34
+ json: (raw: any) => void;
35
+ instructions?: string;
36
+ soul?: string;
37
+ };
38
+ /**
39
+ * Write a checked change and take it over. The agent's file is read back through the loader
40
+ * with everything else: if the configuration does not load, the file is as it was and nothing
41
+ * has changed.
42
+ */
43
+ export declare function applyAgentChange(cfg: PineConfig, agent: AgentConfig, checked: {
44
+ json: (raw: any) => void;
45
+ instructions?: string;
46
+ soul?: string;
47
+ }): void;
48
+ /** The parts of the configuration that name an agent and stand in the way of removing it, or are corrected when it goes. */
49
+ export declare function namedBy(cfg: PineConfig, id: string): {
50
+ routes: string[];
51
+ delegators: string[];
52
+ sources: string[];
53
+ servers: string[];
54
+ };
55
+ /** Take an agent's name out of the lists that name it: other agents' delegates, and the sources and servers of all agents that are only for some. */
56
+ export declare function unname(cfg: PineConfig, id: string): void;
57
+ /**
58
+ * Take what is left of an agent out of pine's files and store, so that nothing of it remains:
59
+ * the routes that wake it, its name in the lists of others, the secrets pine kept for its
60
+ * sources and servers, what is stored under its name (marks, lists, turns, tasks, pins, open
61
+ * tabs), the recorded states of its folders, its private home and its folder. This is the part
62
+ * that needs no running daemon: `AgentManager.removeAgent` stops what runs and then calls it,
63
+ * and `pine agent remove` calls it alone when no daemon runs.
64
+ *
65
+ * The folder is moved aside first and the configuration that is left is read back. If that
66
+ * does not load, the folder stays in `removed/` and `problem` says why. With `keepFiles` it
67
+ * stays there on purpose. A workspace outside pine's home is the owner's folder and is left.
68
+ */
69
+ export declare function eraseAgent(cfg: PineConfig, store: {
70
+ kv: Kv;
71
+ tasks: TaskStore;
72
+ }, id: string, keepFiles?: boolean): {
73
+ routes: string[];
74
+ kept?: string;
75
+ workspaceLeft?: string;
76
+ problem?: string;
77
+ };
78
+ /** A route as the main agent proposes it: a few named values, the same ones `pine.json` takes. */
79
+ export interface RouteInput {
80
+ name: string;
81
+ /** Topic patterns it listens to, separated by commas. */
82
+ on: string;
83
+ /** Only events that match, as JSON: {"payload.open": true}. */
84
+ when?: string;
85
+ throttle?: string;
86
+ debounce?: string;
87
+ /** Wake an agent with a prompt. */
88
+ agent?: string;
89
+ prompt?: string;
90
+ session?: string;
91
+ /** Write shared state, as JSON: {"house/mode": "{{payload.value}}"}. */
92
+ set?: string;
93
+ publish_topic?: string;
94
+ publish_payload?: string;
95
+ /** One model call without tools. */
96
+ call_prompt?: string;
97
+ call_system?: string;
98
+ call_model?: string;
99
+ trust?: string;
100
+ }
101
+ /** Check a proposed route and say what it does, line by line. Nothing is written. */
102
+ export declare function checkRoute(cfg: PineConfig, input: RouteInput, models: string[]): {
103
+ entry: Record<string, unknown>;
104
+ lines: string[];
105
+ wider?: string;
106
+ };
107
+ /** Write a checked route into pine.json and take it over. If the configuration does not load with it, the file is as it was. */
108
+ export declare function addRoute(cfg: PineConfig, entry: Record<string, unknown>): RouteConfig;
109
+ /** Take a route out of pine.json by its name. The routes that stay keep their names, also those that had none of their own. */
110
+ export declare function dropRoute(cfg: PineConfig, name: string): boolean;
111
+ /** The routes as a list for the agent. */
112
+ export declare function routesText(cfg: PineConfig): string;
113
+ /** What an agent has, as its files say it: what goes with it when it is removed. */
114
+ export declare function holdingsOf(cfg: PineConfig, id: string): {
115
+ conversations: string[];
116
+ sources: string[];
117
+ servers: string[];
118
+ schedules: string[];
119
+ skills: string[];
120
+ routes: string[];
121
+ files: number;
122
+ outside: boolean;
123
+ };
124
+ /** How many files lie in a folder, without following links. Stops counting at a limit. */
125
+ export declare function countFiles(dir: string, limit?: number): number;
126
+ interface Setting {
127
+ about: string;
128
+ /** What a value has to be. */
129
+ kind: "model" | "boolean" | "duration" | {
130
+ one: string[];
131
+ } | {
132
+ from: number;
133
+ to: number;
134
+ };
135
+ /** What is in force now, in the words the setting is written in. */
136
+ now(cfg: PineConfig): string;
137
+ /** Whether a new value holds at once. Otherwise it is saved and holds from the next start of pine. */
138
+ live: boolean;
139
+ /** What a value gives up, if it gives something up: said to the owner with the question. */
140
+ wider?(value: unknown): string | undefined;
141
+ }
142
+ /**
143
+ * The settings in pine.json that the main agent can change. Not here on purpose: the control
144
+ * API (address, port, token), secrets, and the lists that have tools of their own (sources, MCP
145
+ * servers, skills, schedules, source types, model servers, agents).
146
+ */
147
+ export declare const SETTINGS: Record<string, Setting>;
148
+ /** The settings as a list for the agent: name, what is in force, what it is. */
149
+ export declare function settingsText(cfg: PineConfig): string;
150
+ /** Check a value for a setting. "default" (or nothing) means: take the entry out, so that pine's default holds. */
151
+ export declare function checkSetting(cfg: PineConfig, key: string, given: unknown, models: string[]): {
152
+ key: string;
153
+ setting: Setting;
154
+ value: unknown;
155
+ text: string;
156
+ wider?: string;
157
+ };
158
+ /**
159
+ * Write a checked setting into pine.json and take it over. The file is read back through the
160
+ * loader; if the configuration does not load, the file is as it was.
161
+ */
162
+ export declare function applySetting(cfg: PineConfig, checked: {
163
+ key: string;
164
+ setting: Setting;
165
+ value: unknown;
166
+ }): void;
167
+ export {};