@llblab/pi-telegram 0.6.3 → 0.7.1
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/AGENTS.md +153 -0
- package/BACKLOG.md +5 -0
- package/CHANGELOG.md +148 -0
- package/README.md +40 -39
- package/docs/README.md +1 -0
- package/docs/architecture.md +36 -27
- package/docs/attachment-handlers.md +4 -6
- package/docs/callback-namespaces.md +36 -0
- package/docs/command-templates.md +53 -9
- package/docs/locks.md +4 -0
- package/docs/outbound-handlers.md +6 -5
- package/index.ts +60 -7
- package/lib/api.ts +1 -0
- package/lib/attachment-handlers.ts +21 -10
- package/lib/attachments.ts +1 -0
- package/lib/command-templates.ts +37 -3
- package/lib/commands.ts +363 -88
- package/lib/config.ts +6 -2
- package/lib/keyboard.ts +14 -0
- package/lib/lifecycle.ts +26 -0
- package/lib/locks.ts +3 -2
- package/lib/media.ts +1 -0
- package/lib/menu-model.ts +881 -0
- package/lib/menu-queue.ts +610 -0
- package/lib/menu-status.ts +226 -0
- package/lib/menu-thinking.ts +171 -0
- package/lib/menu.ts +143 -1019
- package/lib/model.ts +1 -0
- package/lib/outbound-handlers.ts +28 -19
- package/lib/pi.ts +8 -0
- package/lib/polling.ts +1 -0
- package/lib/preview.ts +97 -50
- package/lib/prompt-templates.ts +150 -0
- package/lib/prompts.ts +2 -0
- package/lib/queue.ts +60 -15
- package/lib/rendering.ts +1 -0
- package/lib/replies.ts +90 -2
- package/lib/routing.ts +106 -14
- package/lib/runtime.ts +2 -0
- package/lib/setup.ts +1 -0
- package/lib/status.ts +18 -6
- package/lib/turns.ts +1 -0
- package/lib/updates.ts +55 -6
- package/package.json +5 -2
package/lib/attachments.ts
CHANGED
package/lib/command-templates.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Command-template standard helpers
|
|
3
|
+
* Zones: shared utils, local process execution, automation standard
|
|
3
4
|
* Owns shell-free command-template splitting, placeholder defaults, composition expansion, executable path expansion, and direct execution
|
|
4
5
|
*/
|
|
5
6
|
|
|
@@ -7,12 +8,16 @@ import { spawn } from "node:child_process";
|
|
|
7
8
|
import { homedir } from "node:os";
|
|
8
9
|
import { isAbsolute, resolve } from "node:path";
|
|
9
10
|
|
|
11
|
+
export const DEFAULT_COMMAND_TIMEOUT_MS = 30_000;
|
|
12
|
+
|
|
10
13
|
export interface CommandTemplateObjectConfig {
|
|
11
14
|
template?: CommandTemplateValue;
|
|
12
15
|
args?: string[];
|
|
13
16
|
defaults?: Record<string, unknown>;
|
|
14
17
|
timeout?: number;
|
|
15
18
|
output?: string;
|
|
19
|
+
retry?: number;
|
|
20
|
+
critical?: boolean;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
export type CommandTemplateValue = string | CommandTemplateConfig[];
|
|
@@ -34,6 +39,7 @@ export interface CommandTemplateExecOptions {
|
|
|
34
39
|
signal?: AbortSignal;
|
|
35
40
|
stdin?: string;
|
|
36
41
|
killGrace?: number;
|
|
42
|
+
retry?: number;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
export interface CommandTemplateExecResult {
|
|
@@ -100,7 +106,13 @@ export function expandCommandTemplateConfigs(
|
|
|
100
106
|
}
|
|
101
107
|
if (typeof normalizedConfig.template !== "string") return [];
|
|
102
108
|
return [
|
|
103
|
-
{
|
|
109
|
+
{
|
|
110
|
+
...normalizedConfig,
|
|
111
|
+
...context,
|
|
112
|
+
template: normalizedConfig.template,
|
|
113
|
+
retry: normalizedConfig.retry,
|
|
114
|
+
critical: normalizedConfig.critical,
|
|
115
|
+
},
|
|
104
116
|
];
|
|
105
117
|
}
|
|
106
118
|
|
|
@@ -192,7 +204,27 @@ export function substituteCommandTemplateToken(
|
|
|
192
204
|
);
|
|
193
205
|
}
|
|
194
206
|
|
|
195
|
-
export function execCommandTemplate(
|
|
207
|
+
export async function execCommandTemplate(
|
|
208
|
+
command: string,
|
|
209
|
+
args: string[],
|
|
210
|
+
options: CommandTemplateExecOptions = {},
|
|
211
|
+
): Promise<CommandTemplateExecResult> {
|
|
212
|
+
const maxAttempts = options.retry ?? 1;
|
|
213
|
+
let lastResult: CommandTemplateExecResult = {
|
|
214
|
+
stdout: "",
|
|
215
|
+
stderr: "",
|
|
216
|
+
code: 1,
|
|
217
|
+
killed: false,
|
|
218
|
+
};
|
|
219
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
220
|
+
const result = await execCommandTemplateOnce(command, args, options);
|
|
221
|
+
if (result.code === 0) return result;
|
|
222
|
+
lastResult = result;
|
|
223
|
+
}
|
|
224
|
+
return lastResult;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function execCommandTemplateOnce(
|
|
196
228
|
command: string,
|
|
197
229
|
args: string[],
|
|
198
230
|
options: CommandTemplateExecOptions = {},
|
|
@@ -231,8 +263,10 @@ export function execCommandTemplate(
|
|
|
231
263
|
else
|
|
232
264
|
options.signal.addEventListener("abort", killProcess, { once: true });
|
|
233
265
|
}
|
|
234
|
-
if (options.timeout && options.timeout > 0)
|
|
266
|
+
if (options.timeout !== undefined && options.timeout > 0)
|
|
235
267
|
timeoutId = setTimeout(killProcess, options.timeout);
|
|
268
|
+
else if (options.timeout === undefined)
|
|
269
|
+
timeoutId = setTimeout(killProcess, DEFAULT_COMMAND_TIMEOUT_MS);
|
|
236
270
|
proc.stdout?.on("data", (data) => {
|
|
237
271
|
stdout += data.toString();
|
|
238
272
|
});
|