@keska/sandbox 0.44.0 → 0.46.1

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 (3) hide show
  1. package/dist/index.d.ts +736 -223
  2. package/dist/index.js +1556 -466
  3. package/package.json +4 -3
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ type ResourceUsage = {
38
38
  cpuUsageUsec: number;
39
39
  cpuMillicores: number;
40
40
  };
41
- /** Live sandbox record from create, open, get, or park. */
41
+ /** Live sandbox record from create, wake, get, or sleep. */
42
42
  type SandboxInfo = {
43
43
  id: string;
44
44
  name: string;
@@ -49,7 +49,7 @@ type SandboxInfo = {
49
49
  secretEnv: Record<string, string>;
50
50
  workdir: string;
51
51
  labels: Record<string, string>;
52
- tags: string[];
52
+ profileId: string;
53
53
  /** How the sandbox reaches the network. */
54
54
  net: string;
55
55
  volumeId: string;
@@ -77,7 +77,7 @@ type SandboxSummary = {
77
77
  image: string;
78
78
  name: string;
79
79
  labels: Record<string, string>;
80
- tags: string[];
80
+ profileId: string;
81
81
  createdAt: string;
82
82
  usage: ResourceUsage | null;
83
83
  /** The worker holding this sandbox cannot be reached. The status stays the last recorded value. */
@@ -171,41 +171,72 @@ type SecretList = {
171
171
  secrets: Secret[];
172
172
  nextPageToken: string;
173
173
  };
174
- /** One Matrix agent. `matrixUserId` is who you invite. `secretEnv` maps an env name to a secret name. Values are not included. */
174
+ /** One agent on the wire. `secretEnv` maps an env name to a secret name. Values are not included. */
175
175
  type Agent$1 = {
176
176
  id: string;
177
177
  name: string;
178
178
  matrixUserId: string;
179
179
  secretEnv: Record<string, string>;
180
180
  createdAt: string;
181
+ /** Sandbox this agent is attached to now. Empty when it has none. */
182
+ activeSandboxId: string;
183
+ messaging: boolean;
184
+ matrixRoomId: string;
185
+ templateId: string;
186
+ image: string;
187
+ profileId: string;
181
188
  };
182
189
  type AgentList = {
183
190
  agents: Agent$1[];
184
191
  nextPageToken: string;
185
192
  };
186
- /** Returned only by the call that mints the project token. */
187
- type Token = {
193
+ /** Short-lived Matrix device for an SDK process (CreateMatrixSession). */
194
+ type MatrixSession = {
188
195
  homeserver: string;
189
196
  userId: string;
190
197
  accessToken: string;
198
+ sessionId: string;
191
199
  };
192
- /** Whether a project token is issued. The access token is not here. */
193
- type TokenStatus = {
194
- homeserver: string;
195
- userId: string;
196
- issued: boolean;
200
+ type ScanCheck = "vulnerabilities" | "secrets";
201
+ type RuntimeEvent = "exec" | "filesystem" | "network";
202
+ type Severity = "low" | "medium" | "high" | "critical" | "";
203
+ type ScanPolicy = {
204
+ checks: ScanCheck[];
205
+ every?: string;
206
+ minSeverity?: Severity;
207
+ };
208
+ type RuntimePolicy = {
209
+ events: RuntimeEvent[];
210
+ };
211
+ type Profile$1 = {
212
+ id: string;
213
+ name: string;
214
+ resourcePolicyId: string;
215
+ securityPolicyId: string;
216
+ resourcePolicy: ResourcePolicy$1 | null;
217
+ securityPolicy: SecurityPolicy$1 | null;
218
+ sandboxCount: number;
219
+ templateCount: number;
220
+ agentCount: number;
221
+ createdAt: string;
222
+ updatedAt: string;
223
+ };
224
+ type ProfileList = {
225
+ profiles: Profile$1[];
226
+ nextPageToken: string;
197
227
  };
198
- /** A tag. Create it before passing its name to `create`. */
199
- type Tag = {
228
+ type Template$1 = {
200
229
  id: string;
201
230
  name: string;
202
- policyId: string;
203
- attachmentCount: number;
231
+ image: string;
232
+ secretEnv: Record<string, string>;
233
+ profileId: string;
234
+ agentCount: number;
204
235
  createdAt: string;
205
236
  updatedAt: string;
206
237
  };
207
- type TagList = {
208
- tags: Tag[];
238
+ type TemplateList = {
239
+ templates: Template$1[];
209
240
  nextPageToken: string;
210
241
  };
211
242
  type ImageKind = "platform" | "project" | "";
@@ -220,86 +251,34 @@ type ImageList = {
220
251
  images: Image[];
221
252
  nextPageToken: string;
222
253
  };
223
- /** Falco/IDS source class. Public SDK names; wire is SECURITY_SOURCE_CLASS_*. */
224
- declare const SecuritySourceClass: {
225
- readonly unspecified: "unspecified";
226
- readonly exec: "exec";
227
- readonly filesystem: "filesystem";
228
- readonly network: "network";
229
- };
230
- type SecuritySourceClassName = (typeof SecuritySourceClass)[keyof typeof SecuritySourceClass];
231
- type AVPolicy = {
232
- enabled: boolean;
233
- scanners: string[];
234
- skipDbUpdate: boolean;
235
- workScanIntervalMs: number;
236
- minSeverity: string[];
237
- ignoreUnfixed: boolean;
238
- };
239
- /** IDS policy. allowedSources are alert groups. allowedRules filters Falco's own rule names and does not select a rules file. */
240
- type IDSPolicy = {
241
- enabled: boolean;
242
- allowedSources: SecuritySourceClassName[];
243
- allowedRules: string[];
244
- blockedRules: string[];
245
- minPriority: string;
246
- };
247
- type PolicyNodeAck = {
248
- nodeId: string;
249
- ackedAtUnix: number;
250
- error: string;
251
- };
252
- type PolicyRollout = {
253
- revision: number;
254
- expectedNodes: string[];
255
- missingNodes: string[];
256
- acks: PolicyNodeAck[];
257
- complete: boolean;
258
- hubUnavailable: boolean;
259
- };
260
- /** Named AV+IDS document. Bind with Tag.securityPolicy. */
261
- type SecurityPolicy = {
262
- id: string;
263
- name: string;
264
- av: AVPolicy;
265
- ids: IDSPolicy;
266
- preset: string;
267
- attachmentCount: number;
268
- createdAt: string;
269
- updatedAt: string;
270
- };
271
- type ResourcePolicy = {
254
+ /** Named AV+IDS document. Bind with Profile.securityPolicyId. */
255
+ type SecurityPolicy$1 = {
272
256
  id: string;
273
257
  name: string;
274
- cpuMillicores: number;
275
- memoryBytes: number;
276
- diskBytes: number;
258
+ scanning: ScanPolicy | null;
259
+ runtime: RuntimePolicy | null;
260
+ profileCount: number;
277
261
  createdAt: string;
278
262
  updatedAt: string;
279
263
  };
280
- type PolicySection = {
281
- kind: "security" | "resource" | "";
282
- ref: string;
264
+ type SecurityPolicyList = {
265
+ policies: SecurityPolicy$1[];
266
+ nextPageToken: string;
283
267
  };
284
- type Policy = {
268
+ type ResourcePolicy$1 = {
285
269
  id: string;
286
270
  name: string;
287
- sections: PolicySection[];
288
- attachmentCount: number;
289
- security: SecurityPolicy | null;
290
- resources: ResourcePolicy | null;
271
+ cpuMillicores: number | null;
272
+ memoryBytes: number | null;
273
+ diskBytes: number | null;
274
+ profileCount: number;
291
275
  createdAt: string;
292
276
  updatedAt: string;
293
277
  };
294
- type PolicyList = {
295
- policies: Policy[];
278
+ type ResourcePolicyList = {
279
+ policies: ResourcePolicy$1[];
296
280
  nextPageToken: string;
297
281
  };
298
- type PolicyMutation = {
299
- policy: Policy;
300
- avRollout: PolicyRollout;
301
- idsRollout: PolicyRollout;
302
- };
303
282
  /** One file or directory from `ls` or `stat`. */
304
283
  type FileInfo = {
305
284
  name: string;
@@ -456,6 +435,10 @@ declare class AuthenticationError extends SandboxError {
456
435
  /** A call argument is missing or not allowed. */
457
436
  declare class InvalidArgumentError extends SandboxError {
458
437
  }
438
+ /** Delete is blocked because another object still references this one. */
439
+ declare class ResourceInUseError extends SandboxError {
440
+ get count(): number;
441
+ }
459
442
  /** argv, env, and cwd together exceed the command limit. */
460
443
  declare class CommandTooLargeError extends InvalidArgumentError {
461
444
  }
@@ -491,8 +474,8 @@ type CreateSandboxParams = {
491
474
  workdir?: string;
492
475
  lifetimeSec?: number;
493
476
  idleTimeoutSec?: number;
494
- /** Project tag names that must already exist. */
495
- tags?: string[];
477
+ /** Existing profile id. Empty means no profile. */
478
+ profileId?: string;
496
479
  fromSnapshotId?: string;
497
480
  volumeId?: string;
498
481
  labels?: Record<string, string>;
@@ -572,7 +555,7 @@ declare class Session {
572
555
  close(): void;
573
556
  get forwardBaseUrl(): string;
574
557
  /** Byte stream to a guest port. The call is gRPC on `sbx`.
575
- * Park drops the VMM, so an open forward ends; close it and open a new one after `open()`. */
558
+ * Sleep drops the VMM, so an open forward ends; close it and open a new one after `wake()`. */
576
559
  forward(sandboxId: string, port: number, opts?: CallOpts & {
577
560
  baseUrl?: string;
578
561
  }): Promise<ForwardSession>;
@@ -604,8 +587,8 @@ declare class Session {
604
587
  getGuestHeaders(): Promise<Record<string, string>>;
605
588
  /** CreateSandbox. The server mints the id. `name` is an optional lookup. */
606
589
  createSandbox(params: CreateSandboxParams): Promise<SandboxInfo>;
607
- /** OpenSandbox: wake by id or name. Does not create. */
608
- openSandbox(sandboxId?: string, opts?: CallOpts & {
590
+ /** WakeSandbox: wake by id or name. Does not create. */
591
+ wakeSandbox(sandboxId?: string, opts?: CallOpts & {
609
592
  name?: string;
610
593
  }): Promise<SandboxInfo>;
611
594
  listLogArchives(opts?: CallOpts & {
@@ -619,7 +602,7 @@ declare class Session {
619
602
  name: string;
620
603
  image: string;
621
604
  labels: Record<string, string>;
622
- tags: string[];
605
+ profileId: string;
623
606
  createdAt: string;
624
607
  }[];
625
608
  nextPageToken: string;
@@ -653,22 +636,33 @@ declare class Session {
653
636
  }): Promise<SandboxInfo>;
654
637
  listSandboxes(opts?: CallOpts & {
655
638
  labels?: Record<string, string>;
656
- tags?: string[];
639
+ profileId?: string;
657
640
  statuses?: Array<string | number>;
658
641
  pageSize?: number;
659
642
  pageToken?: string;
660
643
  }): Promise<SandboxList>;
644
+ updateSandbox(sandboxId: string, opts?: CallOpts & {
645
+ labels?: Record<string, string>;
646
+ profileId?: string | null;
647
+ }): Promise<SandboxInfo>;
661
648
  setSandboxLabels(sandboxId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<SandboxInfo>;
649
+ resizeSandbox(sandboxId: string, packing: {
650
+ cpuMillicores?: number;
651
+ memoryBytes?: number;
652
+ diskBytes?: number;
653
+ }, opts?: CallOpts): Promise<SandboxInfo>;
662
654
  setSandboxSize(sandboxId: string, packing: {
663
655
  cpuMillicores?: number;
664
656
  memoryBytes?: number;
665
657
  diskBytes?: number;
666
658
  }, opts?: CallOpts): Promise<SandboxInfo>;
667
- setSandboxTags(sandboxId: string, tags: string[] | undefined, opts?: CallOpts): Promise<SandboxInfo>;
659
+ setSandboxProfile(sandboxId: string, profileId: string | undefined | null, opts?: CallOpts): Promise<SandboxInfo>;
668
660
  /** DeleteSandbox. Idempotent if gone. Named volumes stay. */
669
661
  deleteSandbox(sandboxId: string, opts?: CallOpts): Promise<void>;
670
- /** ParkSandbox: reboot. Commit the writable layer, drop the VM, keep the id. */
671
- parkSandbox(sandboxId: string, opts?: CallOpts): Promise<SandboxInfo>;
662
+ /** SleepSandbox: stop the VM and keep the id. */
663
+ sleepSandbox(sandboxId?: string, opts?: CallOpts & {
664
+ name?: string;
665
+ }): Promise<SandboxInfo>;
672
666
  execStream(sandboxId: string, argv: string[], opts?: ExecStreamOpts): AsyncGenerator<StreamChunk, number | undefined>;
673
667
  startProcess(sandboxId: string, argv: string[], opts?: CallOpts & {
674
668
  env?: Record<string, string>;
@@ -728,7 +722,7 @@ declare class Session {
728
722
  pageSize?: number;
729
723
  pageToken?: string;
730
724
  }): Promise<SnapshotList>;
731
- setSnapshotLabels(snapshotId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Snapshot>;
725
+ updateSnapshot(snapshotId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Snapshot>;
732
726
  deleteSnapshot(snapshotId: string, opts?: CallOpts): Promise<void>;
733
727
  /** Named workdir disk that survives sandbox delete. Attach at Create. */
734
728
  createVolume(opts?: CallOpts & {
@@ -752,53 +746,105 @@ declare class Session {
752
746
  pageToken?: string;
753
747
  }): Promise<SecretList>;
754
748
  deleteSecret(name: string, opts?: CallOpts): Promise<void>;
755
- createAgent(name: string, opts?: CallOpts): Promise<Agent$1>;
756
- getAgent(id: string, opts?: CallOpts): Promise<Agent$1>;
749
+ createAgent(name: string, opts?: CallOpts & {
750
+ templateId?: string;
751
+ messaging?: boolean;
752
+ }): Promise<Agent$1>;
753
+ getAgent(id?: string, opts?: CallOpts & {
754
+ name?: string;
755
+ }): Promise<Agent$1>;
757
756
  listAgents(opts?: CallOpts & {
758
757
  pageSize?: number;
759
758
  pageToken?: string;
759
+ messaging?: boolean;
760
760
  }): Promise<AgentList>;
761
761
  deleteAgent(id: string, opts?: CallOpts): Promise<void>;
762
- setAgentSecret(agentId: string, envName: string, value: string, opts?: CallOpts): Promise<Agent$1>;
763
- deleteAgentSecret(agentId: string, envName: string, opts?: CallOpts): Promise<Agent$1>;
764
- createToken(opts?: CallOpts): Promise<Token>;
765
- tokenStatus(opts?: CallOpts): Promise<TokenStatus>;
766
- revokeToken(opts?: CallOpts): Promise<void>;
767
- createTag(name: string, opts?: CallOpts & {
768
- policyId?: string;
769
- }): Promise<Tag>;
770
- getTag(tagId: string, opts?: CallOpts): Promise<Tag>;
771
- listTags(opts?: CallOpts & {
772
- pageSize?: number;
773
- pageToken?: string;
774
- }): Promise<TagList>;
775
- updateTag(tagId: string, opts?: CallOpts & {
776
- policyId?: string;
777
- }): Promise<Tag>;
778
- createPolicy(name: string, opts?: CallOpts & {
779
- av?: AVPolicy;
780
- ids?: IDSPolicy;
781
- preset?: string;
762
+ bindAgentSecret(agentId: string, envName: string, secretName: string, opts?: CallOpts): Promise<Agent$1>;
763
+ unbindAgentSecret(agentId: string, envName: string, opts?: CallOpts): Promise<Agent$1>;
764
+ createMatrixSession(opts?: CallOpts): Promise<MatrixSession>;
765
+ deleteMatrixSession(sessionId: string, opts?: CallOpts): Promise<void>;
766
+ createResourcePolicy(name: string, opts?: CallOpts & {
782
767
  cpuMillicores?: number;
783
768
  memoryBytes?: number;
784
769
  diskBytes?: number;
785
- }): Promise<PolicyMutation>;
786
- getPolicy(policyId: string, opts?: CallOpts): Promise<Policy>;
787
- listPolicies(opts?: CallOpts & {
770
+ }): Promise<ResourcePolicy$1>;
771
+ getResourcePolicy(id?: string, opts?: CallOpts & {
772
+ name?: string;
773
+ }): Promise<ResourcePolicy$1>;
774
+ getResourcePolicyByName(name: string, opts?: CallOpts): Promise<ResourcePolicy$1>;
775
+ listResourcePolicies(opts?: CallOpts & {
788
776
  pageSize?: number;
789
777
  pageToken?: string;
790
- }): Promise<PolicyList>;
791
- updatePolicy(policyId: string, opts?: CallOpts & {
778
+ }): Promise<ResourcePolicyList>;
779
+ updateResourcePolicy(id: string, opts?: CallOpts & {
792
780
  name?: string;
793
- av?: AVPolicy;
794
- ids?: IDSPolicy;
795
- preset?: string;
796
- cpuMillicores?: number;
797
- memoryBytes?: number;
798
- diskBytes?: number;
799
- }): Promise<PolicyMutation>;
800
- deletePolicy(policyId: string, opts?: CallOpts): Promise<void>;
801
- deleteTag(tagId: string, opts?: CallOpts): Promise<void>;
781
+ cpuMillicores?: number | null;
782
+ memoryBytes?: number | null;
783
+ diskBytes?: number | null;
784
+ clearCpu?: boolean;
785
+ clearMemory?: boolean;
786
+ clearDisk?: boolean;
787
+ }): Promise<ResourcePolicy$1>;
788
+ deleteResourcePolicy(id: string, opts?: CallOpts): Promise<void>;
789
+ createSecurityPolicy(name: string, opts?: CallOpts & {
790
+ scanning?: ScanPolicy;
791
+ runtime?: RuntimePolicy;
792
+ }): Promise<SecurityPolicy$1>;
793
+ getSecurityPolicy(id?: string, opts?: CallOpts & {
794
+ name?: string;
795
+ }): Promise<SecurityPolicy$1>;
796
+ getSecurityPolicyByName(name: string, opts?: CallOpts): Promise<SecurityPolicy$1>;
797
+ listSecurityPolicies(opts?: CallOpts & {
798
+ pageSize?: number;
799
+ pageToken?: string;
800
+ }): Promise<SecurityPolicyList>;
801
+ updateSecurityPolicy(id: string, opts?: CallOpts & {
802
+ name?: string;
803
+ scanning?: ScanPolicy | null;
804
+ runtime?: RuntimePolicy | null;
805
+ clearScanning?: boolean;
806
+ clearRuntime?: boolean;
807
+ }): Promise<SecurityPolicy$1>;
808
+ deleteSecurityPolicy(id: string, opts?: CallOpts): Promise<void>;
809
+ createProfile(name: string, opts?: CallOpts & {
810
+ resourcePolicyId?: string;
811
+ securityPolicyId?: string;
812
+ }): Promise<Profile$1>;
813
+ getProfile(id?: string, opts?: CallOpts & {
814
+ name?: string;
815
+ }): Promise<Profile$1>;
816
+ getProfileByName(name: string, opts?: CallOpts): Promise<Profile$1>;
817
+ listProfiles(opts?: CallOpts & {
818
+ pageSize?: number;
819
+ pageToken?: string;
820
+ }): Promise<ProfileList>;
821
+ updateProfile(id: string, opts?: CallOpts & {
822
+ name?: string;
823
+ resourcePolicyId?: string | null;
824
+ securityPolicyId?: string | null;
825
+ clearResources?: boolean;
826
+ clearSecurity?: boolean;
827
+ }): Promise<Profile$1>;
828
+ deleteProfile(id: string, opts?: CallOpts): Promise<void>;
829
+ createTemplate(name: string, image: string, opts?: CallOpts & {
830
+ profileId?: string;
831
+ secretEnv?: Record<string, string>;
832
+ }): Promise<Template$1>;
833
+ getTemplate(id?: string, opts?: CallOpts & {
834
+ name?: string;
835
+ }): Promise<Template$1>;
836
+ listTemplates(opts?: CallOpts & {
837
+ pageSize?: number;
838
+ pageToken?: string;
839
+ }): Promise<TemplateList>;
840
+ updateTemplate(id: string, opts?: CallOpts & {
841
+ name?: string;
842
+ image?: string;
843
+ profileId?: string | null;
844
+ secretEnv?: Record<string, string>;
845
+ clearProfile?: boolean;
846
+ }): Promise<Template$1>;
847
+ deleteTemplate(id: string, opts?: CallOpts): Promise<void>;
802
848
  registerImage(name: string, opts: CallOpts & {
803
849
  from: string;
804
850
  waitUntilReady?: boolean;
@@ -816,7 +862,7 @@ declare class Session {
816
862
  pageToken?: string;
817
863
  }): Promise<ImageList>;
818
864
  deleteImage(name: string, opts?: CallOpts): Promise<void>;
819
- setVolumeLabels(volumeId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Volume>;
865
+ updateVolume(volumeId: string, labels: Record<string, string> | undefined, opts?: CallOpts): Promise<Volume>;
820
866
  deleteVolume(volumeId: string, opts?: CallOpts): Promise<void>;
821
867
  }
822
868
 
@@ -848,7 +894,107 @@ declare class GuestHttp$1 {
848
894
  websocket(path?: string): Promise<WebSocket>;
849
895
  }
850
896
 
851
- /** Public catalog client. Guest calls live on `Sandbox`, not here. */
897
+ type RawEvent = {
898
+ type?: string;
899
+ event_id?: string;
900
+ sender?: string;
901
+ origin_server_ts?: number;
902
+ content?: Record<string, unknown>;
903
+ };
904
+ type SyncBody = {
905
+ next_batch?: string;
906
+ rooms?: {
907
+ join?: Record<string, {
908
+ timeline?: {
909
+ events?: RawEvent[];
910
+ prev_batch?: string;
911
+ };
912
+ }>;
913
+ };
914
+ };
915
+ interface RoomIO {
916
+ send(roomId: string, content: Record<string, unknown>): Promise<string>;
917
+ messages(roomId: string, fromToken: string, limit: number): Promise<{
918
+ chunk: RawEvent[];
919
+ end: string;
920
+ }>;
921
+ sync(since: string | null, timeoutMs: number): Promise<SyncBody>;
922
+ /**
923
+ * Optional first window for history: this room's recent message timeline
924
+ * only. A plain `sync(null, 0)` on a fresh device is an initial sync over
925
+ * every joined room, which takes seconds; implementations that can scope
926
+ * the request to one room should.
927
+ */
928
+ historyWindow?(roomId: string, limit: number): Promise<SyncBody>;
929
+ close(): void;
930
+ }
931
+
932
+ /** Agent DM timeline and live-stream event shapes. */
933
+
934
+ type SenderKind = "agent" | "user" | "unknown";
935
+ /** One text message in the agent DM. */
936
+ type MessageEvent = {
937
+ /** Discriminator; always `"message"`. */
938
+ type: "message";
939
+ /** Message body. */
940
+ content: string;
941
+ /** Matrix user id of the sender. */
942
+ sender: string;
943
+ /** Matrix event id. */
944
+ eventId: string;
945
+ /** Server timestamp in milliseconds. */
946
+ ts: number;
947
+ /** Whether the sender is the agent, the portal user, or unknown. */
948
+ senderKind?: SenderKind;
949
+ /** Human-readable sender label when known. */
950
+ senderLabel?: string;
951
+ /** Set when an agent posted a protocol final. */
952
+ isFinal?: boolean;
953
+ /** Agent final tied to a human trigger, when present on the Matrix event. */
954
+ triggerEventId?: string;
955
+ };
956
+
957
+ /** Display labels for Matrix senders on agent message events. */
958
+
959
+ type SenderLabelContext = {
960
+ agentMatrixUserId?: string;
961
+ agentName?: string;
962
+ projectUserId?: string;
963
+ };
964
+
965
+ /** One sync pump per Client; room subscriptions receive live messaging events. */
966
+
967
+ declare class RoomSyncPump {
968
+ private readonly io;
969
+ private since;
970
+ private primed;
971
+ private running;
972
+ private stopped;
973
+ private readonly rooms;
974
+ private readonly seenByRoom;
975
+ constructor(io: RoomIO);
976
+ subscribe(roomId: string, labels: SenderLabelContext): MessageSubscription;
977
+ unsubscribe(sub: MessageSubscription, roomId: string): void;
978
+ stop(): void;
979
+ private hasSubscribers;
980
+ private ensurePrimed;
981
+ private seen;
982
+ private deliver;
983
+ private loop;
984
+ take(sub: MessageSubscription, roomId: string): MessageEvent | undefined;
985
+ waitFor(sub: MessageSubscription, roomId: string): Promise<void>;
986
+ isOpen(sub: MessageSubscription, roomId: string): boolean;
987
+ }
988
+ /** Live messaging events for one room. Start before `post()` so fast replies are not missed. */
989
+ declare class MessageSubscription {
990
+ private readonly pump;
991
+ private readonly roomId;
992
+ constructor(pump: RoomSyncPump, roomId: string);
993
+ /** Stop receiving events. */
994
+ close(): void;
995
+ /** Iterate live agent messages until {@link MessageSubscription.close}. */
996
+ [Symbol.asyncIterator](): AsyncIterator<MessageEvent>;
997
+ }
852
998
 
853
999
  type TimeoutOpts = {
854
1000
  timeout?: number;
@@ -874,6 +1020,8 @@ declare class Volumes$1 {
874
1020
  pageSize?: number;
875
1021
  pageToken?: string;
876
1022
  } & TimeoutOpts): Promise<VolumeList>;
1023
+ /** Update labels. */
1024
+ update(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Volume>;
877
1025
  /** Set Labels. */
878
1026
  setLabels(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Volume>;
879
1027
  /** Delete. */
@@ -902,7 +1050,12 @@ declare class Agents$1 {
902
1050
  /** Create the handle. */
903
1051
  constructor(wire: Session);
904
1052
  /** Create. */
905
- create(name: string, opts?: TimeoutOpts): Promise<Agent$1>;
1053
+ create(name: string, opts?: {
1054
+ template?: string;
1055
+ messaging?: boolean;
1056
+ } & TimeoutOpts): Promise<Agent$1>;
1057
+ /** Get by name. */
1058
+ getByName(name: string, opts?: TimeoutOpts): Promise<Agent$1>;
906
1059
  /** Get. */
907
1060
  get(id: string, opts?: TimeoutOpts): Promise<Agent$1>;
908
1061
  /** List. */
@@ -910,18 +1063,12 @@ declare class Agents$1 {
910
1063
  pageSize?: number;
911
1064
  pageToken?: string;
912
1065
  } & TimeoutOpts): Promise<AgentList>;
913
- /** Delete. */
1066
+ /** Delete an agent that has no live sandbox. */
914
1067
  delete(id: string, opts?: TimeoutOpts): Promise<void>;
915
- /** Bind an env name. A name starting with `MATRIX_` is rejected. */
916
- setSecret(id: string, envName: string, value: string, opts?: TimeoutOpts): Promise<Agent$1>;
1068
+ /** Bind an env name to a project secret. */
1069
+ bindSecret(id: string, envName: string, secretName: string, opts?: TimeoutOpts): Promise<Agent$1>;
917
1070
  /** Remove one binding. Fails with reason `AGENT_BUSY` while a sandbox is live. */
918
- deleteSecret(id: string, envName: string, opts?: TimeoutOpts): Promise<Agent$1>;
919
- /** Return `homeserver`, `userId`, and `accessToken` once. A second call fails with reason `TOKEN_EXISTS`. */
920
- createToken(opts?: TimeoutOpts): Promise<Token>;
921
- /** Return `homeserver`, `userId`, and `issued`. The access token is not included. */
922
- tokenStatus(opts?: TimeoutOpts): Promise<TokenStatus>;
923
- /** Log out the user from `createToken`. Succeeds when nothing is issued. Do not call this on startup. */
924
- revokeToken(opts?: TimeoutOpts): Promise<void>;
1071
+ unbindSecret(id: string, envName: string, opts?: TimeoutOpts): Promise<Agent$1>;
925
1072
  }
926
1073
  /** Platform names and project images. */
927
1074
  declare class Images$1 {
@@ -967,37 +1114,139 @@ declare class Snapshots$1 {
967
1114
  pageSize?: number;
968
1115
  pageToken?: string;
969
1116
  } & TimeoutOpts): Promise<SnapshotList>;
1117
+ /** Update labels. */
1118
+ update(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Snapshot>;
970
1119
  /** Set Labels. */
971
1120
  setLabels(id: string, labels?: Record<string, string>, opts?: TimeoutOpts): Promise<Snapshot>;
972
1121
  /** Delete. */
973
1122
  delete(id: string, opts?: TimeoutOpts): Promise<void>;
974
1123
  }
975
- /** Configurations. Each one points at a policy set created in the portal. */
976
- declare class Tags$1 {
1124
+ /** Named CPU/memory/disk documents. */
1125
+ declare class ResourcePolicies$1 {
1126
+ private readonly wire;
1127
+ /** Create the handle. */
1128
+ constructor(wire: Session);
1129
+ /** Create. */
1130
+ create(name: string, opts?: {
1131
+ cpuMillicores?: number;
1132
+ memoryBytes?: number;
1133
+ diskBytes?: number;
1134
+ } & TimeoutOpts): Promise<ResourcePolicy$1>;
1135
+ /** Get. */
1136
+ get(id: string, opts?: TimeoutOpts): Promise<ResourcePolicy$1>;
1137
+ /** Get by name. */
1138
+ getByName(name: string, opts?: TimeoutOpts): Promise<ResourcePolicy$1>;
1139
+ /** List. */
1140
+ list(opts?: {
1141
+ pageSize?: number;
1142
+ pageToken?: string;
1143
+ } & TimeoutOpts): Promise<ResourcePolicyList>;
1144
+ /** Update. */
1145
+ update(id: string, opts?: {
1146
+ name?: string;
1147
+ cpuMillicores?: number | null;
1148
+ memoryBytes?: number | null;
1149
+ diskBytes?: number | null;
1150
+ clearCpu?: boolean;
1151
+ clearMemory?: boolean;
1152
+ clearDisk?: boolean;
1153
+ } & TimeoutOpts): Promise<ResourcePolicy$1>;
1154
+ /** Delete. */
1155
+ delete(id: string, opts?: TimeoutOpts): Promise<void>;
1156
+ }
1157
+ /** Named scanning/runtime documents. */
1158
+ declare class SecurityPolicies$1 {
977
1159
  private readonly wire;
978
1160
  /** Create the handle. */
979
1161
  constructor(wire: Session);
980
1162
  /** Create. */
981
1163
  create(name: string, opts?: {
982
- policyId?: string;
983
- } & TimeoutOpts): Promise<Tag>;
1164
+ scanning?: ScanPolicy;
1165
+ runtime?: RuntimePolicy;
1166
+ } & TimeoutOpts): Promise<SecurityPolicy$1>;
1167
+ /** Get. */
1168
+ get(id: string, opts?: TimeoutOpts): Promise<SecurityPolicy$1>;
1169
+ /** Get by name. */
1170
+ getByName(name: string, opts?: TimeoutOpts): Promise<SecurityPolicy$1>;
1171
+ /** List. */
1172
+ list(opts?: {
1173
+ pageSize?: number;
1174
+ pageToken?: string;
1175
+ } & TimeoutOpts): Promise<SecurityPolicyList>;
1176
+ /** Update. */
1177
+ update(id: string, opts?: {
1178
+ name?: string;
1179
+ scanning?: ScanPolicy | null;
1180
+ runtime?: RuntimePolicy | null;
1181
+ clearScanning?: boolean;
1182
+ clearRuntime?: boolean;
1183
+ } & TimeoutOpts): Promise<SecurityPolicy$1>;
1184
+ /** Delete. */
1185
+ delete(id: string, opts?: TimeoutOpts): Promise<void>;
1186
+ }
1187
+ /** Named profile that points at resource and/or security policies. */
1188
+ declare class Profiles$1 {
1189
+ private readonly wire;
1190
+ /** Create the handle. */
1191
+ constructor(wire: Session);
1192
+ /** Create. */
1193
+ create(name: string, opts?: {
1194
+ resourcePolicyId?: string;
1195
+ securityPolicyId?: string;
1196
+ } & TimeoutOpts): Promise<Profile$1>;
1197
+ /** Get. */
1198
+ get(id: string, opts?: TimeoutOpts): Promise<Profile$1>;
1199
+ /** Get by name. */
1200
+ getByName(name: string, opts?: TimeoutOpts): Promise<Profile$1>;
1201
+ /** List. */
1202
+ list(opts?: {
1203
+ pageSize?: number;
1204
+ pageToken?: string;
1205
+ } & TimeoutOpts): Promise<ProfileList>;
1206
+ /** Update. */
1207
+ update(id: string, opts?: {
1208
+ name?: string;
1209
+ resourcePolicyId?: string | null;
1210
+ securityPolicyId?: string | null;
1211
+ clearResources?: boolean;
1212
+ clearSecurity?: boolean;
1213
+ } & TimeoutOpts): Promise<Profile$1>;
1214
+ /** Delete. */
1215
+ delete(id: string, opts?: TimeoutOpts): Promise<void>;
1216
+ }
1217
+ /** Agent create templates. */
1218
+ declare class Templates$1 {
1219
+ private readonly wire;
1220
+ /** Create the handle. */
1221
+ constructor(wire: Session);
1222
+ /** Create. */
1223
+ create(name: string, image: string, opts?: {
1224
+ profileId?: string;
1225
+ secretEnv?: Record<string, string>;
1226
+ } & TimeoutOpts): Promise<Template$1>;
984
1227
  /** Get. */
985
- get(id: string, opts?: TimeoutOpts): Promise<Tag>;
1228
+ get(id: string, opts?: TimeoutOpts): Promise<Template$1>;
1229
+ /** Get by name. */
1230
+ getByName(name: string, opts?: TimeoutOpts): Promise<Template$1>;
986
1231
  /** List. */
987
1232
  list(opts?: {
988
1233
  pageSize?: number;
989
1234
  pageToken?: string;
990
- } & TimeoutOpts): Promise<TagList>;
1235
+ } & TimeoutOpts): Promise<TemplateList>;
991
1236
  /** Update. */
992
1237
  update(id: string, opts?: {
993
- policyId?: string;
994
- } & TimeoutOpts): Promise<Tag>;
1238
+ name?: string;
1239
+ image?: string;
1240
+ profileId?: string | null;
1241
+ secretEnv?: Record<string, string>;
1242
+ clearProfile?: boolean;
1243
+ } & TimeoutOpts): Promise<Template$1>;
995
1244
  /** Delete. */
996
1245
  delete(id: string, opts?: TimeoutOpts): Promise<void>;
997
1246
  }
998
- /** Images, volumes, secrets, tags, and snapshot inventory.
1247
+ /** Images, volumes, secrets, profiles, and snapshot inventory.
999
1248
  *
1000
- * Sandboxes are created with Sandbox.create. Policies are created in the portal.
1249
+ * Sandboxes are created with Sandbox.create.
1001
1250
  */
1002
1251
  declare class Client$1 {
1003
1252
  /** Base Url. */
@@ -1014,10 +1263,20 @@ declare class Client$1 {
1014
1263
  readonly images: Images$1;
1015
1264
  /** Snapshots. */
1016
1265
  readonly snapshots: Snapshots$1;
1017
- /** Tags. */
1018
- readonly tags: Tags$1;
1266
+ /** Profiles. */
1267
+ readonly profiles: Profiles$1;
1268
+ /** Resource policies. */
1269
+ readonly resourcePolicies: ResourcePolicies$1;
1270
+ /** Security policies. */
1271
+ readonly securityPolicies: SecurityPolicies$1;
1272
+ /** Agent templates. */
1273
+ readonly templates: Templates$1;
1019
1274
  /** Create the handle. */
1020
1275
  constructor(baseUrl?: string | Session, opts?: ClientOpts);
1276
+ /** Mint a Matrix device for this SDK process. */
1277
+ createMatrixSession(opts?: TimeoutOpts): Promise<MatrixSession>;
1278
+ /** Log out one SDK device. */
1279
+ deleteMatrixSession(sessionId: string, opts?: TimeoutOpts): Promise<void>;
1021
1280
  /** Close. */
1022
1281
  close(): void;
1023
1282
  /** Header for the guest URL using this project's access token.
@@ -1029,7 +1288,7 @@ declare class Client$1 {
1029
1288
  /** List Sandboxes. */
1030
1289
  listSandboxes(opts?: {
1031
1290
  labels?: Record<string, string>;
1032
- tags?: string[];
1291
+ profileId?: string;
1033
1292
  statuses?: SandboxStatus$1[];
1034
1293
  pageSize?: number;
1035
1294
  pageToken?: string;
@@ -1040,6 +1299,20 @@ declare class Client$1 {
1040
1299
  listImagesIter(opts?: Omit<NonNullable<Parameters<Images$1["list"]>[0]>, "pageToken">): AsyncGenerator<Image>;
1041
1300
  }
1042
1301
 
1302
+ /** Bounded message history snapshots from Matrix. */
1303
+
1304
+ declare const UNLIMITED$1: number;
1305
+ type HistoryOptions = {
1306
+ /** Maximum eligible text messages. Default 50. */
1307
+ limit?: number;
1308
+ /** Present newest messages first. Default oldest first. */
1309
+ newestFirst?: boolean;
1310
+ /** Overall fetch deadline in seconds. Default 180. */
1311
+ timeout?: number | typeof UNLIMITED$1;
1312
+ /** @internal Resolved by `Agent.history`. */
1313
+ labels?: SenderLabelContext;
1314
+ };
1315
+
1043
1316
  /** Arguments for `Sandbox.create`. Fields say what omit means. */
1044
1317
  type SandboxCreateParams$1 = {
1045
1318
  /** Guest rootfs. Required. Platform aliases such as `numen/base` resolve on the control plane. */
@@ -1056,10 +1329,10 @@ type SandboxCreateParams$1 = {
1056
1329
  workdir?: string;
1057
1330
  /** Lifetime from create, seconds. 0/omit = none. Expiry deletes the box. */
1058
1331
  lifetimeSec?: number;
1059
- /** Seconds of inactivity before park. Omit and the sandbox stays up. */
1332
+ /** Seconds of inactivity before the sandbox sleeps. Omit and the sandbox stays up. */
1060
1333
  idleTimeoutSec?: number;
1061
- /** Project tag names that must already exist. */
1062
- tags?: string[];
1334
+ /** Existing profile id. Empty means no profile. */
1335
+ profileId?: string;
1063
1336
  /** Start from this snapshot. Omit to start from the image. */
1064
1337
  fromSnapshotId?: string;
1065
1338
  /** Named disk to attach. Omit for no volume. */
@@ -1083,9 +1356,9 @@ type SandboxRef = string | {
1083
1356
  /** Sandbox name. */
1084
1357
  name: string;
1085
1358
  };
1086
- /** Disconnect-safe guest process (`StartProcess`). Park / Close / idle-park
1359
+ /** Disconnect-safe guest process (`StartProcess`). Sleep / Close / idle sleep
1087
1360
  * reboot the guest: `poll` / `follow` then `not_found`. Harvested output:
1088
- * `Sandbox.logs()`. Start again after `open()`. */
1361
+ * `Sandbox.logs()`. Start again after `wake()`. */
1089
1362
  declare class ProcessHandle$1 {
1090
1363
  private readonly wire;
1091
1364
  private readonly sandbox;
@@ -1140,27 +1413,27 @@ declare class ProcessHandle$1 {
1140
1413
  type RunSink = {
1141
1414
  write(chunk: string | Uint8Array): void;
1142
1415
  };
1143
- /** One sandbox: run commands, read and write the workdir, park/open, delete.
1416
+ /** One sandbox: run commands, read and write the workdir, sleep/wake, delete.
1144
1417
  *
1145
1418
  * `await using` / `delete()` delete the box. Omit them for a persistent
1146
- * agent and reconnect with `Sandbox.open(client, id)`. */
1419
+ * agent and reconnect with `Sandbox.wake(client, id)`. */
1147
1420
  declare class Sandbox$1 {
1148
1421
  /** Catalog client that shares this box's connection. */
1149
1422
  readonly client: Client$1;
1150
1423
  private readonly wire;
1151
- /** Last record returned by create, get, open, or park. */
1424
+ /** Last record returned by create, get, wake, or sleep. */
1152
1425
  info: SandboxInfo;
1153
1426
  private deleted;
1154
1427
  /** Create the handle. */
1155
1428
  constructor(wire: Session, info: SandboxInfo, catalog?: Client$1);
1156
1429
  /** CreateSandbox. The server mints the id. `name` is an optional lookup. */
1157
1430
  static create(client: Client$1 | Session, params: SandboxCreateParams$1): Promise<Sandbox$1>;
1158
- /** OpenSandbox: wake by id or name. Does not create. */
1159
- static open(client: Client$1 | Session, ref: SandboxRef): Promise<Sandbox$1>;
1431
+ /** WakeSandbox: wake by id or name. Does not create. */
1432
+ static wake(client: Client$1 | Session, ref: SandboxRef): Promise<Sandbox$1>;
1160
1433
  /** GetSandbox by id or name. Does not wake. */
1161
1434
  static get(client: Client$1 | Session, ref: SandboxRef): Promise<Sandbox$1>;
1162
1435
  /** Wake this box if Sleeping. Ready + alive is a no-op. */
1163
- open(opts?: {
1436
+ wake(opts?: {
1164
1437
  signal?: AbortSignal;
1165
1438
  }): Promise<SandboxInfo>;
1166
1439
  /** GetSandbox: live report. Does not wake Sleeping. */
@@ -1183,8 +1456,8 @@ declare class Sandbox$1 {
1183
1456
  get workdir(): string;
1184
1457
  /** Labels. */
1185
1458
  get labels(): Record<string, string>;
1186
- /** Tags. */
1187
- get tags(): string[];
1459
+ /** Profile id. */
1460
+ get profileId(): string;
1188
1461
  /** Net. */
1189
1462
  get net(): string;
1190
1463
  /** Volume Id. */
@@ -1223,7 +1496,7 @@ declare class Sandbox$1 {
1223
1496
  pageToken?: string;
1224
1497
  signal?: AbortSignal;
1225
1498
  }): Promise<LogPage>;
1226
- /** Stdout and stderr the sandbox has already written. The lines remain after park. */
1499
+ /** Stdout and stderr the sandbox has already written. The lines remain after sleep. */
1227
1500
  logs(opts?: {
1228
1501
  processId?: string;
1229
1502
  pageSize?: number;
@@ -1242,8 +1515,14 @@ declare class Sandbox$1 {
1242
1515
  setLabels(labels: Record<string, string> | undefined, opts?: {
1243
1516
  signal?: AbortSignal;
1244
1517
  }): Promise<SandboxInfo>;
1245
- /** Replace sandbox tags. Names must already exist. Part of the Ensure profile. */
1246
- setTags(tags: string[] | undefined, opts?: {
1518
+ /** Set or clear the sandbox profile. */
1519
+ setProfile(profileId: string | null | undefined, opts?: {
1520
+ signal?: AbortSignal;
1521
+ }): Promise<SandboxInfo>;
1522
+ /** Replace labels, profile id, or both. Pass `profileId: null` to clear. */
1523
+ update(opts: {
1524
+ labels?: Record<string, string>;
1525
+ profileId?: string | null;
1247
1526
  signal?: AbortSignal;
1248
1527
  }): Promise<SandboxInfo>;
1249
1528
  /** Run a command. Hang-up kills it. Output is text unless `text` is false. */
@@ -1308,7 +1587,7 @@ declare class Sandbox$1 {
1308
1587
  stat(path: string, opts?: {
1309
1588
  signal?: AbortSignal;
1310
1589
  }): Promise<FileInfo>;
1311
- /** mkdir and rm, plus file bodies as one stream each, in the order given. Never parks. */
1590
+ /** mkdir and rm, plus file bodies as one stream each, in the order given. Never sleeps. */
1312
1591
  write(ops: Array<FileOp$1 | FileSpec | Record<string, unknown>>, opts?: {
1313
1592
  timeout?: number;
1314
1593
  signal?: AbortSignal;
@@ -1376,15 +1655,15 @@ declare class Sandbox$1 {
1376
1655
  deleteHttpGrant(id: string, opts?: {
1377
1656
  signal?: AbortSignal;
1378
1657
  }): Promise<void>;
1379
- /** Admin ParkSandbox: reboot. Commit the writable layer, drop the VM, keep the id.
1658
+ /** SleepSandbox: reboot. Commit the writable layer, drop the VM, keep the id.
1380
1659
  * Overlay upper stays on this worker.
1381
1660
  * An open guest HTTP connection ends with the VMM; dial again after `open()`. */
1382
- park(opts?: {
1661
+ sleep(opts?: {
1383
1662
  signal?: AbortSignal;
1384
1663
  }): Promise<SandboxInfo>;
1385
1664
  /** Set CPU, guest memory, and the writable-state allocation while the sandbox is sleeping.
1386
1665
  *
1387
- * Pass 0 to keep the current value. A Ready sandbox must park first. */
1666
+ * Pass 0 to keep the current value. A Ready sandbox must sleep first. */
1388
1667
  setSize(packing: {
1389
1668
  cpuMillicores?: number;
1390
1669
  memoryBytes?: number;
@@ -1420,7 +1699,7 @@ declare class Sandbox$1 {
1420
1699
  missingOk?: boolean;
1421
1700
  signal?: AbortSignal;
1422
1701
  }): Promise<void>;
1423
- /** Named pin of the writable layer. Parks if Ready/Finished, pins, then opens. */
1702
+ /** Named pin of the writable layer. Sleeps if Ready/Finished, pins, then wakes. */
1424
1703
  snapshot(opts?: {
1425
1704
  name?: string;
1426
1705
  labels?: Record<string, string>;
@@ -1547,59 +1826,132 @@ declare function mkdir(path: string): Mkdir;
1547
1826
  /** Build a `Remove` op for `fs.write`. `recursive` is required for a non-empty directory. */
1548
1827
  declare function remove(path: string, recursive?: boolean): Remove;
1549
1828
  type FileOp = Write | Mkdir | Remove;
1550
- /** One agent. `matrixUserId` is who you invite. One sandbox. Sleep stops the process you started. */
1829
+ /** One agent. One sandbox. Sleep stops the process you started. */
1551
1830
  declare class Agent {
1831
+ #private;
1552
1832
  private readonly client;
1553
1833
  /** Agent id. */
1554
1834
  readonly id: string;
1555
1835
  /** Agent name. */
1556
1836
  name: string;
1557
- /** Matrix user id to invite from your Matrix client. */
1558
- matrixUserId: string;
1559
1837
  /** Env name to secret name. Values are not included. */
1560
1838
  secretEnv: Record<string, string>;
1561
1839
  /** When the agent was created. */
1562
1840
  createdAt: string;
1841
+ /** Sandbox this agent is attached to now. Empty when it has none. */
1842
+ activeSandboxId: string;
1843
+ /** False when this agent has no Matrix identity. */
1844
+ messaging: boolean;
1845
+ /** Template this agent was copied from. */
1846
+ templateId: string;
1847
+ /** Image copied from the template. */
1848
+ image: string;
1849
+ /** Profile copied from the template. */
1850
+ profileId: string;
1563
1851
  constructor(client: Client, info: Agent$1);
1564
1852
  private take;
1565
- /** Bind an env name. The same name replaces the value. A name starting with `MATRIX_` is rejected. Do not set `MATRIX_ACCESS_TOKEN`. */
1566
- addSecret(envName: string, value: string, opts?: {
1853
+ /** Bind an env name to a project secret. */
1854
+ bindSecret(envName: string, secretName: string, opts?: {
1567
1855
  timeout?: Timeout;
1568
1856
  }): Promise<this>;
1569
1857
  /** Remove one binding. Refused while this agent has a live sandbox. */
1570
- removeSecret(envName: string, opts?: {
1858
+ unbindSecret(envName: string, opts?: {
1859
+ timeout?: Timeout;
1860
+ }): Promise<this>;
1861
+ /** Create this agent's sandbox. Omit `image` to use the template's. A second one fails with reason `AGENT_BUSY`. */
1862
+ newSandbox(opts?: Omit<SandboxCreateParams, "agentId" | "image"> & {
1863
+ image?: string;
1864
+ }): Promise<Sandbox>;
1865
+ private requireMessaging;
1866
+ /** Post plain text to this agent's DM. */
1867
+ sendMessage(body: string): Promise<string>;
1868
+ /** Live DM events. Call before `sendMessage` when you need to catch a fast reply. */
1869
+ subscribe(): Promise<MessageSubscription>;
1870
+ /** Bounded snapshot of DM text messages. */
1871
+ history(opts?: HistoryOptions): AsyncGenerator<MessageEvent>;
1872
+ }
1873
+ /** Copied onto an agent at create. Later edits do not change existing agents. */
1874
+ declare class Template {
1875
+ private readonly client;
1876
+ /** Template id. */
1877
+ readonly id: string;
1878
+ /** Template name. */
1879
+ name: string;
1880
+ /** Image copied onto new agents. */
1881
+ image: string;
1882
+ /** Env name to secret name. */
1883
+ secretEnv: Record<string, string>;
1884
+ /** Optional profile copied onto new agents. */
1885
+ profileId: string;
1886
+ /** Agents created from this template. */
1887
+ agentCount: number;
1888
+ /** When the template was created. */
1889
+ createdAt: string;
1890
+ /** When the template was last updated. */
1891
+ updatedAt: string;
1892
+ constructor(client: Client, info: Template$1);
1893
+ private take;
1894
+ /** Change name, image, profile, or secret refs. Pass `profile: null` to clear. */
1895
+ update(opts: {
1896
+ name?: string;
1897
+ image?: string;
1898
+ profile?: string | null;
1899
+ secretEnv?: Record<string, string>;
1571
1900
  timeout?: Timeout;
1572
1901
  }): Promise<this>;
1573
- /** Create this agent's sandbox. A second one fails with reason `AGENT_BUSY`. */
1574
- newSandbox(opts: Omit<SandboxCreateParams, "agentId">): Promise<Sandbox>;
1902
+ /** Delete this template. Blocked while agents still use it. */
1903
+ delete(opts?: {
1904
+ missingOk?: boolean;
1905
+ timeout?: Timeout;
1906
+ }): Promise<void>;
1907
+ }
1908
+ declare class Templates {
1909
+ private readonly client;
1910
+ constructor(client: Client);
1911
+ create(name: string, opts: {
1912
+ image: string;
1913
+ profileId?: string;
1914
+ secretEnv?: Record<string, string>;
1915
+ timeout?: Timeout;
1916
+ }): Promise<Template>;
1917
+ get(id: string, opts?: {
1918
+ timeout?: Timeout;
1919
+ }): Promise<Template>;
1920
+ getByName(name: string, opts?: {
1921
+ timeout?: Timeout;
1922
+ }): Promise<Template>;
1923
+ list(opts?: ListOpts): Promise<Page<Template>>;
1924
+ iter(opts?: Omit<ListOpts, "pageToken"> & {
1925
+ limit?: number;
1926
+ }): AsyncGenerator<Template>;
1927
+ delete(id: string, opts?: {
1928
+ missingOk?: boolean;
1929
+ timeout?: Timeout;
1930
+ }): Promise<void>;
1575
1931
  }
1576
1932
  declare class Agents {
1577
1933
  private readonly client;
1934
+ readonly templates: Templates;
1578
1935
  constructor(client: Client);
1579
- /** Create an agent. Invite `matrixUserId` from your Matrix client. */
1580
1936
  create(name: string, opts?: {
1937
+ template?: string;
1938
+ messaging?: boolean;
1939
+ timeout?: Timeout;
1940
+ }): Promise<Agent>;
1941
+ getByName(name: string, opts?: {
1581
1942
  timeout?: Timeout;
1582
1943
  }): Promise<Agent>;
1583
1944
  get(id: string, opts?: {
1584
1945
  timeout?: Timeout;
1585
1946
  }): Promise<Agent>;
1947
+ iter(opts?: Omit<ListOpts, "pageToken"> & {
1948
+ limit?: number;
1949
+ }): AsyncGenerator<Agent>;
1586
1950
  list(opts?: ListOpts): Promise<Page<Agent>>;
1587
1951
  delete(id: string, opts?: {
1588
1952
  missingOk?: boolean;
1589
1953
  timeout?: Timeout;
1590
1954
  }): Promise<void>;
1591
- /** Return `homeserver`, `userId`, and `accessToken` once. A second call fails with reason `TOKEN_EXISTS`. The stored token still works. */
1592
- createToken(opts?: {
1593
- timeout?: Timeout;
1594
- }): Promise<Token>;
1595
- /** Return `homeserver`, `userId`, and `issued`. The access token is not included. */
1596
- tokenStatus(opts?: {
1597
- timeout?: Timeout;
1598
- }): Promise<TokenStatus>;
1599
- /** Log out the user from `createToken`. The old access token stops working. Succeeds when nothing is issued. Do not call this on startup. */
1600
- revokeToken(opts?: {
1601
- timeout?: Timeout;
1602
- }): Promise<void>;
1603
1955
  }
1604
1956
  /** Where to connect. */
1605
1957
  type ClientOptions = {
@@ -1634,12 +1986,19 @@ declare class Client {
1634
1986
  readonly images: Images;
1635
1987
  /** Filesystem snapshots. */
1636
1988
  readonly snapshots: Snapshots;
1637
- /** Names bound to a policy set. */
1638
- readonly tags: Tags;
1989
+ /** Named compute/security profiles. */
1990
+ readonly profiles: Profiles;
1991
+ /** Resource and security policies. */
1992
+ readonly policies: Policies;
1639
1993
  /** Create, list, and open sandboxes. */
1640
1994
  readonly sandboxes: Sandboxes;
1641
1995
  constructor(opts?: ClientOptions);
1642
- /** Close the connection. */
1996
+ private matrix;
1997
+ /** The Matrix client for send and receive. One device for this process. */
1998
+ room(): Promise<RoomIO>;
1999
+ /** @internal Matrix user id for the live SDK session. */
2000
+ matrixUserId(): Promise<string>;
2001
+ /** Close the connection and log out this process's Matrix device. */
1643
2002
  close(): void;
1644
2003
  /** `using` calls this. */
1645
2004
  [Symbol.dispose](): void;
@@ -1749,34 +2108,188 @@ declare class Snapshots {
1749
2108
  timeout?: Timeout;
1750
2109
  }): Promise<void>;
1751
2110
  }
1752
- /** A project name bound to one policy set. */
1753
- declare class Tags {
2111
+ declare class Policies {
2112
+ readonly resources: ResourcePolicies;
2113
+ readonly security: SecurityPolicies;
2114
+ constructor(client: Client);
2115
+ }
2116
+ declare class ResourcePolicies {
1754
2117
  private readonly client;
1755
2118
  constructor(client: Client);
1756
2119
  create(name: string, opts?: {
1757
- policyId?: string;
2120
+ cpuMillicores?: number;
2121
+ memoryBytes?: number;
2122
+ diskBytes?: number;
1758
2123
  timeout?: Timeout;
1759
- }): Promise<Tag>;
2124
+ }): Promise<ResourcePolicy>;
1760
2125
  get(id: string, opts?: {
1761
2126
  timeout?: Timeout;
1762
- }): Promise<Tag>;
1763
- /** Walks every page of `list`. */
2127
+ }): Promise<ResourcePolicy>;
1764
2128
  getByName(name: string, opts?: {
1765
2129
  timeout?: Timeout;
1766
- }): Promise<Tag>;
1767
- list(opts?: ListOpts): Promise<Page<Tag>>;
2130
+ }): Promise<ResourcePolicy>;
2131
+ list(opts?: ListOpts): Promise<Page<ResourcePolicy>>;
1768
2132
  iter(opts?: Omit<ListOpts, "pageToken"> & {
1769
2133
  limit?: number;
1770
- }): AsyncGenerator<Tag>;
1771
- update(id: string, opts: {
1772
- policyId: string;
2134
+ }): AsyncGenerator<ResourcePolicy>;
2135
+ delete(id: string, opts?: {
2136
+ missingOk?: boolean;
2137
+ timeout?: Timeout;
2138
+ }): Promise<void>;
2139
+ }
2140
+ declare class SecurityPolicies {
2141
+ private readonly client;
2142
+ constructor(client: Client);
2143
+ create(name: string, opts?: {
2144
+ scanning?: ScanPolicy;
2145
+ runtime?: RuntimePolicy;
1773
2146
  timeout?: Timeout;
1774
- }): Promise<Tag>;
2147
+ }): Promise<SecurityPolicy>;
2148
+ get(id: string, opts?: {
2149
+ timeout?: Timeout;
2150
+ }): Promise<SecurityPolicy>;
2151
+ getByName(name: string, opts?: {
2152
+ timeout?: Timeout;
2153
+ }): Promise<SecurityPolicy>;
2154
+ list(opts?: ListOpts): Promise<Page<SecurityPolicy>>;
2155
+ iter(opts?: Omit<ListOpts, "pageToken"> & {
2156
+ limit?: number;
2157
+ }): AsyncGenerator<SecurityPolicy>;
2158
+ delete(id: string, opts?: {
2159
+ missingOk?: boolean;
2160
+ timeout?: Timeout;
2161
+ }): Promise<void>;
2162
+ }
2163
+ declare class Profiles {
2164
+ private readonly client;
2165
+ constructor(client: Client);
2166
+ create(name: string, opts?: {
2167
+ resourcePolicyId?: string;
2168
+ securityPolicyId?: string;
2169
+ timeout?: Timeout;
2170
+ }): Promise<Profile>;
2171
+ get(id: string, opts?: {
2172
+ timeout?: Timeout;
2173
+ }): Promise<Profile>;
2174
+ getByName(name: string, opts?: {
2175
+ timeout?: Timeout;
2176
+ }): Promise<Profile>;
2177
+ list(opts?: ListOpts): Promise<Page<Profile>>;
2178
+ iter(opts?: Omit<ListOpts, "pageToken"> & {
2179
+ limit?: number;
2180
+ }): AsyncGenerator<Profile>;
1775
2181
  delete(id: string, opts?: {
1776
2182
  missingOk?: boolean;
1777
2183
  timeout?: Timeout;
1778
2184
  }): Promise<void>;
1779
2185
  }
2186
+ /** Named CPU, memory, and disk document. */
2187
+ declare class ResourcePolicy {
2188
+ private readonly client;
2189
+ /** Resource policy id. */
2190
+ readonly id: string;
2191
+ /** Resource policy name. */
2192
+ name: string;
2193
+ /** Packing millicores. Null means the platform default. */
2194
+ cpuMillicores: number | null;
2195
+ /** Guest memory in bytes. Null means the platform default. */
2196
+ memoryBytes: number | null;
2197
+ /** Overlay disk in bytes. Null means the platform default. */
2198
+ diskBytes: number | null;
2199
+ /** Profiles that reference this policy. */
2200
+ profileCount: number;
2201
+ /** When the policy was created. */
2202
+ createdAt: string;
2203
+ /** When the policy was last updated. */
2204
+ updatedAt: string;
2205
+ constructor(client: Client, info: ResourcePolicy$1);
2206
+ private take;
2207
+ /** Change name or dimensions. Pass `null` to clear a dimension. */
2208
+ update(opts: {
2209
+ name?: string;
2210
+ cpuMillicores?: number | null;
2211
+ memoryBytes?: number | null;
2212
+ diskBytes?: number | null;
2213
+ timeout?: Timeout;
2214
+ }): Promise<this>;
2215
+ /** Delete this policy. Blocked while a profile still uses it. */
2216
+ delete(opts?: {
2217
+ missingOk?: boolean;
2218
+ timeout?: Timeout;
2219
+ }): Promise<void>;
2220
+ }
2221
+ /** Named scanning and runtime document. */
2222
+ declare class SecurityPolicy {
2223
+ private readonly client;
2224
+ /** Security policy id. */
2225
+ readonly id: string;
2226
+ /** Security policy name. */
2227
+ name: string;
2228
+ /** Scanning facet, if set. */
2229
+ scanning: ScanPolicy | null;
2230
+ /** Runtime facet, if set. */
2231
+ runtime: RuntimePolicy | null;
2232
+ /** Profiles that reference this policy. */
2233
+ profileCount: number;
2234
+ /** When the policy was created. */
2235
+ createdAt: string;
2236
+ /** When the policy was last updated. */
2237
+ updatedAt: string;
2238
+ constructor(client: Client, info: SecurityPolicy$1);
2239
+ private take;
2240
+ /** Change name, scanning, or runtime. Pass `null` to clear a facet. */
2241
+ update(opts: {
2242
+ name?: string;
2243
+ scanning?: ScanPolicy | null;
2244
+ runtime?: RuntimePolicy | null;
2245
+ timeout?: Timeout;
2246
+ }): Promise<this>;
2247
+ /** Delete this policy. Blocked while a profile still uses it. */
2248
+ delete(opts?: {
2249
+ missingOk?: boolean;
2250
+ timeout?: Timeout;
2251
+ }): Promise<void>;
2252
+ }
2253
+ /** Named pair of optional resource and security policies. */
2254
+ declare class Profile {
2255
+ private readonly client;
2256
+ /** Profile id. */
2257
+ readonly id: string;
2258
+ /** Profile name. */
2259
+ name: string;
2260
+ /** Linked resource policy id, or empty. */
2261
+ resourcePolicyId: string;
2262
+ /** Linked security policy id, or empty. */
2263
+ securityPolicyId: string;
2264
+ /** Embedded resource policy, when linked. */
2265
+ resourcePolicy: ResourcePolicy$1 | null;
2266
+ /** Embedded security policy, when linked. */
2267
+ securityPolicy: SecurityPolicy$1 | null;
2268
+ /** Non-terminal sandboxes using this profile. */
2269
+ sandboxCount: number;
2270
+ /** Templates using this profile. */
2271
+ templateCount: number;
2272
+ /** Agents using this profile. */
2273
+ agentCount: number;
2274
+ /** When the profile was created. */
2275
+ createdAt: string;
2276
+ /** When the profile was last updated. */
2277
+ updatedAt: string;
2278
+ constructor(client: Client, info: Profile$1);
2279
+ private take;
2280
+ /** Change name or linked policies. Pass `null` to detach a policy. */
2281
+ update(opts: {
2282
+ name?: string;
2283
+ resourcePolicyId?: string | null;
2284
+ securityPolicyId?: string | null;
2285
+ timeout?: Timeout;
2286
+ }): Promise<this>;
2287
+ /** Delete this profile. Blocked while sandboxes, templates, or agents still use it. */
2288
+ delete(opts?: {
2289
+ missingOk?: boolean;
2290
+ timeout?: Timeout;
2291
+ }): Promise<void>;
2292
+ }
1780
2293
  type ListOpts = {
1781
2294
  pageSize?: number;
1782
2295
  pageToken?: string;
@@ -1806,8 +2319,8 @@ type SandboxCreateParams = {
1806
2319
  volumeId?: string;
1807
2320
  /** Your metadata. Labels do not change how the sandbox runs. */
1808
2321
  labels?: Record<string, string>;
1809
- /** Tag names that must already exist. */
1810
- tags?: string[];
2322
+ /** Existing profile id. Empty means no profile. */
2323
+ profile?: string;
1811
2324
  /** Size. Omit for 1 core, 1 GiB of memory, and 1 GiB of writable disk. */
1812
2325
  resources?: Resources;
1813
2326
  /** `await using` deletes the sandbox when this is true, the default. */
@@ -1822,15 +2335,15 @@ declare class Sandboxes {
1822
2335
  create(opts: SandboxCreateParams): Promise<Sandbox>;
1823
2336
  get(id: string): Promise<Sandbox>;
1824
2337
  getByName(name: string): Promise<Sandbox>;
1825
- resume(id: string): Promise<Sandbox>;
2338
+ wake(id: string): Promise<Sandbox>;
1826
2339
  list(opts?: ListOpts & {
1827
2340
  labels?: Record<string, string>;
1828
- tags?: string[];
2341
+ profileId?: string;
1829
2342
  status?: SandboxStatus | readonly SandboxStatus[];
1830
2343
  }): Promise<Page<SandboxRow>>;
1831
2344
  iter(opts?: Omit<ListOpts, "pageToken"> & {
1832
2345
  labels?: Record<string, string>;
1833
- tags?: string[];
2346
+ profileId?: string;
1834
2347
  status?: SandboxStatus | readonly SandboxStatus[];
1835
2348
  limit?: number;
1836
2349
  }): AsyncGenerator<SandboxRow>;
@@ -1891,10 +2404,10 @@ declare class Sandbox {
1891
2404
  memory?: number | string;
1892
2405
  disk?: number | string;
1893
2406
  }): Promise<SandboxInfo>;
1894
- /** Replace labels, tags, or both. */
2407
+ /** Replace labels, profile, or both. Pass `profile: null` to clear. */
1895
2408
  update(opts: {
1896
2409
  labels?: Record<string, string>;
1897
- tags?: string[];
2410
+ profile?: string | null;
1898
2411
  }): Promise<SandboxInfo>;
1899
2412
  /** Run a command and wait for it. Omit `timeout` for no RPC deadline. */
1900
2413
  run(argv: string[], opts?: {
@@ -2097,6 +2610,6 @@ type GuestHttp = GuestHttp$1;
2097
2610
  /** Body returned by `GuestHttp.get` and `GuestHttp.post`. */
2098
2611
  type GuestResponse = GuestResponse$1;
2099
2612
 
2100
- declare const publicExports: readonly ["Agent", "AuthenticationError", "CapacityError", "Client", "CommandFailedError", "CommandTimeoutError", "CommandTooLargeError", "ConflictError", "DirectoryNotEmptyError", "ExecutableNotFoundError", "FileExistsError", "FileTooLargeError", "GuestRuntimeDeadError", "ImageTimeoutError", "InvalidArgumentError", "InvalidPathError", "Mkdir", "UNLIMITED", "NameTakenError", "NotFoundError", "Page", "PathNotFoundError", "PageExhaustedError", "PermissionDeniedError", "PortNotOpenError", "ProcessHandle", "ProcessNotFoundError", "ProcessWaitTimeoutError", "Remove", "Sandbox", "SandboxConflictError", "SandboxError", "SandboxNotFoundError", "SandboxNotReadyError", "SandboxSleepingError", "SandboxStateError", "LogStream", "SandboxStatus", "SandboxWaitTimeoutError", "SandboxTimeoutError", "TimeoutError", "UnavailableError", "Write", "mkdir", "publicExports", "remove", "write"];
2613
+ declare const publicExports: readonly ["Agent", "Template", "MessageSubscription", "AuthenticationError", "CapacityError", "Client", "CommandFailedError", "CommandTimeoutError", "CommandTooLargeError", "ConflictError", "DirectoryNotEmptyError", "ExecutableNotFoundError", "FileExistsError", "FileTooLargeError", "GuestRuntimeDeadError", "ImageTimeoutError", "InvalidArgumentError", "InvalidPathError", "Mkdir", "UNLIMITED", "NameTakenError", "NotFoundError", "Page", "PathNotFoundError", "PageExhaustedError", "PermissionDeniedError", "PortNotOpenError", "ProcessHandle", "Profile", "ResourceInUseError", "ResourcePolicy", "SecurityPolicy", "ProcessNotFoundError", "ProcessWaitTimeoutError", "Remove", "Sandbox", "SandboxConflictError", "SandboxError", "SandboxNotFoundError", "SandboxNotReadyError", "SandboxSleepingError", "SandboxStateError", "LogStream", "SandboxStatus", "SandboxWaitTimeoutError", "SandboxTimeoutError", "TimeoutError", "UnavailableError", "Write", "mkdir", "publicExports", "remove", "write"];
2101
2614
 
2102
- export { Agent, AuthenticationError, CapacityError, Client, type ClientOptions, CommandFailedError, CommandTimeoutError, CommandTooLargeError, ConflictError, DirectoryNotEmptyError, type ExecBytesResult, type ExecResult, ExecutableNotFoundError, FileExistsError, type FileInfo, type FileList, FileTooLargeError, type GuestHttp, type GuestResponse, GuestRuntimeDeadError, type HTTPGrant, type Image, type ImageKind, ImageTimeoutError, InvalidArgumentError, InvalidPathError, type LogEntry, LogStream, Mkdir, NameTakenError, NotFoundError, Page, PageExhaustedError, PathNotFoundError, PermissionDeniedError, PortNotOpenError, type Process, ProcessHandle, ProcessNotFoundError, ProcessWaitTimeoutError, Remove, type Resources, Sandbox, SandboxConflictError, type SandboxCreateParams, SandboxError, type SandboxInfo, SandboxNotFoundError, SandboxNotReadyError, type SandboxRow, SandboxSleepingError, SandboxStateError, SandboxStatus, SandboxTimeoutError, SandboxWaitTimeoutError, type Secret, type Snapshot, type StreamChunk, type Tag, TimeoutError, type Token, type TokenStatus, UNLIMITED, UnavailableError, type Volume, Write, mkdir, publicExports, remove, write };
2615
+ export { Agent, AuthenticationError, CapacityError, Client, type ClientOptions, CommandFailedError, CommandTimeoutError, CommandTooLargeError, ConflictError, DirectoryNotEmptyError, type ExecBytesResult, type ExecResult, ExecutableNotFoundError, FileExistsError, type FileInfo, type FileList, FileTooLargeError, type GuestHttp, type GuestResponse, GuestRuntimeDeadError, type HTTPGrant, type Image, type ImageKind, ImageTimeoutError, InvalidArgumentError, InvalidPathError, type LogEntry, LogStream, type MessageEvent, MessageSubscription, Mkdir, NameTakenError, NotFoundError, Page, PageExhaustedError, PathNotFoundError, PermissionDeniedError, PortNotOpenError, type Process, ProcessHandle, ProcessNotFoundError, ProcessWaitTimeoutError, Profile, Remove, ResourceInUseError, ResourcePolicy, type Resources, Sandbox, SandboxConflictError, type SandboxCreateParams, SandboxError, type SandboxInfo, SandboxNotFoundError, SandboxNotReadyError, type SandboxRow, SandboxSleepingError, SandboxStateError, SandboxStatus, SandboxTimeoutError, SandboxWaitTimeoutError, type Secret, SecurityPolicy, type Snapshot, type StreamChunk, Template, TimeoutError, UNLIMITED, UnavailableError, type Volume, Write, mkdir, publicExports, remove, write };