@mitralab.io/sdk-core 0.2.10 → 0.2.11

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/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## 0.2.11-beta.0
6
+
7
+ - Agent turn usage (`AgentTurnUsage`): `inputTokens` and `outputTokens`, and when the harness
8
+ reports them `reasoningTokens`, `cacheReadTokens`, `cacheCreationTokens`, `model`,
9
+ `provider`, `costUsd` (this turn), `costUsdRaw` (the provider session so far) and
10
+ `costSource`. `inputTokens` is the input without cache, as in the legacy platform; cache is
11
+ counted apart in `cacheReadTokens` and `cacheCreationTokens`.
12
+ - Also optional on it: `requestCount`, `requests` (`AgentTurnUsageRequest`: `model`,
13
+ `inputTokens`, `outputTokens`, `cacheReadTokens`, `cacheCreationTokens`), `authMode`
14
+ (`subscription`, `api_key`, `included_ai`, `custom`, `unknown`, or a newer string kept as is),
15
+ `durationMs` and `requestMessageId`. `durationMs` comes from the box in `stepFinish`, live and
16
+ in the history; `authMode` and `requestMessageId` only from the Copilot's record, so they show
17
+ in the history and in a recovered turn, never in the live `turnEnd`.
18
+ - `AgentMessage.usage` carries it on the Agent message that closed a turn, as the Copilot
19
+ returns it from `GET /api/v1/tasks/{id}/messages`, and `loadHistory` keeps it on that `agent`
20
+ timeline item. A message without it is still valid (older Copilot).
21
+ - `turnEnd`, and the result `sendAndWait` resolves, carry `usage` from the turn's `stepFinish`,
22
+ on the direct channel and on the Copilot stream alike. A turn that reported none has no
23
+ `usage`.
24
+ - A usage value the SDK cannot read is dropped, never an error: counts must be non-negative
25
+ integers and costs finite numbers, an invalid field is lost alone, a `requests` item with
26
+ nothing readable leaves the list, and a usage without valid `inputTokens` and `outputTokens`
27
+ is dropped whole. The message page and the turn go on.
28
+
5
29
  ## 0.2.10-beta.0
6
30
 
7
31
  - `agentCredentials.usage(provider, { scope })` reads the last subscription reading a chat on that
package/README.md CHANGED
@@ -84,6 +84,24 @@ reconnection and reconciles persisted messages; live deltas across that gap are
84
84
  be lossless. Abort and timeout stop the local `sendAndWait` waiter but do not interrupt the remote
85
85
  turn. Use `cancel()` when interruption is intended.
86
86
 
87
+ **Turn usage.** `turnEnd` and the result of `sendAndWait` carry `usage` (`AgentTurnUsage`) when
88
+ the turn's `stepFinish` reported it, on the direct channel and on the Copilot stream alike. The
89
+ Agent message that closed a turn carries the same object as `usage` in `listMessages`, and
90
+ `loadHistory` keeps it on that `agent` item. `inputTokens` and `outputTokens` are always there;
91
+ `reasoningTokens`, `cacheReadTokens`, `cacheCreationTokens`, `model`, `provider`, `costUsd`
92
+ (this turn, USD), `costUsdRaw` (the provider session so far) and `costSource` only when the
93
+ harness reports them (Codex sends no cost and no cache writes). `inputTokens` is the input
94
+ without cache, as in the legacy platform; cache is counted apart in `cacheReadTokens` and
95
+ `cacheCreationTokens`. Also optional: `requestCount` and `requests` (`AgentTurnUsageRequest`,
96
+ one entry per provider call or per model), `durationMs` (the provider's time, sent by the box
97
+ in `stepFinish`, so it shows in the live `turnEnd` and in the history), and `authMode`
98
+ (`subscription`, `api_key`, `included_ai`, `custom`, `unknown`, or a newer string passed
99
+ through as is) and `requestMessageId`, which only the Copilot's record has: they show in
100
+ `listMessages`, `loadHistory` and a recovered turn, never in the live `turnEnd`. A turn or
101
+ message without usage has no `usage` field. A value the SDK cannot read is dropped rather than
102
+ failing the page or the turn: counts must be non-negative integers, costs finite numbers, and
103
+ a bad `requests` item leaves the list.
104
+
87
105
  ### Direct channel
88
106
 
89
107
  The direct channel is on when the concrete SDK passes `directChannel.apiUrl`, and it serves a
@@ -24,6 +24,16 @@ publishes.
24
24
 
25
25
  ## Versions
26
26
 
27
+ - `0.2.11` is the stable release of the `0.2.11-beta.0` surface: the agent turn usage in
28
+ `AgentTurnUsage` on `AgentMessage.usage`, on the `agent` item of `loadHistory` and on `turnEnd`
29
+ and `sendAndWait`. Same parity cases; the version exists so a consumer pinning the stable package
30
+ can pin a corpus with the same number.
31
+
32
+ - `0.2.11-beta.0` is the `0.2.10` parity surface republished with the agent turn usage:
33
+ `AgentTurnUsage` on `AgentMessage.usage`, on the `agent` item of `loadHistory` and on `turnEnd`
34
+ and `sendAndWait`, which the parity cases do not cover. Same parity cases; the version exists so
35
+ a consumer pinning the package can pin a corpus with the same number.
36
+
27
37
  - `0.2.10` is the stable release of the `0.2.10-beta.0` surface: the subscription usage in
28
38
  `agentCredentials.usage`, `agentConnections.usage` and the `providerUsage` session event. Same
29
39
  parity cases; the version exists so a consumer pinning the stable package can pin a corpus with
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contract": "SDK-PARITY-001",
3
- "current": "0.2.10",
3
+ "current": "0.2.11",
4
4
  "versions": [
5
5
  {
6
6
  "version": "0.1.0",
@@ -95,6 +95,16 @@
95
95
  "version": "0.2.10",
96
96
  "path": "v0.2.10/sdk-parity.json",
97
97
  "sha256": "03cb5b6943cd092d8620e5f96bdb0ba8cc3aa182417bcadb388ea6f2f9d76a33"
98
+ },
99
+ {
100
+ "version": "0.2.11-beta.0",
101
+ "path": "v0.2.11-beta.0/sdk-parity.json",
102
+ "sha256": "37f39080f5403d829bd08eba832ec6f5a3916b650e21f7f4a2fa6030f352bde5"
103
+ },
104
+ {
105
+ "version": "0.2.11",
106
+ "path": "v0.2.11/sdk-parity.json",
107
+ "sha256": "36cdb3f4198079b700022b70e03d9fe75b855ec222f23b3832f25e714650ea7f"
98
108
  }
99
109
  ]
100
110
  }