orquesta-agent 0.2.201 → 0.2.203
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/executor.d.ts +28 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +109 -6
- package/dist/executor.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/socketio-transport.d.ts +1 -0
- package/dist/socketio-transport.d.ts.map +1 -1
- package/dist/supabase.d.ts +20 -1
- package/dist/supabase.d.ts.map +1 -1
- package/dist/supabase.js +4 -1
- package/dist/supabase.js.map +1 -1
- package/dist/ws-client.d.ts +9 -0
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +11 -0
- package/dist/ws-client.js.map +1 -1
- package/package.json +1 -1
package/dist/executor.d.ts
CHANGED
|
@@ -159,7 +159,34 @@ export interface StartSessionOptions {
|
|
|
159
159
|
/** Workstream (sub-agent) this session belongs to. undefined = default slot. */
|
|
160
160
|
subAgentId?: string;
|
|
161
161
|
subAgentName?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Resume the most recent conversation in this working directory instead of
|
|
164
|
+
* starting fresh (dashboard "Resume" button). Maps to the CLI's --continue
|
|
165
|
+
* flag. Supported by claude + orquesta-cli; ignored for kimi (no such flag).
|
|
166
|
+
*/
|
|
167
|
+
resume?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Resume a SPECIFIC prior conversation by its id (dashboard Resume menu →
|
|
170
|
+
* "past conversations"). Maps to claude's `--resume <id>`. When set it takes
|
|
171
|
+
* precedence over the plain `resume` (--continue). orquesta/kimi have no
|
|
172
|
+
* per-id resume, so they fall back to --continue.
|
|
173
|
+
*/
|
|
174
|
+
resumeSessionId?: string;
|
|
162
175
|
}
|
|
176
|
+
export interface ResumableSession {
|
|
177
|
+
sessionId: string;
|
|
178
|
+
label: string;
|
|
179
|
+
/** ISO timestamp of the transcript's last modification. */
|
|
180
|
+
when?: string;
|
|
181
|
+
subAgentId?: string | null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Enumerate resumable past conversations for a working directory by reading
|
|
185
|
+
* claude's transcript dir (~/.claude/projects/<encoded cwd>/<sessionId>.jsonl).
|
|
186
|
+
* Newest first, capped. Best-effort — returns [] on any error or when the dir
|
|
187
|
+
* doesn't exist (e.g. no prior claude sessions in this cwd).
|
|
188
|
+
*/
|
|
189
|
+
export declare function listResumableSessions(workingDir: string, subAgentId?: string | null, limit?: number): ResumableSession[];
|
|
163
190
|
/**
|
|
164
191
|
* Start an interactive Claude CLI session.
|
|
165
192
|
* The session runs with --dangerously-skip-permissions for uninterrupted interaction.
|
|
@@ -169,7 +196,7 @@ export declare function startSession(options: StartSessionOptions): Promise<bool
|
|
|
169
196
|
* Send input to the active interactive session.
|
|
170
197
|
* This writes directly to Claude CLI's stdin.
|
|
171
198
|
* If raw=true, write the input byte(s) directly without appending Enter (used for ESC, Ctrl+C).
|
|
172
|
-
* If attachments are provided, they're downloaded to /
|
|
199
|
+
* If attachments are provided, they're downloaded to ~/.cache/orquesta-attachments and
|
|
173
200
|
* their absolute paths are appended to the message text so Claude can Read them.
|
|
174
201
|
*/
|
|
175
202
|
export declare function sendSessionInput(sessionId: string, input: string, raw?: boolean, attachments?: Attachment[]): boolean;
|
package/dist/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAiCtD,OAAO,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAiCtD,OAAO,EAAgG,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAgO7I,wBAAgB,sBAAsB,CAAC,WAAW,EAA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the bundled orquesta-cli entry on Windows (see the
|
|
23
23
|
// interactive-session spawn — node-pty can't launch the `.cmd` shim).
|
|
24
24
|
const nodeRequire = createRequire(import.meta.url);
|
|
25
|
-
import { isSandboxAvailable, buildBwrapArgs, shQuote, ensureStrictProjectDirs } from './sandbox.js';
|
|
25
|
+
import { isSandboxAvailable, buildBwrapArgs, shQuote, ensureStrictProjectDirs, encodeClaudeProjectDir } from './sandbox.js';
|
|
26
26
|
import { parseCoordSpec, runCoordination } from './coordination.js';
|
|
27
27
|
import { sendOutput, sendComplete, sendError, sendSupervisionRequest, sendExecutionResumed, updatePromptStatus, persistOutputLogs, clearOutputBuffer, sendRequirement, persistRequirement, sendQAInstructions, persistQAInstructions, sendPlanItemsGenerated, sendSessionOutput, sendSessionStarted, sendSessionEnded, sendSessionError, reportAgentError } from './supabase.js';
|
|
28
28
|
import { createThinkingLog, createToolCallLog, createToolResultLog, createOutputLog, createErrorLog, createSystemLog, } from './types/agent-logs.js';
|
|
@@ -860,8 +860,16 @@ export async function gitCommitAndPush(targetDir, message) {
|
|
|
860
860
|
// ============================================
|
|
861
861
|
// Attachment Processing
|
|
862
862
|
// ============================================
|
|
863
|
-
// Temp directory for downloaded attachments
|
|
864
|
-
|
|
863
|
+
// Temp directory for downloaded attachments.
|
|
864
|
+
//
|
|
865
|
+
// MUST live under ~/.cache (not os.tmpdir()/'/tmp'): the agent downloads the
|
|
866
|
+
// file here OUTSIDE the sandbox, then hands the CLI the absolute path to Read it
|
|
867
|
+
// from INSIDE the sandbox. In strict mode the sandbox gets a PRIVATE /tmp tmpfs
|
|
868
|
+
// (sandbox.ts), so anything the agent writes to the host /tmp is invisible to the
|
|
869
|
+
// spawned CLI — attachments silently never reach it. ~/.cache is re-bound rw into
|
|
870
|
+
// the strict jail (see userWritable in sandbox.ts), so the same path resolves to
|
|
871
|
+
// the same file both outside and inside, in every mode.
|
|
872
|
+
const ATTACHMENT_TEMP_DIR = path.join(os.homedir(), '.cache', 'orquesta-attachments');
|
|
865
873
|
/**
|
|
866
874
|
* Download an attachment from URL and save to temp file.
|
|
867
875
|
* Returns the local file path.
|
|
@@ -937,7 +945,7 @@ async function processAttachments(attachments) {
|
|
|
937
945
|
switch (category) {
|
|
938
946
|
case 'image':
|
|
939
947
|
// Claude resolves @filename relative to cwd, and the file lives in
|
|
940
|
-
// /
|
|
948
|
+
// ~/.cache/orquesta-attachments/, so @basename never resolves. Give the
|
|
941
949
|
// absolute path and tell Claude to Read it — Claude's Read tool returns
|
|
942
950
|
// base64 image content for image files.
|
|
943
951
|
fileReferences.push(localPath);
|
|
@@ -2965,12 +2973,89 @@ function startRogerthatMonitor(sessionId) {
|
|
|
2965
2973
|
export function setOnSessionEnded(cb) {
|
|
2966
2974
|
onSessionEndedCallback = cb;
|
|
2967
2975
|
}
|
|
2976
|
+
/** Collapse whitespace and cap a derived label. */
|
|
2977
|
+
function truncateLabel(s, n = 60) {
|
|
2978
|
+
const oneLine = s.replace(/\s+/g, ' ').trim();
|
|
2979
|
+
return oneLine.length > n ? oneLine.slice(0, n - 1) + '…' : oneLine;
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Best-effort: derive a human label from a claude transcript by reading the
|
|
2983
|
+
* first ~64KB and pulling the first user message. Returns null if none found.
|
|
2984
|
+
*/
|
|
2985
|
+
function deriveSessionLabel(file) {
|
|
2986
|
+
try {
|
|
2987
|
+
const fd = fs.openSync(file, 'r');
|
|
2988
|
+
const buf = Buffer.alloc(65536);
|
|
2989
|
+
const n = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
2990
|
+
fs.closeSync(fd);
|
|
2991
|
+
const raw = buf.subarray(0, n).toString('utf-8');
|
|
2992
|
+
for (const line of raw.split('\n')) {
|
|
2993
|
+
if (!line.trim())
|
|
2994
|
+
continue;
|
|
2995
|
+
let obj;
|
|
2996
|
+
try {
|
|
2997
|
+
obj = JSON.parse(line);
|
|
2998
|
+
}
|
|
2999
|
+
catch {
|
|
3000
|
+
continue;
|
|
3001
|
+
}
|
|
3002
|
+
const isUser = obj?.type === 'user' || obj?.message?.role === 'user';
|
|
3003
|
+
if (!isUser)
|
|
3004
|
+
continue;
|
|
3005
|
+
const c = (obj?.message?.content ?? obj?.content);
|
|
3006
|
+
const text = typeof c === 'string'
|
|
3007
|
+
? c
|
|
3008
|
+
: Array.isArray(c)
|
|
3009
|
+
? c.map(p => (typeof p === 'string' ? p : (p?.text || ''))).join(' ')
|
|
3010
|
+
: '';
|
|
3011
|
+
if (text.trim())
|
|
3012
|
+
return truncateLabel(text);
|
|
3013
|
+
}
|
|
3014
|
+
return null;
|
|
3015
|
+
}
|
|
3016
|
+
catch {
|
|
3017
|
+
return null;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Enumerate resumable past conversations for a working directory by reading
|
|
3022
|
+
* claude's transcript dir (~/.claude/projects/<encoded cwd>/<sessionId>.jsonl).
|
|
3023
|
+
* Newest first, capped. Best-effort — returns [] on any error or when the dir
|
|
3024
|
+
* doesn't exist (e.g. no prior claude sessions in this cwd).
|
|
3025
|
+
*/
|
|
3026
|
+
export function listResumableSessions(workingDir, subAgentId, limit = 12) {
|
|
3027
|
+
try {
|
|
3028
|
+
const dir = path.join(os.homedir(), '.claude', 'projects', encodeClaudeProjectDir(workingDir));
|
|
3029
|
+
const items = fs.readdirSync(dir)
|
|
3030
|
+
.filter(f => f.endsWith('.jsonl'))
|
|
3031
|
+
.map(f => {
|
|
3032
|
+
const full = path.join(dir, f);
|
|
3033
|
+
let mtime = 0;
|
|
3034
|
+
try {
|
|
3035
|
+
mtime = fs.statSync(full).mtimeMs;
|
|
3036
|
+
}
|
|
3037
|
+
catch { /* skip stat errors */ }
|
|
3038
|
+
return { full, mtime, sessionId: f.replace(/\.jsonl$/, '') };
|
|
3039
|
+
})
|
|
3040
|
+
.sort((a, b) => b.mtime - a.mtime)
|
|
3041
|
+
.slice(0, limit);
|
|
3042
|
+
return items.map(it => ({
|
|
3043
|
+
sessionId: it.sessionId,
|
|
3044
|
+
label: deriveSessionLabel(it.full) || 'Conversation',
|
|
3045
|
+
when: it.mtime ? new Date(it.mtime).toISOString() : undefined,
|
|
3046
|
+
subAgentId: subAgentId ?? null,
|
|
3047
|
+
}));
|
|
3048
|
+
}
|
|
3049
|
+
catch {
|
|
3050
|
+
return [];
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
2968
3053
|
/**
|
|
2969
3054
|
* Start an interactive Claude CLI session.
|
|
2970
3055
|
* The session runs with --dangerously-skip-permissions for uninterrupted interaction.
|
|
2971
3056
|
*/
|
|
2972
3057
|
export async function startSession(options) {
|
|
2973
|
-
const { sessionId, workingDirectory, channel, cols = 120, rows = 40, subAgentId, subAgentName } = options;
|
|
3058
|
+
const { sessionId, workingDirectory, channel, cols = 120, rows = 40, subAgentId, subAgentName, resume, resumeSessionId } = options;
|
|
2974
3059
|
// If this exact sessionId is already live, terminate it before re-creating.
|
|
2975
3060
|
// Sessions on OTHER workstreams are left untouched — they run concurrently.
|
|
2976
3061
|
if (sessions.has(sessionId)) {
|
|
@@ -3112,6 +3197,24 @@ export async function startSession(options) {
|
|
|
3112
3197
|
? ['--dangerously-skip-permissions', '--append-system-prompt-file', sysPromptFile]
|
|
3113
3198
|
: ['--dangerously-skip-permissions', '--append-system-prompt', systemPromptBlock];
|
|
3114
3199
|
}
|
|
3200
|
+
// Resume the most recent conversation in this cwd when requested (dashboard
|
|
3201
|
+
// "Resume" button). claude (-c/--continue) and orquesta-cli (--continue, see
|
|
3202
|
+
// cli.ts) both reattach the latest session non-interactively; kimi has no
|
|
3203
|
+
// resume flag, so the option is silently ignored there. Prepended so it's an
|
|
3204
|
+
// unambiguous standalone flag, separate from --append-system-prompt's value.
|
|
3205
|
+
if ((resume || resumeSessionId) && cliCommand !== 'kimi') {
|
|
3206
|
+
// claude can target a SPECIFIC past conversation by id (--resume <id>);
|
|
3207
|
+
// orquesta-cli only reattaches the latest (--continue). So when a specific
|
|
3208
|
+
// id is requested and we're on claude, use --resume; otherwise --continue.
|
|
3209
|
+
if (resumeSessionId && cliCommand === 'claude') {
|
|
3210
|
+
ptyArgs.unshift('--resume', resumeSessionId);
|
|
3211
|
+
logger.info(`[Session] Resuming conversation ${resumeSessionId} (--resume) for ${cliCommand}`);
|
|
3212
|
+
}
|
|
3213
|
+
else {
|
|
3214
|
+
ptyArgs.unshift('--continue');
|
|
3215
|
+
logger.info(`[Session] Resuming most recent conversation (--continue) for ${cliCommand}`);
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3115
3218
|
// Per-project endpoint override (only the orquesta CLI understands --endpoint).
|
|
3116
3219
|
if (cliCommand === 'orquesta' && globalCliEndpoint) {
|
|
3117
3220
|
ptyArgs.push('--endpoint', globalCliEndpoint);
|
|
@@ -3307,7 +3410,7 @@ export async function startSession(options) {
|
|
|
3307
3410
|
* Send input to the active interactive session.
|
|
3308
3411
|
* This writes directly to Claude CLI's stdin.
|
|
3309
3412
|
* If raw=true, write the input byte(s) directly without appending Enter (used for ESC, Ctrl+C).
|
|
3310
|
-
* If attachments are provided, they're downloaded to /
|
|
3413
|
+
* If attachments are provided, they're downloaded to ~/.cache/orquesta-attachments and
|
|
3311
3414
|
* their absolute paths are appended to the message text so Claude can Read them.
|
|
3312
3415
|
*/
|
|
3313
3416
|
export function sendSessionInput(sessionId, input, raw = false, attachments) {
|