wherever-dev 0.21.0 → 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.
- package/CHANGELOG.md +26 -0
- package/dist/assistant-channels.d.ts +242 -0
- package/dist/assistant-channels.d.ts.map +1 -0
- package/dist/assistant-channels.js +270 -0
- package/dist/assistant-channels.js.map +1 -0
- package/dist/assistant-controller.d.ts +228 -0
- package/dist/assistant-controller.d.ts.map +1 -0
- package/dist/assistant-controller.js +314 -0
- package/dist/assistant-controller.js.map +1 -0
- package/dist/assistant-cron.d.ts +87 -0
- package/dist/assistant-cron.d.ts.map +1 -0
- package/dist/assistant-cron.js +352 -0
- package/dist/assistant-cron.js.map +1 -0
- package/dist/assistant-folder.d.ts +161 -0
- package/dist/assistant-folder.d.ts.map +1 -0
- package/dist/assistant-folder.js +333 -0
- package/dist/assistant-folder.js.map +1 -0
- package/dist/assistant-schedule.d.ts +236 -0
- package/dist/assistant-schedule.d.ts.map +1 -0
- package/dist/assistant-schedule.js +454 -0
- package/dist/assistant-schedule.js.map +1 -0
- package/dist/assistant-scheduler.d.ts +210 -0
- package/dist/assistant-scheduler.d.ts.map +1 -0
- package/dist/assistant-scheduler.js +472 -0
- package/dist/assistant-scheduler.js.map +1 -0
- package/dist/assistant-tool-text.d.ts +40 -0
- package/dist/assistant-tool-text.d.ts.map +1 -0
- package/dist/assistant-tool-text.js +102 -0
- package/dist/assistant-tool-text.js.map +1 -0
- package/dist/assistant-tools.d.ts +207 -0
- package/dist/assistant-tools.d.ts.map +1 -0
- package/dist/assistant-tools.js +390 -0
- package/dist/assistant-tools.js.map +1 -0
- package/dist/attach-file-tool.d.ts +20 -1
- package/dist/attach-file-tool.d.ts.map +1 -1
- package/dist/attach-file-tool.js +45 -3
- package/dist/attach-file-tool.js.map +1 -1
- package/dist/cli-requests.d.ts +90 -0
- package/dist/cli-requests.d.ts.map +1 -0
- package/dist/cli-requests.js +75 -0
- package/dist/cli-requests.js.map +1 -0
- package/dist/download-grants.d.ts +12 -0
- package/dist/download-grants.d.ts.map +1 -0
- package/dist/download-grants.js +76 -0
- package/dist/download-grants.js.map +1 -0
- package/dist/index.js +431 -20
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +43 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/reply-routing.d.ts +106 -0
- package/dist/reply-routing.d.ts.map +1 -0
- package/dist/reply-routing.js +174 -0
- package/dist/reply-routing.js.map +1 -0
- package/dist/session-pool.d.ts +243 -4
- package/dist/session-pool.d.ts.map +1 -1
- package/dist/session-pool.js +464 -100
- package/dist/session-pool.js.map +1 -1
- package/dist/telegram-channel.d.ts +272 -0
- package/dist/telegram-channel.d.ts.map +1 -0
- package/dist/telegram-channel.js +701 -0
- package/dist/telegram-channel.js.map +1 -0
- package/dist/telegram-files.d.ts +101 -0
- package/dist/telegram-files.d.ts.map +1 -0
- package/dist/telegram-files.js +145 -0
- package/dist/telegram-files.js.map +1 -0
- package/dist/telegram-pairing.d.ts +119 -0
- package/dist/telegram-pairing.d.ts.map +1 -0
- package/dist/telegram-pairing.js +97 -0
- package/dist/telegram-pairing.js.map +1 -0
- package/dist/telegram-replies.d.ts +94 -0
- package/dist/telegram-replies.d.ts.map +1 -0
- package/dist/telegram-replies.js +329 -0
- package/dist/telegram-replies.js.map +1 -0
- package/dist/telegram-token.d.ts +55 -0
- package/dist/telegram-token.d.ts.map +1 -0
- package/dist/telegram-token.js +86 -0
- package/dist/telegram-token.js.map +1 -0
- package/dist/web-push.d.ts +167 -0
- package/dist/web-push.d.ts.map +1 -0
- package/dist/web-push.js +387 -0
- package/dist/web-push.js.map +1 -0
- package/package.json +1 -1
- package/public/_app/immutable/assets/0.BkzT3rFr.css +1 -0
- package/public/_app/immutable/chunks/CExVgK9Z.js +2 -0
- package/public/_app/immutable/chunks/CExVgK9Z.js.map +1 -0
- package/public/_app/immutable/chunks/CkOw6fRa.js +2 -0
- package/public/_app/immutable/chunks/{idnZrCTB.js.map → CkOw6fRa.js.map} +1 -1
- package/public/_app/immutable/chunks/DyHllYtq.js +2 -0
- package/public/_app/immutable/chunks/{DJMI34rR.js.map → DyHllYtq.js.map} +1 -1
- package/public/_app/immutable/entry/{app.CF_gzWKW.js → app.D3PEFbtP.js} +3 -3
- package/public/_app/immutable/entry/{app.CF_gzWKW.js.map → app.D3PEFbtP.js.map} +1 -1
- package/public/_app/immutable/entry/start.BR00Qps5.js +2 -0
- package/public/_app/immutable/entry/start.BR00Qps5.js.map +1 -0
- package/public/_app/immutable/nodes/{0.CIIhZFWl.js → 0.DG3L8hMN.js} +3 -3
- package/public/_app/immutable/nodes/{0.CIIhZFWl.js.map → 0.DG3L8hMN.js.map} +1 -1
- package/public/_app/immutable/nodes/{1.D4WVeMej.js → 1.BCpuoZxW.js} +2 -2
- package/public/_app/immutable/nodes/{1.D4WVeMej.js.map → 1.BCpuoZxW.js.map} +1 -1
- package/public/_app/immutable/nodes/2.D2auiZW1.js +122 -0
- package/public/_app/immutable/nodes/2.D2auiZW1.js.map +1 -0
- package/public/_app/version.json +1 -1
- package/public/index.html +11 -11
- package/public/service-worker.js +1 -1
- package/public/_app/immutable/assets/0.BKJ49K71.css +0 -1
- package/public/_app/immutable/chunks/CkzyFwPn.js +0 -2
- package/public/_app/immutable/chunks/CkzyFwPn.js.map +0 -1
- package/public/_app/immutable/chunks/DJMI34rR.js +0 -2
- package/public/_app/immutable/chunks/idnZrCTB.js +0 -2
- package/public/_app/immutable/entry/start.GpPJ13Gr.js +0 -2
- package/public/_app/immutable/entry/start.GpPJ13Gr.js.map +0 -1
- package/public/_app/immutable/nodes/2._KcrsFWH.js +0 -120
- package/public/_app/immutable/nodes/2._KcrsFWH.js.map +0 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
/** Lock file name, inside the assistant folder (ADR 0018: NOT in the state dir). */
|
|
6
|
+
export const ASSISTANT_LOCK_FILE = '.assistant.lock';
|
|
7
|
+
export const ASSISTANT_AGENTS_MD = `# Assistant
|
|
8
|
+
|
|
9
|
+
You are a long-lived general assistant. This folder is your home and your memory.
|
|
10
|
+
|
|
11
|
+
## Memory
|
|
12
|
+
|
|
13
|
+
This session may be reset at any time, and a fresh session remembers nothing of this one. So save anything worth keeping into files here AS YOU GO, not at the end: \`memory/\` (one file per topic), \`profile.md\` (who the user is, their preferences), and whatever else helps. At the start of a fresh session, read them before answering.
|
|
14
|
+
|
|
15
|
+
## Time
|
|
16
|
+
|
|
17
|
+
Use the \`assistant_schedule_*\` tools for anything time-based (reminders, recurring briefings, "check X later"). Leave \`tz\` unset so the job follows the user wherever they are; set \`tz\` only for things pinned to a place ("6pm her time"). When the user tells you where they are, call \`assistant_set_timezone\`.
|
|
18
|
+
|
|
19
|
+
## Delegate
|
|
20
|
+
|
|
21
|
+
Do not block the conversation on long or slow work. DELEGATE it to an isolated job (\`at: "now"\`) that notifies the user when it is done. Anything possibly urgent must be an isolated job too, so it never waits behind a conversation.
|
|
22
|
+
|
|
23
|
+
## Talking to the user
|
|
24
|
+
|
|
25
|
+
The user hears from you ONLY through your replies and \`assistant_notify\`. A turn that starts with \`[schedule:...]\` is a scheduled job, not the user talking: if the user should hear about its outcome, call \`assistant_notify\`.
|
|
26
|
+
|
|
27
|
+
If a \`recall_search\` tool is available, use it to find what was said in earlier sessions rather than asking the user to repeat themselves.
|
|
28
|
+
`;
|
|
29
|
+
export const ASSISTANT_JOBS_AGENTS_MD = `# Assistant job
|
|
30
|
+
|
|
31
|
+
You are an isolated job run by the assistant. Do the task you were given. Save anything worth keeping under \`../memory/\`. If the user should know the result, call \`assistant_notify\`. Do not start conversations: nobody is reading this session.
|
|
32
|
+
`;
|
|
33
|
+
export const ASSISTANT_GITIGNORE = `# Runtime lock held by the wherever server using this folder.
|
|
34
|
+
${ASSISTANT_LOCK_FILE}
|
|
35
|
+
`;
|
|
36
|
+
/** The seed files, relative to the assistant folder. Each is written only if missing. */
|
|
37
|
+
const SEED_FILES = [
|
|
38
|
+
['AGENTS.md', ASSISTANT_AGENTS_MD],
|
|
39
|
+
[path.join('jobs', 'AGENTS.md'), ASSISTANT_JOBS_AGENTS_MD],
|
|
40
|
+
['.gitignore', ASSISTANT_GITIGNORE],
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* The configured assistant folder, tilde-expanded and absolute, or null when the
|
|
44
|
+
* feature is off (unset, empty or whitespace).
|
|
45
|
+
*/
|
|
46
|
+
export function resolveAssistantFolder(config) {
|
|
47
|
+
const raw = typeof config.assistantFolder === 'string' ? config.assistantFolder.trim() : '';
|
|
48
|
+
if (!raw)
|
|
49
|
+
return null;
|
|
50
|
+
const expanded = raw === '~' || raw.startsWith('~/') ? path.join(os.homedir(), raw.slice(1)) : raw;
|
|
51
|
+
return path.resolve(expanded);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create the folder if missing and drop each seed file that does not exist yet.
|
|
55
|
+
* NEVER overwrites: the folder is the user's (and the agent's) to edit. Throws on
|
|
56
|
+
* a real I/O failure (e.g. an unwritable parent); callers decide how loud to be.
|
|
57
|
+
* Returns the seed files it actually wrote.
|
|
58
|
+
*/
|
|
59
|
+
export function seedAssistantFolder(folder) {
|
|
60
|
+
fs.mkdirSync(folder, { recursive: true });
|
|
61
|
+
const written = [];
|
|
62
|
+
for (const [rel, content] of SEED_FILES) {
|
|
63
|
+
const full = path.join(folder, rel);
|
|
64
|
+
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
65
|
+
try {
|
|
66
|
+
// 'wx' = create-only, so a file appearing between a check and the write is
|
|
67
|
+
// never clobbered.
|
|
68
|
+
fs.writeFileSync(full, content, { encoding: 'utf8', flag: 'wx' });
|
|
69
|
+
written.push(rel);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (err.code !== 'EEXIST')
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return written;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The `createNewSession` hook, beside `maybeSeedSearchWorkspace`: if `resolvedCwd`
|
|
80
|
+
* IS the assistant folder, re-seed any missing file (self-healing when the user
|
|
81
|
+
* deleted one). `assistantFolder` is the server's START-TIME assistant folder,
|
|
82
|
+
* and only when this server holds the lock (undefined otherwise), so session
|
|
83
|
+
* creation is unchanged with the feature off and a refused server never writes
|
|
84
|
+
* into a folder another server owns. Best-effort: never throws.
|
|
85
|
+
*/
|
|
86
|
+
export function maybeSeedAssistantSession(resolvedCwd, assistantFolder) {
|
|
87
|
+
if (!assistantFolder)
|
|
88
|
+
return;
|
|
89
|
+
if (path.resolve(resolvedCwd) !== path.resolve(assistantFolder))
|
|
90
|
+
return;
|
|
91
|
+
try {
|
|
92
|
+
const written = seedAssistantFolder(assistantFolder);
|
|
93
|
+
if (written.length > 0)
|
|
94
|
+
console.log(`[wherever] assistant: seeded ${written.join(', ')} in ${assistantFolder}`);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
console.error(`[wherever] assistant: failed to seed ${assistantFolder}:`, err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The PURE lock decision. `existing` is the parsed lock (null = no lock file,
|
|
102
|
+
* 'corrupt' = present but unparseable). `probe` describes `existing.pid` as seen
|
|
103
|
+
* from THIS host (ignored for a foreign host).
|
|
104
|
+
*
|
|
105
|
+
* - Another HOST: never taken over. We cannot see its processes, and a shared
|
|
106
|
+
* (synced / network) folder is exactly where two servers collide; the human
|
|
107
|
+
* removes the file by hand.
|
|
108
|
+
* - Same host, stale when ANY of: the boot id differs (both known), the pid is
|
|
109
|
+
* dead, or the pid is alive but its start time differs (both known: the pid was
|
|
110
|
+
* reused by an unrelated process). Otherwise it is live and refused.
|
|
111
|
+
* - A corrupt file is taken over: a crash mid-write is the likeliest cause, and
|
|
112
|
+
* refusing would wedge the assistant behind a file nobody can attribute.
|
|
113
|
+
*/
|
|
114
|
+
export function decideAssistantLock(existing, self, probe) {
|
|
115
|
+
if (existing === null)
|
|
116
|
+
return { action: 'take', reason: 'free' };
|
|
117
|
+
if (existing === 'corrupt')
|
|
118
|
+
return { action: 'takeover', reason: 'corrupt' };
|
|
119
|
+
if (existing.host !== self.host)
|
|
120
|
+
return { action: 'refuse', reason: 'foreign-host' };
|
|
121
|
+
if (existing.bootId && self.bootId && existing.bootId !== self.bootId) {
|
|
122
|
+
return { action: 'takeover', reason: 'other-boot' };
|
|
123
|
+
}
|
|
124
|
+
if (!probe.alive)
|
|
125
|
+
return { action: 'takeover', reason: 'dead-pid' };
|
|
126
|
+
if (existing.startTime && probe.startTime && existing.startTime !== probe.startTime) {
|
|
127
|
+
return { action: 'takeover', reason: 'pid-reused' };
|
|
128
|
+
}
|
|
129
|
+
if (existing.pid === self.pid)
|
|
130
|
+
return { action: 'take', reason: 'own' };
|
|
131
|
+
return { action: 'refuse', reason: 'live-lock' };
|
|
132
|
+
}
|
|
133
|
+
// --- thin platform probes --------------------------------------------------
|
|
134
|
+
/** The current boot's id, or null where unsupported. Never throws. */
|
|
135
|
+
export function readBootId() {
|
|
136
|
+
try {
|
|
137
|
+
if (process.platform === 'linux') {
|
|
138
|
+
return fs.readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim() || null;
|
|
139
|
+
}
|
|
140
|
+
if (process.platform === 'darwin') {
|
|
141
|
+
// "{ sec = 1714000000, usec = 123456 } Wed Apr 24 ..." -> "1714000000.123456"
|
|
142
|
+
const out = execFileSync('sysctl', ['-n', 'kern.boottime'], { encoding: 'utf8', timeout: 2000 });
|
|
143
|
+
const m = /sec\s*=\s*(\d+),\s*usec\s*=\s*(\d+)/.exec(out);
|
|
144
|
+
return m ? `${m[1]}.${m[2]}` : out.trim() || null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch { }
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/** Start time of `pid`, or null if it is not running or the platform cannot say. Never throws. */
|
|
151
|
+
export function readProcessStartTime(pid) {
|
|
152
|
+
try {
|
|
153
|
+
if (process.platform === 'linux') {
|
|
154
|
+
const stat = fs.readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
155
|
+
// The comm field (2) is parenthesised and may contain spaces or ')'; split
|
|
156
|
+
// after the LAST ')'. What follows starts at field 3, so starttime (22) is
|
|
157
|
+
// index 19.
|
|
158
|
+
const fields = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
|
|
159
|
+
return fields[19] || null;
|
|
160
|
+
}
|
|
161
|
+
if (process.platform === 'darwin') {
|
|
162
|
+
const out = execFileSync('ps', ['-o', 'lstart=', '-p', String(pid)], { encoding: 'utf8', timeout: 2000 });
|
|
163
|
+
return out.trim() || null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch { }
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
/** Whether `pid` exists (EPERM means it does, owned by someone else). */
|
|
170
|
+
export function isPidAlive(pid) {
|
|
171
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
172
|
+
return false;
|
|
173
|
+
try {
|
|
174
|
+
process.kill(pid, 0);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
return err.code === 'EPERM';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export function currentProcessIdentity() {
|
|
182
|
+
return { pid: process.pid, host: os.hostname(), bootId: readBootId(), startTime: readProcessStartTime(process.pid) };
|
|
183
|
+
}
|
|
184
|
+
function readLockFile(lockPath) {
|
|
185
|
+
let text;
|
|
186
|
+
try {
|
|
187
|
+
text = fs.readFileSync(lockPath, 'utf8');
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
if (err.code === 'ENOENT')
|
|
191
|
+
return null;
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const rec = JSON.parse(text);
|
|
196
|
+
if (!rec || typeof rec.pid !== 'number' || typeof rec.host !== 'string')
|
|
197
|
+
return 'corrupt';
|
|
198
|
+
return {
|
|
199
|
+
pid: rec.pid,
|
|
200
|
+
host: rec.host,
|
|
201
|
+
bootId: typeof rec.bootId === 'string' ? rec.bootId : null,
|
|
202
|
+
startTime: typeof rec.startTime === 'string' ? rec.startTime : null,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return 'corrupt';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Take `<folder>/.assistant.lock` for this process, or report why not. The
|
|
211
|
+
* folder must exist. Creation is exclusive (`wx`), so two servers starting at
|
|
212
|
+
* the same instant cannot both win; a stale lock is unlinked and the exclusive
|
|
213
|
+
* create retried (a bounded loop, in case a third process slips in between).
|
|
214
|
+
* Logs a clear line for every refusal and takeover. Never throws.
|
|
215
|
+
*/
|
|
216
|
+
export function acquireAssistantLock(folder) {
|
|
217
|
+
const lockPath = path.join(folder, ASSISTANT_LOCK_FILE);
|
|
218
|
+
try {
|
|
219
|
+
const self = currentProcessIdentity();
|
|
220
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
221
|
+
const existing = readLockFile(lockPath);
|
|
222
|
+
const probe = existing && existing !== 'corrupt' && existing.host === self.host
|
|
223
|
+
? { alive: isPidAlive(existing.pid), startTime: readProcessStartTime(existing.pid) }
|
|
224
|
+
: { alive: false, startTime: null };
|
|
225
|
+
const decision = decideAssistantLock(existing, self, probe);
|
|
226
|
+
if (decision.action === 'refuse') {
|
|
227
|
+
const holder = existing;
|
|
228
|
+
const message = decision.reason === 'foreign-host'
|
|
229
|
+
? `assistant folder ${folder} is locked by a wherever server on another host ` +
|
|
230
|
+
`(${holder.host}, pid ${holder.pid}). A lock from another host is never taken over: ` +
|
|
231
|
+
`if no server there uses this folder any more, remove ${lockPath} by hand and restart.`
|
|
232
|
+
: `assistant folder ${folder} is in use by another wherever server on this host ` +
|
|
233
|
+
`(pid ${holder.pid}). Two servers must not share one assistant folder: give this one ` +
|
|
234
|
+
`a different assistantFolder, or stop the other server and restart.`;
|
|
235
|
+
console.error(`[wherever] assistant DISABLED: ${message}`);
|
|
236
|
+
return { state: 'refused', reason: decision.reason, holder: { pid: holder.pid, host: holder.host }, message };
|
|
237
|
+
}
|
|
238
|
+
if (decision.action === 'take' && decision.reason === 'own')
|
|
239
|
+
return { state: 'held' };
|
|
240
|
+
if (decision.action === 'takeover') {
|
|
241
|
+
const who = existing && existing !== 'corrupt' ? ` (pid ${existing.pid})` : '';
|
|
242
|
+
console.warn(`[wherever] assistant: taking over stale lock ${lockPath}${who}: ${decision.reason}`);
|
|
243
|
+
try {
|
|
244
|
+
fs.unlinkSync(lockPath);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
if (err.code !== 'ENOENT')
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const record = { ...self, acquiredAt: new Date().toISOString() };
|
|
252
|
+
try {
|
|
253
|
+
fs.writeFileSync(lockPath, JSON.stringify(record, null, 2) + '\n', { encoding: 'utf8', flag: 'wx' });
|
|
254
|
+
return { state: 'held' };
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
if (err.code !== 'EEXIST')
|
|
258
|
+
throw err;
|
|
259
|
+
// Someone created it between our read and our write: decide again.
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
throw new Error('lock kept changing while acquiring it');
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
const message = `could not lock assistant folder ${folder}: ${err.message}`;
|
|
266
|
+
console.error(`[wherever] assistant DISABLED: ${message}`);
|
|
267
|
+
return { state: 'error', message };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Remove the lock iff it is still THIS process's (same pid and start time).
|
|
272
|
+
* Synchronous so it is safe from a `process.on('exit')` handler. Never throws.
|
|
273
|
+
*/
|
|
274
|
+
export function releaseAssistantLock(folder) {
|
|
275
|
+
const lockPath = path.join(folder, ASSISTANT_LOCK_FILE);
|
|
276
|
+
try {
|
|
277
|
+
const existing = readLockFile(lockPath);
|
|
278
|
+
if (!existing || existing === 'corrupt')
|
|
279
|
+
return;
|
|
280
|
+
if (existing.pid !== process.pid || existing.host !== os.hostname())
|
|
281
|
+
return;
|
|
282
|
+
const mine = readProcessStartTime(process.pid);
|
|
283
|
+
if (existing.startTime && mine && existing.startTime !== mine)
|
|
284
|
+
return;
|
|
285
|
+
fs.unlinkSync(lockPath);
|
|
286
|
+
}
|
|
287
|
+
catch { }
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Server-start entry point: resolve, create, lock, seed. Order matters: the
|
|
291
|
+
* folder is created first (the lock lives in it), then locked, and ONLY a server
|
|
292
|
+
* that holds the lock seeds it, so a refused server writes nothing beyond the
|
|
293
|
+
* mkdir of a folder that already had a lock in it.
|
|
294
|
+
*/
|
|
295
|
+
export function startAssistantFolder(config) {
|
|
296
|
+
const folder = resolveAssistantFolder(config);
|
|
297
|
+
if (!folder) {
|
|
298
|
+
return { status: { configured: false, folder: null, active: false, lock: null }, release() { } };
|
|
299
|
+
}
|
|
300
|
+
let lock;
|
|
301
|
+
try {
|
|
302
|
+
fs.mkdirSync(folder, { recursive: true });
|
|
303
|
+
lock = acquireAssistantLock(folder);
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
const message = `could not create assistant folder ${folder}: ${err.message}`;
|
|
307
|
+
console.error(`[wherever] assistant DISABLED: ${message}`);
|
|
308
|
+
lock = { state: 'error', message };
|
|
309
|
+
}
|
|
310
|
+
if (lock.state === 'held') {
|
|
311
|
+
try {
|
|
312
|
+
const written = seedAssistantFolder(folder);
|
|
313
|
+
if (written.length > 0)
|
|
314
|
+
console.log(`[wherever] assistant: seeded ${written.join(', ')} in ${folder}`);
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
// Seeding is a convenience, not a precondition: keep the lock and the feature.
|
|
318
|
+
console.error(`[wherever] assistant: failed to seed ${folder}:`, err);
|
|
319
|
+
}
|
|
320
|
+
console.log(`[wherever] assistant folder: ${folder}`);
|
|
321
|
+
}
|
|
322
|
+
let released = false;
|
|
323
|
+
return {
|
|
324
|
+
status: { configured: true, folder, active: lock.state === 'held', lock },
|
|
325
|
+
release() {
|
|
326
|
+
if (released || lock.state !== 'held')
|
|
327
|
+
return;
|
|
328
|
+
released = true;
|
|
329
|
+
releaseAssistantLock(folder);
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=assistant-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-folder.js","sourceRoot":"","sources":["../src/assistant-folder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA2B7B,oFAAoF;AACpF,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBlC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;CAGvC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;EACjC,mBAAmB;CACpB,CAAC;AAEF,yFAAyF;AACzF,MAAM,UAAU,GAAoC;IAClD,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAClC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,wBAAwB,CAAC;IAC1D,CAAC,YAAY,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,C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,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,IAAI,EAAE;QACzE,OAAO;YACL,IAAI,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM;gBAAE,OAAO;YAC9C,QAAQ,GAAG,IAAI,CAAC;YAChB,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { type CronSpec, type ParsedAt } from './assistant-cron.js';
|
|
2
|
+
/**
|
|
3
|
+
* The assistant's SCHEDULE (spec `assistant-session-and-channels`, ADR 0015):
|
|
4
|
+
* the job format and its validation, the pure next-run planner, the store that
|
|
5
|
+
* reads and writes `<assistantFolder>/schedule.json`, the append-only run log
|
|
6
|
+
* `<stateDir>/assistant-runs.jsonl`, and the user's timezone state
|
|
7
|
+
* `<stateDir>/assistant-timezone.json`. The firing loop is
|
|
8
|
+
* `assistant-scheduler.ts`.
|
|
9
|
+
*
|
|
10
|
+
* Intent vs run state (ADR 0015): `schedule.json` holds only what the user (or
|
|
11
|
+
* an agent) asked for, so it can be read, hand-edited and versioned with the
|
|
12
|
+
* rest of the assistant's memory. The server never writes run bookkeeping into
|
|
13
|
+
* it; last / next run are DERIVED from the run log.
|
|
14
|
+
*
|
|
15
|
+
* File shape (decision): `{ "jobs": [ <job>, ... ] }`. A missing file is an empty
|
|
16
|
+
* schedule. Any other top-level shape makes the whole file unreadable: nothing
|
|
17
|
+
* fires, `list()` reports the file error, and writes REFUSE (rather than replace
|
|
18
|
+
* a file the user is in the middle of editing). Unknown keys, at the top level
|
|
19
|
+
* and inside a job, are kept untouched by writes and ignored by the scheduler,
|
|
20
|
+
* so a later format addition never invalidates an older server's view.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SCHEDULE_FILE = "schedule.json";
|
|
23
|
+
export declare const RUN_LOG_FILE = "assistant-runs.jsonl";
|
|
24
|
+
export declare const TIMEZONE_FILE = "assistant-timezone.json";
|
|
25
|
+
/** Default restart grace window: a missed run is caught up only if it is this recent. */
|
|
26
|
+
export declare const DEFAULT_GRACE_MS: number;
|
|
27
|
+
export type JobMode = 'inline' | 'isolated';
|
|
28
|
+
/** One job, as written in `schedule.json` (intent only). */
|
|
29
|
+
export interface ScheduleJob {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
/** 5-field cron (recurring). Exactly one of `cron` / `at`. */
|
|
33
|
+
cron?: string;
|
|
34
|
+
/** ISO 8601 date-time, or `"now"` (one-shot). An `at` without a UTC offset is read in the job's effective timezone. */
|
|
35
|
+
at?: string;
|
|
36
|
+
/** Pinned IANA timezone. Unset = follows the user's CURRENT timezone. */
|
|
37
|
+
tz?: string;
|
|
38
|
+
mode: JobMode;
|
|
39
|
+
prompt: string;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
/** The session that scheduled it (context, not the execution location). */
|
|
42
|
+
originSessionId?: string;
|
|
43
|
+
originCwd?: string;
|
|
44
|
+
}
|
|
45
|
+
/** A job that passed validation, with its parsed time spec. */
|
|
46
|
+
export interface ValidJob {
|
|
47
|
+
job: ScheduleJob;
|
|
48
|
+
index: number;
|
|
49
|
+
cron?: CronSpec;
|
|
50
|
+
at?: ParsedAt | 'now';
|
|
51
|
+
}
|
|
52
|
+
/** A malformed entry: listed as invalid, never fired, never stops the valid ones. */
|
|
53
|
+
export interface InvalidJob {
|
|
54
|
+
index: number;
|
|
55
|
+
id: string | null;
|
|
56
|
+
name: string | null;
|
|
57
|
+
errors: string[];
|
|
58
|
+
raw: unknown;
|
|
59
|
+
}
|
|
60
|
+
export interface ValidatedSchedule {
|
|
61
|
+
valid: ValidJob[];
|
|
62
|
+
invalid: InvalidJob[];
|
|
63
|
+
/** Set when the FILE itself is unreadable (bad JSON, wrong shape); then `valid` is empty. */
|
|
64
|
+
fileError: string | null;
|
|
65
|
+
}
|
|
66
|
+
/** Validate one raw entry. Returns the job or the list of problems. */
|
|
67
|
+
export declare function validateJob(raw: unknown): {
|
|
68
|
+
ok: true;
|
|
69
|
+
job: ScheduleJob;
|
|
70
|
+
cron?: CronSpec;
|
|
71
|
+
at?: ParsedAt | 'now';
|
|
72
|
+
} | {
|
|
73
|
+
ok: false;
|
|
74
|
+
errors: string[];
|
|
75
|
+
};
|
|
76
|
+
/** Parse + validate a whole `schedule.json` text (null = the file does not exist). */
|
|
77
|
+
export declare function validateSchedule(text: string | null): ValidatedSchedule;
|
|
78
|
+
export type RunOutcome = 'fired' | 'failed' | 'refused' | 'skipped';
|
|
79
|
+
/** One line of `assistant-runs.jsonl`. Append-only; never rewritten. */
|
|
80
|
+
export interface RunEntry {
|
|
81
|
+
jobId: string;
|
|
82
|
+
/** When the entry was written (ISO). */
|
|
83
|
+
time: string;
|
|
84
|
+
/** The occurrence this run accounts for (ISO). For a skip: the latest missed occurrence. */
|
|
85
|
+
scheduledFor: string;
|
|
86
|
+
mode: JobMode;
|
|
87
|
+
outcome: RunOutcome;
|
|
88
|
+
/** The session the run was delivered to (inline: the assistant session; isolated: its job session). */
|
|
89
|
+
sessionFile?: string | null;
|
|
90
|
+
error?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The append-only run log. Loaded once and kept in memory (the server is its
|
|
94
|
+
* only writer); every append goes to the file and the memory copy together. A
|
|
95
|
+
* line that does not parse is skipped (a crash mid-append leaves at most one).
|
|
96
|
+
*/
|
|
97
|
+
export declare class RunLog {
|
|
98
|
+
readonly filePath: string;
|
|
99
|
+
private entries;
|
|
100
|
+
private byJob;
|
|
101
|
+
constructor(stateDir: string);
|
|
102
|
+
append(entry: RunEntry): void;
|
|
103
|
+
forJob(jobId: string): readonly RunEntry[];
|
|
104
|
+
all(): readonly RunEntry[];
|
|
105
|
+
private remember;
|
|
106
|
+
}
|
|
107
|
+
export type JobPlan =
|
|
108
|
+
/** Disabled: never fires. */
|
|
109
|
+
{
|
|
110
|
+
state: 'disabled';
|
|
111
|
+
next: null;
|
|
112
|
+
}
|
|
113
|
+
/** A one-shot that already ran (or was skipped / refused): reported done. */
|
|
114
|
+
| {
|
|
115
|
+
state: 'done';
|
|
116
|
+
next: null;
|
|
117
|
+
}
|
|
118
|
+
/** A cron with no occurrence within the search horizon (e.g. Feb 31). */
|
|
119
|
+
| {
|
|
120
|
+
state: 'never';
|
|
121
|
+
next: null;
|
|
122
|
+
}
|
|
123
|
+
/** Next run in the future. */
|
|
124
|
+
| {
|
|
125
|
+
state: 'waiting';
|
|
126
|
+
next: number;
|
|
127
|
+
}
|
|
128
|
+
/** Fire now, for the occurrence `scheduledFor` (the latest one at or before now). */
|
|
129
|
+
| {
|
|
130
|
+
state: 'due';
|
|
131
|
+
next: number;
|
|
132
|
+
scheduledFor: number;
|
|
133
|
+
}
|
|
134
|
+
/** Missed outside the grace window: record a skip for `scheduledFor`, do not fire. */
|
|
135
|
+
| {
|
|
136
|
+
state: 'missed';
|
|
137
|
+
next: number;
|
|
138
|
+
scheduledFor: number;
|
|
139
|
+
};
|
|
140
|
+
export interface PlanOptions {
|
|
141
|
+
/** Grace window in ms (a missed run older than this is skipped, not fired). */
|
|
142
|
+
graceMs: number;
|
|
143
|
+
/**
|
|
144
|
+
* Occurrences at or before this instant are never "missed". The scheduler sets
|
|
145
|
+
* it to when it first saw the job (a job with no run yet) or when it last saw
|
|
146
|
+
* the job re-enabled or edited, so a job that never existed (or was off) for a
|
|
147
|
+
* past occurrence does not catch up on it. Undefined with no run yet = now.
|
|
148
|
+
*/
|
|
149
|
+
since?: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Where a job stands at `now`: the pure next-run function (entry, timezone, run
|
|
153
|
+
* log, now). `tz` is the job's EFFECTIVE timezone (its own `tz`, else the user's
|
|
154
|
+
* current one), so a follows-the-user job moves with the user, and an `at`
|
|
155
|
+
* without an offset is read in it.
|
|
156
|
+
*
|
|
157
|
+
* Recurring: the last accounted occurrence (the newest run entry's
|
|
158
|
+
* `scheduledFor`, or `since`) is the base; if the first occurrence after it is
|
|
159
|
+
* still in the future the job is waiting, otherwise runs were missed and the
|
|
160
|
+
* LATEST missed one either fires once (inside the grace window) or is skipped.
|
|
161
|
+
* One-shot: any run entry means done; `"now"` is due as soon as it is seen; a
|
|
162
|
+
* past `at` fires inside the grace window, else is skipped (and then done).
|
|
163
|
+
*/
|
|
164
|
+
export declare function planJob(entry: ValidJob, tz: string, runs: readonly RunEntry[], now: number, opts: PlanOptions): JobPlan;
|
|
165
|
+
/** The effective timezone of a job: its pinned `tz`, else the user's current one. */
|
|
166
|
+
export declare function effectiveTimeZone(job: ScheduleJob, userTz: string): string;
|
|
167
|
+
/** The schedule file could not be read as a schedule; a write would clobber it. */
|
|
168
|
+
export declare class ScheduleFileError extends Error {
|
|
169
|
+
constructor(message: string);
|
|
170
|
+
}
|
|
171
|
+
/** A job given to `addJob` is not valid; nothing was written. */
|
|
172
|
+
export declare class ScheduleValidationError extends Error {
|
|
173
|
+
readonly errors: string[];
|
|
174
|
+
constructor(errors: string[]);
|
|
175
|
+
}
|
|
176
|
+
export interface ScheduleStoreOptions {
|
|
177
|
+
/** Test seam: called after the new content is staged, before the conflict check. */
|
|
178
|
+
beforeCommit?: (attempt: number) => void;
|
|
179
|
+
/** How many times a write re-reads and retries when the file changed under it. Default 5. */
|
|
180
|
+
maxAttempts?: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Reads and writes `schedule.json`. Every write goes through ONE serial queue,
|
|
184
|
+
* re-reads the file, applies the change to what is on disk NOW, stages it in a
|
|
185
|
+
* temp file, then checks the file did not change since it was read before the
|
|
186
|
+
* atomic rename; if it did (a hand edit landed meanwhile), the whole
|
|
187
|
+
* read-modify-write is retried on the new content, so the edit is never
|
|
188
|
+
* clobbered (ADR 0015).
|
|
189
|
+
*/
|
|
190
|
+
export declare class ScheduleStore {
|
|
191
|
+
readonly filePath: string;
|
|
192
|
+
private queue;
|
|
193
|
+
private readonly beforeCommit?;
|
|
194
|
+
private readonly maxAttempts;
|
|
195
|
+
constructor(folder: string, opts?: ScheduleStoreOptions);
|
|
196
|
+
/** The raw file text, or null when it does not exist. */
|
|
197
|
+
readRaw(): string | null;
|
|
198
|
+
/** Read + validate (on every read, ADR 0015). An I/O error reads as a file error. */
|
|
199
|
+
read(): ValidatedSchedule;
|
|
200
|
+
/**
|
|
201
|
+
* Apply `mutate` to the raw job list (unknown keys kept) through the write
|
|
202
|
+
* queue. `mutate` may throw to abort (nothing is written).
|
|
203
|
+
*/
|
|
204
|
+
update<T>(mutate: (jobs: unknown[]) => T): Promise<T>;
|
|
205
|
+
/** Validate and append a job. The id is generated when missing; a duplicate id is refused. */
|
|
206
|
+
addJob(input: Omit<ScheduleJob, 'id'> & {
|
|
207
|
+
id?: string;
|
|
208
|
+
}): Promise<ScheduleJob>;
|
|
209
|
+
/** Remove a job by id. Resolves false when there was none. */
|
|
210
|
+
removeJob(id: string): Promise<boolean>;
|
|
211
|
+
private updateNow;
|
|
212
|
+
}
|
|
213
|
+
export interface TimezoneChange {
|
|
214
|
+
timezone: string;
|
|
215
|
+
at: string;
|
|
216
|
+
/** Who set it: `system` (initialised), `web`, `assistant`, ... */
|
|
217
|
+
source: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The user's CURRENT timezone: what a job without `tz` follows (ADR 0015). Server
|
|
221
|
+
* state in the state dir, initialised to the system timezone, changed through
|
|
222
|
+
* `set` (later tasks: the web's report and `assistant_set_timezone`). Every
|
|
223
|
+
* change is recorded in the file's `history`.
|
|
224
|
+
*/
|
|
225
|
+
export declare class UserTimezone {
|
|
226
|
+
readonly filePath: string;
|
|
227
|
+
private state;
|
|
228
|
+
constructor(stateDir: string, systemTz?: string);
|
|
229
|
+
get(): string;
|
|
230
|
+
history(): readonly TimezoneChange[];
|
|
231
|
+
/** Change it. Throws on an unknown zone; resolves false (nothing written) when unchanged. */
|
|
232
|
+
set(timezone: string, source: string): boolean;
|
|
233
|
+
private load;
|
|
234
|
+
private write;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=assistant-schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-schedule.d.ts","sourceRoot":"","sources":["../src/assistant-schedule.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,YAAY,yBAAyB,CAAC;AACnD,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,QAAiB,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5C,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,WAAW,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IA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