@matterailab/orbcode 0.3.1 → 0.3.2

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/dist/api/client.js +26 -10
  2. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import OpenAI from "openai";
2
- import { API_GATEWAY_PATH, getUrlFromToken } from "../auth/auth.js";
3
- import { DEFAULT_HEADERS, X_AXONCODE_TASKID, X_AXON_REPO, X_ORGANIZATIONID } from "./headers.js";
2
+ import { API_GATEWAY_PATH } from "../auth/auth.js";
3
+ import { DEFAULT_HEADERS, X_AXONCODE_TASKID, X_AXON_REPO, X_ORGANIZATIONID, } from "./headers.js";
4
4
  import { stripReasoningDetails } from "./llmClient.js";
5
5
  import { getModel } from "./models.js";
6
6
  export class AxonClient {
@@ -9,13 +9,20 @@ export class AxonClient {
9
9
  constructor(options) {
10
10
  this.options = options;
11
11
  this.client = new OpenAI({
12
- baseURL: options.baseUrl || getUrlFromToken(API_GATEWAY_PATH, options.token),
12
+ // Use the gateway URL directly. Do not rehost it through
13
+ // getUrlFromToken — that helper rewrites any api.matterai.so host
14
+ // onto the control plane, which would send inference to
15
+ // api.matterai.so instead of the gateway at api2.matterai.so.
16
+ // Per-model `baseUrl` overrides (e.g. local dev) still win.
17
+ baseURL: options.baseUrl || API_GATEWAY_PATH,
13
18
  apiKey: options.token,
14
19
  defaultHeaders: DEFAULT_HEADERS,
15
20
  });
16
21
  }
17
22
  requestHeaders() {
18
- const headers = { [X_AXONCODE_TASKID]: this.options.taskId };
23
+ const headers = {
24
+ [X_AXONCODE_TASKID]: this.options.taskId,
25
+ };
19
26
  if (this.options.organizationId)
20
27
  headers[X_ORGANIZATIONID] = this.options.organizationId;
21
28
  if (this.options.repo)
@@ -27,7 +34,10 @@ export class AxonClient {
27
34
  const requestOptions = {
28
35
  model: model.id,
29
36
  temperature: 0.2,
30
- messages: [{ role: "system", content: systemPrompt }, ...stripReasoningDetails(messages)],
37
+ messages: [
38
+ { role: "system", content: systemPrompt },
39
+ ...stripReasoningDetails(messages),
40
+ ],
31
41
  stream: true,
32
42
  stream_options: { include_usage: true },
33
43
  max_tokens: model.maxOutputTokens,
@@ -48,12 +58,14 @@ export class AxonClient {
48
58
  for await (const chunk of stream) {
49
59
  // The gateway may return an error object instead of throwing.
50
60
  if ("error" in chunk) {
51
- const error = chunk.error;
61
+ const error = chunk
62
+ .error;
52
63
  const err = new Error(`Axon API Error ${error?.code ?? ""}: ${error?.message ?? "unknown error"}`);
53
64
  err.status = error?.code;
54
65
  throw err;
55
66
  }
56
- if ("provider" in chunk && typeof chunk.provider === "string") {
67
+ if ("provider" in chunk &&
68
+ typeof chunk.provider === "string") {
57
69
  inferenceProvider = chunk.provider;
58
70
  }
59
71
  if (chunk.usage) {
@@ -74,7 +86,9 @@ export class AxonClient {
74
86
  if (newText.includes("<think>")) {
75
87
  isThinking = true;
76
88
  }
77
- if (newText.includes("<think>") || newText.includes("</think>") || isThinking) {
89
+ if (newText.includes("<think>") ||
90
+ newText.includes("</think>") ||
91
+ isThinking) {
78
92
  if (newText.includes("</think>")) {
79
93
  isThinking = false;
80
94
  }
@@ -90,7 +104,8 @@ export class AxonClient {
90
104
  if (typeof deltaRecord.reasoning === "string" && deltaRecord.reasoning) {
91
105
  yield { type: "reasoning", text: deltaRecord.reasoning };
92
106
  }
93
- if (typeof deltaRecord.reasoning_content === "string" && deltaRecord.reasoning_content) {
107
+ if (typeof deltaRecord.reasoning_content === "string" &&
108
+ deltaRecord.reasoning_content) {
94
109
  yield { type: "reasoning", text: deltaRecord.reasoning_content };
95
110
  }
96
111
  if (delta.tool_calls && delta.tool_calls.length > 0) {
@@ -101,7 +116,8 @@ export class AxonClient {
101
116
  // index + argument fragments. Drop pure placeholders.
102
117
  const hasValidId = tc.id !== null && tc.id !== undefined;
103
118
  const hasValidName = !!tc.function.name;
104
- const hasArguments = typeof tc.function.arguments === "string" && tc.function.arguments.length > 0;
119
+ const hasArguments = typeof tc.function.arguments === "string" &&
120
+ tc.function.arguments.length > 0;
105
121
  return hasValidId || hasValidName || hasArguments;
106
122
  })
107
123
  .map((tc) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterailab/orbcode",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "OrbCode CLI — agentic coding in your terminal, powered by Axon models by MatterAI",
5
5
  "type": "module",
6
6
  "bin": {