@defend-tech/opencode-optima 0.1.14 → 0.1.15

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/index.js CHANGED
@@ -9207,24 +9207,30 @@ async function createOpenCodeSession(client, { title, directory } = {}) {
9207
9207
  const result = await client.session.create({ query: { directory }, body: { title } });
9208
9208
  return result?.data?.id || result?.id;
9209
9209
  }
9210
- async function callOpenCodePromptWithPathFallback(method, sessionId, payload) {
9210
+ async function callOpenCodePromptWithFallbacks(method, sessionId, flatPayload, structuredPayload) {
9211
9211
  try {
9212
- return await method({ ...payload, path: { sessionID: sessionId } });
9213
- } catch (error) {
9212
+ return await method({ sessionID: sessionId, ...flatPayload });
9213
+ } catch (flatError) {
9214
9214
  try {
9215
- return await method({ ...payload, path: { id: sessionId } });
9215
+ return await method({ ...structuredPayload, path: { sessionID: sessionId } });
9216
9216
  } catch {
9217
- throw error;
9217
+ try {
9218
+ return await method({ ...structuredPayload, path: { id: sessionId } });
9219
+ } catch {
9220
+ throw flatError;
9221
+ }
9218
9222
  }
9219
9223
  }
9220
9224
  }
9221
9225
  async function sendOpenCodeSessionEvent(client, { sessionId, agent, text, directory } = {}) {
9222
- const payload = { query: { directory }, body: { agent, parts: [{ type: "text", text }] } };
9226
+ const parts = [{ type: "text", text }];
9227
+ const flatPayload = { directory, agent, parts };
9228
+ const structuredPayload = { query: { directory }, body: { agent, parts } };
9223
9229
  if (typeof client?.session?.prompt === "function") {
9224
- return callOpenCodePromptWithPathFallback(client.session.prompt.bind(client.session), sessionId, payload);
9230
+ return callOpenCodePromptWithFallbacks(client.session.prompt.bind(client.session), sessionId, flatPayload, structuredPayload);
9225
9231
  }
9226
9232
  if (typeof client?.session?.promptAsync === "function") {
9227
- return callOpenCodePromptWithPathFallback(client.session.promptAsync.bind(client.session), sessionId, payload);
9233
+ return callOpenCodePromptWithFallbacks(client.session.promptAsync.bind(client.session), sessionId, flatPayload, structuredPayload);
9228
9234
  }
9229
9235
  throw new Error("OpenCode client does not expose session.prompt or session.promptAsync.");
9230
9236
  }
@@ -9214,24 +9214,30 @@ async function createOpenCodeSession(client, { title, directory } = {}) {
9214
9214
  const result = await client.session.create({ query: { directory }, body: { title } });
9215
9215
  return result?.data?.id || result?.id;
9216
9216
  }
9217
- async function callOpenCodePromptWithPathFallback(method, sessionId, payload) {
9217
+ async function callOpenCodePromptWithFallbacks(method, sessionId, flatPayload, structuredPayload) {
9218
9218
  try {
9219
- return await method({ ...payload, path: { sessionID: sessionId } });
9220
- } catch (error) {
9219
+ return await method({ sessionID: sessionId, ...flatPayload });
9220
+ } catch (flatError) {
9221
9221
  try {
9222
- return await method({ ...payload, path: { id: sessionId } });
9222
+ return await method({ ...structuredPayload, path: { sessionID: sessionId } });
9223
9223
  } catch {
9224
- throw error;
9224
+ try {
9225
+ return await method({ ...structuredPayload, path: { id: sessionId } });
9226
+ } catch {
9227
+ throw flatError;
9228
+ }
9225
9229
  }
9226
9230
  }
9227
9231
  }
9228
9232
  async function sendOpenCodeSessionEvent(client, { sessionId, agent, text, directory } = {}) {
9229
- const payload = { query: { directory }, body: { agent, parts: [{ type: "text", text }] } };
9233
+ const parts = [{ type: "text", text }];
9234
+ const flatPayload = { directory, agent, parts };
9235
+ const structuredPayload = { query: { directory }, body: { agent, parts } };
9230
9236
  if (typeof client?.session?.prompt === "function") {
9231
- return callOpenCodePromptWithPathFallback(client.session.prompt.bind(client.session), sessionId, payload);
9237
+ return callOpenCodePromptWithFallbacks(client.session.prompt.bind(client.session), sessionId, flatPayload, structuredPayload);
9232
9238
  }
9233
9239
  if (typeof client?.session?.promptAsync === "function") {
9234
- return callOpenCodePromptWithPathFallback(client.session.promptAsync.bind(client.session), sessionId, payload);
9240
+ return callOpenCodePromptWithFallbacks(client.session.promptAsync.bind(client.session), sessionId, flatPayload, structuredPayload);
9235
9241
  }
9236
9242
  throw new Error("OpenCode client does not expose session.prompt or session.promptAsync.");
9237
9243
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defend-tech/opencode-optima",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@github.com/defend-tech/opencode-optima.git"