@pmndre/pine 0.22.0 → 0.33.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/README.md +2 -1
- package/changes.json +265 -0
- package/docs/SKILL.md +31 -7
- package/docs/references/agents.md +245 -21
- package/docs/references/coding.md +1 -1
- package/docs/references/computer.md +1 -1
- package/docs/references/configuration.md +14 -5
- package/docs/references/mcp.md +9 -0
- package/docs/references/operations.md +20 -9
- package/docs/references/overview.md +3 -1
- package/docs/references/security.md +83 -24
- package/docs/references/setup.md +55 -9
- package/docs/references/source-types.md +1418 -0
- package/docs/references/sources.md +333 -19
- package/docs/references/stack.md +1 -0
- package/docs/references/tui.md +86 -12
- package/examples/home/AGENTS.md +4 -0
- package/examples/home/TOOLS.md +5 -0
- package/examples/home/agents/main/workspace/AGENTS.md +1 -1
- package/examples/home/agents/main/workspace/TOOLS.md +5 -0
- package/mcp/browser.d.ts +6 -0
- package/mcp/browser.js +19 -0
- package/mcp/render.d.ts +1 -0
- package/mcp/render.js +237 -0
- package/package.json +3 -1
- package/src/actions.d.ts +6 -1
- package/src/actions.js +17 -4
- package/src/admin.d.ts +4 -0
- package/src/admin.js +25 -6
- package/src/agents.d.ts +167 -2
- package/src/agents.js +912 -45
- package/src/catalogue.d.ts +60 -0
- package/src/catalogue.js +791 -0
- package/src/cli.js +10 -7
- package/src/config.d.ts +53 -4
- package/src/config.js +30 -5
- package/src/goals.d.ts +1 -1
- package/src/goals.js +14 -1
- package/src/manual.js +24 -2
- package/src/mime.d.ts +78 -0
- package/src/mime.js +342 -0
- package/src/net.d.ts +11 -0
- package/src/net.js +29 -2
- package/src/pine.js +10 -1
- package/src/router.js +3 -3
- package/src/sandbox-linux.d.ts +3 -1
- package/src/sandbox-linux.js +5 -0
- package/src/security.d.ts +22 -6
- package/src/security.js +44 -13
- package/src/slots.d.ts +106 -0
- package/src/slots.js +250 -0
- package/src/source-types.d.ts +20 -0
- package/src/sources/calendar.d.ts +24 -0
- package/src/sources/calendar.js +265 -0
- package/src/sources/command.js +109 -4
- package/src/sources/discord.d.ts +4 -0
- package/src/sources/discord.js +298 -0
- package/src/sources/feed.d.ts +19 -0
- package/src/sources/feed.js +257 -0
- package/src/sources/http.js +154 -103
- package/src/sources/mail.d.ts +51 -0
- package/src/sources/mail.js +1013 -0
- package/src/sources/matrix.d.ts +4 -0
- package/src/sources/matrix.js +232 -0
- package/src/sources/modbus.d.ts +15 -0
- package/src/sources/modbus.js +240 -0
- package/src/sources/onvif.d.ts +35 -0
- package/src/sources/onvif.js +326 -0
- package/src/sources/presence.d.ts +80 -0
- package/src/sources/presence.js +480 -0
- package/src/sources/serial.d.ts +21 -0
- package/src/sources/serial.js +220 -0
- package/src/sources/slack.d.ts +16 -0
- package/src/sources/slack.js +1062 -0
- package/src/sources/smtp.d.ts +4 -0
- package/src/sources/smtp.js +360 -0
- package/src/sources/stream.d.ts +68 -0
- package/src/sources/stream.js +534 -0
- package/src/sources/syslog.d.ts +32 -0
- package/src/sources/syslog.js +243 -0
- package/src/sources/system.d.ts +14 -0
- package/src/sources/system.js +236 -0
- package/src/sources/system.swift +102 -0
- package/src/sources/telegram.js +34 -1
- package/src/sources.d.ts +41 -1
- package/src/sources.js +147 -24
- package/src/tools.d.ts +1 -1
- package/src/tools.js +304 -23
- package/src/tui/app.d.ts +35 -2
- package/src/tui/app.js +306 -43
- package/src/tui/levels.d.ts +68 -0
- package/src/tui/levels.js +273 -0
- package/src/tui/picture.d.ts +17 -1
- package/src/tui/picture.js +72 -5
- package/src/types.d.ts +3 -0
- package/src/update.d.ts +9 -1
- package/src/update.js +75 -3
- package/src/watching.d.ts +156 -0
- package/src/watching.js +609 -4
package/src/cli.js
CHANGED
|
@@ -55,9 +55,10 @@ Talking to a running daemon
|
|
|
55
55
|
|
|
56
56
|
Event sources
|
|
57
57
|
pine sources configured sources, whether they run, who is subscribed, last event
|
|
58
|
-
pine subscribe <agent> <source> [--session name] [--note text] [--throttle 5m] [--when json] [--separate]
|
|
58
|
+
pine subscribe <agent> <source> [--session name | --fresh] [--note text] [--throttle 5m] [--when json] [--separate]
|
|
59
59
|
wake that agent whenever the source reports something: in its main
|
|
60
|
-
conversation,
|
|
60
|
+
conversation, only the conversation named with --session, or with
|
|
61
|
+
--fresh in a new conversation for every event
|
|
61
62
|
pine subscribe --global <source> [--note text] ...
|
|
62
63
|
wake every agent that can use the source
|
|
63
64
|
pine unsubscribe <agent> <source> [--session name] | pine unsubscribe --global <source>
|
|
@@ -72,7 +73,7 @@ Agents (the main agent does the same when you ask it: create_agent, update_agent
|
|
|
72
73
|
pine agent add <id> --description "what it is for" [--instructions "who it is and how it works"]
|
|
73
74
|
[--instructions-file <file>] [--model provider/model] [--tools read,bash,...]
|
|
74
75
|
pine agent update <id> [--description ...] [--instructions ... | --instructions-file <file>]
|
|
75
|
-
[--soul ... | --soul-file <file>]
|
|
76
|
+
[--soul ... | --soul-file <file>] [--tooling ... | --tooling-file <file>]
|
|
76
77
|
[--model provider/model|default] [--thinking off|low|...|max]
|
|
77
78
|
[--mode auto|safe|manual|bypass|plan|default] [--tools read,bash,...] [--delegates id,id|*]
|
|
78
79
|
[--network | --no-network] [--read /path,/path] [--write /path] [--forget /path]
|
|
@@ -104,7 +105,7 @@ function parseArgs(argv) {
|
|
|
104
105
|
else if (a.startsWith("--no-"))
|
|
105
106
|
flags[a.slice(5)] = false;
|
|
106
107
|
else if (a.startsWith("--"))
|
|
107
|
-
flags[a.slice(2)] = argv[i + 1] !== undefined && !argv[i + 1].startsWith("--") && !["follow", "json", "api-key", "oauth", "taints", "offline", "always", "separate", "global", "yes", "keep-files", "network"].includes(a.slice(2)) ? argv[++i] : true;
|
|
108
|
+
flags[a.slice(2)] = argv[i + 1] !== undefined && !argv[i + 1].startsWith("--") && !["follow", "json", "api-key", "oauth", "taints", "offline", "always", "separate", "fresh", "global", "yes", "keep-files", "network"].includes(a.slice(2)) ? argv[++i] : true;
|
|
108
109
|
else
|
|
109
110
|
rest.push(a);
|
|
110
111
|
}
|
|
@@ -198,7 +199,7 @@ async function agentCommand(cfg, argv, out) {
|
|
|
198
199
|
}
|
|
199
200
|
case "update": {
|
|
200
201
|
const id = rest[0];
|
|
201
|
-
const usage = 'usage: pine agent update <id> [--description "..."] [--instructions "..." | --instructions-file <file>] [--soul "..." | --soul-file <file>] [--model provider/model|default] [--thinking off|minimal|low|medium|high|xhigh|max] [--mode auto|safe|manual|bypass|plan|default] [--tools read,bash,...] [--delegates id,id|*] [--network | --no-network] [--read /path,/path] [--write /path] [--forget /path]';
|
|
202
|
+
const usage = 'usage: pine agent update <id> [--description "..."] [--instructions "..." | --instructions-file <file>] [--soul "..." | --soul-file <file>] [--tooling "..." | --tooling-file <file>] [--model provider/model|default] [--thinking off|minimal|low|medium|high|xhigh|max] [--mode auto|safe|manual|bypass|plan|default] [--tools read,bash,...] [--delegates id,id|*] [--network | --no-network] [--read /path,/path] [--write /path] [--forget /path]';
|
|
202
203
|
if (!id)
|
|
203
204
|
throw new Error(usage);
|
|
204
205
|
const agent = cfg.agents[id];
|
|
@@ -211,6 +212,7 @@ async function agentCommand(cfg, argv, out) {
|
|
|
211
212
|
description: str(flags.description),
|
|
212
213
|
instructions: fromFile ?? str(flags.instructions),
|
|
213
214
|
soul: typeof flags["soul-file"] === "string" ? fs.readFileSync(expandHome(flags["soul-file"]), "utf8") : str(flags.soul),
|
|
215
|
+
tooling: typeof flags["tooling-file"] === "string" ? fs.readFileSync(expandHome(flags["tooling-file"]), "utf8") : str(flags.tooling),
|
|
214
216
|
model: str(flags.model),
|
|
215
217
|
thinking: str(flags.thinking),
|
|
216
218
|
mode: str(flags.mode),
|
|
@@ -739,8 +741,9 @@ async function main() {
|
|
|
739
741
|
const r = await api.post(`/agents/${rest[0]}/unsubscribe`, { source: rest[1], session: typeof flags.session === "string" ? flags.session : undefined });
|
|
740
742
|
return out(r.unsubscribed ? `${rest[0]} is no longer subscribed to ${rest[1]}${r.sessions.some((x) => x !== "main") ? ` (conversations: ${r.sessions.join(", ")})` : ""}` : `${rest[0]} was not subscribed to ${rest[1]}`);
|
|
741
743
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
+
// --fresh: a conversation of its own for every event, instead of the agent's main one.
|
|
745
|
+
const info = await api.post(`/agents/${rest[0]}/subscribe`, { source: rest[1], session: flags.fresh === true ? "new" : flags.session, ...details });
|
|
746
|
+
return out(`${rest[0]} is subscribed to ${rest[1]} (${info.running ? "running" : "not running"}); each event wakes it in ${info.session === "new" ? "a fresh conversation of its own" : `its conversation "${info.session}"`}`);
|
|
744
747
|
}
|
|
745
748
|
case "approvals": {
|
|
746
749
|
const list = await api.get("/approvals");
|
package/src/config.d.ts
CHANGED
|
@@ -58,6 +58,14 @@ export interface SourceConfig {
|
|
|
58
58
|
options: Record<string, any>;
|
|
59
59
|
}
|
|
60
60
|
export declare const SOURCE_TYPES: string[];
|
|
61
|
+
/**
|
|
62
|
+
* The types an agent is told about with all their options, in the description of its add_source
|
|
63
|
+
* tool. The others are named there with what they are for: what each takes is in the manual
|
|
64
|
+
* (a part per type, made from the type's own schema) and in the answer to a call that leaves a
|
|
65
|
+
* needed option out. A description that carried every option of every type would be read with
|
|
66
|
+
* every request.
|
|
67
|
+
*/
|
|
68
|
+
export declare const EVERYDAY_TYPES: string[];
|
|
61
69
|
/** Topics only the daemon itself publishes on: the publish_event tool and route definitions refuse them. */
|
|
62
70
|
export declare const RESERVED_TOPICS: string[];
|
|
63
71
|
/**
|
|
@@ -95,6 +103,12 @@ export interface RouteConfig {
|
|
|
95
103
|
debounceMs?: number;
|
|
96
104
|
/** Handle the first event, then ignore matching events for this long. */
|
|
97
105
|
throttleMs?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Without a `prompt`: show the agent the whole event, also when it has a `text`. Otherwise an
|
|
108
|
+
* event with a text is that text and nothing else, which is right for somebody writing to the
|
|
109
|
+
* agent and wrong for a report about a message (who wrote it, where, is the rest of the event).
|
|
110
|
+
*/
|
|
111
|
+
whole?: boolean;
|
|
98
112
|
/** Template for the debounce/throttle bucket. Default: the event topic. */
|
|
99
113
|
key?: string;
|
|
100
114
|
/** Write world state: key template -> value template. */
|
|
@@ -181,6 +195,14 @@ export type Level = "manual" | "safe" | "auto" | "bypass";
|
|
|
181
195
|
export type Mode = Level | "plan";
|
|
182
196
|
export declare const LEVELS: Level[];
|
|
183
197
|
export declare const MODES: Mode[];
|
|
198
|
+
/**
|
|
199
|
+
* How an agent's tools are declared to the model. "families": a group of tools is one declared
|
|
200
|
+
* tool, and everything before a conversation's first message is the same for all conversations
|
|
201
|
+
* of the agent, so that a model server keeps what it has read (src/catalogue.ts, steady() in
|
|
202
|
+
* agents.ts). "full": every tool by itself with its whole description, as pi does it.
|
|
203
|
+
*/
|
|
204
|
+
export type Catalogue = "families" | "full";
|
|
205
|
+
export declare const CATALOGUES: Catalogue[];
|
|
184
206
|
/** Whether a level leaves the sandbox off: the owner's whole account and the network. */
|
|
185
207
|
export declare const unsandboxed: (level: Level) => level is "auto" | "bypass";
|
|
186
208
|
export interface SandboxConfig {
|
|
@@ -210,6 +232,8 @@ export interface AgentConfig {
|
|
|
210
232
|
workspace: string;
|
|
211
233
|
model?: string;
|
|
212
234
|
thinking: string;
|
|
235
|
+
/** How its tools are declared to the model. */
|
|
236
|
+
catalogue: Catalogue;
|
|
213
237
|
/** Allowlist of pi built-in tools. Undefined keeps pi's default set. */
|
|
214
238
|
tools?: string[];
|
|
215
239
|
mcp: Record<string, McpServerConfig>;
|
|
@@ -268,7 +292,8 @@ export interface PineConfig {
|
|
|
268
292
|
defaults: {
|
|
269
293
|
model?: string; /** The model that judges whether a goal is met, as "provider/id". Not set: the agent's own. */
|
|
270
294
|
judge?: string;
|
|
271
|
-
thinking: string;
|
|
295
|
+
thinking: string; /** How tools are declared to the model, for agents that do not say. */
|
|
296
|
+
catalogue: Catalogue;
|
|
272
297
|
mode?: Mode;
|
|
273
298
|
bashTimeoutSec: number;
|
|
274
299
|
taskTimeoutSec: number;
|
|
@@ -299,6 +324,21 @@ export interface PineConfig {
|
|
|
299
324
|
goalIdleRounds: number;
|
|
300
325
|
/** How long the judge of a goal may take before its silence counts as no verdict. */
|
|
301
326
|
goalJudgeMs: number;
|
|
327
|
+
/**
|
|
328
|
+
* Whether pine has the idle slots of a llama.cpp server read what every conversation of an
|
|
329
|
+
* agent begins with (the tools and instructions), after the owner has used the model: the
|
|
330
|
+
* next conversation, or a sub-agent, then starts where the server has read already. It
|
|
331
|
+
* costs the server one reading of that beginning per slot, in the background.
|
|
332
|
+
*/
|
|
333
|
+
warmSlots: boolean;
|
|
334
|
+
/** How long the model has to be left alone before an idle slot is filled. */
|
|
335
|
+
warmAfterMs: number;
|
|
336
|
+
/**
|
|
337
|
+
* How many conversations that had to leave their slot are kept in files of a llama.cpp
|
|
338
|
+
* server that has a folder for them (--slot-save-path), to be read back when they come
|
|
339
|
+
* again (src/slots.ts). 0: none.
|
|
340
|
+
*/
|
|
341
|
+
slotPages: number;
|
|
302
342
|
};
|
|
303
343
|
security: {
|
|
304
344
|
approvalTimeoutMs: number;
|
|
@@ -356,11 +396,20 @@ export declare function loadConfig(home?: string): PineConfig;
|
|
|
356
396
|
/**
|
|
357
397
|
* The files in an agent's workspace that are part of its prompt, in the order they enter it. They
|
|
358
398
|
* are the agent's own: it reads them as its instructions and keeps them up to date itself.
|
|
359
|
-
* AGENTS.md is how it works, SOUL.md who it is,
|
|
399
|
+
* AGENTS.md is how it works, SOUL.md who it is, TOOLS.md how it uses its tools (what is
|
|
400
|
+
* different or more for it than the TOOLS.md for all agents says), MEMORY.md what should
|
|
401
|
+
* outlive a conversation.
|
|
360
402
|
*/
|
|
361
403
|
export declare const WORKSPACE_FILES: string[];
|
|
362
|
-
/**
|
|
363
|
-
|
|
404
|
+
/**
|
|
405
|
+
* What is the same for all agents: three files in pine's home, in every agent's prompt, kept by
|
|
406
|
+
* the main agent. AGENTS.md is traits and behaviour (how every agent is to be and to act),
|
|
407
|
+
* TOOLS.md is tooling (defaults and preferences for tools of any kind: skills, MCP servers,
|
|
408
|
+
* shell commands, schedules, event sources; technical and functional details), USER.md what is
|
|
409
|
+
* known about the owner. An agent's own files say what is different for it.
|
|
410
|
+
*/
|
|
411
|
+
export declare const SHARED_FILES: string[];
|
|
412
|
+
export declare const sharedFiles: (cfg: PineConfig) => string[];
|
|
364
413
|
/**
|
|
365
414
|
* Where skills lie that were set up by tool call. The place says whom a skill is for: all agents,
|
|
366
415
|
* one agent, or one conversation of an agent. All of it is inside pine's home, which agents read
|
package/src/config.js
CHANGED
|
@@ -2,11 +2,20 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parseEnv } from "node:util";
|
|
4
4
|
import { expandHome, parseDuration, resolvePath } from "./util.js";
|
|
5
|
-
export const SOURCE_TYPES = ["folder", "mqtt", "webhook", "ftp", "telegram", "http", "command"];
|
|
5
|
+
export const SOURCE_TYPES = ["folder", "mqtt", "webhook", "ftp", "telegram", "http", "command", "feed", "calendar", "stream", "mail", "slack", "matrix", "discord", "smtp", "syslog", "system", "presence", "modbus", "serial", "onvif"];
|
|
6
|
+
/**
|
|
7
|
+
* The types an agent is told about with all their options, in the description of its add_source
|
|
8
|
+
* tool. The others are named there with what they are for: what each takes is in the manual
|
|
9
|
+
* (a part per type, made from the type's own schema) and in the answer to a call that leaves a
|
|
10
|
+
* needed option out. A description that carried every option of every type would be read with
|
|
11
|
+
* every request.
|
|
12
|
+
*/
|
|
13
|
+
export const EVERYDAY_TYPES = ["folder", "mqtt", "webhook", "ftp", "telegram", "http", "command"];
|
|
6
14
|
/** Topics only the daemon itself publishes on: the publish_event tool and route definitions refuse them. */
|
|
7
15
|
export const RESERVED_TOPICS = ["approval/#", "agent/#", "pine/#", "state/#", "timer/#"];
|
|
8
16
|
export const LEVELS = ["auto", "safe", "manual", "bypass"];
|
|
9
17
|
export const MODES = [...LEVELS, "plan"];
|
|
18
|
+
export const CATALOGUES = ["families", "full"];
|
|
10
19
|
/** Whether a level leaves the sandbox off: the owner's whole account and the network. */
|
|
11
20
|
export const unsandboxed = (level) => level === "auto" || level === "bypass";
|
|
12
21
|
export class ConfigError extends Error {
|
|
@@ -85,6 +94,7 @@ function loadAgent(id, dir, raw, cfg, problems) {
|
|
|
85
94
|
workspace,
|
|
86
95
|
model: raw.model,
|
|
87
96
|
thinking: raw.thinking ?? cfg.defaults.thinking,
|
|
97
|
+
catalogue: raw.catalogue ?? cfg.defaults.catalogue,
|
|
88
98
|
tools: Array.isArray(raw.tools) ? raw.tools.map(String) : undefined,
|
|
89
99
|
mcp: raw.mcp ?? {},
|
|
90
100
|
globalMcp: raw.globalMcp ?? true,
|
|
@@ -237,6 +247,7 @@ export function loadConfig(home = defaultHome()) {
|
|
|
237
247
|
model: d.model,
|
|
238
248
|
judge: typeof d.judge === "string" && d.judge ? d.judge : undefined,
|
|
239
249
|
thinking: d.thinking ?? "off",
|
|
250
|
+
catalogue: d.catalogue ?? "families",
|
|
240
251
|
mode: d.mode,
|
|
241
252
|
bashTimeoutSec: d.bashTimeoutSec ?? 900,
|
|
242
253
|
taskTimeoutSec: d.taskTimeoutSec ?? 7200,
|
|
@@ -247,6 +258,9 @@ export function loadConfig(home = defaultHome()) {
|
|
|
247
258
|
maxConcurrentRuns: l.maxConcurrentRuns ?? 2,
|
|
248
259
|
maxDelegationDepth: l.maxDelegationDepth ?? 3,
|
|
249
260
|
maxDownloadMb: l.maxDownloadMb ?? 200,
|
|
261
|
+
warmSlots: l.warmSlots ?? true,
|
|
262
|
+
warmAfterMs: l.warmAfterMs ?? 3000,
|
|
263
|
+
slotPages: l.slotPages ?? 6,
|
|
250
264
|
maxEventHops: l.maxEventHops ?? 8,
|
|
251
265
|
modelHeadersTimeoutMs: parseDuration(l.modelHeadersTimeoutMs ?? "10m"),
|
|
252
266
|
modelStreamIdleMs: parseDuration(l.modelStreamIdleMs ?? "5m"),
|
|
@@ -321,6 +335,8 @@ export function loadConfig(home = defaultHome()) {
|
|
|
321
335
|
a.level = a.mode === "plan" || !MODES.includes(a.mode) ? plain : a.mode;
|
|
322
336
|
if (!MODES.includes(a.mode))
|
|
323
337
|
problems.push(`agents/${a.id}/agent.json: mode must be one of ${MODES.join(", ")} (got "${a.mode}")`);
|
|
338
|
+
if (!CATALOGUES.includes(a.catalogue))
|
|
339
|
+
problems.push(`agents/${a.id}/agent.json: catalogue must be one of ${CATALOGUES.join(", ")} (got "${a.catalogue}")`);
|
|
324
340
|
if (!(a.model ?? cfg.defaults.model))
|
|
325
341
|
problems.push(`agents/${a.id}/agent.json: no model (set "model" or defaults.model in pine.json)`);
|
|
326
342
|
for (const t of a.delegates)
|
|
@@ -377,11 +393,20 @@ export function loadConfig(home = defaultHome()) {
|
|
|
377
393
|
/**
|
|
378
394
|
* The files in an agent's workspace that are part of its prompt, in the order they enter it. They
|
|
379
395
|
* are the agent's own: it reads them as its instructions and keeps them up to date itself.
|
|
380
|
-
* AGENTS.md is how it works, SOUL.md who it is,
|
|
396
|
+
* AGENTS.md is how it works, SOUL.md who it is, TOOLS.md how it uses its tools (what is
|
|
397
|
+
* different or more for it than the TOOLS.md for all agents says), MEMORY.md what should
|
|
398
|
+
* outlive a conversation.
|
|
399
|
+
*/
|
|
400
|
+
export const WORKSPACE_FILES = ["AGENTS.md", "SOUL.md", "TOOLS.md", "MEMORY.md"];
|
|
401
|
+
/**
|
|
402
|
+
* What is the same for all agents: three files in pine's home, in every agent's prompt, kept by
|
|
403
|
+
* the main agent. AGENTS.md is traits and behaviour (how every agent is to be and to act),
|
|
404
|
+
* TOOLS.md is tooling (defaults and preferences for tools of any kind: skills, MCP servers,
|
|
405
|
+
* shell commands, schedules, event sources; technical and functional details), USER.md what is
|
|
406
|
+
* known about the owner. An agent's own files say what is different for it.
|
|
381
407
|
*/
|
|
382
|
-
export const
|
|
383
|
-
|
|
384
|
-
export const userFile = (cfg) => path.join(cfg.home, "USER.md");
|
|
408
|
+
export const SHARED_FILES = ["AGENTS.md", "TOOLS.md", "USER.md"];
|
|
409
|
+
export const sharedFiles = (cfg) => SHARED_FILES.map((f) => path.join(cfg.home, f));
|
|
385
410
|
/**
|
|
386
411
|
* Where skills lie that were set up by tool call. The place says whom a skill is for: all agents,
|
|
387
412
|
* one agent, or one conversation of an agent. All of it is inside pine's home, which agents read
|
package/src/goals.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare function parseJudgement(text: string): {
|
|
|
59
59
|
verdict: GoalVerdict;
|
|
60
60
|
reason?: string;
|
|
61
61
|
} | undefined;
|
|
62
|
-
type Manager = Pick<AgentManager, "cfg" | "kv" | "tasks" | "bus" | "limiter" | "models" | "submit" | "cancel" | "resolveModel" | "modelFor">;
|
|
62
|
+
type Manager = Pick<AgentManager, "cfg" | "kv" | "tasks" | "bus" | "limiter" | "models" | "submit" | "cancel" | "resolveModel" | "modelFor" | "callSlot">;
|
|
63
63
|
export declare class Goals {
|
|
64
64
|
private m;
|
|
65
65
|
private log;
|
package/src/goals.js
CHANGED
|
@@ -294,7 +294,20 @@ export class Goals {
|
|
|
294
294
|
return undefined;
|
|
295
295
|
// A model of its own where one is set: a second, small model keeps the judge from pushing the agent's conversation out of a model server's cache.
|
|
296
296
|
const model = cfg.defaults.judge ? this.m.resolveModel(cfg.defaults.judge) : this.m.modelFor(agent);
|
|
297
|
-
|
|
297
|
+
// On a llama.cpp server the judge is given a slot of its own, like a new conversation: left to the server, its
|
|
298
|
+
// call could land in the slot of the conversation it judges, which would then be read again from its first word.
|
|
299
|
+
const place = await this.m.callSlot(model, `${agent.id}:~judge`);
|
|
300
|
+
let msg;
|
|
301
|
+
try {
|
|
302
|
+
msg = await this.m.models.completeSimple(model, { systemPrompt: system, messages: [{ role: "user", content: [{ type: "text", text: user }], timestamp: Date.now() }] }, {
|
|
303
|
+
signal: AbortSignal.any([stop.signal, AbortSignal.timeout(cfg.limits.goalJudgeMs)]),
|
|
304
|
+
sessionId: "pine-goal",
|
|
305
|
+
onPayload: (payload) => (place.slot === undefined ? undefined : { ...payload, id_slot: place.slot }),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
place.done();
|
|
310
|
+
}
|
|
298
311
|
if (msg.stopReason === "error" || msg.stopReason === "aborted")
|
|
299
312
|
throw new Error(msg.errorMessage ?? `model call ${msg.stopReason}`);
|
|
300
313
|
const text = (msg.content ?? []).filter((c) => c.type === "text").map((c) => c.text).join("");
|
package/src/manual.js
CHANGED
|
@@ -12,13 +12,33 @@ const SYNONYMS = [
|
|
|
12
12
|
["approve", "approval", "permission", "confirm", "consent", "ask", "allow", "deny", "dialog", "prompt", "question"],
|
|
13
13
|
["sandbox", "isolation", "confine", "restrict", "jail", "permission", "access"],
|
|
14
14
|
["conversation", "session", "tab", "chat", "thread"],
|
|
15
|
+
["rss", "atom", "podcast", "blog", "newsletter", "release", "changelog", "syndication"],
|
|
16
|
+
["calendar", "ical", "ics", "icalendar", "webcal", "caldav", "appointment", "meeting", "agenda"],
|
|
17
|
+
["selector", "select", "css", "element", "scrape", "scraping", "dom"],
|
|
18
|
+
["render", "rendered", "javascript", "js", "dynamic", "spa", "headless", "ajax"],
|
|
19
|
+
["stream", "sse", "eventsource", "websocket", "push", "realtime", "firehose"],
|
|
20
|
+
["mail", "email", "inbox", "mailbox", "imap", "gmail", "icloud"],
|
|
21
|
+
["microsoft", "outlook", "hotmail", "office365", "m365", "exchange", "entra", "azure"],
|
|
22
|
+
["signin", "sign", "oauth", "oauth2", "login", "xoauth2", "sso"],
|
|
23
|
+
["smtp", "maildrop", "mailserver", "msmtp", "postfix", "sendmail"],
|
|
24
|
+
["syslog", "rsyslog", "journal", "siem"],
|
|
25
|
+
["matrix", "element", "homeserver", "synapse"],
|
|
26
|
+
["discord", "guild", "gateway"],
|
|
27
|
+
["mention", "ping", "highlight"],
|
|
28
|
+
["modbus", "inverter", "solar", "photovoltaic", "pv", "heatpump", "wallbox", "sunspec", "register"],
|
|
29
|
+
["serial", "uart", "comport", "rs232", "arduino", "esp32", "microcontroller", "dsmr", "nmea"],
|
|
30
|
+
["onvif", "camera", "ipcam", "cctv", "nvr", "surveillance"],
|
|
31
|
+
["presence", "geofence", "bonjour", "mdns", "zeroconf", "reachable"],
|
|
32
|
+
["system", "computer", "mac", "laptop", "sleep", "wake", "lock", "unlock", "battery"],
|
|
33
|
+
["catalogue", "catalog", "family", "families", "declare", "declared", "declaration", "toolset", "grouped", "schema"],
|
|
34
|
+
["cache", "cached", "caching", "slot", "warm", "reread", "reprocess", "reprocessing", "kept", "prefix", "page", "paging"],
|
|
15
35
|
["undo", "redo", "revert", "rollback", "rewind", "restore", "checkpoint", "snapshot", "unsend", "mistake"],
|
|
16
36
|
["taint", "tainted", "outside", "untrusted", "injection", "external", "hostile"],
|
|
17
37
|
["trust", "owner", "trusted", "yours"],
|
|
18
38
|
["scope", "local", "global"],
|
|
19
39
|
["global", "everyone", "all", "shared", "every"],
|
|
20
40
|
["agent", "assistant", "bot", "persona"],
|
|
21
|
-
["subagent", "delegate", "delegation", "handoff", "child", "spawn"],
|
|
41
|
+
["subagent", "delegate", "delegation", "handoff", "child", "spawn", "helper", "worker"],
|
|
22
42
|
["model", "llm", "provider", "inference", "endpoint"],
|
|
23
43
|
["telegram", "messenger", "phone", "chat", "bot"],
|
|
24
44
|
["pair", "pairing", "link", "connect", "bind"],
|
|
@@ -42,10 +62,12 @@ const SYNONYMS = [
|
|
|
42
62
|
["goal", "objective", "target", "aim", "mission", "autonomous", "autonomously", "unattended", "nonstop", "overnight"],
|
|
43
63
|
["error", "problem", "fail", "broken", "troubleshoot", "debug", "wrong", "stuck"],
|
|
44
64
|
["log", "history", "audit", "record", "trace"],
|
|
45
|
-
["image", "picture", "photo", "screenshot", "video", "media"],
|
|
65
|
+
["image", "picture", "photo", "screenshot", "video", "media", "clip"],
|
|
46
66
|
["sound", "audio", "speech", "voice", "music", "hear", "wav", "mp3"],
|
|
67
|
+
["bars", "waveform", "spectrum", "equalizer", "equaliser", "visualizer", "visualiser", "animation", "animated"],
|
|
47
68
|
["dictate", "dictating", "dictation", "microphone", "talk", "talking", "speak", "speaking"],
|
|
48
69
|
["browser", "web", "playwright", "page", "search"],
|
|
70
|
+
["fold", "collapse", "collapsed", "expand", "unfold", "clutter", "cluttered", "noise"],
|
|
49
71
|
["show", "visible", "headed", "headless", "window", "watch", "see"],
|
|
50
72
|
["plan", "propose", "proposal", "outline", "preview", "dry"],
|
|
51
73
|
["todo", "step", "checklist", "track", "progress", "tasklist"],
|
package/src/mime.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export interface MailLimits {
|
|
2
|
+
/** How many parts of a message are looked at; the rest is left out. */
|
|
3
|
+
parts?: number;
|
|
4
|
+
/** How deep parts may lie inside parts. */
|
|
5
|
+
depth?: number;
|
|
6
|
+
/** How many characters of text are kept. */
|
|
7
|
+
text?: number;
|
|
8
|
+
/** The largest attachment that is kept, in bytes. A larger one is named, without its bytes. */
|
|
9
|
+
attachmentBytes?: number;
|
|
10
|
+
/** How many attachments are kept. */
|
|
11
|
+
attachments?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface MailFile {
|
|
14
|
+
/** A plain file name: no folders, no control characters. */
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
size: number;
|
|
18
|
+
/** What it holds; empty for one that was larger than the limit (`skipped`). */
|
|
19
|
+
bytes: Buffer;
|
|
20
|
+
skipped?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Mail {
|
|
23
|
+
/** The address the message says it is from. Anyone can write any address there. */
|
|
24
|
+
from: string;
|
|
25
|
+
fromName?: string;
|
|
26
|
+
to: string[];
|
|
27
|
+
cc?: string[];
|
|
28
|
+
subject: string;
|
|
29
|
+
/** When it says it was written, as an ISO time. */
|
|
30
|
+
date?: string;
|
|
31
|
+
messageId?: string;
|
|
32
|
+
text: string;
|
|
33
|
+
attachments: MailFile[];
|
|
34
|
+
}
|
|
35
|
+
/** Bytes in a character set a message names. One that nobody knows is read byte by byte. */
|
|
36
|
+
export declare function decodeText(bytes: Buffer, charset?: string): string;
|
|
37
|
+
/** A header value as it was meant: "=?utf-8?B?...?=" words decoded, raw UTF-8 read as such. */
|
|
38
|
+
export declare function decodeWords(value: string): string;
|
|
39
|
+
/** The addresses in a header such as To: or From:, with the names beside them. */
|
|
40
|
+
export declare function addresses(value: string | undefined): Array<{
|
|
41
|
+
address: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** "text/plain; charset=utf-8; name*=utf-8''a%20b" → the value and its parameters. */
|
|
45
|
+
export declare function headerParams(value: string | undefined): {
|
|
46
|
+
value: string;
|
|
47
|
+
params: Record<string, string>;
|
|
48
|
+
};
|
|
49
|
+
/** A name a file can have: no folders, nothing that is not a visible character, no dot in front. */
|
|
50
|
+
export declare function fileName(given: string | undefined, fallback: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Read a message. `raw` is what was sent, headers and body; a message that was cut off (only its
|
|
53
|
+
* first megabytes were fetched) is read as far as it goes.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseMail(raw: Buffer, limits?: MailLimits): Mail;
|
|
56
|
+
/** The types of picture a model can be shown, by what a message says a file is. */
|
|
57
|
+
export declare const PICTURES: Record<string, string>;
|
|
58
|
+
/** A file that came with a message, as an event names it: `path` is where pine put it; one without was too large to keep. */
|
|
59
|
+
export interface KeptFile {
|
|
60
|
+
file: string;
|
|
61
|
+
path?: string;
|
|
62
|
+
type: string;
|
|
63
|
+
size: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Put the files of a message into a source's own folder, each under a name pine makes (a new
|
|
67
|
+
* one every time, with the cleaned name the message gave at its end). Nothing a message says
|
|
68
|
+
* decides where a file lands, and nothing that exists is written over.
|
|
69
|
+
*/
|
|
70
|
+
export declare function keepFiles(dir: string, mail: Mail): {
|
|
71
|
+
attachments: KeptFile[];
|
|
72
|
+
images?: Array<{
|
|
73
|
+
path: string;
|
|
74
|
+
mimeType: string;
|
|
75
|
+
}>;
|
|
76
|
+
};
|
|
77
|
+
/** Delete what a source kept for longer than `keepMs`. */
|
|
78
|
+
export declare function pruneFiles(dir: string, keepMs: number): void;
|