@jush-agent/sdk 0.2.6252 → 0.2.6254

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/dist/index.mjs CHANGED
@@ -2350,7 +2350,7 @@ const commandLocaleSchema = z.object({
2350
2350
  * What a declared command knows beyond its arguments: which conversation it
2351
2351
  * serves, who started it, and the locale and color scheme its results are
2352
2352
  * presented in. Work that belongs to no conversation names the provider
2353
- * entry it serves instead.
2353
+ * entry it serves instead, or the device's own scope ([`DEVICE_SCOPE`]).
2354
2354
  *
2355
2355
  * The backend is its only source, and nothing reads it from the environment:
2356
2356
  * a script can change variables, and every program a job runs inherits them.
@@ -2737,6 +2737,8 @@ const errorCodeSchema = z.enum([
2737
2737
  "device_not_found",
2738
2738
  "device_managed",
2739
2739
  "device_offline",
2740
+ "device_lost",
2741
+ "command_timed_out",
2740
2742
  "not_a_paired_device",
2741
2743
  "conversation_not_found",
2742
2744
  "block_not_found",
@@ -2897,6 +2899,16 @@ const projectDtoSchema = z.object({
2897
2899
  */
2898
2900
  savedCount: z.int().min(0)
2899
2901
  });
2902
+ /** What a script printed, read as UTF-8 with an invalid byte as U+FFFD. */
2903
+ const execOutputSchema = z.object({
2904
+ stdout: z.string(),
2905
+ stderr: z.string(),
2906
+ /**
2907
+ * The bytes missing from both: the middle a device leaves out past the
2908
+ * 16 MiB of a job's output it keeps, and what could not be read from it.
2909
+ */
2910
+ leftOutBytes: z.int().min(0)
2911
+ });
2900
2912
  /**
2901
2913
  * A JSON error answer: `{ code, message, params?, requestId }`, and a
2902
2914
  * plugin's own `reason` when a plugin refused the call. The page words the
@@ -2937,6 +2949,11 @@ const errorBodySchema = z.object({
2937
2949
  * directory, which the page opens rather than a second one.
2938
2950
  */
2939
2951
  project: projectDtoSchema.nullable().optional(),
2952
+ /**
2953
+ * With `command_timed_out`, what the script printed before it was
2954
+ * stopped.
2955
+ */
2956
+ output: execOutputSchema.nullable().optional(),
2940
2957
  /** The request the answer is of, as its `X-Request-Id` names it. */
2941
2958
  requestId: z.string().min(1)
2942
2959
  });
@@ -5271,6 +5288,15 @@ const accountsSchema = z.object({
5271
5288
  z.strictObject({ credentialId: z.string().min(1) });
5272
5289
  /** `{ active }`: the account the entry now infers with. */
5273
5290
  const activeAccountSchema = z.object({ active: z.string().min(1) });
5291
+ /**
5292
+ * An agent's turn: the agent, whose node is the conversation's id for its
5293
+ * root, and the turn, whose id for a turn a message started is the
5294
+ * message's.
5295
+ */
5296
+ const agentTurnSchema = z.object({
5297
+ node: z.string().min(1),
5298
+ turn: z.string().min(1)
5299
+ });
5274
5300
  /** Whether the page follows the system's light or dark scheme or fixes one. */
5275
5301
  const themeSchema = z.enum([
5276
5302
  "system",
@@ -5510,6 +5536,201 @@ const conversationStatusSchema = z.enum([
5510
5536
  * is green for an answer and red for an error.
5511
5537
  */
5512
5538
  const unreadEndSchema = z.enum(["answered", "failed"]);
5539
+ /** The unit a repeat's cycle counts in. */
5540
+ const repeatUnitSchema = z.enum([
5541
+ "days",
5542
+ "weeks",
5543
+ "months",
5544
+ "years"
5545
+ ]);
5546
+ /**
5547
+ * A repeating cycle, as Calendar's repeat: every `every` days, weeks,
5548
+ * months or years. A cycle of several units counts from the day, week,
5549
+ * month or year of `start`, its first cycle, and runs its tasks in each
5550
+ * cycle's first unit.
5551
+ */
5552
+ const repeatSchema = z.object({
5553
+ every: z.int().min(1).max(4294967295),
5554
+ unit: repeatUnitSchema,
5555
+ /**
5556
+ * The first cycle's day, as `2026-01-01`, for a cycle of several
5557
+ * units; null for one unit.
5558
+ */
5559
+ start: z.string().nullable()
5560
+ });
5561
+ /** A day of the week, as a weekly task names the days it runs on. */
5562
+ const weekdaySchema = z.enum([
5563
+ "mon",
5564
+ "tue",
5565
+ "wed",
5566
+ "thu",
5567
+ "fri",
5568
+ "sat",
5569
+ "sun"
5570
+ ]);
5571
+ /** Which of a month's weekdays. */
5572
+ const weekOfMonthSchema = z.enum([
5573
+ "first",
5574
+ "second",
5575
+ "third",
5576
+ "fourth",
5577
+ "last"
5578
+ ]);
5579
+ /** The first or the last. */
5580
+ const firstOrLastSchema = z.enum(["first", "last"]);
5581
+ /**
5582
+ * A day of a month: a date, which a month without it skips; the last day;
5583
+ * a weekday's first to fourth or last; or the first or last working day.
5584
+ */
5585
+ const monthDaySchema = z.discriminatedUnion("kind", [
5586
+ z.object({
5587
+ kind: z.literal("date"),
5588
+ date: z.int().min(1).max(31)
5589
+ }),
5590
+ z.object({ kind: z.literal("last_day") }),
5591
+ z.object({
5592
+ kind: z.literal("weekday"),
5593
+ week: weekOfMonthSchema,
5594
+ weekday: weekdaySchema
5595
+ }),
5596
+ z.object({
5597
+ kind: z.literal("working_day"),
5598
+ which: firstOrLastSchema
5599
+ })
5600
+ ]);
5601
+ /**
5602
+ * A country by its ISO 3166 code, and one of its regions whose holidays
5603
+ * differ, by the code the holidays' table gives it.
5604
+ */
5605
+ const holidayPlaceSchema = z.object({
5606
+ country: z.string().min(2).max(3),
5607
+ region: z.string().nullable()
5608
+ });
5609
+ /**
5610
+ * A task of a repeat: a moment in its cycle and the message it sends.
5611
+ *
5612
+ * Its moment is `time` and, as the repeat's unit asks, `days` (weeks),
5613
+ * `day` (months), or `month` and `day` (years); the parts another unit
5614
+ * reads are kept, so a repeat changed back finds them as they were.
5615
+ */
5616
+ const taskSchema = z.object({
5617
+ /** Unique among the repeat's tasks; the page or the command makes it. */
5618
+ id: z.string().min(1),
5619
+ /** A clock time as `09:00`. */
5620
+ time: z.string().regex(/* @__PURE__ */ new RegExp("^([01][0-9]|2[0-3]):[0-5][0-9]$", "u")),
5621
+ /** One to seven distinct days. */
5622
+ days: z.array(weekdaySchema).min(1).max(7),
5623
+ day: monthDaySchema,
5624
+ /** 1 to 12. */
5625
+ month: z.int().min(1).max(12),
5626
+ /**
5627
+ * The country, and its region, whose working week and public
5628
+ * holidays a first or last working day follows; null for Monday to
5629
+ * Friday.
5630
+ */
5631
+ holidays: holidayPlaceSchema.nullable(),
5632
+ /** Empty until written; a task without a message does not run. */
5633
+ prompt: z.string()
5634
+ });
5635
+ /** When a time trigger fires, in the schedule's time zone. */
5636
+ const timingSchema = z.discriminatedUnion("kind", [
5637
+ z.object({
5638
+ kind: z.literal("once"),
5639
+ at: z.iso.datetime({ precision: 3 })
5640
+ }),
5641
+ z.object({
5642
+ kind: z.literal("repeat"),
5643
+ repeat: repeatSchema,
5644
+ tasks: z.array(taskSchema).min(1)
5645
+ }),
5646
+ z.object({
5647
+ kind: z.literal("every"),
5648
+ minutes: z.int().min(1).max(4294967295)
5649
+ }),
5650
+ z.object({
5651
+ kind: z.literal("cron"),
5652
+ expression: z.string().min(9)
5653
+ })
5654
+ ]);
5655
+ /** What starts a schedule's runs. */
5656
+ const triggerSchema = z.discriminatedUnion("kind", [
5657
+ z.object({
5658
+ kind: z.literal("time"),
5659
+ timing: timingSchema
5660
+ }),
5661
+ z.object({
5662
+ kind: z.literal("change"),
5663
+ command: z.string().min(1),
5664
+ everyMinutes: z.int().min(1).max(4294967295)
5665
+ }),
5666
+ z.object({ kind: z.literal("url") }),
5667
+ z.object({
5668
+ kind: z.literal("done"),
5669
+ conversation: z.string().regex(/* @__PURE__ */ new RegExp("^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$", "u"))
5670
+ })
5671
+ ]);
5672
+ /** Where a run stands. */
5673
+ const runStateSchema = z.enum([
5674
+ "running",
5675
+ "done",
5676
+ "skipped",
5677
+ "failed",
5678
+ "notified"
5679
+ ]);
5680
+ /** Why a run was skipped or failed, which the page words. */
5681
+ const runNoteSchema = z.discriminatedUnion("kind", [
5682
+ z.object({
5683
+ kind: z.literal("offline"),
5684
+ device: z.string()
5685
+ }),
5686
+ z.object({
5687
+ kind: z.literal("limit"),
5688
+ limit: z.int().min(0).max(4294967295),
5689
+ calls: z.int().min(0).max(4294967295)
5690
+ }),
5691
+ z.object({ kind: z.literal("command_timed_out") }),
5692
+ z.object({
5693
+ kind: z.literal("command_failed"),
5694
+ message: z.string()
5695
+ }),
5696
+ z.object({
5697
+ kind: z.literal("turn_failed"),
5698
+ message: z.string(),
5699
+ code: z.string().nullable()
5700
+ })
5701
+ ]);
5702
+ /** How a schedule last woke its conversation. */
5703
+ const lastRunSchema = z.object({
5704
+ at: z.iso.datetime({ precision: 3 }),
5705
+ state: runStateSchema,
5706
+ /** Why it was skipped or failed. */
5707
+ note: runNoteSchema.nullable()
5708
+ });
5709
+ /**
5710
+ * A schedule of a conversation as its Schedules menu lists it: what wakes
5711
+ * the conversation, when it next will, and how it last did. The user pauses,
5712
+ * resumes and deletes it there; the agent and a program do the rest.
5713
+ */
5714
+ const conversationScheduleSchema = z.object({
5715
+ id: z.string().min(1),
5716
+ name: z.string(),
5717
+ trigger: triggerSchema,
5718
+ /** The IANA time zone its times are read in. */
5719
+ timeZone: z.string(),
5720
+ /**
5721
+ * Whether the user or the agent paused it. A schedule of an archived
5722
+ * conversation wakes nothing either, which the conversation's own
5723
+ * archived state says.
5724
+ */
5725
+ paused: z.boolean(),
5726
+ /**
5727
+ * When it next wakes the conversation; null while paused, while its
5728
+ * conversation is archived, with no time left, and for a URL.
5729
+ */
5730
+ nextAt: z.iso.datetime({ precision: 3 }).nullable(),
5731
+ /** Its last run; null before it woke the conversation. */
5732
+ lastRun: lastRunSchema.nullable()
5733
+ });
5513
5734
  /**
5514
5735
  * A conversation as the list carries it: what the sidebar shows of it, and
5515
5736
  * its work's tabs, which the page draws before it opens the
@@ -5567,10 +5788,11 @@ const conversationSummarySchema = z.object({
5567
5788
  */
5568
5789
  unreadPermissionRequests: z.int().min(0),
5569
5790
  /**
5570
- * Whether the conversation has a schedule, which the sidebar marks with
5571
- * an alarm clock; its schedules are in its metadata.
5791
+ * The schedules that wake the conversation, newest first: the sidebar
5792
+ * marks a conversation that has one with an alarm clock, and its
5793
+ * Schedules menu lists them.
5572
5794
  */
5573
- scheduled: z.boolean(),
5795
+ schedules: z.array(conversationScheduleSchema),
5574
5796
  /**
5575
5797
  * The conversation's work: its tabs under the revision that counts
5576
5798
  * its changes. The page draws the work's frame and tabs from it as soon
@@ -6475,201 +6697,6 @@ const conversationPermissionsSchema = z.object({
6475
6697
  revision: z.int().min(0),
6476
6698
  requests: z.array(permissionRequestSchema)
6477
6699
  });
6478
- /** The unit a repeat's cycle counts in. */
6479
- const repeatUnitSchema = z.enum([
6480
- "days",
6481
- "weeks",
6482
- "months",
6483
- "years"
6484
- ]);
6485
- /**
6486
- * A repeating cycle, as Calendar's repeat: every `every` days, weeks,
6487
- * months or years. A cycle of several units counts from the day, week,
6488
- * month or year of `start`, its first cycle, and runs its tasks in each
6489
- * cycle's first unit.
6490
- */
6491
- const repeatSchema = z.object({
6492
- every: z.int().min(1).max(4294967295),
6493
- unit: repeatUnitSchema,
6494
- /**
6495
- * The first cycle's day, as `2026-01-01`, for a cycle of several
6496
- * units; null for one unit.
6497
- */
6498
- start: z.string().nullable()
6499
- });
6500
- /** A day of the week, as a weekly task names the days it runs on. */
6501
- const weekdaySchema = z.enum([
6502
- "mon",
6503
- "tue",
6504
- "wed",
6505
- "thu",
6506
- "fri",
6507
- "sat",
6508
- "sun"
6509
- ]);
6510
- /** Which of a month's weekdays. */
6511
- const weekOfMonthSchema = z.enum([
6512
- "first",
6513
- "second",
6514
- "third",
6515
- "fourth",
6516
- "last"
6517
- ]);
6518
- /** The first or the last. */
6519
- const firstOrLastSchema = z.enum(["first", "last"]);
6520
- /**
6521
- * A day of a month: a date, which a month without it skips; the last day;
6522
- * a weekday's first to fourth or last; or the first or last working day.
6523
- */
6524
- const monthDaySchema = z.discriminatedUnion("kind", [
6525
- z.object({
6526
- kind: z.literal("date"),
6527
- date: z.int().min(1).max(31)
6528
- }),
6529
- z.object({ kind: z.literal("last_day") }),
6530
- z.object({
6531
- kind: z.literal("weekday"),
6532
- week: weekOfMonthSchema,
6533
- weekday: weekdaySchema
6534
- }),
6535
- z.object({
6536
- kind: z.literal("working_day"),
6537
- which: firstOrLastSchema
6538
- })
6539
- ]);
6540
- /**
6541
- * A country by its ISO 3166 code, and one of its regions whose holidays
6542
- * differ, by the code the holidays' table gives it.
6543
- */
6544
- const holidayPlaceSchema = z.object({
6545
- country: z.string().min(2).max(3),
6546
- region: z.string().nullable()
6547
- });
6548
- /**
6549
- * A task of a repeat: a moment in its cycle and the message it sends.
6550
- *
6551
- * Its moment is `time` and, as the repeat's unit asks, `days` (weeks),
6552
- * `day` (months), or `month` and `day` (years); the parts another unit
6553
- * reads are kept, so a repeat changed back finds them as they were.
6554
- */
6555
- const taskSchema = z.object({
6556
- /** Unique among the repeat's tasks; the page or the command makes it. */
6557
- id: z.string().min(1),
6558
- /** A clock time as `09:00`. */
6559
- time: z.string().regex(/* @__PURE__ */ new RegExp("^([01][0-9]|2[0-3]):[0-5][0-9]$", "u")),
6560
- /** One to seven distinct days. */
6561
- days: z.array(weekdaySchema).min(1).max(7),
6562
- day: monthDaySchema,
6563
- /** 1 to 12. */
6564
- month: z.int().min(1).max(12),
6565
- /**
6566
- * The country, and its region, whose working week and public
6567
- * holidays a first or last working day follows; null for Monday to
6568
- * Friday.
6569
- */
6570
- holidays: holidayPlaceSchema.nullable(),
6571
- /** Empty until written; a task without a message does not run. */
6572
- prompt: z.string()
6573
- });
6574
- /** When a time trigger fires, in the schedule's time zone. */
6575
- const timingSchema = z.discriminatedUnion("kind", [
6576
- z.object({
6577
- kind: z.literal("once"),
6578
- at: z.iso.datetime({ precision: 3 })
6579
- }),
6580
- z.object({
6581
- kind: z.literal("repeat"),
6582
- repeat: repeatSchema,
6583
- tasks: z.array(taskSchema).min(1)
6584
- }),
6585
- z.object({
6586
- kind: z.literal("every"),
6587
- minutes: z.int().min(1).max(4294967295)
6588
- }),
6589
- z.object({
6590
- kind: z.literal("cron"),
6591
- expression: z.string().min(9)
6592
- })
6593
- ]);
6594
- /** What starts a schedule's runs. */
6595
- const triggerSchema = z.discriminatedUnion("kind", [
6596
- z.object({
6597
- kind: z.literal("time"),
6598
- timing: timingSchema
6599
- }),
6600
- z.object({
6601
- kind: z.literal("change"),
6602
- command: z.string().min(1),
6603
- everyMinutes: z.int().min(1).max(4294967295)
6604
- }),
6605
- z.object({ kind: z.literal("url") }),
6606
- z.object({
6607
- kind: z.literal("done"),
6608
- conversation: z.string().regex(/* @__PURE__ */ new RegExp("^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$", "u"))
6609
- })
6610
- ]);
6611
- /** Where a run stands. */
6612
- const runStateSchema = z.enum([
6613
- "running",
6614
- "done",
6615
- "skipped",
6616
- "failed",
6617
- "notified"
6618
- ]);
6619
- /** Why a run was skipped or failed, which the page words. */
6620
- const runNoteSchema = z.discriminatedUnion("kind", [
6621
- z.object({
6622
- kind: z.literal("offline"),
6623
- device: z.string()
6624
- }),
6625
- z.object({
6626
- kind: z.literal("limit"),
6627
- limit: z.int().min(0).max(4294967295),
6628
- calls: z.int().min(0).max(4294967295)
6629
- }),
6630
- z.object({ kind: z.literal("command_timed_out") }),
6631
- z.object({
6632
- kind: z.literal("command_failed"),
6633
- message: z.string()
6634
- }),
6635
- z.object({
6636
- kind: z.literal("turn_failed"),
6637
- message: z.string(),
6638
- code: z.string().nullable()
6639
- })
6640
- ]);
6641
- /** How a schedule last woke its conversation. */
6642
- const lastRunSchema = z.object({
6643
- at: z.iso.datetime({ precision: 3 }),
6644
- state: runStateSchema,
6645
- /** Why it was skipped or failed. */
6646
- note: runNoteSchema.nullable()
6647
- });
6648
- /**
6649
- * A schedule of a conversation as its Schedules menu lists it: what wakes
6650
- * the conversation, when it next will, and how it last did. The user pauses,
6651
- * resumes and deletes it there; the agent does the rest.
6652
- */
6653
- const conversationScheduleSchema = z.object({
6654
- id: z.string().min(1),
6655
- name: z.string(),
6656
- trigger: triggerSchema,
6657
- /** The IANA time zone its times are read in. */
6658
- timeZone: z.string(),
6659
- /**
6660
- * Whether the user or the agent paused it. A schedule of an archived
6661
- * conversation wakes nothing either, which the conversation's own
6662
- * archived state says.
6663
- */
6664
- paused: z.boolean(),
6665
- /**
6666
- * When it next wakes the conversation; null while paused, while its
6667
- * conversation is archived, with no time left, and for a URL.
6668
- */
6669
- nextAt: z.iso.datetime({ precision: 3 }).nullable(),
6670
- /** Its last run; null before it woke the conversation. */
6671
- lastRun: lastRunSchema.nullable()
6672
- });
6673
6700
  /**
6674
6701
  * A command a `shell` call left running, its call having returned while it
6675
6702
  * ran, that ended.
@@ -6799,8 +6826,6 @@ const conversationMetadataSchema = z.object({
6799
6826
  * that rises with each change of them in this run of the backend.
6800
6827
  */
6801
6828
  permissions: conversationPermissionsSchema,
6802
- /** The conversation's schedules, which wake it, newest first. */
6803
- schedules: z.array(conversationScheduleSchema),
6804
6829
  /**
6805
6830
  * The commands the calls on the conversation's current path left
6806
6831
  * running that ended, its root's and those of the subagents on that
@@ -8245,6 +8270,31 @@ const deviceAnswerSchema = z.object({ device: deviceDtoSchema });
8245
8270
  */
8246
8271
  const elevationOutcomeSchema = z.enum(["shown", "unavailable"]);
8247
8272
  z.object({ outcome: elevationOutcomeSchema });
8273
+ z.strictObject({
8274
+ script: z.string(),
8275
+ /**
8276
+ * The directory it starts in; absent for the home directory the
8277
+ * device's runner reported.
8278
+ */
8279
+ cwd: z.string().optional(),
8280
+ /** The variables it starts with, above the device's own. */
8281
+ env: z.record(z.string(), z.string()).optional(),
8282
+ /** What it reads on its standard input, which then ends. */
8283
+ stdin: z.string().optional(),
8284
+ /**
8285
+ * How long it may run before it is stopped, in milliseconds; absent for
8286
+ * as long as it runs.
8287
+ */
8288
+ timeoutMs: z.int().min(1).optional()
8289
+ });
8290
+ /**
8291
+ * `{ exitCode, output }`: the answer of `POST /devices/:id/exec`, the exit
8292
+ * status as the agent's shell reports one.
8293
+ */
8294
+ const deviceExecResultSchema = z.object({
8295
+ exitCode: z.int().min(-2147483648).max(2147483647),
8296
+ output: execOutputSchema
8297
+ });
8248
8298
  const deviceNumberSchema = z.int().min(0);
8249
8299
  /** A cleanup that removed something from a device. */
8250
8300
  const storageCleanupSchema = z.object({
@@ -8689,6 +8739,8 @@ const rootedPathSchema = z.string();
8689
8739
  z.strictObject({ path: rootedPathSchema });
8690
8740
  z.object({ url: z.string() });
8691
8741
  z.object({ user: userDtoSchema });
8742
+ /** What a run's message does while its conversation is busy. */
8743
+ const ifBusySchema = z.enum(["queue", "steer"]);
8692
8744
  /**
8693
8745
  * A change of how an entry makes images: `enabled`, its Image Generation
8694
8746
  * switch, for an entry that makes images.
@@ -8906,6 +8958,12 @@ z.strictObject({
8906
8958
  instructions: z.string().nullable(),
8907
8959
  canSpawn: z.boolean()
8908
8960
  });
8961
+ z.strictObject({
8962
+ /**
8963
+ * The repeat's task it runs, which may be left out when the repeat has
8964
+ * one; none for a single trigger.
8965
+ */
8966
+ task: z.string().optional() });
8909
8967
  const shareKeyUseSchema = z.object({
8910
8968
  server: z.string(),
8911
8969
  at: z.iso.datetime({ precision: 3 })
@@ -9788,6 +9846,14 @@ const restartStepSchema = z.object({
9788
9846
  });
9789
9847
  z.object({ value: z.string() });
9790
9848
  z.object({ removed: z.array(z.string().min(1)) });
9849
+ /** What fired a run. */
9850
+ const runCauseSchema = z.enum([
9851
+ "time",
9852
+ "change",
9853
+ "url",
9854
+ "done",
9855
+ "now"
9856
+ ]);
9791
9857
  z.strictObject({ version: z.string().min(1).max(64) });
9792
9858
  z.object({
9793
9859
  message: savedMessageSchema,
@@ -9818,7 +9884,81 @@ z.strictObject({
9818
9884
  text: z.string(),
9819
9885
  files: z.array(clientContentSchema)
9820
9886
  });
9821
- z.strictObject({ paused: z.boolean() });
9887
+ /** One run of a schedule. */
9888
+ const scheduleRunDtoSchema = z.object({
9889
+ id: z.string().min(1),
9890
+ cause: runCauseSchema,
9891
+ /** When its trigger fired. */
9892
+ at: z.iso.datetime({ precision: 3 }),
9893
+ /** The repeat's task that started it; null for a single trigger. */
9894
+ taskId: z.string().nullable(),
9895
+ state: runStateSchema,
9896
+ /** Why it was skipped or failed. */
9897
+ note: runNoteSchema.nullable(),
9898
+ /** The start of its agent's last answer. */
9899
+ line: z.string().nullable(),
9900
+ /**
9901
+ * The turn its message started, whose id is the message's; null for a
9902
+ * run that started none, as one skipped while its device was offline.
9903
+ */
9904
+ turn: z.string().min(1).nullable()
9905
+ });
9906
+ /** A schedule as `jush schedule` shows it, with its latest runs. */
9907
+ const scheduleDtoSchema = z.object({
9908
+ id: z.string().min(1),
9909
+ name: z.string(),
9910
+ trigger: triggerSchema,
9911
+ /** The IANA time zone its timing and its daily limit count in. */
9912
+ timeZone: z.string(),
9913
+ /** A change watch's or a URL's limit on runs a day; null for none. */
9914
+ maxRunsPerDay: z.int().min(0).max(4294967295).nullable(),
9915
+ ifBusy: ifBusySchema,
9916
+ /** What a single trigger's runs send; a repeat's tasks hold their own. */
9917
+ prompt: z.string(),
9918
+ paused: z.boolean(),
9919
+ /**
9920
+ * When it next fires by itself; null while paused or with no time
9921
+ * left, and for a URL.
9922
+ */
9923
+ nextAt: z.iso.datetime({ precision: 3 }).nullable(),
9924
+ createdAt: z.iso.datetime({ precision: 3 }),
9925
+ /**
9926
+ * The agent's turn whose `jush schedule create` made it; null for one a
9927
+ * program made.
9928
+ */
9929
+ createdIn: agentTurnSchema.nullable(),
9930
+ /**
9931
+ * The agent's turn whose `jush schedule edit` last changed what it
9932
+ * does, anything but whether it is on; null when no agent changed it
9933
+ * since it was made, or a program changed it last.
9934
+ */
9935
+ editedIn: agentTurnSchema.nullable(),
9936
+ /** Its latest runs, newest first, [`RUNS_SHOWN`] at most. */
9937
+ runs: z.array(scheduleRunDtoSchema)
9938
+ });
9939
+ /**
9940
+ * A schedule a program made or changed, with a URL trigger's secret when
9941
+ * the change made one: the only time the secret is shown.
9942
+ */
9943
+ const scheduleAnswerSchema = z.object({
9944
+ schedule: scheduleDtoSchema,
9945
+ secret: z.string().nullable()
9946
+ });
9947
+ z.strictObject({
9948
+ name: z.string().trim().optional(),
9949
+ trigger: triggerSchema.optional(),
9950
+ timeZone: z.string().optional(),
9951
+ /** Null removes the limit. */
9952
+ maxRunsPerDay: z.int().min(0).max(4294967295).nullable().optional(),
9953
+ ifBusy: ifBusySchema.optional(),
9954
+ prompt: z.string().optional(),
9955
+ paused: z.boolean().optional()
9956
+ });
9957
+ /**
9958
+ * `GET /conversations/:id/schedules/:schedule/runs`: a page of its runs,
9959
+ * newest first, [`RUNS_SHOWN`] at most.
9960
+ */
9961
+ const scheduleRunsSchema = z.object({ runs: z.array(scheduleRunDtoSchema) });
9822
9962
  z.discriminatedUnion("type", [z.object({
9823
9963
  type: z.literal("file"),
9824
9964
  /** Relative to the directory searched, with `/` between its parts. */
@@ -13309,9 +13449,23 @@ var Conversation = class {
13309
13449
  reopening = false;
13310
13450
  /** Whether the lane dropped again while it was being opened again. */
13311
13451
  droppedAgain = false;
13452
+ schedules;
13312
13453
  constructor(id, routes) {
13313
13454
  this.id = id;
13314
13455
  this.routes = routes;
13456
+ const path = `/conversations/${encodeURIComponent(id)}/schedules`;
13457
+ const one = (schedule) => `${path}/${encodeURIComponent(schedule)}`;
13458
+ this.schedules = {
13459
+ create: (patch) => routes.json("POST", path, scheduleAnswerSchema, patch),
13460
+ get: (schedule) => routes.json("GET", one(schedule), scheduleDtoSchema),
13461
+ update: (schedule, patch) => routes.json("PATCH", one(schedule), scheduleAnswerSchema, patch),
13462
+ remove: (schedule) => routes.send("DELETE", one(schedule)),
13463
+ run: (schedule, task) => routes.json("POST", `${one(schedule)}/runs`, scheduleRunDtoSchema, task === void 0 ? {} : { task }),
13464
+ runs: async (schedule, before) => {
13465
+ const query = before === void 0 ? "" : `?before=${encodeURIComponent(before)}`;
13466
+ return (await routes.json("GET", `${one(schedule)}/runs${query}`, scheduleRunsSchema)).runs;
13467
+ }
13468
+ };
13315
13469
  }
13316
13470
  /** Opens the conversation's lane, once; each action opens it first. */
13317
13471
  open() {
@@ -14721,6 +14875,30 @@ var Device = class {
14721
14875
  return child;
14722
14876
  }
14723
14877
  /**
14878
+ * Runs `script` on the device, outside any conversation, as the agent's
14879
+ * shell runs a command, and resolves once it exited, whatever its status.
14880
+ * Rejects with a `JushError` when it has no status: `device_offline`, when
14881
+ * it never ran; `command_timed_out`, when it ran past `timeout` and was
14882
+ * stopped (`SIGTERM`, then `SIGKILL` 5 seconds later), with what it printed
14883
+ * in `body.output`; `device_lost`, when the device lost it or its input was
14884
+ * cut; `backend_closing`, when the core closed while it ran, whose device
14885
+ * stops it when it connects again.
14886
+ */
14887
+ async exec(script, options = {}) {
14888
+ const { timeout, signal, ...where } = options;
14889
+ const limited = timeout !== void 0 && timeout !== 0 && Number.isFinite(timeout);
14890
+ const body = {
14891
+ script,
14892
+ ...where,
14893
+ ...limited ? { timeoutMs: Math.ceil(timeout) } : {}
14894
+ };
14895
+ const ran = await this.routes.json("POST", `/devices/${encodeURIComponent(this.id)}/exec`, deviceExecResultSchema, body, signal);
14896
+ return {
14897
+ exitCode: ran.exitCode,
14898
+ ...ran.output
14899
+ };
14900
+ }
14901
+ /**
14724
14902
  * Revokes the device, as the app's Revoke does: its token opens nothing
14725
14903
  * from then on, the commands running on it are lost, and the commands of
14726
14904
  * a conversation whose target it is fail until `update({ target })` names