botmux 2.110.0-canary.1 → 2.110.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/dist/adapters/backend/riff-backend.d.ts +251 -0
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -0
- package/dist/adapters/backend/riff-backend.js +1004 -0
- package/dist/adapters/backend/riff-backend.js.map +1 -0
- package/dist/adapters/backend/sandbox.d.ts +17 -2
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +58 -5
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/backend/session-backend-selector.d.ts +2 -0
- package/dist/adapters/backend/session-backend-selector.d.ts.map +1 -1
- package/dist/adapters/backend/session-backend-selector.js +12 -0
- package/dist/adapters/backend/session-backend-selector.js.map +1 -1
- package/dist/adapters/backend/types.d.ts +24 -2
- package/dist/adapters/backend/types.d.ts.map +1 -1
- package/dist/adapters/backend/types.js.map +1 -1
- package/dist/adapters/backend/zellij-backend.d.ts +0 -8
- package/dist/adapters/backend/zellij-backend.d.ts.map +1 -1
- package/dist/adapters/backend/zellij-backend.js +16 -63
- package/dist/adapters/backend/zellij-backend.js.map +1 -1
- package/dist/adapters/cli/mir.js +1 -1
- package/dist/adapters/cli/registry.d.ts +5 -1
- package/dist/adapters/cli/registry.d.ts.map +1 -1
- package/dist/adapters/cli/registry.js +48 -1
- package/dist/adapters/cli/registry.js.map +1 -1
- package/dist/adapters/cli/riff.d.ts +14 -0
- package/dist/adapters/cli/riff.d.ts.map +1 -0
- package/dist/adapters/cli/riff.js +35 -0
- package/dist/adapters/cli/riff.js.map +1 -0
- package/dist/adapters/cli/types.d.ts +1 -1
- package/dist/adapters/cli/types.d.ts.map +1 -1
- package/dist/bot-registry.d.ts +7 -0
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +1 -0
- package/dist/bot-registry.js.map +1 -1
- package/dist/cli/quoted-render.d.ts +12 -1
- package/dist/cli/quoted-render.d.ts.map +1 -1
- package/dist/cli/quoted-render.js +16 -1
- package/dist/cli/quoted-render.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +347 -67
- package/dist/cli.js.map +1 -1
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +77 -2
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +90 -0
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dashboard-rows.d.ts +3 -0
- package/dist/core/dashboard-rows.d.ts.map +1 -1
- package/dist/core/dashboard-rows.js +1 -0
- package/dist/core/dashboard-rows.js.map +1 -1
- package/dist/core/persistent-backend.d.ts +11 -0
- package/dist/core/persistent-backend.d.ts.map +1 -1
- package/dist/core/persistent-backend.js +24 -0
- package/dist/core/persistent-backend.js.map +1 -1
- package/dist/core/terminal-url.d.ts +3 -0
- package/dist/core/terminal-url.d.ts.map +1 -1
- package/dist/core/terminal-url.js +6 -0
- package/dist/core/terminal-url.js.map +1 -1
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +15 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +224 -15
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/core/zellij-adopt-discovery.d.ts +0 -17
- package/dist/core/zellij-adopt-discovery.d.ts.map +1 -1
- package/dist/core/zellij-adopt-discovery.js +4 -24
- package/dist/core/zellij-adopt-discovery.js.map +1 -1
- package/dist/core/zellij-session-discovery.d.ts +0 -3
- package/dist/core/zellij-session-discovery.d.ts.map +1 -1
- package/dist/core/zellij-session-discovery.js +0 -1
- package/dist/core/zellij-session-discovery.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +3 -0
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +1 -0
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +1 -0
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/web/app.d.ts.map +1 -1
- package/dist/dashboard/web/app.js +46 -1
- package/dist/dashboard/web/app.js.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults-page.js +116 -4
- package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
- package/dist/dashboard/web/bot-defaults.d.ts +4 -0
- package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
- package/dist/dashboard/web/bot-defaults.js.map +1 -1
- package/dist/dashboard/web/bot-onboarding.d.ts +1 -0
- package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
- package/dist/dashboard/web/bot-onboarding.js +12 -2
- package/dist/dashboard/web/bot-onboarding.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +56 -2
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/insights.js +1 -1
- package/dist/dashboard/web/insights.js.map +1 -1
- package/dist/dashboard/web/session-terminal.d.ts.map +1 -1
- package/dist/dashboard/web/session-terminal.js +4 -0
- package/dist/dashboard/web/session-terminal.js.map +1 -1
- package/dist/dashboard/web/theme-menu.d.ts.map +1 -1
- package/dist/dashboard/web/theme-menu.js +23 -6
- package/dist/dashboard/web/theme-menu.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-QXZ2VFJJ.js +4 -0
- package/dist/dashboard-web/chunks/{chunk-CNQSGYJO.js → chunk-7UY333A5.js} +7 -7
- package/dist/dashboard-web/chunks/chunk-DFLNXQNT.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-N6VSRM5P.js → chunk-GF7DU2B5.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-52T2O5F2.js → chunk-IAES47WV.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-SHZ5PUYF.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-OJPXC6IX.js → chunk-TORH53FI.js} +1 -1
- package/dist/dashboard-web/chunks/{connectors-page-NQWVXDDQ.js → connectors-page-N6GKR6JL.js} +1 -1
- package/dist/dashboard-web/chunks/{groups-page-LNKIB7ES.js → groups-page-IK3GXSQU.js} +1 -1
- package/dist/dashboard-web/chunks/{insights-page-3K22SWPU.js → insights-page-T2PDFPGO.js} +2 -2
- package/dist/dashboard-web/chunks/{legacy-workflow-page-MBZ4EZKI.js → legacy-workflow-page-YQPLKH74.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-2EQSH6FZ.js → monitor-room-7EL3LVJS.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-PRPDWN4L.js → monitoring-page-BCADF56L.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-YN5AEKUU.js → office-page-KP7BDLAE.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-IM4JR3FS.js → overview-page-6GWDHDTI.js} +1 -1
- package/dist/dashboard-web/chunks/{roles-page-3WVXQ46Q.js → roles-page-2OFR2IBG.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-2RKFISU5.js → schedules-page-TAWMTSNL.js} +1 -1
- package/dist/dashboard-web/chunks/{sessions-page-ZSIGVTRI.js → sessions-page-42QZHPPP.js} +1 -1
- package/dist/dashboard-web/chunks/{settings-page-L35RFRCL.js → settings-page-OVKXUXSV.js} +1 -1
- package/dist/dashboard-web/chunks/{skills-page-NCV3CKCE.js → skills-page-Y2EC3NBI.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-FEOU7FX2.js → team-federation-page-QYMJUH5F.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-2W4VVYIK.js → v3-page-FZJCW5QG.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-WIES2PL3.js → whiteboards-page-FBHBBCAL.js} +1 -1
- package/dist/dashboard-web/style.css +157 -7
- package/dist/dashboard.js +59 -19
- package/dist/dashboard.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +3 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +3 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +4 -1
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts +1 -0
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +26 -3
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +11 -2
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/md-card.d.ts +22 -3
- package/dist/im/lark/md-card.d.ts.map +1 -1
- package/dist/im/lark/md-card.js +186 -9
- package/dist/im/lark/md-card.js.map +1 -1
- package/dist/im/lark/message-parser.d.ts +1 -0
- package/dist/im/lark/message-parser.d.ts.map +1 -1
- package/dist/im/lark/message-parser.js +70 -7
- package/dist/im/lark/message-parser.js.map +1 -1
- package/dist/mir-local-runtime.js +1 -1
- package/dist/mir-local-runtime.js.map +1 -1
- package/dist/mir-runner.js +18 -4
- package/dist/mir-runner.js.map +1 -1
- package/dist/services/bot-config-store.d.ts.map +1 -1
- package/dist/services/bot-config-store.js +19 -0
- package/dist/services/bot-config-store.js.map +1 -1
- package/dist/services/default-worktree.d.ts.map +1 -1
- package/dist/services/default-worktree.js +13 -1
- package/dist/services/default-worktree.js.map +1 -1
- package/dist/services/git-worktree.d.ts +8 -0
- package/dist/services/git-worktree.d.ts.map +1 -1
- package/dist/services/git-worktree.js +11 -0
- package/dist/services/git-worktree.js.map +1 -1
- package/dist/setup/bot-config-editor.d.ts.map +1 -1
- package/dist/setup/bot-config-editor.js +4 -2
- package/dist/setup/bot-config-editor.js.map +1 -1
- package/dist/setup/cli-availability.d.ts +26 -0
- package/dist/setup/cli-availability.d.ts.map +1 -0
- package/dist/setup/cli-availability.js +77 -0
- package/dist/setup/cli-availability.js.map +1 -0
- package/dist/setup/cli-selection.js +1 -1
- package/dist/setup/cli-selection.js.map +1 -1
- package/dist/setup/open-platform-automation.d.ts +105 -28
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +366 -92
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/skills/definitions.d.ts.map +1 -1
- package/dist/skills/definitions.js +27 -11
- package/dist/skills/definitions.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.js +284 -67
- package/dist/worker.js.map +1 -1
- package/dist/workflows/definition.d.ts +34 -34
- package/dist/workflows/events/schema.d.ts +280 -280
- package/package.json +1 -1
- package/dist/adapters/backend/zellij-socket-probe.d.ts +0 -5
- package/dist/adapters/backend/zellij-socket-probe.d.ts.map +0 -1
- package/dist/adapters/backend/zellij-socket-probe.js +0 -70
- package/dist/adapters/backend/zellij-socket-probe.js.map +0 -1
- package/dist/dashboard-web/chunks/bot-defaults-page-7AUAVC5N.js +0 -1
- package/dist/dashboard-web/chunks/chunk-TWEDQIZO.js +0 -1
- package/dist/dashboard-web/chunks/chunk-XJ7BGPJH.js +0 -1
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type { SessionBackend, SpawnOpts } from './types.js';
|
|
2
|
+
export interface RiffBackendConfig {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
templateId?: string;
|
|
5
|
+
agent?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
/** Direct JWT token (takes precedence over jwtEnv). */
|
|
8
|
+
jwt?: string;
|
|
9
|
+
/** Name of env var containing the JWT token (default: RIFF_JWT). */
|
|
10
|
+
jwtEnv?: string;
|
|
11
|
+
sandboxCluster?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Repos to clone into the riff sandbox, in the API's native shape
|
|
14
|
+
* ({ repoName: 'group/repo', repoBranch? }). Takes precedence over
|
|
15
|
+
* defaultRepo/defaultBranch. Typically derived by the worker from the
|
|
16
|
+
* session's local workingDir (复用本地仓库+分支) — see
|
|
17
|
+
* deriveRiffRepoFromWorkingDir.
|
|
18
|
+
*/
|
|
19
|
+
repos?: RiffRepoRef[];
|
|
20
|
+
/** Parent task id persisted by the daemon (see worker riff_task_id IPC) —
|
|
21
|
+
* restores the follow-up lineage after a daemon restart. */
|
|
22
|
+
resumeParentTaskId?: string;
|
|
23
|
+
/** Human-readable notes about the derived repo state (dirty tree, unpushed
|
|
24
|
+
* commits). Printed as status lines on task creation so the user knows the
|
|
25
|
+
* sandbox may not see their latest local changes. */
|
|
26
|
+
repoWarnings?: string[];
|
|
27
|
+
injectStatusLines?: boolean;
|
|
28
|
+
logLevel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Environment variables injected into the riff sandbox execution environment.
|
|
31
|
+
* Merged from: botmux session context vars (BOTMUX_SESSION_ID, …) → per-bot
|
|
32
|
+
* env (bots.json `env`) → explicit config.env (which takes precedence).
|
|
33
|
+
* The sandbox installs botmux via setupCommands, so BOTMUX_* vars are needed
|
|
34
|
+
* for the agent to use `botmux send`. Sent as `config.env` to the riff API.
|
|
35
|
+
*/
|
|
36
|
+
env?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* System prompt injected into the riff task. Prepended to the userPrompt
|
|
39
|
+
* (riff API has no separate system-prompt field) so the agent knows it is
|
|
40
|
+
* running inside a botmux-bridged session. When unset, the built-in
|
|
41
|
+
* DEFAULT_RIFF_SYSTEM_PROMPT is used as a fallback.
|
|
42
|
+
*/
|
|
43
|
+
systemPrompt?: string;
|
|
44
|
+
/**
|
|
45
|
+
* ADDITIONAL shell commands run in the riff sandbox before the agent starts
|
|
46
|
+
* working. botmux is ALWAYS installed via MANDATORY_SETUP_COMMANDS (not
|
|
47
|
+
* user-editable, sent to the riff API as config.setupCommands); these are
|
|
48
|
+
* extra commands the user wants to run after that (e.g. installing other
|
|
49
|
+
* dependencies). Sent to the riff API as `config.setupCommands` appended
|
|
50
|
+
* after the mandatory botmux install commands.
|
|
51
|
+
*/
|
|
52
|
+
setupCommands?: string[];
|
|
53
|
+
}
|
|
54
|
+
/** Valid riff service base URL: non-empty http(s). Shared by the worker's
|
|
55
|
+
* spawn fail-fast and the dashboard PUT endpoint so every config entry point
|
|
56
|
+
* (dashboard / /config / setup / hand-edited bots.json) hits the same gate. */
|
|
57
|
+
export declare function isValidRiffBaseUrl(v: unknown): v is string;
|
|
58
|
+
export interface RiffRepoRef {
|
|
59
|
+
/** Internal repo name, e.g. 'webinfra/agent-monorepo' (code.byted.org). */
|
|
60
|
+
repoName: string;
|
|
61
|
+
/** Branch to pin. Omitted → the repo's default branch. (The riff API
|
|
62
|
+
* ignores unknown fields like `branch`; `repoBranch` is the real one —
|
|
63
|
+
* verified empirically: it normalizes to gitRef/gitRefType/gitCommitId.) */
|
|
64
|
+
repoBranch?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize a git origin URL / repo spec to riff's internal repoName.
|
|
68
|
+
* Accepts `git@code.byted.org:group/repo.git`, `https://code.byted.org/group/repo(.git)`
|
|
69
|
+
* and bare `group/repo`. Returns null for non-internal hosts (github.com etc.) —
|
|
70
|
+
* the riff API validates repoName against the internal registry and cannot
|
|
71
|
+
* clone external repos.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseRiffRepoName(spec: string): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Derive the riff repo ref from a local checkout so a riff task executes
|
|
76
|
+
* against the same repo + branch the botmux session works in (复用本地仓库).
|
|
77
|
+
* All git calls are local (no network). Returns null when the workingDir is
|
|
78
|
+
* not a git repo or its origin is not an internal repo riff can clone.
|
|
79
|
+
* `warnings` surface states the sandbox cannot see (dirty tree, unpushed
|
|
80
|
+
* commits, never-pushed branch) — callers inject them as status lines.
|
|
81
|
+
*/
|
|
82
|
+
export declare function deriveRiffRepoFromWorkingDir(workingDir: string, runGit?: (args: string[]) => string | null): {
|
|
83
|
+
repo: RiffRepoRef;
|
|
84
|
+
warnings: string[];
|
|
85
|
+
} | null;
|
|
86
|
+
/**
|
|
87
|
+
* Multi-repo derivation over an EXPLICIT, ordered dir list — the repo-select
|
|
88
|
+
* card's 多仓库 flow stamps the user's chosen worktree dirs (in selection
|
|
89
|
+
* order) onto the session, and ONLY that stamp triggers multi-repo here. The
|
|
90
|
+
* first dir becomes riff's `primary` (sandbox cwd). Never scans children of an
|
|
91
|
+
* arbitrary non-git workingDir: a home dir / repo-collection dir would attach
|
|
92
|
+
* random unrelated repos to the task.
|
|
93
|
+
*/
|
|
94
|
+
export declare function deriveRiffReposFromDirs(dirs: string[], deriveOne?: typeof deriveRiffRepoFromWorkingDir): {
|
|
95
|
+
repos: RiffRepoRef[];
|
|
96
|
+
warnings: string[];
|
|
97
|
+
} | null;
|
|
98
|
+
/**
|
|
99
|
+
* Daemon-side orphan cancel: /close on a worker-less riff session must still
|
|
100
|
+
* cancel the persisted remote task (the sandbox agent otherwise keeps running
|
|
101
|
+
* with injected Lark credentials after the topic is closed). Bounded + one
|
|
102
|
+
* retry; failures are logged, never thrown.
|
|
103
|
+
*/
|
|
104
|
+
export declare function cancelRiffTaskById(cfg: {
|
|
105
|
+
baseUrl: string;
|
|
106
|
+
jwt?: string;
|
|
107
|
+
jwtEnv?: string;
|
|
108
|
+
}, taskId: string): Promise<boolean>;
|
|
109
|
+
/** Irreversible short hash of a sandbox URL for log correlation — the unique
|
|
110
|
+
* subdomain IS the write capability, so neither URL nor host may be logged. */
|
|
111
|
+
export declare function hashUrlForLog(u: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* RiffBackend — bridges botmux's SessionBackend interface to riff's HTTP API.
|
|
114
|
+
*
|
|
115
|
+
* Lifecycle:
|
|
116
|
+
* spawn() → initializes riff client (no actual task created yet)
|
|
117
|
+
* write(text) → creates a task (first write) or follow-up (subsequent writes)
|
|
118
|
+
* SSE output events flow through onData callback
|
|
119
|
+
* kill() → cancels current task via task-cancel
|
|
120
|
+
* onExit → fires on /close (kill) or unrecoverable error, NOT on task done
|
|
121
|
+
*
|
|
122
|
+
* SSE events use standard SSE format: event type in `event:` line, JSON in `data:` lines.
|
|
123
|
+
* Events: output (text chunks), status (state changes), init (full state + accessUrl),
|
|
124
|
+
* session_info (sandbox access info), done (task completion), log (verbose logs).
|
|
125
|
+
*/
|
|
126
|
+
export declare class RiffBackend implements SessionBackend {
|
|
127
|
+
private config;
|
|
128
|
+
private sessionId;
|
|
129
|
+
private dataCb;
|
|
130
|
+
private exitCb;
|
|
131
|
+
private accessUrlCb;
|
|
132
|
+
private taskDoneCb;
|
|
133
|
+
private taskIdCb;
|
|
134
|
+
private outputBuffer;
|
|
135
|
+
private currentTaskId;
|
|
136
|
+
private currentAccessUrl;
|
|
137
|
+
/** True when currentAccessUrl is the sandbox directAccessUrl (never downgrade it). */
|
|
138
|
+
private accessUrlIsDirect;
|
|
139
|
+
private abortController;
|
|
140
|
+
private killed;
|
|
141
|
+
/** /close teardown in progress — new writes are rejected and an in-flight
|
|
142
|
+
* create/follow-up must cancel its late task instead of streaming it. */
|
|
143
|
+
private closing;
|
|
144
|
+
private taskDone;
|
|
145
|
+
/** Tasks whose done event already fired the turn boundary — a duplicate
|
|
146
|
+
* done (observed live) or a stale stream must never re-fire it. Bounded:
|
|
147
|
+
* cleared past 64 entries (a session rarely exceeds a few dozen turns). */
|
|
148
|
+
private completedTaskIds;
|
|
149
|
+
private reconnectAttempts;
|
|
150
|
+
private maxReconnectAttempts;
|
|
151
|
+
/** 预算层级(单调覆盖,见 destroySession 注释);字段化以便测试注入边界。 */
|
|
152
|
+
private cancelTimeoutMs;
|
|
153
|
+
private createTimeoutMs;
|
|
154
|
+
private destroyDeadlineMs;
|
|
155
|
+
/** Serializes write() → createTask/followUp. Without this, a second message
|
|
156
|
+
* arriving before the first task-execute HTTP returns would see
|
|
157
|
+
* currentTaskId === null and create a duplicate task. */
|
|
158
|
+
private writeChain;
|
|
159
|
+
constructor(config: RiffBackendConfig, sessionId: string);
|
|
160
|
+
/** Called when the riff sandbox accessUrl becomes available or changes. */
|
|
161
|
+
onAccessUrl(cb: (url: string) => void): void;
|
|
162
|
+
/** Called when the current riff task completes or fails (turn boundary). */
|
|
163
|
+
onTaskDone(cb: () => void): void;
|
|
164
|
+
/** Called whenever a new task id becomes current (create/follow-up). The
|
|
165
|
+
* worker forwards it to the daemon so the follow-up lineage survives a
|
|
166
|
+
* daemon restart (currentTaskId otherwise lives only in this process). */
|
|
167
|
+
onTaskId(cb: (taskId: string | null) => void): void;
|
|
168
|
+
/** Resolve JWT dynamically — re-reads env/keychain each call so auto-refresh works. */
|
|
169
|
+
private getJwt;
|
|
170
|
+
private resolveJwt;
|
|
171
|
+
private readJwtFromBytecloudKeychain;
|
|
172
|
+
spawn(_bin: string, _args: string[], _opts: SpawnOpts): void;
|
|
173
|
+
write(data: string): void;
|
|
174
|
+
resize(_cols: number, _rows: number): void;
|
|
175
|
+
onData(cb: (data: string) => void): void;
|
|
176
|
+
onExit(cb: (code: number | null, signal: string | null) => void): void;
|
|
177
|
+
kill(): void;
|
|
178
|
+
destroySession(): Promise<void>;
|
|
179
|
+
getChildPid(): number | null;
|
|
180
|
+
captureCurrentScreen(): string;
|
|
181
|
+
captureViewport(): string;
|
|
182
|
+
getPaneSize(): {
|
|
183
|
+
cols: number;
|
|
184
|
+
rows: number;
|
|
185
|
+
} | null;
|
|
186
|
+
/**
|
|
187
|
+
* Emit a styled status line into the terminal stream. The worker renders
|
|
188
|
+
* this through a headless xterm — bare `\n` (no carriage return) makes
|
|
189
|
+
* lines stair-step to the right, which is the main reason the raw log view
|
|
190
|
+
* was hard to read. Always emit `\r\n` and reset ANSI styling per line.
|
|
191
|
+
*/
|
|
192
|
+
private emitLine;
|
|
193
|
+
/** Normalize newlines for xterm rendering (bare \n → \r\n, keep existing \r\n). */
|
|
194
|
+
private emitText;
|
|
195
|
+
private extractAttachments;
|
|
196
|
+
private basename;
|
|
197
|
+
private createTask;
|
|
198
|
+
private followUp;
|
|
199
|
+
/**
|
|
200
|
+
* Prepend the configured system prompt to the user prompt.
|
|
201
|
+
* The riff API has no separate system-prompt field (only userPrompt), so we
|
|
202
|
+
* fold the system prompt into the prompt text. config.systemPrompt takes
|
|
203
|
+
* precedence over the built-in DEFAULT_RIFF_SYSTEM_PROMPT. The result is
|
|
204
|
+
* wrapped in a <system> block so the agent can distinguish it from the user
|
|
205
|
+
* message. NOTE: setup commands (botmux install) are NOT injected here —
|
|
206
|
+
* they are sent to the riff API via config.setupCommands for reliability.
|
|
207
|
+
*/
|
|
208
|
+
private injectSystemPrompt;
|
|
209
|
+
/**
|
|
210
|
+
* Build the env object for the riff sandbox. Precedence (highest wins):
|
|
211
|
+
* 1. config.env (explicit per-bot riff config)
|
|
212
|
+
* 2. per-bot env from bots.json `env` (merged by the worker into config.env)
|
|
213
|
+
* Returns a clean Record with empty values dropped.
|
|
214
|
+
*/
|
|
215
|
+
private buildEnv;
|
|
216
|
+
private uploadAndCreate;
|
|
217
|
+
private readFileAsBlob;
|
|
218
|
+
/**
|
|
219
|
+
* Post-await adoption gate for a freshly created/followed-up task id.
|
|
220
|
+
* - closing(/close 竞态窗口):这个 late task 已经没有会话可服务——立即取消
|
|
221
|
+
* (有界+一次重试),绝不 stream/登记,防远端 orphan;
|
|
222
|
+
* - killed(detach:重启/休眠):登记 id 让 daemon 持久化血缘,但不 stream
|
|
223
|
+
* (任务合法续跑,重启后 follow-up 接上);
|
|
224
|
+
* - 正常:登记 + 由调用方启动 stream。
|
|
225
|
+
*/
|
|
226
|
+
private adoptLateTask;
|
|
227
|
+
/** Repos come exclusively from config.repos (worker-derived from the session
|
|
228
|
+
* workingDir). The old defaultRepo/defaultBranch bot config was removed —
|
|
229
|
+
* a stale bots.json value would silently shadow the workingDir derivation
|
|
230
|
+
* with no UI left to clear it. */
|
|
231
|
+
private buildRepos;
|
|
232
|
+
private cancelTask;
|
|
233
|
+
private streamTask;
|
|
234
|
+
private handleSseEvent;
|
|
235
|
+
/**
|
|
236
|
+
* Track the best sandbox URL for the "Web 终端" button.
|
|
237
|
+
* Preference: directAccessUrl (the AIO sandbox terminal, directly openable)
|
|
238
|
+
* over accessUrl (riff frontend page — hardcoded to the production domain
|
|
239
|
+
* even on BOE deployments, so its origin is rewritten to the configured
|
|
240
|
+
* baseUrl). A direct URL is never downgraded back to a frontend URL within
|
|
241
|
+
* the same task. Returns true when the current URL changed.
|
|
242
|
+
*/
|
|
243
|
+
private updateAccessUrl;
|
|
244
|
+
/** Rewrite a riff frontend URL onto the configured baseUrl origin (BOE vs prod). */
|
|
245
|
+
private rewriteToBaseOrigin;
|
|
246
|
+
/** One-shot task-detail fetch to pick up directAccessUrl (not present in SSE events). */
|
|
247
|
+
private fetchDirectAccessUrl;
|
|
248
|
+
private emitError;
|
|
249
|
+
private fetchAndEmitOutput;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=riff-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"riff-backend.d.ts","sourceRoot":"","sources":["../../../src/adapters/backend/riff-backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAuD5D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB;iEAC6D;IAC7D,kBAAkB,CAAC,EAAE,M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