@agentims/sdk 0.0.0-stage → 0.3.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 +73 -2
- package/dist/api/client.d.ts +36 -0
- package/dist/api/client.js +54 -0
- package/dist/api/errors.d.ts +52 -0
- package/dist/api/errors.js +43 -0
- package/dist/api/options.d.ts +12 -0
- package/dist/api/options.js +1 -0
- package/dist/api/request-data.d.ts +10 -0
- package/dist/api/request-data.js +43 -0
- package/dist/features/contacts/client.d.ts +9 -0
- package/dist/features/contacts/client.js +12 -0
- package/dist/features/contacts/index.d.ts +1 -0
- package/dist/features/contacts/index.js +1 -0
- package/dist/features/contacts/types.d.ts +19 -0
- package/dist/features/contacts/types.js +3 -0
- package/dist/features/conversations/client.d.ts +20 -0
- package/dist/features/conversations/client.js +42 -0
- package/dist/features/conversations/index.d.ts +1 -0
- package/dist/features/conversations/index.js +1 -0
- package/dist/features/conversations/types.d.ts +64 -0
- package/dist/features/conversations/types.js +3 -0
- package/dist/features/deliveries/client.d.ts +17 -0
- package/dist/features/deliveries/client.js +31 -0
- package/dist/features/deliveries/index.d.ts +1 -0
- package/dist/features/deliveries/index.js +1 -0
- package/dist/features/deliveries/types.d.ts +54 -0
- package/dist/features/deliveries/types.js +1 -0
- package/dist/features/devices/client.d.ts +11 -0
- package/dist/features/devices/client.js +18 -0
- package/dist/features/devices/index.d.ts +1 -0
- package/dist/features/devices/index.js +1 -0
- package/dist/features/devices/types.d.ts +29 -0
- package/dist/features/devices/types.js +3 -0
- package/dist/features/discovery/client.d.ts +9 -0
- package/dist/features/discovery/client.js +9 -0
- package/dist/features/discovery/index.d.ts +1 -0
- package/dist/features/discovery/index.js +1 -0
- package/dist/features/discovery/types.d.ts +6 -0
- package/dist/features/discovery/types.js +3 -0
- package/dist/features/encryption/client.d.ts +16 -0
- package/dist/features/encryption/client.js +30 -0
- package/dist/features/encryption/index.d.ts +1 -0
- package/dist/features/encryption/index.js +1 -0
- package/dist/features/encryption/types.d.ts +54 -0
- package/dist/features/encryption/types.js +3 -0
- package/dist/features/identity/client.d.ts +21 -0
- package/dist/features/identity/client.js +43 -0
- package/dist/features/identity/index.d.ts +3 -0
- package/dist/features/identity/index.js +1 -0
- package/dist/features/identity/types.d.ts +105 -0
- package/dist/features/identity/types.js +1 -0
- package/dist/features/messages/client.d.ts +18 -0
- package/dist/features/messages/client.js +35 -0
- package/dist/features/messages/index.d.ts +1 -0
- package/dist/features/messages/index.js +1 -0
- package/dist/features/messages/types.d.ts +54 -0
- package/dist/features/messages/types.js +3 -0
- package/dist/features/outbox/client.d.ts +14 -0
- package/dist/features/outbox/client.js +25 -0
- package/dist/features/outbox/index.d.ts +1 -0
- package/dist/features/outbox/index.js +1 -0
- package/dist/features/outbox/types.d.ts +41 -0
- package/dist/features/outbox/types.js +3 -0
- package/dist/features/pairing/client.d.ts +11 -0
- package/dist/features/pairing/client.js +16 -0
- package/dist/features/pairing/index.d.ts +1 -0
- package/dist/features/pairing/index.js +1 -0
- package/dist/features/pairing/types.d.ts +21 -0
- package/dist/features/pairing/types.js +3 -0
- package/dist/features/profiles/client.d.ts +10 -0
- package/dist/features/profiles/client.js +15 -0
- package/dist/features/profiles/index.d.ts +1 -0
- package/dist/features/profiles/index.js +1 -0
- package/dist/features/profiles/types.d.ts +23 -0
- package/dist/features/profiles/types.js +3 -0
- package/dist/features/reliability/client.d.ts +9 -0
- package/dist/features/reliability/client.js +12 -0
- package/dist/features/reliability/index.d.ts +1 -0
- package/dist/features/reliability/index.js +1 -0
- package/dist/features/reliability/types.d.ts +27 -0
- package/dist/features/reliability/types.js +3 -0
- package/dist/features/timeline/client.d.ts +12 -0
- package/dist/features/timeline/client.js +21 -0
- package/dist/features/timeline/index.d.ts +1 -0
- package/dist/features/timeline/index.js +1 -0
- package/dist/features/timeline/types.d.ts +60 -0
- package/dist/features/timeline/types.js +3 -0
- package/dist/features/verification/client.d.ts +11 -0
- package/dist/features/verification/client.js +18 -0
- package/dist/features/verification/index.d.ts +1 -0
- package/dist/features/verification/index.js +1 -0
- package/dist/features/verification/types.d.ts +20 -0
- package/dist/features/verification/types.js +3 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +4 -0
- package/dist/internal/protocol/codec.d.ts +4 -0
- package/dist/internal/protocol/codec.js +69 -0
- package/dist/internal/protocol/input.d.ts +2 -0
- package/dist/internal/protocol/input.js +38 -0
- package/dist/internal/protocol/operations.json +88 -0
- package/dist/internal/protocol/registry.d.ts +17 -0
- package/dist/internal/protocol/registry.js +72 -0
- package/dist/internal/protocol/schema.d.ts +23 -0
- package/dist/internal/protocol/schema.js +105 -0
- package/dist/internal/transport/client.d.ts +8 -0
- package/dist/internal/transport/client.js +102 -0
- package/dist/internal/transport/error-diagnostics.d.ts +3 -0
- package/dist/internal/transport/error-diagnostics.js +50 -0
- package/dist/internal/transport/request.d.ts +9 -0
- package/dist/internal/transport/request.js +55 -0
- package/dist/internal/transport/response.d.ts +2 -0
- package/dist/internal/transport/response.js +85 -0
- package/package.json +34 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Decisions require the fingerprint obtained from the Agent's trusted context. */
|
|
2
|
+
export class PairingClient {
|
|
3
|
+
transport;
|
|
4
|
+
constructor(transport) {
|
|
5
|
+
this.transport = transport;
|
|
6
|
+
}
|
|
7
|
+
list(options = {}) {
|
|
8
|
+
return this.transport.call("localListPairings", options);
|
|
9
|
+
}
|
|
10
|
+
get(pairingId, options = {}) {
|
|
11
|
+
return this.transport.call("localGetPairing", { ...options, path: { pairing_id: pairingId } });
|
|
12
|
+
}
|
|
13
|
+
decide(pairingId, body, options = {}) {
|
|
14
|
+
return this.transport.call("localDecidePairing", { ...options, path: { pairing_id: pairingId }, body });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PairingDecisionRequest, PairingList, PairingRequest } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PairingDecisionRequest {
|
|
2
|
+
readonly decision: "approve" | "reject";
|
|
3
|
+
readonly user_code: string;
|
|
4
|
+
readonly code_challenge: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PairingList {
|
|
7
|
+
readonly requests: readonly (PairingRequest)[];
|
|
8
|
+
}
|
|
9
|
+
export interface PairingRequest {
|
|
10
|
+
readonly pairing_id: string;
|
|
11
|
+
readonly target_user_id: string;
|
|
12
|
+
readonly user_code: string;
|
|
13
|
+
readonly code_challenge: string;
|
|
14
|
+
readonly device_name: string;
|
|
15
|
+
readonly client_origin: string;
|
|
16
|
+
readonly state: "pending" | "approved" | "rejected" | "cancelled" | "consuming" | "consumed" | "expired" | "failed";
|
|
17
|
+
readonly created_at_ms: number | bigint;
|
|
18
|
+
readonly expires_at_ms: number | bigint;
|
|
19
|
+
readonly server_time_ms: number | bigint;
|
|
20
|
+
readonly poll_interval_ms: 2000;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RequestOptions } from "../../api/options.js";
|
|
2
|
+
import type { Transport } from "../../internal/transport/client.js";
|
|
3
|
+
import type { AgentProfile, UpdateProfileRequest } from "./types.js";
|
|
4
|
+
export declare class ProfilesClient {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
constructor(transport: Transport);
|
|
7
|
+
getOwn(options?: RequestOptions): Promise<AgentProfile>;
|
|
8
|
+
updateOwn(body: UpdateProfileRequest, options?: RequestOptions): Promise<AgentProfile>;
|
|
9
|
+
get(userId: string, options?: RequestOptions): Promise<AgentProfile>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class ProfilesClient {
|
|
2
|
+
transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.transport = transport;
|
|
5
|
+
}
|
|
6
|
+
getOwn(options = {}) {
|
|
7
|
+
return this.transport.call("localGetOwnProfile", options);
|
|
8
|
+
}
|
|
9
|
+
updateOwn(body, options = {}) {
|
|
10
|
+
return this.transport.call("localUpdateOwnProfile", { ...options, body });
|
|
11
|
+
}
|
|
12
|
+
get(userId, options = {}) {
|
|
13
|
+
return this.transport.call("localGetProfile", { ...options, path: { user_id: userId } });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { AgentProfile, ProfilePage, ProfileUpdate, UpdateProfileRequest, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface AgentProfile {
|
|
2
|
+
readonly user_id: string;
|
|
3
|
+
readonly description: string;
|
|
4
|
+
readonly capabilities: readonly (string)[];
|
|
5
|
+
readonly discoverable: boolean;
|
|
6
|
+
readonly contact_policy: "request" | "closed";
|
|
7
|
+
}
|
|
8
|
+
export interface ProfilePage {
|
|
9
|
+
readonly profiles: readonly (AgentProfile)[];
|
|
10
|
+
readonly next_cursor: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface ProfileUpdate {
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly capabilities: readonly (string)[];
|
|
15
|
+
readonly discoverable: boolean;
|
|
16
|
+
readonly contact_policy: "request" | "closed";
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateProfileRequest {
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly capabilities: readonly (string)[];
|
|
21
|
+
readonly discoverable: boolean;
|
|
22
|
+
readonly contact_policy: "request" | "closed";
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestOptions } from "../../api/options.js";
|
|
2
|
+
import type { Transport } from "../../internal/transport/client.js";
|
|
3
|
+
import type { ReliabilityStatus, RescanRequest } from "./types.js";
|
|
4
|
+
export declare class ReliabilityClient {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
constructor(transport: Transport);
|
|
7
|
+
status(options?: RequestOptions): Promise<ReliabilityStatus>;
|
|
8
|
+
rescan(body?: RescanRequest, options?: RequestOptions): Promise<ReliabilityStatus>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class ReliabilityClient {
|
|
2
|
+
transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.transport = transport;
|
|
5
|
+
}
|
|
6
|
+
status(options = {}) {
|
|
7
|
+
return this.transport.call("readReliability", options);
|
|
8
|
+
}
|
|
9
|
+
rescan(body = {}, options = {}) {
|
|
10
|
+
return this.transport.call("rescanHistory", { ...options, body });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { HistoryRoomStatus, ReliabilityStatus, RescanRequest, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface HistoryRoomStatus {
|
|
2
|
+
readonly room_id: string;
|
|
3
|
+
readonly state: "pending" | "caught_up" | "backpressure" | "blocked" | "error" | "no_progress";
|
|
4
|
+
readonly pending: boolean;
|
|
5
|
+
readonly limited: boolean;
|
|
6
|
+
readonly pages: number | bigint;
|
|
7
|
+
readonly last_error: string | null;
|
|
8
|
+
readonly updated_at_ms: number | bigint;
|
|
9
|
+
}
|
|
10
|
+
export interface ReliabilityStatus {
|
|
11
|
+
readonly protocol_syncs: number | bigint;
|
|
12
|
+
readonly sync_running: boolean;
|
|
13
|
+
readonly history_running: boolean;
|
|
14
|
+
readonly inbox_pending: number | bigint;
|
|
15
|
+
readonly inbox_bytes: number | bigint;
|
|
16
|
+
readonly pending_decryption: number | bigint;
|
|
17
|
+
readonly backpressure: boolean;
|
|
18
|
+
readonly outbox_pending: number | bigint;
|
|
19
|
+
readonly outbox_uncertain: number | bigint;
|
|
20
|
+
readonly binding_valid: boolean;
|
|
21
|
+
readonly rooms: readonly (HistoryRoomStatus)[];
|
|
22
|
+
readonly ignore_open_intervals: number | bigint;
|
|
23
|
+
readonly ignore_pending_projections: number | bigint;
|
|
24
|
+
}
|
|
25
|
+
export interface RescanRequest {
|
|
26
|
+
readonly from_beginning?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RequestOptions } from "../../api/options.js";
|
|
2
|
+
import type { Transport } from "../../internal/transport/client.js";
|
|
3
|
+
import type { EffectiveMessage, ReadEventContextQuery, ReadEventRelationsQuery, ReadRoomHistoryQuery, ReadTimelineChangesQuery, TimelineChanges, TimelineContext, TimelinePage } from "./types.js";
|
|
4
|
+
export declare class TimelineClient {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
constructor(transport: Transport);
|
|
7
|
+
history(roomId: string, query?: ReadRoomHistoryQuery, options?: RequestOptions): Promise<TimelinePage>;
|
|
8
|
+
context(roomId: string, eventId: string, query?: ReadEventContextQuery, options?: RequestOptions): Promise<TimelineContext>;
|
|
9
|
+
relations(roomId: string, eventId: string, query?: ReadEventRelationsQuery, options?: RequestOptions): Promise<TimelinePage>;
|
|
10
|
+
event(roomId: string, eventId: string, options?: RequestOptions): Promise<EffectiveMessage>;
|
|
11
|
+
changes(query?: ReadTimelineChangesQuery, options?: RequestOptions): Promise<TimelineChanges>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class TimelineClient {
|
|
2
|
+
transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.transport = transport;
|
|
5
|
+
}
|
|
6
|
+
history(roomId, query = {}, options = {}) {
|
|
7
|
+
return this.transport.call("readRoomHistory", { timeoutMs: 180000, ...options, path: { room_id: roomId }, query });
|
|
8
|
+
}
|
|
9
|
+
context(roomId, eventId, query = {}, options = {}) {
|
|
10
|
+
return this.transport.call("readEventContext", { timeoutMs: 180000, ...options, path: { room_id: roomId, event_id: eventId }, query });
|
|
11
|
+
}
|
|
12
|
+
relations(roomId, eventId, query = {}, options = {}) {
|
|
13
|
+
return this.transport.call("readEventRelations", { timeoutMs: 180000, ...options, path: { room_id: roomId, event_id: eventId }, query });
|
|
14
|
+
}
|
|
15
|
+
event(roomId, eventId, options = {}) {
|
|
16
|
+
return this.transport.call("readTimelineEvent", { timeoutMs: 180000, ...options, path: { room_id: roomId, event_id: eventId } });
|
|
17
|
+
}
|
|
18
|
+
changes(query = {}, options = {}) {
|
|
19
|
+
return this.transport.call("readTimelineChanges", { timeoutMs: 180000, ...options, query });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { EffectiveMessage, ReadEventContextQuery, ReadEventRelationsQuery, ReadRoomHistoryQuery, ReadTimelineChangesQuery, TimelineChange, TimelineChanges, TimelineContext, TimelineEvent, TimelinePage } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface EffectiveMessage {
|
|
2
|
+
readonly original: TimelineEvent;
|
|
3
|
+
readonly effective: TimelineEvent;
|
|
4
|
+
readonly edit_event_id: string | null;
|
|
5
|
+
readonly complete: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ReadEventContextQuery {
|
|
8
|
+
readonly limit?: number | bigint;
|
|
9
|
+
}
|
|
10
|
+
export interface ReadEventRelationsQuery {
|
|
11
|
+
readonly cursor?: string;
|
|
12
|
+
readonly direction?: "backward" | "forward";
|
|
13
|
+
readonly limit?: number | bigint;
|
|
14
|
+
}
|
|
15
|
+
export interface ReadRoomHistoryQuery {
|
|
16
|
+
readonly cursor?: string;
|
|
17
|
+
readonly direction?: "backward" | "forward";
|
|
18
|
+
readonly limit?: number | bigint;
|
|
19
|
+
readonly timestamp?: number | bigint;
|
|
20
|
+
readonly since_ms?: number | bigint;
|
|
21
|
+
readonly until_ms?: number | bigint;
|
|
22
|
+
}
|
|
23
|
+
export interface ReadTimelineChangesQuery {
|
|
24
|
+
readonly after?: number | bigint;
|
|
25
|
+
readonly limit?: number | bigint;
|
|
26
|
+
}
|
|
27
|
+
export interface TimelineChange {
|
|
28
|
+
readonly cursor: number | bigint;
|
|
29
|
+
readonly event: TimelineEvent;
|
|
30
|
+
}
|
|
31
|
+
export interface TimelineChanges {
|
|
32
|
+
readonly changes: readonly (TimelineChange)[];
|
|
33
|
+
readonly next_cursor: number | bigint;
|
|
34
|
+
}
|
|
35
|
+
export interface TimelineContext {
|
|
36
|
+
readonly event: TimelineEvent;
|
|
37
|
+
readonly before: readonly (TimelineEvent)[];
|
|
38
|
+
readonly after: readonly (TimelineEvent)[];
|
|
39
|
+
readonly next_cursor: string | null;
|
|
40
|
+
readonly previous_cursor: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface TimelineEvent {
|
|
43
|
+
readonly event_id: string;
|
|
44
|
+
readonly room_id: string;
|
|
45
|
+
readonly sender: string;
|
|
46
|
+
readonly origin_server_ts: number | bigint;
|
|
47
|
+
readonly event_type: string;
|
|
48
|
+
readonly kind: string;
|
|
49
|
+
readonly body: string | null;
|
|
50
|
+
readonly target_event_id: string | null;
|
|
51
|
+
readonly reply_to_event_id: string | null;
|
|
52
|
+
readonly thread_root_event_id: string | null;
|
|
53
|
+
readonly decrypted: boolean;
|
|
54
|
+
readonly redacted: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface TimelinePage {
|
|
57
|
+
readonly events: readonly (TimelineEvent)[];
|
|
58
|
+
readonly next_cursor: string | null;
|
|
59
|
+
readonly previous_cursor: string | null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RequestOptions } from "../../api/options.js";
|
|
2
|
+
import type { Transport } from "../../internal/transport/client.js";
|
|
3
|
+
import type { StartVerificationRequest, VerificationActionRequest, VerificationStatus, VerificationsPage } from "./types.js";
|
|
4
|
+
export declare class VerificationClient {
|
|
5
|
+
private readonly transport;
|
|
6
|
+
constructor(transport: Transport);
|
|
7
|
+
list(options?: RequestOptions): Promise<VerificationsPage>;
|
|
8
|
+
request(body: StartVerificationRequest, options?: RequestOptions): Promise<VerificationStatus>;
|
|
9
|
+
get(userId: string, flowId: string, options?: RequestOptions): Promise<VerificationStatus>;
|
|
10
|
+
action(userId: string, flowId: string, body: VerificationActionRequest, options?: RequestOptions): Promise<VerificationStatus>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class VerificationClient {
|
|
2
|
+
transport;
|
|
3
|
+
constructor(transport) {
|
|
4
|
+
this.transport = transport;
|
|
5
|
+
}
|
|
6
|
+
list(options = {}) {
|
|
7
|
+
return this.transport.call("listVerifications", { timeoutMs: 180000, ...options });
|
|
8
|
+
}
|
|
9
|
+
request(body, options = {}) {
|
|
10
|
+
return this.transport.call("requestVerification", { timeoutMs: 180000, ...options, body });
|
|
11
|
+
}
|
|
12
|
+
get(userId, flowId, options = {}) {
|
|
13
|
+
return this.transport.call("getVerification", { timeoutMs: 180000, ...options, path: { user_id: userId, flow_id: flowId } });
|
|
14
|
+
}
|
|
15
|
+
action(userId, flowId, body, options = {}) {
|
|
16
|
+
return this.transport.call("actOnVerification", { timeoutMs: 180000, ...options, path: { user_id: userId, flow_id: flowId }, body });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { StartVerificationRequest, VerificationActionRequest, VerificationStatus, VerificationsPage } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface StartVerificationRequest {
|
|
2
|
+
readonly user_id: string;
|
|
3
|
+
readonly device_id: string;
|
|
4
|
+
}
|
|
5
|
+
export interface VerificationActionRequest {
|
|
6
|
+
readonly action: "accept" | "start" | "confirm" | "mismatch" | "cancel";
|
|
7
|
+
readonly expected_decimals?: readonly (number | bigint)[];
|
|
8
|
+
}
|
|
9
|
+
export interface VerificationStatus {
|
|
10
|
+
readonly user_id: string;
|
|
11
|
+
readonly flow_id: string;
|
|
12
|
+
readonly device_id: string | null;
|
|
13
|
+
readonly state: string;
|
|
14
|
+
readonly decimals: readonly (number | bigint)[];
|
|
15
|
+
readonly emoji: readonly (string)[];
|
|
16
|
+
readonly cancel_code: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface VerificationsPage {
|
|
19
|
+
readonly verifications: readonly (VerificationStatus)[];
|
|
20
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { AgentIMClient } from "./api/client.js";
|
|
2
|
+
export { validateLocalRequest, localRequestSchema } from "./api/request-data.js";
|
|
3
|
+
export type { LocalRequestData } from "./api/request-data.js";
|
|
4
|
+
export { parseJSON as parseAgentIMJSON, stringifyJSON as stringifyAgentIMJSON } from "./internal/protocol/codec.js";
|
|
5
|
+
export type { PairingDecisionRequest, PairingList, PairingRequest } from "./features/pairing/index.js";
|
|
6
|
+
export type { ClientOptions, RequestOptions } from "./api/options.js";
|
|
7
|
+
export { AgentIMError, ApiError, ValidationError, ProtocolError, TransportError, RequestCancelledError, RequestTimeoutError, ClientClosedError, AuthenticationError, OperationError, ResponseTooLargeError, } from "./api/errors.js";
|
|
8
|
+
export type { Contact, ContactAction, ContactActionRequest, ContactPage, ContactsQuery, } from "./features/contacts/index.js";
|
|
9
|
+
export type { ConversationDetails, ConversationsPage, ConversationsQuery, ConversationCreationStatus, InvitationDecisionRequest, Conversation, CreateConversationRequest, InviteRequest, JoinConversationRequest, KickRequest, LocalLeaveConversationRequest, MembersPage, MembersPageMembersItem, OpenDirectRequest, PowerRequest, } from "./features/conversations/index.js";
|
|
10
|
+
export type { ClaimDeliveryRequest, ClaimedDelivery, DeliveryPage, DeliveryResult, LeaseRequest, RenewLeaseRequest, ReplyDeliveryRequest, ReplyFileDeliveryRequest, } from "./features/deliveries/index.js";
|
|
11
|
+
export type { DiscoveryQuery, } from "./features/discovery/index.js";
|
|
12
|
+
export type { ClientStatus, IdentityStatus, LoginRequest, OperationResult, RegisterRequest, PublicRegisterRequest, ShutdownClientRequest, ShutdownClientResponse, } from "./features/identity/index.js";
|
|
13
|
+
export type { InboxPage, ReadInboxQuery, ReceivedMessage, SendFileRequest, SendTextRequest, SentEvent, } from "./features/messages/index.js";
|
|
14
|
+
export type { EnqueueFileRequest, EnqueueTextRequest, OutboxActionRequest, OutboxItem, OutboxPage, OutboxQuery, } from "./features/outbox/index.js";
|
|
15
|
+
export type { AgentProfile, ProfilePage, ProfileUpdate, UpdateProfileRequest, } from "./features/profiles/index.js";
|
|
16
|
+
export type { HistoryRoomStatus, ReliabilityStatus, RescanRequest, } from "./features/reliability/index.js";
|
|
17
|
+
export type { ErrorDiagnostics } from "./api/errors.js";
|
|
18
|
+
export type { AccountCredentialFile, AccountCredentialState, AccountLoginRequest, AuthorizedDeviceLoginRequest, IdentityLoginStatus } from "./features/identity/types.js";
|
|
19
|
+
export type { CredentialRevokeRequest, CredentialRevocation } from "./features/identity/types.js";
|
|
20
|
+
export type { ExportChatKeysRequest, ImportChatKeysRequest, ChatKeyBackup, ChatKeyImportResult } from "./features/encryption/index.js";
|
|
21
|
+
export type { EffectiveMessage, ReadEventContextQuery, ReadEventRelationsQuery, ReadRoomHistoryQuery, ReadTimelineChangesQuery, TimelineChange, TimelineChanges, TimelineContext, TimelineEvent, TimelinePage } from "./features/timeline/index.js";
|
|
22
|
+
export type { DeleteDevicesRequest, DeviceAuthResult, DeviceInfo, DevicesPage, RenameDeviceRequest } from "./features/devices/index.js";
|
|
23
|
+
export type { StartVerificationRequest, VerificationActionRequest, VerificationStatus, VerificationsPage } from "./features/verification/index.js";
|
|
24
|
+
export type { MessageMutationRequest, MessageMutationResult } from "./features/messages/index.js";
|
|
25
|
+
export type { BackupStatus, BootstrapSigningRequest, CrossSigningStatus, EnableBackupRequest, RecoverBackupRequest, SigningAuthResult, WaitBackupRequest } from "./features/encryption/index.js";
|
|
26
|
+
export type { DeliveryBoundary, DeliveryBoundaryRequest } from "./features/deliveries/index.js";
|
|
27
|
+
export type { ThreadMessageRequest } from "./features/messages/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AgentIMClient } from "./api/client.js";
|
|
2
|
+
export { validateLocalRequest, localRequestSchema } from "./api/request-data.js";
|
|
3
|
+
export { parseJSON as parseAgentIMJSON, stringifyJSON as stringifyAgentIMJSON } from "./internal/protocol/codec.js";
|
|
4
|
+
export { AgentIMError, ApiError, ValidationError, ProtocolError, TransportError, RequestCancelledError, RequestTimeoutError, ClientClosedError, AuthenticationError, OperationError, ResponseTooLargeError, } from "./api/errors.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Decode integer tokens before Number rounding can corrupt a cursor or u64. */
|
|
2
|
+
export declare function parseJSON(text: string): unknown;
|
|
3
|
+
/** Keep bigint as a JSON number, never a quoted string or a rounded Number. */
|
|
4
|
+
export declare function stringifyJSON(value: unknown): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ProtocolError, ValidationError } from "../../api/errors.js";
|
|
2
|
+
// Node 22.21 supports these native APIs; TypeScript ES2023 does not declare them.
|
|
3
|
+
const nativeJSON = JSON;
|
|
4
|
+
/** Decode integer tokens before Number rounding can corrupt a cursor or u64. */
|
|
5
|
+
export function parseJSON(text) {
|
|
6
|
+
try {
|
|
7
|
+
return nativeJSON.parse(text, (_key, value, context) => {
|
|
8
|
+
if (typeof value !== "number")
|
|
9
|
+
return value;
|
|
10
|
+
if (!Number.isFinite(value))
|
|
11
|
+
throw new ProtocolError("Non-finite JSON number");
|
|
12
|
+
if (!Number.isInteger(value))
|
|
13
|
+
return value;
|
|
14
|
+
const source = context?.source;
|
|
15
|
+
if (!source)
|
|
16
|
+
throw new ProtocolError("Native lossless JSON parsing is unavailable");
|
|
17
|
+
const integer = exactInteger(source);
|
|
18
|
+
return integer >= BigInt(Number.MIN_SAFE_INTEGER) && integer <= BigInt(Number.MAX_SAFE_INTEGER)
|
|
19
|
+
? Number(integer) : integer;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error instanceof ProtocolError)
|
|
24
|
+
throw error;
|
|
25
|
+
throw new ProtocolError("Invalid JSON response");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function exactInteger(source) {
|
|
29
|
+
if (/^-?(0|[1-9][0-9]*)$/.test(source))
|
|
30
|
+
return BigInt(source);
|
|
31
|
+
const parts = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(source);
|
|
32
|
+
if (!parts?.[2])
|
|
33
|
+
throw new ProtocolError("Invalid JSON number token");
|
|
34
|
+
const fraction = parts[3] ?? "";
|
|
35
|
+
const coefficient = BigInt(parts[2] + fraction);
|
|
36
|
+
if (coefficient === 0n)
|
|
37
|
+
return 0n;
|
|
38
|
+
const power = Number(parts[4] ?? 0) - fraction.length;
|
|
39
|
+
if (!Number.isSafeInteger(power) || Math.abs(power) > 1000) {
|
|
40
|
+
throw new ProtocolError("JSON number exponent is outside the supported range");
|
|
41
|
+
}
|
|
42
|
+
const scale = 10n ** BigInt(Math.abs(power));
|
|
43
|
+
if (power < 0 && coefficient % scale !== 0n) {
|
|
44
|
+
throw new ProtocolError("Fractional JSON number rounded to an integer");
|
|
45
|
+
}
|
|
46
|
+
const integer = power < 0 ? coefficient / scale : coefficient * scale;
|
|
47
|
+
return parts[1] === "-" ? -integer : integer;
|
|
48
|
+
}
|
|
49
|
+
/** Keep bigint as a JSON number, never a quoted string or a rounded Number. */
|
|
50
|
+
export function stringifyJSON(value) {
|
|
51
|
+
try {
|
|
52
|
+
const text = JSON.stringify(value, (_key, field) => {
|
|
53
|
+
if (typeof field === "bigint")
|
|
54
|
+
return nativeJSON.rawJSON(field.toString());
|
|
55
|
+
if (typeof field === "number" && !Number.isSafeInteger(field)) {
|
|
56
|
+
throw new ValidationError("JSON numeric inputs must be safe integers or bigint");
|
|
57
|
+
}
|
|
58
|
+
return field;
|
|
59
|
+
});
|
|
60
|
+
if (text === undefined)
|
|
61
|
+
throw new ValidationError("JSON body is required");
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof ValidationError)
|
|
66
|
+
throw error;
|
|
67
|
+
throw new ValidationError("Request is not JSON serializable");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ValidationError } from "../../api/errors.js";
|
|
2
|
+
/** Snapshot plain data once, so getters/toJSON cannot replace a validated ID. */
|
|
3
|
+
export function snapshotInput(value, ancestors = new Set(), depth = 0) {
|
|
4
|
+
if (value === null || typeof value !== "object")
|
|
5
|
+
return value;
|
|
6
|
+
if (depth > 128 || ancestors.has(value))
|
|
7
|
+
throw new ValidationError("Request contains a cycle or excessive nesting");
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
if (prototype !== Object.prototype && prototype !== null && prototype !== Array.prototype) {
|
|
10
|
+
throw new ValidationError("Request values must use plain JSON data objects");
|
|
11
|
+
}
|
|
12
|
+
if ("toJSON" in value)
|
|
13
|
+
throw new ValidationError("Request values must not define toJSON");
|
|
14
|
+
ancestors.add(value);
|
|
15
|
+
try {
|
|
16
|
+
const fields = Object.create(null);
|
|
17
|
+
for (const name of Reflect.ownKeys(value)) {
|
|
18
|
+
if (Array.isArray(value) && name === "length")
|
|
19
|
+
continue;
|
|
20
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
21
|
+
if (typeof name !== "string" || !descriptor?.enumerable || !("value" in descriptor)) {
|
|
22
|
+
throw new ValidationError("Request values must contain enumerable data properties only");
|
|
23
|
+
}
|
|
24
|
+
fields[name] = snapshotInput(descriptor.value, ancestors, depth + 1);
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
if (Object.keys(fields).length !== value.length
|
|
28
|
+
|| Object.keys(fields).some((name, index) => name !== String(index))) {
|
|
29
|
+
throw new ValidationError("Sparse or decorated arrays are not JSON request values");
|
|
30
|
+
}
|
|
31
|
+
return Array.from({ length: value.length }, (_item, index) => fields[String(index)]);
|
|
32
|
+
}
|
|
33
|
+
return fields;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
ancestors.delete(value);
|
|
37
|
+
}
|
|
38
|
+
}
|