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
|
@@ -15,6 +15,25 @@ import type { ToolDefinition } from '@earendil-works/pi-coding-agent';
|
|
|
15
15
|
* works in a pure web-frontend session with no CLI bridge present.
|
|
16
16
|
*
|
|
17
17
|
* `cwd` is the session's working directory; relative paths resolve against it.
|
|
18
|
+
*
|
|
19
|
+
* Serving: a successful call is itself the download grant (download-grants.ts),
|
|
20
|
+
* so any existing file the agent attaches is downloadable, inside the cwd or not.
|
|
21
|
+
* The remaining refusals are server-wide policy, which `downloadsConfig` exposes
|
|
22
|
+
* so the tool can FAIL LOUDLY instead of showing a button that can only error:
|
|
23
|
+
* downloads disabled, or the file over `downloads.maxBytes`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createAttachFileTool(cwd: string, downloadsConfig?: () => DownloadsPolicy | undefined): ToolDefinition;
|
|
26
|
+
/** The slice of `WhereverConfig.downloads` the tool needs to predict a refusal. */
|
|
27
|
+
export interface DownloadsPolicy {
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
maxBytes?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Default `downloads.maxBytes`, kept in step with GET /session/download. */
|
|
32
|
+
export declare const DEFAULT_DOWNLOAD_MAX_BYTES: number;
|
|
33
|
+
/**
|
|
34
|
+
* Why GET /session/download would refuse this file, as an actionable tool error,
|
|
35
|
+
* or null when it will be served. Mirrors the endpoint's policy checks so the
|
|
36
|
+
* agent learns at attach time rather than the user at tap time.
|
|
18
37
|
*/
|
|
19
|
-
export declare function
|
|
38
|
+
export declare function downloadRefusal(policy: DownloadsPolicy | undefined, size: number, resolved: string): string | null;
|
|
20
39
|
//# sourceMappingURL=attach-file-tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach-file-tool.d.ts","sourceRoot":"","sources":["../src/attach-file-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"attach-file-tool.d.ts","sourceRoot":"","sources":["../src/attach-file-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,eAAe,GAAE,MAAM,eAAe,GAAG,SAA2B,GACnE,cAAc,CAqGhB;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,6EAA6E;AAC7E,eAAO,MAAM,0BAA0B,QAAoB,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAgBf"}
|
package/dist/attach-file-tool.js
CHANGED
|
@@ -18,8 +18,14 @@ import { Type } from 'typebox';
|
|
|
18
18
|
* works in a pure web-frontend session with no CLI bridge present.
|
|
19
19
|
*
|
|
20
20
|
* `cwd` is the session's working directory; relative paths resolve against it.
|
|
21
|
+
*
|
|
22
|
+
* Serving: a successful call is itself the download grant (download-grants.ts),
|
|
23
|
+
* so any existing file the agent attaches is downloadable, inside the cwd or not.
|
|
24
|
+
* The remaining refusals are server-wide policy, which `downloadsConfig` exposes
|
|
25
|
+
* so the tool can FAIL LOUDLY instead of showing a button that can only error:
|
|
26
|
+
* downloads disabled, or the file over `downloads.maxBytes`.
|
|
21
27
|
*/
|
|
22
|
-
export function createAttachFileTool(cwd) {
|
|
28
|
+
export function createAttachFileTool(cwd, downloadsConfig = () => undefined) {
|
|
23
29
|
return {
|
|
24
30
|
name: 'attach_file',
|
|
25
31
|
label: 'Attach File',
|
|
@@ -27,8 +33,8 @@ export function createAttachFileTool(cwd) {
|
|
|
27
33
|
'phone/browser) can download it with one tap. The user is remote and CANNOT ' +
|
|
28
34
|
'reach the local filesystem, so a file path in your reply is NOT enough: they ' +
|
|
29
35
|
'can only obtain a file if you attach it with this tool. Pass the path to a ' +
|
|
30
|
-
'real, existing file
|
|
31
|
-
'
|
|
36
|
+
'real, existing file (relative to the working directory, or absolute; it does ' +
|
|
37
|
+
'not need to be inside the working directory). Use this both right after generating a ' +
|
|
32
38
|
'deliverable (a PDF, an export, a report) AND whenever the user asks for a ' +
|
|
33
39
|
"file by name or type, including one created earlier in the conversation, " +
|
|
34
40
|
"e.g. 'give me the gpx', 'send me the pdf', 'download the report', 'can I " +
|
|
@@ -87,6 +93,22 @@ export function createAttachFileTool(cwd) {
|
|
|
87
93
|
isError: true,
|
|
88
94
|
};
|
|
89
95
|
}
|
|
96
|
+
const refusal = downloadRefusal(downloadsConfig(), size ?? 0, resolved);
|
|
97
|
+
if (refusal) {
|
|
98
|
+
return {
|
|
99
|
+
content: [{ type: 'text', text: refusal }],
|
|
100
|
+
details: undefined,
|
|
101
|
+
isError: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// Report the REAL path: it is what the download grant names, so the grant
|
|
105
|
+
// pins the file attached now, not whatever a symlink points at later.
|
|
106
|
+
try {
|
|
107
|
+
resolved = fs.realpathSync(resolved);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// Raced away after the stat: keep the lexical path; the download will 404.
|
|
111
|
+
}
|
|
90
112
|
const filename = path.basename(resolved);
|
|
91
113
|
return {
|
|
92
114
|
content: [
|
|
@@ -101,4 +123,24 @@ export function createAttachFileTool(cwd) {
|
|
|
101
123
|
},
|
|
102
124
|
};
|
|
103
125
|
}
|
|
126
|
+
/** Default `downloads.maxBytes`, kept in step with GET /session/download. */
|
|
127
|
+
export const DEFAULT_DOWNLOAD_MAX_BYTES = 100 * 1024 * 1024;
|
|
128
|
+
/**
|
|
129
|
+
* Why GET /session/download would refuse this file, as an actionable tool error,
|
|
130
|
+
* or null when it will be served. Mirrors the endpoint's policy checks so the
|
|
131
|
+
* agent learns at attach time rather than the user at tap time.
|
|
132
|
+
*/
|
|
133
|
+
export function downloadRefusal(policy, size, resolved) {
|
|
134
|
+
if (policy?.enabled === false) {
|
|
135
|
+
return (`attach_file: downloads are disabled on this server (downloads.enabled is false), ` +
|
|
136
|
+
`so the user cannot download ${resolved}. Tell the user the file path instead.`);
|
|
137
|
+
}
|
|
138
|
+
const maxBytes = policy?.maxBytes ?? DEFAULT_DOWNLOAD_MAX_BYTES;
|
|
139
|
+
if (size > maxBytes) {
|
|
140
|
+
return (`attach_file: ${resolved} is ${size} bytes, over the server's download limit of ` +
|
|
141
|
+
`${maxBytes} bytes (downloads.maxBytes). Produce a smaller file (compress, split ` +
|
|
142
|
+
`or downscale it) and attach that instead.`);
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
104
146
|
//# sourceMappingURL=attach-file-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach-file-tool.js","sourceRoot":"","sources":["../src/attach-file-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B
|
|
1
|
+
{"version":3,"file":"attach-file-tool.js","sourceRoot":"","sources":["../src/attach-file-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,kBAAqD,GAAG,EAAE,CAAC,SAAS;IAEpE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,2EAA2E;YAC3E,6EAA6E;YAC7E,+EAA+E;YAC/E,6EAA6E;YAC7E,+EAA+E;YAC/E,uFAAuF;YACvF,4EAA4E;YAC5E,2EAA2E;YAC3E,2EAA2E;YAC3E,0EAA0E;Y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,EAAE;aAC5C,CAAC;QACJ,CAAC;KAC2B,CAAC;AACjC,CAAC;AAQD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAmC,EACnC,IAAY,EACZ,QAAgB;IAEhB,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,CACL,mFAAmF;YACnF,+BAA+B,QAAQ,wCAAwC,CAChF,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,0BAA0B,CAAC;IAChE,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;QACpB,OAAO,CACL,gBAAgB,QAAQ,OAAO,IAAI,8CAA8C;YACjF,GAAG,QAAQ,uEAAuE;YAClF,2CAA2C,CAC5C,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server half of the CLI bridge's REQUEST/RESPONSE path (ADR 0016, spec
|
|
3
|
+
* `assistant-session-and-channels`).
|
|
4
|
+
*
|
|
5
|
+
* The `@wherever-dev/pi` extension sends `cli_request {id, op, args}` on its
|
|
6
|
+
* bridge WebSocket and waits for `cli_response {id, ok, result | error}` with the
|
|
7
|
+
* same id. The CALLER is never read from the request: it is the session that
|
|
8
|
+
* connection registered with `cli_register` (index.ts resolves it), so an origin
|
|
9
|
+
* a later op stamps (`assistant_notify`, `assistant_schedule_add`, ...) is
|
|
10
|
+
* server-side truth. A connection that never registered is refused.
|
|
11
|
+
*
|
|
12
|
+
* Ops: `assistant_info`, and the five ops behind the extension's `assistant_*`
|
|
13
|
+
* tool twins (`cli-assistant-tool-twins`): `schedule_add`, `schedule_list`,
|
|
14
|
+
* `schedule_remove`, `set_timezone`, `notify`. Those run the SAME op code as the
|
|
15
|
+
* server's own tools (`assistantCliOps` in assistant-tools.ts) and answer
|
|
16
|
+
* `{ text, details }` (the tool result the twin returns) or an error (the twin's
|
|
17
|
+
* `isError` text). An unknown op answers an error (an OLDER server, which has no
|
|
18
|
+
* `cli_request` case at all, answers nothing, and the extension detects it by
|
|
19
|
+
* timeout).
|
|
20
|
+
*/
|
|
21
|
+
import { type AssistantSessionHooks } from './assistant-tools.js';
|
|
22
|
+
/** The calling bridge session, resolved from its registration. */
|
|
23
|
+
export interface CliCaller {
|
|
24
|
+
sessionFile: string;
|
|
25
|
+
/** The registered session's id (null when the pool no longer tracks it). */
|
|
26
|
+
sessionId?: string | null;
|
|
27
|
+
/** The registered session's cwd (absent when the pool no longer tracks it). */
|
|
28
|
+
cwd?: string;
|
|
29
|
+
}
|
|
30
|
+
/** An op implementation. Its return value is the response `result`; a throw answers its message. */
|
|
31
|
+
export type CliRequestOp = (args: unknown, caller: CliCaller) => unknown | Promise<unknown>;
|
|
32
|
+
export interface CliRequestFrame {
|
|
33
|
+
type: 'cli_request';
|
|
34
|
+
id: string;
|
|
35
|
+
op: string;
|
|
36
|
+
args?: unknown;
|
|
37
|
+
}
|
|
38
|
+
export type CliResponseFrame = {
|
|
39
|
+
type: 'cli_response';
|
|
40
|
+
id: string;
|
|
41
|
+
ok: true;
|
|
42
|
+
result: unknown;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'cli_response';
|
|
45
|
+
id: string;
|
|
46
|
+
ok: false;
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* What `assistant_info` returns and `assistant_info_changed` pushes.
|
|
51
|
+
* `assistantFolder` is null when the assistant is not ACTIVE on this server
|
|
52
|
+
* (unset, or refused because another server holds the folder lock): the gate is
|
|
53
|
+
* `assistant.active`, as everywhere else in the assistant. `timezone` is the
|
|
54
|
+
* user's current timezone (the scheduler's, see assistant-tools.ts), null when
|
|
55
|
+
* not active; every change of it is pushed as `assistant_info_changed`.
|
|
56
|
+
*/
|
|
57
|
+
export interface AssistantInfo {
|
|
58
|
+
assistantFolder: string | null;
|
|
59
|
+
timezone?: string | null;
|
|
60
|
+
}
|
|
61
|
+
export declare class CliRequestRouter {
|
|
62
|
+
private readonly ops;
|
|
63
|
+
register(op: string, impl: CliRequestOp): void;
|
|
64
|
+
/**
|
|
65
|
+
* Answer one request. Null only when the request carries no string id (there
|
|
66
|
+
* is nothing to correlate an answer with). Never throws.
|
|
67
|
+
*/
|
|
68
|
+
handle(msg: Partial<CliRequestFrame>, caller: CliCaller | null): Promise<CliResponseFrame | null>;
|
|
69
|
+
}
|
|
70
|
+
export interface CliRequestRouterDeps {
|
|
71
|
+
/** The current assistant info (read on every request, so it is never stale). */
|
|
72
|
+
assistantInfo: () => AssistantInfo;
|
|
73
|
+
/**
|
|
74
|
+
* The same hooks the pool gives server sessions (undefined while
|
|
75
|
+
* `assistantFolder` is unset), read on every request. The tool-twin ops answer
|
|
76
|
+
* "not configured" without them, and the lock-state error while not active.
|
|
77
|
+
*/
|
|
78
|
+
assistantHooks?: () => AssistantSessionHooks | undefined;
|
|
79
|
+
}
|
|
80
|
+
/** The router with this server's built-in ops. */
|
|
81
|
+
export declare function createCliRequestRouter(deps: CliRequestRouterDeps): CliRequestRouter;
|
|
82
|
+
/** The ops behind the extension's `assistant_*` tool twins (extension/src/assistant-tool-twins.ts `ASSISTANT_TWIN_OPS`). */
|
|
83
|
+
export declare const ASSISTANT_TWIN_OP_NAMES: readonly ["schedule_add", "schedule_list", "schedule_remove", "set_timezone", "notify"];
|
|
84
|
+
/** The server-to-extension push sent to every connected CLI bridge when the assistant info changes. */
|
|
85
|
+
export declare function assistantInfoChangedFrame(info: AssistantInfo): {
|
|
86
|
+
type: 'assistant_info_changed';
|
|
87
|
+
assistantFolder: string | null;
|
|
88
|
+
timezone: string | null;
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=cli-requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-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G;IACG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAexG;AAED,MAAM,WAAW,oBAAoB;IACnC,gFAAgF;IAChF,aAAa,EAAE,MAAM,aAAa,CAAC;IACnC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,qBAAqB,GAAG,SAAS,CAAC;CAC1D;AAED,kDAAkD;AAClD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,gBAAgB,CAenF;AAED,4HAA4H;AAC5H,eAAO,MAAM,uBAAuB,yFAA0F,CAAC;AAE/H,uGAAuG;AACvG,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,aAAa,GAAG;IAC9D,IAAI,EAAE,wBAAwB,CAAC;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAEA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server half of the CLI bridge's REQUEST/RESPONSE path (ADR 0016, spec
|
|
3
|
+
* `assistant-session-and-channels`).
|
|
4
|
+
*
|
|
5
|
+
* The `@wherever-dev/pi` extension sends `cli_request {id, op, args}` on its
|
|
6
|
+
* bridge WebSocket and waits for `cli_response {id, ok, result | error}` with the
|
|
7
|
+
* same id. The CALLER is never read from the request: it is the session that
|
|
8
|
+
* connection registered with `cli_register` (index.ts resolves it), so an origin
|
|
9
|
+
* a later op stamps (`assistant_notify`, `assistant_schedule_add`, ...) is
|
|
10
|
+
* server-side truth. A connection that never registered is refused.
|
|
11
|
+
*
|
|
12
|
+
* Ops: `assistant_info`, and the five ops behind the extension's `assistant_*`
|
|
13
|
+
* tool twins (`cli-assistant-tool-twins`): `schedule_add`, `schedule_list`,
|
|
14
|
+
* `schedule_remove`, `set_timezone`, `notify`. Those run the SAME op code as the
|
|
15
|
+
* server's own tools (`assistantCliOps` in assistant-tools.ts) and answer
|
|
16
|
+
* `{ text, details }` (the tool result the twin returns) or an error (the twin's
|
|
17
|
+
* `isError` text). An unknown op answers an error (an OLDER server, which has no
|
|
18
|
+
* `cli_request` case at all, answers nothing, and the extension detects it by
|
|
19
|
+
* timeout).
|
|
20
|
+
*/
|
|
21
|
+
import { assistantCliOps } from './assistant-tools.js';
|
|
22
|
+
export class CliRequestRouter {
|
|
23
|
+
ops = new Map();
|
|
24
|
+
register(op, impl) {
|
|
25
|
+
this.ops.set(op, impl);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Answer one request. Null only when the request carries no string id (there
|
|
29
|
+
* is nothing to correlate an answer with). Never throws.
|
|
30
|
+
*/
|
|
31
|
+
async handle(msg, caller) {
|
|
32
|
+
const id = msg?.id;
|
|
33
|
+
if (typeof id !== 'string' || !id)
|
|
34
|
+
return null;
|
|
35
|
+
const fail = (error) => ({ type: 'cli_response', id, ok: false, error });
|
|
36
|
+
if (!caller)
|
|
37
|
+
return fail('cli_request needs a registered CLI bridge session (send cli_register first).');
|
|
38
|
+
const op = typeof msg.op === 'string' ? msg.op : '';
|
|
39
|
+
const impl = this.ops.get(op);
|
|
40
|
+
if (!impl)
|
|
41
|
+
return fail(`Unknown cli_request op: ${op || '(none)'}`);
|
|
42
|
+
try {
|
|
43
|
+
const result = await impl(msg.args, caller);
|
|
44
|
+
return { type: 'cli_response', id, ok: true, result: result ?? null };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** The router with this server's built-in ops. */
|
|
52
|
+
export function createCliRequestRouter(deps) {
|
|
53
|
+
const router = new CliRequestRouter();
|
|
54
|
+
router.register('assistant_info', () => deps.assistantInfo());
|
|
55
|
+
for (const op of ASSISTANT_TWIN_OP_NAMES) {
|
|
56
|
+
router.register(op, async (args, caller) => {
|
|
57
|
+
if (!caller.cwd) {
|
|
58
|
+
throw new Error('this CLI session is no longer registered with the wherever server; reconnect and try again');
|
|
59
|
+
}
|
|
60
|
+
const run = assistantCliOps(deps.assistantHooks?.())[op];
|
|
61
|
+
const r = await run(args, { sessionId: caller.sessionId ?? null, cwd: caller.cwd, sessionFile: caller.sessionFile });
|
|
62
|
+
if (!r.ok)
|
|
63
|
+
throw new Error(r.error);
|
|
64
|
+
return { text: r.text, details: r.details };
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return router;
|
|
68
|
+
}
|
|
69
|
+
/** The ops behind the extension's `assistant_*` tool twins (extension/src/assistant-tool-twins.ts `ASSISTANT_TWIN_OPS`). */
|
|
70
|
+
export const ASSISTANT_TWIN_OP_NAMES = ['schedule_add', 'schedule_list', 'schedule_remove', 'set_timezone', 'notify'];
|
|
71
|
+
/** The server-to-extension push sent to every connected CLI bridge when the assistant info changes. */
|
|
72
|
+
export function assistantInfoChangedFrame(info) {
|
|
73
|
+
return { type: 'assistant_info_changed', assistantFolder: info.assistantFolder, timezone: info.timezone ?? null };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=cli-requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-requests.js","sourceRoot":"","sources":["../src/cli-requests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AAsCnF,MAAM,OAAO,gBAAgB;IACV,GAAG,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEvD,QAAQ,CAAC,EAAU,EAAE,IAAkB;QACrC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,GAA6B,EAAE,MAAwB;QAClE,MAAM,EAAE,GAAG,GAAG,EAAE,EA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
|
3
|
+
* transcript at `sessionFile`. Returns `[]` when the file is missing/unreadable.
|
|
4
|
+
* Cached against the file's mtime + size, so a long transcript is re-scanned
|
|
5
|
+
* only after it changes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readAttachGrants(sessionFile: string): Promise<string[]>;
|
|
8
|
+
/** Extract the granted path from one transcript line, or null if it is not a successful attach_file result. */
|
|
9
|
+
export declare function attachGrantFromLine(line: string): string | null;
|
|
10
|
+
/** Test hook: forget every cached scan. */
|
|
11
|
+
export declare function clearAttachGrantCache(): void;
|
|
12
|
+
//# sourceMappingURL=download-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-grants.d.ts","sourceRoot":"","sources":["../src/download-grants.ts"],"names":[],"mappings":"AAuCA;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoC7E;AAED,+GAA+G;AAC/G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe/D;AAED,2CAA2C;AAC3C,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
const cache = new Map();
|
|
4
|
+
const MAX_CACHE_ENTRIES = 64;
|
|
5
|
+
/** Cheap pre-filter so only lines that can possibly be an attach result are JSON-parsed. */
|
|
6
|
+
const NEEDLE = '"toolName":"attach_file"';
|
|
7
|
+
/**
|
|
8
|
+
* The absolute paths granted by successful `attach_file` tool results in the
|
|
9
|
+
* transcript at `sessionFile`. Returns `[]` when the file is missing/unreadable.
|
|
10
|
+
* Cached against the file's mtime + size, so a long transcript is re-scanned
|
|
11
|
+
* only after it changes.
|
|
12
|
+
*/
|
|
13
|
+
export async function readAttachGrants(sessionFile) {
|
|
14
|
+
let stat;
|
|
15
|
+
try {
|
|
16
|
+
stat = await fs.promises.stat(sessionFile);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
if (!stat.isFile())
|
|
22
|
+
return [];
|
|
23
|
+
const cached = cache.get(sessionFile);
|
|
24
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
|
|
25
|
+
return cached.paths;
|
|
26
|
+
}
|
|
27
|
+
const paths = new Set();
|
|
28
|
+
try {
|
|
29
|
+
const rl = readline.createInterface({
|
|
30
|
+
input: fs.createReadStream(sessionFile, { encoding: 'utf8' }),
|
|
31
|
+
crlfDelay: Infinity,
|
|
32
|
+
});
|
|
33
|
+
for await (const line of rl) {
|
|
34
|
+
if (!line.includes(NEEDLE))
|
|
35
|
+
continue;
|
|
36
|
+
const granted = attachGrantFromLine(line);
|
|
37
|
+
if (granted)
|
|
38
|
+
paths.add(granted);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const result = Array.from(paths);
|
|
45
|
+
if (cache.size >= MAX_CACHE_ENTRIES && !cache.has(sessionFile)) {
|
|
46
|
+
const oldest = cache.keys().next().value;
|
|
47
|
+
if (oldest !== undefined)
|
|
48
|
+
cache.delete(oldest);
|
|
49
|
+
}
|
|
50
|
+
cache.set(sessionFile, { mtimeMs: stat.mtimeMs, size: stat.size, paths: result });
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
/** Extract the granted path from one transcript line, or null if it is not a successful attach_file result. */
|
|
54
|
+
export function attachGrantFromLine(line) {
|
|
55
|
+
let entry;
|
|
56
|
+
try {
|
|
57
|
+
entry = JSON.parse(line);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (entry?.type !== 'message')
|
|
63
|
+
return null;
|
|
64
|
+
const message = entry.message;
|
|
65
|
+
if (!message || message.role !== 'toolResult' || message.toolName !== 'attach_file')
|
|
66
|
+
return null;
|
|
67
|
+
if (message.isError === true)
|
|
68
|
+
return null;
|
|
69
|
+
const p = message.details?.path;
|
|
70
|
+
return typeof p === 'string' && p.length > 0 ? p : null;
|
|
71
|
+
}
|
|
72
|
+
/** Test hook: forget every cached scan. */
|
|
73
|
+
export function clearAttachGrantCache() {
|
|
74
|
+
cache.clear();
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=download-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-grants.js","sourceRoot":"","sources":["../src/download-grants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,QAAQ,MAAM,eAAe,CAAC;AAgCrC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAC5C,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,4FAA4F;AAC5F,MAAM,MAAM,GAAG,0BAA0B,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAAmB;IACxD,IAAI,IAAc,CAAC;IACnB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3E,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,I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