orchestrar 0.1.0 → 0.3.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/LICENSE +21 -0
- package/orchestrator.js +56 -6
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Darko Luketic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/orchestrator.js
CHANGED
|
@@ -4,6 +4,8 @@ const fs = require("node:fs/promises");
|
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const DEFAULT_MODEL = "github-copilot/gpt-5.2-codex";
|
|
6
6
|
const COMMIT_MODEL = "github-copilot/gpt-5-mini";
|
|
7
|
+
const DEFAULT_AGENT = "build-gpt-5.2-codex";
|
|
8
|
+
const COMMIT_AGENT = "build";
|
|
7
9
|
const DEFAULT_REVIEW_COMMAND_NAME = "review-uncommited";
|
|
8
10
|
const DEFAULT_REVIEW_COMMAND_ARGUMENTS = "";
|
|
9
11
|
const DEFAULT_REVIEW_TIMEOUT_MS = 60 * 60 * 1000;
|
|
@@ -45,7 +47,7 @@ async function runWorkInstance(createOpencode, docs, root) {
|
|
|
45
47
|
"session.create"
|
|
46
48
|
);
|
|
47
49
|
|
|
48
|
-
const sessionID = session.
|
|
50
|
+
const sessionID = extractSessionID(session, "session.create (work instance)");
|
|
49
51
|
const promptPaths = buildPromptPaths(docs, root);
|
|
50
52
|
|
|
51
53
|
await sendPrompt(
|
|
@@ -83,13 +85,14 @@ async function runCommitInstance(createOpencode, root) {
|
|
|
83
85
|
"session.create"
|
|
84
86
|
);
|
|
85
87
|
|
|
86
|
-
const sessionID = session.
|
|
88
|
+
const sessionID = extractSessionID(session, "session.create (commit instance)");
|
|
87
89
|
await sendPrompt(
|
|
88
90
|
client,
|
|
89
91
|
sessionID,
|
|
90
92
|
buildCommitPrompt(),
|
|
91
93
|
root,
|
|
92
|
-
COMMIT_MODEL
|
|
94
|
+
COMMIT_MODEL,
|
|
95
|
+
COMMIT_AGENT
|
|
93
96
|
);
|
|
94
97
|
await waitForSessionIdle(client, sessionID, root);
|
|
95
98
|
} finally {
|
|
@@ -153,7 +156,7 @@ async function runReviewCommand(createOpencode, root) {
|
|
|
153
156
|
"session.create"
|
|
154
157
|
);
|
|
155
158
|
|
|
156
|
-
const sessionID = session.
|
|
159
|
+
const sessionID = extractSessionID(session, "session.create (review instance)");
|
|
157
160
|
const commandResult = await unwrap(
|
|
158
161
|
client.session.command({
|
|
159
162
|
path: { id: sessionID },
|
|
@@ -161,6 +164,7 @@ async function runReviewCommand(createOpencode, root) {
|
|
|
161
164
|
body: {
|
|
162
165
|
command: commandName,
|
|
163
166
|
arguments: commandArguments,
|
|
167
|
+
agent: DEFAULT_AGENT,
|
|
164
168
|
model: DEFAULT_MODEL,
|
|
165
169
|
},
|
|
166
170
|
}),
|
|
@@ -197,7 +201,8 @@ async function sendPrompt(
|
|
|
197
201
|
sessionID,
|
|
198
202
|
text,
|
|
199
203
|
root,
|
|
200
|
-
modelSpec = DEFAULT_MODEL
|
|
204
|
+
modelSpec = DEFAULT_MODEL,
|
|
205
|
+
agentSpec = DEFAULT_AGENT
|
|
201
206
|
) {
|
|
202
207
|
const model = parseModelSpec(modelSpec);
|
|
203
208
|
await unwrap(
|
|
@@ -205,6 +210,7 @@ async function sendPrompt(
|
|
|
205
210
|
path: { id: sessionID },
|
|
206
211
|
query: { directory: root },
|
|
207
212
|
body: {
|
|
213
|
+
agent: agentSpec,
|
|
208
214
|
model,
|
|
209
215
|
parts: [{ type: "text", text }],
|
|
210
216
|
},
|
|
@@ -233,7 +239,11 @@ async function waitForSessionIdle(client, sessionID, root, timeoutOverrideMs) {
|
|
|
233
239
|
);
|
|
234
240
|
const status = statusMap?.[sessionID];
|
|
235
241
|
if (!status) {
|
|
236
|
-
|
|
242
|
+
const knownSessions = statusMap ? Object.keys(statusMap) : [];
|
|
243
|
+
const knownList = knownSessions.length ? knownSessions.join(", ") : "none";
|
|
244
|
+
throw new Error(
|
|
245
|
+
`Session status missing for ${sessionID}. Known sessions: ${knownList}.`
|
|
246
|
+
);
|
|
237
247
|
}
|
|
238
248
|
if (status.type === "idle") {
|
|
239
249
|
return;
|
|
@@ -446,6 +456,46 @@ function unwrap(result, label) {
|
|
|
446
456
|
return result;
|
|
447
457
|
}
|
|
448
458
|
|
|
459
|
+
function extractSessionID(session, context) {
|
|
460
|
+
if (!session || typeof session !== "object") {
|
|
461
|
+
throw new Error(`${context} did not return a session object.`);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const candidates = [
|
|
465
|
+
session.id,
|
|
466
|
+
session.sessionID,
|
|
467
|
+
session.info?.id,
|
|
468
|
+
session.info?.sessionID,
|
|
469
|
+
session.properties?.id,
|
|
470
|
+
session.properties?.sessionID,
|
|
471
|
+
session.properties?.info?.id,
|
|
472
|
+
session.properties?.info?.sessionID,
|
|
473
|
+
session.slug,
|
|
474
|
+
];
|
|
475
|
+
|
|
476
|
+
for (const candidate of candidates) {
|
|
477
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
478
|
+
return candidate;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
throw new Error(
|
|
483
|
+
`${context} returned a session without an id. Response: ${safeStringify(session)}`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function safeStringify(value, maxLength = 1000) {
|
|
488
|
+
try {
|
|
489
|
+
const json = JSON.stringify(value);
|
|
490
|
+
if (typeof json === "string" && json.length > 0) {
|
|
491
|
+
return json.length > maxLength ? `${json.slice(0, maxLength)}...` : json;
|
|
492
|
+
}
|
|
493
|
+
} catch (error) {
|
|
494
|
+
// fall through to String()
|
|
495
|
+
}
|
|
496
|
+
return String(value);
|
|
497
|
+
}
|
|
498
|
+
|
|
449
499
|
function formatError(error) {
|
|
450
500
|
if (!error) {
|
|
451
501
|
return "Unknown error";
|