@jush-agent/sdk 0.2.6346 → 0.2.6368
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 +65 -34
- package/dist/index.d.mts +191 -107
- package/dist/index.mjs +139 -70
- package/package.json +7 -7
- package/release/commands/jush-browser/descriptor.json +13 -13
- package/release/commands/jush-fetch/descriptor.json +12 -12
- package/release/commands/jush-file/descriptor.json +13 -13
- package/release/commands/jush-mobile/descriptor.json +13 -13
- package/release/commands/jush-subscription-cli/descriptor.json +12 -12
package/README.md
CHANGED
|
@@ -386,16 +386,19 @@ turn it starts ended, with that turn's blocks and outcome, also when your
|
|
|
386
386
|
program's connection to the process dropped while the turn ended. It fails
|
|
387
387
|
when the message leaves the queue without running, as an abort that clears
|
|
388
388
|
the queue or gives the message back makes it, or when the conversation
|
|
389
|
-
closes first. `options.
|
|
390
|
-
|
|
391
|
-
as `
|
|
392
|
-
|
|
393
|
-
the
|
|
389
|
+
closes first. `options.labels` are your own key-value pairs for the
|
|
390
|
+
message, such as `{ sender: 'alex', scene: 'review' }`: the message's `user`
|
|
391
|
+
block keeps them as `labels`, so a page can show who wrote what, the model
|
|
392
|
+
does not read them, and [Usage](#usage) says what they count. At most 16; a
|
|
393
|
+
key is 1 to 64 letters, digits, `.`, `_` and `-`, the first a letter or a
|
|
394
|
+
digit, and a value 1 to 512 characters. `options.assignmentId` names the
|
|
395
|
+
earlier work the message continues ([Usage](#usage)). The other actions are
|
|
396
|
+
the ones the app has:
|
|
394
397
|
|
|
395
398
|
| Method | What it does |
|
|
396
399
|
| --- | --- |
|
|
397
|
-
| `send(input, messageId?, options?)` | Sends a message, queued behind a running turn; resolves once the conversation holds it; `options
|
|
398
|
-
| `steer(input, steerId?, options?)` | Hands a message to the running turn; resolves once the turn took it; `options
|
|
400
|
+
| `send(input, messageId?, options?)` | Sends a message, queued behind a running turn; resolves once the conversation holds it; `options` as `run` takes them |
|
|
401
|
+
| `steer(input, steerId?, options?)` | Hands a message to the running turn; resolves once the turn took it; `options` as `run` takes them |
|
|
399
402
|
| `abort()` | Stops the running turn |
|
|
400
403
|
| `retry()` | Runs the latest turn again from your message |
|
|
401
404
|
| `resume()` | Finishes a turn that did not finish |
|
|
@@ -511,7 +514,8 @@ to one subagent, named by its id in `conversation.agents`. A subagent at work
|
|
|
511
514
|
takes it as a steer, an idle one starts a turn with it, and one that ended is
|
|
512
515
|
resumed with it. Give the message an id when you may send it again, such as
|
|
513
516
|
after a lost answer: the subagent takes a message once, however often it
|
|
514
|
-
arrives. `options
|
|
517
|
+
arrives. `options` names its labels and the work it continues, as `run`
|
|
518
|
+
takes them.
|
|
515
519
|
|
|
516
520
|
```ts
|
|
517
521
|
const tester = conversation.agents.find((agent) => agent.role.kind === 'subagent' && agent.role.profile === 'tester')
|
|
@@ -734,8 +738,9 @@ conversation already.
|
|
|
734
738
|
## Usage
|
|
735
739
|
|
|
736
740
|
`core.usage.report` sums the calls of a period by minute, hour or day of a
|
|
737
|
-
time zone, grouped by any of `conversation`, `agent`, `
|
|
738
|
-
`
|
|
741
|
+
time zone, grouped by any of `conversation`, `agent`, `model`, `provider`,
|
|
742
|
+
`account`, `turn`, `assignment` and `purpose`, and by the labels your
|
|
743
|
+
messages carry, each as `label:<key>`:
|
|
739
744
|
|
|
740
745
|
```ts
|
|
741
746
|
const report = await core.usage.report({
|
|
@@ -743,15 +748,18 @@ const report = await core.usage.report({
|
|
|
743
748
|
to: new Date('2026-12-01T00:00:00+08:00'),
|
|
744
749
|
bucket: 'day',
|
|
745
750
|
timeZone: 'Asia/Shanghai',
|
|
746
|
-
groupBy: ['conversation', 'sender', 'model'],
|
|
751
|
+
groupBy: ['conversation', 'label:sender', 'model'],
|
|
747
752
|
})
|
|
748
753
|
for (const bucket of report.buckets) {
|
|
749
754
|
for (const group of bucket.groups) {
|
|
750
|
-
console.log(bucket.start, group.sender, group.model, group.calls, group.cost.usd, group.apiPrice)
|
|
755
|
+
console.log(bucket.start, group.labels?.sender, group.model, group.calls, group.cost.usd, group.apiPrice)
|
|
751
756
|
}
|
|
752
757
|
}
|
|
753
758
|
```
|
|
754
759
|
|
|
760
|
+
A group names the value of each label it is grouped by in `labels`, null
|
|
761
|
+
for calls without it, such as `{ sender: 'alex' }` or `{ sender: null }`.
|
|
762
|
+
Jush gives a label no meaning: group by as many as your program counts by.
|
|
755
763
|
A group counts its calls and their tokens, `cost` is what the vendors said
|
|
756
764
|
the calls cost, by currency and never converted, and `apiPrice` what their
|
|
757
765
|
tokens would cost on the vendors' APIs in dollars, leaving out the
|
|
@@ -788,28 +796,30 @@ const review = await core.usage.report({
|
|
|
788
796
|
`agent` is null for a side question's call and for one no agent made, such
|
|
789
797
|
as a title's, and `agents` keeps neither.
|
|
790
798
|
|
|
791
|
-
A call
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
- A subagent the agent starts
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
799
|
+
A call carries the labels of the latest message that handed its agent
|
|
800
|
+
work: a message, a steer, a side question, or another agent's message; or
|
|
801
|
+
those of the work whose end opened its turn.
|
|
802
|
+
|
|
803
|
+
- A message labeled `{ sender: 'alice' }` starts a turn: the turn's calls
|
|
804
|
+
carry its labels, and so do those of the turn that continues once a
|
|
805
|
+
command it started ends.
|
|
806
|
+
- A subagent the agent starts during that work carries Alice's labels, and
|
|
807
|
+
so do its calls and the commands it runs. So does the work of a subagent
|
|
808
|
+
or a conversation the agent sends a message to then.
|
|
809
|
+
- A steer labeled `{ sender: 'bob' }` reaches the running turn: the calls
|
|
810
|
+
after the agent read it carry Bob's labels, in place of Alice's rather
|
|
811
|
+
than merged with them, so a `scene` Alice's message named is gone. A
|
|
812
|
+
steer that names no labels leaves the calls after it none.
|
|
813
|
+
- A turn that Alice's work wakes once it ends carries her labels, even
|
|
814
|
+
after Bob's message: a command started in her turn, a subagent of her
|
|
815
|
+
work, or another conversation her turn sent a message to with
|
|
806
816
|
`--wake-when-done`. What ends while Bob's turn runs joins that turn,
|
|
807
|
-
which
|
|
808
|
-
- A schedule the agent makes
|
|
817
|
+
which keeps Bob's.
|
|
818
|
+
- A schedule the agent makes during Alice's work runs with her labels.
|
|
809
819
|
|
|
810
|
-
After a message that names no
|
|
811
|
-
schedule your program or the user made, the calls
|
|
812
|
-
|
|
820
|
+
After a message that names no labels, as one from the app or from a
|
|
821
|
+
schedule your program or the user made, the calls carry none, and neither
|
|
822
|
+
does a turn that the end of work it started opens. Nor do the calls
|
|
813
823
|
outside an agent's work, such as a title's or the suggested replies after
|
|
814
824
|
a turn.
|
|
815
825
|
|
|
@@ -817,7 +827,7 @@ A call's `assignment` is the id of the message that handed its agent the
|
|
|
817
827
|
work: the id you sent the message under, a side question's or its
|
|
818
828
|
follow-up's (`sideQuestions.followUp(side, input, messageId)`), or a
|
|
819
829
|
schedule run's `turn`. The turns that continue that work share it, as they
|
|
820
|
-
share its
|
|
830
|
+
share its labels: those a background command's end, a subagent's end or
|
|
821
831
|
another conversation's end opens, a retry, a resume or a compaction, and
|
|
822
832
|
the runs of a schedule the agent made then. A steer joins the running
|
|
823
833
|
turn's assignment. What continues work that names no assignment, such as
|
|
@@ -831,6 +841,27 @@ await conversation.send('Summarize the incident', 'listener:ops-alerts:8812')
|
|
|
831
841
|
const report = await core.usage.report({ from, to, bucket: 'day', timeZone: 'Asia/Shanghai', groupBy: ['conversation', 'assignment', 'model'] })
|
|
832
842
|
```
|
|
833
843
|
|
|
844
|
+
A message your program sends to continue earlier work names that work's
|
|
845
|
+
assignment with `assignmentId`, and its labels with `labels`. A plugin's
|
|
846
|
+
command call names the assignment and the labels of the work it was part
|
|
847
|
+
of; a program that follows something for the conversation keeps them, and
|
|
848
|
+
wakes it within that work:
|
|
849
|
+
|
|
850
|
+
```ts
|
|
851
|
+
// In the command that starts following a merge request.
|
|
852
|
+
const caller = call.invocation.caller
|
|
853
|
+
// Hours later, as a commit lands.
|
|
854
|
+
await conversation.send('A commit landed on !42; review it again.', 'acme:review-42:3', {
|
|
855
|
+
labels: caller?.labels,
|
|
856
|
+
assignmentId: caller?.assignmentId,
|
|
857
|
+
})
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
The turn it opens, its commands and the work that continues it are counted
|
|
861
|
+
in that assignment, in `usage.report` and in `commands.history`. A steer the
|
|
862
|
+
running turn reads joins that turn's whatever it names, and so does a
|
|
863
|
+
message to a running subagent.
|
|
864
|
+
|
|
834
865
|
## Commands your agents ran
|
|
835
866
|
|
|
836
867
|
`core.commands.history` reads the core's command history, in the order its
|
|
@@ -845,7 +876,7 @@ let page = await core.commands.history({ from: new Date(Date.now() - 30 * 86_400
|
|
|
845
876
|
for (const command of page.commands) {
|
|
846
877
|
// command.conversation, command.agent (0 for the main agent, null for a
|
|
847
878
|
// side question), command.command, command.device, command.turn,
|
|
848
|
-
// command.
|
|
879
|
+
// command.labels, command.assignment, command.title, command.script,
|
|
849
880
|
// command.startedAt (a wait for its device included), command.endedAt,
|
|
850
881
|
// and command.end:
|
|
851
882
|
// { kind: 'exited', exitCode } | { kind: 'stopped' } | { kind: 'lost', reason } | { kind: 'not_started', reason }
|