@jsm-mit/tigi-sharded-package 0.2.0 → 0.4.0

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 (37) hide show
  1. package/README.md +51 -3
  2. package/declarations/coordinator/coordinator.did +39 -0
  3. package/declarations/coordinator/coordinator.did.d.ts +68 -0
  4. package/declarations/coordinator/coordinator.did.js +23 -0
  5. package/declarations/core/core.did +210 -45
  6. package/declarations/core/core.did.d.ts +191 -43
  7. package/declarations/core/core.did.js +146 -42
  8. package/declarations/tigi-driver/tigi-driver.did +15 -0
  9. package/declarations/tigi-driver/tigi-driver.did.d.ts +19 -0
  10. package/declarations/tigi-driver/tigi-driver.did.js +6 -0
  11. package/declarations/tigi-simulator/tigi-simulator.did +46 -4
  12. package/declarations/tigi-simulator/tigi-simulator.did.d.ts +70 -4
  13. package/declarations/tigi-simulator/tigi-simulator.did.js +39 -10
  14. package/declarations/worker/worker.did +23 -6
  15. package/declarations/worker/worker.did.d.ts +18 -6
  16. package/declarations/worker/worker.did.js +14 -7
  17. package/dist/actors/driver-canisters-actor.d.ts +77 -0
  18. package/dist/actors/driver-canisters-actor.d.ts.map +1 -0
  19. package/dist/actors/driver-canisters-actor.js +147 -0
  20. package/dist/actors/rides-actor.d.ts +21 -1
  21. package/dist/actors/rides-actor.d.ts.map +1 -1
  22. package/dist/actors/rides-actor.js +44 -2
  23. package/dist/geo.d.ts +5 -0
  24. package/dist/geo.d.ts.map +1 -1
  25. package/dist/geo.js +41 -0
  26. package/dist/group/canister-actor.d.ts +7 -0
  27. package/dist/group/canister-actor.d.ts.map +1 -1
  28. package/dist/group/canister-actor.js +18 -0
  29. package/dist/index.d.ts +3 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +5 -2
  32. package/dist/interfaces.d.ts +43 -1
  33. package/dist/interfaces.d.ts.map +1 -1
  34. package/dist/mappers.d.ts +7 -2
  35. package/dist/mappers.d.ts.map +1 -1
  36. package/dist/mappers.js +17 -2
  37. package/package.json +7 -4
@@ -28,6 +28,11 @@ type WasmChunkArgs =
28
28
  index: nat32;
29
29
  kind: WasmKind;
30
30
  };
31
+ type UsageBatch =
32
+ record {
33
+ batchId: nat64;
34
+ entries: vec DriverUsage;
35
+ };
31
36
  type UnblockRiderArgs = record {rider: principal;};
32
37
  type UnblockDriverArgs =
33
38
  record {
@@ -40,54 +45,66 @@ type TigiCore =
40
45
  /// Admins: an admin more (the coordinator adds the people who rule the group).
41
46
  addAdmin: (args: PrincipalArgs) -> (Result_2);
42
47
  /// Admins: a canister the core controls joins the demo pool (U-35).
43
- addPoolCanister: (args: CanisterArgs) -> (Result_16);
48
+ addPoolCanister: (args: CanisterArgs) -> (Result_20);
44
49
  /// Admins: a driver canister, or one driver in it (`driverKey`), is blocked; the workers
45
50
  /// drop it at once (WO-2).
46
51
  blockDriver: (args: BlockDriverArgs) -> (Result_2);
47
52
  /// Admins: a rider is blocked (core.md, accepted 2026-10-22).
48
53
  blockRider: (args: BlockRiderArgs) -> (Result_2);
54
+ /// F-20 (U-45): the caller — the driver signed in on the canister's own front — takes
55
+ /// over the demo canister with the code of the link. Single use, 15 min; every refusal
56
+ /// answers the same NotAuthorized. The room of the canister gets the caller (C-15).
57
+ claimDriverCanister: (args: ClaimArgs) -> (Result_20);
49
58
  clearLogs: () -> ();
50
59
  /// Admins: the chunks become THE module of their kind. A new driver wasm is released
51
60
  /// (F-11) and its hash goes to the workers.
52
- commitDriverWasm: (args: WasmCommitArgs) -> (Result_22);
61
+ commitDriverWasm: (args: WasmCommitArgs) -> (Result_29);
53
62
  /// Admins, localTest: an empty canister from the core's cycles joins the demo pool.
54
- createLocalPoolCanister: () -> (Result_16);
63
+ createLocalPoolCanister: () -> (Result_20);
55
64
  /// F-2 … F-4, F-10: the caller's own driver canister (localTest: from the core's cycles).
56
- createMyDriverCanister: () -> (Result_16);
65
+ createMyDriverCanister: () -> (Result_20);
57
66
  /// Admins: the simulator, created once (F-18).
58
- ensureSimulator: () -> (Result_21);
67
+ ensureSimulator: () -> (Result_28);
59
68
  /// F-8: 15 min more for the holder of a demo canister.
60
- extendDemoLease: () -> (Result_16);
61
- getAdmins: () -> (Result_20) query;
69
+ extendDemoLease: () -> (Result_20);
70
+ getAdmins: () -> (Result_27) query;
62
71
  /// For the fronts (through the package): where the chat of this environment is. Null =
63
72
  /// no chat here yet. The room of a driver is `ChatRoomFunctions.driverRoomId`.
64
73
  getChatConfig: () -> (opt ChatConfig) query;
65
74
  /// Admins: how far the driver rooms are (C-15).
66
- getChatRoomsStatus: () -> (Result_19) query;
75
+ getChatRoomsStatus: () -> (Result_26) query;
67
76
  /// WO-1, WO-2: what the core knows of a canister — for the workers and anybody.
68
77
  getDriverCanisterStatus: (args: CanisterArgs) ->
69
78
  (DriverCanisterStatus) query;
70
- getDriverRollout: () -> (Result_18) query;
71
- getFactoryStatus: () -> (Result_17) query;
79
+ /// Admins: the account of one driver canister (C-17 … C-20).
80
+ getDriverFeeAccount: (args: CanisterArgs) -> (Result_25) query;
81
+ /// C-19: a driver canister of the registry asks for its bill — the events since its
82
+ /// last settlement, priced on the fee's day. Called by the canister at its first
83
+ /// "Przyjmuję zlecenia" of a day. A pool canister owes nothing (C-18).
84
+ getDriverFeeBill: () -> (Result_24);
85
+ getDriverRollout: () -> (Result_23) query;
86
+ getFactoryStatus: () -> (Result_22) query;
87
+ /// C-22: the rates, the day, the multiplier cached, the totals.
88
+ getFeeStatus: () -> (Result_21) query;
72
89
  getLogs: () -> (text) query;
73
90
  /// The caller's own canister, or the demo canister the caller holds now.
74
- getMyDriverCanister: () -> (Result_16) query;
91
+ getMyDriverCanister: () -> (Result_20) query;
75
92
  getMyProfile: () -> (Result_4) query;
76
93
  /// C-16, PF-4: the caller's own rating as a rider (sum and count of stars; null = no
77
94
  /// rating yet). Ratings reach the core in the workers' batches, up to a minute late.
78
- getMyRating: () -> (Result_15) query;
95
+ getMyRating: () -> (Result_19) query;
79
96
  /// C-8: the caller's rides, newest first.
80
- getMyRides: (args: RidesPageArgs) -> (Result_14) query;
97
+ getMyRides: (args: RidesPageArgs) -> (Result_18) query;
81
98
  /// C-3: the names of up to MAX_PROFILES_PER_CALL principals; unknown ones are left out.
82
- getProfiles: (args: ProfilesArgs) -> (Result_13) query;
99
+ getProfiles: (args: ProfilesArgs) -> (Result_17) query;
83
100
  /// F-11: the driver wasms released so far, oldest first.
84
101
  getReleasedDriverWasms: () -> (vec ReleasedWasm) query;
85
102
  /// F-18: the simulator of this group; none in prod or before ensureSimulator.
86
103
  getSimulator: () -> (opt principal) query;
87
104
  /// Admins: the coordinator, the workers confirmed so far, the mode.
88
- getWiring: () -> (Result_12) query;
105
+ getWiring: () -> (Result_16) query;
89
106
  /// Admins: how far the outbox to the workers is (C-6, C-7).
90
- getWorkerOutbox: () -> (Result_11) query;
107
+ getWorkerOutbox: () -> (Result_15) query;
91
108
  /// Workers of the group: the core asks the coordinator once and remembers the worker,
92
109
  /// which then gets the network state through the outbox. A worker calls it once after
93
110
  /// its install. Answers true.
@@ -95,27 +112,49 @@ type TigiCore =
95
112
  /// Workers of the group: finished rides and ratings, at most MAX_RIDE_BATCH (C-4, C-5).
96
113
  /// Idempotent: a known requestId and a counted rating count once. Invalid entries are
97
114
  /// rejected and logged; the worker drops the whole batch after an ok.
98
- ingestRideBatch: (batch: RideBatch) -> (Result_10);
115
+ ingestRideBatch: (batch: RideBatch) -> (Result_14);
99
116
  /// C-14: the accounts gate of the chat (U-43). The chat core asks this group's
100
117
  /// coordinator WHERE (`accountsCanisterFor` → this core) and asks here: true = an
101
118
  /// account with a name exists for the principal and the rider is not blocked.
102
119
  isUser: ("principal": principal) -> (bool) query;
103
- /// F-5 … F-7: a demo canister for 15 min (outside prod).
104
- leaseDemoDriverCanister: () -> (Result_9);
105
- listBlocks: (args: PageArgs) -> (Result_8) query;
106
- listDriverCanisters: (args: PageArgs) -> (Result_7) query;
120
+ /// F-5 … F-7: a demo canister for 15 min (outside prod). A fresh lease comes with a
121
+ /// one-time claim code (F-20, U-45).
122
+ leaseDemoDriverCanister: () -> (Result_13);
123
+ listBlocks: (args: PageArgs) -> (Result_12) query;
124
+ listDriverCanisters: (args: PageArgs) -> (Result_11) query;
125
+ /// Admins: the accounts, 100 a page at most.
126
+ listDriverFeeAccounts: (args: PageArgs) -> (Result_10) query;
107
127
  /// Admins: the driver rooms as the core wants them, 100 a page at most.
108
- listDriverRooms: (args: PageArgs) -> (Result_6) query;
128
+ listDriverRooms: (args: PageArgs) -> (Result_9) query;
129
+ /// F-20: a fresh claim code for the caller's running demo lease; the old one stops
130
+ /// working.
131
+ newClaimCode: () -> (Result_8);
132
+ /// C-20: the driver canister pays the bill of `day` with the cycles attached to this
133
+ /// call. The core takes exactly the bill (the rest goes back), or nothing when less is
134
+ /// attached (`FEE_SHORT`); a day paid already answers `accepted = 0`.
135
+ payDriverFee: (args: FeePayArgs) -> (Result_7);
109
136
  removeAdmin: (args: PrincipalArgs) -> (Result_2);
110
137
  resumeDriverRollout: () -> (Result_3);
111
138
  /// Admins: the chat of this environment — the chat group's coordinator and the project
112
139
  /// (whose admin and accounts field are this group's coordinator). Every call sends every
113
140
  /// driver room again (a new project, a chat group set up again).
114
- setChatConfig: (args: ChatConfig) -> (Result_5);
141
+ setChatConfig: (args: ChatConfig) -> (Result_6);
142
+ /// Admins, localTest only: new claim codes live this long (the local check of an
143
+ /// expired code). Heap only: an upgrade brings back 15 min.
144
+ setClaimCodeTtl: (args: ClaimTtlArgs) -> (Result);
145
+ /// Admins: the cycles per event (C-18).
146
+ setFeeRates: (rates: FeeRates) -> (Result_5);
115
147
  setLoggingEnabled: (enabled: bool) -> (Result_2);
116
148
  /// The coordinator only: the balance below which the core asks for cycles.
117
149
  setLowCyclesBelow: (value: nat) -> (Result_2);
118
150
  setMyProfile: (args: SetProfileArgs) -> (Result_4);
151
+ /// F-21 (2026-10-24, route line): admins — the one principal that routes the simulator's
152
+ /// quotes (S-N13, a Node process like a driver's front); null removes it. The simulator
153
+ /// takes it from the core only.
154
+ setSimulatorRouter: (args: SimulatorRouterArgs) -> (Result_2);
155
+ /// Admins, localTest only: the fee's day moves this many days on (the local check of
156
+ /// "the next day"). Heap only: an upgrade brings back the real day.
157
+ setTestDayOffset: (args: TestDayArgs) -> (Result);
119
158
  /// Admins: a rollout of the current driver wasm (F-12): the canary, then the rest, one
120
159
  /// canister a step, never during a ride (F-13).
121
160
  startDriverRollout: () -> (Result_3);
@@ -126,6 +165,8 @@ type TigiCore =
126
165
  /// Admins: one chunk of a new driver or simulator module (gzipped: ~0.7 MB).
127
166
  uploadDriverWasmChunk: (args: WasmChunkArgs) -> (Result);
128
167
  };
168
+ type TestDayArgs = record {days: nat;};
169
+ type SimulatorRouterArgs = record {router: opt principal;};
129
170
  type SetProfileArgs = record {name: text;};
130
171
  type RolloutView =
131
172
  record {
@@ -190,31 +231,32 @@ type RideBatch =
190
231
  record {
191
232
  ratings: vec RatingEntry;
192
233
  rides: vec RideEntry;
234
+ usage: opt UsageBatch;
193
235
  };
194
236
  type Result_9 =
195
237
  variant {
196
238
  err: Error;
197
- ok: LeaseAnswer;
239
+ ok: vec DriverRoomView;
198
240
  };
199
241
  type Result_8 =
200
242
  variant {
201
243
  err: Error;
202
- ok: vec Block;
244
+ ok: ClaimCode;
203
245
  };
204
246
  type Result_7 =
205
247
  variant {
206
248
  err: Error;
207
- ok: DriverCanistersPage;
249
+ ok: FeePaid;
208
250
  };
209
251
  type Result_6 =
210
252
  variant {
211
253
  err: Error;
212
- ok: vec DriverRoomView;
254
+ ok: ChatConfig;
213
255
  };
214
256
  type Result_5 =
215
257
  variant {
216
258
  err: Error;
217
- ok: ChatConfig;
259
+ ok: FeeRates;
218
260
  };
219
261
  type Result_4 =
220
262
  variant {
@@ -226,67 +268,82 @@ type Result_3 =
226
268
  err: Error;
227
269
  ok: RolloutView;
228
270
  };
229
- type Result_22 =
271
+ type Result_29 =
230
272
  variant {
231
273
  err: Error;
232
274
  ok: WasmInfo;
233
275
  };
234
- type Result_21 =
276
+ type Result_28 =
235
277
  variant {
236
278
  err: Error;
237
279
  ok: principal;
238
280
  };
239
- type Result_20 =
281
+ type Result_27 =
240
282
  variant {
241
283
  err: Error;
242
284
  ok: vec principal;
243
285
  };
244
- type Result_2 =
286
+ type Result_26 =
245
287
  variant {
246
288
  err: Error;
247
- ok: bool;
289
+ ok: ChatRoomsStatus;
248
290
  };
249
- type Result_19 =
291
+ type Result_25 =
250
292
  variant {
251
293
  err: Error;
252
- ok: ChatRoomsStatus;
294
+ ok: DriverFeeAccountView;
253
295
  };
254
- type Result_18 =
296
+ type Result_24 =
297
+ variant {
298
+ err: Error;
299
+ ok: FeeBill;
300
+ };
301
+ type Result_23 =
255
302
  variant {
256
303
  err: Error;
257
304
  ok: opt RolloutView;
258
305
  };
259
- type Result_17 =
306
+ type Result_22 =
260
307
  variant {
261
308
  err: Error;
262
309
  ok: FactoryStatus;
263
310
  };
264
- type Result_16 =
311
+ type Result_21 =
312
+ variant {
313
+ err: Error;
314
+ ok: FeeStatus;
315
+ };
316
+ type Result_20 =
265
317
  variant {
266
318
  err: Error;
267
319
  ok: DriverCanister;
268
320
  };
269
- type Result_15 =
321
+ type Result_2 =
322
+ variant {
323
+ err: Error;
324
+ ok: bool;
325
+ };
326
+ type Result_19 =
270
327
  variant {
271
328
  err: Error;
272
329
  ok: opt Rating;
273
330
  };
274
- type Result_14 =
331
+ type Result_18 =
275
332
  variant {
276
333
  err: Error;
277
334
  ok: RidesPage;
278
335
  };
279
- type Result_13 =
336
+ type Result_17 =
280
337
  variant {
281
338
  err: Error;
282
339
  ok: vec ProfileEntry;
283
340
  };
284
- type Result_12 =
341
+ type Result_16 =
285
342
  variant {
286
343
  err: Error;
287
344
  ok: Wiring;
288
345
  };
289
- type Result_11 =
346
+ type Result_15 =
290
347
  variant {
291
348
  err: Error;
292
349
  ok:
@@ -297,11 +354,31 @@ type Result_11 =
297
354
  subjects: nat;
298
355
  };
299
356
  };
300
- type Result_10 =
357
+ type Result_14 =
301
358
  variant {
302
359
  err: Error;
303
360
  ok: RideBatchResult;
304
361
  };
362
+ type Result_13 =
363
+ variant {
364
+ err: Error;
365
+ ok: LeaseAnswer;
366
+ };
367
+ type Result_12 =
368
+ variant {
369
+ err: Error;
370
+ ok: vec Block;
371
+ };
372
+ type Result_11 =
373
+ variant {
374
+ err: Error;
375
+ ok: DriverCanistersPage;
376
+ };
377
+ type Result_10 =
378
+ variant {
379
+ err: Error;
380
+ ok: vec DriverFeeAccountView;
381
+ };
305
382
  type Result_1 =
306
383
  variant {
307
384
  err: Error;
@@ -367,10 +444,22 @@ type Mode =
367
444
  stage;
368
445
  test;
369
446
  };
447
+ type LeasedCanister =
448
+ record {
449
+ blocked: bool;
450
+ canister: principal;
451
+ claim: opt ClaimCode;
452
+ createdAtNs: int;
453
+ installedAtNs: opt int;
454
+ kind: DriverCanisterKind;
455
+ leaseUntilNs: opt int;
456
+ moduleHash: opt blob;
457
+ owner: principal;
458
+ };
370
459
  type LeaseAnswer =
371
460
  variant {
372
461
  busy: record {untilNs: int;};
373
- leased: DriverCanister;
462
+ leased: LeasedCanister;
374
463
  };
375
464
  type InitArgs =
376
465
  record {
@@ -378,6 +467,54 @@ type InitArgs =
378
467
  coordinator: opt principal;
379
468
  mode: Mode;
380
469
  };
470
+ type FeeUsage =
471
+ record {
472
+ quoteRequests: nat;
473
+ registrations: nat;
474
+ rides: nat;
475
+ };
476
+ type FeeStatus =
477
+ record {
478
+ accounts: nat;
479
+ forwardedTotal: nat;
480
+ lastForwardError: opt text;
481
+ multiplier: opt record {
482
+ day: nat;
483
+ permille: nat;
484
+ };
485
+ paidTotal: nat;
486
+ rates: FeeRates;
487
+ toForward: nat;
488
+ today: nat;
489
+ };
490
+ type FeeRecord =
491
+ record {
492
+ amount: nat;
493
+ day: nat;
494
+ paidAtNs: int;
495
+ };
496
+ type FeeRates =
497
+ record {
498
+ perQuoteRequest: nat;
499
+ perRegistration: nat;
500
+ perRide: nat;
501
+ };
502
+ type FeePayArgs = record {day: nat;};
503
+ type FeePaid =
504
+ record {
505
+ accepted: nat;
506
+ amount: nat;
507
+ day: nat;
508
+ };
509
+ type FeeBill =
510
+ record {
511
+ amount: nat;
512
+ day: nat;
513
+ multiplierPermille: nat;
514
+ rates: FeeRates;
515
+ settled: bool;
516
+ usage: FeeUsage;
517
+ };
381
518
  type FactoryStatus =
382
519
  record {
383
520
  creationsInProgress: nat;
@@ -405,6 +542,13 @@ type Error =
405
542
  details: ErrorDetails;
406
543
  logsJson: text;
407
544
  };
545
+ type DriverUsage =
546
+ record {
547
+ canister: principal;
548
+ quoteRequests: nat;
549
+ registrations: nat;
550
+ rides: nat;
551
+ };
408
552
  type DriverRoomView =
409
553
  record {
410
554
  canister: principal;
@@ -414,6 +558,15 @@ type DriverRoomView =
414
558
  roomId: text;
415
559
  synced: bool;
416
560
  };
561
+ type DriverFeeAccountView =
562
+ record {
563
+ bill: opt FeeBill;
564
+ canister: principal;
565
+ lastFee: opt FeeRecord;
566
+ lastSettledDay: opt nat;
567
+ paidTotal: nat;
568
+ pending: FeeUsage;
569
+ };
417
570
  type DriverCanistersPage =
418
571
  record {
419
572
  canisters: vec DriverCanister;
@@ -441,6 +594,18 @@ type DriverCanister =
441
594
  moduleHash: opt blob;
442
595
  owner: principal;
443
596
  };
597
+ type ClaimTtlArgs = record {seconds: nat;};
598
+ type ClaimCode =
599
+ record {
600
+ canister: principal;
601
+ code: text;
602
+ expiresAtNs: int;
603
+ };
604
+ type ClaimArgs =
605
+ record {
606
+ canister: principal;
607
+ code: text;
608
+ };
444
609
  type ChatRoomsStatus =
445
610
  record {
446
611
  config: opt ChatConfig;