@jush-agent/sdk 0.2.6247 → 0.2.6252
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 +21 -8
- package/dist/index.d.mts +53 -25
- package/dist/index.mjs +281 -123
- 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 +12 -12
- package/release/commands/jush-file/descriptor.json +11 -11
- package/release/commands/jush-mobile/descriptor.json +13 -13
package/README.md
CHANGED
|
@@ -52,6 +52,10 @@ await jush.close()
|
|
|
52
52
|
|
|
53
53
|
`turn.outcome` is `finished`, `failed` or `stopped`; `turn.text` is the text
|
|
54
54
|
the agent wrote after your message, and `turn.blocks` everything it did.
|
|
55
|
+
Blocks read back as a page, as after a dropped connection, come in the light
|
|
56
|
+
form the app's list holds: a tool call without its output's text, and with
|
|
57
|
+
only the description of a long input, and thinking without its text. The
|
|
58
|
+
answer's text is whole.
|
|
55
59
|
|
|
56
60
|
## Cores
|
|
57
61
|
|
|
@@ -288,9 +292,11 @@ await desk.update({ plugins: ['tickets-next'] })
|
|
|
288
292
|
```
|
|
289
293
|
|
|
290
294
|
`conversation.run(input)` sends a message and resolves once the turn it
|
|
291
|
-
starts ended
|
|
292
|
-
|
|
293
|
-
|
|
295
|
+
starts ended, with that turn's blocks and outcome, also when your program's
|
|
296
|
+
connection to the process dropped while the turn ended. It fails when the
|
|
297
|
+
message leaves the queue without running, as an abort that clears the queue
|
|
298
|
+
or gives the message back makes it, or when the conversation closes first.
|
|
299
|
+
The other actions are the ones the app has:
|
|
294
300
|
|
|
295
301
|
| Method | What it does |
|
|
296
302
|
| --- | --- |
|
|
@@ -340,14 +346,21 @@ The loop ends when you leave it or the conversation closes.
|
|
|
340
346
|
`conversation.close()` stops following the conversation; its agents go on in
|
|
341
347
|
the core, and the next action follows it again.
|
|
342
348
|
|
|
349
|
+
`conversation.agents` lists the conversation's agents: the root, whose id is
|
|
350
|
+
the conversation's, and each subagent, with its role, phase and queue. The
|
|
351
|
+
`agents` and `agent` events say they changed.
|
|
352
|
+
|
|
343
353
|
`conversation.sendToAgent(node, text)` sends a message to one subagent, named
|
|
344
|
-
by its id in
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
354
|
+
by its id in `conversation.agents`. A subagent at work takes it as a steer, an
|
|
355
|
+
idle one starts a turn with it, and one that ended is resumed with it. Give
|
|
356
|
+
the message an id when you may send it again, such as after a lost answer:
|
|
357
|
+
the subagent takes a message once, however often it arrives.
|
|
348
358
|
|
|
349
359
|
```ts
|
|
350
|
-
|
|
360
|
+
const tester = conversation.agents.find((agent) => agent.role.kind === 'subagent' && agent.role.profile === 'tester')
|
|
361
|
+
if (tester) {
|
|
362
|
+
await conversation.sendToAgent(tester.id, 'The build finished.', 'reminder-7')
|
|
363
|
+
}
|
|
351
364
|
```
|
|
352
365
|
|
|
353
366
|
## Permission requests
|
package/dist/index.d.mts
CHANGED
|
@@ -3826,6 +3826,7 @@ declare const errorBodySchema: z.ZodObject<{
|
|
|
3826
3826
|
not_a_paired_device: "not_a_paired_device";
|
|
3827
3827
|
conversation_not_found: "conversation_not_found";
|
|
3828
3828
|
block_not_found: "block_not_found";
|
|
3829
|
+
turn_not_found: "turn_not_found";
|
|
3829
3830
|
transcript_changed: "transcript_changed";
|
|
3830
3831
|
conversation_unreadable: "conversation_unreadable";
|
|
3831
3832
|
conversation_archived: "conversation_archived";
|
|
@@ -3873,7 +3874,6 @@ declare const errorBodySchema: z.ZodObject<{
|
|
|
3873
3874
|
forbidden_origin: "forbidden_origin";
|
|
3874
3875
|
unknown_stream: "unknown_stream";
|
|
3875
3876
|
upgrade_required: "upgrade_required";
|
|
3876
|
-
too_many_lanes: "too_many_lanes";
|
|
3877
3877
|
stream_failed: "stream_failed";
|
|
3878
3878
|
id_unavailable: "id_unavailable";
|
|
3879
3879
|
invalid_revision: "invalid_revision";
|
|
@@ -4812,6 +4812,7 @@ declare const portAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
4812
4812
|
not_a_paired_device: "not_a_paired_device";
|
|
4813
4813
|
conversation_not_found: "conversation_not_found";
|
|
4814
4814
|
block_not_found: "block_not_found";
|
|
4815
|
+
turn_not_found: "turn_not_found";
|
|
4815
4816
|
transcript_changed: "transcript_changed";
|
|
4816
4817
|
conversation_unreadable: "conversation_unreadable";
|
|
4817
4818
|
conversation_archived: "conversation_archived";
|
|
@@ -4859,7 +4860,6 @@ declare const portAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
4859
4860
|
forbidden_origin: "forbidden_origin";
|
|
4860
4861
|
unknown_stream: "unknown_stream";
|
|
4861
4862
|
upgrade_required: "upgrade_required";
|
|
4862
|
-
too_many_lanes: "too_many_lanes";
|
|
4863
4863
|
stream_failed: "stream_failed";
|
|
4864
4864
|
id_unavailable: "id_unavailable";
|
|
4865
4865
|
invalid_revision: "invalid_revision";
|
|
@@ -4975,6 +4975,7 @@ declare const portAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
4975
4975
|
not_a_paired_device: "not_a_paired_device";
|
|
4976
4976
|
conversation_not_found: "conversation_not_found";
|
|
4977
4977
|
block_not_found: "block_not_found";
|
|
4978
|
+
turn_not_found: "turn_not_found";
|
|
4978
4979
|
transcript_changed: "transcript_changed";
|
|
4979
4980
|
conversation_unreadable: "conversation_unreadable";
|
|
4980
4981
|
conversation_archived: "conversation_archived";
|
|
@@ -5022,7 +5023,6 @@ declare const portAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
5022
5023
|
forbidden_origin: "forbidden_origin";
|
|
5023
5024
|
unknown_stream: "unknown_stream";
|
|
5024
5025
|
upgrade_required: "upgrade_required";
|
|
5025
|
-
too_many_lanes: "too_many_lanes";
|
|
5026
5026
|
stream_failed: "stream_failed";
|
|
5027
5027
|
id_unavailable: "id_unavailable";
|
|
5028
5028
|
invalid_revision: "invalid_revision";
|
|
@@ -5303,6 +5303,7 @@ declare const laneRefusalSchema: z.ZodObject<{
|
|
|
5303
5303
|
not_a_paired_device: "not_a_paired_device";
|
|
5304
5304
|
conversation_not_found: "conversation_not_found";
|
|
5305
5305
|
block_not_found: "block_not_found";
|
|
5306
|
+
turn_not_found: "turn_not_found";
|
|
5306
5307
|
transcript_changed: "transcript_changed";
|
|
5307
5308
|
conversation_unreadable: "conversation_unreadable";
|
|
5308
5309
|
conversation_archived: "conversation_archived";
|
|
@@ -5350,7 +5351,6 @@ declare const laneRefusalSchema: z.ZodObject<{
|
|
|
5350
5351
|
forbidden_origin: "forbidden_origin";
|
|
5351
5352
|
unknown_stream: "unknown_stream";
|
|
5352
5353
|
upgrade_required: "upgrade_required";
|
|
5353
|
-
too_many_lanes: "too_many_lanes";
|
|
5354
5354
|
stream_failed: "stream_failed";
|
|
5355
5355
|
id_unavailable: "id_unavailable";
|
|
5356
5356
|
invalid_revision: "invalid_revision";
|
|
@@ -15637,6 +15637,7 @@ declare const conversationUpdateSchema: z.ZodObject<{
|
|
|
15637
15637
|
cwd: z.ZodString;
|
|
15638
15638
|
lastTurn: z.ZodNullable<z.ZodObject<{
|
|
15639
15639
|
id: z.ZodString;
|
|
15640
|
+
turnId: z.ZodString;
|
|
15640
15641
|
outcome: z.ZodEnum<{
|
|
15641
15642
|
stopped: "stopped";
|
|
15642
15643
|
failed: "failed";
|
|
@@ -15970,6 +15971,7 @@ declare const conversationUpdateSchema: z.ZodObject<{
|
|
|
15970
15971
|
not_a_paired_device: "not_a_paired_device";
|
|
15971
15972
|
conversation_not_found: "conversation_not_found";
|
|
15972
15973
|
block_not_found: "block_not_found";
|
|
15974
|
+
turn_not_found: "turn_not_found";
|
|
15973
15975
|
transcript_changed: "transcript_changed";
|
|
15974
15976
|
conversation_unreadable: "conversation_unreadable";
|
|
15975
15977
|
conversation_archived: "conversation_archived";
|
|
@@ -16017,7 +16019,6 @@ declare const conversationUpdateSchema: z.ZodObject<{
|
|
|
16017
16019
|
forbidden_origin: "forbidden_origin";
|
|
16018
16020
|
unknown_stream: "unknown_stream";
|
|
16019
16021
|
upgrade_required: "upgrade_required";
|
|
16020
|
-
too_many_lanes: "too_many_lanes";
|
|
16021
16022
|
stream_failed: "stream_failed";
|
|
16022
16023
|
id_unavailable: "id_unavailable";
|
|
16023
16024
|
invalid_revision: "invalid_revision";
|
|
@@ -18158,10 +18159,10 @@ declare class ConversationClient {
|
|
|
18158
18159
|
transcriptVersion(node?: string | null): Version | null;
|
|
18159
18160
|
/** The version of the agents the client holds; null before the open answered. */
|
|
18160
18161
|
heldAgents(): Version | null;
|
|
18162
|
+
/** The agents' entries the client holds, the root's and every subagent's and side question's, as copies. */
|
|
18163
|
+
agentEntries(): AgentEntry[];
|
|
18161
18164
|
/** The accepted steers not yet in the transcript, as copies. */
|
|
18162
18165
|
pendingSteers(): PendingSteer[];
|
|
18163
|
-
/** The message the root's running turn started with, until its turn writes it, as a copy. */
|
|
18164
|
-
startingMessage(): QueuedMessage | null;
|
|
18165
18166
|
/** The calls the root's model is writing, as copies. */
|
|
18166
18167
|
pendingCalls(): PendingCall[];
|
|
18167
18168
|
/** Sends `frame` unless the client is detached; answers whether it did. */
|
|
@@ -18183,8 +18184,14 @@ declare class ConversationClient {
|
|
|
18183
18184
|
private untilState;
|
|
18184
18185
|
/**
|
|
18185
18186
|
* Whether the client holds the agents at `at`, the version a command's
|
|
18186
|
-
* answer names: at or past its revision, or at another epoch
|
|
18187
|
-
*
|
|
18187
|
+
* answer names: at or past its revision, or at another epoch once no read
|
|
18188
|
+
* of the agents is under way; null names no tree, and nothing to wait for.
|
|
18189
|
+
*
|
|
18190
|
+
* The answer comes after its step reached the page, so a page that held
|
|
18191
|
+
* another epoch, such as the stored one it read before its open restored
|
|
18192
|
+
* the tree, which the open's follow answered as stale, has begun reading
|
|
18193
|
+
* the agents again by then: the read shows the whole state, the command's
|
|
18194
|
+
* step included.
|
|
18188
18195
|
*/
|
|
18189
18196
|
private holdsVersion;
|
|
18190
18197
|
/** The wait of a `send` whose message has not run. */
|
|
@@ -18639,9 +18646,6 @@ declare class Conversation {
|
|
|
18639
18646
|
/** The root's transcript, as the lane keeps it. */
|
|
18640
18647
|
private transcript;
|
|
18641
18648
|
private metadata;
|
|
18642
|
-
/** The ids of the messages waiting in the root's queue. */
|
|
18643
|
-
private queued;
|
|
18644
|
-
private rootPhase;
|
|
18645
18649
|
/** The permission requests told already. */
|
|
18646
18650
|
private readonly told;
|
|
18647
18651
|
private readonly listeners;
|
|
@@ -18666,6 +18670,12 @@ declare class Conversation {
|
|
|
18666
18670
|
get permissions(): Permission[];
|
|
18667
18671
|
/** The root's blocks the conversation holds, oldest first. */
|
|
18668
18672
|
get blocks(): Block[];
|
|
18673
|
+
/**
|
|
18674
|
+
* The conversation's agents as its lane holds them: the root's entry,
|
|
18675
|
+
* whose id is the conversation's, each subagent's, whose id `sendToAgent`
|
|
18676
|
+
* takes, and each side question's. Empty until the lane opens.
|
|
18677
|
+
*/
|
|
18678
|
+
get agents(): AgentEntry[];
|
|
18669
18679
|
/**
|
|
18670
18680
|
* Sends a message; resolves once it is in the transcript or the queue.
|
|
18671
18681
|
* The conversation takes it once however often it is sent under
|
|
@@ -18679,10 +18689,11 @@ declare class Conversation {
|
|
|
18679
18689
|
*/
|
|
18680
18690
|
update(patch: ConversationPatch): Promise<ConversationUpdate>;
|
|
18681
18691
|
/**
|
|
18682
|
-
* Sends `text` to the subagent `node`,
|
|
18683
|
-
* which takes it once however often it is sent
|
|
18684
|
-
* one as a steer, and an ended one is resumed
|
|
18685
|
-
* message's id, the one made for it when
|
|
18692
|
+
* Sends `text` to the subagent `node`, the id of one of `agents` whose
|
|
18693
|
+
* role is a subagent's, which takes it once however often it is sent
|
|
18694
|
+
* under `messageId`: a live one as a steer, and an ended one is resumed
|
|
18695
|
+
* with it. Resolves with the message's id, the one made for it when
|
|
18696
|
+
* `messageId` is absent.
|
|
18686
18697
|
*/
|
|
18687
18698
|
sendToAgent(node: string, text: string, messageId?: string): Promise<string>;
|
|
18688
18699
|
/**
|
|
@@ -18697,20 +18708,37 @@ declare class Conversation {
|
|
|
18697
18708
|
compact(): Promise<void>;
|
|
18698
18709
|
/**
|
|
18699
18710
|
* Sends `input`, and answers the turn it starts once the turn ended: once
|
|
18700
|
-
* the conversation's last ended turn is
|
|
18701
|
-
*
|
|
18702
|
-
*
|
|
18703
|
-
* the
|
|
18711
|
+
* the conversation's last ended turn is its own, as a turn the root
|
|
18712
|
+
* resumes ends anew. When the lane's view cannot tell, as after its
|
|
18713
|
+
* connection dropped while the turn ended, it asks the conversation where
|
|
18714
|
+
* the turn stands, again at each view that cannot tell. It reads the
|
|
18715
|
+
* transcript back to the message when the turn ended past what the lane
|
|
18716
|
+
* holds. It fails when the message left the queue without running, as an
|
|
18717
|
+
* abort's clearing of the queue removes it.
|
|
18704
18718
|
*/
|
|
18705
18719
|
run(input: Input): Promise<Turn>;
|
|
18706
18720
|
/**
|
|
18707
|
-
*
|
|
18708
|
-
*
|
|
18709
|
-
* nor
|
|
18721
|
+
* The lane's view of the conversation when it leaves the turn of the sent
|
|
18722
|
+
* message `messageId` unaccounted for: the root idle, and the message
|
|
18723
|
+
* neither queued, nor starting, nor the last ended turn's, as when the
|
|
18724
|
+
* turn ended unseen or the message left the queue. Null when the view
|
|
18725
|
+
* accounts for it, or cannot tell yet: while the lane opens again, or
|
|
18726
|
+
* before it holds both the agents and the root's transcript current, as
|
|
18727
|
+
* after a drop.
|
|
18710
18728
|
*/
|
|
18711
|
-
private
|
|
18712
|
-
/**
|
|
18729
|
+
private unaccounted;
|
|
18730
|
+
/** Where the turn `messageId` stands, as the conversation answers; null when it holds no turn of it. */
|
|
18731
|
+
private turnState;
|
|
18732
|
+
/** The turn `messageId` started, which ended at `ending`; null until one window of the transcript holds both ends. */
|
|
18713
18733
|
private turnOf;
|
|
18734
|
+
/**
|
|
18735
|
+
* The window of the root's transcript that holds the turn's end `ending`
|
|
18736
|
+
* but not the message `messageId` that started it, when the transcript
|
|
18737
|
+
* goes on before it; null otherwise.
|
|
18738
|
+
*/
|
|
18739
|
+
private shortOf;
|
|
18740
|
+
/** Reads the page of the root's transcript before `window` into what the conversation holds. */
|
|
18741
|
+
private readBefore;
|
|
18714
18742
|
/**
|
|
18715
18743
|
* Everything the conversation's lane tells from now on, until the loop
|
|
18716
18744
|
* that reads it stops or the conversation closes.
|
package/dist/index.mjs
CHANGED
|
@@ -2740,6 +2740,7 @@ const errorCodeSchema = z.enum([
|
|
|
2740
2740
|
"not_a_paired_device",
|
|
2741
2741
|
"conversation_not_found",
|
|
2742
2742
|
"block_not_found",
|
|
2743
|
+
"turn_not_found",
|
|
2743
2744
|
"transcript_changed",
|
|
2744
2745
|
"conversation_unreadable",
|
|
2745
2746
|
"conversation_archived",
|
|
@@ -2787,7 +2788,6 @@ const errorCodeSchema = z.enum([
|
|
|
2787
2788
|
"forbidden_origin",
|
|
2788
2789
|
"unknown_stream",
|
|
2789
2790
|
"upgrade_required",
|
|
2790
|
-
"too_many_lanes",
|
|
2791
2791
|
"stream_failed",
|
|
2792
2792
|
"id_unavailable",
|
|
2793
2793
|
"invalid_revision",
|
|
@@ -6309,6 +6309,13 @@ const lastTurnSchema = z.object({
|
|
|
6309
6309
|
* ends anew.
|
|
6310
6310
|
*/
|
|
6311
6311
|
id: z.string().min(1),
|
|
6312
|
+
/**
|
|
6313
|
+
* The turn it ended, which the turn's input blocks name: for a turn a
|
|
6314
|
+
* message started, the message's id, which a Resume of the turn keeps;
|
|
6315
|
+
* a turn Jush started for a command's report or an agent's message has
|
|
6316
|
+
* an id of its own.
|
|
6317
|
+
*/
|
|
6318
|
+
turnId: z.string().min(1),
|
|
6312
6319
|
outcome: turnOutcomeSchema
|
|
6313
6320
|
});
|
|
6314
6321
|
/**
|
|
@@ -10423,6 +10430,19 @@ const transcriptPageSchema = z.object({
|
|
|
10423
10430
|
*/
|
|
10424
10431
|
cacheChart: cacheChartSchema.optional()
|
|
10425
10432
|
});
|
|
10433
|
+
/**
|
|
10434
|
+
* Where a turn of a conversation's root stands, by the id of the message
|
|
10435
|
+
* that started it (`GET /conversations/{id}/turns/{turnId}`).
|
|
10436
|
+
*/
|
|
10437
|
+
const turnStateSchema = z.discriminatedUnion("state", [
|
|
10438
|
+
z.object({ state: z.literal("queued") }),
|
|
10439
|
+
z.object({ state: z.literal("running") }),
|
|
10440
|
+
z.object({
|
|
10441
|
+
state: z.literal("ended"),
|
|
10442
|
+
end: z.string().min(1),
|
|
10443
|
+
outcome: turnOutcomeSchema
|
|
10444
|
+
})
|
|
10445
|
+
]);
|
|
10426
10446
|
z.object({ totals: z.array(usageGroupSchema) });
|
|
10427
10447
|
z.strictObject({
|
|
10428
10448
|
role: newRoleSchema.nullable().optional(),
|
|
@@ -11204,6 +11224,7 @@ var ConversationClient = class {
|
|
|
11204
11224
|
}, (event) => {
|
|
11205
11225
|
if (event.type === "send_result" && event.messageId === messageId) at = event.at;
|
|
11206
11226
|
if (at !== void 0 && this.holdsVersion(at)) return { resolve: void 0 };
|
|
11227
|
+
if (at !== void 0 && event.type === "error") return;
|
|
11207
11228
|
return this.failure(event, "send");
|
|
11208
11229
|
});
|
|
11209
11230
|
}
|
|
@@ -11237,6 +11258,7 @@ var ConversationClient = class {
|
|
|
11237
11258
|
}
|
|
11238
11259
|
if (event.type === "send_result" && event.messageId === turnId) at = event.at;
|
|
11239
11260
|
if (at !== void 0 && this.holdsVersion(at)) return { resolve: void 0 };
|
|
11261
|
+
if (at !== void 0 && event.type === "error") return;
|
|
11240
11262
|
if (event.type === "rejected" && event.command === "send_saved" && event.code === "saved_not_found") return { reject: new SavedGoneError() };
|
|
11241
11263
|
return this.failure(event, "send_saved");
|
|
11242
11264
|
});
|
|
@@ -11537,14 +11559,14 @@ var ConversationClient = class {
|
|
|
11537
11559
|
heldAgents() {
|
|
11538
11560
|
return this.agentsVersion ? { ...this.agentsVersion } : null;
|
|
11539
11561
|
}
|
|
11562
|
+
/** The agents' entries the client holds, the root's and every subagent's and side question's, as copies. */
|
|
11563
|
+
agentEntries() {
|
|
11564
|
+
return structuredClone([...this.agents.values()]);
|
|
11565
|
+
}
|
|
11540
11566
|
/** The accepted steers not yet in the transcript, as copies. */
|
|
11541
11567
|
pendingSteers() {
|
|
11542
11568
|
return structuredClone(this.pending);
|
|
11543
11569
|
}
|
|
11544
|
-
/** The message the root's running turn started with, until its turn writes it, as a copy. */
|
|
11545
|
-
startingMessage() {
|
|
11546
|
-
return structuredClone(this.starting);
|
|
11547
|
-
}
|
|
11548
11570
|
/** The calls the root's model is writing, as copies. */
|
|
11549
11571
|
pendingCalls() {
|
|
11550
11572
|
const root = this.root === null ? void 0 : this.agents.get(this.root);
|
|
@@ -11658,12 +11680,20 @@ var ConversationClient = class {
|
|
|
11658
11680
|
}
|
|
11659
11681
|
/**
|
|
11660
11682
|
* Whether the client holds the agents at `at`, the version a command's
|
|
11661
|
-
* answer names: at or past its revision, or at another epoch
|
|
11662
|
-
*
|
|
11683
|
+
* answer names: at or past its revision, or at another epoch once no read
|
|
11684
|
+
* of the agents is under way; null names no tree, and nothing to wait for.
|
|
11685
|
+
*
|
|
11686
|
+
* The answer comes after its step reached the page, so a page that held
|
|
11687
|
+
* another epoch, such as the stored one it read before its open restored
|
|
11688
|
+
* the tree, which the open's follow answered as stale, has begun reading
|
|
11689
|
+
* the agents again by then: the read shows the whole state, the command's
|
|
11690
|
+
* step included.
|
|
11663
11691
|
*/
|
|
11664
11692
|
holdsVersion(at) {
|
|
11665
11693
|
const held = this.agentsVersion;
|
|
11666
|
-
|
|
11694
|
+
if (at === null) return true;
|
|
11695
|
+
if (held === null) return false;
|
|
11696
|
+
return held.epoch === at.epoch ? held.revision >= at.revision : !this.agentsReading;
|
|
11667
11697
|
}
|
|
11668
11698
|
/** The wait of a `send` whose message has not run. */
|
|
11669
11699
|
queuedSendWaiter(messageId) {
|
|
@@ -12352,6 +12382,10 @@ function latestWindow(held) {
|
|
|
12352
12382
|
const last = held.windows.at(-1);
|
|
12353
12383
|
return last && windowEnd(last) >= held.length ? last : void 0;
|
|
12354
12384
|
}
|
|
12385
|
+
/** The window that holds the block `id`. */
|
|
12386
|
+
function windowOf(held, id) {
|
|
12387
|
+
return held.windows.find((window) => window.blocks.some((block) => block.id === id));
|
|
12388
|
+
}
|
|
12355
12389
|
/** Every block the page holds, in order, the windows' one after another. */
|
|
12356
12390
|
function heldBlocks(held) {
|
|
12357
12391
|
return held.windows.flatMap((window) => window.blocks);
|
|
@@ -12436,6 +12470,33 @@ function resetTranscript(held, reset, asked) {
|
|
|
12436
12470
|
blocks: withVersions(blocks, reset.versions)
|
|
12437
12471
|
}, "incoming"), reset.version);
|
|
12438
12472
|
}
|
|
12473
|
+
/**
|
|
12474
|
+
* The transcript with a page of it the page read, its blocks light. A block the page
|
|
12475
|
+
* already holds stays as it is. A page tells the transcript's length as the database
|
|
12476
|
+
* holds it, which the page takes only while no stream told it one.
|
|
12477
|
+
*/
|
|
12478
|
+
function addPage(held, page, live) {
|
|
12479
|
+
const blocks = withVersions(page.blocks.map((block) => ({
|
|
12480
|
+
...block,
|
|
12481
|
+
light: true
|
|
12482
|
+
})), page.versions);
|
|
12483
|
+
return addWindow(held, {
|
|
12484
|
+
start: page.start,
|
|
12485
|
+
length: page.length,
|
|
12486
|
+
blocks
|
|
12487
|
+
}, live);
|
|
12488
|
+
}
|
|
12489
|
+
/**
|
|
12490
|
+
* The transcript with `page`'s items, as the page holds them, among its
|
|
12491
|
+
* windows: an item the page already holds stays as it is, and the page's
|
|
12492
|
+
* length is taken only while no stream told one.
|
|
12493
|
+
*/
|
|
12494
|
+
function addWindow(held, page, live) {
|
|
12495
|
+
return heldTranscript(live ? held.length : page.length, joined(held.windows, {
|
|
12496
|
+
start: page.start,
|
|
12497
|
+
blocks: page.blocks
|
|
12498
|
+
}, "held"), held.version);
|
|
12499
|
+
}
|
|
12439
12500
|
/** `windows` without the blocks from `length` on. */
|
|
12440
12501
|
function truncated(windows, length) {
|
|
12441
12502
|
return windows.flatMap((window) => {
|
|
@@ -13143,6 +13204,82 @@ function connectTransport(connection, conversation) {
|
|
|
13143
13204
|
};
|
|
13144
13205
|
}
|
|
13145
13206
|
//#endregion
|
|
13207
|
+
//#region src/routes.ts
|
|
13208
|
+
/** A route refused the call: its status, and the core's error body. */
|
|
13209
|
+
var JushError = class extends Error {
|
|
13210
|
+
status;
|
|
13211
|
+
body;
|
|
13212
|
+
code;
|
|
13213
|
+
requestId;
|
|
13214
|
+
constructor(status, body, fallback) {
|
|
13215
|
+
super(body?.message ?? fallback);
|
|
13216
|
+
this.status = status;
|
|
13217
|
+
this.body = body;
|
|
13218
|
+
this.name = "JushError";
|
|
13219
|
+
this.code = body?.code ?? null;
|
|
13220
|
+
this.requestId = body?.requestId ?? null;
|
|
13221
|
+
}
|
|
13222
|
+
};
|
|
13223
|
+
/** The base of a process's URLs; the process reads the path alone. */
|
|
13224
|
+
const PROCESS_ORIGIN = "http://jush-core";
|
|
13225
|
+
/**
|
|
13226
|
+
* `path` below `base`, such as `/conversations` of `/jush/api/conversations`
|
|
13227
|
+
* below `/jush/api`; `path` itself when it is not below it, as
|
|
13228
|
+
* `/jush/apiary` is not.
|
|
13229
|
+
*/
|
|
13230
|
+
function below(path, base) {
|
|
13231
|
+
const root = base.endsWith("/") ? base.slice(0, -1) : base;
|
|
13232
|
+
return path === root || path.startsWith(`${root}/`) ? path.slice(root.length) : path;
|
|
13233
|
+
}
|
|
13234
|
+
/** The refusal `response`, an answer other than 2xx to `what`, carries. */
|
|
13235
|
+
async function refusal(response, what) {
|
|
13236
|
+
const text = await response.text();
|
|
13237
|
+
let body = null;
|
|
13238
|
+
try {
|
|
13239
|
+
const parsed = errorBodySchema.safeParse(JSON.parse(text));
|
|
13240
|
+
body = parsed.success ? parsed.data : null;
|
|
13241
|
+
} catch {}
|
|
13242
|
+
return new JushError(response.status, body, `${what} answered ${response.status}: ${text}`);
|
|
13243
|
+
}
|
|
13244
|
+
var CoreRoutes = class {
|
|
13245
|
+
process;
|
|
13246
|
+
id;
|
|
13247
|
+
connection;
|
|
13248
|
+
constructor(process, id, connection) {
|
|
13249
|
+
this.process = process;
|
|
13250
|
+
this.id = id;
|
|
13251
|
+
this.connection = connection;
|
|
13252
|
+
}
|
|
13253
|
+
/** The process's path of the core's route `path`, such as `/conversations`. */
|
|
13254
|
+
path(path) {
|
|
13255
|
+
return `/cores/${encodeURIComponent(this.id)}/api${path}`;
|
|
13256
|
+
}
|
|
13257
|
+
/** Calls the route `path` with `body` as JSON; throws `JushError` for an answer other than 2xx. */
|
|
13258
|
+
async request(method, path, body, signal) {
|
|
13259
|
+
const response = await this.process.fetch(new Request(PROCESS_ORIGIN + this.path(path), {
|
|
13260
|
+
method,
|
|
13261
|
+
...body === void 0 ? {} : {
|
|
13262
|
+
body: JSON.stringify(body),
|
|
13263
|
+
headers: { "content-type": "application/json" }
|
|
13264
|
+
},
|
|
13265
|
+
...signal === void 0 ? {} : { signal }
|
|
13266
|
+
}));
|
|
13267
|
+
if (!response.ok) throw await refusal(response, `${method} ${path}`);
|
|
13268
|
+
return response;
|
|
13269
|
+
}
|
|
13270
|
+
/** The answer of the route `path`, read with `schema`. */
|
|
13271
|
+
async json(method, path, schema, body, signal) {
|
|
13272
|
+
const response = await this.request(method, path, body, signal);
|
|
13273
|
+
const parsed = schema.safeParse(await response.json());
|
|
13274
|
+
if (!parsed.success) throw new Error(schemaRefusal(parsed.error));
|
|
13275
|
+
return parsed.data;
|
|
13276
|
+
}
|
|
13277
|
+
/** Calls the route `path`, and drops its answer. */
|
|
13278
|
+
async send(method, path, body) {
|
|
13279
|
+
await (await this.request(method, path, body)).body?.cancel();
|
|
13280
|
+
}
|
|
13281
|
+
};
|
|
13282
|
+
//#endregion
|
|
13146
13283
|
//#region src/conversation.ts
|
|
13147
13284
|
/**
|
|
13148
13285
|
* A conversation of a core, driven as the web app drives one: a
|
|
@@ -13163,9 +13300,6 @@ var Conversation = class {
|
|
|
13163
13300
|
/** The root's transcript, as the lane keeps it. */
|
|
13164
13301
|
transcript = EMPTY_TRANSCRIPT;
|
|
13165
13302
|
metadata = null;
|
|
13166
|
-
/** The ids of the messages waiting in the root's queue. */
|
|
13167
|
-
queued = /* @__PURE__ */ new Set();
|
|
13168
|
-
rootPhase = "idle";
|
|
13169
13303
|
/** The permission requests told already. */
|
|
13170
13304
|
told = /* @__PURE__ */ new Set();
|
|
13171
13305
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -13241,15 +13375,6 @@ var Conversation = class {
|
|
|
13241
13375
|
case "disconnected":
|
|
13242
13376
|
this.reopen();
|
|
13243
13377
|
break;
|
|
13244
|
-
case "queue":
|
|
13245
|
-
this.queued = new Set(event.queue.map((message) => message.id));
|
|
13246
|
-
break;
|
|
13247
|
-
case "agents":
|
|
13248
|
-
this.rootPhase = event.agents.find((agent) => agent.role.kind === "root")?.phase ?? this.rootPhase;
|
|
13249
|
-
break;
|
|
13250
|
-
case "agent":
|
|
13251
|
-
if (event.agent.role.kind === "root") this.rootPhase = event.agent.phase;
|
|
13252
|
-
break;
|
|
13253
13378
|
case "transcript_reset":
|
|
13254
13379
|
if (event.node === this.id) this.transcript = resetTranscript(this.transcript, event, event.asked);
|
|
13255
13380
|
break;
|
|
@@ -13280,6 +13405,7 @@ var Conversation = class {
|
|
|
13280
13405
|
}
|
|
13281
13406
|
} finally {
|
|
13282
13407
|
this.reopening = false;
|
|
13408
|
+
this.changed();
|
|
13283
13409
|
}
|
|
13284
13410
|
})();
|
|
13285
13411
|
this.opening = opening;
|
|
@@ -13322,6 +13448,14 @@ var Conversation = class {
|
|
|
13322
13448
|
return heldBlocks(this.transcript);
|
|
13323
13449
|
}
|
|
13324
13450
|
/**
|
|
13451
|
+
* The conversation's agents as its lane holds them: the root's entry,
|
|
13452
|
+
* whose id is the conversation's, each subagent's, whose id `sendToAgent`
|
|
13453
|
+
* takes, and each side question's. Empty until the lane opens.
|
|
13454
|
+
*/
|
|
13455
|
+
get agents() {
|
|
13456
|
+
return this.client?.agentEntries() ?? [];
|
|
13457
|
+
}
|
|
13458
|
+
/**
|
|
13325
13459
|
* Sends a message; resolves once it is in the transcript or the queue.
|
|
13326
13460
|
* The conversation takes it once however often it is sent under
|
|
13327
13461
|
* `messageId`, which messages and steers share.
|
|
@@ -13338,10 +13472,11 @@ var Conversation = class {
|
|
|
13338
13472
|
return this.routes.json("PATCH", `/conversations/${encodeURIComponent(this.id)}`, conversationUpdateSchema, patch);
|
|
13339
13473
|
}
|
|
13340
13474
|
/**
|
|
13341
|
-
* Sends `text` to the subagent `node`,
|
|
13342
|
-
* which takes it once however often it is sent
|
|
13343
|
-
* one as a steer, and an ended one is resumed
|
|
13344
|
-
* message's id, the one made for it when
|
|
13475
|
+
* Sends `text` to the subagent `node`, the id of one of `agents` whose
|
|
13476
|
+
* role is a subagent's, which takes it once however often it is sent
|
|
13477
|
+
* under `messageId`: a live one as a steer, and an ended one is resumed
|
|
13478
|
+
* with it. Resolves with the message's id, the one made for it when
|
|
13479
|
+
* `messageId` is absent.
|
|
13345
13480
|
*/
|
|
13346
13481
|
async sendToAgent(node, text, messageId) {
|
|
13347
13482
|
const path = `/conversations/${encodeURIComponent(this.id)}/agents/${encodeURIComponent(node)}/messages`;
|
|
@@ -13373,29 +13508,88 @@ var Conversation = class {
|
|
|
13373
13508
|
}
|
|
13374
13509
|
/**
|
|
13375
13510
|
* Sends `input`, and answers the turn it starts once the turn ended: once
|
|
13376
|
-
* the conversation's last ended turn is
|
|
13377
|
-
*
|
|
13378
|
-
*
|
|
13379
|
-
* the
|
|
13511
|
+
* the conversation's last ended turn is its own, as a turn the root
|
|
13512
|
+
* resumes ends anew. When the lane's view cannot tell, as after its
|
|
13513
|
+
* connection dropped while the turn ended, it asks the conversation where
|
|
13514
|
+
* the turn stands, again at each view that cannot tell. It reads the
|
|
13515
|
+
* transcript back to the message when the turn ended past what the lane
|
|
13516
|
+
* holds. It fails when the message left the queue without running, as an
|
|
13517
|
+
* abort's clearing of the queue removes it.
|
|
13380
13518
|
*/
|
|
13381
13519
|
async run(input) {
|
|
13382
13520
|
const messageId = randomUUID();
|
|
13383
13521
|
let sent = false;
|
|
13522
|
+
let answered = null;
|
|
13523
|
+
let asked = null;
|
|
13524
|
+
let reading = false;
|
|
13525
|
+
let failures = 0;
|
|
13384
13526
|
let change = {
|
|
13385
13527
|
changed: () => {},
|
|
13386
13528
|
closed: () => {}
|
|
13387
13529
|
};
|
|
13388
13530
|
const ended = new Promise((resolve, reject) => {
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13531
|
+
const again = () => {
|
|
13532
|
+
if (this.changes.has(change)) change.changed();
|
|
13533
|
+
};
|
|
13534
|
+
const later = () => {
|
|
13535
|
+
failures += 1;
|
|
13536
|
+
setTimeout(again, reconnectWait(failures));
|
|
13537
|
+
};
|
|
13538
|
+
const ask = (view) => {
|
|
13539
|
+
asked = view;
|
|
13540
|
+
this.turnState(messageId).then((state) => {
|
|
13541
|
+
if (asked !== view) return;
|
|
13542
|
+
if (state === null) {
|
|
13396
13543
|
this.changes.delete(change);
|
|
13397
13544
|
reject(/* @__PURE__ */ new Error("The message left the queue without running"));
|
|
13545
|
+
} else if (state.state === "ended") {
|
|
13546
|
+
failures = 0;
|
|
13547
|
+
answered = {
|
|
13548
|
+
end: state.end,
|
|
13549
|
+
outcome: state.outcome
|
|
13550
|
+
};
|
|
13551
|
+
again();
|
|
13552
|
+
} else {
|
|
13553
|
+
asked = null;
|
|
13554
|
+
later();
|
|
13555
|
+
}
|
|
13556
|
+
}, () => {
|
|
13557
|
+
if (asked === view) {
|
|
13558
|
+
asked = null;
|
|
13559
|
+
later();
|
|
13560
|
+
}
|
|
13561
|
+
});
|
|
13562
|
+
};
|
|
13563
|
+
const readBefore = (window) => {
|
|
13564
|
+
reading = true;
|
|
13565
|
+
this.readBefore(window).then(() => {
|
|
13566
|
+
reading = false;
|
|
13567
|
+
failures = 0;
|
|
13568
|
+
again();
|
|
13569
|
+
}, () => {
|
|
13570
|
+
reading = false;
|
|
13571
|
+
later();
|
|
13572
|
+
});
|
|
13573
|
+
};
|
|
13574
|
+
change = {
|
|
13575
|
+
changed: () => {
|
|
13576
|
+
const last = this.metadata?.lastTurn;
|
|
13577
|
+
const end = last?.turnId === messageId ? {
|
|
13578
|
+
end: last.id,
|
|
13579
|
+
outcome: last.outcome
|
|
13580
|
+
} : answered;
|
|
13581
|
+
if (end) {
|
|
13582
|
+
const turn = this.turnOf(messageId, end);
|
|
13583
|
+
if (turn) {
|
|
13584
|
+
this.changes.delete(change);
|
|
13585
|
+
resolve(turn);
|
|
13586
|
+
return;
|
|
13587
|
+
}
|
|
13588
|
+
const short = this.shortOf(messageId, end);
|
|
13589
|
+
if (short && !reading) readBefore(short);
|
|
13398
13590
|
}
|
|
13591
|
+
const view = sent ? this.unaccounted(messageId) : null;
|
|
13592
|
+
if (view !== null && view !== asked) ask(view);
|
|
13399
13593
|
},
|
|
13400
13594
|
closed: () => reject(/* @__PURE__ */ new Error("The conversation was closed before its turn ended"))
|
|
13401
13595
|
};
|
|
@@ -13413,30 +13607,70 @@ var Conversation = class {
|
|
|
13413
13607
|
return ended;
|
|
13414
13608
|
}
|
|
13415
13609
|
/**
|
|
13416
|
-
*
|
|
13417
|
-
*
|
|
13418
|
-
* nor
|
|
13610
|
+
* The lane's view of the conversation when it leaves the turn of the sent
|
|
13611
|
+
* message `messageId` unaccounted for: the root idle, and the message
|
|
13612
|
+
* neither queued, nor starting, nor the last ended turn's, as when the
|
|
13613
|
+
* turn ended unseen or the message left the queue. Null when the view
|
|
13614
|
+
* accounts for it, or cannot tell yet: while the lane opens again, or
|
|
13615
|
+
* before it holds both the agents and the root's transcript current, as
|
|
13616
|
+
* after a drop.
|
|
13419
13617
|
*/
|
|
13420
|
-
|
|
13421
|
-
|
|
13618
|
+
unaccounted(messageId) {
|
|
13619
|
+
const client = this.client;
|
|
13620
|
+
const agents = client?.heldAgents();
|
|
13621
|
+
if (this.reopening || !client || !agents || !client.holdsCurrent(this.id)) return null;
|
|
13622
|
+
const root = this.agents.find((agent) => agent.role.kind === "root");
|
|
13623
|
+
const phase = root?.phase ?? "idle";
|
|
13624
|
+
const last = this.metadata?.lastTurn ?? null;
|
|
13625
|
+
return phase !== "idle" && phase !== "compacting_idle" || root?.queue.some((message) => message.id === messageId) || root?.starting?.id === messageId || last?.turnId === messageId ? null : JSON.stringify([
|
|
13626
|
+
agents,
|
|
13627
|
+
client.transcriptVersion(this.id),
|
|
13628
|
+
last?.id ?? null
|
|
13629
|
+
]);
|
|
13630
|
+
}
|
|
13631
|
+
/** Where the turn `messageId` stands, as the conversation answers; null when it holds no turn of it. */
|
|
13632
|
+
async turnState(messageId) {
|
|
13633
|
+
const path = `/conversations/${encodeURIComponent(this.id)}/turns/${encodeURIComponent(messageId)}`;
|
|
13634
|
+
try {
|
|
13635
|
+
return await this.routes.json("GET", path, turnStateSchema);
|
|
13636
|
+
} catch (error) {
|
|
13637
|
+
if (error instanceof JushError && error.code === "turn_not_found") return null;
|
|
13638
|
+
throw error;
|
|
13639
|
+
}
|
|
13422
13640
|
}
|
|
13423
|
-
/** The turn `messageId` started,
|
|
13424
|
-
turnOf(messageId) {
|
|
13425
|
-
const
|
|
13426
|
-
if (!last) return null;
|
|
13427
|
-
const blocks = this.blocks;
|
|
13641
|
+
/** The turn `messageId` started, which ended at `ending`; null until one window of the transcript holds both ends. */
|
|
13642
|
+
turnOf(messageId, ending) {
|
|
13643
|
+
const blocks = windowOf(this.transcript, ending.end)?.blocks ?? [];
|
|
13428
13644
|
const at = blocks.findIndex((block) => block.type === "user" && block.turnId === messageId);
|
|
13429
|
-
const end = blocks.findIndex((block) => block.id ===
|
|
13645
|
+
const end = blocks.findIndex((block) => block.id === ending.end);
|
|
13430
13646
|
if (at < 0 || end <= at) return null;
|
|
13431
13647
|
const after = blocks.slice(at + 1, end + 1);
|
|
13432
13648
|
const text = after.flatMap((block) => block.type === "text" ? [block.text] : []).join("\n\n");
|
|
13433
13649
|
return {
|
|
13434
|
-
outcome:
|
|
13650
|
+
outcome: ending.outcome,
|
|
13435
13651
|
blocks: after,
|
|
13436
13652
|
text
|
|
13437
13653
|
};
|
|
13438
13654
|
}
|
|
13439
13655
|
/**
|
|
13656
|
+
* The window of the root's transcript that holds the turn's end `ending`
|
|
13657
|
+
* but not the message `messageId` that started it, when the transcript
|
|
13658
|
+
* goes on before it; null otherwise.
|
|
13659
|
+
*/
|
|
13660
|
+
shortOf(messageId, ending) {
|
|
13661
|
+
const window = windowOf(this.transcript, ending.end);
|
|
13662
|
+
const started = window?.blocks.some((block) => block.type === "user" && block.turnId === messageId);
|
|
13663
|
+
return window && window.start > 0 && !started ? window : null;
|
|
13664
|
+
}
|
|
13665
|
+
/** Reads the page of the root's transcript before `window` into what the conversation holds. */
|
|
13666
|
+
async readBefore(window) {
|
|
13667
|
+
const root = encodeURIComponent(this.id);
|
|
13668
|
+
const edge = encodeURIComponent(window.blocks[0].id);
|
|
13669
|
+
const path = `/conversations/${root}/agents/${root}/transcript?before=${window.start}&edge=${edge}`;
|
|
13670
|
+
const page = await this.routes.json("GET", path, transcriptPageSchema);
|
|
13671
|
+
this.transcript = addPage(this.transcript, page, true);
|
|
13672
|
+
}
|
|
13673
|
+
/**
|
|
13440
13674
|
* Everything the conversation's lane tells from now on, until the loop
|
|
13441
13675
|
* that reads it stops or the conversation closes.
|
|
13442
13676
|
*/
|
|
@@ -13876,82 +14110,6 @@ function pluginError(error) {
|
|
|
13876
14110
|
};
|
|
13877
14111
|
}
|
|
13878
14112
|
//#endregion
|
|
13879
|
-
//#region src/routes.ts
|
|
13880
|
-
/** A route refused the call: its status, and the core's error body. */
|
|
13881
|
-
var JushError = class extends Error {
|
|
13882
|
-
status;
|
|
13883
|
-
body;
|
|
13884
|
-
code;
|
|
13885
|
-
requestId;
|
|
13886
|
-
constructor(status, body, fallback) {
|
|
13887
|
-
super(body?.message ?? fallback);
|
|
13888
|
-
this.status = status;
|
|
13889
|
-
this.body = body;
|
|
13890
|
-
this.name = "JushError";
|
|
13891
|
-
this.code = body?.code ?? null;
|
|
13892
|
-
this.requestId = body?.requestId ?? null;
|
|
13893
|
-
}
|
|
13894
|
-
};
|
|
13895
|
-
/** The base of a process's URLs; the process reads the path alone. */
|
|
13896
|
-
const PROCESS_ORIGIN = "http://jush-core";
|
|
13897
|
-
/**
|
|
13898
|
-
* `path` below `base`, such as `/conversations` of `/jush/api/conversations`
|
|
13899
|
-
* below `/jush/api`; `path` itself when it is not below it, as
|
|
13900
|
-
* `/jush/apiary` is not.
|
|
13901
|
-
*/
|
|
13902
|
-
function below(path, base) {
|
|
13903
|
-
const root = base.endsWith("/") ? base.slice(0, -1) : base;
|
|
13904
|
-
return path === root || path.startsWith(`${root}/`) ? path.slice(root.length) : path;
|
|
13905
|
-
}
|
|
13906
|
-
/** The refusal `response`, an answer other than 2xx to `what`, carries. */
|
|
13907
|
-
async function refusal(response, what) {
|
|
13908
|
-
const text = await response.text();
|
|
13909
|
-
let body = null;
|
|
13910
|
-
try {
|
|
13911
|
-
const parsed = errorBodySchema.safeParse(JSON.parse(text));
|
|
13912
|
-
body = parsed.success ? parsed.data : null;
|
|
13913
|
-
} catch {}
|
|
13914
|
-
return new JushError(response.status, body, `${what} answered ${response.status}: ${text}`);
|
|
13915
|
-
}
|
|
13916
|
-
var CoreRoutes = class {
|
|
13917
|
-
process;
|
|
13918
|
-
id;
|
|
13919
|
-
connection;
|
|
13920
|
-
constructor(process, id, connection) {
|
|
13921
|
-
this.process = process;
|
|
13922
|
-
this.id = id;
|
|
13923
|
-
this.connection = connection;
|
|
13924
|
-
}
|
|
13925
|
-
/** The process's path of the core's route `path`, such as `/conversations`. */
|
|
13926
|
-
path(path) {
|
|
13927
|
-
return `/cores/${encodeURIComponent(this.id)}/api${path}`;
|
|
13928
|
-
}
|
|
13929
|
-
/** Calls the route `path` with `body` as JSON; throws `JushError` for an answer other than 2xx. */
|
|
13930
|
-
async request(method, path, body, signal) {
|
|
13931
|
-
const response = await this.process.fetch(new Request(PROCESS_ORIGIN + this.path(path), {
|
|
13932
|
-
method,
|
|
13933
|
-
...body === void 0 ? {} : {
|
|
13934
|
-
body: JSON.stringify(body),
|
|
13935
|
-
headers: { "content-type": "application/json" }
|
|
13936
|
-
},
|
|
13937
|
-
...signal === void 0 ? {} : { signal }
|
|
13938
|
-
}));
|
|
13939
|
-
if (!response.ok) throw await refusal(response, `${method} ${path}`);
|
|
13940
|
-
return response;
|
|
13941
|
-
}
|
|
13942
|
-
/** The answer of the route `path`, read with `schema`. */
|
|
13943
|
-
async json(method, path, schema, body, signal) {
|
|
13944
|
-
const response = await this.request(method, path, body, signal);
|
|
13945
|
-
const parsed = schema.safeParse(await response.json());
|
|
13946
|
-
if (!parsed.success) throw new Error(schemaRefusal(parsed.error));
|
|
13947
|
-
return parsed.data;
|
|
13948
|
-
}
|
|
13949
|
-
/** Calls the route `path`, and drops its answer. */
|
|
13950
|
-
async send(method, path, body) {
|
|
13951
|
-
await (await this.request(method, path, body)).body?.cancel();
|
|
13952
|
-
}
|
|
13953
|
-
};
|
|
13954
|
-
//#endregion
|
|
13955
14113
|
//#region src/socket.ts
|
|
13956
14114
|
/**
|
|
13957
14115
|
* A WebSocket on a stream of the process's HTTP/2 connection (RFC 8441):
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jush-agent/sdk",
|
|
3
3
|
"description": "Jush's agents in a program: its cores, conversations, providers, devices and plugins, in a process of the program's own.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.6252",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"homepage": "https://github.com/jush-ai/jush/tree/main/packages/sdk#readme",
|
|
36
36
|
"bugs": "https://github.com/jush-ai/jush/issues",
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@jush-agent/sdk-darwin-arm64": "0.2.
|
|
39
|
-
"@jush-agent/sdk-darwin-x64": "0.2.
|
|
40
|
-
"@jush-agent/sdk-linux-arm64": "0.2.
|
|
41
|
-
"@jush-agent/sdk-linux-x64": "0.2.
|
|
42
|
-
"@jush-agent/sdk-win32-arm64": "0.2.
|
|
43
|
-
"@jush-agent/sdk-win32-x64": "0.2.
|
|
38
|
+
"@jush-agent/sdk-darwin-arm64": "0.2.6252",
|
|
39
|
+
"@jush-agent/sdk-darwin-x64": "0.2.6252",
|
|
40
|
+
"@jush-agent/sdk-linux-arm64": "0.2.6252",
|
|
41
|
+
"@jush-agent/sdk-linux-x64": "0.2.6252",
|
|
42
|
+
"@jush-agent/sdk-win32-arm64": "0.2.6252",
|
|
43
|
+
"@jush-agent/sdk-win32-x64": "0.2.6252"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "jush.browser",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6252",
|
|
4
4
|
"protocolVersion": 1,
|
|
5
5
|
"operations": [
|
|
6
6
|
"browser.tab.new",
|
|
@@ -60,28 +60,28 @@
|
|
|
60
60
|
],
|
|
61
61
|
"targets": {
|
|
62
62
|
"aarch64-apple-darwin": {
|
|
63
|
-
"sha256": "
|
|
64
|
-
"size":
|
|
63
|
+
"sha256": "f827e9a1aeba37fad31fc2044aceaad1c0e0efad5e4f0efde36c3e6e192f9c2d",
|
|
64
|
+
"size": 27343008
|
|
65
65
|
},
|
|
66
66
|
"aarch64-pc-windows-msvc": {
|
|
67
|
-
"sha256": "
|
|
68
|
-
"size":
|
|
67
|
+
"sha256": "abacc40ae27231c116a4f6900106b1179ec93e23e694d295c2de2fbcf086ab4c",
|
|
68
|
+
"size": 24764416
|
|
69
69
|
},
|
|
70
70
|
"aarch64-unknown-linux-musl": {
|
|
71
|
-
"sha256": "
|
|
72
|
-
"size":
|
|
71
|
+
"sha256": "dc8c9e1fd58b69f65844d7658c9a9439fc62cd35a1600bf885eaf545d4507cdd",
|
|
72
|
+
"size": 23390448
|
|
73
73
|
},
|
|
74
74
|
"x86_64-apple-darwin": {
|
|
75
|
-
"sha256": "
|
|
76
|
-
"size":
|
|
75
|
+
"sha256": "356a5ed63a6b46fc30ae530e372dfd45d67e99b41c2f7c07778b17a0b101f670",
|
|
76
|
+
"size": 27948904
|
|
77
77
|
},
|
|
78
78
|
"x86_64-pc-windows-msvc": {
|
|
79
|
-
"sha256": "
|
|
80
|
-
"size":
|
|
79
|
+
"sha256": "7eac074db7c63828b90997c67daf5eec371ae1e3b95dfbcb03e8060a68637464",
|
|
80
|
+
"size": 27777536
|
|
81
81
|
},
|
|
82
82
|
"x86_64-unknown-linux-musl": {
|
|
83
|
-
"sha256": "
|
|
84
|
-
"size":
|
|
83
|
+
"sha256": "a22eb830d77197436185391d6e24f4fbce8c7a922b0c6bcf1b10e92ef232c706",
|
|
84
|
+
"size": 25865208
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "jush.claude-code",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6252",
|
|
4
4
|
"protocolVersion": 1,
|
|
5
5
|
"operations": [
|
|
6
6
|
"claude-code.ensure",
|
|
@@ -8,28 +8,28 @@
|
|
|
8
8
|
],
|
|
9
9
|
"targets": {
|
|
10
10
|
"aarch64-apple-darwin": {
|
|
11
|
-
"sha256": "
|
|
12
|
-
"size":
|
|
11
|
+
"sha256": "5e04f12b441dc5f8ed5539116ee54c5778134c42c84e34d1a46c1ee2d5ddb5b2",
|
|
12
|
+
"size": 3883872
|
|
13
13
|
},
|
|
14
14
|
"aarch64-pc-windows-msvc": {
|
|
15
|
-
"sha256": "
|
|
16
|
-
"size":
|
|
15
|
+
"sha256": "ece77aef17131a632f880eb19118d920f85788c870334e8408d8aac3dc75f5bc",
|
|
16
|
+
"size": 3499520
|
|
17
17
|
},
|
|
18
18
|
"aarch64-unknown-linux-musl": {
|
|
19
|
-
"sha256": "
|
|
20
|
-
"size":
|
|
19
|
+
"sha256": "18b8b29db6dc76b6edfff765b03c54c0560afefe12e317aa484328d0557fcebd",
|
|
20
|
+
"size": 3591112
|
|
21
21
|
},
|
|
22
22
|
"x86_64-apple-darwin": {
|
|
23
|
-
"sha256": "
|
|
24
|
-
"size":
|
|
23
|
+
"sha256": "0d0ee0a76be8745a94ba1698e3eabda20b5205d2c1d2f61236702e0e15923c1b",
|
|
24
|
+
"size": 3787440
|
|
25
25
|
},
|
|
26
26
|
"x86_64-pc-windows-msvc": {
|
|
27
|
-
"sha256": "
|
|
28
|
-
"size":
|
|
27
|
+
"sha256": "fe134d0aabff88d41bb8b1d33e8140ddd830b3627d1e7859f945de9b790b2f16",
|
|
28
|
+
"size": 3726336
|
|
29
29
|
},
|
|
30
30
|
"x86_64-unknown-linux-musl": {
|
|
31
|
-
"sha256": "
|
|
32
|
-
"size":
|
|
31
|
+
"sha256": "21ed769633fbd553f81a29d3becf4c71ab433d2f908a41044d582e18277dc4b3",
|
|
32
|
+
"size": 3756104
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "jush.fetch",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6252",
|
|
4
4
|
"protocolVersion": 1,
|
|
5
5
|
"operations": [
|
|
6
6
|
"fetch.get"
|
|
7
7
|
],
|
|
8
8
|
"targets": {
|
|
9
9
|
"aarch64-apple-darwin": {
|
|
10
|
-
"sha256": "
|
|
11
|
-
"size":
|
|
10
|
+
"sha256": "fedcdccec2632f7fed105bd0b1c2828173f96cae56402b378f41e4762ffb863b",
|
|
11
|
+
"size": 7164592
|
|
12
12
|
},
|
|
13
13
|
"aarch64-pc-windows-msvc": {
|
|
14
|
-
"sha256": "
|
|
15
|
-
"size":
|
|
14
|
+
"sha256": "d8c7133901a78167d71beb13ca70c9b9327276be70bfc8a76a03195b5c8fe84c",
|
|
15
|
+
"size": 6516736
|
|
16
16
|
},
|
|
17
17
|
"aarch64-unknown-linux-musl": {
|
|
18
|
-
"sha256": "
|
|
19
|
-
"size":
|
|
18
|
+
"sha256": "cdec02625c3204366bc3132e7aef3f61a5db8177a0f12dec1271b7d21e2016d0",
|
|
19
|
+
"size": 6529264
|
|
20
20
|
},
|
|
21
21
|
"x86_64-apple-darwin": {
|
|
22
|
-
"sha256": "
|
|
23
|
-
"size":
|
|
22
|
+
"sha256": "f2624e663887e1c51a47b980a59cb5bc437eee9b4aa3133906062a56c5b2623d",
|
|
23
|
+
"size": 7276104
|
|
24
24
|
},
|
|
25
25
|
"x86_64-pc-windows-msvc": {
|
|
26
|
-
"sha256": "
|
|
26
|
+
"sha256": "e5d78893b279edbc518c2ce8976481036f9baefb87e687db53b703d2e91591ad",
|
|
27
27
|
"size": 6989824
|
|
28
28
|
},
|
|
29
29
|
"x86_64-unknown-linux-musl": {
|
|
30
|
-
"sha256": "
|
|
31
|
-
"size":
|
|
30
|
+
"sha256": "189e6d2c75d25d7f11926ce38f86e5a285df8761e33618a45b6ae8cfa2b28cd8",
|
|
31
|
+
"size": 7017264
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "jush.file",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6252",
|
|
4
4
|
"protocolVersion": 1,
|
|
5
5
|
"operations": [
|
|
6
6
|
"file.view",
|
|
@@ -9,28 +9,28 @@
|
|
|
9
9
|
],
|
|
10
10
|
"targets": {
|
|
11
11
|
"aarch64-apple-darwin": {
|
|
12
|
-
"sha256": "
|
|
13
|
-
"size":
|
|
12
|
+
"sha256": "37452902e1c8c51879495a01505005421ca535b7750fff6e3657029bfd0493ec",
|
|
13
|
+
"size": 4930224
|
|
14
14
|
},
|
|
15
15
|
"aarch64-pc-windows-msvc": {
|
|
16
|
-
"sha256": "
|
|
16
|
+
"sha256": "8c02c9cbb87b4b065e0d3c3a21e971da1718e7bc4408f0e19cad11d735e644b7",
|
|
17
17
|
"size": 4361728
|
|
18
18
|
},
|
|
19
19
|
"aarch64-unknown-linux-musl": {
|
|
20
|
-
"sha256": "
|
|
21
|
-
"size":
|
|
20
|
+
"sha256": "16317306a3429de9176fed2160aa6dd142525dcc1ec3a77a69ee7010fbafb429",
|
|
21
|
+
"size": 4469504
|
|
22
22
|
},
|
|
23
23
|
"x86_64-apple-darwin": {
|
|
24
|
-
"sha256": "
|
|
25
|
-
"size":
|
|
24
|
+
"sha256": "c67a5758e55e154445bbc2e144df1c7123a6c66e5b81732320e68c9d5ffbd856",
|
|
25
|
+
"size": 4806312
|
|
26
26
|
},
|
|
27
27
|
"x86_64-pc-windows-msvc": {
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "7308f921e6d09b339676445c6c08626950dcafe15e0f568713afd5d5ee13e746",
|
|
29
29
|
"size": 4665344
|
|
30
30
|
},
|
|
31
31
|
"x86_64-unknown-linux-musl": {
|
|
32
|
-
"sha256": "
|
|
33
|
-
"size":
|
|
32
|
+
"sha256": "9d6ecb4c6120991784d4950a30419fb5fac0bd77804c52045d50bbf3e5fb78af",
|
|
33
|
+
"size": 4691456
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "jush.mobile",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6252",
|
|
4
4
|
"protocolVersion": 1,
|
|
5
5
|
"operations": [
|
|
6
6
|
"mobile.list",
|
|
@@ -25,28 +25,28 @@
|
|
|
25
25
|
],
|
|
26
26
|
"targets": {
|
|
27
27
|
"aarch64-apple-darwin": {
|
|
28
|
-
"sha256": "
|
|
29
|
-
"size":
|
|
28
|
+
"sha256": "8c1b7d30efe78f0ac2c47d2e262bee6b3d5daae612eb8a3daacc1826ba9f9ff1",
|
|
29
|
+
"size": 22227488
|
|
30
30
|
},
|
|
31
31
|
"aarch64-pc-windows-msvc": {
|
|
32
|
-
"sha256": "
|
|
33
|
-
"size":
|
|
32
|
+
"sha256": "351246da1246d2fe319bb7e7fc179194f6e59706d5649947ce010691a7c0db1d",
|
|
33
|
+
"size": 17900032
|
|
34
34
|
},
|
|
35
35
|
"aarch64-unknown-linux-musl": {
|
|
36
|
-
"sha256": "
|
|
37
|
-
"size":
|
|
36
|
+
"sha256": "05a404a38bb964c65f09c621827f8d121ffc20bdf96c2bff878891b7ee89e564",
|
|
37
|
+
"size": 17339184
|
|
38
38
|
},
|
|
39
39
|
"x86_64-apple-darwin": {
|
|
40
|
-
"sha256": "
|
|
41
|
-
"size":
|
|
40
|
+
"sha256": "214c803c2d826ce034ced573a6c63918e78f0e7aaa66e20f94d9921e19e3fda2",
|
|
41
|
+
"size": 21509120
|
|
42
42
|
},
|
|
43
43
|
"x86_64-pc-windows-msvc": {
|
|
44
|
-
"sha256": "
|
|
45
|
-
"size":
|
|
44
|
+
"sha256": "75893e9d9aab06dbbf8dacf13c0038e0ddcaf75578408483870be0e48fc773da",
|
|
45
|
+
"size": 20918272
|
|
46
46
|
},
|
|
47
47
|
"x86_64-unknown-linux-musl": {
|
|
48
|
-
"sha256": "
|
|
49
|
-
"size":
|
|
48
|
+
"sha256": "b023363faa8b4b6c66a3f3e9785bc90e052f904bd7b4efb1a24aca4bcf0da8a6",
|
|
49
|
+
"size": 19920640
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|