orquesta-agent 0.2.202 → 0.2.204
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 +22 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +105 -9
- package/dist/executor.js.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/supabase.d.ts +22 -3
- package/dist/supabase.d.ts.map +1 -1
- package/dist/supabase.js +8 -3
- 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
|
@@ -165,7 +165,28 @@ export interface StartSessionOptions {
|
|
|
165
165
|
* flag. Supported by claude + orquesta-cli; ignored for kimi (no such flag).
|
|
166
166
|
*/
|
|
167
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;
|
|
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;
|
|
168
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[];
|
|
169
190
|
/**
|
|
170
191
|
* Start an interactive Claude CLI session.
|
|
171
192
|
* The session runs with --dangerously-skip-permissions for uninterrupted interaction.
|
|
@@ -175,7 +196,7 @@ export declare function startSession(options: StartSessionOptions): Promise<bool
|
|
|
175
196
|
* Send input to the active interactive session.
|
|
176
197
|
* This writes directly to Claude CLI's stdin.
|
|
177
198
|
* If raw=true, write the input byte(s) directly without appending Enter (used for ESC, Ctrl+C).
|
|
178
|
-
* If attachments are provided, they're downloaded to /
|
|
199
|
+
* If attachments are provided, they're downloaded to ~/.cache/orquesta-attachments and
|
|
179
200
|
* their absolute paths are appended to the message text so Claude can Read them.
|
|
180
201
|
*/
|
|
181
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,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEhF;AAGD,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE/D;AAGD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,YAAY,CAAA;AAOlD,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UA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;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAMvE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAGlD;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAA;CACzC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,WAAW,EAAE,CAe9C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAe3M;AAsBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAmBzD"}
|
package/dist/executor.js
CHANGED
|
@@ -22,7 +22,7 @@ import * as logger from './logger.js';
|
|
|
22
22
|
// ESM require for resolving 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';
|
|
@@ -945,7 +945,7 @@ async function processAttachments(attachments) {
|
|
|
945
945
|
switch (category) {
|
|
946
946
|
case 'image':
|
|
947
947
|
// Claude resolves @filename relative to cwd, and the file lives in
|
|
948
|
-
// /
|
|
948
|
+
// ~/.cache/orquesta-attachments/, so @basename never resolves. Give the
|
|
949
949
|
// absolute path and tell Claude to Read it — Claude's Read tool returns
|
|
950
950
|
// base64 image content for image files.
|
|
951
951
|
fileReferences.push(localPath);
|
|
@@ -2973,12 +2973,89 @@ function startRogerthatMonitor(sessionId) {
|
|
|
2973
2973
|
export function setOnSessionEnded(cb) {
|
|
2974
2974
|
onSessionEndedCallback = cb;
|
|
2975
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
|
+
}
|
|
2976
3053
|
/**
|
|
2977
3054
|
* Start an interactive Claude CLI session.
|
|
2978
3055
|
* The session runs with --dangerously-skip-permissions for uninterrupted interaction.
|
|
2979
3056
|
*/
|
|
2980
3057
|
export async function startSession(options) {
|
|
2981
|
-
const { sessionId, workingDirectory, channel, cols = 120, rows = 40, subAgentId, subAgentName, resume } = options;
|
|
3058
|
+
const { sessionId, workingDirectory, channel, cols = 120, rows = 40, subAgentId, subAgentName, resume, resumeSessionId } = options;
|
|
2982
3059
|
// If this exact sessionId is already live, terminate it before re-creating.
|
|
2983
3060
|
// Sessions on OTHER workstreams are left untouched — they run concurrently.
|
|
2984
3061
|
if (sessions.has(sessionId)) {
|
|
@@ -3019,6 +3096,16 @@ export async function startSession(options) {
|
|
|
3019
3096
|
// resolves identically inside bwrap (/ is ro-bound). cliCommand stays the TYPE.
|
|
3020
3097
|
const cliBinary = cliCommand === 'kimi' ? (resolveKimiBinary() || 'kimi') : cliCommand;
|
|
3021
3098
|
logger.info(`Interactive session CLI: ${cliCommand}${cliCommand === 'kimi' ? ` (${cliBinary})` : ''}`);
|
|
3099
|
+
// Best-effort model + cli label reported in session:started so the dashboard
|
|
3100
|
+
// can tag the interactive prompt (same mapping dispatched prompts use on
|
|
3101
|
+
// completion). claude's exact model isn't knowable from a raw PTY, so it falls
|
|
3102
|
+
// back to ANTHROPIC_MODEL when set, else undefined.
|
|
3103
|
+
const sessionModel = cliCommand === 'kimi'
|
|
3104
|
+
? 'kimi-for-coding'
|
|
3105
|
+
: cliCommand === 'orquesta'
|
|
3106
|
+
? ((globalCliEndpoint === 'batuta' || !globalCliEndpoint) ? 'batuta-auto' : globalCliEndpoint)
|
|
3107
|
+
: (process.env.ANTHROPIC_MODEL || undefined);
|
|
3108
|
+
const sessionCliType = cliCommand === 'orquesta' ? 'orquesta' : cliCommand === 'kimi' ? 'kimi' : 'claude';
|
|
3022
3109
|
// Filter undefined env values — node-pty requires Record<string, string>.
|
|
3023
3110
|
// In strict sandbox mode, sandboxEnv() first reduces to the allowlist so the
|
|
3024
3111
|
// interactive CLI can't read unrelated host secrets from its own env.
|
|
@@ -3125,9 +3212,18 @@ export async function startSession(options) {
|
|
|
3125
3212
|
// cli.ts) both reattach the latest session non-interactively; kimi has no
|
|
3126
3213
|
// resume flag, so the option is silently ignored there. Prepended so it's an
|
|
3127
3214
|
// unambiguous standalone flag, separate from --append-system-prompt's value.
|
|
3128
|
-
if (resume && cliCommand !== 'kimi') {
|
|
3129
|
-
|
|
3130
|
-
|
|
3215
|
+
if ((resume || resumeSessionId) && cliCommand !== 'kimi') {
|
|
3216
|
+
// claude can target a SPECIFIC past conversation by id (--resume <id>);
|
|
3217
|
+
// orquesta-cli only reattaches the latest (--continue). So when a specific
|
|
3218
|
+
// id is requested and we're on claude, use --resume; otherwise --continue.
|
|
3219
|
+
if (resumeSessionId && cliCommand === 'claude') {
|
|
3220
|
+
ptyArgs.unshift('--resume', resumeSessionId);
|
|
3221
|
+
logger.info(`[Session] Resuming conversation ${resumeSessionId} (--resume) for ${cliCommand}`);
|
|
3222
|
+
}
|
|
3223
|
+
else {
|
|
3224
|
+
ptyArgs.unshift('--continue');
|
|
3225
|
+
logger.info(`[Session] Resuming most recent conversation (--continue) for ${cliCommand}`);
|
|
3226
|
+
}
|
|
3131
3227
|
}
|
|
3132
3228
|
// Per-project endpoint override (only the orquesta CLI understands --endpoint).
|
|
3133
3229
|
if (cliCommand === 'orquesta' && globalCliEndpoint) {
|
|
@@ -3259,7 +3355,7 @@ export async function startSession(options) {
|
|
|
3259
3355
|
// Confirm session is ready on first output from Claude
|
|
3260
3356
|
if (!sessionStartedSent) {
|
|
3261
3357
|
sessionStartedSent = true;
|
|
3262
|
-
sendSessionStarted(channel, sessionId, cwd,
|
|
3358
|
+
sendSessionStarted(channel, sessionId, cwd, sessionCliType, { id: subAgentId, name: subAgentName }, sessionModel);
|
|
3263
3359
|
}
|
|
3264
3360
|
// Append to buffer; schedule flush if not already pending
|
|
3265
3361
|
outputBuffer += data;
|
|
@@ -3272,7 +3368,7 @@ export async function startSession(options) {
|
|
|
3272
3368
|
if (!sessionStartedSent) {
|
|
3273
3369
|
sessionStartedSent = true;
|
|
3274
3370
|
logger.warn('[Session] No initial output after 5s, sending session:started anyway');
|
|
3275
|
-
sendSessionStarted(channel, sessionId, cwd,
|
|
3371
|
+
sendSessionStarted(channel, sessionId, cwd, sessionCliType, { id: subAgentId, name: subAgentName }, sessionModel);
|
|
3276
3372
|
}
|
|
3277
3373
|
}, 5000);
|
|
3278
3374
|
// Handle PTY exit
|
|
@@ -3324,7 +3420,7 @@ export async function startSession(options) {
|
|
|
3324
3420
|
* Send input to the active interactive session.
|
|
3325
3421
|
* This writes directly to Claude CLI's stdin.
|
|
3326
3422
|
* If raw=true, write the input byte(s) directly without appending Enter (used for ESC, Ctrl+C).
|
|
3327
|
-
* If attachments are provided, they're downloaded to /
|
|
3423
|
+
* If attachments are provided, they're downloaded to ~/.cache/orquesta-attachments and
|
|
3328
3424
|
* their absolute paths are appended to the message text so Claude can Read them.
|
|
3329
3425
|
*/
|
|
3330
3426
|
export function sendSessionInput(sessionId, input, raw = false, attachments) {
|