@phpsandbox/sdk 0.3.3 → 0.3.4

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.
@@ -12,137 +12,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12
12
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
13
13
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
14
14
 
15
- // src/errors/index.ts
16
- var remoteErrorCodes = [
17
- "ActionNotFound",
18
- "AuthenticationRequired",
19
- "BadGateway",
20
- "BadRequest",
21
- "Conflict",
22
- "FileAlreadyExists",
23
- "FileIsDirectory",
24
- "FileNotDirectory",
25
- "FileNotFound",
26
- "FilesystemUnavailable",
27
- "InternalError",
28
- "InvalidArgument",
29
- "InvalidConfiguration",
30
- "InvalidRequest",
31
- "InvalidResponse",
32
- "InvalidServiceCommand",
33
- "MethodNotAllowed",
34
- "NotebookInitializationFailed",
35
- "NotebookUnavailable",
36
- "NotFound",
37
- "PayloadTooLarge",
38
- "PermissionDenied",
39
- "RateLimited",
40
- "RequestFailed",
41
- "RuntimeOperationFailed",
42
- "ServiceNotFound",
43
- "ServiceUnavailable",
44
- "UnprocessableEntity",
45
- "ValidationFailed",
46
- "WorkspaceUnavailable"
47
- ];
48
- var PHPSandboxError = class extends Error {
49
- constructor(message, cause) {
50
- super(message);
51
- this.name = new.target.name;
52
- this.cause = cause;
53
- }
54
- };
55
- var RemoteError = class _RemoteError extends PHPSandboxError {
56
- constructor(message, options) {
57
- super(message, options.cause);
58
- this.source = options.source;
59
- this.status = options.status;
60
- this.code = options.code;
61
- this.details = options.details;
62
- }
63
- static is(error51, code) {
64
- return error51 instanceof _RemoteError && (code === void 0 || error51.code === code);
65
- }
66
- static isValidation(error51) {
67
- return _RemoteError.is(error51, "ValidationFailed") && validationDetails(error51.details) !== void 0;
68
- }
69
- is(code) {
70
- return this.code === code;
71
- }
72
- };
73
- var TransportError = class _TransportError extends PHPSandboxError {
74
- constructor(message, code, cause, response) {
75
- super(message, cause);
76
- this.code = code;
77
- this.response = response;
78
- }
79
- static is(error51, code) {
80
- return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
81
- }
82
- is(code) {
83
- return this.code === code;
84
- }
85
- };
86
- function remoteError(source, payload, cause) {
87
- const error51 = record(payload);
88
- const status = positiveInteger(error51?.status);
89
- const code = nonEmptyString(error51?.code);
90
- const message = nonEmptyString(error51?.message);
91
- if (status === void 0 || !isRemoteErrorCode(code) || message === void 0) {
92
- throw new TransportError("PHPSandbox returned an invalid error response.", "InvalidResponse", cause ?? payload);
93
- }
94
- return new RemoteError(message, {
95
- source,
96
- status,
97
- code,
98
- details: error51?.details,
99
- cause
100
- });
101
- }
102
- function isRemoteErrorCode(value) {
103
- return typeof value === "string" && remoteErrorCodes.includes(value);
104
- }
105
- function positiveInteger(value) {
106
- return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
107
- }
108
- function nonEmptyString(value) {
109
- return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
110
- }
111
- function record(value) {
112
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
113
- }
114
- function stringArrayRecord(value) {
115
- const candidate = record(value);
116
- if (candidate === void 0) {
117
- return void 0;
118
- }
119
- const entries = Object.entries(candidate);
120
- if (!entries.every(([, messages]) => Array.isArray(messages) && messages.every((message) => typeof message === "string"))) {
121
- return void 0;
122
- }
123
- return Object.fromEntries(entries);
124
- }
125
- function validationDetails(value) {
126
- const details = record(value);
127
- const errors = stringArrayRecord(details?.errors);
128
- return errors === void 0 ? void 0 : { errors };
129
- }
130
- var PromiseTimeoutError = class extends Error {
131
- constructor(message, time3) {
132
- super(message);
133
- this.time = time3;
134
- }
135
- };
136
- var SendTimeoutError = class _SendTimeoutError extends TransportError {
137
- constructor(message, time3, cause) {
138
- super(message, "SendTimeout", cause);
139
- this.time = time3;
140
- }
141
- static fromPromiseTimeoutError(error51) {
142
- return new _SendTimeoutError(error51.message, error51.time, error51);
143
- }
144
- };
145
-
146
15
  // node_modules/zod/v4/classic/external.js
147
16
  var external_exports = {};
148
17
  __export(external_exports, {
@@ -337,7 +206,7 @@ __export(external_exports, {
337
206
  promise: () => promise,
338
207
  property: () => _property,
339
208
  readonly: () => readonly,
340
- record: () => record2,
209
+ record: () => record,
341
210
  refine: () => refine,
342
211
  regex: () => _regex,
343
212
  regexes: () => regexes_exports,
@@ -12675,7 +12544,7 @@ __export(schemas_exports2, {
12675
12544
  preprocess: () => preprocess,
12676
12545
  promise: () => promise,
12677
12546
  readonly: () => readonly,
12678
- record: () => record2,
12547
+ record: () => record,
12679
12548
  refine: () => refine,
12680
12549
  set: () => set,
12681
12550
  strictObject: () => strictObject,
@@ -13644,7 +13513,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
13644
13513
  inst.keyType = def.keyType;
13645
13514
  inst.valueType = def.valueType;
13646
13515
  });
13647
- function record2(keyType, valueType, params) {
13516
+ function record(keyType, valueType, params) {
13648
13517
  if (!valueType || !valueType._zod) {
13649
13518
  return new ZodRecord({
13650
13519
  type: "record",
@@ -14111,7 +13980,7 @@ var stringbool = (...args) => _stringbool({
14111
13980
  }, ...args);
14112
13981
  function json(params) {
14113
13982
  const jsonSchema = lazy(() => {
14114
- return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record2(string2(), jsonSchema)]);
13983
+ return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14115
13984
  });
14116
13985
  return jsonSchema;
14117
13986
  }
@@ -14657,12 +14526,146 @@ function date4(params) {
14657
14526
  // node_modules/zod/v4/classic/external.js
14658
14527
  config(en_default());
14659
14528
 
14529
+ // src/identity.ts
14530
+ var identitySchema = external_exports.object({
14531
+ user: external_exports.object({ id: external_exports.string(), name: external_exports.string() }).nullable(),
14532
+ organization: external_exports.object({ id: external_exports.string(), name: external_exports.string() }),
14533
+ permissions: external_exports.array(external_exports.string())
14534
+ });
14535
+
14536
+ // src/errors/index.ts
14537
+ var remoteErrorCodes = [
14538
+ "ActionNotFound",
14539
+ "AuthenticationRequired",
14540
+ "BadGateway",
14541
+ "BadRequest",
14542
+ "Conflict",
14543
+ "FileAlreadyExists",
14544
+ "FileIsDirectory",
14545
+ "FileNotDirectory",
14546
+ "FileNotFound",
14547
+ "FilesystemUnavailable",
14548
+ "InternalError",
14549
+ "InvalidArgument",
14550
+ "InvalidConfiguration",
14551
+ "InvalidRequest",
14552
+ "InvalidResponse",
14553
+ "InvalidServiceCommand",
14554
+ "MethodNotAllowed",
14555
+ "NotebookInitializationFailed",
14556
+ "NotebookUnavailable",
14557
+ "NotFound",
14558
+ "PayloadTooLarge",
14559
+ "PermissionDenied",
14560
+ "RateLimited",
14561
+ "RequestFailed",
14562
+ "RuntimeOperationFailed",
14563
+ "ServiceNotFound",
14564
+ "ServiceUnavailable",
14565
+ "UnprocessableEntity",
14566
+ "ValidationFailed",
14567
+ "WorkspaceUnavailable"
14568
+ ];
14569
+ var PHPSandboxError = class extends Error {
14570
+ constructor(message, cause) {
14571
+ super(message);
14572
+ this.name = new.target.name;
14573
+ this.cause = cause;
14574
+ }
14575
+ };
14576
+ var RemoteError = class _RemoteError extends PHPSandboxError {
14577
+ constructor(message, options) {
14578
+ super(message, options.cause);
14579
+ this.source = options.source;
14580
+ this.status = options.status;
14581
+ this.code = options.code;
14582
+ this.details = options.details;
14583
+ }
14584
+ static is(error51, code) {
14585
+ return error51 instanceof _RemoteError && (code === void 0 || error51.code === code);
14586
+ }
14587
+ static isValidation(error51) {
14588
+ return _RemoteError.is(error51, "ValidationFailed") && validationDetails(error51.details) !== void 0;
14589
+ }
14590
+ is(code) {
14591
+ return this.code === code;
14592
+ }
14593
+ };
14594
+ var TransportError = class _TransportError extends PHPSandboxError {
14595
+ constructor(message, code, cause, response) {
14596
+ super(message, cause);
14597
+ this.code = code;
14598
+ this.response = response;
14599
+ }
14600
+ static is(error51, code) {
14601
+ return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
14602
+ }
14603
+ is(code) {
14604
+ return this.code === code;
14605
+ }
14606
+ };
14607
+ function remoteError(source, payload, cause) {
14608
+ const error51 = record2(payload);
14609
+ const status = positiveInteger(error51?.status);
14610
+ const code = nonEmptyString(error51?.code);
14611
+ const message = nonEmptyString(error51?.message);
14612
+ if (status === void 0 || !isRemoteErrorCode(code) || message === void 0) {
14613
+ throw new TransportError("PHPSandbox returned an invalid error response.", "InvalidResponse", cause ?? payload);
14614
+ }
14615
+ return new RemoteError(message, {
14616
+ source,
14617
+ status,
14618
+ code,
14619
+ details: error51?.details,
14620
+ cause
14621
+ });
14622
+ }
14623
+ function isRemoteErrorCode(value) {
14624
+ return typeof value === "string" && remoteErrorCodes.includes(value);
14625
+ }
14626
+ function positiveInteger(value) {
14627
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
14628
+ }
14629
+ function nonEmptyString(value) {
14630
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
14631
+ }
14632
+ function record2(value) {
14633
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
14634
+ }
14635
+ function stringArrayRecord(value) {
14636
+ const candidate = record2(value);
14637
+ if (candidate === void 0) {
14638
+ return void 0;
14639
+ }
14640
+ const entries = Object.entries(candidate);
14641
+ if (!entries.every(([, messages]) => Array.isArray(messages) && messages.every((message) => typeof message === "string"))) {
14642
+ return void 0;
14643
+ }
14644
+ return Object.fromEntries(entries);
14645
+ }
14646
+ function validationDetails(value) {
14647
+ const details = record2(value);
14648
+ const errors = stringArrayRecord(details?.errors);
14649
+ return errors === void 0 ? void 0 : { errors };
14650
+ }
14651
+ var PromiseTimeoutError = class extends Error {
14652
+ constructor(message, time3) {
14653
+ super(message);
14654
+ this.time = time3;
14655
+ }
14656
+ };
14657
+ var SendTimeoutError = class _SendTimeoutError extends TransportError {
14658
+ constructor(message, time3, cause) {
14659
+ super(message, "SendTimeout", cause);
14660
+ this.time = time3;
14661
+ }
14662
+ static fromPromiseTimeoutError(error51) {
14663
+ return new _SendTimeoutError(error51.message, error51.time, error51);
14664
+ }
14665
+ };
14666
+
14660
14667
  // src/schemas/publications.ts
14661
- var PublicationProviderNameSchema = external_exports.enum([
14662
- "cloudflare-containers",
14663
- "ssh-server",
14664
- "laravel-cloud"
14665
- ]);
14668
+ var PublicationProviderNameSchema = external_exports.enum(["cloudflare-containers", "ssh-server", "laravel-cloud"]);
14666
14669
  var PublicationStatusSchema = external_exports.enum([
14667
14670
  "pending",
14668
14671
  "queued",
@@ -14675,36 +14678,10 @@ var PublicationStatusSchema = external_exports.enum([
14675
14678
  "deleted",
14676
14679
  "delete_failed"
14677
14680
  ]);
14678
- var PublicationBuildStatusSchema = external_exports.enum([
14679
- "pending",
14680
- "queued",
14681
- "running",
14682
- "succeeded",
14683
- "failed",
14684
- "cancelled"
14685
- ]);
14681
+ var PublicationBuildStatusSchema = external_exports.enum(["pending", "queued", "running", "succeeded", "failed", "cancelled"]);
14686
14682
  var PublicationReleaseStatusSchema = external_exports.enum(["created", "ready", "deleted"]);
14687
- var PublicationSizeSchema = external_exports.enum([
14688
- "nano",
14689
- "small",
14690
- "medium",
14691
- "large",
14692
- "lite",
14693
- "basic",
14694
- "standard-1",
14695
- "standard-2"
14696
- ]);
14697
- var PublicationRegionSchema = external_exports.enum([
14698
- "ENAM",
14699
- "WNAM",
14700
- "EEUR",
14701
- "WEUR",
14702
- "APAC",
14703
- "SAM",
14704
- "ME",
14705
- "OC",
14706
- "AFR"
14707
- ]);
14683
+ var PublicationSizeSchema = external_exports.enum(["nano", "small", "medium", "large", "lite", "basic", "standard-1", "standard-2"]);
14684
+ var PublicationRegionSchema = external_exports.enum(["ENAM", "WNAM", "EEUR", "WEUR", "APAC", "SAM", "ME", "OC", "AFR"]);
14708
14685
  var PublicationJurisdictionSchema = external_exports.enum(["eu", "fedramp"]);
14709
14686
  var PublicationProtectionModeSchema = external_exports.enum(["none", "password"]);
14710
14687
  var PublicationLogStreamSchema = external_exports.enum(["build", "runtime"]);
@@ -14814,7 +14791,9 @@ async function* readPublicationStream(input, options = {}) {
14814
14791
  const lines = data;
14815
14792
  eventName = "message";
14816
14793
  data = [];
14817
- if (!lines.length || !PublishStreamSseEventNameSchema.safeParse(name).success) return null;
14794
+ if (!lines.length || !PublishStreamSseEventNameSchema.safeParse(name).success) {
14795
+ return null;
14796
+ }
14818
14797
  const raw = lines.join("\n");
14819
14798
  let payload;
14820
14799
  try {
@@ -14823,18 +14802,30 @@ async function* readPublicationStream(input, options = {}) {
14823
14802
  payload = raw;
14824
14803
  }
14825
14804
  const event = PublishStreamSseEventSchema.parse({ event: name, data: payload });
14826
- if (event.type === "result") receivedResult = true;
14805
+ if (event.type === "result") {
14806
+ receivedResult = true;
14807
+ }
14827
14808
  return event;
14828
14809
  }
14829
14810
  function line(value) {
14830
- if (value === "") return dispatch();
14831
- if (value.startsWith(":")) return null;
14811
+ if (value === "") {
14812
+ return dispatch();
14813
+ }
14814
+ if (value.startsWith(":")) {
14815
+ return null;
14816
+ }
14832
14817
  const colon = value.indexOf(":");
14833
14818
  const field = colon < 0 ? value : value.slice(0, colon);
14834
14819
  let content = colon < 0 ? "" : value.slice(colon + 1);
14835
- if (content.startsWith(" ")) content = content.slice(1);
14836
- if (field === "event") eventName = content;
14837
- if (field === "data") data.push(content);
14820
+ if (content.startsWith(" ")) {
14821
+ content = content.slice(1);
14822
+ }
14823
+ if (field === "event") {
14824
+ eventName = content;
14825
+ }
14826
+ if (field === "data") {
14827
+ data.push(content);
14828
+ }
14838
14829
  return null;
14839
14830
  }
14840
14831
  try {
@@ -14843,19 +14834,27 @@ async function* readPublicationStream(input, options = {}) {
14843
14834
  buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });
14844
14835
  let match;
14845
14836
  while (match = /\r\n|\r|\n/.exec(buffer)) {
14846
- if (!done && match[0] === "\r" && match.index === buffer.length - 1) break;
14837
+ if (!done && match[0] === "\r" && match.index === buffer.length - 1) {
14838
+ break;
14839
+ }
14847
14840
  const event = line(buffer.slice(0, match.index));
14848
14841
  buffer = buffer.slice(match.index + match[0].length);
14849
- if (event) yield event;
14842
+ if (event) {
14843
+ yield event;
14844
+ }
14850
14845
  }
14851
14846
  if (done) {
14852
14847
  ended = true;
14853
14848
  if (buffer) {
14854
14849
  const event2 = line(buffer);
14855
- if (event2) yield event2;
14850
+ if (event2) {
14851
+ yield event2;
14852
+ }
14856
14853
  }
14857
14854
  const event = dispatch();
14858
- if (event) yield event;
14855
+ if (event) {
14856
+ yield event;
14857
+ }
14859
14858
  if (options.requireResult !== false && !receivedResult) {
14860
14859
  throw new PHPSandboxError("Publish stream ended without result");
14861
14860
  }
@@ -14863,7 +14862,9 @@ async function* readPublicationStream(input, options = {}) {
14863
14862
  }
14864
14863
  }
14865
14864
  } finally {
14866
- if (!ended) await reader.cancel().catch(() => void 0);
14865
+ if (!ended) {
14866
+ await reader.cancel().catch(() => void 0);
14867
+ }
14867
14868
  reader.releaseLock();
14868
14869
  }
14869
14870
  }
@@ -14874,7 +14875,9 @@ function createPublicationStreamResponse(stream, options = {}) {
14874
14875
  let cancellation;
14875
14876
  let abort;
14876
14877
  async function dispose() {
14877
- if (disposed) return;
14878
+ if (disposed) {
14879
+ return;
14880
+ }
14878
14881
  disposed = true;
14879
14882
  options.signal?.removeEventListener("abort", abort);
14880
14883
  reader.releaseLock();
@@ -14890,43 +14893,56 @@ function createPublicationStreamResponse(stream, options = {}) {
14890
14893
  }
14891
14894
  })());
14892
14895
  }
14893
- return new Response(new ReadableStream({
14894
- start(controller) {
14895
- abort = () => {
14896
- controller.error(options.signal.reason);
14897
- void cancel(options.signal.reason).catch(() => void 0);
14898
- };
14899
- if (options.signal?.aborted) abort();
14900
- else options.signal?.addEventListener("abort", abort, { once: true });
14901
- },
14902
- async pull(controller) {
14903
- try {
14904
- const { done, value } = await reader.read();
14905
- if (finished) return;
14906
- if (done) {
14907
- finished = true;
14908
- await dispose();
14909
- controller.close();
14910
- } else {
14911
- controller.enqueue(value);
14912
- }
14913
- } catch (error51) {
14914
- if (finished && cancellation) return;
14915
- try {
14916
- await cancel(error51);
14917
- } finally {
14918
- controller.error(error51);
14919
- }
14896
+ return new Response(
14897
+ new ReadableStream(
14898
+ {
14899
+ start(controller) {
14900
+ abort = () => {
14901
+ controller.error(options.signal.reason);
14902
+ void cancel(options.signal.reason).catch(() => void 0);
14903
+ };
14904
+ if (options.signal?.aborted) {
14905
+ abort();
14906
+ } else {
14907
+ options.signal?.addEventListener("abort", abort, { once: true });
14908
+ }
14909
+ },
14910
+ async pull(controller) {
14911
+ try {
14912
+ const { done, value } = await reader.read();
14913
+ if (finished) {
14914
+ return;
14915
+ }
14916
+ if (done) {
14917
+ finished = true;
14918
+ await dispose();
14919
+ controller.close();
14920
+ } else {
14921
+ controller.enqueue(value);
14922
+ }
14923
+ } catch (error51) {
14924
+ if (finished && cancellation) {
14925
+ return;
14926
+ }
14927
+ try {
14928
+ await cancel(error51);
14929
+ } finally {
14930
+ controller.error(error51);
14931
+ }
14932
+ }
14933
+ },
14934
+ cancel
14935
+ },
14936
+ { highWaterMark: 0 }
14937
+ ),
14938
+ {
14939
+ headers: {
14940
+ "Content-Type": "text/event-stream",
14941
+ "Cache-Control": "no-cache, no-transform",
14942
+ "X-Accel-Buffering": "no"
14920
14943
  }
14921
- },
14922
- cancel
14923
- }, { highWaterMark: 0 }), {
14924
- headers: {
14925
- "Content-Type": "text/event-stream",
14926
- "Cache-Control": "no-cache, no-transform",
14927
- "X-Accel-Buffering": "no"
14928
14944
  }
14929
- });
14945
+ );
14930
14946
  }
14931
14947
 
14932
14948
  // src/publication/run.ts
@@ -15247,7 +15263,9 @@ var PublicationInstance = class _PublicationInstance {
15247
15263
  }
15248
15264
  async logSnapshot(stream, limit = 50) {
15249
15265
  const query = new URLSearchParams({ stream, limit: String(limit) });
15250
- return (await this.client.get(`/publications/${encodeURIComponent(this.data.id)}/logs?${query}`)).data;
15266
+ return (await this.client.get(
15267
+ `/publications/${encodeURIComponent(this.data.id)}/logs?${query}`
15268
+ )).data;
15251
15269
  }
15252
15270
  async logs() {
15253
15271
  return parseNdjsonStream(
@@ -15356,11 +15374,15 @@ var NotebookPublication = class {
15356
15374
  /** Publish the exact app selection in a server-owned review. */
15357
15375
  async publish(input) {
15358
15376
  const application = (await this.client.post(`${this.path}/publication`, input)).data;
15359
- if (!("confirmationRequired" in application)) this.startApplicationRuns(application);
15377
+ if (!("confirmationRequired" in application)) {
15378
+ this.startApplicationRuns(application);
15379
+ }
15360
15380
  return application;
15361
15381
  }
15362
15382
  async application(applicationId) {
15363
- return (await this.client.get(`${this.path}/publication/application/${encodeURIComponent(applicationId)}`)).data;
15383
+ return (await this.client.get(
15384
+ `${this.path}/publication/application/${encodeURIComponent(applicationId)}`
15385
+ )).data;
15364
15386
  }
15365
15387
  /** Retry failed apps and pending route attachments while preserving running releases. */
15366
15388
  async retryApplication(applicationId) {
@@ -15377,12 +15399,13 @@ var NotebookPublication = class {
15377
15399
  }
15378
15400
  startApplicationRuns(application) {
15379
15401
  for (const app of application.apps) {
15380
- if (!(application.selectedAppIds ?? []).includes(app.appId)) continue;
15381
- if (!["pending", "queued", "building", "deploying"].includes(app.publication.status)) continue;
15382
- new PublicationRun(
15383
- new PublicationInstance(app.publication, this.client, this.notebookId),
15384
- this.client
15385
- ).start();
15402
+ if (!(application.selectedAppIds ?? []).includes(app.appId)) {
15403
+ continue;
15404
+ }
15405
+ if (!["pending", "queued", "building", "deploying"].includes(app.publication.status)) {
15406
+ continue;
15407
+ }
15408
+ new PublicationRun(new PublicationInstance(app.publication, this.client, this.notebookId), this.client).start();
15386
15409
  }
15387
15410
  }
15388
15411
  async catalog(provider, serverId) {
@@ -15997,7 +16020,7 @@ var Terminals = class {
15997
16020
  return this.okra.invoke("terminal.close", { id });
15998
16021
  });
15999
16022
  const resize = (dimensions) => {
16000
- this.okra.invoke("terminal.resize", { id, width: dimensions.cols, height: dimensions.rows });
16023
+ return this.okra.invoke("terminal.resize", { id, width: dimensions.cols, height: dimensions.rows });
16001
16024
  };
16002
16025
  if (abortSignal && !abortSignal.aborted) {
16003
16026
  abortHandler = () => {
@@ -16018,20 +16041,6 @@ var Terminals = class {
16018
16041
  }
16019
16042
  };
16020
16043
 
16021
- // src/auth.ts
16022
- var Auth = class {
16023
- constructor(okra) {
16024
- this.okra = okra;
16025
- }
16026
- login(runtimeUrl) {
16027
- const runtimeTicket = new URL(runtimeUrl).searchParams.get("ticket");
16028
- if (runtimeTicket === null || runtimeTicket === "") {
16029
- throw new TypeError("The notebook connection does not contain a runtime ticket.");
16030
- }
16031
- return this.okra.invoke("auth.login", { runtimeTicket });
16032
- }
16033
- };
16034
-
16035
16044
  // src/lsp.ts
16036
16045
  var Lsp = class {
16037
16046
  constructor(okra) {
@@ -16086,10 +16095,10 @@ var LspConnection = class _LspConnection {
16086
16095
  return this.lsp.onClose(this.id, cb);
16087
16096
  }
16088
16097
  dispose() {
16089
- this.lsp.close(this.id);
16098
+ return this.lsp.close(this.id);
16090
16099
  }
16091
16100
  start() {
16092
- this.lsp.start(this.id);
16101
+ return this.lsp.start(this.id);
16093
16102
  }
16094
16103
  onClientDisconnect(cb) {
16095
16104
  return this.lsp.onClientDisconnect(cb);
@@ -16192,11 +16201,7 @@ var ShellProcess = class {
16192
16201
  stderr.fail(error51);
16193
16202
  };
16194
16203
  const { abortSignal, ...payloadOpts } = opts;
16195
- this.completion = this.okra.invoke(
16196
- "shell.exec",
16197
- { command, opts: { ...payloadOpts, id: this.id } },
16198
- { abortSignal }
16199
- ).then((result) => {
16204
+ this.completion = this.okra.invoke("shell.exec", { command, opts: { ...payloadOpts, id: this.id } }, { abortSignal }).then((result) => {
16200
16205
  finish();
16201
16206
  return result;
16202
16207
  }).catch((error51) => {
@@ -16229,15 +16234,14 @@ var ComposerCredentials = class {
16229
16234
  this.notebookId = notebookId;
16230
16235
  }
16231
16236
  async set(input) {
16232
- const response = await this.client.put(
16233
- `/notebook/${this.notebookId}/composer/credentials`,
16234
- input
16235
- );
16237
+ const response = await this.client.put(`/notebook/${this.notebookId}/composer/credentials`, input);
16236
16238
  return response.data;
16237
16239
  }
16238
16240
  async remove(type, url2) {
16239
16241
  const params = new URLSearchParams({ type });
16240
- if (url2) params.set("url", url2);
16242
+ if (url2) {
16243
+ params.set("url", url2);
16244
+ }
16241
16245
  await this.client.delete(`/notebook/${this.notebookId}/composer/credentials?${params.toString()}`);
16242
16246
  }
16243
16247
  };
@@ -16422,11 +16426,18 @@ var Logs = class {
16422
16426
  this.telemetry = telemetry;
16423
16427
  }
16424
16428
  follow(options = {}) {
16425
- return watchRuntimeTelemetry(this.okra, this.telemetry, "logs", "notebook.log", (message) => ({
16426
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16427
- source: "runtime",
16428
- message
16429
- }), options);
16429
+ return watchRuntimeTelemetry(
16430
+ this.okra,
16431
+ this.telemetry,
16432
+ "logs",
16433
+ "notebook.log",
16434
+ (message) => ({
16435
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16436
+ source: "runtime",
16437
+ message
16438
+ }),
16439
+ options
16440
+ );
16430
16441
  }
16431
16442
  };
16432
16443
 
@@ -18886,7 +18897,7 @@ ${JSON.stringify(metadata, null, 2)}` : "";
18886
18897
  id() {
18887
18898
  return this.clientId;
18888
18899
  }
18889
- async registerWatchers() {
18900
+ registerWatchers() {
18890
18901
  const onMessage = (ev) => {
18891
18902
  this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error51) => {
18892
18903
  this.log("error", "Failed to process queued WebSocket frame", {
@@ -19052,7 +19063,9 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19052
19063
  this.eventEmitter.emit(event, this.clientId);
19053
19064
  return;
19054
19065
  }
19055
- event && this.eventEmitter.emit(as || event, data);
19066
+ if (event) {
19067
+ this.eventEmitter.emit(as || event, data);
19068
+ }
19056
19069
  }
19057
19070
  listen(event, listener, _context) {
19058
19071
  return this.eventEmitter.listen(event, listener);
@@ -19148,12 +19161,14 @@ ${JSON.stringify(metadata, null, 2)}` : "";
19148
19161
  });
19149
19162
  closeHandler = (_ev) => {
19150
19163
  if (_ev.code === 1008 && (_ev.reason || "").includes("rate limit")) {
19151
- reject(new RemoteError(_ev.reason || "Rate limit exceeded", {
19152
- source: "runtime",
19153
- status: 429,
19154
- code: "RateLimited",
19155
- cause: _ev
19156
- }));
19164
+ reject(
19165
+ new RemoteError(_ev.reason || "Rate limit exceeded", {
19166
+ source: "runtime",
19167
+ status: 429,
19168
+ code: "RateLimited",
19169
+ cause: _ev
19170
+ })
19171
+ );
19157
19172
  return;
19158
19173
  }
19159
19174
  const detail = describeWebSocketEvent(_ev);
@@ -19689,8 +19704,13 @@ var ServerInstance = class {
19689
19704
  async share(email3) {
19690
19705
  return (await this.client.post(`/servers/${encodeURIComponent(this.data.id)}/members`, { email: email3 })).data;
19691
19706
  }
19707
+ async shareWithOrganization(organizationId) {
19708
+ return (await this.client.post(`/servers/${encodeURIComponent(this.data.id)}/members`, { organizationId })).data;
19709
+ }
19692
19710
  async revokeAccess(memberId) {
19693
- await this.client.delete(`/servers/${encodeURIComponent(this.data.id)}/members/${encodeURIComponent(String(memberId))}`);
19711
+ await this.client.delete(
19712
+ `/servers/${encodeURIComponent(this.data.id)}/members/${encodeURIComponent(String(memberId))}`
19713
+ );
19694
19714
  }
19695
19715
  refresh() {
19696
19716
  return this.client.servers.get(this.data.id);
@@ -19914,9 +19934,7 @@ function runtimeActionRequestBody(action, data, url2, headers) {
19914
19934
  throw new TypeError("Runtime file contents must be binary data.");
19915
19935
  }
19916
19936
  headers["Content-Type"] = "application/octet-stream";
19917
- return Uint8Array.from(
19918
- new Uint8Array(payload.contents.buffer, payload.contents.byteOffset, payload.contents.byteLength)
19919
- ).buffer;
19937
+ return Uint8Array.from(new Uint8Array(payload.contents.buffer, payload.contents.byteOffset, payload.contents.byteLength)).buffer;
19920
19938
  }
19921
19939
  headers["Content-Type"] = "application/json";
19922
19940
  return JSON.stringify(data);
@@ -19978,11 +19996,11 @@ var Feedback = class {
19978
19996
  async list(options = {}) {
19979
19997
  const query = new URLSearchParams();
19980
19998
  for (const [name, value] of Object.entries(options)) {
19981
- if (value !== void 0) query.set(name, String(value));
19999
+ if (value !== void 0) {
20000
+ query.set(name, String(value));
20001
+ }
19982
20002
  }
19983
- return this.client.get(
19984
- `${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`
19985
- );
20003
+ return this.client.get(`${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`);
19986
20004
  }
19987
20005
  async get(id) {
19988
20006
  const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
@@ -20030,10 +20048,7 @@ var Integration = class _Integration {
20030
20048
  return this.data.label;
20031
20049
  }
20032
20050
  async update(input) {
20033
- const response = await this.client.patch(
20034
- `/integrations/${encodeURIComponent(this.id)}`,
20035
- input
20036
- );
20051
+ const response = await this.client.patch(`/integrations/${encodeURIComponent(this.id)}`, input);
20037
20052
  return new _Integration(response.data, this.client);
20038
20053
  }
20039
20054
  async unlink() {
@@ -20296,6 +20311,14 @@ var PHPSandbox = class _PHPSandbox {
20296
20311
  this.servers = client.servers;
20297
20312
  this.integrations = client.integrations;
20298
20313
  }
20314
+ async whoami() {
20315
+ const { data } = await this.client.get("/auth/whoami");
20316
+ const result = identitySchema.safeParse(data);
20317
+ if (!result.success) {
20318
+ throw new PHPSandboxError("Invalid identity response.");
20319
+ }
20320
+ return result.data;
20321
+ }
20299
20322
  get runtimeTransport() {
20300
20323
  return this.client.runtimeTransport;
20301
20324
  }
@@ -20343,7 +20366,6 @@ var _NotebookInstance = class _NotebookInstance {
20343
20366
  }
20344
20367
  this.files = new Filesystem(this, this.socket === null ? null : (handler) => this.onDidConnect(handler));
20345
20368
  this.terminals = new Terminals(this);
20346
- this.auth = new Auth(this);
20347
20369
  this.lsp = new Lsp(this);
20348
20370
  this.composer = new Composer(this, client);
20349
20371
  this.runtime = new Runtime(this);
@@ -20544,7 +20566,7 @@ var _NotebookInstance = class _NotebookInstance {
20544
20566
  socket.reconnect();
20545
20567
  this.initialized = false;
20546
20568
  await whenConnected;
20547
- __privateMethod(this, _NotebookInstance_instances, init_fn).call(this);
20569
+ __privateSet(this, _initPromise, __privateMethod(this, _NotebookInstance_instances, init_fn).call(this));
20548
20570
  return this.ready().then(() => this);
20549
20571
  }
20550
20572
  realtimeSocket() {
@@ -20593,7 +20615,9 @@ var NotebookSecrets = class {
20593
20615
  }
20594
20616
  async list(options) {
20595
20617
  const params = new URLSearchParams();
20596
- if (options?.environment) params.set("environment", options.environment);
20618
+ if (options?.environment) {
20619
+ params.set("environment", options.environment);
20620
+ }
20597
20621
  const query = params.toString();
20598
20622
  const response = await this.client.get(
20599
20623
  `/notebook/${this.notebookId}/secrets${query ? `?${query}` : ""}`
@@ -20613,7 +20637,9 @@ var NotebookSecrets = class {
20613
20637
  }
20614
20638
  async delete(name, options) {
20615
20639
  const params = new URLSearchParams();
20616
- if (options?.environment) params.set("environment", options.environment);
20640
+ if (options?.environment) {
20641
+ params.set("environment", options.environment);
20642
+ }
20617
20643
  const query = params.toString();
20618
20644
  await this.client.delete(`/notebook/${this.notebookId}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ""}`);
20619
20645
  }