angela-sdk 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -15,6 +15,10 @@ Angela games run as deterministic WebAssembly cartridges in Discord servers. The
15
15
  3. [Architecture & How It Works](#architecture--how-it-works)
16
16
  4. [Application Lifecycle & Event Routing](#application-lifecycle--event-routing)
17
17
  5. [The Game Context (`ctx`)](#the-game-context-ctx)
18
+ - [Temporary Channels (`ctx.channel`)](#temporary-channels-ctxchannel)
19
+ - [Permission Overwrites (`ctx.perms`)](#channel-permissions-ctxperms)
20
+ - [Timers & Hibernation (`ctx.timer`)](#timers--hibernation-ctxtimer)
21
+ - [Persistent Player Storage & Stats (`ctx.storage`)](#persistent-player-storage--stats-ctxstorage)
18
22
  6. [Economy & Multi-Currency System](#economy--multi-currency-system)
19
23
  7. [Inventory & Items](#inventory--items)
20
24
  8. [UI Engine](#ui-engine)
@@ -27,8 +31,14 @@ Angela games run as deterministic WebAssembly cartridges in Discord servers. The
27
31
  - [Complete Drawing API Reference](#complete-drawing-api-reference)
28
32
  10. [Multiplayer & Lobbies](#multiplayer--lobbies)
29
33
  11. [AI & Media Gateways](#ai--media-gateways)
30
- 12. [HTTP & Discord Utilities](#http--discord-utilities)
31
- 13. [Cartridge Project Layout & CLI](#cartridge-project-layout--cli)
34
+ 12. [Discord Utilities & Low-Level Primitives](#discord-utilities--low-level-primitives)
35
+ - [Channel Creation & Deletion (`ctx.channel`)](#channel-creation--deletion-ctxchannel)
36
+ - [Permission Overwrites (`ctx.perms`)](#permission-overwrites-ctxperms)
37
+ - [Timer Hibernation & Early Cancellation (`ctx.timer`)](#timer-hibernation--early-cancellation-ctxtimer)
38
+ - [Zero-DM Secret Actions & Ephemerals](#zero-dm-secret-actions--ephemerals)
39
+ 13. [Compute Tiers & Flux Metering](#compute-tiers--flux-metering)
40
+ 14. [HTTP & Safe Network Access](#http--safe-network-access)
41
+ 15. [Cartridge Project Layout & CLI](#cartridge-project-layout--cli)
32
42
 
33
43
  ---
34
44
 
@@ -264,7 +274,50 @@ const maxTries = Number(ctx.config.max_tries || 3);
264
274
 
265
275
  Read-only object containing private slot credentials (such as API keys). Secrets are kept private to the host and never written to game state.
266
276
 
267
- ### Persistent Player Storage (`ctx.storage`)
277
+ ### Temporary Channels (`ctx.channel`)
278
+
279
+ Control isolated game channels and private discussion threads:
280
+
281
+ ```typescript
282
+ // Create private game thread or temporary channel
283
+ ctx.channel.create("secret-room", {
284
+ type: "private_thread",
285
+ autoDeleteAfter: 300,
286
+ topic: "Secret Strategy Room"
287
+ });
288
+
289
+ // Delete temporary channel when match ends
290
+ ctx.channel.delete(123456789);
291
+ ```
292
+
293
+ ### Channel Permissions (`ctx.perms`)
294
+
295
+ Apply low-level permission overwrites dynamically:
296
+
297
+ ```typescript
298
+ // Set channel overwrites for a player
299
+ ctx.perms.set(ctx.user.id, {
300
+ allow: ["view_channel", "send_messages"],
301
+ deny: ["add_reactions"]
302
+ });
303
+
304
+ // Freeze chat during critical turn phases
305
+ ctx.perms.lockChannel(30);
306
+ ```
307
+
308
+ ### Timers & Hibernation (`ctx.timer`)
309
+
310
+ Schedule asynchronous hibernation wakeups and early cancellations:
311
+
312
+ ```typescript
313
+ // Schedule hibernation wake (0 MB RAM & 0 Flux while sleeping)
314
+ ctx.timer.schedule(30, "on_turn_timeout", { round: 1 });
315
+
316
+ // Cancel active session wake early if all participants act
317
+ ctx.timer.cancel();
318
+ ```
319
+
320
+ ### Persistent Player Storage & Stats (`ctx.storage`)
268
321
 
269
322
  Store game-scoped persistent player progress and manage cooldowns:
270
323
 
@@ -275,6 +328,10 @@ ctx.storage.set("best_score", Math.max(bestScore, currentScore));
275
328
 
276
329
  // Enforce a 60-second cooldown on the player
277
330
  ctx.storage.setCooldown(ctx.user.id, 60);
331
+
332
+ // Record persistent player gameplay statistics (safeguarded at max 50 keys, 48 chars)
333
+ ctx.storage.recordStat(ctx.user.id, "games_won", 1, "inc");
334
+ ctx.storage.recordStat(ctx.user.id, "top_score", 9990, "set");
278
335
  ```
279
336
 
280
337
  ---
@@ -701,14 +758,84 @@ To guarantee zero latency spikes, airtight security, and deterministic runs acro
701
758
 
702
759
  ---
703
760
 
704
- ## Discord Utilities
761
+ ## Discord Utilities & Low-Level Primitives
762
+
763
+ ### Channel Creation & Deletion (`ctx.channel`)
764
+
765
+ For games requiring private rooms, team discussion threads, or staged arenas:
766
+
767
+ ```typescript
768
+ // Create a private discussion thread or temporary channel
769
+ ctx.channel.create("secret-room", {
770
+ type: "private_thread", // or "text" for temporary guild channel
771
+ autoDeleteAfter: 600, // Auto-cleaned after 10 minutes
772
+ topic: "Secret Game Room"
773
+ });
774
+
775
+ // Tear down when the round or match concludes
776
+ ctx.channel.delete(123456789);
777
+ ```
778
+
779
+ > [!NOTE]
780
+ > To prevent channel clutter, servers enforce a hard quota of max 2 concurrent temporary channels per game cartridge.
781
+
782
+ ### Permission Overwrites (`ctx.perms`)
705
783
 
706
- ### Channel Management & Chat Listening
784
+ Modify player or role channel visibility and permissions dynamically:
707
785
 
708
786
  ```typescript
709
- // Lock channel during critical minigame phase
710
- ctx.discord.lockChannel(30);
787
+ // Grant a player access to view and chat in the private room
788
+ ctx.perms.set(ctx.user.id, {
789
+ allow: ["view_channel", "send_messages", "read_message_history"],
790
+ deny: ["add_reactions"]
791
+ });
792
+
793
+ // Freeze channel chat during voting or turn calculations
794
+ ctx.perms.lockChannel(30);
795
+ ```
796
+
797
+ **Allowed Overwrite Permissions**: `send_messages`, `view_channel`, `read_message_history`, `add_reactions`, `attach_files`.
798
+
799
+ ### Timer Hibernation & Early Cancellation (`ctx.timer`)
800
+
801
+ For turn timeouts, phase countdowns, or scheduled events:
802
+
803
+ ```typescript
804
+ // Hibernate cartridge for 45 seconds (0 MB RAM & 0 Flux during sleep)
805
+ ctx.timer.schedule(45, "on_night_timeout", {
806
+ phase: "night",
807
+ round: 2
808
+ });
809
+
810
+ // If all players submit actions before the timer expires, cancel it early:
811
+ if (Object.keys(ctx.state.votes || {}).length === ctx.session.participants.length) {
812
+ ctx.timer.cancel();
813
+ // Resume immediately!
814
+ }
815
+ ```
816
+
817
+ ### Zero-DM Secret Actions & Ephemerals
818
+
819
+ Angela enforces a strict **Zero-DM policy** to protect against Discord anti-spam flags, rate limits (HTTP 429), and user privacy blocks (`Cannot send messages to this user (50007)`).
820
+
821
+ Instead of bot DMs, handle secret gameplay through:
822
+ 1. **In-Channel Ephemeral UI**:
823
+ ```typescript
824
+ // Only visible to the clicking user inside the channel
825
+ ctx.ui.replyEphemeral({
826
+ text: `🤫 Your secret role is **${myRole}**!`,
827
+ buttons: [
828
+ new Button({ customId: "secret_action_1", label: "Secret Choice A", style: "danger" }),
829
+ new Button({ customId: "secret_action_2", label: "Secret Choice B", style: "secondary" }),
830
+ ]
831
+ });
832
+ ```
833
+ 2. **Private Threads**:
834
+ Use `ctx.channel.create("game-room", { type: "private_thread" })` and invite only specific players with `ctx.perms.set()`.
711
835
 
836
+ ### Channel Management & Chat Listening (`ctx.discord`)
837
+
838
+ ```typescript
712
839
  // Listen for chat message answers
713
840
  ctx.discord.listenMessages({
714
841
  exactMatch: "42",
@@ -719,6 +846,31 @@ ctx.discord.listenMessages({
719
846
 
720
847
  ---
721
848
 
849
+ ## Compute Tiers & Flux Metering
850
+
851
+ Complex games requiring pathfinding, heavy simulations, or large board states can select appropriate compute tiers in `manifest.json`:
852
+
853
+ | Compute Tier | Wasm Instruction Ceiling (Fuel) | Wall-Clock Timeout | Base Flux Cost |
854
+ |---|---|---|---|
855
+ | `"standard"` (default) | 50,000,000 | 5.0 seconds | 1⚡ |
856
+ | `"high"` | 150,000,000 | 12.0 seconds | 3⚡ |
857
+ | `"ultra"` | 350,000,000 | 25.0 seconds | 6⚡ |
858
+
859
+ Configure your cartridge's tier in `manifest.json`:
860
+
861
+ ```json
862
+ {
863
+ "package_id": "grand-strategy",
864
+ "compute_tier": "high",
865
+ "max_flux_per_tick": 5
866
+ }
867
+ ```
868
+
869
+ * **Deterministic Fuel Metering**: Billing is calculated based on exact Wasm instructions executed (fuel), ensuring fair costs regardless of server load. Wall-clock timeouts act solely as safety circuit breakers.
870
+ * **Sleeping Sessions Cost Zero**: When a game calls `ctx.timer.schedule()` or `ctx.sleep()`, RAM is released and zero fuel/Flux is charged during hibernation.
871
+
872
+ ---
873
+
722
874
  ## Cartridge Project Layout & CLI
723
875
 
724
876
  Use `angela-cli` to scaffold, test, and publish your cartridge.
@@ -753,6 +905,7 @@ Angela cartridges require a valid `manifest.json` at project root matching the C
753
905
  "target_slot_id": 1,
754
906
  "default_command": "dice-master-ts",
755
907
  "default_ui_theme": "AUTO",
908
+ "compute_tier": "standard",
756
909
  "max_flux_per_tick": 5,
757
910
  "config_schema": {
758
911
  "currency_name": "Coins",
@@ -777,6 +930,7 @@ Angela cartridges require a valid `manifest.json` at project root matching the C
777
930
  | `target_slot_id` | `integer` | **Yes** | Target slot ID number on the server (e.g. `1`, `2`). |
778
931
  | `default_command` | `string` | No | Slash command trigger for this game (defaults to `package_id`). |
779
932
  | `default_ui_theme` | `string` | No | Default rendering mode: `"AUTO"`, `"CV2"`, or `"CLASSIC_EMBED"`. |
933
+ | `compute_tier` | `string` | No | Compute capability tier: `"standard"` (50M fuel / 5s), `"high"` (150M fuel / 12s), or `"ultra"` (350M fuel / 25s). |
780
934
  | `max_flux_per_tick` | `integer` | No | Compute Flux ceiling per interaction tick (1 to 100, defaults to 5). |
781
935
  | `config_schema` | `object` | No | Default server configuration options merged into `ctx.config`. |
782
936
 
package/dist/cjs/index.js CHANGED
@@ -27,6 +27,7 @@ __export(index_exports, {
27
27
  CanvasContext: () => CanvasContext,
28
28
  CanvasLayer: () => CanvasLayer,
29
29
  CanvasScene: () => CanvasScene,
30
+ ChannelContext: () => ChannelContext,
30
31
  Container: () => Container,
31
32
  Context: () => Context,
32
33
  DiscordContext: () => DiscordContext,
@@ -39,6 +40,7 @@ __export(index_exports, {
39
40
  LobbyContext: () => LobbyContext,
40
41
  MediaContext: () => MediaContext,
41
42
  MediaGallery: () => MediaGallery,
43
+ PermissionsContext: () => PermissionsContext,
42
44
  Section: () => Section,
43
45
  Select: () => Select,
44
46
  SelectOption: () => SelectOption,
@@ -48,6 +50,7 @@ __export(index_exports, {
48
50
  TextDisplay: () => TextDisplay,
49
51
  TextInput: () => TextInput,
50
52
  Thumbnail: () => Thumbnail,
53
+ TimerContext: () => TimerContext,
51
54
  UIContext: () => UIContext,
52
55
  User: () => User,
53
56
  VERSION: () => VERSION,
@@ -327,6 +330,35 @@ var CanvasContext = class {
327
330
  }
328
331
  };
329
332
 
333
+ // src/channel.ts
334
+ var ChannelContext = class {
335
+ constructor(ctx) {
336
+ this.ctx = ctx;
337
+ }
338
+ ctx;
339
+ create(options) {
340
+ const intent = {
341
+ op: "CHANNEL_OP",
342
+ action: "CREATE",
343
+ name: String(options.name).slice(0, 32),
344
+ category_id: options.categoryId ? Number(options.categoryId) : void 0,
345
+ max_ttl_minutes: options.ttlMinutes ?? 60,
346
+ callback_event_id: options.callback
347
+ };
348
+ this.ctx.addIntent(intent);
349
+ return intent;
350
+ }
351
+ delete(channelId) {
352
+ const intent = {
353
+ op: "CHANNEL_OP",
354
+ action: "DELETE",
355
+ channel_id: channelId ? Number(channelId) : this.ctx.channelId
356
+ };
357
+ this.ctx.addIntent(intent);
358
+ return intent;
359
+ }
360
+ };
361
+
330
362
  // src/http.ts
331
363
  var HTTPContext = class {
332
364
  constructor(ctx) {
@@ -399,7 +431,19 @@ var StorageContext = class {
399
431
  this.ctx.addIntent(intent);
400
432
  return intent;
401
433
  }
434
+ recordStat(userId, key, delta = 1) {
435
+ const intent = {
436
+ op: "STORAGE_MUTATE",
437
+ action: "RECORD_STAT",
438
+ user_id: Number(userId),
439
+ key: String(key).slice(0, 48),
440
+ delta: Math.floor(delta)
441
+ };
442
+ this.ctx.addIntent(intent);
443
+ return intent;
444
+ }
402
445
  set_cooldown = this.setCooldown.bind(this);
446
+ record_stat = this.recordStat.bind(this);
403
447
  };
404
448
 
405
449
  // src/economy.ts
@@ -695,6 +739,66 @@ var Session = class {
695
739
  }
696
740
  };
697
741
 
742
+ // src/permissions.ts
743
+ var PermissionsContext = class {
744
+ constructor(ctx) {
745
+ this.ctx = ctx;
746
+ }
747
+ ctx;
748
+ set(options) {
749
+ const targetStr = String(options.target).trim();
750
+ const isEveryone = targetStr === "@everyone" || targetStr === "0" || targetStr.toLowerCase() === "everyone";
751
+ const targetType = isEveryone || !/^\d+$/.test(targetStr) ? "ROLE" : "USER";
752
+ const targetId = isEveryone ? 0 : Number(options.target);
753
+ const intent = {
754
+ op: "PERMISSION_OVERWRITE",
755
+ channel_id: options.channelId ? Number(options.channelId) : this.ctx.channelId,
756
+ target_type: targetType,
757
+ target_id: targetId,
758
+ allow: options.allow ?? [],
759
+ deny: options.deny ?? [],
760
+ duration_seconds: options.durationSeconds,
761
+ reason: options.reason ?? "Game Permission Overwrite"
762
+ };
763
+ this.ctx.addIntent(intent);
764
+ return intent;
765
+ }
766
+ lockChannel(durationSeconds = 20, channelId) {
767
+ return this.set({
768
+ target: 0,
769
+ deny: ["SEND_MESSAGES"],
770
+ channelId,
771
+ durationSeconds,
772
+ reason: "Channel Lock"
773
+ });
774
+ }
775
+ lock_channel = this.lockChannel.bind(this);
776
+ };
777
+
778
+ // src/timer.ts
779
+ var TimerContext = class {
780
+ constructor(ctx) {
781
+ this.ctx = ctx;
782
+ }
783
+ ctx;
784
+ schedule(delaySeconds, callback = "on_wake") {
785
+ const intent = {
786
+ op: "SCHEDULE_WAKE",
787
+ delay_seconds: Number(delaySeconds),
788
+ callback_event_id: String(callback)
789
+ };
790
+ this.ctx.addIntent(intent);
791
+ return intent;
792
+ }
793
+ cancel() {
794
+ const intent = {
795
+ op: "TIMER_CANCEL"
796
+ };
797
+ this.ctx.addIntent(intent);
798
+ return intent;
799
+ }
800
+ };
801
+
698
802
  // src/ui.ts
699
803
  var Button = class {
700
804
  customId;
@@ -1127,6 +1231,9 @@ var Context = class {
1127
1231
  http;
1128
1232
  discord;
1129
1233
  storage;
1234
+ channel;
1235
+ perms;
1236
+ timer;
1130
1237
  constructor(rawEvent = {}) {
1131
1238
  this.rawEvent = rawEvent;
1132
1239
  this.eventType = String(rawEvent.event_type ?? "COMMAND");
@@ -1151,6 +1258,9 @@ var Context = class {
1151
1258
  this.http = new HTTPContext(this);
1152
1259
  this.discord = new DiscordContext(this);
1153
1260
  this.storage = new StorageContext(this);
1261
+ this.channel = new ChannelContext(this);
1262
+ this.perms = new PermissionsContext(this);
1263
+ this.timer = new TimerContext(this);
1154
1264
  }
1155
1265
  get hostId() {
1156
1266
  if (this.session.participants.length > 0) {
@@ -1362,7 +1472,7 @@ function dispatch(handler, event) {
1362
1472
  }
1363
1473
 
1364
1474
  // src/index.ts
1365
- var VERSION = "0.2.0";
1475
+ var VERSION = "0.3.1";
1366
1476
  // Annotate the CommonJS export names for ESM import in node:
1367
1477
  0 && (module.exports = {
1368
1478
  AIContext,
@@ -1372,6 +1482,7 @@ var VERSION = "0.2.0";
1372
1482
  CanvasContext,
1373
1483
  CanvasLayer,
1374
1484
  CanvasScene,
1485
+ ChannelContext,
1375
1486
  Container,
1376
1487
  Context,
1377
1488
  DiscordContext,
@@ -1384,6 +1495,7 @@ var VERSION = "0.2.0";
1384
1495
  LobbyContext,
1385
1496
  MediaContext,
1386
1497
  MediaGallery,
1498
+ PermissionsContext,
1387
1499
  Section,
1388
1500
  Select,
1389
1501
  SelectOption,
@@ -1393,6 +1505,7 @@ var VERSION = "0.2.0";
1393
1505
  TextDisplay,
1394
1506
  TextInput,
1395
1507
  Thumbnail,
1508
+ TimerContext,
1396
1509
  UIContext,
1397
1510
  User,
1398
1511
  VERSION,
package/dist/esm/index.js CHANGED
@@ -270,6 +270,35 @@ var CanvasContext = class {
270
270
  }
271
271
  };
272
272
 
273
+ // src/channel.ts
274
+ var ChannelContext = class {
275
+ constructor(ctx) {
276
+ this.ctx = ctx;
277
+ }
278
+ ctx;
279
+ create(options) {
280
+ const intent = {
281
+ op: "CHANNEL_OP",
282
+ action: "CREATE",
283
+ name: String(options.name).slice(0, 32),
284
+ category_id: options.categoryId ? Number(options.categoryId) : void 0,
285
+ max_ttl_minutes: options.ttlMinutes ?? 60,
286
+ callback_event_id: options.callback
287
+ };
288
+ this.ctx.addIntent(intent);
289
+ return intent;
290
+ }
291
+ delete(channelId) {
292
+ const intent = {
293
+ op: "CHANNEL_OP",
294
+ action: "DELETE",
295
+ channel_id: channelId ? Number(channelId) : this.ctx.channelId
296
+ };
297
+ this.ctx.addIntent(intent);
298
+ return intent;
299
+ }
300
+ };
301
+
273
302
  // src/http.ts
274
303
  var HTTPContext = class {
275
304
  constructor(ctx) {
@@ -342,7 +371,19 @@ var StorageContext = class {
342
371
  this.ctx.addIntent(intent);
343
372
  return intent;
344
373
  }
374
+ recordStat(userId, key, delta = 1) {
375
+ const intent = {
376
+ op: "STORAGE_MUTATE",
377
+ action: "RECORD_STAT",
378
+ user_id: Number(userId),
379
+ key: String(key).slice(0, 48),
380
+ delta: Math.floor(delta)
381
+ };
382
+ this.ctx.addIntent(intent);
383
+ return intent;
384
+ }
345
385
  set_cooldown = this.setCooldown.bind(this);
386
+ record_stat = this.recordStat.bind(this);
346
387
  };
347
388
 
348
389
  // src/economy.ts
@@ -638,6 +679,66 @@ var Session = class {
638
679
  }
639
680
  };
640
681
 
682
+ // src/permissions.ts
683
+ var PermissionsContext = class {
684
+ constructor(ctx) {
685
+ this.ctx = ctx;
686
+ }
687
+ ctx;
688
+ set(options) {
689
+ const targetStr = String(options.target).trim();
690
+ const isEveryone = targetStr === "@everyone" || targetStr === "0" || targetStr.toLowerCase() === "everyone";
691
+ const targetType = isEveryone || !/^\d+$/.test(targetStr) ? "ROLE" : "USER";
692
+ const targetId = isEveryone ? 0 : Number(options.target);
693
+ const intent = {
694
+ op: "PERMISSION_OVERWRITE",
695
+ channel_id: options.channelId ? Number(options.channelId) : this.ctx.channelId,
696
+ target_type: targetType,
697
+ target_id: targetId,
698
+ allow: options.allow ?? [],
699
+ deny: options.deny ?? [],
700
+ duration_seconds: options.durationSeconds,
701
+ reason: options.reason ?? "Game Permission Overwrite"
702
+ };
703
+ this.ctx.addIntent(intent);
704
+ return intent;
705
+ }
706
+ lockChannel(durationSeconds = 20, channelId) {
707
+ return this.set({
708
+ target: 0,
709
+ deny: ["SEND_MESSAGES"],
710
+ channelId,
711
+ durationSeconds,
712
+ reason: "Channel Lock"
713
+ });
714
+ }
715
+ lock_channel = this.lockChannel.bind(this);
716
+ };
717
+
718
+ // src/timer.ts
719
+ var TimerContext = class {
720
+ constructor(ctx) {
721
+ this.ctx = ctx;
722
+ }
723
+ ctx;
724
+ schedule(delaySeconds, callback = "on_wake") {
725
+ const intent = {
726
+ op: "SCHEDULE_WAKE",
727
+ delay_seconds: Number(delaySeconds),
728
+ callback_event_id: String(callback)
729
+ };
730
+ this.ctx.addIntent(intent);
731
+ return intent;
732
+ }
733
+ cancel() {
734
+ const intent = {
735
+ op: "TIMER_CANCEL"
736
+ };
737
+ this.ctx.addIntent(intent);
738
+ return intent;
739
+ }
740
+ };
741
+
641
742
  // src/ui.ts
642
743
  var Button = class {
643
744
  customId;
@@ -1070,6 +1171,9 @@ var Context = class {
1070
1171
  http;
1071
1172
  discord;
1072
1173
  storage;
1174
+ channel;
1175
+ perms;
1176
+ timer;
1073
1177
  constructor(rawEvent = {}) {
1074
1178
  this.rawEvent = rawEvent;
1075
1179
  this.eventType = String(rawEvent.event_type ?? "COMMAND");
@@ -1094,6 +1198,9 @@ var Context = class {
1094
1198
  this.http = new HTTPContext(this);
1095
1199
  this.discord = new DiscordContext(this);
1096
1200
  this.storage = new StorageContext(this);
1201
+ this.channel = new ChannelContext(this);
1202
+ this.perms = new PermissionsContext(this);
1203
+ this.timer = new TimerContext(this);
1097
1204
  }
1098
1205
  get hostId() {
1099
1206
  if (this.session.participants.length > 0) {
@@ -1305,7 +1412,7 @@ function dispatch(handler, event) {
1305
1412
  }
1306
1413
 
1307
1414
  // src/index.ts
1308
- var VERSION = "0.2.0";
1415
+ var VERSION = "0.3.1";
1309
1416
  export {
1310
1417
  AIContext,
1311
1418
  ActionRow,
@@ -1314,6 +1421,7 @@ export {
1314
1421
  CanvasContext,
1315
1422
  CanvasLayer,
1316
1423
  CanvasScene,
1424
+ ChannelContext,
1317
1425
  Container,
1318
1426
  Context,
1319
1427
  DiscordContext,
@@ -1326,6 +1434,7 @@ export {
1326
1434
  LobbyContext,
1327
1435
  MediaContext,
1328
1436
  MediaGallery,
1437
+ PermissionsContext,
1329
1438
  Section,
1330
1439
  Select,
1331
1440
  SelectOption,
@@ -1335,6 +1444,7 @@ export {
1335
1444
  TextDisplay,
1336
1445
  TextInput,
1337
1446
  Thumbnail,
1447
+ TimerContext,
1338
1448
  UIContext,
1339
1449
  User,
1340
1450
  VERSION,
@@ -0,0 +1,13 @@
1
+ import type { Context } from "./context.js";
2
+ import type { Intent } from "./models.js";
3
+ export declare class ChannelContext {
4
+ private ctx;
5
+ constructor(ctx: Context);
6
+ create(options: {
7
+ name: string;
8
+ categoryId?: number | string | null;
9
+ ttlMinutes?: number;
10
+ callback?: string;
11
+ }): Intent;
12
+ delete(channelId?: number | string): Intent;
13
+ }
@@ -1,10 +1,13 @@
1
1
  import { AIContext, MediaContext } from "./ai.js";
2
2
  import { CanvasContext } from "./canvas.js";
3
+ import { ChannelContext } from "./channel.js";
3
4
  import { DiscordContext, HTTPContext, StorageContext } from "./http.js";
4
5
  import { EconomyContext } from "./economy.js";
5
6
  import { InventoryContext } from "./inventory.js";
6
7
  import { LobbyContext } from "./lobby.js";
7
8
  import { Args, type ArgsData, type Intent, Session, type SessionData, User, type UserData } from "./models.js";
9
+ import { PermissionsContext } from "./permissions.js";
10
+ import { TimerContext } from "./timer.js";
8
11
  import { UIContext } from "./ui.js";
9
12
  export interface EventPayload {
10
13
  event_type?: string;
@@ -42,6 +45,9 @@ export declare class Context {
42
45
  http: HTTPContext;
43
46
  discord: DiscordContext;
44
47
  storage: StorageContext;
48
+ channel: ChannelContext;
49
+ perms: PermissionsContext;
50
+ timer: TimerContext;
45
51
  constructor(rawEvent?: EventPayload);
46
52
  get hostId(): number;
47
53
  get event_type(): string;
@@ -37,5 +37,7 @@ export declare class StorageContext {
37
37
  get<T = unknown>(key: string, defaultValue?: T): T | undefined;
38
38
  set(key: string, value: unknown): void;
39
39
  setCooldown(userId: number | string, seconds: number): Intent;
40
+ recordStat(userId: number | string, key: string, delta?: number): Intent;
40
41
  set_cooldown: (userId: number | string, seconds: number) => Intent;
42
+ record_stat: (userId: number | string, key: string, delta?: number) => Intent;
41
43
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export * from "./ai.js";
6
6
  export * from "./canvas.js";
7
+ export * from "./channel.js";
7
8
  export * from "./context.js";
8
9
  export * from "./economy.js";
9
10
  export * from "./game.js";
@@ -11,5 +12,7 @@ export * from "./http.js";
11
12
  export * from "./inventory.js";
12
13
  export * from "./lobby.js";
13
14
  export * from "./models.js";
15
+ export * from "./permissions.js";
16
+ export * from "./timer.js";
14
17
  export * from "./ui.js";
15
- export declare const VERSION = "0.2.0";
18
+ export declare const VERSION = "0.3.1";
@@ -0,0 +1,16 @@
1
+ import type { Context } from "./context.js";
2
+ import type { Intent } from "./models.js";
3
+ export declare class PermissionsContext {
4
+ private ctx;
5
+ constructor(ctx: Context);
6
+ set(options: {
7
+ target: number | string;
8
+ allow?: string[];
9
+ deny?: string[];
10
+ channelId?: number | string;
11
+ durationSeconds?: number;
12
+ reason?: string;
13
+ }): Intent;
14
+ lockChannel(durationSeconds?: number, channelId?: number | string): Intent;
15
+ lock_channel: (durationSeconds?: number, channelId?: number | string) => Intent;
16
+ }
@@ -0,0 +1,8 @@
1
+ import type { Context } from "./context.js";
2
+ import type { Intent } from "./models.js";
3
+ export declare class TimerContext {
4
+ private ctx;
5
+ constructor(ctx: Context);
6
+ schedule(delaySeconds: number, callback?: string): Intent;
7
+ cancel(): Intent;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angela-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Official TypeScript & JavaScript SDK for Angela Games Ecosystem cartridges",
6
6
  "main": "./dist/cjs/index.js",