@pmndre/pine 0.22.1 → 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/watching.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type Agent } from "undici";
|
|
2
|
+
import type { SourceApi } from "./sources.ts";
|
|
1
3
|
export declare const clip: (s: string, n?: number) => string;
|
|
2
4
|
/** A value as an event carries it: text and large structures cut to a sensible length. */
|
|
3
5
|
export declare function shown(value: unknown): unknown;
|
|
@@ -18,3 +20,157 @@ export declare function lineDiff(before: string, now: string): {
|
|
|
18
20
|
};
|
|
19
21
|
/** What a reader of a web page sees, line by line: no scripts, no styles, no markup. */
|
|
20
22
|
export declare function pageText(html: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* A cap for a source that is told things rather than looking: at most `perMinute` reports in any
|
|
25
|
+
* minute. What comes on top is dropped and counted, so that a device or a service that talks all
|
|
26
|
+
* day fills neither the event log nor a conversation. `dropped()` says how many were left out
|
|
27
|
+
* since it was last asked, for the next report to carry.
|
|
28
|
+
*/
|
|
29
|
+
export declare function capped(perMinute: number): {
|
|
30
|
+
ok(): boolean;
|
|
31
|
+
dropped(): number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The number a value stands for, if it reads as a number or an amount and nothing else:
|
|
35
|
+
* 12.5, "87 %", "$1,299.00", "1.299,00 €", "-3,5 °C". A text with more to it than a sign, a unit
|
|
36
|
+
* or a currency is not one, and neither is a version (1.2.3), a date or a time.
|
|
37
|
+
*
|
|
38
|
+
* Two separators: the last one is the decimal point. One kind several times: thousands. One
|
|
39
|
+
* separator once is the hard case. Followed by one, two, or more than three digits it is a decimal
|
|
40
|
+
* point. Followed by exactly three it could be either, and then the rest of the text decides: next
|
|
41
|
+
* to a continental currency (€, zł, kr, Kč) a dot groups thousands and a comma is the decimal
|
|
42
|
+
* point; anywhere else it is the other way round, as a program writes numbers.
|
|
43
|
+
*/
|
|
44
|
+
export declare function numberOf(value: unknown): number | undefined;
|
|
45
|
+
/** `number` and `previousNumber` for an event, where the value now or the one before reads as a number. */
|
|
46
|
+
export declare function numbers(value: unknown, previous: unknown): {
|
|
47
|
+
number?: number;
|
|
48
|
+
previousNumber?: number;
|
|
49
|
+
};
|
|
50
|
+
/** A text with its character references (&, €, A) written out. */
|
|
51
|
+
export declare const unescaped: (s: string) => string;
|
|
52
|
+
interface Simple {
|
|
53
|
+
tag?: string;
|
|
54
|
+
id?: string;
|
|
55
|
+
classes: string[];
|
|
56
|
+
attrs: Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
op?: string;
|
|
59
|
+
value?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/** One selector: its parts from left to right, each with how it hangs on the one before (" " inside it, ">" directly inside it). */
|
|
63
|
+
type Chain = Array<{
|
|
64
|
+
part: Simple;
|
|
65
|
+
how: " " | ">";
|
|
66
|
+
}>;
|
|
67
|
+
/** A CSS selector as this file can read it, or an error that says what it takes. */
|
|
68
|
+
export declare function selector(source: string): Chain[];
|
|
69
|
+
/**
|
|
70
|
+
* What the first element of a page that a selector matches says to a reader: its text, or with
|
|
71
|
+
* `attr` the value of that attribute (a price in a meta tag, a data- attribute). Nothing matched is null.
|
|
72
|
+
*/
|
|
73
|
+
export declare function selected(html: string, chains: Chain[], attr?: string): string | null;
|
|
74
|
+
/** How long one look at an address may take. */
|
|
75
|
+
export declare const LOOK_TIMEOUT = 20000;
|
|
76
|
+
/** Headers that carry a secret. Those go into `token`, which is kept out of the configuration. */
|
|
77
|
+
export declare const SECRET_HEADERS: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Whether an address says by itself that it is on this computer or the local network. Such an
|
|
80
|
+
* address the owner confirmed as what it is. Any other one must stay on the public internet: a
|
|
81
|
+
* name that one day points into the local network is not followed there.
|
|
82
|
+
*/
|
|
83
|
+
export declare const isLocalAddress: (url: URL) => boolean;
|
|
84
|
+
/** Why a look failed, in words: what lies behind "fetch failed". */
|
|
85
|
+
export declare const whyFailed: (e: unknown, url: URL) => string;
|
|
86
|
+
/** The connections an address is asked over: as they are for a local one, kept on the public internet for any other. */
|
|
87
|
+
export declare const guardFor: (url: URL, local: unknown) => Agent | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* What every type that asks a web address checks when it is set up: that it is one, that nothing
|
|
90
|
+
* secret is written into it or into a header, and how often it may be asked. Returns the address.
|
|
91
|
+
*/
|
|
92
|
+
export declare function askable(o: Record<string, any>, least: string, usual: string): {
|
|
93
|
+
url: URL;
|
|
94
|
+
every: string;
|
|
95
|
+
local: boolean;
|
|
96
|
+
};
|
|
97
|
+
/** What is sent along with a look. */
|
|
98
|
+
export interface Asking {
|
|
99
|
+
headers?: Record<string, string>;
|
|
100
|
+
token?: string;
|
|
101
|
+
tokenHeader?: string;
|
|
102
|
+
/** "GET", or "POST" with `body`. */
|
|
103
|
+
method?: string;
|
|
104
|
+
body?: string;
|
|
105
|
+
/** What kind of answer is wanted, where `headers` does not say. */
|
|
106
|
+
accept?: string;
|
|
107
|
+
}
|
|
108
|
+
/** What an address said about its last answer, to ask "anything new since?" the next time. */
|
|
109
|
+
export interface Since {
|
|
110
|
+
etag?: string;
|
|
111
|
+
modified?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface Answer extends Since {
|
|
114
|
+
type: string;
|
|
115
|
+
body: string;
|
|
116
|
+
/** It answered that nothing is new since the answer `since` came from (304). There is no body then. */
|
|
117
|
+
unchanged?: boolean;
|
|
118
|
+
/** The answer was longer than what is read of one. */
|
|
119
|
+
truncated?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* One look: the answer's text, at most `maxBody` of it (1 MB). A redirect is followed only on the
|
|
123
|
+
* same host. With `since`, an address that has nothing new says so in one line instead of
|
|
124
|
+
* sending everything again.
|
|
125
|
+
*/
|
|
126
|
+
export declare function ask(start: URL, o: Asking, guard: Agent | undefined, signal: AbortSignal, since?: Since, maxBody?: number): Promise<Answer>;
|
|
127
|
+
/**
|
|
128
|
+
* What the address said about the answer a source last worked through, for the next look to ask
|
|
129
|
+
* with. `about` names what the source makes of an answer (the address, what it watches in it): a
|
|
130
|
+
* source that was set up anew for something else starts from a full answer.
|
|
131
|
+
*/
|
|
132
|
+
export declare function sinceOf(source: SourceApi, about: unknown): Since | undefined;
|
|
133
|
+
/** Remember what an answer said about itself, once the source has worked it through: a look that failed half way is made in full again. */
|
|
134
|
+
export declare function keepSince(source: SourceApi, about: unknown, answer: Since): void;
|
|
135
|
+
/** How long one look with the browser may take: starting it, loading the page, waiting for it to be quiet. */
|
|
136
|
+
export declare const RENDER_TIMEOUT = 45000;
|
|
137
|
+
/**
|
|
138
|
+
* For tests: a program that speaks the one-line protocol of the helper (mcp/render.ts) in its
|
|
139
|
+
* place, so that a rendered look can be tried without a browser, and a shorter time limit. Not an
|
|
140
|
+
* option of a source: a source's options are what an agent may set, and which program the daemon
|
|
141
|
+
* runs is not among them.
|
|
142
|
+
*/
|
|
143
|
+
export declare const rendering: {
|
|
144
|
+
program?: string[];
|
|
145
|
+
timeoutMs?: number;
|
|
146
|
+
};
|
|
147
|
+
/** What a rendered look is told: the address, what to take from the page, and where the one local address that is allowed is written. */
|
|
148
|
+
export interface RenderJob {
|
|
149
|
+
url: string;
|
|
150
|
+
select?: string;
|
|
151
|
+
attr?: string;
|
|
152
|
+
/** A file in pine's data with the local "host:port" the owner confirmed, as the browser's guard reads it. */
|
|
153
|
+
localFile?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface Rendered {
|
|
156
|
+
/** What a reader of the page sees, line by line. Without `select`. */
|
|
157
|
+
text?: string;
|
|
158
|
+
/** With `select`: the text of the first element it matches, or the attribute. Nothing matched is null. */
|
|
159
|
+
value?: string | null;
|
|
160
|
+
/** The address the browser was on when it read the page. */
|
|
161
|
+
final: string;
|
|
162
|
+
}
|
|
163
|
+
/** Whether the address a look ended on is the one that was confirmed: the same host, and the same port unless http became https. */
|
|
164
|
+
export declare function sameSite(start: URL, end: URL): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* One look at a page with the browser pine ships: the page is loaded without a window, its
|
|
167
|
+
* scripts run, and what a reader sees then is handed back. The browser runs in a helper program
|
|
168
|
+
* (mcp/render.ts) that is started for this look and gone after it, whatever happens: an answer,
|
|
169
|
+
* no answer within the time limit, or the source stopping.
|
|
170
|
+
*
|
|
171
|
+
* `dir` is the source's own folder in pine's data. The helper works in a folder inside it, which
|
|
172
|
+
* is emptied afterwards. It gets no part of the daemon's environment, one line with the job, and
|
|
173
|
+
* is read one line of answer from, of bounded length. Throws with a sentence when the look failed.
|
|
174
|
+
*/
|
|
175
|
+
export declare function rendered(job: RenderJob, dir: string, signal: AbortSignal): Promise<Rendered>;
|
|
176
|
+
export {};
|