@phpsandbox/sdk 0.0.66 → 0.0.67

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/README.md CHANGED
@@ -66,7 +66,7 @@ PHPSandbox.realtime('token', 'https://api.phpsandbox.io/v1', {
66
66
 
67
67
  // Use explicit request/response runtime actions without a websocket.
68
68
  PHPSandbox.rest('token', 'https://api.phpsandbox.io/v1', {
69
- okraUrlProvider: async (notebookId) => getFreshOkraUrl(notebookId),
69
+ runtimeUrlProvider: async (notebookId) => getFreshRuntimeUrl(notebookId),
70
70
  });
71
71
  ```
72
72
 
@@ -103,6 +103,7 @@ Notes:
103
103
  - `create()` and `fork()` initialize automatically.
104
104
  - `open()` and `get()` return a notebook instance; call `await notebook.ready()` before using tools.
105
105
  - API notebook creates and forks are ephemeral by default. `persistent: true` requires an entitled account.
106
+ - Use `NotebookData.runtimeUrl`, `runtimeUrlProvider`, and `DeploymentData.eventStreamUrl` for runtime access. Their `okraUrl` and `okraUrlProvider` aliases are deprecated compatibility fields.
106
107
 
107
108
  ## Services At A Glance
108
109
 
@@ -124,9 +125,9 @@ Each `NotebookInstance` exposes service clients:
124
125
 
125
126
  Notes:
126
127
 
127
- - `terminal.spawn()` and `shell.exec()` are part of the current okra websocket action set. `terminal.start` currently is not.
128
- - `notebook.repl.eval()` is part of the current okra websocket action set. `repl.start` is currently not.
129
- - `notebook.laravel` is exposed by the SDK, but the current okra websocket action set does not expose Laravel maintenance actions.
128
+ - `terminal.spawn()` and `shell.exec()` are part of the current runtime action set. `terminal.start` currently is not.
129
+ - `notebook.repl.eval()` is part of the current runtime action set. `repl.start` is currently not.
130
+ - `notebook.laravel` is exposed by the SDK, but the current runtime action set does not expose Laravel maintenance actions.
130
131
 
131
132
  ## Common Operations
132
133
 
package/dist/auth.d.ts CHANGED
@@ -8,5 +8,5 @@ export default class Auth {
8
8
  protected okra: NotebookInstance;
9
9
  constructor(okra: NotebookInstance);
10
10
  logout(): void;
11
- login(okraUrl: string): Promise<boolean>;
11
+ login(runtimeUrl: string): Promise<boolean>;
12
12
  }
package/dist/auth.js CHANGED
@@ -5,8 +5,8 @@ export default class Auth {
5
5
  logout() {
6
6
  this.okra.dispose();
7
7
  }
8
- login(okraUrl) {
9
- const runtimeTicket = new URL(okraUrl).searchParams.get('ticket');
8
+ login(runtimeUrl) {
9
+ const runtimeTicket = new URL(runtimeUrl).searchParams.get('ticket');
10
10
  if (runtimeTicket === null || runtimeTicket === '') {
11
11
  throw new TypeError('The notebook connection does not contain a runtime ticket.');
12
12
  }
@@ -584,8 +584,8 @@ var Auth = class {
584
584
  logout() {
585
585
  this.okra.dispose();
586
586
  }
587
- login(okraUrl) {
588
- const runtimeTicket = new URL(okraUrl).searchParams.get("ticket");
587
+ login(runtimeUrl) {
588
+ const runtimeTicket = new URL(runtimeUrl).searchParams.get("ticket");
589
589
  if (runtimeTicket === null || runtimeTicket === "") {
590
590
  throw new TypeError("The notebook connection does not contain a runtime ticket.");
591
591
  }
@@ -19441,8 +19441,9 @@ var DeploymentRun = class {
19441
19441
  if (this.started) {
19442
19442
  return this;
19443
19443
  }
19444
- if (!this.initial.data.okraUrl) {
19445
- throw new Error(`Deployment ${this.initial.data.id} has no okraUrl for SSE streaming`);
19444
+ const eventStreamUrl = this.initial.data.eventStreamUrl ?? this.initial.data.okraUrl;
19445
+ if (!eventStreamUrl) {
19446
+ throw new Error(`Deployment ${this.initial.data.id} has no eventStreamUrl for SSE streaming`);
19446
19447
  }
19447
19448
  this.started = true;
19448
19449
  this.resultPromise = new Promise((resolve, reject) => {
@@ -19450,7 +19451,7 @@ var DeploymentRun = class {
19450
19451
  this.rejectResult = reject;
19451
19452
  });
19452
19453
  this.resultPromise.catch(() => void 0);
19453
- void this.consumeStream(this.initial.data.okraUrl);
19454
+ void this.consumeStream(eventStreamUrl);
19454
19455
  return this;
19455
19456
  }
19456
19457
  subscribe() {
@@ -19467,9 +19468,9 @@ var DeploymentRun = class {
19467
19468
  }
19468
19469
  return queue;
19469
19470
  }
19470
- async consumeStream(okraUrl) {
19471
+ async consumeStream(eventStreamUrl) {
19471
19472
  try {
19472
- const stream = await this.client.sse(okraUrl);
19473
+ const stream = await this.client.sse(eventStreamUrl);
19473
19474
  for await (const event of readDeployStreamEvents(stream)) {
19474
19475
  this.publish(event);
19475
19476
  if (event.type === "result") {
@@ -19868,20 +19869,20 @@ var RestRuntimeInvoker = class {
19868
19869
  this.refresh = refresh;
19869
19870
  this.refreshPromise = null;
19870
19871
  this.notebookId = data.id;
19871
- this.configure(data.okraUrl);
19872
+ this.configure(data.runtimeUrl ?? data.okraUrl);
19872
19873
  }
19873
- configure(connectionUrl) {
19874
- const okraUrl = new URL(connectionUrl);
19875
- const ticket = okraUrl.searchParams.get("ticket") ?? "";
19874
+ configure(runtimeUrl) {
19875
+ const actionUrl = new URL(runtimeUrl);
19876
+ const ticket = actionUrl.searchParams.get("ticket") ?? "";
19876
19877
  if (ticket === "") {
19877
19878
  throw new UnsupportedRuntimeTransportError("The notebook connection does not contain a runtime ticket.");
19878
19879
  }
19879
19880
  this.ticket = ticket;
19880
- okraUrl.protocol = okraUrl.protocol === "wss:" ? "https:" : "http:";
19881
- okraUrl.pathname = `/api/v1/notebooks/${encodeURIComponent(this.notebookId)}`;
19882
- okraUrl.searchParams.delete("ticket");
19883
- okraUrl.hash = "";
19884
- this.actionUrl = okraUrl;
19881
+ actionUrl.protocol = actionUrl.protocol === "wss:" ? "https:" : "http:";
19882
+ actionUrl.pathname = `/api/v1/notebooks/${encodeURIComponent(this.notebookId)}`;
19883
+ actionUrl.searchParams.delete("ticket");
19884
+ actionUrl.hash = "";
19885
+ this.actionUrl = actionUrl;
19885
19886
  }
19886
19887
  ready() {
19887
19888
  return this.invokeRaw("runtime.ready", {}, {});
@@ -19939,7 +19940,7 @@ var RestRuntimeInvoker = class {
19939
19940
  }
19940
19941
  async refreshAuthorization() {
19941
19942
  if (this.refreshPromise === null) {
19942
- this.refreshPromise = this.refresh().then((okraUrl) => this.configure(okraUrl));
19943
+ this.refreshPromise = this.refresh().then((runtimeUrl) => this.configure(runtimeUrl));
19943
19944
  }
19944
19945
  try {
19945
19946
  await this.refreshPromise;
@@ -20335,23 +20336,25 @@ var NotebookInstance2 = class {
20335
20336
  this.initialized = false;
20336
20337
  __privateAdd(this, _initPromise, null);
20337
20338
  this.disposables = [];
20339
+ const runtimeUrl = data.runtimeUrl ?? data.okraUrl;
20340
+ const runtimeUrlProvider = client.options.runtimeUrlProvider ?? client.options.okraUrlProvider;
20338
20341
  this.emitter = EventManager.createInstance();
20339
20342
  if (client.runtimeTransport === "rest") {
20340
20343
  this.socket = null;
20341
20344
  this.restInvoker = new RestRuntimeInvoker(
20342
20345
  data,
20343
20346
  client.options.fetch ?? globalThis.fetch,
20344
- client.options.okraUrlProvider === void 0 ? void 0 : () => client.options.okraUrlProvider(data.id)
20347
+ runtimeUrlProvider === void 0 ? void 0 : () => runtimeUrlProvider(data.id)
20345
20348
  );
20346
20349
  } else {
20347
20350
  this.restInvoker = null;
20348
20351
  let initialConnection = true;
20349
- const connectionUrl = client.options.okraUrlProvider === void 0 ? data.okraUrl : async () => {
20352
+ const connectionUrl = runtimeUrlProvider === void 0 ? runtimeUrl : async () => {
20350
20353
  if (initialConnection) {
20351
20354
  initialConnection = false;
20352
- return data.okraUrl;
20355
+ return runtimeUrl;
20353
20356
  }
20354
- return client.options.okraUrlProvider(data.id);
20357
+ return runtimeUrlProvider(data.id);
20355
20358
  };
20356
20359
  this.socket = new Transport(connectionUrl, this.emitter, {
20357
20360
  debug: client.options.debug,