@stelis/agent-q-core 0.0.0
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 +144 -0
- package/dist/adapter-internal.d.ts +5 -0
- package/dist/adapter-internal.js +6 -0
- package/dist/adapter-internal.js.map +1 -0
- package/dist/config.d.ts +74 -0
- package/dist/config.js +489 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts +320 -0
- package/dist/core.js +840 -0
- package/dist/core.js.map +1 -0
- package/dist/device.d.ts +55 -0
- package/dist/device.js +23 -0
- package/dist/device.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -0
- package/dist/host-output-schema.d.ts +2437 -0
- package/dist/host-output-schema.js +655 -0
- package/dist/host-output-schema.js.map +1 -0
- package/dist/protocol-error.d.ts +4 -0
- package/dist/protocol-error.js +9 -0
- package/dist/protocol-error.js.map +1 -0
- package/dist/protocol-management-primitives.d.ts +27 -0
- package/dist/protocol-management-primitives.js +51 -0
- package/dist/protocol-management-primitives.js.map +1 -0
- package/dist/protocol-primitives.d.ts +53 -0
- package/dist/protocol-primitives.js +331 -0
- package/dist/protocol-primitives.js.map +1 -0
- package/dist/protocol.d.ts +207 -0
- package/dist/protocol.js +897 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider-protocol.d.ts +262 -0
- package/dist/provider-protocol.js +637 -0
- package/dist/provider-protocol.js.map +1 -0
- package/dist/public-error.d.ts +9 -0
- package/dist/public-error.js +79 -0
- package/dist/public-error.js.map +1 -0
- package/dist/safe-text.d.ts +31 -0
- package/dist/safe-text.js +143 -0
- package/dist/safe-text.js.map +1 -0
- package/dist/transport-invariants.d.ts +18 -0
- package/dist/transport-invariants.js +24 -0
- package/dist/transport-invariants.js.map +1 -0
- package/dist/usb.d.ts +76 -0
- package/dist/usb.js +454 -0
- package/dist/usb.js.map +1 -0
- package/package.json +58 -0
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { ConfigStore, type DeviceListing } from "./config.js";
|
|
2
|
+
export { SerialPortUsbDriver } from "./usb.js";
|
|
3
|
+
import { type Account, type ApprovalHistoryRecord, type CapabilityChain, type DeviceStatusSnapshot, type IdentifyDeviceResponse, type PolicyDocument, type PolicyProposeResultResponse, type SignResultResponse, type SigningCapabilities, type StatusResponse } from "./protocol.js";
|
|
4
|
+
import { type UnavailableReason, type UsbSerialDriver } from "./usb.js";
|
|
5
|
+
export interface LiveDeviceStatus {
|
|
6
|
+
source: "live";
|
|
7
|
+
connected: true;
|
|
8
|
+
portPath: string;
|
|
9
|
+
protocolResponse: StatusResponse;
|
|
10
|
+
}
|
|
11
|
+
export interface CachedDeviceStatus {
|
|
12
|
+
source: "cached";
|
|
13
|
+
connected: false;
|
|
14
|
+
statusObservedAt: string;
|
|
15
|
+
unavailableReason: UnavailableReason;
|
|
16
|
+
firmwareErrorCode?: string;
|
|
17
|
+
cachedStatus: DeviceStatusSnapshot;
|
|
18
|
+
}
|
|
19
|
+
export type DeviceStatusResult = LiveDeviceStatus | CachedDeviceStatus;
|
|
20
|
+
export type DeviceStatusToolResult = DeviceStatusResult;
|
|
21
|
+
export interface ScanDevicesResult {
|
|
22
|
+
source: "live";
|
|
23
|
+
devices: LiveDeviceStatus[];
|
|
24
|
+
failures: ScanDeviceFailure[];
|
|
25
|
+
activeDeviceId: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface ScanDeviceFailure {
|
|
28
|
+
source: "error";
|
|
29
|
+
connected: false;
|
|
30
|
+
portPath: string;
|
|
31
|
+
unavailableReason: UnavailableReason;
|
|
32
|
+
firmwareErrorCode?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface IdentifiedDevice {
|
|
35
|
+
source: "live";
|
|
36
|
+
connected: true;
|
|
37
|
+
portPath: string;
|
|
38
|
+
status: "displayed";
|
|
39
|
+
code: string;
|
|
40
|
+
protocolResponse: IdentifyDeviceResponse;
|
|
41
|
+
}
|
|
42
|
+
export interface IdentifyDeviceFailure {
|
|
43
|
+
source: "error";
|
|
44
|
+
connected: false;
|
|
45
|
+
portPath: string;
|
|
46
|
+
deviceId: string;
|
|
47
|
+
status: "error";
|
|
48
|
+
error: {
|
|
49
|
+
code: string;
|
|
50
|
+
message: string;
|
|
51
|
+
retryable: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface IdentifyDevicesResult {
|
|
55
|
+
source: "live";
|
|
56
|
+
devices: Array<IdentifiedDevice | IdentifyDeviceFailure>;
|
|
57
|
+
activeDeviceId: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface SelectDeviceResult {
|
|
60
|
+
source: "selected";
|
|
61
|
+
activeDeviceId: string;
|
|
62
|
+
purpose: string | null;
|
|
63
|
+
device: StatusResponse["device"];
|
|
64
|
+
}
|
|
65
|
+
export interface RuntimeSessionView {
|
|
66
|
+
sessionTtlMs: number;
|
|
67
|
+
connectedAt: string;
|
|
68
|
+
}
|
|
69
|
+
export interface DeviceListEntry extends DeviceListing {
|
|
70
|
+
runtimeSession: RuntimeSessionView | null;
|
|
71
|
+
}
|
|
72
|
+
export interface DeviceListResult {
|
|
73
|
+
source: "list";
|
|
74
|
+
devices: DeviceListEntry[];
|
|
75
|
+
activeDeviceId: string | null;
|
|
76
|
+
activeDeviceIdsByPurpose: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
export interface SetDeviceMetadataResult {
|
|
79
|
+
source: "metadata";
|
|
80
|
+
deviceId: string;
|
|
81
|
+
label: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface ConnectDeviceResult {
|
|
84
|
+
source: "connected";
|
|
85
|
+
deviceId: string;
|
|
86
|
+
sessionTtlMs: number;
|
|
87
|
+
connectedAt: string;
|
|
88
|
+
device: StatusResponse["device"];
|
|
89
|
+
}
|
|
90
|
+
export declare const DISCONNECT_REASONS: readonly ["firmware_confirmed", "invalid_session", "transport_unavailable", "timeout", "not_connected"];
|
|
91
|
+
export type DisconnectReason = (typeof DISCONNECT_REASONS)[number];
|
|
92
|
+
export declare const DISCONNECT_ENDED_REASONS: readonly ["firmware_confirmed", "invalid_session", "transport_unavailable", "timeout"];
|
|
93
|
+
export type DisconnectEndedReason = (typeof DISCONNECT_ENDED_REASONS)[number];
|
|
94
|
+
export declare const GET_ACCOUNTS_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
95
|
+
export type GetAccountsSessionEndedReason = (typeof GET_ACCOUNTS_SESSION_ENDED_REASONS)[number];
|
|
96
|
+
export declare const GET_CAPABILITIES_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
97
|
+
export type GetCapabilitiesSessionEndedReason = GetAccountsSessionEndedReason;
|
|
98
|
+
export declare const POLICY_GET_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
99
|
+
export type PolicyGetSessionEndedReason = GetAccountsSessionEndedReason;
|
|
100
|
+
export declare const GET_APPROVAL_HISTORY_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
101
|
+
export type GetApprovalHistorySessionEndedReason = GetAccountsSessionEndedReason;
|
|
102
|
+
export declare const POLICY_PROPOSE_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
103
|
+
export type PolicyProposeSessionEndedReason = GetAccountsSessionEndedReason;
|
|
104
|
+
export declare const SIGN_TRANSACTION_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
105
|
+
export type SignTransactionSessionEndedReason = GetAccountsSessionEndedReason;
|
|
106
|
+
export declare const SIGN_PERSONAL_MESSAGE_SESSION_ENDED_REASONS: readonly ["invalid_session", "transport_unavailable", "timeout"];
|
|
107
|
+
export type SignPersonalMessageSessionEndedReason = GetAccountsSessionEndedReason;
|
|
108
|
+
export type DisconnectDeviceResult = {
|
|
109
|
+
source: "disconnected";
|
|
110
|
+
deviceId: string;
|
|
111
|
+
reason: DisconnectEndedReason;
|
|
112
|
+
} | {
|
|
113
|
+
source: "not_connected";
|
|
114
|
+
deviceId: string;
|
|
115
|
+
reason: "not_connected";
|
|
116
|
+
};
|
|
117
|
+
export type GetCapabilitiesResult = {
|
|
118
|
+
source: "live";
|
|
119
|
+
deviceId: string;
|
|
120
|
+
capabilities: CapabilityChain[];
|
|
121
|
+
signing?: SigningCapabilities;
|
|
122
|
+
} | {
|
|
123
|
+
source: "not_connected";
|
|
124
|
+
deviceId: string;
|
|
125
|
+
reason: "not_connected";
|
|
126
|
+
} | {
|
|
127
|
+
source: "session_ended";
|
|
128
|
+
deviceId: string;
|
|
129
|
+
reason: GetCapabilitiesSessionEndedReason;
|
|
130
|
+
};
|
|
131
|
+
export type GetAccountsResult = {
|
|
132
|
+
source: "live";
|
|
133
|
+
deviceId: string;
|
|
134
|
+
accounts: Account[];
|
|
135
|
+
} | {
|
|
136
|
+
source: "not_connected";
|
|
137
|
+
deviceId: string;
|
|
138
|
+
reason: "not_connected";
|
|
139
|
+
} | {
|
|
140
|
+
source: "session_ended";
|
|
141
|
+
deviceId: string;
|
|
142
|
+
reason: GetAccountsSessionEndedReason;
|
|
143
|
+
};
|
|
144
|
+
export type PolicyGetResult = {
|
|
145
|
+
source: "live";
|
|
146
|
+
deviceId: string;
|
|
147
|
+
policy: PolicyDocument;
|
|
148
|
+
} | {
|
|
149
|
+
source: "not_connected";
|
|
150
|
+
deviceId: string;
|
|
151
|
+
reason: "not_connected";
|
|
152
|
+
} | {
|
|
153
|
+
source: "session_ended";
|
|
154
|
+
deviceId: string;
|
|
155
|
+
reason: PolicyGetSessionEndedReason;
|
|
156
|
+
};
|
|
157
|
+
export type GetApprovalHistoryResult = {
|
|
158
|
+
source: "live";
|
|
159
|
+
deviceId: string;
|
|
160
|
+
records: ApprovalHistoryRecord[];
|
|
161
|
+
hasMore: boolean;
|
|
162
|
+
} | {
|
|
163
|
+
source: "not_connected";
|
|
164
|
+
deviceId: string;
|
|
165
|
+
reason: "not_connected";
|
|
166
|
+
} | {
|
|
167
|
+
source: "session_ended";
|
|
168
|
+
deviceId: string;
|
|
169
|
+
reason: GetApprovalHistorySessionEndedReason;
|
|
170
|
+
};
|
|
171
|
+
export type PolicyProposeResult = {
|
|
172
|
+
source: "live";
|
|
173
|
+
deviceId: string;
|
|
174
|
+
status: PolicyProposeResultResponse["status"];
|
|
175
|
+
reasonCode: PolicyProposeResultResponse["reasonCode"];
|
|
176
|
+
policy?: PolicyProposeResultResponse["policy"];
|
|
177
|
+
} | {
|
|
178
|
+
source: "not_connected";
|
|
179
|
+
deviceId: string;
|
|
180
|
+
reason: "not_connected";
|
|
181
|
+
} | {
|
|
182
|
+
source: "session_ended";
|
|
183
|
+
deviceId: string;
|
|
184
|
+
reason: PolicyProposeSessionEndedReason;
|
|
185
|
+
};
|
|
186
|
+
type SignTerminalResponse = Extract<SignResultResponse, {
|
|
187
|
+
status: "user_rejected" | "user_timed_out" | "policy_rejected" | "signing_failed";
|
|
188
|
+
}>;
|
|
189
|
+
type LiveSignedResult = {
|
|
190
|
+
source: "live";
|
|
191
|
+
deviceId: string;
|
|
192
|
+
status: "signed";
|
|
193
|
+
authorization: Extract<SignResultResponse, {
|
|
194
|
+
status: "signed";
|
|
195
|
+
}>["authorization"];
|
|
196
|
+
chain: Extract<SignResultResponse, {
|
|
197
|
+
status: "signed";
|
|
198
|
+
}>["chain"];
|
|
199
|
+
method: Extract<SignResultResponse, {
|
|
200
|
+
status: "signed";
|
|
201
|
+
}>["method"];
|
|
202
|
+
signature: string;
|
|
203
|
+
messageBytes?: string;
|
|
204
|
+
};
|
|
205
|
+
type LiveTerminalSignResult = {
|
|
206
|
+
source: "live";
|
|
207
|
+
deviceId: string;
|
|
208
|
+
status: Exclude<SignTerminalResponse["status"], "policy_rejected">;
|
|
209
|
+
authorization: SignTerminalResponse["authorization"];
|
|
210
|
+
error: Extract<SignTerminalResponse, {
|
|
211
|
+
status: Exclude<SignTerminalResponse["status"], "policy_rejected">;
|
|
212
|
+
}>["error"];
|
|
213
|
+
} | {
|
|
214
|
+
source: "live";
|
|
215
|
+
deviceId: string;
|
|
216
|
+
status: "policy_rejected";
|
|
217
|
+
authorization: "policy";
|
|
218
|
+
policyHash: string;
|
|
219
|
+
ruleRef: string;
|
|
220
|
+
error: Extract<SignTerminalResponse, {
|
|
221
|
+
status: "policy_rejected";
|
|
222
|
+
}>["error"];
|
|
223
|
+
};
|
|
224
|
+
export type SignTransactionResult = LiveSignedResult | LiveTerminalSignResult | {
|
|
225
|
+
source: "not_connected";
|
|
226
|
+
deviceId: string;
|
|
227
|
+
reason: "not_connected";
|
|
228
|
+
} | {
|
|
229
|
+
source: "session_ended";
|
|
230
|
+
deviceId: string;
|
|
231
|
+
reason: SignTransactionSessionEndedReason;
|
|
232
|
+
};
|
|
233
|
+
export type SignPersonalMessageResult = LiveSignedResult | LiveTerminalSignResult | {
|
|
234
|
+
source: "not_connected";
|
|
235
|
+
deviceId: string;
|
|
236
|
+
reason: "not_connected";
|
|
237
|
+
} | {
|
|
238
|
+
source: "session_ended";
|
|
239
|
+
deviceId: string;
|
|
240
|
+
reason: SignPersonalMessageSessionEndedReason;
|
|
241
|
+
};
|
|
242
|
+
export declare const DEFAULT_CLIENT_NAME = "Agent-Q";
|
|
243
|
+
export declare class AgentQCore {
|
|
244
|
+
private readonly configStore;
|
|
245
|
+
private readonly clock;
|
|
246
|
+
private readonly runtimeSessions;
|
|
247
|
+
private readonly usbDriver;
|
|
248
|
+
constructor(configStore: ConfigStore, usbDriver: UsbSerialDriver, clock?: () => Date);
|
|
249
|
+
scanDevices(input?: Record<string, never>): Promise<ScanDevicesResult>;
|
|
250
|
+
identifyDevices(input?: Record<string, never>): Promise<IdentifyDevicesResult>;
|
|
251
|
+
selectDevice(input: {
|
|
252
|
+
deviceId: string;
|
|
253
|
+
purpose?: string;
|
|
254
|
+
}): Promise<SelectDeviceResult>;
|
|
255
|
+
listDevices(): Promise<DeviceListResult>;
|
|
256
|
+
setDeviceMetadata(input: {
|
|
257
|
+
deviceId: string;
|
|
258
|
+
label?: string | null;
|
|
259
|
+
}): Promise<SetDeviceMetadataResult>;
|
|
260
|
+
connectDevice(input?: {
|
|
261
|
+
deviceId?: string;
|
|
262
|
+
purpose?: string;
|
|
263
|
+
clientName?: string;
|
|
264
|
+
}): Promise<ConnectDeviceResult>;
|
|
265
|
+
disconnectDevice(input?: {
|
|
266
|
+
deviceId?: string;
|
|
267
|
+
purpose?: string;
|
|
268
|
+
}): Promise<DisconnectDeviceResult>;
|
|
269
|
+
getCapabilities(input?: {
|
|
270
|
+
deviceId?: string;
|
|
271
|
+
purpose?: string;
|
|
272
|
+
}): Promise<GetCapabilitiesResult>;
|
|
273
|
+
getAccounts(input?: {
|
|
274
|
+
deviceId?: string;
|
|
275
|
+
purpose?: string;
|
|
276
|
+
}): Promise<GetAccountsResult>;
|
|
277
|
+
policyGet(input?: {
|
|
278
|
+
deviceId?: string;
|
|
279
|
+
purpose?: string;
|
|
280
|
+
}): Promise<PolicyGetResult>;
|
|
281
|
+
getApprovalHistory(input?: {
|
|
282
|
+
deviceId?: string;
|
|
283
|
+
purpose?: string;
|
|
284
|
+
limit?: number;
|
|
285
|
+
beforeSeq?: string;
|
|
286
|
+
}): Promise<GetApprovalHistoryResult>;
|
|
287
|
+
policyPropose(input: {
|
|
288
|
+
deviceId?: string;
|
|
289
|
+
purpose?: string;
|
|
290
|
+
policy: Record<string, unknown>;
|
|
291
|
+
}): Promise<PolicyProposeResult>;
|
|
292
|
+
signTransaction(input: {
|
|
293
|
+
deviceId?: string;
|
|
294
|
+
purpose?: string;
|
|
295
|
+
chain: string;
|
|
296
|
+
method: string;
|
|
297
|
+
network: unknown;
|
|
298
|
+
txBytes: string;
|
|
299
|
+
}): Promise<SignTransactionResult>;
|
|
300
|
+
signPersonalMessage(input: {
|
|
301
|
+
deviceId?: string;
|
|
302
|
+
purpose?: string;
|
|
303
|
+
chain: string;
|
|
304
|
+
method: string;
|
|
305
|
+
network: unknown;
|
|
306
|
+
message: string;
|
|
307
|
+
}): Promise<SignPersonalMessageResult>;
|
|
308
|
+
private peekRuntimeSession;
|
|
309
|
+
private recordSession;
|
|
310
|
+
private clearRuntimeSessionsAbsentFromLiveUsbScan;
|
|
311
|
+
private clearRuntimeSessionMirror;
|
|
312
|
+
private clearRuntimeSessionMirrorIfEnded;
|
|
313
|
+
private resolveTargetDevice;
|
|
314
|
+
private findLivePortForDevice;
|
|
315
|
+
getDeviceStatus(input?: {
|
|
316
|
+
deviceId?: string;
|
|
317
|
+
purpose?: string;
|
|
318
|
+
}): Promise<DeviceStatusResult>;
|
|
319
|
+
}
|
|
320
|
+
export declare function createDefaultAgentQCore(): AgentQCore;
|