@jush-agent/sdk 0.2.6250 → 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/README.md +87 -0
- package/dist/index.d.mts +759 -140
- package/dist/index.mjs +380 -203
- package/package.json +7 -7
- package/release/commands/jush-browser/descriptor.json +13 -13
- package/release/commands/jush-claude-code/descriptor.json +13 -13
- package/release/commands/jush-fetch/descriptor.json +13 -13
- package/release/commands/jush-file/descriptor.json +10 -10
- package/release/commands/jush-mobile/descriptor.json +13 -13
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",
|
|
@@ -2788,7 +2790,6 @@ const errorCodeSchema = z.enum([
|
|
|
2788
2790
|
"forbidden_origin",
|
|
2789
2791
|
"unknown_stream",
|
|
2790
2792
|
"upgrade_required",
|
|
2791
|
-
"too_many_lanes",
|
|
2792
2793
|
"stream_failed",
|
|
2793
2794
|
"id_unavailable",
|
|
2794
2795
|
"invalid_revision",
|
|
@@ -2898,6 +2899,16 @@ const projectDtoSchema = z.object({
|
|
|
2898
2899
|
*/
|
|
2899
2900
|
savedCount: z.int().min(0)
|
|
2900
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
|
+
});
|
|
2901
2912
|
/**
|
|
2902
2913
|
* A JSON error answer: `{ code, message, params?, requestId }`, and a
|
|
2903
2914
|
* plugin's own `reason` when a plugin refused the call. The page words the
|
|
@@ -2938,6 +2949,11 @@ const errorBodySchema = z.object({
|
|
|
2938
2949
|
* directory, which the page opens rather than a second one.
|
|
2939
2950
|
*/
|
|
2940
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(),
|
|
2941
2957
|
/** The request the answer is of, as its `X-Request-Id` names it. */
|
|
2942
2958
|
requestId: z.string().min(1)
|
|
2943
2959
|
});
|
|
@@ -5272,6 +5288,15 @@ const accountsSchema = z.object({
|
|
|
5272
5288
|
z.strictObject({ credentialId: z.string().min(1) });
|
|
5273
5289
|
/** `{ active }`: the account the entry now infers with. */
|
|
5274
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
|
+
});
|
|
5275
5300
|
/** Whether the page follows the system's light or dark scheme or fixes one. */
|
|
5276
5301
|
const themeSchema = z.enum([
|
|
5277
5302
|
"system",
|
|
@@ -5511,6 +5536,201 @@ const conversationStatusSchema = z.enum([
|
|
|
5511
5536
|
* is green for an answer and red for an error.
|
|
5512
5537
|
*/
|
|
5513
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
|
+
});
|
|
5514
5734
|
/**
|
|
5515
5735
|
* A conversation as the list carries it: what the sidebar shows of it, and
|
|
5516
5736
|
* its work's tabs, which the page draws before it opens the
|
|
@@ -5568,10 +5788,11 @@ const conversationSummarySchema = z.object({
|
|
|
5568
5788
|
*/
|
|
5569
5789
|
unreadPermissionRequests: z.int().min(0),
|
|
5570
5790
|
/**
|
|
5571
|
-
*
|
|
5572
|
-
* an alarm clock
|
|
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.
|
|
5573
5794
|
*/
|
|
5574
|
-
|
|
5795
|
+
schedules: z.array(conversationScheduleSchema),
|
|
5575
5796
|
/**
|
|
5576
5797
|
* The conversation's work: its tabs under the revision that counts
|
|
5577
5798
|
* its changes. The page draws the work's frame and tabs from it as soon
|
|
@@ -6476,201 +6697,6 @@ const conversationPermissionsSchema = z.object({
|
|
|
6476
6697
|
revision: z.int().min(0),
|
|
6477
6698
|
requests: z.array(permissionRequestSchema)
|
|
6478
6699
|
});
|
|
6479
|
-
/** The unit a repeat's cycle counts in. */
|
|
6480
|
-
const repeatUnitSchema = z.enum([
|
|
6481
|
-
"days",
|
|
6482
|
-
"weeks",
|
|
6483
|
-
"months",
|
|
6484
|
-
"years"
|
|
6485
|
-
]);
|
|
6486
|
-
/**
|
|
6487
|
-
* A repeating cycle, as Calendar's repeat: every `every` days, weeks,
|
|
6488
|
-
* months or years. A cycle of several units counts from the day, week,
|
|
6489
|
-
* month or year of `start`, its first cycle, and runs its tasks in each
|
|
6490
|
-
* cycle's first unit.
|
|
6491
|
-
*/
|
|
6492
|
-
const repeatSchema = z.object({
|
|
6493
|
-
every: z.int().min(1).max(4294967295),
|
|
6494
|
-
unit: repeatUnitSchema,
|
|
6495
|
-
/**
|
|
6496
|
-
* The first cycle's day, as `2026-01-01`, for a cycle of several
|
|
6497
|
-
* units; null for one unit.
|
|
6498
|
-
*/
|
|
6499
|
-
start: z.string().nullable()
|
|
6500
|
-
});
|
|
6501
|
-
/** A day of the week, as a weekly task names the days it runs on. */
|
|
6502
|
-
const weekdaySchema = z.enum([
|
|
6503
|
-
"mon",
|
|
6504
|
-
"tue",
|
|
6505
|
-
"wed",
|
|
6506
|
-
"thu",
|
|
6507
|
-
"fri",
|
|
6508
|
-
"sat",
|
|
6509
|
-
"sun"
|
|
6510
|
-
]);
|
|
6511
|
-
/** Which of a month's weekdays. */
|
|
6512
|
-
const weekOfMonthSchema = z.enum([
|
|
6513
|
-
"first",
|
|
6514
|
-
"second",
|
|
6515
|
-
"third",
|
|
6516
|
-
"fourth",
|
|
6517
|
-
"last"
|
|
6518
|
-
]);
|
|
6519
|
-
/** The first or the last. */
|
|
6520
|
-
const firstOrLastSchema = z.enum(["first", "last"]);
|
|
6521
|
-
/**
|
|
6522
|
-
* A day of a month: a date, which a month without it skips; the last day;
|
|
6523
|
-
* a weekday's first to fourth or last; or the first or last working day.
|
|
6524
|
-
*/
|
|
6525
|
-
const monthDaySchema = z.discriminatedUnion("kind", [
|
|
6526
|
-
z.object({
|
|
6527
|
-
kind: z.literal("date"),
|
|
6528
|
-
date: z.int().min(1).max(31)
|
|
6529
|
-
}),
|
|
6530
|
-
z.object({ kind: z.literal("last_day") }),
|
|
6531
|
-
z.object({
|
|
6532
|
-
kind: z.literal("weekday"),
|
|
6533
|
-
week: weekOfMonthSchema,
|
|
6534
|
-
weekday: weekdaySchema
|
|
6535
|
-
}),
|
|
6536
|
-
z.object({
|
|
6537
|
-
kind: z.literal("working_day"),
|
|
6538
|
-
which: firstOrLastSchema
|
|
6539
|
-
})
|
|
6540
|
-
]);
|
|
6541
|
-
/**
|
|
6542
|
-
* A country by its ISO 3166 code, and one of its regions whose holidays
|
|
6543
|
-
* differ, by the code the holidays' table gives it.
|
|
6544
|
-
*/
|
|
6545
|
-
const holidayPlaceSchema = z.object({
|
|
6546
|
-
country: z.string().min(2).max(3),
|
|
6547
|
-
region: z.string().nullable()
|
|
6548
|
-
});
|
|
6549
|
-
/**
|
|
6550
|
-
* A task of a repeat: a moment in its cycle and the message it sends.
|
|
6551
|
-
*
|
|
6552
|
-
* Its moment is `time` and, as the repeat's unit asks, `days` (weeks),
|
|
6553
|
-
* `day` (months), or `month` and `day` (years); the parts another unit
|
|
6554
|
-
* reads are kept, so a repeat changed back finds them as they were.
|
|
6555
|
-
*/
|
|
6556
|
-
const taskSchema = z.object({
|
|
6557
|
-
/** Unique among the repeat's tasks; the page or the command makes it. */
|
|
6558
|
-
id: z.string().min(1),
|
|
6559
|
-
/** A clock time as `09:00`. */
|
|
6560
|
-
time: z.string().regex(/* @__PURE__ */ new RegExp("^([01][0-9]|2[0-3]):[0-5][0-9]$", "u")),
|
|
6561
|
-
/** One to seven distinct days. */
|
|
6562
|
-
days: z.array(weekdaySchema).min(1).max(7),
|
|
6563
|
-
day: monthDaySchema,
|
|
6564
|
-
/** 1 to 12. */
|
|
6565
|
-
month: z.int().min(1).max(12),
|
|
6566
|
-
/**
|
|
6567
|
-
* The country, and its region, whose working week and public
|
|
6568
|
-
* holidays a first or last working day follows; null for Monday to
|
|
6569
|
-
* Friday.
|
|
6570
|
-
*/
|
|
6571
|
-
holidays: holidayPlaceSchema.nullable(),
|
|
6572
|
-
/** Empty until written; a task without a message does not run. */
|
|
6573
|
-
prompt: z.string()
|
|
6574
|
-
});
|
|
6575
|
-
/** When a time trigger fires, in the schedule's time zone. */
|
|
6576
|
-
const timingSchema = z.discriminatedUnion("kind", [
|
|
6577
|
-
z.object({
|
|
6578
|
-
kind: z.literal("once"),
|
|
6579
|
-
at: z.iso.datetime({ precision: 3 })
|
|
6580
|
-
}),
|
|
6581
|
-
z.object({
|
|
6582
|
-
kind: z.literal("repeat"),
|
|
6583
|
-
repeat: repeatSchema,
|
|
6584
|
-
tasks: z.array(taskSchema).min(1)
|
|
6585
|
-
}),
|
|
6586
|
-
z.object({
|
|
6587
|
-
kind: z.literal("every"),
|
|
6588
|
-
minutes: z.int().min(1).max(4294967295)
|
|
6589
|
-
}),
|
|
6590
|
-
z.object({
|
|
6591
|
-
kind: z.literal("cron"),
|
|
6592
|
-
expression: z.string().min(9)
|
|
6593
|
-
})
|
|
6594
|
-
]);
|
|
6595
|
-
/** What starts a schedule's runs. */
|
|
6596
|
-
const triggerSchema = z.discriminatedUnion("kind", [
|
|
6597
|
-
z.object({
|
|
6598
|
-
kind: z.literal("time"),
|
|
6599
|
-
timing: timingSchema
|
|
6600
|
-
}),
|
|
6601
|
-
z.object({
|
|
6602
|
-
kind: z.literal("change"),
|
|
6603
|
-
command: z.string().min(1),
|
|
6604
|
-
everyMinutes: z.int().min(1).max(4294967295)
|
|
6605
|
-
}),
|
|
6606
|
-
z.object({ kind: z.literal("url") }),
|
|
6607
|
-
z.object({
|
|
6608
|
-
kind: z.literal("done"),
|
|
6609
|
-
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"))
|
|
6610
|
-
})
|
|
6611
|
-
]);
|
|
6612
|
-
/** Where a run stands. */
|
|
6613
|
-
const runStateSchema = z.enum([
|
|
6614
|
-
"running",
|
|
6615
|
-
"done",
|
|
6616
|
-
"skipped",
|
|
6617
|
-
"failed",
|
|
6618
|
-
"notified"
|
|
6619
|
-
]);
|
|
6620
|
-
/** Why a run was skipped or failed, which the page words. */
|
|
6621
|
-
const runNoteSchema = z.discriminatedUnion("kind", [
|
|
6622
|
-
z.object({
|
|
6623
|
-
kind: z.literal("offline"),
|
|
6624
|
-
device: z.string()
|
|
6625
|
-
}),
|
|
6626
|
-
z.object({
|
|
6627
|
-
kind: z.literal("limit"),
|
|
6628
|
-
limit: z.int().min(0).max(4294967295),
|
|
6629
|
-
calls: z.int().min(0).max(4294967295)
|
|
6630
|
-
}),
|
|
6631
|
-
z.object({ kind: z.literal("command_timed_out") }),
|
|
6632
|
-
z.object({
|
|
6633
|
-
kind: z.literal("command_failed"),
|
|
6634
|
-
message: z.string()
|
|
6635
|
-
}),
|
|
6636
|
-
z.object({
|
|
6637
|
-
kind: z.literal("turn_failed"),
|
|
6638
|
-
message: z.string(),
|
|
6639
|
-
code: z.string().nullable()
|
|
6640
|
-
})
|
|
6641
|
-
]);
|
|
6642
|
-
/** How a schedule last woke its conversation. */
|
|
6643
|
-
const lastRunSchema = z.object({
|
|
6644
|
-
at: z.iso.datetime({ precision: 3 }),
|
|
6645
|
-
state: runStateSchema,
|
|
6646
|
-
/** Why it was skipped or failed. */
|
|
6647
|
-
note: runNoteSchema.nullable()
|
|
6648
|
-
});
|
|
6649
|
-
/**
|
|
6650
|
-
* A schedule of a conversation as its Schedules menu lists it: what wakes
|
|
6651
|
-
* the conversation, when it next will, and how it last did. The user pauses,
|
|
6652
|
-
* resumes and deletes it there; the agent does the rest.
|
|
6653
|
-
*/
|
|
6654
|
-
const conversationScheduleSchema = z.object({
|
|
6655
|
-
id: z.string().min(1),
|
|
6656
|
-
name: z.string(),
|
|
6657
|
-
trigger: triggerSchema,
|
|
6658
|
-
/** The IANA time zone its times are read in. */
|
|
6659
|
-
timeZone: z.string(),
|
|
6660
|
-
/**
|
|
6661
|
-
* Whether the user or the agent paused it. A schedule of an archived
|
|
6662
|
-
* conversation wakes nothing either, which the conversation's own
|
|
6663
|
-
* archived state says.
|
|
6664
|
-
*/
|
|
6665
|
-
paused: z.boolean(),
|
|
6666
|
-
/**
|
|
6667
|
-
* When it next wakes the conversation; null while paused, while its
|
|
6668
|
-
* conversation is archived, with no time left, and for a URL.
|
|
6669
|
-
*/
|
|
6670
|
-
nextAt: z.iso.datetime({ precision: 3 }).nullable(),
|
|
6671
|
-
/** Its last run; null before it woke the conversation. */
|
|
6672
|
-
lastRun: lastRunSchema.nullable()
|
|
6673
|
-
});
|
|
6674
6700
|
/**
|
|
6675
6701
|
* A command a `shell` call left running, its call having returned while it
|
|
6676
6702
|
* ran, that ended.
|
|
@@ -6800,8 +6826,6 @@ const conversationMetadataSchema = z.object({
|
|
|
6800
6826
|
* that rises with each change of them in this run of the backend.
|
|
6801
6827
|
*/
|
|
6802
6828
|
permissions: conversationPermissionsSchema,
|
|
6803
|
-
/** The conversation's schedules, which wake it, newest first. */
|
|
6804
|
-
schedules: z.array(conversationScheduleSchema),
|
|
6805
6829
|
/**
|
|
6806
6830
|
* The commands the calls on the conversation's current path left
|
|
6807
6831
|
* running that ended, its root's and those of the subagents on that
|
|
@@ -8246,6 +8270,31 @@ const deviceAnswerSchema = z.object({ device: deviceDtoSchema });
|
|
|
8246
8270
|
*/
|
|
8247
8271
|
const elevationOutcomeSchema = z.enum(["shown", "unavailable"]);
|
|
8248
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
|
+
});
|
|
8249
8298
|
const deviceNumberSchema = z.int().min(0);
|
|
8250
8299
|
/** A cleanup that removed something from a device. */
|
|
8251
8300
|
const storageCleanupSchema = z.object({
|
|
@@ -8690,6 +8739,8 @@ const rootedPathSchema = z.string();
|
|
|
8690
8739
|
z.strictObject({ path: rootedPathSchema });
|
|
8691
8740
|
z.object({ url: z.string() });
|
|
8692
8741
|
z.object({ user: userDtoSchema });
|
|
8742
|
+
/** What a run's message does while its conversation is busy. */
|
|
8743
|
+
const ifBusySchema = z.enum(["queue", "steer"]);
|
|
8693
8744
|
/**
|
|
8694
8745
|
* A change of how an entry makes images: `enabled`, its Image Generation
|
|
8695
8746
|
* switch, for an entry that makes images.
|
|
@@ -8907,6 +8958,12 @@ z.strictObject({
|
|
|
8907
8958
|
instructions: z.string().nullable(),
|
|
8908
8959
|
canSpawn: z.boolean()
|
|
8909
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() });
|
|
8910
8967
|
const shareKeyUseSchema = z.object({
|
|
8911
8968
|
server: z.string(),
|
|
8912
8969
|
at: z.iso.datetime({ precision: 3 })
|
|
@@ -9789,6 +9846,14 @@ const restartStepSchema = z.object({
|
|
|
9789
9846
|
});
|
|
9790
9847
|
z.object({ value: z.string() });
|
|
9791
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
|
+
]);
|
|
9792
9857
|
z.strictObject({ version: z.string().min(1).max(64) });
|
|
9793
9858
|
z.object({
|
|
9794
9859
|
message: savedMessageSchema,
|
|
@@ -9819,7 +9884,81 @@ z.strictObject({
|
|
|
9819
9884
|
text: z.string(),
|
|
9820
9885
|
files: z.array(clientContentSchema)
|
|
9821
9886
|
});
|
|
9822
|
-
|
|
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) });
|
|
9823
9962
|
z.discriminatedUnion("type", [z.object({
|
|
9824
9963
|
type: z.literal("file"),
|
|
9825
9964
|
/** Relative to the directory searched, with `/` between its parts. */
|
|
@@ -13310,9 +13449,23 @@ var Conversation = class {
|
|
|
13310
13449
|
reopening = false;
|
|
13311
13450
|
/** Whether the lane dropped again while it was being opened again. */
|
|
13312
13451
|
droppedAgain = false;
|
|
13452
|
+
schedules;
|
|
13313
13453
|
constructor(id, routes) {
|
|
13314
13454
|
this.id = id;
|
|
13315
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
|
+
};
|
|
13316
13469
|
}
|
|
13317
13470
|
/** Opens the conversation's lane, once; each action opens it first. */
|
|
13318
13471
|
open() {
|
|
@@ -14722,6 +14875,30 @@ var Device = class {
|
|
|
14722
14875
|
return child;
|
|
14723
14876
|
}
|
|
14724
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
|
+
/**
|
|
14725
14902
|
* Revokes the device, as the app's Revoke does: its token opens nothing
|
|
14726
14903
|
* from then on, the commands running on it are lost, and the commands of
|
|
14727
14904
|
* a conversation whose target it is fail until `update({ target })` names
|