@uxnan/shared 0.0.21-alpha.20260927 → 0.0.23-alpha.20260927

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 CHANGED
@@ -13,7 +13,7 @@ equivalents (see
13
13
  [`architecture/02b-contracts-and-requirements.md`](../architecture/02b-contracts-and-requirements.md)
14
14
  §1 for the canonical contract list).
15
15
 
16
- > **Status:** implemented and stable — **84 JSON-RPC methods** + **22 streaming
16
+ > **Status:** implemented and stable — **93 JSON-RPC methods** + **24 streaming
17
17
  > notifications**, kept lock-step at build time with the `METHOD_NAMES` array and
18
18
  > the `StreamNotification` enum (a compile-time assertion in
19
19
  > `src/jsonrpc/method-registry.ts` fails the build on any drift). Changes are
@@ -49,14 +49,15 @@ flowchart TB
49
49
 
50
50
  | Area | Exports |
51
51
  |---|---|
52
- | JSON-RPC | envelope types + constructors (`makeRequest`, `makeNotification`, `makeResponse`, `makeErrorResponse`), error codes (`JsonRpcErrorCode` + Uxnan-specific `-32000..-32009`), `RpcError`, typed method registry (`JsonRpcMethodRegistry` + `METHOD_NAMES`), `isKnownMethod` |
52
+ | JSON-RPC | envelope types + constructors (`makeRequest`, `makeNotification`, `makeResponse`, `makeErrorResponse`), error codes (`JsonRpcErrorCode` + Uxnan-specific `-32000..-32010`), `RpcError`, typed method registry (`JsonRpcMethodRegistry` + `METHOD_NAMES`), `isKnownMethod` |
53
53
  | Streaming | `StreamNotification` enum + param types (`TurnStartedParams`, `MessageDeltaParams`, `ThinkingDeltaParams`, `ContentBlockParams`, `TurnCompletedParams`, `TurnUsage`, `TurnErrorParams`, `TurnAbortedParams`, `ModelResolvedParams`, and the multi-client set: `ThreadUpdatedParams`, `ThreadDeletedParams`, `TurnCreatedParams`, `ApprovalResolvedParams`, `QuestionResolvedParams`) |
54
54
  | Local control | the loopback channel Uxnan Desktop uses on the bridge's machine: `LOCAL_CONTROL_FILE` / `LOCAL_CONTROL_PATH`, `LocalControlDiscovery`, the `LocalControlFrame` union (`hello` + `message`), `isValidLocalClientId`, `localReceiverId` (architecture/02a §5.8.15) |
55
55
  | Replica sync | `sync/changes` (`SyncChanges`: revisioned threads, projects, settings, deletions, presence), `BridgeSettings { home }`, `ClientPresence`, `Project` registry fields, `Turn.seq`, `Thread.origin` (`src/models/sync.ts`, architecture/02a §5.8.17) |
56
56
  | Agent locations | `agent-locations.json` (package root) + `locateAgent` / `agentLocation`: where every agent CLI installs — the one table the bridge and Uxnan Desktop resolve from |
57
57
  | E2EE | handshake messages (`clientHello` / `serverHello` / `clientAuth` / `ready`), `buildHandshakeTranscript`, `SecureEnvelope`, `PairingPayload` v2 (`relay` optional + `hosts: string[]`) with `Base64(utf8(JSON))` QR encoding |
58
58
  | Models | thread / turn / message (with `MessageContent` polymorphic blocks), durable `CompactionContentBlock` and `AssistantResponseBoundaryBlock`, git, workspace (incl. `browseDirs` + `exists`), project, auth, session/trust (`BridgeStatus` incl. `latestVersion?`/`updateAvailable?`), bridge-owned profile metrics (complete-ledger export/import), approval, question (interactive multiple-choice) |
59
- | Agents | `IAgentAdapter` (with `respondApproval`, `listModels`, `nativeSessionId`, `SendTurnOptions { threadId, turnId, text, service?, effort?, options?, attachments?, cwd?, accessMode? }`), `AgentModel` (incl. `version?`, `isDefault?`, `options?`, `contextWindow?`, `isLatestAlias?`), `AgentCapabilities` (incl. `images`, `approvals`, `reportsContextUsage`, `reportsCompaction`), `AgentDescriptor.deprecated`, `AgentConfig` (cwd, agentId, model, plus optional `binaryPath`/`extraArgs`) |
59
+ | Agent sessions | `agent/sessions` · `holds` · `hold` · `release` · `requestHandoff` · `handoffAnswer` (`AgentSessionSummary`, `AgentSessionHold`, hand-off outcomes), `stream/agent/held` / `handoffRequested`, `SessionHeld` (`-32010`), `ONE_SHOT_PROMPT_OPENERS` / `isOneShotPrompt` (`src/models/agent-session.ts`, `src/agents/one-shot.ts`, architecture/02a §5.8.19) |
60
+ | Agents | `IAgentAdapter` (with `respondApproval`, `listModels`, `nativeSessionId`, `adoptNativeSession`, `listNativeSessions` → `NativeSessionInfo`, `SendTurnOptions { threadId, turnId, text, service?, effort?, options?, attachments?, cwd?, accessMode? }`), `AgentModel` (incl. `version?`, `isDefault?`, `options?`, `contextWindow?`, `isLatestAlias?`), `AgentCapabilities` (incl. `images`, `approvals`, `reportsContextUsage`, `reportsCompaction`), `AgentDescriptor.deprecated`, `AgentConfig` (cwd, agentId, model, plus optional `binaryPath`/`extraArgs`) |
60
61
  | Version | `compareVersions` / `isNewerVersion` — dependency-free SemVer precedence (used by the bridge's npm update check) |
61
62
  | Validation | Ajv validators for requests, responses, envelopes, pairing payload, push payloads |
62
63
 
@@ -85,6 +85,26 @@ export interface GenerateTitleOptions {
85
85
  /** Working directory to run the one-shot in (the thread's own). */
86
86
  cwd?: string;
87
87
  }
88
+ /**
89
+ * One of the agent's own sessions in a folder, as its CLI keeps it — the raw
90
+ * material of `agent/sessions` (the bridge turns the time into an age and
91
+ * links the conversation that continues it).
92
+ */
93
+ export interface NativeSessionInfo {
94
+ sessionId: string;
95
+ cwd: string;
96
+ /** The CLI's own title for it, else the first thing the person asked. */
97
+ title?: string;
98
+ /** When it last changed, on this PC's clock (epoch ms). */
99
+ updatedAt: number;
100
+ /**
101
+ * Started by a person in the agent's own interface (its terminal UI or
102
+ * app), rather than run headless by a program — the bridge's own runs, or
103
+ * one-shots like naming a conversation. A headless session is listed only
104
+ * when a conversation continues it.
105
+ */
106
+ interactive: boolean;
107
+ }
88
108
  export interface IAgentAdapter {
89
109
  readonly agentId: AgentId;
90
110
  readonly capabilities: AgentCapabilities;
@@ -96,6 +116,33 @@ export interface IAgentAdapter {
96
116
  sendTurn(options: SendTurnOptions): Promise<void>;
97
117
  /** Cancel an in-flight turn. */
98
118
  cancelTurn(threadId: string, turnId: string): Promise<void>;
119
+ /**
120
+ * The agent's own session id for a conversation — the id its CLI resumes
121
+ * (`claude --resume`, Codex `thread/resume`, ACP `session/load`, …) and the
122
+ * one its transcript on disk is named after. `undefined` until the agent
123
+ * has one for the thread.
124
+ */
125
+ nativeSessionId(threadId: string): string | undefined;
126
+ /**
127
+ * Continue a conversation in a native session this process did not open:
128
+ * the id the bridge stored before it restarted, or a session started
129
+ * elsewhere (a terminal) that the conversation now takes over. The next
130
+ * turn resumes it instead of opening a new one, so the agent keeps the
131
+ * context the user can see.
132
+ *
133
+ * Never replaces a session the adapter already holds for the thread, and
134
+ * never takes back an id the CLI already refused to resume for it: that
135
+ * conversation continues in the fresh session that replaced it.
136
+ */
137
+ adoptNativeSession(threadId: string, sessionId: string): void;
138
+ /**
139
+ * The agent's sessions in a folder, most recent first, read the way this
140
+ * CLI exposes them (its app-server, its server, ACP `session/list`, or its
141
+ * own session store — head and tail only, never whole transcripts).
142
+ * Optional: an agent whose CLI cannot list its sessions (Antigravity) omits
143
+ * it, and its sessions are continued only from the terminal they run in.
144
+ */
145
+ listNativeSessions?(cwd: string): Promise<NativeSessionInfo[]>;
99
146
  /**
100
147
  * Name a conversation from its opening exchange — a handful of words, no
101
148
  * punctuation, in the language the user wrote in.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Uxnan's own one-shot prompts: the short headless runs it makes through an
3
+ * agent's CLI to name a conversation or write a commit message or a pull
4
+ * request body. They are errands, not conversations — but a CLI that cannot
5
+ * run without keeping a session (OpenCode, Grok, Zero, Antigravity; Claude
6
+ * Code, Codex and pi run them without one) keeps them in its history like any
7
+ * other session. The session catalog (`agent/sessions`) leaves them out by
8
+ * how they open.
9
+ *
10
+ * Every producer's test checks its prompt opens with one of these, so a
11
+ * reworded prompt cannot leak back into the list: the bridge's
12
+ * (`agents/thread-title.ts`) and the desktop's (`convtitle.rs`, `aicommit.rs`).
13
+ */
14
+ export declare const ONE_SHOT_PROMPT_OPENERS: readonly ["Name this conversation in 3 to 6 words", "Below is an excerpt of a terminal session with a coding agent.", "Write a git commit message for the following staged changes.", "Write a GitHub pull request description in Markdown"];
15
+ /** Whether a session's first prompt is one of Uxnan's own one-shots. */
16
+ export declare function isOneShotPrompt(prompt: string): boolean;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Uxnan's own one-shot prompts: the short headless runs it makes through an
3
+ * agent's CLI to name a conversation or write a commit message or a pull
4
+ * request body. They are errands, not conversations — but a CLI that cannot
5
+ * run without keeping a session (OpenCode, Grok, Zero, Antigravity; Claude
6
+ * Code, Codex and pi run them without one) keeps them in its history like any
7
+ * other session. The session catalog (`agent/sessions`) leaves them out by
8
+ * how they open.
9
+ *
10
+ * Every producer's test checks its prompt opens with one of these, so a
11
+ * reworded prompt cannot leak back into the list: the bridge's
12
+ * (`agents/thread-title.ts`) and the desktop's (`convtitle.rs`, `aicommit.rs`).
13
+ */
14
+ export const ONE_SHOT_PROMPT_OPENERS = [
15
+ // Naming a chat (the bridge).
16
+ 'Name this conversation in 3 to 6 words',
17
+ // Naming a terminal session (the desktop).
18
+ 'Below is an excerpt of a terminal session with a coding agent.',
19
+ // A commit message (the desktop).
20
+ 'Write a git commit message for the following staged changes.',
21
+ // A pull request body (the desktop).
22
+ 'Write a GitHub pull request description in Markdown',
23
+ ];
24
+ /** Whether a session's first prompt is one of Uxnan's own one-shots. */
25
+ export function isOneShotPrompt(prompt) {
26
+ const text = prompt.trimStart();
27
+ return ONE_SHOT_PROMPT_OPENERS.some((opener) => text.startsWith(opener));
28
+ }
29
+ //# sourceMappingURL=one-shot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-shot.js","sourceRoot":"","sources":["../../../src/agents/one-shot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,8BAA8B;IAC9B,wCAAwC;IACxC,2CAA2C;IAC3C,gEAAgE;IAChE,kCAAkC;IAClC,8DAA8D;IAC9D,qCAAqC;IACrC,qDAAqD;CAC7C,CAAC;AAEX,wEAAwE;AACxE,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAChC,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC"}
@@ -15,6 +15,7 @@ export * from './agents/agent-capabilities.js';
15
15
  export * from './agents/agent-config.js';
16
16
  export * from './agents/agent-adapter.js';
17
17
  export * from './agents/agent-locations.js';
18
+ export * from './agents/one-shot.js';
18
19
  export * from './local-control/local-control.js';
19
20
  export * from './version/compare.js';
20
21
  export * from './notifications/push-payload.js';
@@ -31,5 +32,6 @@ export * from './models/assistant-response.js';
31
32
  export * from './models/tool.js';
32
33
  export * from './models/usage.js';
33
34
  export * from './models/metrics.js';
35
+ export * from './models/agent-session.js';
34
36
  export * from './validators/validate.js';
35
37
  export * from './validators/json-schema/schemas.js';
package/dist/src/index.js CHANGED
@@ -18,6 +18,7 @@ export * from './agents/agent-capabilities.js';
18
18
  export * from './agents/agent-config.js';
19
19
  export * from './agents/agent-adapter.js';
20
20
  export * from './agents/agent-locations.js';
21
+ export * from './agents/one-shot.js';
21
22
  // Local control channel (desktop ↔ bridge on the same machine)
22
23
  export * from './local-control/local-control.js';
23
24
  // Version
@@ -38,6 +39,7 @@ export * from './models/assistant-response.js';
38
39
  export * from './models/tool.js';
39
40
  export * from './models/usage.js';
40
41
  export * from './models/metrics.js';
42
+ export * from './models/agent-session.js';
41
43
  // Validators
42
44
  export * from './validators/validate.js';
43
45
  export * from './validators/json-schema/schemas.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAE/B,WAAW;AACX,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAE3C,OAAO;AACP,cAAc,qBAAqB,CAA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,cAAc,kCAAkC,CAAC;AAEjD,UAAU;AACV,cAAc,sBAAsB,CAAC;AAErC,gBAAgB;AAChB,cAAc,iCAAiC,CAAC;AAEhD,SAAS;AACT,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAE1C,aAAa;AACb,cAAc,0BAA0B,CAAC;AACzC,cAAc,qCAAqC,CAAC"}
@@ -25,6 +25,12 @@ export declare const JsonRpcErrorCode: {
25
25
  * explicit opt-out — the default is to queue.
26
26
  */
27
27
  readonly AgentBusy: -32009;
28
+ /**
29
+ * The conversation's agent session is open in a desktop terminal
30
+ * (`agent/hold`): the bridge runs no turn in it until the terminal
31
+ * lets it go. `data` carries the {@link AgentSessionHold}.
32
+ */
33
+ readonly SessionHeld: -32010;
28
34
  };
29
35
  export type JsonRpcErrorCode = (typeof JsonRpcErrorCode)[keyof typeof JsonRpcErrorCode];
30
36
  /** Human-readable default messages for each error code. */
@@ -27,6 +27,12 @@ export const JsonRpcErrorCode = {
27
27
  * explicit opt-out — the default is to queue.
28
28
  */
29
29
  AgentBusy: -32009,
30
+ /**
31
+ * The conversation's agent session is open in a desktop terminal
32
+ * (`agent/hold`): the bridge runs no turn in it until the terminal
33
+ * lets it go. `data` carries the {@link AgentSessionHold}.
34
+ */
35
+ SessionHeld: -32010,
30
36
  };
31
37
  /** Human-readable default messages for each error code. */
32
38
  export const JSON_RPC_ERROR_MESSAGES = {
@@ -45,6 +51,7 @@ export const JSON_RPC_ERROR_MESSAGES = {
45
51
  [JsonRpcErrorCode.ConfirmationRequired]: 'Confirmation required',
46
52
  [JsonRpcErrorCode.ResourceNotFound]: 'Resource not found',
47
53
  [JsonRpcErrorCode.AgentBusy]: 'Agent busy',
54
+ [JsonRpcErrorCode.SessionHeld]: 'Session open in a terminal',
48
55
  };
49
56
  /**
50
57
  * Error carrying a JSON-RPC error code, so handlers can throw a typed error
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/jsonrpc/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,wBAAwB;IACxB,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;IACrB,iBAAiB;IACjB,WAAW,EAAE,CAAC,KAAK;IACnB,sBAAsB,EAAE,CAAC,KAAK;IAC9B,eAAe,EAAE,CAAC,KAAK;IACvB,kBAAkB,EAAE,CAAC,KAAK;IAC1B,qBAAqB,EAAE,CAAC,KAAK;IAC7B,yBAAyB,EAAE,CAAC,KAAK;IACjC,cAAc,EAAE,CAAC,KAAK;IACtB,oBAAoB,EAAE,CAAC,KAAK;IAC5B,gBAAgB,EAAE,CAAC,KAAK;IACxB;;;;OAIG;IACH,SAAS,EAAE,CAAC,KAAK;CACT,CAAC;AAIX,2DAA2D;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC5C,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACpD,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,kBAAkB;IACrD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAClD,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAg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,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IAED,aAAa;QACX,MAAM,GAAG,GAAuB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3E,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAc;QAClC,OAAO,IAAI,QAAQ,CAAC,gBAAgB,CAAC,cAAc,EAAE,qBAAqB,MAAM,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAAe,EAAE,IAAc;QAClD,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACxE,OAAO,IAAI,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -3,5 +3,5 @@
3
3
  * compile-time {@link JsonRpcMethodRegistry} via the assertion below.
4
4
  */
5
5
  import type { JsonRpcMethodName } from './methods.js';
6
- export declare const METHOD_NAMES: readonly ["thread/list", "thread/read", "thread/start", "thread/resume", "thread/fork", "thread/setModel", "thread/rename", "thread/setAccessMode", "thread/archive", "thread/unarchive", "thread/delete", "turn/list", "turn/read", "turn/send", "turn/cancel", "turn/attachment", "queue/resume", "queue/clear", "git/status", "git/diff", "git/commit", "git/push", "git/pull", "git/checkout", "git/createBranch", "git/createWorktree", "git/stage", "git/unstage", "git/discard", "git/createPr", "git/undoCommit", "git/branches", "git/switchBranch", "git/revert", "git/deleteBranch", "git/removeWorktree", "git/worktrees", "git/log", "git/commitShow", "workspace/readFile", "workspace/readImage", "workspace/list", "workspace/searchFiles", "workspace/resolveFileLink", "workspace/browseDirs", "workspace/checkpoint", "workspace/diffCheckpoint", "workspace/applyCheckpoint", "workspace/applyPatch", "workspace/exists", "project/list", "project/resolve", "project/add", "project/remove", "project/rename", "sync/changes", "settings/get", "settings/set", "device/describe", "device/rename", "agent/list", "agent/models", "agent/commands", "agent/usageStats", "agent/doctor", "metrics/get", "metrics/export", "metrics/import", "auth/status", "auth/login", "auth/logout", "notifications/register", "notifications/update", "notifications/unregister", "bridge/status", "bridge/generatePairingQr", "bridge/connectedPhones", "bridge/disconnectPhone", "bridge/trustedDevices", "bridge/removeTrustedDevice", "bridge/update", "bridge/checkForUpdate", "desktop/attach", "desktop/detach"];
6
+ export declare const METHOD_NAMES: readonly ["thread/list", "thread/read", "thread/start", "thread/resume", "thread/fork", "thread/setModel", "thread/rename", "thread/setAccessMode", "thread/archive", "thread/unarchive", "thread/delete", "turn/list", "turn/read", "turn/send", "turn/cancel", "turn/attachment", "queue/resume", "queue/clear", "queue/sendNow", "git/status", "git/diff", "git/commit", "git/push", "git/pull", "git/checkout", "git/createBranch", "git/createWorktree", "git/stage", "git/unstage", "git/discard", "git/createPr", "git/undoCommit", "git/branches", "git/switchBranch", "git/revert", "git/deleteBranch", "git/removeWorktree", "git/worktrees", "git/log", "git/commitShow", "workspace/readFile", "workspace/readImage", "workspace/list", "workspace/searchFiles", "workspace/resolveFileLink", "workspace/browseDirs", "workspace/checkpoint", "workspace/diffCheckpoint", "workspace/applyCheckpoint", "workspace/applyPatch", "workspace/exists", "project/list", "project/resolve", "project/add", "project/remove", "project/rename", "sync/changes", "settings/get", "settings/set", "device/describe", "device/rename", "agent/list", "agent/models", "agent/commands", "agent/usageStats", "usage/redeemReset", "usage/summary", "agent/sessions", "agent/holds", "agent/hold", "agent/release", "agent/requestHandoff", "agent/handoffAnswer", "agent/doctor", "metrics/get", "metrics/export", "metrics/import", "auth/status", "auth/login", "auth/logout", "notifications/register", "notifications/update", "notifications/unregister", "bridge/status", "bridge/generatePairingQr", "bridge/connectedPhones", "bridge/disconnectPhone", "bridge/trustedDevices", "bridge/removeTrustedDevice", "bridge/update", "bridge/checkForUpdate", "desktop/attach", "desktop/detach"];
7
7
  export declare function isKnownMethod(method: string): method is JsonRpcMethodName;
@@ -19,6 +19,7 @@ export const METHOD_NAMES = [
19
19
  // Message queue
20
20
  'queue/resume',
21
21
  'queue/clear',
22
+ 'queue/sendNow',
22
23
  // Git
23
24
  'git/status',
24
25
  'git/diff',
@@ -70,6 +71,15 @@ export const METHOD_NAMES = [
70
71
  'agent/models',
71
72
  'agent/commands',
72
73
  'agent/usageStats',
74
+ 'usage/redeemReset',
75
+ 'usage/summary',
76
+ // Agent sessions
77
+ 'agent/sessions',
78
+ 'agent/holds',
79
+ 'agent/hold',
80
+ 'agent/release',
81
+ 'agent/requestHandoff',
82
+ 'agent/handoffAnswer',
73
83
  'agent/doctor',
74
84
  // Metrics (bridge-owned, survivable profile stats + tamper-proof backup)
75
85
  'metrics/get',
@@ -1 +1 @@
1
- {"version":3,"file":"method-registry.js","sourceRoot":"","sources":["../../../src/jsonrpc/method-registry.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,aAAa;IACb,aAAa;IACb,cAAc;IACd,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf,sBAAsB;IACtB,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,WAAW;IACX,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,MAAM;IACN,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,UAAU;IACV,UAAU;IACV,cAAc;IACd,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,aAAa;IACb,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,kBAAkB;IAClB,oBAAoB;IACpB,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,gBAAgB;IAChB,uBAAuB;IACvB,2BAA2B;IAC3B,sBAAsB;IACtB,sBAAsB;IACtB,0BAA0B;IAC1B,2BAA2B;IAC3B,sBAAsB;IACtB,kBAAkB;IAClB,WAAW;IACX,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,mCAAmC;IACnC,cAAc;IACd,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,eAAe;IACf,SAAS;IACT,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,yEAAyE;IACzE,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,OAAO;IACP,aAAa;IACb,YAAY;IACZ,aAAa;IACb,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;IACtB,0BAA0B;IAC1B,iBAAiB;IACjB,eAAe;IACf,0BAA0B;IAC1B,wBAAwB;IACxB,wBAAwB;IACxB,uBAAuB;IACvB,4BAA4B;IAC5B,eAAe;IACf,uBAAuB;IACvB,mEAAmE;IACnE,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAQX,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,KAAK,sBAAsB,CAAC;AAC5B,KAAK,sBAAsB,CAAC;AAE5B,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;AAEnE,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"method-registry.js","sourceRoot":"","sources":["../../../src/jsonrpc/method-registry.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,kBAAkB;IAClB,aAAa;IACb,aAAa;IACb,cAAc;IACd,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,eAA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AmE;IACnE,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAQX,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,MAAM,sBAAsB,GAAqB,IAAI,CAAC;AACtD,KAAK,sBAAsB,CAAC;AAC5B,KAAK,sBAAsB,CAAC;AAE5B,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;AAEnE,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * Source: architecture/02b-contracts-and-requirements.md and
6
6
  * uxnandesktop/architecture/02e-bridge-integration.md §4.4.
7
7
  */
8
+ import type { AgentSessionHandoffAnswerParams, AgentSessionHandoffResult, AgentSessionHold, AgentSessionHoldParams, AgentSessionHoldsResult, AgentSessionKey, AgentSessionListParams, AgentSessionListResult } from '../models/agent-session.js';
8
9
  import type { AccessMode, QueuePausedReason, Thread, ThreadList, Turn, TurnList } from '../models/thread.js';
9
10
  import type { GitBranchList, GitBranchResult, GitCommitDetails, GitCommitResult, GitCommitShowParams, GitDiff, GitLogParams, GitLogResult, GitPrResult, GitPullResult, GitPushResult, GitRepoStatus, GitWorktreeList, GitWorktreeResult } from '../models/git.js';
10
11
  import type { ApplyResult, BrowseResult, Checkpoint, CheckpointDiff, FileContent, ImageContent, PatchChange, TurnAttachment, WorkspaceFileTarget, WorkspaceExistsResult, WorkspaceListing, SearchFilesParams, WorkspaceSearchResult } from '../models/workspace.js';
@@ -15,7 +16,7 @@ import type { QuestionResponse } from '../models/question.js';
15
16
  import type { BridgeStatus, BridgeUpdate, ConnectedPhone, DeviceDescribeParams, DeviceDescription, DeviceRenameParams, TrustedDevice } from '../models/session.js';
16
17
  import type { PairingPayload } from '../e2ee/pairing-payload.js';
17
18
  import type { AgentCommand, AgentCommandInvocation, AgentDescriptor, AgentDiagnosis, AgentId, AgentModel } from '../agents/agent-capabilities.js';
18
- import type { UsageStatsParams, UsageStatsResult } from '../models/usage.js';
19
+ import type { ProviderUsage, UsageRedeemResetParams, UsageStatsParams, UsageStatsResult, UsageSummary, UsageSummaryParams } from '../models/usage.js';
19
20
  import type { MetricsExportParams, MetricsExportResult, MetricsImportParams, MetricsImportResult, MetricsSnapshot } from '../models/metrics.js';
20
21
  import type { PushPlatform } from '../notifications/push-payload.js';
21
22
  import type { DesktopAttachParams, DesktopAttachResult } from '../local-control/local-control.js';
@@ -31,6 +32,13 @@ export interface StartThreadParams {
31
32
  model?: string;
32
33
  /** Working directory override; defaults to the project's cwd. */
33
34
  cwd?: string;
35
+ /**
36
+ * Continue this existing session of the agent (`agent/sessions`) instead
37
+ * of opening a new one: its turns become the conversation's history and the
38
+ * first turn resumes it. Requires `agentId`. When a conversation already
39
+ * continues the session, that conversation is returned instead of a second one.
40
+ */
41
+ agentSessionId?: string;
34
42
  }
35
43
  export interface ForkParams {
36
44
  threadId: string;
@@ -451,6 +459,19 @@ export interface JsonRpcMethodRegistry {
451
459
  };
452
460
  result: QueueStateResult;
453
461
  };
462
+ /**
463
+ * Sends one queued message now: into the running turn when its agent takes
464
+ * input mid-turn (`capabilities.steering`), else — nothing running — as the
465
+ * next turn at once, through a pause. Refused while a turn runs whose agent
466
+ * cannot take it, or the agent waits on the person's answer.
467
+ */
468
+ 'queue/sendNow': {
469
+ params: {
470
+ threadId: string;
471
+ turnId: string;
472
+ };
473
+ result: QueueStateResult;
474
+ };
454
475
  'git/status': {
455
476
  params: {
456
477
  cwd: string;
@@ -661,6 +682,40 @@ export interface JsonRpcMethodRegistry {
661
682
  params: UsageStatsParams;
662
683
  result: UsageStatsResult;
663
684
  };
685
+ /** Redeem a rate-limit reset (Codex); answers the provider's fresh usage. */
686
+ 'usage/redeemReset': {
687
+ params: UsageRedeemResetParams;
688
+ result: ProviderUsage;
689
+ };
690
+ /** Tokens and cost the agent CLIs on this PC spent, by day, agent and model. */
691
+ 'usage/summary': {
692
+ params: UsageSummaryParams;
693
+ result: UsageSummary;
694
+ };
695
+ 'agent/sessions': {
696
+ params: AgentSessionListParams;
697
+ result: AgentSessionListResult;
698
+ };
699
+ 'agent/holds': {
700
+ params: void;
701
+ result: AgentSessionHoldsResult;
702
+ };
703
+ 'agent/hold': {
704
+ params: AgentSessionHoldParams;
705
+ result: AgentSessionHold;
706
+ };
707
+ 'agent/release': {
708
+ params: AgentSessionKey;
709
+ result: void;
710
+ };
711
+ 'agent/requestHandoff': {
712
+ params: AgentSessionKey;
713
+ result: AgentSessionHandoffResult;
714
+ };
715
+ 'agent/handoffAnswer': {
716
+ params: AgentSessionHandoffAnswerParams;
717
+ result: void;
718
+ };
664
719
  'agent/doctor': {
665
720
  params: void;
666
721
  result: {
@@ -67,6 +67,16 @@ export declare const StreamNotification: {
67
67
  * would answer now (idempotent).
68
68
  */
69
69
  readonly BridgeUpdated: "stream/bridge/updated";
70
+ /**
71
+ * A session's hold changed: a desktop terminal took it, its agent started or
72
+ * stopped working, or the terminal let it go (`hold` absent).
73
+ */
74
+ readonly AgentSessionHeld: "stream/agent/held";
75
+ /**
76
+ * Someone asked the holding desktop to let a session go (sent to that
77
+ * desktop only); it answers with `agent/handoffAnswer`.
78
+ */
79
+ readonly AgentSessionHandoffRequested: "stream/agent/handoffRequested";
70
80
  };
71
81
  export type StreamNotification = (typeof StreamNotification)[keyof typeof StreamNotification];
72
82
  export interface TurnStartedParams {
@@ -50,5 +50,15 @@ export const StreamNotification = {
50
50
  * would answer now (idempotent).
51
51
  */
52
52
  BridgeUpdated: 'stream/bridge/updated',
53
+ /**
54
+ * A session's hold changed: a desktop terminal took it, its agent started or
55
+ * stopped working, or the terminal let it go (`hold` absent).
56
+ */
57
+ AgentSessionHeld: 'stream/agent/held',
58
+ /**
59
+ * Someone asked the holding desktop to let a session go (sent to that
60
+ * desktop only); it answers with `agent/handoffAnswer`.
61
+ */
62
+ AgentSessionHandoffRequested: 'stream/agent/handoffRequested',
53
63
  };
54
64
  //# sourceMappingURL=notifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/jsonrpc/notifications.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,qBAAqB;IAClC,YAAY,EAAE,sBAAsB;IACpC,kFAAkF;IAClF,aAAa,EAAE,uBAAuB;IACtC,mFAAmF;IACnF,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;IACtC,SAAS,EAAE,mBAAmB;IAC9B,WAAW,EAAE,qBAAqB;IAClC,2EAA2E;IAC3E,aAAa,EAAE,uBAAuB;IACtC,+EAA+E;IAC/E,YAAY,EAAE,sBAAsB;IACpC,sFAAsF;IACtF,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,uBAAuB;IACtC,4BAA4B;IAC5B,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,WAAW,EAAE,qBAAqB;IAClC,oEAAoE;IACpE,gBAAgB,EAAE,0BAA0B;IAC5C,6EAA6E;IAC7E,gBAAgB,EAAE,0BAA0B;IAC5C,qDAAqD;IACrD,cAAc,EAAE,wBAAwB;IACxC,wEAAwE;IACxE,cAAc,EAAE,wBAAwB;IACxC,yEAAyE;IACzE,eAAe,EAAE,yBAAyB;IAC1C,0CAA0C;IAC1C,eAAe,EAAE,yBAAyB;IAC1C,uDAAuD;IACvD,cAAc,EAAE,wBAAwB;IACxC,qEAAqE;IACrE,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,uBAAuB;CAC9B,CAAC"}
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/jsonrpc/notifications.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,WAAW,EAAE,qBAAqB;IAClC,YAAY,EAAE,sBAAsB;IACpC,kFAAkF;IAClF,aAAa,EAAE,uBAAuB;IACtC,mFAAmF;IACnF,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;IACtC,SAAS,EAAE,mBAAmB;IAC9B,WAAW,EAAE,qBAAqB;IAClC,2EAA2E;IAC3E,aAAa,EAAE,uBAAuB;IACtC,+EAA+E;IAC/E,YAAY,EAAE,sBAAsB;IACpC,sFAAsF;IACtF,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,uBAAuB;IACtC,4BAA4B;IAC5B,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,WAAW,EAAE,qBAAqB;IAClC,oEAAoE;IACpE,gBAAgB,EAAE,0BAA0B;IAC5C,6EAA6E;IAC7E,gBAAgB,EAAE,0BAA0B;IAC5C,qDAAqD;IACrD,cAAc,EAAE,wBAAwB;IACxC,wEAAwE;IACxE,cAAc,EAAE,wBAAwB;IACxC,yEAAyE;IACzE,eAAe,EAAE,yBAAyB;IAC1C,0CAA0C;IAC1C,eAAe,EAAE,yBAAyB;IAC1C,uDAAuD;IACvD,cAAc,EAAE,wBAAwB;IACxC,qEAAqE;IACrE,aAAa,EAAE,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,uBAAuB;IACtC;;;OAGG;IACH,gBAAgB,EAAE,mBAAmB;IACrC;;;OAGG;IACH,4BAA4B,EAAE,+BAA+B;CACrD,CAAC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Agent sessions: the conversations an agent CLI keeps on the PC, whoever
3
+ * started them — a terminal, the bridge, the agent's own app — and whether one
4
+ * is open in a terminal right now (architecture/02a §5.8.19).
5
+ *
6
+ * The bridge owns both: it lists each agent's sessions through that agent's
7
+ * own surface (`agent/sessions`), and it knows which ones a desktop
8
+ * terminal holds (`agent/hold`), so every client — phone, desktop — can
9
+ * pick a session up, and none of them ever writes into a session a terminal is
10
+ * running.
11
+ *
12
+ * Across devices every time is an age (`…AgoMs`), never a timestamp.
13
+ */
14
+ import type { AgentId } from '../agents/agent-capabilities.js';
15
+ /** One of an agent's sessions in a folder, as `agent/sessions` returns it. */
16
+ export interface AgentSessionSummary {
17
+ agentId: AgentId;
18
+ /** The agent's own session id — the one its CLI resumes. */
19
+ sessionId: string;
20
+ /** The folder the session runs in. */
21
+ cwd: string;
22
+ /**
23
+ * The session's name: the CLI's own title when it keeps one, else the
24
+ * first thing the person asked, trimmed. Absent when neither is known.
25
+ */
26
+ title?: string;
27
+ /** How long ago the session last changed. */
28
+ updatedAgoMs: number;
29
+ /** The conversation that continues this session, when one does. */
30
+ threadId?: string;
31
+ /** Where the session is open right now, when a terminal holds it. */
32
+ hold?: AgentSessionHold;
33
+ }
34
+ /** Who holds a session: a terminal of Uxnan Desktop, on the named PC. */
35
+ export interface AgentSessionHolder {
36
+ kind: 'terminal';
37
+ /** The PC's name, as the bridge's shared settings call it. */
38
+ name: string;
39
+ }
40
+ /**
41
+ * A session open in a desktop terminal. While it is held, the bridge runs no
42
+ * turn in it: a CLI's session has one writer, and the terminal is it.
43
+ */
44
+ export interface AgentSessionHold {
45
+ agentId: AgentId;
46
+ sessionId: string;
47
+ cwd?: string;
48
+ holder: AgentSessionHolder;
49
+ /** How long ago the terminal took it. */
50
+ heldAgoMs: number;
51
+ /** Whether the agent is working right now; a hand-off waits until it is not. */
52
+ busy: boolean;
53
+ /** The conversation that continues this session, when one does. */
54
+ threadId?: string;
55
+ }
56
+ /** Which session: an agent and its session id. */
57
+ export interface AgentSessionKey {
58
+ agentId: AgentId;
59
+ sessionId: string;
60
+ }
61
+ export interface AgentSessionListParams {
62
+ /** The folder whose sessions to list. */
63
+ cwd: string;
64
+ /** Only this agent's sessions; every agent's when absent. */
65
+ agentId?: AgentId;
66
+ }
67
+ export interface AgentSessionListResult {
68
+ /** Most recently changed first. */
69
+ sessions: AgentSessionSummary[];
70
+ /**
71
+ * Agents installed here whose CLI cannot list its sessions (Antigravity):
72
+ * one of their sessions can still be continued from the terminal it runs in.
73
+ */
74
+ unlisted: AgentId[];
75
+ }
76
+ /**
77
+ * `agent/hold` — Uxnan Desktop says one of its terminals has this
78
+ * session open (or that its agent started or stopped working). Idempotent:
79
+ * the latest call wins. Accepted only over the local control channel, and
80
+ * dropped when that connection closes (the terminals close with the app).
81
+ */
82
+ export interface AgentSessionHoldParams extends AgentSessionKey {
83
+ cwd?: string;
84
+ busy?: boolean;
85
+ }
86
+ export interface AgentSessionHoldsResult {
87
+ holds: AgentSessionHold[];
88
+ }
89
+ /**
90
+ * How asking a terminal to let go of a session ended:
91
+ * - `released`: the agent was closed in its terminal; the session is free.
92
+ * - `busy`: the agent is working; ask again when it is done.
93
+ * - `declined`: the person at the PC kept it.
94
+ * - `unreachable`: the desktop did not answer in time.
95
+ * - `notHeld`: no terminal holds it; it is free already.
96
+ */
97
+ export type AgentSessionHandoffOutcome = 'released' | 'busy' | 'declined' | 'unreachable' | 'notHeld';
98
+ export interface AgentSessionHandoffResult {
99
+ outcome: AgentSessionHandoffOutcome;
100
+ }
101
+ /** `stream/agent/handoffRequested` — sent only to the holding desktop. */
102
+ export interface AgentSessionHandoffRequestedParams extends AgentSessionKey {
103
+ /** Answer with `agent/handoffAnswer` quoting this id. */
104
+ requestId: string;
105
+ /** Who asks: the client's name (a phone's, or the PC's). */
106
+ from: string;
107
+ }
108
+ /** `agent/handoffAnswer` — the holding desktop's answer. */
109
+ export interface AgentSessionHandoffAnswerParams {
110
+ requestId: string;
111
+ outcome: Extract<AgentSessionHandoffOutcome, 'released' | 'busy' | 'declined'>;
112
+ }
113
+ /**
114
+ * `stream/agent/held` — a session's hold changed: taken, busy or idle,
115
+ * or let go (`hold` absent). Every client follows it; one that missed some
116
+ * asks `agent/holds`.
117
+ */
118
+ export interface AgentSessionHeldParams extends AgentSessionKey {
119
+ hold?: AgentSessionHold;
120
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session.js","sourceRoot":"","sources":["../../../src/models/agent-session.ts"],"names":[],"mappings":""}
@@ -7,7 +7,7 @@
7
7
  * were derived on the phone from local storage and so were lost on an app
8
8
  * uninstall (the app has no cloud login). To make them durable, the **bridge**
9
9
  * becomes the source of truth: it persists a complete activity ledger
10
- * (conversations, turns/messages, reported tokens, sessions and Git actions)
10
+ * (conversations, turns/messages, sessions and Git actions)
11
11
  * and serves it over `metrics/get`. Deleting mutable conversation history does
12
12
  * not subtract activity. The phone renders one snapshot per PC and sums PCs.
13
13
  *
@@ -16,8 +16,10 @@
16
16
  * keychain), so users cannot fabricate or edit their stats; `metrics/import`
17
17
  * feeds one back and merges its events by id (idempotent).
18
18
  *
19
- * Provider usage/credits are deliberately NOT part of this — those are read live
20
- * via `agent/usageStats` and never persisted.
19
+ * What the agents spent (tokens, cost) and provider limits are deliberately NOT
20
+ * part of this: `usage/summary` reads spend from each CLI's own history (every
21
+ * session, not only the bridge's) and `agent/usageStats` asks for limits live.
22
+ * The development `echo` agent is never counted.
21
23
  *
22
24
  * Source: architecture/02a-system-architecture.md §5.8.11 and
23
25
  * 02b-contracts-and-requirements.md.
@@ -39,19 +41,12 @@ export interface MetricsAgentDay {
39
41
  conversations: number;
40
42
  /** Messages exchanged that day in this agent's threads. */
41
43
  messages: number;
42
- /**
43
- * Tokens processed that day — the sum of each turn's reported usage (input
44
- * incl. the re-sent context + output). **Throughput, not billed cost**: caching
45
- * and input/output pricing differ (use `agent/usageStats` for money). 0 for
46
- * agents that don't report usage (e.g. Zero).
47
- */
48
- tokens: number;
49
44
  }
50
45
  /** One calendar day's activity split per agent. */
51
46
  export interface MetricsDayBreakdown {
52
47
  /** UTC-midnight epoch ms of the calendar date (same encoding as `activity`). */
53
48
  day: number;
54
- /** Per-agent activity that day (agents with any conversation/message/token). */
49
+ /** Per-agent activity that day (agents with any conversation or message). */
55
50
  byAgent: MetricsAgentDay[];
56
51
  }
57
52
  /**
@@ -112,7 +107,7 @@ export interface MetricsSnapshot {
112
107
  /** Per-day activity buckets for the contribution heatmap. */
113
108
  activity: MetricsActivityDay[];
114
109
  /**
115
- * Per-day activity split per agent (conversations, messages, tokens), for the
110
+ * Per-day activity split per agent (conversations, messages), for the
116
111
  * unified agent-activity view: the per-agent bars show all-time totals, or a
117
112
  * single day's totals when a heatmap cell is selected. See
118
113
  * {@link MetricsAgentDay}.
@@ -7,7 +7,7 @@
7
7
  * were derived on the phone from local storage and so were lost on an app
8
8
  * uninstall (the app has no cloud login). To make them durable, the **bridge**
9
9
  * becomes the source of truth: it persists a complete activity ledger
10
- * (conversations, turns/messages, reported tokens, sessions and Git actions)
10
+ * (conversations, turns/messages, sessions and Git actions)
11
11
  * and serves it over `metrics/get`. Deleting mutable conversation history does
12
12
  * not subtract activity. The phone renders one snapshot per PC and sums PCs.
13
13
  *
@@ -16,8 +16,10 @@
16
16
  * keychain), so users cannot fabricate or edit their stats; `metrics/import`
17
17
  * feeds one back and merges its events by id (idempotent).
18
18
  *
19
- * Provider usage/credits are deliberately NOT part of this — those are read live
20
- * via `agent/usageStats` and never persisted.
19
+ * What the agents spent (tokens, cost) and provider limits are deliberately NOT
20
+ * part of this: `usage/summary` reads spend from each CLI's own history (every
21
+ * session, not only the bridge's) and `agent/usageStats` asks for limits live.
22
+ * The development `echo` agent is never counted.
21
23
  *
22
24
  * Source: architecture/02a-system-architecture.md §5.8.11 and
23
25
  * 02b-contracts-and-requirements.md.
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/models/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/models/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}
@@ -225,4 +225,12 @@ export interface BridgeFeatures {
225
225
  * `Turn.seq`. Absent/false → a client keeps its older `thread/list` flow.
226
226
  */
227
227
  sync?: boolean;
228
+ /**
229
+ * The bridge lists every agent's sessions in a folder (`agent/sessions`),
230
+ * starts a conversation that continues one (`thread/start` with
231
+ * `agentSessionId`) and knows which ones a desktop terminal holds
232
+ * (`agent/holds`, `agent/hold`, …, `stream/agent/held`). Absent/false → a client
233
+ * offers none of it.
234
+ */
235
+ agentSessions?: boolean;
228
236
  }
@@ -65,22 +65,24 @@ export interface Message {
65
65
  contextWindow?: number;
66
66
  };
67
67
  /**
68
- * The images the user attached to this message, kept by the bridge with the
69
- * turn (user messages only). They are named here, not inlined — a page of
68
+ * The images and files the user attached to this message, kept by the bridge
69
+ * with the turn (user messages only). They are named here, not inlined — a page of
70
70
  * history stays small — and each client fetches the bytes it shows with
71
71
  * `turn/attachment`.
72
72
  */
73
73
  attachments?: MessageAttachment[];
74
74
  createdAt: number;
75
75
  }
76
- /** An image attached to a user message, as `turn/list` names it. */
76
+ /** An image or a file attached to a user message, as `turn/list` names it. */
77
77
  export interface MessageAttachment {
78
78
  /** Opaque id, unique in its thread; the key for `turn/attachment`. */
79
79
  id: string;
80
80
  /** MIME type, e.g. `image/png`. */
81
81
  mimeType: string;
82
- /** Size of the stored image in bytes. */
82
+ /** Size of the stored image or file in bytes. */
83
83
  bytes: number;
84
+ /** A file's name, as it was sent (absent for an image). */
85
+ name?: string;
84
86
  /** Pixel width, when the sender knew it. */
85
87
  width?: number;
86
88
  /** Pixel height, when the sender knew it. */
@@ -1,21 +1,17 @@
1
1
  /**
2
- * AI-provider usage statistics: quota/rate windows, plan/account, credit
3
- * balance and local token tallies read from a coding CLI's on-disk state — its
4
- * stored OAuth token (→ the provider's official usage API) and/or its local
5
- * session logs.
2
+ * AI-provider usage: plan limits (quota windows, plan, account, credit) and
3
+ * spend (tokens and cost by day, agent and model).
6
4
  *
7
- * Surfaced in the desktop's Settings → Providers section and, over the bridge,
8
- * on the phone. The access path is per-runtime by design (02a §5.8.10): the
9
- * desktop reads these files natively in Rust; the bridge reads them in TS so a
10
- * paired phone — which cannot see the PC's disk directly — gets the same data
11
- * over `agent/usageStats`. The Dart equivalents live in uxnanmobile and are kept
12
- * in sync manually (see 02e-bridge-integration.md §4.2).
13
- *
14
- * Posture: only the token the CLI itself stored is read — from its file, or
15
- * from the OS credential store where that is where the CLI keeps it (Claude
16
- * Code on macOS), and then only after the user has granted the OS-level
17
- * permission once (see `accessRequired`). Never browser cookies, never
18
- * user-pasted API keys, never a refresh token.
5
+ * The bridge is the one reader; every client — the phone, Uxnan Desktop's
6
+ * Providers panel — asks it (`agent/usageStats`, `usage/summary`,
7
+ * `usage/redeemReset`). Claude Code and Codex are asked themselves: each CLI
8
+ * answers for the account it is signed in to, so no credential is read and no
9
+ * OS permission is needed. Copilot and Grok have no such surface: only the
10
+ * token each CLI stored is read (`gh auth token`, `~/.grok/auth.json`) and sent
11
+ * to the provider's own usage API. Spend comes from the transcripts every
12
+ * agent CLI keeps on disk. Never browser cookies, never a pasted key, never a
13
+ * refresh token. The Dart equivalents live in uxnanmobile and are kept in sync
14
+ * manually.
19
15
  */
20
16
  /** A coding CLI whose usage we read from its own stored token. */
21
17
  export type UsageProvider = 'codex' | 'claude' | 'copilot' | 'grok';
@@ -25,18 +21,13 @@ export type UsageStatus =
25
21
  'ok'
26
22
  /** CLI is present but not signed in (no usable token). */
27
23
  | 'authRequired'
28
- /** The CLI's token exists in the OS credential store, but the OS has not yet
29
- * authorized the reader to open it. The user grants that once from the
30
- * desktop's Providers panel (the OS shows its own dialog); the reader never
31
- * prompts on its own. A phone shows "grant access on the PC". */
32
- | 'accessRequired'
33
24
  /** CLI / its config directory is not present on this machine. */
34
25
  | 'notInstalled'
35
26
  /** Read/network/parse failure — see {@link ProviderUsage.message}. */
36
27
  | 'error';
37
- /** How the data was obtained, for the UI's provenance label. Every wired
38
- * provider reads its quota from the CLI's own signed-in token. */
39
- export type UsageSource = 'token';
28
+ /** How the data was obtained: asked of the CLI itself (`cli`, Claude Code and
29
+ * Codex), or its stored token sent to the provider's usage API (`token`). */
30
+ export type UsageSource = 'cli' | 'token';
40
31
  /**
41
32
  * The kind of billing relationship, so the UI can label an account beyond its
42
33
  * plan name (e.g. distinguish a flat subscription from usage/credit billing).
@@ -94,6 +85,8 @@ export interface CreditBalance {
94
85
  */
95
86
  /** One redeemable reset — for the per-credit detail (which one, when it expires). */
96
87
  export interface ResetCreditEntry {
88
+ /** The provider's id for this reset, to redeem exactly it (`usage/redeemReset`). */
89
+ id?: string;
97
90
  /** Short label the provider gives the reset (e.g. "Full reset"). */
98
91
  title?: string;
99
92
  /** When this reset lapses (epoch ms). */
@@ -129,8 +122,7 @@ export interface ProviderUsage {
129
122
  resetCredits?: ResetCredits;
130
123
  /** When this snapshot was produced (epoch ms). */
131
124
  updatedAt: number;
132
- /** Error/hint message for `error` / `authRequired` / `accessRequired` /
133
- * `notInstalled` states. */
125
+ /** Error/hint message for `error` / `authRequired` / `notInstalled` states. */
134
126
  message?: string;
135
127
  }
136
128
  /**
@@ -144,3 +136,77 @@ export interface UsageStatsParams {
144
136
  export interface UsageStatsResult {
145
137
  usage: ProviderUsage[];
146
138
  }
139
+ /**
140
+ * `usage/redeemReset` request: redeem one of a provider's rate-limit resets
141
+ * (Codex today) — [creditId] from `ResetCredits.entries`, or the
142
+ * soonest-expiring one when absent. [idempotencyKey] names the attempt, so a
143
+ * retry after a lost answer never redeems twice.
144
+ */
145
+ export interface UsageRedeemResetParams {
146
+ provider: UsageProvider;
147
+ idempotencyKey: string;
148
+ creditId?: string;
149
+ }
150
+ /**
151
+ * `usage/summary` request: the last [days] calendar days of this PC (today
152
+ * included), 1–366.
153
+ */
154
+ export interface UsageSummaryParams {
155
+ days: number;
156
+ }
157
+ /** Tokens and cost of a set of model responses. */
158
+ export interface UsageSpend {
159
+ /** Input not read from the cache. */
160
+ inputTokens: number;
161
+ /** Input read from the cache. */
162
+ cachedInputTokens: number;
163
+ /** Input written to the cache. */
164
+ cacheWriteTokens: number;
165
+ /** Output, reasoning included. */
166
+ outputTokens: number;
167
+ /** The reasoning part of `outputTokens`, where the CLI records it. */
168
+ reasoningTokens: number;
169
+ /** US dollars: what the provider billed where the CLI records it, else the
170
+ * estimate at API prices (`estimatedCostUsd` of it). */
171
+ costUsd: number;
172
+ /** The part of `costUsd` estimated at API prices (on a subscription, what
173
+ * the same work would cost pay-as-you-go). */
174
+ estimatedCostUsd: number;
175
+ /** Tokens of responses whose model has no known price — not in `costUsd`. */
176
+ unpricedTokens: number;
177
+ /** Model responses counted. */
178
+ responses: number;
179
+ }
180
+ /** One agent + model's spend on one day. */
181
+ export interface UsageBucket extends UsageSpend {
182
+ /** Wire agent id (`claude-code`, `codex`, `pi-agent`, `grok`, `opencode`). */
183
+ agentId: string;
184
+ /** The model id as the CLI recorded it (`provider/model` where it routes). */
185
+ model: string;
186
+ }
187
+ /** One calendar day of this PC. */
188
+ export interface UsageDay {
189
+ /** `YYYY-MM-DD`, the PC's local date. */
190
+ day: string;
191
+ buckets: UsageBucket[];
192
+ }
193
+ /** What was found for one agent. */
194
+ export interface UsageAgentSource {
195
+ agentId: string;
196
+ /** Sessions with spend in the period. */
197
+ sessions: number;
198
+ /** `ok`: read (possibly nothing in the period); `unreadable`: its store
199
+ * exists but could not be read (see `message`). Agents with no store on
200
+ * this PC are not listed. */
201
+ status: 'ok' | 'unreadable';
202
+ message?: string;
203
+ }
204
+ /**
205
+ * `usage/summary` result: every model response the agent CLIs on this PC
206
+ * recorded in the period — the bridge's turns and a person's own terminal
207
+ * sessions alike — by day, agent and model. Only days with spend are listed.
208
+ */
209
+ export interface UsageSummary {
210
+ days: UsageDay[];
211
+ agents: UsageAgentSource[];
212
+ }
@@ -1,21 +1,17 @@
1
1
  /**
2
- * AI-provider usage statistics: quota/rate windows, plan/account, credit
3
- * balance and local token tallies read from a coding CLI's on-disk state — its
4
- * stored OAuth token (→ the provider's official usage API) and/or its local
5
- * session logs.
2
+ * AI-provider usage: plan limits (quota windows, plan, account, credit) and
3
+ * spend (tokens and cost by day, agent and model).
6
4
  *
7
- * Surfaced in the desktop's Settings → Providers section and, over the bridge,
8
- * on the phone. The access path is per-runtime by design (02a §5.8.10): the
9
- * desktop reads these files natively in Rust; the bridge reads them in TS so a
10
- * paired phone — which cannot see the PC's disk directly — gets the same data
11
- * over `agent/usageStats`. The Dart equivalents live in uxnanmobile and are kept
12
- * in sync manually (see 02e-bridge-integration.md §4.2).
13
- *
14
- * Posture: only the token the CLI itself stored is read — from its file, or
15
- * from the OS credential store where that is where the CLI keeps it (Claude
16
- * Code on macOS), and then only after the user has granted the OS-level
17
- * permission once (see `accessRequired`). Never browser cookies, never
18
- * user-pasted API keys, never a refresh token.
5
+ * The bridge is the one reader; every client — the phone, Uxnan Desktop's
6
+ * Providers panel — asks it (`agent/usageStats`, `usage/summary`,
7
+ * `usage/redeemReset`). Claude Code and Codex are asked themselves: each CLI
8
+ * answers for the account it is signed in to, so no credential is read and no
9
+ * OS permission is needed. Copilot and Grok have no such surface: only the
10
+ * token each CLI stored is read (`gh auth token`, `~/.grok/auth.json`) and sent
11
+ * to the provider's own usage API. Spend comes from the transcripts every
12
+ * agent CLI keeps on disk. Never browser cookies, never a pasted key, never a
13
+ * refresh token. The Dart equivalents live in uxnanmobile and are kept in sync
14
+ * manually.
19
15
  */
20
16
  export {};
21
17
  //# sourceMappingURL=usage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/models/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/models/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -26,14 +26,21 @@ export interface WorkspaceFileTarget {
26
26
  path: string;
27
27
  }
28
28
  /**
29
- * An image (or other media) attached to a user turn (`turn/send { attachments }`).
30
- * Tolerant by design — the phone sends inline base64 with the original
29
+ * An image or a file attached to a user turn (`turn/send { attachments }`).
30
+ * Tolerant by design — clients send inline base64 with the original
31
31
  * `mimeType`; `path`/`width`/`height` are best-effort metadata. At least one of
32
32
  * `base64Data`/`path` must be present for the bridge to deliver it to the agent.
33
+ * The bridge writes each one into the agent's folder for the turn and names
34
+ * it in the prompt, so every agent opens it with its own tools; a file keeps
35
+ * its `name` there. At most {@link MAX_ATTACHMENT_BYTES} each.
33
36
  */
37
+ /** The largest attachment `turn/send` takes, decoded: 20 MB. */
38
+ export declare const MAX_ATTACHMENT_BYTES: number;
34
39
  export interface TurnAttachment {
35
- /** Wire discriminator (always `image` today). */
36
- type?: 'image';
40
+ /** An image (the default), or any other file. */
41
+ type?: 'image' | 'file';
42
+ /** A file's name (no directories), kept when the agent receives it. */
43
+ name?: string;
37
44
  /** MIME type, e.g. `image/png`. */
38
45
  mimeType: string;
39
46
  /** Inline base64 payload (no `data:` URI prefix). */
@@ -3,5 +3,15 @@
3
3
  *
4
4
  * Source: architecture/02a-system-architecture.md §5.8.7.
5
5
  */
6
- export {};
6
+ /**
7
+ * An image or a file attached to a user turn (`turn/send { attachments }`).
8
+ * Tolerant by design — clients send inline base64 with the original
9
+ * `mimeType`; `path`/`width`/`height` are best-effort metadata. At least one of
10
+ * `base64Data`/`path` must be present for the bridge to deliver it to the agent.
11
+ * The bridge writes each one into the agent's folder for the turn and names
12
+ * it in the prompt, so every agent opens it with its own tools; a file keeps
13
+ * its `name` there. At most {@link MAX_ATTACHMENT_BYTES} each.
14
+ */
15
+ /** The largest attachment `turn/send` takes, decoded: 20 MB. */
16
+ export const MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
7
17
  //# sourceMappingURL=workspace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/models/workspace.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/models/workspace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH;;;;;;;;GAQG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxnan/shared",
3
- "version": "0.0.21-alpha.20260927",
3
+ "version": "0.0.23-alpha.20260927",
4
4
  "description": "Shared JSON-RPC and E2EE contracts for the Uxnan ecosystem (bridge, relay, mobile).",
5
5
  "license": "MPL-2.0",
6
6
  "author": "Luis Donaldo Gamas Vazquez",