@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.
Files changed (47) hide show
  1. package/README.md +144 -0
  2. package/dist/adapter-internal.d.ts +5 -0
  3. package/dist/adapter-internal.js +6 -0
  4. package/dist/adapter-internal.js.map +1 -0
  5. package/dist/config.d.ts +74 -0
  6. package/dist/config.js +489 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/core.d.ts +320 -0
  9. package/dist/core.js +840 -0
  10. package/dist/core.js.map +1 -0
  11. package/dist/device.d.ts +55 -0
  12. package/dist/device.js +23 -0
  13. package/dist/device.js.map +1 -0
  14. package/dist/errors.d.ts +6 -0
  15. package/dist/errors.js +20 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/host-output-schema.d.ts +2437 -0
  18. package/dist/host-output-schema.js +655 -0
  19. package/dist/host-output-schema.js.map +1 -0
  20. package/dist/protocol-error.d.ts +4 -0
  21. package/dist/protocol-error.js +9 -0
  22. package/dist/protocol-error.js.map +1 -0
  23. package/dist/protocol-management-primitives.d.ts +27 -0
  24. package/dist/protocol-management-primitives.js +51 -0
  25. package/dist/protocol-management-primitives.js.map +1 -0
  26. package/dist/protocol-primitives.d.ts +53 -0
  27. package/dist/protocol-primitives.js +331 -0
  28. package/dist/protocol-primitives.js.map +1 -0
  29. package/dist/protocol.d.ts +207 -0
  30. package/dist/protocol.js +897 -0
  31. package/dist/protocol.js.map +1 -0
  32. package/dist/provider-protocol.d.ts +262 -0
  33. package/dist/provider-protocol.js +637 -0
  34. package/dist/provider-protocol.js.map +1 -0
  35. package/dist/public-error.d.ts +9 -0
  36. package/dist/public-error.js +79 -0
  37. package/dist/public-error.js.map +1 -0
  38. package/dist/safe-text.d.ts +31 -0
  39. package/dist/safe-text.js +143 -0
  40. package/dist/safe-text.js.map +1 -0
  41. package/dist/transport-invariants.d.ts +18 -0
  42. package/dist/transport-invariants.js +24 -0
  43. package/dist/transport-invariants.js.map +1 -0
  44. package/dist/usb.d.ts +76 -0
  45. package/dist/usb.js +454 -0
  46. package/dist/usb.js.map +1 -0
  47. package/package.json +58 -0
@@ -0,0 +1,207 @@
1
+ import { isClientName, isSafeDeviceId, isSafeRequestId, isSessionId, sanitizeDisplayText, type DeviceState, type ProvisioningState } from "./safe-text.js";
2
+ import { makeConnectRequest as makeProviderConnectRequest, makeDisconnectRequest as makeProviderDisconnectRequest, makeGetAccountsRequest as makeProviderGetAccountsRequest, makeGetCapabilitiesRequest as makeProviderGetCapabilitiesRequest, type AccountsResponse, type CapabilitiesResponse, type ConnectRequest, type ConnectResponse, type DisconnectRequest, type DisconnectResponse, type GetAccountsRequest, type GetCapabilitiesRequest, type ProtocolErrorResponse, type SignPersonalMessageParams, type SignPersonalMessageRequest, type SignResultResponse, type SignTransactionParams, type SignTransactionRequest } from "./provider-protocol.js";
3
+ import { ProtocolError } from "./protocol-error.js";
4
+ import { AGENT_Q_POLICY_SCHEMA, APPROVAL_HISTORY_HIGHEST_ACTIONS, APPROVAL_HISTORY_POLICY_UPDATE_RESULTS, APPROVAL_HISTORY_REASON_CODE_PATTERN, APPROVAL_HISTORY_RULE_REF_PATTERN, MAX_APPROVAL_HISTORY_RECORDS, MAX_POLICY_CHAIN_ID_LENGTH, MAX_POLICY_CRITERION_VALUES, MAX_POLICY_FIELD_ID_LENGTH, MAX_POLICY_METHOD_LENGTH, MAX_POLICY_RULE_CRITERIA, MAX_POLICY_RULE_COUNT, MAX_POLICY_RULE_ID_LENGTH, MAX_POLICY_UPDATE_REQUEST_JSON_BYTES, MAX_POLICY_VALUE_LENGTH, POLICY_ACTIONS, POLICY_FIELD_ID_PATTERN, POLICY_ID_PATTERN, POLICY_IDENTIFIER_PATTERN, POLICY_OPERATORS, POLICY_PROPOSE_RESULT_STATUSES, POLICY_RULE_ID_PATTERN, SIGNING_HISTORY_RECORD_KINDS, SIGNING_HISTORY_TERMINAL_RESULTS, SIGN_CHAIN_PATTERN, SIGN_METHOD_PATTERN, UINT_DECIMAL_STRING_PATTERN } from "./protocol-management-primitives.js";
5
+ import { ED25519_PUBLIC_KEY_BASE64_PATTERN, FORBIDDEN_SECRET_FIELD_NAMES, MAX_ACCOUNTS_PER_RESPONSE, MAX_CAPABILITY_ACCOUNTS_PER_CHAIN, MAX_CAPABILITY_CHAINS, MAX_PROTOCOL_RESPONSE_LINE_BYTES, MAX_RAW_PROTOCOL_JSON_BYTES, MAX_SESSION_TTL_MS, MAX_SIGN_RESULT_PAYLOAD_BASE64_CHARS, MAX_SIGNING_CAPABILITIES, MAX_SUI_SIGN_PERSONAL_MESSAGE_BASE64_CHARS, MAX_SUI_SIGN_PERSONAL_MESSAGE_BYTES, MAX_SUI_SIGN_TRANSACTION_TX_BYTES, MAX_SUI_SIGN_TRANSACTION_TX_BYTES_BASE64_CHARS, PROTOCOL_VERSION, SIGN_RESULT_ERROR_MESSAGES, SUI_ADDRESS_PATTERN, SUI_CHAIN_ID, SUI_DERIVATION_PATH, SUI_ED25519_SIGNATURE_BASE64_PATTERN, SUI_SIGN_PERSONAL_MESSAGE_METHOD, SUI_SIGN_TRANSACTION_METHOD, SUI_SIGN_TRANSACTION_NETWORKS, UNSUPPORTED_METHOD_MESSAGE, consumeProtocolResponseChunk, createRequestId, isSuiAddressForPublicKey, type SignResultErrorCode, type SuiSignMethod, type SuiSignTransactionNetwork } from "./protocol-primitives.js";
6
+ export { isClientName, isSafeDeviceId, isSafeRequestId, isSessionId, sanitizeDisplayText };
7
+ export { AGENT_Q_POLICY_SCHEMA, APPROVAL_HISTORY_HIGHEST_ACTIONS, APPROVAL_HISTORY_POLICY_UPDATE_RESULTS, APPROVAL_HISTORY_REASON_CODE_PATTERN, APPROVAL_HISTORY_RULE_REF_PATTERN, ED25519_PUBLIC_KEY_BASE64_PATTERN, FORBIDDEN_SECRET_FIELD_NAMES, MAX_ACCOUNTS_PER_RESPONSE, MAX_APPROVAL_HISTORY_RECORDS, MAX_CAPABILITY_ACCOUNTS_PER_CHAIN, MAX_CAPABILITY_CHAINS, MAX_POLICY_CHAIN_ID_LENGTH, MAX_POLICY_CRITERION_VALUES, MAX_POLICY_FIELD_ID_LENGTH, MAX_POLICY_METHOD_LENGTH, MAX_POLICY_RULE_CRITERIA, MAX_POLICY_RULE_COUNT, MAX_POLICY_RULE_ID_LENGTH, MAX_POLICY_UPDATE_REQUEST_JSON_BYTES, MAX_POLICY_VALUE_LENGTH, MAX_PROTOCOL_RESPONSE_LINE_BYTES, MAX_RAW_PROTOCOL_JSON_BYTES, MAX_SESSION_TTL_MS, MAX_SIGN_RESULT_PAYLOAD_BASE64_CHARS, MAX_SIGNING_CAPABILITIES, MAX_SUI_SIGN_PERSONAL_MESSAGE_BASE64_CHARS, MAX_SUI_SIGN_PERSONAL_MESSAGE_BYTES, MAX_SUI_SIGN_TRANSACTION_TX_BYTES, MAX_SUI_SIGN_TRANSACTION_TX_BYTES_BASE64_CHARS, POLICY_ACTIONS, POLICY_FIELD_ID_PATTERN, POLICY_ID_PATTERN, POLICY_IDENTIFIER_PATTERN, POLICY_OPERATORS, POLICY_PROPOSE_RESULT_STATUSES, POLICY_RULE_ID_PATTERN, PROTOCOL_VERSION, SIGNING_HISTORY_RECORD_KINDS, SIGNING_HISTORY_TERMINAL_RESULTS, SIGN_CHAIN_PATTERN, SIGN_METHOD_PATTERN, SIGN_RESULT_ERROR_MESSAGES, SUI_ADDRESS_PATTERN, SUI_CHAIN_ID, SUI_DERIVATION_PATH, SUI_ED25519_SIGNATURE_BASE64_PATTERN, SUI_SIGN_PERSONAL_MESSAGE_METHOD, SUI_SIGN_TRANSACTION_METHOD, SUI_SIGN_TRANSACTION_NETWORKS, UINT_DECIMAL_STRING_PATTERN, UNSUPPORTED_METHOD_MESSAGE, consumeProtocolResponseChunk, createRequestId, isSuiAddressForPublicKey, };
8
+ export { ProtocolError };
9
+ export type { DeviceState, ProvisioningState, SignResultErrorCode, SuiSignMethod, SuiSignTransactionNetwork };
10
+ export type { Account, AccountsResponse, CapabilitiesResponse, CapabilityAccount, CapabilityChain, ConnectApprovedResponse, ConnectRejectedResponse, ConnectRequest, ConnectResponse, DisconnectRequest, DisconnectResponse, GetAccountsRequest, GetCapabilitiesRequest, ProtocolErrorResponse, SignPersonalMessageParams, SignPersonalMessageRequest, SignPersonalMessageSignedResponse, SignOperationType, SignResultAuthorization, SignResultPolicyRejectedResponse, SignResultResponse, SignResultSignedResponse, SignResultSigningFailedResponse, SignResultStatus, SignResultUserRejectedResponse, SignTransactionParams, SignTransactionRequest, SignTransactionSignedResponse, SupportedSignRoute, SigningCapabilities, SigningCapabilityEntry, } from "./provider-protocol.js";
11
+ export { identifySignRoute, makeSignPersonalMessageRequest, makeSignTransactionRequest, } from "./provider-protocol.js";
12
+ export interface DeviceStatus {
13
+ deviceId: string;
14
+ state: DeviceState;
15
+ firmwareName: string;
16
+ hardware: string;
17
+ firmwareVersion: string;
18
+ }
19
+ export interface ProvisioningStatus {
20
+ state: ProvisioningState;
21
+ }
22
+ export interface DeviceStatusSnapshot {
23
+ device: DeviceStatus;
24
+ provisioning: ProvisioningStatus;
25
+ }
26
+ export interface GetStatusRequest {
27
+ id: string;
28
+ version: typeof PROTOCOL_VERSION;
29
+ type: "get_status";
30
+ }
31
+ export interface IdentifyDeviceRequest {
32
+ id: string;
33
+ version: typeof PROTOCOL_VERSION;
34
+ type: "identify_device";
35
+ params: {
36
+ code: string;
37
+ };
38
+ }
39
+ export interface PolicyGetRequest {
40
+ id: string;
41
+ version: typeof PROTOCOL_VERSION;
42
+ type: "policy_get";
43
+ sessionId: string;
44
+ }
45
+ export interface GetApprovalHistoryRequest {
46
+ id: string;
47
+ version: typeof PROTOCOL_VERSION;
48
+ type: "get_approval_history";
49
+ sessionId: string;
50
+ params: {
51
+ limit: number;
52
+ beforeSeq?: string;
53
+ };
54
+ }
55
+ export interface PolicyProposeRequest {
56
+ id: string;
57
+ version: typeof PROTOCOL_VERSION;
58
+ type: "policy_propose";
59
+ sessionId: string;
60
+ params: {
61
+ policy: Record<string, unknown>;
62
+ };
63
+ }
64
+ export type ProtocolRequest = GetStatusRequest | IdentifyDeviceRequest | ConnectRequest | DisconnectRequest | GetCapabilitiesRequest | GetAccountsRequest | PolicyGetRequest | GetApprovalHistoryRequest | PolicyProposeRequest | SignTransactionRequest | SignPersonalMessageRequest;
65
+ export interface StatusResponse {
66
+ id: string;
67
+ version: typeof PROTOCOL_VERSION;
68
+ type: "status";
69
+ device: DeviceStatus;
70
+ provisioning: ProvisioningStatus;
71
+ }
72
+ export interface IdentifyDeviceResponse {
73
+ id: string;
74
+ version: typeof PROTOCOL_VERSION;
75
+ type: "identify_device_result";
76
+ status: "displayed";
77
+ code: string;
78
+ device: DeviceStatus;
79
+ }
80
+ export type PolicyAction = "reject" | "sign";
81
+ export type PolicyOperator = "eq" | "in" | "lte";
82
+ export interface PolicyCriterion {
83
+ field: string;
84
+ op: PolicyOperator;
85
+ value?: string;
86
+ values?: string[];
87
+ }
88
+ export interface PolicyRule {
89
+ id: string;
90
+ chain: string;
91
+ method: string;
92
+ action: PolicyAction;
93
+ criteria: PolicyCriterion[];
94
+ }
95
+ export interface PolicyDocument {
96
+ schema: string;
97
+ policyId: string;
98
+ defaultAction: PolicyAction;
99
+ ruleCount: number;
100
+ rules: PolicyRule[];
101
+ }
102
+ export interface PolicyResponse {
103
+ id: string;
104
+ version: typeof PROTOCOL_VERSION;
105
+ type: "policy";
106
+ policy: PolicyDocument;
107
+ }
108
+ export type SigningHistoryRecordKind = "confirmation" | "terminal";
109
+ export type SigningHistoryTerminalResult = "signed" | "user_rejected" | "user_timed_out" | "policy_rejected" | "signing_failed";
110
+ export type ApprovalHistoryPolicyUpdateResult = "applied" | "rejected" | "timed_out" | "storage_error";
111
+ export type ApprovalHistoryHighestAction = PolicyAction;
112
+ interface ApprovalHistoryRecordBase {
113
+ seq: string;
114
+ uptimeMs: string;
115
+ timeSource: "uptime";
116
+ eventKind: "policy_update" | "signing";
117
+ reasonCode: string;
118
+ }
119
+ export interface PolicyUpdateApprovalHistoryRecord extends ApprovalHistoryRecordBase {
120
+ eventKind: "policy_update";
121
+ result: ApprovalHistoryPolicyUpdateResult;
122
+ policyHash: string;
123
+ ruleCount: number;
124
+ highestAction: ApprovalHistoryHighestAction;
125
+ }
126
+ export interface SigningApprovalHistoryRecord extends ApprovalHistoryRecordBase {
127
+ eventKind: "signing";
128
+ recordKind: SigningHistoryRecordKind;
129
+ authorization: "user" | "policy";
130
+ chain: string;
131
+ method: string;
132
+ payloadDigest: string;
133
+ confirmationKind?: "local_pin" | "physical_confirm" | "policy";
134
+ policyHash?: string;
135
+ ruleRef?: string;
136
+ terminalResult?: SigningHistoryTerminalResult;
137
+ }
138
+ export type ApprovalHistoryRecord = PolicyUpdateApprovalHistoryRecord | SigningApprovalHistoryRecord;
139
+ export interface ApprovalHistoryResponse {
140
+ id: string;
141
+ version: typeof PROTOCOL_VERSION;
142
+ type: "approval_history";
143
+ records: ApprovalHistoryRecord[];
144
+ hasMore: boolean;
145
+ }
146
+ export type PolicyProposeResultStatus = "applied" | "rejected" | "timed_out" | "invalid_policy" | "ui_error" | "storage_error" | "consistency_error";
147
+ export interface PolicyProposeResultPolicySummary {
148
+ policyHash: string;
149
+ ruleCount: number;
150
+ highestAction: ApprovalHistoryHighestAction;
151
+ }
152
+ export interface PolicyProposeResultResponse {
153
+ id: string;
154
+ version: typeof PROTOCOL_VERSION;
155
+ type: "policy_propose_result";
156
+ status: PolicyProposeResultStatus;
157
+ reasonCode: string;
158
+ policy?: PolicyProposeResultPolicySummary;
159
+ }
160
+ export type ProtocolResponse = StatusResponse | IdentifyDeviceResponse | ConnectResponse | DisconnectResponse | CapabilitiesResponse | AccountsResponse | PolicyResponse | ApprovalHistoryResponse | PolicyProposeResultResponse | SignResultResponse | ProtocolErrorResponse;
161
+ export declare function makeGetStatusRequest(id?: string): GetStatusRequest;
162
+ export declare function makeIdentifyDeviceRequest(code: string, id?: string): IdentifyDeviceRequest;
163
+ export declare function createIdentificationCode(): string;
164
+ export declare const makeConnectRequest: typeof makeProviderConnectRequest;
165
+ export declare const makeDisconnectRequest: typeof makeProviderDisconnectRequest;
166
+ export declare const makeGetCapabilitiesRequest: typeof makeProviderGetCapabilitiesRequest;
167
+ export declare const makeGetAccountsRequest: typeof makeProviderGetAccountsRequest;
168
+ export declare function makePolicyGetRequest(sessionId: string, id?: string): PolicyGetRequest;
169
+ export declare function makeGetApprovalHistoryRequest(sessionId: string, params?: {
170
+ limit?: number;
171
+ beforeSeq?: string;
172
+ }, id?: string): GetApprovalHistoryRequest;
173
+ export declare function makePolicyProposeRequest(sessionId: string, policy: Record<string, unknown>, id?: string): PolicyProposeRequest;
174
+ export declare function validatePolicyProposeRequestInput(sessionId: string, policy: Record<string, unknown>): void;
175
+ export declare function validateSignRequestInput(chain: unknown, method: unknown, params: unknown, requestType?: string): SignTransactionParams;
176
+ export declare function validateSignTransactionParamsInput(params: unknown, requestType?: string): SignTransactionParams;
177
+ export declare function validateSignPersonalMessageRequestInput(chain: unknown, method: unknown, params: unknown, requestType?: string): SignPersonalMessageParams;
178
+ export declare function validateSignPersonalMessageParamsInput(params: unknown, requestType?: string): SignPersonalMessageParams;
179
+ export declare function validatePolicyProposeInput(policy: unknown): asserts policy is Record<string, unknown>;
180
+ export declare function validateApprovalHistoryInput(params?: {
181
+ limit?: number;
182
+ beforeSeq?: string;
183
+ }): {
184
+ limit: number;
185
+ beforeSeq?: string;
186
+ };
187
+ export declare function serializeRequest(request: ProtocolRequest): string;
188
+ export declare function parseJsonLine(line: string): unknown;
189
+ export declare function parseProtocolResponse(line: string, expectedId?: string): ProtocolResponse;
190
+ export declare function parseProviderProtocolResponse(line: string, expectedId?: string): ProtocolResponse;
191
+ export declare function assertStatusResponse(response: ProtocolResponse): StatusResponse;
192
+ export declare function assertIdentifyDeviceResponse(response: ProtocolResponse): IdentifyDeviceResponse;
193
+ export declare function assertConnectResponse(response: ProtocolResponse): ConnectResponse;
194
+ export declare function assertDisconnectResponse(response: ProtocolResponse): DisconnectResponse;
195
+ export declare function assertCapabilitiesResponse(response: ProtocolResponse): CapabilitiesResponse;
196
+ export declare function assertAccountsResponse(response: ProtocolResponse): AccountsResponse;
197
+ export declare function assertPolicyResponse(response: ProtocolResponse): PolicyResponse;
198
+ export declare function assertApprovalHistoryResponse(response: ProtocolResponse): ApprovalHistoryResponse;
199
+ export declare function assertPolicyProposeResultResponse(response: ProtocolResponse): PolicyProposeResultResponse;
200
+ export declare function assertSignResultResponse(response: ProtocolResponse): SignResultResponse;
201
+ export declare function sanitizeDeviceStatus(value: unknown): DeviceStatus | null;
202
+ export declare function sanitizeProvisioningStatus(value: unknown): ProvisioningStatus | null;
203
+ export declare function isSignChain(value: unknown): value is string;
204
+ export declare function isSignMethod(value: unknown): value is string;
205
+ export declare function isUint64DecimalString(value: unknown): value is string;
206
+ export declare function sanitizeCurrentPolicyDocument(value: unknown): PolicyDocument | null;
207
+ export declare function sanitizeDeviceStatusSnapshot(value: unknown): DeviceStatusSnapshot | null;