openmates 0.11.0-alpha.23 → 0.11.0-alpha.24

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.
@@ -3639,12 +3639,14 @@ var OpenMatesClient = class _OpenMatesClient {
3639
3639
  }
3640
3640
  return this.resolveAsyncSkillResponse(response.data, headers);
3641
3641
  }
3642
- getCodeRunStreamAuth() {
3642
+ async getCodeRunStreamAuth() {
3643
3643
  const session = this.session;
3644
3644
  if (!session) return null;
3645
+ await this.refreshWsToken();
3645
3646
  const token = session.wsToken || session.cookies.auth_refresh_token;
3646
3647
  if (!token) return null;
3647
- return { sessionId: session.sessionId, token };
3648
+ const fallbackToken = session.cookies.auth_refresh_token;
3649
+ return { sessionId: session.sessionId, token, fallbackToken };
3648
3650
  }
3649
3651
  async getCodeRunStatus(path, apiKey) {
3650
3652
  const headers = {
@@ -9317,7 +9319,7 @@ async function handleCodeRun(client, flags, apiKey) {
9317
9319
  if (!result?.execution_id || !result.status_path) {
9318
9320
  throw new Error("Code Run did not return an execution id.");
9319
9321
  }
9320
- const streamAuth = apiKey ? null : client.getCodeRunStreamAuth();
9322
+ const streamAuth = apiKey ? null : await client.getCodeRunStreamAuth();
9321
9323
  let finalStatus;
9322
9324
  if (streamAuth && result.stream_path) {
9323
9325
  const url = buildCodeRunStreamUrl({
@@ -9326,7 +9328,18 @@ async function handleCodeRun(client, flags, apiKey) {
9326
9328
  sessionId: streamAuth.sessionId,
9327
9329
  token: streamAuth.token
9328
9330
  });
9329
- finalStatus = await streamCodeRunToTerminal(url, flags.json === true);
9331
+ try {
9332
+ finalStatus = await streamCodeRunToTerminal(url, flags.json === true);
9333
+ } catch (err) {
9334
+ if (!streamAuth.fallbackToken || streamAuth.fallbackToken === streamAuth.token) throw err;
9335
+ const fallbackUrl = buildCodeRunStreamUrl({
9336
+ apiUrl: client.apiUrl,
9337
+ executionId: result.execution_id,
9338
+ sessionId: streamAuth.sessionId,
9339
+ token: streamAuth.fallbackToken
9340
+ });
9341
+ finalStatus = await streamCodeRunToTerminal(fallbackUrl, flags.json === true);
9342
+ }
9330
9343
  } else {
9331
9344
  finalStatus = await pollCodeRunStatus(client, result.status_path, apiKey, flags.json === true);
9332
9345
  }
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-Z7CD2LI4.js";
5
+ } from "./chunk-PT6ABNJW.js";
6
6
  import "./chunk-AXNRPVLE.js";
7
7
  export {
8
8
  getExtForLang,
package/dist/index.d.ts CHANGED
@@ -618,10 +618,11 @@ declare class OpenMatesClient {
618
618
  inputData: Record<string, unknown>;
619
619
  apiKey?: string;
620
620
  }): Promise<unknown>;
621
- getCodeRunStreamAuth(): {
621
+ getCodeRunStreamAuth(): Promise<{
622
622
  sessionId: string;
623
623
  token: string;
624
- } | null;
624
+ fallbackToken?: string;
625
+ } | null>;
625
626
  getCodeRunStatus(path: string, apiKey?: string): Promise<Record<string, unknown>>;
626
627
  /**
627
628
  * Look up a booking URL for a flight using its booking_token.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  getExtForLang,
8
8
  parseNewChatSuggestionText,
9
9
  serializeToYaml
10
- } from "./chunk-Z7CD2LI4.js";
10
+ } from "./chunk-PT6ABNJW.js";
11
11
  import "./chunk-AXNRPVLE.js";
12
12
  export {
13
13
  MATE_NAMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.11.0-alpha.23",
3
+ "version": "0.11.0-alpha.24",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",