shadok-ai 0.3.84 → 0.3.86
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/dist/channels.d.ts +10 -10
- package/dist/channels.js +10 -10
- package/dist/config.d.ts +3 -3
- package/dist/crons.d.ts +37 -37
- package/dist/crons.js +46 -45
- package/dist/crons.js.map +1 -1
- package/dist/csp.d.ts +32 -32
- package/dist/csp.js +32 -32
- package/dist/csp.js.map +1 -1
- package/dist/extract.d.ts +24 -24
- package/dist/extract.js +32 -33
- package/dist/extract.js.map +1 -1
- package/dist/net.d.ts +34 -35
- package/dist/net.js +43 -44
- package/dist/net.js.map +1 -1
- package/dist/pace.d.ts +10 -11
- package/dist/pace.js +11 -12
- package/dist/pace.js.map +1 -1
- package/dist/profiles.js +17 -16
- package/dist/profiles.js.map +1 -1
- package/dist/server.js +132 -130
- package/dist/server.js.map +1 -1
- package/dist/tail.d.ts +15 -16
- package/dist/tail.js +33 -34
- package/dist/tail.js.map +1 -1
- package/dist/telegram.d.ts +47 -49
- package/dist/telegram.js +165 -166
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/dist/channels.d.ts
CHANGED
|
@@ -128,13 +128,13 @@ export declare function saveGroups(list: any[]): void;
|
|
|
128
128
|
export declare function loadTgGroup(): number | null;
|
|
129
129
|
export declare function saveTgGroup(groupId: number | null): void;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
131
|
+
* The Telegram channels (`bindKey`) where tool calls are SHOWN. An allowlist
|
|
132
|
+
* rather than a key → boolean map: the default (hidden) costs no entry, and a
|
|
133
|
+
* missing or unreadable file degrades to exactly "everything hidden" — the
|
|
134
|
+
* intended default.
|
|
135
135
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
136
|
+
* The setting belongs to the topic, not to the session: `/new` recreates a
|
|
137
|
+
* session in the same topic and must keep the user's choice.
|
|
138
138
|
*/
|
|
139
139
|
export declare function loadTgToolKeys(): string[];
|
|
140
140
|
/** Pure core of setTgTools — returns a new list; exported for testing. */
|
|
@@ -142,10 +142,10 @@ export declare function setToolKeys(keys: string[], key: string, on: boolean): s
|
|
|
142
142
|
export declare function tgToolsEnabled(key: string): boolean;
|
|
143
143
|
export declare function setTgTools(key: string, on: boolean): void;
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* session
|
|
148
|
-
*
|
|
145
|
+
* The owner of direct messages: the Telegram id of the first user to write to
|
|
146
|
+
* the bot in a DM. Without it, a stranger who finds the bot gets a Claude
|
|
147
|
+
* session on the machine — groups were already bounded to the bound group,
|
|
148
|
+
* DMs were not.
|
|
149
149
|
*/
|
|
150
150
|
export declare function loadTgOwner(): number | null;
|
|
151
151
|
export declare function saveTgOwner(userId: number | null): void;
|
package/dist/channels.js
CHANGED
|
@@ -221,13 +221,13 @@ export function saveTgGroup(groupId) {
|
|
|
221
221
|
writeJson("telegram-group", groupId == null ? [] : [groupId]);
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
224
|
+
* The Telegram channels (`bindKey`) where tool calls are SHOWN. An allowlist
|
|
225
|
+
* rather than a key → boolean map: the default (hidden) costs no entry, and a
|
|
226
|
+
* missing or unreadable file degrades to exactly "everything hidden" — the
|
|
227
|
+
* intended default.
|
|
228
228
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
229
|
+
* The setting belongs to the topic, not to the session: `/new` recreates a
|
|
230
|
+
* session in the same topic and must keep the user's choice.
|
|
231
231
|
*/
|
|
232
232
|
export function loadTgToolKeys() {
|
|
233
233
|
return readJson("telegram-tools").filter((k) => typeof k === "string");
|
|
@@ -244,10 +244,10 @@ export function setTgTools(key, on) {
|
|
|
244
244
|
writeJson("telegram-tools", setToolKeys(loadTgToolKeys(), key, on));
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* session
|
|
250
|
-
*
|
|
247
|
+
* The owner of direct messages: the Telegram id of the first user to write to
|
|
248
|
+
* the bot in a DM. Without it, a stranger who finds the bot gets a Claude
|
|
249
|
+
* session on the machine — groups were already bounded to the bound group,
|
|
250
|
+
* DMs were not.
|
|
251
251
|
*/
|
|
252
252
|
export function loadTgOwner() {
|
|
253
253
|
const v = readJson("telegram-owner")[0];
|
package/dist/config.d.ts
CHANGED
|
@@ -42,9 +42,9 @@ export interface Config {
|
|
|
42
42
|
*/
|
|
43
43
|
permissionMode?: string;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* Default IANA time zone for `daily` crons ("Europe/Paris"). Without it the
|
|
46
|
+
* hour follows the machine's zone — so a server running UTC shifts every
|
|
47
|
+
* schedule silently. A cron can override it through its own `tz`.
|
|
48
48
|
*/
|
|
49
49
|
timezone?: string;
|
|
50
50
|
/**
|
package/dist/crons.d.ts
CHANGED
|
@@ -29,11 +29,11 @@ export interface Cron {
|
|
|
29
29
|
*/
|
|
30
30
|
check?: string;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* `cronTimeZone
|
|
36
|
-
*
|
|
32
|
+
* IANA time zone ("Europe/Paris") a `daily` schedule is read in. Without it
|
|
33
|
+
* the hour follows the MACHINE's zone: the same `daily:09:00` fires at 09:00
|
|
34
|
+
* in Paris and at 09:00 UTC on a server running UTC, i.e. 11:00 as lived.
|
|
35
|
+
* Resolved by `cronTimeZone`: this field, else the global default (config
|
|
36
|
+
* `timezone`), else the system zone — so nothing moves until it is set.
|
|
37
37
|
*/
|
|
38
38
|
tz?: string;
|
|
39
39
|
/** ms epoch of the last fire, and the next scheduled fire. */
|
|
@@ -77,27 +77,27 @@ export interface CronTarget {
|
|
|
77
77
|
*/
|
|
78
78
|
export declare function resolveCronTarget(channels: readonly Channel[], sessionId: string, fallbackCwd: string): CronTarget;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Mark carried by the TEXT of a prompt sent by a cron.
|
|
81
81
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
82
|
+
* Why in the content and not only in the protocol (`origin: "cron"`): the
|
|
83
|
+
* prompt goes through the TUI, so Claude Code writes it into the transcript
|
|
84
|
+
* like any other user message. Hiding only the direct echo left the wall of
|
|
85
|
+
* text — the prompt PLUS the guard's output, kilobytes of it — coming back on
|
|
86
|
+
* a page reload and in a Telegram topic's backfill, both of which re-read
|
|
87
|
+
* `loadHistory`.
|
|
88
88
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* Same choice as the `NOTHING TO SHOW` sentinel: a mark in the content,
|
|
90
|
+
* filtered wherever we render. It has a useful side effect — the agent learns
|
|
91
|
+
* this turn comes from a schedule, which nothing else told it.
|
|
92
92
|
*/
|
|
93
93
|
export declare const CRON_PROMPT_MARK = "\u23F0 [cron]";
|
|
94
|
-
/**
|
|
94
|
+
/** Prefix a cron's prompt. Idempotent: re-marking does not double the mark. */
|
|
95
95
|
export declare function markCronPrompt(text: string): string;
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
97
|
+
* Is this text a cron prompt? Deliberately STRICT — the mark must OPEN the
|
|
98
|
+
* message. An agent (or a human) quoting "⏰ [cron]" mid-sentence must not see
|
|
99
|
+
* its message vanish: that is the cost of an over-broad heuristic, the one
|
|
100
|
+
* invariant 2 is about.
|
|
101
101
|
*/
|
|
102
102
|
export declare function isCronPrompt(text: string): boolean;
|
|
103
103
|
/** Why a cron's delivery to its channel failed. Lives here (not in server.ts)
|
|
@@ -121,28 +121,28 @@ export declare function nextRunAfterFailure(nowMs: number, scheduledNextMs: numb
|
|
|
121
121
|
};
|
|
122
122
|
/**
|
|
123
123
|
* Next fire time (ms epoch) for a schedule, strictly after `fromMs`.
|
|
124
|
-
* `tz` (IANA)
|
|
125
|
-
*
|
|
124
|
+
* `tz` (IANA) only applies to `daily` — an interval is a duration, it has no
|
|
125
|
+
* time zone. Absent → the machine's local time (historical behaviour).
|
|
126
126
|
*/
|
|
127
127
|
export declare function nextRunFor(s: CronSchedule, fromMs: number, tz?: string | null): number;
|
|
128
|
-
/**
|
|
128
|
+
/** Is this an IANA zone identifier the bundled ICU knows? */
|
|
129
129
|
export declare function isValidTimeZone(tz: string): boolean;
|
|
130
130
|
/** Validate + normalize a raw schedule object; null if invalid. */
|
|
131
131
|
export declare function normalizeSchedule(raw: any): CronSchedule | null;
|
|
132
|
-
/**
|
|
132
|
+
/** The machine's zone — the fallback when nothing is configured. */
|
|
133
133
|
export declare function systemTimeZone(): string;
|
|
134
|
-
/**
|
|
134
|
+
/** Global default (config `timezone`), ignored unless it is a valid zone. */
|
|
135
135
|
export declare function defaultTimeZone(): string | undefined;
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
137
|
+
* A cron's effective zone: its own, else the global default, else the
|
|
138
|
+
* machine's. Setting `tz` on the config therefore fixes every existing cron at
|
|
139
|
+
* once — exactly what you want on a server running UTC.
|
|
140
140
|
*/
|
|
141
141
|
export declare function cronTimeZone(c: Pick<Cron, "tz">): string;
|
|
142
142
|
/**
|
|
143
|
-
* Human label for a schedule (UI/Telegram).
|
|
144
|
-
*
|
|
145
|
-
*
|
|
143
|
+
* Human label for a schedule (UI/Telegram). The zone is ALWAYS shown for a
|
|
144
|
+
* `daily`: it is the only way to spot a server that is not in the zone you
|
|
145
|
+
* assume (a bare "daily at 09:00" does not say 09:00 where).
|
|
146
146
|
*/
|
|
147
147
|
export declare function scheduleLabel(s: CronSchedule, tz?: string): string;
|
|
148
148
|
export declare function loadCrons(): Cron[];
|
|
@@ -159,12 +159,12 @@ export type CronLookup = {
|
|
|
159
159
|
matches: number;
|
|
160
160
|
};
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
162
|
+
* Resolve what the user typed into a full cron id.
|
|
163
163
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
164
|
+
* Every surface shows ONLY the first 8 characters of the id (the web, skill
|
|
165
|
+
* and Telegram `list`), so accepting a prefix is not a convenience: it is the
|
|
166
|
+
* only way to name a cron with what is on screen. And an empty prefix must
|
|
167
|
+
* never "match the first one" — a bare `/cron del` would delete a cron at
|
|
168
|
+
* random.
|
|
169
169
|
*/
|
|
170
170
|
export declare function resolveCronId(list: Cron[], needle: string): CronLookup;
|
package/dist/crons.js
CHANGED
|
@@ -23,29 +23,29 @@ export function resolveCronTarget(channels, sessionId, fallbackCwd) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Mark carried by the TEXT of a prompt sent by a cron.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
28
|
+
* Why in the content and not only in the protocol (`origin: "cron"`): the
|
|
29
|
+
* prompt goes through the TUI, so Claude Code writes it into the transcript
|
|
30
|
+
* like any other user message. Hiding only the direct echo left the wall of
|
|
31
|
+
* text — the prompt PLUS the guard's output, kilobytes of it — coming back on
|
|
32
|
+
* a page reload and in a Telegram topic's backfill, both of which re-read
|
|
33
|
+
* `loadHistory`.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* Same choice as the `NOTHING TO SHOW` sentinel: a mark in the content,
|
|
36
|
+
* filtered wherever we render. It has a useful side effect — the agent learns
|
|
37
|
+
* this turn comes from a schedule, which nothing else told it.
|
|
38
38
|
*/
|
|
39
39
|
export const CRON_PROMPT_MARK = "⏰ [cron]";
|
|
40
|
-
/**
|
|
40
|
+
/** Prefix a cron's prompt. Idempotent: re-marking does not double the mark. */
|
|
41
41
|
export function markCronPrompt(text) {
|
|
42
42
|
return isCronPrompt(text) ? text : `${CRON_PROMPT_MARK} ${text}`;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
45
|
+
* Is this text a cron prompt? Deliberately STRICT — the mark must OPEN the
|
|
46
|
+
* message. An agent (or a human) quoting "⏰ [cron]" mid-sentence must not see
|
|
47
|
+
* its message vanish: that is the cost of an over-broad heuristic, the one
|
|
48
|
+
* invariant 2 is about.
|
|
49
49
|
*/
|
|
50
50
|
export function isCronPrompt(text) {
|
|
51
51
|
return typeof text === "string" && text.trimStart().startsWith(CRON_PROMPT_MARK);
|
|
@@ -84,8 +84,8 @@ export function nextRunAfterFailure(nowMs, scheduledNextMs, attempts) {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Next fire time (ms epoch) for a schedule, strictly after `fromMs`.
|
|
87
|
-
* `tz` (IANA)
|
|
88
|
-
*
|
|
87
|
+
* `tz` (IANA) only applies to `daily` — an interval is a duration, it has no
|
|
88
|
+
* time zone. Absent → the machine's local time (historical behaviour).
|
|
89
89
|
*/
|
|
90
90
|
export function nextRunFor(s, fromMs, tz) {
|
|
91
91
|
if (s.kind === "interval") {
|
|
@@ -93,8 +93,8 @@ export function nextRunFor(s, fromMs, tz) {
|
|
|
93
93
|
return fromMs + step;
|
|
94
94
|
}
|
|
95
95
|
if (!tz || !isValidTimeZone(tz)) {
|
|
96
|
-
//
|
|
97
|
-
//
|
|
96
|
+
// Machine zone. `setHours` on a local Date follows daylight-saving shifts
|
|
97
|
+
// on its own (09:00 stays 09:00), which is why this path is kept as is.
|
|
98
98
|
const next = new Date(fromMs);
|
|
99
99
|
next.setHours(s.hour, s.minute, 0, 0);
|
|
100
100
|
if (next.getTime() <= fromMs)
|
|
@@ -104,14 +104,14 @@ export function nextRunFor(s, fromMs, tz) {
|
|
|
104
104
|
const today = calendarDayIn(tz, fromMs);
|
|
105
105
|
let t = instantOfWallClock(tz, today.y, today.mo, today.d, s.hour, s.minute);
|
|
106
106
|
if (t <= fromMs) {
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// Next CALENDAR day (not +24h: a daylight-saving switch day lasts 23 or
|
|
108
|
+
// 25 hours, and the schedule must stay at HH:MM).
|
|
109
109
|
const nd = new Date(Date.UTC(today.y, today.mo - 1, today.d) + 86_400_000);
|
|
110
110
|
t = instantOfWallClock(tz, nd.getUTCFullYear(), nd.getUTCMonth() + 1, nd.getUTCDate(), s.hour, s.minute);
|
|
111
111
|
}
|
|
112
112
|
return t;
|
|
113
113
|
}
|
|
114
|
-
/**
|
|
114
|
+
/** Is this an IANA zone identifier the bundled ICU knows? */
|
|
115
115
|
export function isValidTimeZone(tz) {
|
|
116
116
|
if (!tz || typeof tz !== "string")
|
|
117
117
|
return false;
|
|
@@ -123,7 +123,7 @@ export function isValidTimeZone(tz) {
|
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
/**
|
|
126
|
+
/** Wall-clock fields of an instant, read in `tz`. */
|
|
127
127
|
function wallClockIn(tz, atMs) {
|
|
128
128
|
const parts = new Intl.DateTimeFormat("en-US", {
|
|
129
129
|
timeZone: tz,
|
|
@@ -139,22 +139,23 @@ function wallClockIn(tz, atMs) {
|
|
|
139
139
|
for (const p of parts)
|
|
140
140
|
if (p.type !== "literal")
|
|
141
141
|
out[p.type] = Number(p.value);
|
|
142
|
-
//
|
|
142
|
+
// Some ICU versions render hour "24" at midnight in the h23 cycle.
|
|
143
143
|
out.hour = out.hour % 24;
|
|
144
144
|
return out;
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
146
|
+
/** Calendar date (y/mo/d) as lived in `tz` at that instant. */
|
|
147
147
|
function calendarDayIn(tz, atMs) {
|
|
148
148
|
const w = wallClockIn(tz, atMs);
|
|
149
149
|
return { y: w.year, mo: w.month, d: w.day };
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* Instant (ms epoch)
|
|
152
|
+
* Instant (ms epoch) at which `tz`'s wall clock reads that date/time.
|
|
153
153
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
154
|
+
* Two passes: the offset from UTC depends on the very instant we are looking
|
|
155
|
+
* for, which we only know once the offset is applied. The first pass gives a
|
|
156
|
+
* candidate, the second re-reads the REAL offset at that candidate — which
|
|
157
|
+
* fixes daylight-saving switches (a single pass was an hour off on both
|
|
158
|
+
* changeover days).
|
|
158
159
|
*/
|
|
159
160
|
function instantOfWallClock(tz, y, mo, d, h, mi) {
|
|
160
161
|
const naive = Date.UTC(y, mo - 1, d, h, mi, 0, 0);
|
|
@@ -183,7 +184,7 @@ export function normalizeSchedule(raw) {
|
|
|
183
184
|
}
|
|
184
185
|
return null;
|
|
185
186
|
}
|
|
186
|
-
/**
|
|
187
|
+
/** The machine's zone — the fallback when nothing is configured. */
|
|
187
188
|
export function systemTimeZone() {
|
|
188
189
|
try {
|
|
189
190
|
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
@@ -192,16 +193,16 @@ export function systemTimeZone() {
|
|
|
192
193
|
return "UTC";
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
|
-
/**
|
|
196
|
+
/** Global default (config `timezone`), ignored unless it is a valid zone. */
|
|
196
197
|
export function defaultTimeZone() {
|
|
197
198
|
const raw = loadConfig().timezone;
|
|
198
199
|
const tz = typeof raw === "string" ? raw.trim() : "";
|
|
199
200
|
return tz && isValidTimeZone(tz) ? tz : undefined;
|
|
200
201
|
}
|
|
201
202
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
203
|
+
* A cron's effective zone: its own, else the global default, else the
|
|
204
|
+
* machine's. Setting `tz` on the config therefore fixes every existing cron at
|
|
205
|
+
* once — exactly what you want on a server running UTC.
|
|
205
206
|
*/
|
|
206
207
|
export function cronTimeZone(c) {
|
|
207
208
|
if (c.tz && isValidTimeZone(c.tz))
|
|
@@ -209,9 +210,9 @@ export function cronTimeZone(c) {
|
|
|
209
210
|
return defaultTimeZone() ?? systemTimeZone();
|
|
210
211
|
}
|
|
211
212
|
/**
|
|
212
|
-
* Human label for a schedule (UI/Telegram).
|
|
213
|
-
*
|
|
214
|
-
*
|
|
213
|
+
* Human label for a schedule (UI/Telegram). The zone is ALWAYS shown for a
|
|
214
|
+
* `daily`: it is the only way to spot a server that is not in the zone you
|
|
215
|
+
* assume (a bare "daily at 09:00" does not say 09:00 where).
|
|
215
216
|
*/
|
|
216
217
|
export function scheduleLabel(s, tz) {
|
|
217
218
|
if (s.kind === "interval") {
|
|
@@ -255,19 +256,19 @@ export function removeCron(id) {
|
|
|
255
256
|
saveCrons(loadCrons().filter((c) => c.id !== id));
|
|
256
257
|
}
|
|
257
258
|
/**
|
|
258
|
-
*
|
|
259
|
+
* Resolve what the user typed into a full cron id.
|
|
259
260
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
261
|
+
* Every surface shows ONLY the first 8 characters of the id (the web, skill
|
|
262
|
+
* and Telegram `list`), so accepting a prefix is not a convenience: it is the
|
|
263
|
+
* only way to name a cron with what is on screen. And an empty prefix must
|
|
264
|
+
* never "match the first one" — a bare `/cron del` would delete a cron at
|
|
265
|
+
* random.
|
|
265
266
|
*/
|
|
266
267
|
export function resolveCronId(list, needle) {
|
|
267
268
|
const n = (needle ?? "").trim();
|
|
268
269
|
if (!n)
|
|
269
270
|
return { ok: false, error: "empty", matches: 0 };
|
|
270
|
-
//
|
|
271
|
+
// A full id always wins, even when it is also the prefix of another.
|
|
271
272
|
if (list.some((c) => c.id === n))
|
|
272
273
|
return { ok: true, id: n };
|
|
273
274
|
const hits = list.filter((c) => c.id.startsWith(n));
|
package/dist/crons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAA4B,EAC5B,SAAiB,EACjB,WAAmB;IAEnB,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAC3D,OAAO;QACL,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,WAAW;QACnC,OAAO,EAAE,EAAE,EAAE,OAAO,IAAI,IAAI;QAC5B,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,IAAI;QAC1B,IAAI,EAAE,EAAE,EAAE,IAAI,IAAI,IAAI;QACtB,KAAK,EAAE,CAAC,CAAC,EAAE;KACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../src/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAA4B,EAC5B,SAAiB,EACjB,WAAmB;IAEnB,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK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MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACpF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/csp.d.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The cockpit's Content-Security-Policy, and the nonce injection into the page.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* page
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* Why a CSP here: the transcript renders **Markdown produced by the agent**,
|
|
5
|
+
* i.e. content derived from what the agent read (a file in a cloned repo, a web
|
|
6
|
+
* page, a Telegram message). `marked` lets raw HTML through. With no guard, an
|
|
7
|
+
* `<img onerror=…>` planted in a README runs inside the cockpit — which can
|
|
8
|
+
* create a cron, hence run a shell command. Sanitising (DOMPurify, client-side)
|
|
9
|
+
* is the first barrier; the CSP is the one that still holds when the sanitiser
|
|
10
|
+
* has a hole.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Everything here is pure; the wiring lives in server.ts.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Marker hardcoded in `public/index.html`, replaced by the real nonce on every
|
|
16
|
+
* request.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
* A literal string replacement, not a tag rewrite: we want neither to parse
|
|
19
|
+
* HTML nor to risk "nonce-ing" a `<script` that happens to sit inside a
|
|
20
|
+
* JavaScript string. As a bonus the marker makes the requirement visible in the
|
|
21
|
+
* source — a future script block without it will not run, which shows up
|
|
22
|
+
* immediately.
|
|
23
23
|
*/
|
|
24
24
|
export declare const NONCE_PLACEHOLDER = "__CSP_NONCE__";
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* The policy served with every page.
|
|
27
27
|
*
|
|
28
|
-
* - `script-src
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* - `style-src`
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* - `img-src`
|
|
37
|
-
* notification
|
|
38
|
-
* - `connect-src 'self'`
|
|
39
|
-
* `ws://`
|
|
40
|
-
* - `base-uri`/`object-src`/`frame-ancestors`
|
|
41
|
-
*
|
|
28
|
+
* - `script-src`: **no `unsafe-inline`**. That is the directive that matters —
|
|
29
|
+
* it neutralises `<img onerror>`, injected `<script>` and `javascript:`. The
|
|
30
|
+
* page's two inline blocks carry the nonce; injected HTML cannot guess it (it
|
|
31
|
+
* is drawn afresh on every request).
|
|
32
|
+
* - `style-src` keeps `unsafe-inline`: the page has one large inline stylesheet
|
|
33
|
+
* and `style=` attributes all over. The nonce does not cover attributes, so
|
|
34
|
+
* requiring it would mean rewriting the whole client for little gain — style
|
|
35
|
+
* injection alone does not give code execution.
|
|
36
|
+
* - `img-src` allows `data:`: the favicon is an SVG data-URI, and the
|
|
37
|
+
* notification pip rewrites it on the fly.
|
|
38
|
+
* - `connect-src 'self'` covers the WebSocket: `'self'` also applies to a
|
|
39
|
+
* `ws://` on the same host and port.
|
|
40
|
+
* - `base-uri`/`object-src`/`frame-ancestors` at `none`: nothing to rewrite,
|
|
41
|
+
* nothing to embed, and no clickjacking on a UI that drives agents.
|
|
42
42
|
*/
|
|
43
43
|
export declare function cspHeader(nonce: string): string;
|
|
44
|
-
/**
|
|
44
|
+
/** Replace every marker with this request's nonce. */
|
|
45
45
|
export declare function injectNonce(html: string, nonce: string): string;
|