orchestrar 0.3.5 → 0.3.6

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.
Files changed (2) hide show
  1. package/orchestrator.js +31 -11
  2. package/package.json +1 -1
package/orchestrator.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require("node:fs/promises");
4
4
  const path = require("node:path");
5
+ const crypto = require("node:crypto");
5
6
  const DEFAULT_MODEL = "github-copilot/gpt-5.2-codex";
6
7
  const COMMIT_MODEL = "github-copilot/gpt-5-mini";
7
8
  const DEFAULT_AGENT = "build-gpt-5.2-codex";
@@ -229,12 +230,14 @@ async function sendPrompt(
229
230
  logDebug(
230
231
  `Sending prompt to session ${sessionID}: ${summarizeText(text, 160)}`
231
232
  );
232
- const response = await callClient(
233
- "session.prompt",
234
- client.session.prompt({
233
+ const messageID = generateMessageID();
234
+ await callClient(
235
+ "session.promptAsync",
236
+ client.session.promptAsync({
235
237
  path: { id: sessionID },
236
238
  query: { directory: root },
237
239
  body: {
240
+ messageID,
238
241
  agent: agentSpec,
239
242
  model,
240
243
  parts: [{ type: "text", text }],
@@ -242,7 +245,7 @@ async function sendPrompt(
242
245
  })
243
246
  );
244
247
 
245
- return extractMessageID(response);
248
+ return messageID;
246
249
  }
247
250
 
248
251
  async function waitForSessionIdle(client, sessionID, root, timeoutOverrideMs) {
@@ -326,13 +329,26 @@ async function waitForMessageComplete(
326
329
  let attempt = 0;
327
330
  while (Date.now() - start < timeoutMs) {
328
331
  attempt += 1;
329
- const message = await callClient(
330
- "session.message",
331
- client.session.message({
332
- path: { id: sessionID, messageID },
333
- query: { directory: root },
334
- })
335
- );
332
+ let message;
333
+ try {
334
+ message = await callClient(
335
+ "session.message",
336
+ client.session.message({
337
+ path: { id: sessionID, messageID },
338
+ query: { directory: root },
339
+ })
340
+ );
341
+ } catch (error) {
342
+ const formatted = formatError(error).toLowerCase();
343
+ if (formatted.includes("not found") || formatted.includes("404")) {
344
+ logDebug(
345
+ `Message poll ${attempt}: message=${messageID}, not found yet`
346
+ );
347
+ await delay(pollIntervalMs);
348
+ continue;
349
+ }
350
+ throw error;
351
+ }
336
352
  const info = message?.info ?? message;
337
353
  logDebug(
338
354
  `Message poll ${attempt}: message=${messageID}, completed=${
@@ -711,6 +727,10 @@ function summarizeText(text, maxLength) {
711
727
  return `${trimmed.slice(0, maxLength)}...`;
712
728
  }
713
729
 
730
+ function generateMessageID() {
731
+ return `msg_${crypto.randomBytes(12).toString("hex")}`;
732
+ }
733
+
714
734
  main().catch((error) => {
715
735
  console.error(`[orchestrator] Failed: ${formatError(error)}`);
716
736
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrar",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "OpenCode milestone orchestrator",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",