@songsid/agend 2.1.4-beta.2 → 2.1.4-beta.21
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/agent-endpoint.js +1 -1
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/backend/antigravity.d.ts +1 -0
- package/dist/backend/antigravity.js +4 -0
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/claude-code.js +23 -2
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.d.ts +17 -0
- package/dist/backend/codex.js +122 -7
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/kiro.d.ts +1 -0
- package/dist/backend/kiro.js +14 -0
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/opencode.d.ts +27 -11
- package/dist/backend/opencode.js +48 -37
- package/dist/backend/opencode.js.map +1 -1
- package/dist/backend/types.d.ts +14 -0
- package/dist/backend/types.js +7 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/channel/adapters/discord.js +76 -25
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.js +5 -3
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-server.js +6 -20
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +4 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/channel/types.d.ts +1 -1
- package/dist/classic-channel-manager.d.ts +40 -3
- package/dist/classic-channel-manager.js +218 -31
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +159 -36
- package/dist/cli.js.map +1 -1
- package/dist/completion-install.d.ts +70 -0
- package/dist/completion-install.js +152 -0
- package/dist/completion-install.js.map +1 -0
- package/dist/completion.d.ts +7 -1
- package/dist/completion.js +14 -4
- package/dist/completion.js.map +1 -1
- package/dist/config-validator.js +38 -7
- package/dist/config-validator.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.js +10 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +171 -5
- package/dist/daemon.js +696 -82
- package/dist/daemon.js.map +1 -1
- package/dist/doctor.d.ts +26 -0
- package/dist/doctor.js +216 -0
- package/dist/doctor.js.map +1 -0
- package/dist/fleet-context.d.ts +16 -0
- package/dist/fleet-manager.d.ts +233 -10
- package/dist/fleet-manager.js +1828 -493
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-yaml-slim.d.ts +10 -0
- package/dist/fleet-yaml-slim.js +59 -0
- package/dist/fleet-yaml-slim.js.map +1 -0
- package/dist/general-knowledge/skills/backend-providers/SKILL.md +114 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +3 -1
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +52 -0
- package/dist/general-knowledge/skills/development-workflow/SKILL.md +28 -0
- package/dist/general-knowledge/skills/fleet-config/SKILL.md +1 -0
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -0
- package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -0
- package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -0
- package/dist/general-knowledge/skills/model-discovery/SKILL.md +64 -16
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -0
- package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -0
- package/dist/general-knowledge/skills/session-management/SKILL.md +1 -0
- package/dist/general-knowledge/skills/tui-effort/SKILL.md +1 -0
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +30 -0
- package/dist/instance-lifecycle.d.ts +8 -0
- package/dist/instance-lifecycle.js +46 -25
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +12 -0
- package/dist/instructions.js +33 -0
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +656 -220
- package/dist/locale.js.map +1 -1
- package/dist/outbound-handlers.d.ts +8 -0
- package/dist/outbound-handlers.js +44 -5
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +5 -0
- package/dist/outbound-schemas.js +7 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/quickstart.js +25 -0
- package/dist/quickstart.js.map +1 -1
- package/dist/restart-progress.d.ts +9 -1
- package/dist/restart-progress.js +30 -6
- package/dist/restart-progress.js.map +1 -1
- package/dist/scheduler/db.d.ts +5 -0
- package/dist/scheduler/db.js +35 -0
- package/dist/scheduler/db.js.map +1 -1
- package/dist/service-installer.d.ts +11 -0
- package/dist/service-installer.js +84 -18
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-api.js +1 -1
- package/dist/settings-api.js.map +1 -1
- package/dist/tips.d.ts +39 -0
- package/dist/tips.js +351 -0
- package/dist/tips.js.map +1 -0
- package/dist/tool-progress.d.ts +40 -0
- package/dist/tool-progress.js +289 -0
- package/dist/tool-progress.js.map +1 -0
- package/dist/topic-commands.d.ts +28 -4
- package/dist/topic-commands.js +227 -65
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +15 -2
- package/dist/transcript-monitor.js +63 -17
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-sources.d.ts +106 -0
- package/dist/transcript-sources.js +428 -0
- package/dist/transcript-sources.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/ui/dashboard.html +55 -32
- package/dist/ui/settings.html +120 -51
- package/dist/ui/view.html +23 -15
- package/dist/update-marker.d.ts +30 -0
- package/dist/update-marker.js +71 -20
- package/dist/update-marker.js.map +1 -1
- package/dist/update-progress.d.ts +6 -0
- package/dist/update-progress.js +29 -0
- package/dist/update-progress.js.map +1 -0
- package/dist/usage/usage-api.d.ts +8 -2
- package/dist/usage/usage-api.js +24 -3
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/workflow-templates/default.md +2 -1
- package/package.json +1 -1
|
@@ -17,22 +17,38 @@ export declare class OpenCodeBackend implements CliBackend {
|
|
|
17
17
|
getContextUsage(): number | null;
|
|
18
18
|
getSessionId(): string | null;
|
|
19
19
|
/**
|
|
20
|
-
* Find this instance's OpenCode session
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* Find this instance's OpenCode session via the CLI's own listing —
|
|
21
|
+
* `opencode session list --format json` — the official output surface for
|
|
22
|
+
* exactly the data this needs ({ id, directory, created, updated } per
|
|
23
|
+
* session, newest first, subagent children excluded). This replaced a
|
|
24
|
+
* direct read of opencode.db: same information, but semver-protected CLI
|
|
25
|
+
* output instead of a private sqlite schema, and no node:sqlite
|
|
26
|
+
* requirement. ~1.2s per call is fine — discovery only runs from
|
|
27
|
+
* saveSessionId sites (shutdown, pause, crash respawn, idle checkpoint),
|
|
28
|
+
* never on a hot path.
|
|
25
29
|
*
|
|
26
30
|
* A row is only accepted when it matches the spawn this backend performed:
|
|
27
31
|
* same directory AND (created after our launch, or the exact id we resumed
|
|
28
|
-
* with). A session someone created manually in the same cwd before our
|
|
29
|
-
* can therefore never be adopted — the hijack #525 removed must not
|
|
30
|
-
* through this path.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* quietly returns null and resume simply stays unavailable.
|
|
32
|
+
* with). A session someone created manually in the same cwd before our
|
|
33
|
+
* spawn can therefore never be adopted — the hijack #525 removed must not
|
|
34
|
+
* return through this path. The directory filter is done here because the
|
|
35
|
+
* listing is global; `--continue`'s apparent per-cwd behavior is an
|
|
36
|
+
* undocumented server-scoping side effect we deliberately do not rely on.
|
|
34
37
|
*/
|
|
35
38
|
private discoverSessionId;
|
|
39
|
+
/**
|
|
40
|
+
* `opencode session list --format json`, bounded and best-effort. Split out
|
|
41
|
+
* as the process-spawning seam so tests stub it with fixture rows instead
|
|
42
|
+
* of a real CLI.
|
|
43
|
+
*
|
|
44
|
+
* Runs with cwd = the instance's working directory: the listing is scoped
|
|
45
|
+
* to the PROJECT opencode resolves for the cwd it runs in (a git root, or
|
|
46
|
+
* the "global" project outside one — verified on 1.18.15). Run anywhere
|
|
47
|
+
* else and the instance's sessions may simply not be in the output. The
|
|
48
|
+
* exact-directory filter in discoverSessionId still applies on top, because
|
|
49
|
+
* a project can span several directories (worktrees, monorepo).
|
|
50
|
+
*/
|
|
51
|
+
private listSessions;
|
|
36
52
|
getQuitCommand(): string;
|
|
37
53
|
getCompactCommand(): string;
|
|
38
54
|
getClearCommand(): string;
|
package/dist/backend/opencode.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
4
|
import { resolveBinary, validateModel, warnIfModelMismatch } from "./types.js";
|
|
6
5
|
export class OpenCodeBackend {
|
|
7
6
|
instanceDir;
|
|
@@ -113,52 +112,64 @@ export class OpenCodeBackend {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
/**
|
|
116
|
-
* Find this instance's OpenCode session
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
115
|
+
* Find this instance's OpenCode session via the CLI's own listing —
|
|
116
|
+
* `opencode session list --format json` — the official output surface for
|
|
117
|
+
* exactly the data this needs ({ id, directory, created, updated } per
|
|
118
|
+
* session, newest first, subagent children excluded). This replaced a
|
|
119
|
+
* direct read of opencode.db: same information, but semver-protected CLI
|
|
120
|
+
* output instead of a private sqlite schema, and no node:sqlite
|
|
121
|
+
* requirement. ~1.2s per call is fine — discovery only runs from
|
|
122
|
+
* saveSessionId sites (shutdown, pause, crash respawn, idle checkpoint),
|
|
123
|
+
* never on a hot path.
|
|
121
124
|
*
|
|
122
125
|
* A row is only accepted when it matches the spawn this backend performed:
|
|
123
126
|
* same directory AND (created after our launch, or the exact id we resumed
|
|
124
|
-
* with). A session someone created manually in the same cwd before our
|
|
125
|
-
* can therefore never be adopted — the hijack #525 removed must not
|
|
126
|
-
* through this path.
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* quietly returns null and resume simply stays unavailable.
|
|
127
|
+
* with). A session someone created manually in the same cwd before our
|
|
128
|
+
* spawn can therefore never be adopted — the hijack #525 removed must not
|
|
129
|
+
* return through this path. The directory filter is done here because the
|
|
130
|
+
* listing is global; `--continue`'s apparent per-cwd behavior is an
|
|
131
|
+
* undocumented server-scoping side effect we deliberately do not rely on.
|
|
130
132
|
*/
|
|
131
133
|
discoverSessionId() {
|
|
132
134
|
if (!this.workingDirectory || this.launchedAt === null)
|
|
133
135
|
return null;
|
|
136
|
+
const sessions = this.listSessions();
|
|
137
|
+
if (!sessions)
|
|
138
|
+
return null;
|
|
139
|
+
const candidates = sessions
|
|
140
|
+
.filter(s => s.directory === this.workingDirectory && !s.parentID)
|
|
141
|
+
.sort((a, b) => (b.updated ?? 0) - (a.updated ?? 0));
|
|
142
|
+
for (const session of candidates) {
|
|
143
|
+
if (session.id === this.launchedSessionId)
|
|
144
|
+
return session.id;
|
|
145
|
+
if ((session.created ?? 0) >= this.launchedAt)
|
|
146
|
+
return session.id;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* `opencode session list --format json`, bounded and best-effort. Split out
|
|
152
|
+
* as the process-spawning seam so tests stub it with fixture rows instead
|
|
153
|
+
* of a real CLI.
|
|
154
|
+
*
|
|
155
|
+
* Runs with cwd = the instance's working directory: the listing is scoped
|
|
156
|
+
* to the PROJECT opencode resolves for the cwd it runs in (a git root, or
|
|
157
|
+
* the "global" project outside one — verified on 1.18.15). Run anywhere
|
|
158
|
+
* else and the instance's sessions may simply not be in the output. The
|
|
159
|
+
* exact-directory filter in discoverSessionId still applies on top, because
|
|
160
|
+
* a project can span several directories (worktrees, monorepo).
|
|
161
|
+
*/
|
|
162
|
+
listSessions() {
|
|
163
|
+
if (!this.workingDirectory)
|
|
164
|
+
return null;
|
|
134
165
|
try {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return null;
|
|
139
|
-
const dataHome = process.env.XDG_DATA_HOME || join(homedir(), ".local", "share");
|
|
140
|
-
const dbPath = join(dataHome, "opencode", "opencode.db");
|
|
141
|
-
if (!existsSync(dbPath))
|
|
142
|
-
return null;
|
|
143
|
-
const db = new sqlite.DatabaseSync(dbPath, { readOnly: true });
|
|
144
|
-
try {
|
|
145
|
-
// parent_id IS NULL excludes subagent child sessions. LIMIT 10 keeps the
|
|
146
|
-
// scan bounded; the active session is the newest by time_updated anyway.
|
|
147
|
-
const rows = db.prepare("SELECT id, time_created FROM session WHERE directory = ? AND parent_id IS NULL ORDER BY time_updated DESC LIMIT 10").all(this.workingDirectory);
|
|
148
|
-
for (const row of rows) {
|
|
149
|
-
if (row.id === this.launchedSessionId)
|
|
150
|
-
return row.id;
|
|
151
|
-
if (row.time_created >= this.launchedAt)
|
|
152
|
-
return row.id;
|
|
153
|
-
}
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
157
|
-
db.close();
|
|
158
|
-
}
|
|
166
|
+
const out = execFileSync(this.binaryPath, ["session", "list", "--format", "json", "-n", "50"], { encoding: "utf-8", timeout: 15_000, stdio: ["ignore", "pipe", "ignore"], cwd: this.workingDirectory });
|
|
167
|
+
const parsed = JSON.parse(out);
|
|
168
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
159
169
|
}
|
|
160
170
|
catch {
|
|
161
|
-
//
|
|
171
|
+
// CLI missing/slow/failed, or the working directory is gone — resume is
|
|
172
|
+
// best-effort, never fatal.
|
|
162
173
|
return null;
|
|
163
174
|
}
|
|
164
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/backend/opencode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,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GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;gBAC3E,CAAC;gBACD,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;QAE7B,iCAAiC;QACjC,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;YACpE,IAAI,UAAU,CAAC,SAAS,CAAC;gBAAE,UAAU,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/backend/types.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export interface CliBackendConfig {
|
|
|
34
34
|
agentMode?: "mcp" | "cli";
|
|
35
35
|
/** Health server port for CLI mode (agend-agent connects here). */
|
|
36
36
|
agentPort?: number;
|
|
37
|
+
/** Per-backend options merged from fleet defaults + instance config (e.g. { provider: "glm" }). */
|
|
38
|
+
backendOptions?: Record<string, unknown>;
|
|
37
39
|
}
|
|
38
40
|
/** Action to take when an error pattern is detected in PTY output. */
|
|
39
41
|
export type ErrorActionType = "notify" | "failover" | "restart" | "pause";
|
|
@@ -107,6 +109,16 @@ export interface CliBackend {
|
|
|
107
109
|
* at an empty prompt and during generation. Absent means false.
|
|
108
110
|
*/
|
|
109
111
|
requiresDeliveryEnterRetry?(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the TUI can emit terminal output while its visible pane is
|
|
114
|
+
* unchanged (for example, rerunning and repainting a status-line hook).
|
|
115
|
+
*
|
|
116
|
+
* The daemon normally treats every tmux control-mode output event as immediate
|
|
117
|
+
* evidence of work. Backends with periodic cosmetic redraws instead require a
|
|
118
|
+
* pane capture to confirm that visible content actually changed. Absent means
|
|
119
|
+
* false.
|
|
120
|
+
*/
|
|
121
|
+
hasPeriodicPaneRedraw?(): boolean;
|
|
110
122
|
/** Build the shell command string to launch the CLI in a tmux window. */
|
|
111
123
|
buildCommand(config: CliBackendConfig): string;
|
|
112
124
|
/** Write all config files the CLI needs before launch. */
|
|
@@ -250,6 +262,8 @@ export declare function resolveBinary(name: string, fallbackDirs?: readonly stri
|
|
|
250
262
|
*/
|
|
251
263
|
export declare function validateEffort(effort: string): string;
|
|
252
264
|
export declare function validateModel(model: string): string;
|
|
265
|
+
/** Guard a provider name before embedding it in a shell command. */
|
|
266
|
+
export declare function validateProvider(provider: string): string;
|
|
253
267
|
/** Check if a model name is compatible with the given backend. */
|
|
254
268
|
export declare function isModelCompatible(backendName: string, model: string): boolean;
|
|
255
269
|
/**
|
package/dist/backend/types.js
CHANGED
|
@@ -92,6 +92,13 @@ export function validateModel(model) {
|
|
|
92
92
|
}
|
|
93
93
|
return model;
|
|
94
94
|
}
|
|
95
|
+
/** Guard a provider name before embedding it in a shell command. */
|
|
96
|
+
export function validateProvider(provider) {
|
|
97
|
+
if (!/^[A-Za-z0-9_-]+$/.test(provider)) {
|
|
98
|
+
throw new Error(`Invalid provider name: "${provider}" — only alphanumeric, underscore, hyphen allowed`);
|
|
99
|
+
}
|
|
100
|
+
return provider;
|
|
101
|
+
}
|
|
95
102
|
/** Known model prefixes/patterns per backend. Used only for advisory warnings. */
|
|
96
103
|
const BACKEND_MODEL_PATTERNS = {
|
|
97
104
|
"claude-code": /^(sonnet|opus|haiku|opusplan|best|fable|claude)/i,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,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F,MAAM,sBAAsB,GAA2B;IACrD,aAAa,EAAE,kDAAkD;IACjE,UAAU,EAAE,iEAAiE;IAC7E,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,UAAU;IACxB,UAAU,EAAE,GAAG,EAAG,iDAAiD;IACnE,0EAA0E;IAC1E,8DAA8D;IAC9D,aAAa,EAAE,2BAA2B;IAC1C,MAAM,EAAE,QAAQ,EAAG,gDAAgD;CACpE,CAAC;AAEF,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,WAAmB,EAAE,KAAa;IAClE,MAAM,OAAO,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC,CAAC,iCAAiC;IAC5D,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,KAAa;IACpE,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,uCAAuC,WAAW,0BAA0B,CAAC,CAAC;IACpH,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -265,6 +265,33 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
265
265
|
size: att.size,
|
|
266
266
|
filename: att.name ?? undefined,
|
|
267
267
|
}));
|
|
268
|
+
// A Discord reply carries only the referenced message id on the new
|
|
269
|
+
// message. Fetch the original so image attachments are delivered with
|
|
270
|
+
// the reply rather than reducing the reference to text alone. Keep this
|
|
271
|
+
// limited to real attachments: ordinary URL auto-embeds must not become
|
|
272
|
+
// downloads (the same policy as the outer message above).
|
|
273
|
+
let replyToText;
|
|
274
|
+
if (msg.reference?.messageId) {
|
|
275
|
+
try {
|
|
276
|
+
const ref = await msg.fetchReference();
|
|
277
|
+
replyToText = ref.content || ref.embeds?.[0]?.description || undefined;
|
|
278
|
+
for (const att of ref.attachments?.values() ?? []) {
|
|
279
|
+
if (!att.contentType?.startsWith("image/"))
|
|
280
|
+
continue;
|
|
281
|
+
if (!attachments.some(existing => existing.fileId === att.id)) {
|
|
282
|
+
attachments.push({
|
|
283
|
+
kind: "photo",
|
|
284
|
+
fileId: att.id,
|
|
285
|
+
mime: att.contentType,
|
|
286
|
+
size: att.size,
|
|
287
|
+
filename: att.name ?? undefined,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
this.attachmentUrls.set(att.id, att.url);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch { /* deleted message or no permission */ }
|
|
294
|
+
}
|
|
268
295
|
// Embed images become synthetic photo attachments so the normal download
|
|
269
296
|
// path (attachment-handler → downloadAttachment → image_path) serves them
|
|
270
297
|
// without knowing where the bytes came from. Their synthetic ids are
|
|
@@ -293,14 +320,6 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
293
320
|
else
|
|
294
321
|
break;
|
|
295
322
|
}
|
|
296
|
-
let replyToText;
|
|
297
|
-
if (msg.reference?.messageId) {
|
|
298
|
-
try {
|
|
299
|
-
const ref = await msg.fetchReference();
|
|
300
|
-
replyToText = ref.content || ref.embeds?.[0]?.description || undefined;
|
|
301
|
-
}
|
|
302
|
-
catch { /* deleted message or no permission */ }
|
|
303
|
-
}
|
|
304
323
|
this.emit("message", {
|
|
305
324
|
source: "discord",
|
|
306
325
|
adapterId: this.id,
|
|
@@ -410,7 +429,10 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
410
429
|
});
|
|
411
430
|
}
|
|
412
431
|
else {
|
|
413
|
-
|
|
432
|
+
// /update progress must survive the fleet process restart. A public
|
|
433
|
+
// bot message can be re-fetched and edited by the new process;
|
|
434
|
+
// Discord ephemeral interaction replies cannot.
|
|
435
|
+
await interaction.deferReply({ ephemeral: interaction.commandName !== "update" });
|
|
414
436
|
// Extract options as key-value pairs for fleet-manager
|
|
415
437
|
const options = {};
|
|
416
438
|
for (const opt of interaction.options.data) {
|
|
@@ -425,9 +447,11 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
425
447
|
username,
|
|
426
448
|
options,
|
|
427
449
|
respond: async (reply) => { try {
|
|
428
|
-
await this._editReplyLong(interaction, reply);
|
|
450
|
+
return await this._editReplyLong(interaction, reply);
|
|
429
451
|
}
|
|
430
|
-
catch {
|
|
452
|
+
catch {
|
|
453
|
+
return undefined;
|
|
454
|
+
} },
|
|
431
455
|
respondChoices: async (text, choices) => {
|
|
432
456
|
const select = new StringSelectMenuBuilder()
|
|
433
457
|
.setCustomId(CLASSIC_START_BACKEND_SELECT_ID)
|
|
@@ -493,7 +517,7 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
493
517
|
name: "start", description: t("slash.start"),
|
|
494
518
|
options: [{
|
|
495
519
|
name: "backend",
|
|
496
|
-
description: "
|
|
520
|
+
description: t("slash.option.backend"),
|
|
497
521
|
type: ApplicationCommandOptionType.String,
|
|
498
522
|
required: true,
|
|
499
523
|
choices: DISCORD_START_BACKEND_CHOICES,
|
|
@@ -501,16 +525,16 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
501
525
|
},
|
|
502
526
|
{ name: "stop", description: t("slash.stop") },
|
|
503
527
|
{
|
|
504
|
-
name: "pause", description: "🔒
|
|
505
|
-
options: [{ name: "instance", description: "
|
|
528
|
+
name: "pause", description: "🔒 " + t("slash.pause"),
|
|
529
|
+
options: [{ name: "instance", description: t("slash.option.instance"), type: ApplicationCommandOptionType.String, required: false }],
|
|
506
530
|
},
|
|
507
531
|
{
|
|
508
|
-
name: "wake", description: "🔒
|
|
509
|
-
options: [{ name: "instance", description: "
|
|
532
|
+
name: "wake", description: "🔒 " + t("slash.wake"),
|
|
533
|
+
options: [{ name: "instance", description: t("slash.option.instance"), type: ApplicationCommandOptionType.String, required: false }],
|
|
510
534
|
},
|
|
511
535
|
{
|
|
512
536
|
name: "chat", description: t("slash.chat"),
|
|
513
|
-
options: [{ name: "message", description: "
|
|
537
|
+
options: [{ name: "message", description: t("slash.option.message"), type: 3, required: true }],
|
|
514
538
|
},
|
|
515
539
|
{ name: "status", description: "🔒 " + t("slash.status") },
|
|
516
540
|
{ name: "sysinfo", description: t("slash.sysinfo") },
|
|
@@ -520,15 +544,41 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
520
544
|
{ name: "update", description: "🔒 " + t("slash.update") },
|
|
521
545
|
{ name: "doctor", description: "🔒 " + t("slash.doctor") },
|
|
522
546
|
{ name: "usage", description: t("slash.usage") },
|
|
547
|
+
{
|
|
548
|
+
name: "tips", description: t("slash.tips"),
|
|
549
|
+
options: [{
|
|
550
|
+
name: "mode", description: t("slash.option.tips_mode"),
|
|
551
|
+
type: ApplicationCommandOptionType.String, required: false,
|
|
552
|
+
choices: [
|
|
553
|
+
{ name: "on", value: "on" },
|
|
554
|
+
{ name: "off", value: "off" },
|
|
555
|
+
{ name: "advanced on", value: "advanced on" },
|
|
556
|
+
],
|
|
557
|
+
}],
|
|
558
|
+
},
|
|
523
559
|
{ name: "compact", description: "🔒 " + t("slash.compact") },
|
|
560
|
+
{
|
|
561
|
+
name: "steer", description: t("slash.steer"),
|
|
562
|
+
options: [{
|
|
563
|
+
name: "message", description: t("slash.option.steer_message"),
|
|
564
|
+
type: ApplicationCommandOptionType.String, required: true,
|
|
565
|
+
}],
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "btw", description: t("slash.btw"),
|
|
569
|
+
options: [{
|
|
570
|
+
name: "message", description: t("slash.option.btw_message"),
|
|
571
|
+
type: ApplicationCommandOptionType.String, required: true,
|
|
572
|
+
}],
|
|
573
|
+
},
|
|
524
574
|
{ name: "clear", description: "🔒 " + t("slash.clear") },
|
|
525
575
|
{
|
|
526
|
-
name: "model", description: "🔒
|
|
576
|
+
name: "model", description: "🔒 " + t("slash.model"),
|
|
527
577
|
},
|
|
528
578
|
{
|
|
529
579
|
name: "effort", description: "🔒 " + t("slash.effort"),
|
|
530
580
|
options: [{
|
|
531
|
-
name: "level", description: "
|
|
581
|
+
name: "level", description: t("slash.option.effort_level"),
|
|
532
582
|
type: ApplicationCommandOptionType.String, required: false,
|
|
533
583
|
choices: [
|
|
534
584
|
{ name: "low", value: "low" }, { name: "medium", value: "medium" },
|
|
@@ -541,13 +591,13 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
541
591
|
{
|
|
542
592
|
name: "save", description: "🔒 " + t("slash.save"),
|
|
543
593
|
options: [
|
|
544
|
-
{ name: "filename", description: "
|
|
545
|
-
{ name: "force", description: "
|
|
594
|
+
{ name: "filename", description: t("slash.option.save_filename"), type: 3, required: true },
|
|
595
|
+
{ name: "force", description: t("slash.option.save_force"), type: 5, required: false },
|
|
546
596
|
],
|
|
547
597
|
},
|
|
548
598
|
{
|
|
549
599
|
name: "load", description: "🔒 " + t("slash.load"),
|
|
550
|
-
options: [{ name: "filename", description: "
|
|
600
|
+
options: [{ name: "filename", description: t("slash.option.load_filename"), type: 3, required: true }],
|
|
551
601
|
},
|
|
552
602
|
{ name: "cancel", description: t("slash.cancel") },
|
|
553
603
|
]);
|
|
@@ -575,14 +625,15 @@ export class DiscordAdapter extends EventEmitter {
|
|
|
575
625
|
async _editReplyLong(interaction, reply) {
|
|
576
626
|
const EMBED_MAX = 4096;
|
|
577
627
|
if (reply.length <= DISCORD_MAX_LENGTH) {
|
|
578
|
-
await interaction.editReply({ content: reply, components: [] });
|
|
579
|
-
return;
|
|
628
|
+
const message = await interaction.editReply({ content: reply, components: [] });
|
|
629
|
+
return message.id;
|
|
580
630
|
}
|
|
581
631
|
const chunks = splitText(reply, EMBED_MAX);
|
|
582
|
-
await interaction.editReply({ content: "", embeds: [{ description: chunks[0] }], components: [] });
|
|
632
|
+
const message = await interaction.editReply({ content: "", embeds: [{ description: chunks[0] }], components: [] });
|
|
583
633
|
for (let i = 1; i < chunks.length; i++) {
|
|
584
634
|
await interaction.followUp({ ephemeral: true, embeds: [{ description: chunks[i] }] });
|
|
585
635
|
}
|
|
636
|
+
return message.id;
|
|
586
637
|
}
|
|
587
638
|
async sendText(chatId, text, opts) {
|
|
588
639
|
const channelId = opts?.threadId ?? chatId;
|