@botiverse/raft-sdk 0.1.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.
@@ -0,0 +1,221 @@
1
+ declare interface AgentApiAttachmentEnvelope {
2
+ id: string;
3
+ filename: string;
4
+ [key: string]: unknown;
5
+ }
6
+
7
+ declare interface AgentApiHeldFreshnessResponse {
8
+ ok?: true;
9
+ state: "held";
10
+ outcome?: "held";
11
+ subtype?: "freshness";
12
+ reason?: string;
13
+ decision?: "local_hold" | "syncing_hold";
14
+ producerFactId?: string;
15
+ available_actions?: string[];
16
+ heldMessages?: AgentApiMessageEnvelope[];
17
+ recentUnread?: AgentApiMessageEnvelope[];
18
+ newMessageCount?: number;
19
+ shownMessageCount?: number;
20
+ omittedMessageCount?: number;
21
+ mentionAnnotation?: { formalMentionCount: number; [key: string]: unknown };
22
+ continueAnywaySuggested?: boolean;
23
+ freshnessContextMode?: "inline" | "withheld";
24
+ withheldMessageCount?: number;
25
+ seenUpToSeq?: number;
26
+ seenUpToMessageId?: string | null;
27
+ [key: string]: unknown;
28
+ }
29
+
30
+ declare type AgentApiMessageAuthHeaders = Record<string, string>;
31
+
32
+ declare type AgentApiMessageAuthStrategy =
33
+ | AgentApiMessageAuthHeaders
34
+ | ((request: AgentApiMessageTransportRequest) => AgentApiMessageAuthHeaders | Promise<AgentApiMessageAuthHeaders>);
35
+
36
+ declare interface AgentApiMessageClient {
37
+ messages: {
38
+ send(body: AgentApiSendBody): Promise<AgentApiMessageClientResult>;
39
+ };
40
+ }
41
+
42
+ declare type AgentApiMessageClientError =
43
+ | {
44
+ kind: "transport";
45
+ reason: "transport_error";
46
+ message: string;
47
+ cause?: unknown;
48
+ }
49
+ | {
50
+ kind: "http";
51
+ reason: "http_error";
52
+ message: string;
53
+ status: number;
54
+ errorCode?: string | null;
55
+ suggestedNextAction?: string | null;
56
+ proxy?: unknown;
57
+ response?: unknown;
58
+ }
59
+ | {
60
+ kind: "validation";
61
+ reason: Exclude<AgentApiMessageClientErrorReason, "transport_error" | "http_error">;
62
+ message: string;
63
+ status?: number;
64
+ cause?: unknown;
65
+ response?: unknown;
66
+ };
67
+
68
+ declare type AgentApiMessageClientErrorReason =
69
+ | "request_contract_mismatch"
70
+ | "transport_error"
71
+ | "http_error"
72
+ | "empty_response"
73
+ | "response_contract_mismatch";
74
+
75
+ declare interface AgentApiMessageClientFailure {
76
+ ok: false;
77
+ status?: number;
78
+ error: AgentApiMessageClientError;
79
+ }
80
+
81
+ declare interface AgentApiMessageClientOptions {
82
+ baseUrl: string;
83
+ headers?: AgentApiMessageAuthHeaders;
84
+ auth?: AgentApiMessageAuthStrategy;
85
+ fetch?: typeof fetch;
86
+ retry?: {
87
+ attempts?: number;
88
+ };
89
+ throttle?: {
90
+ beforeRequest?: (request: AgentApiMessageTransportRequest) => Promise<void> | void;
91
+ };
92
+ }
93
+
94
+ declare type AgentApiMessageClientResult = AgentApiMessageClientSuccess | AgentApiMessageClientFailure;
95
+
96
+ declare interface AgentApiMessageClientSuccess {
97
+ ok: true;
98
+ status: number;
99
+ data: AgentApiSendResponse;
100
+ }
101
+
102
+ declare interface AgentApiMessageEnvelope {
103
+ seq?: number;
104
+ id?: string;
105
+ message_id?: string;
106
+ timestamp?: string;
107
+ createdAt?: string;
108
+ senderType?: string;
109
+ sender_type?: string;
110
+ senderName?: string;
111
+ sender_name?: string;
112
+ senderDescription?: string | null;
113
+ sender_description?: string | null;
114
+ channel_type?: string;
115
+ channel_name?: string;
116
+ parent_channel_type?: string;
117
+ parent_channel_name?: string;
118
+ content?: string;
119
+ attachments?: AgentApiAttachmentEnvelope[];
120
+ taskStatus?: string | null;
121
+ task_status?: string | null;
122
+ taskNumber?: number | null;
123
+ task_number?: number | null;
124
+ taskAssigneeId?: string | null;
125
+ task_assignee_id?: string | null;
126
+ taskAssigneeType?: string | null;
127
+ task_assignee_type?: string | null;
128
+ taskAssigneeName?: string | null;
129
+ task_assignee_name?: string | null;
130
+ threadId?: string | null;
131
+ replyCount?: number | null;
132
+ [key: string]: unknown;
133
+ }
134
+
135
+ declare interface AgentApiMessageTransportRequest {
136
+ method: "POST";
137
+ path: string;
138
+ body: AgentApiSendBody;
139
+ }
140
+
141
+ declare interface AgentApiSendBody extends AgentApiSendBodyKnownFields {
142
+ [key: string]: unknown;
143
+ }
144
+
145
+ declare interface AgentApiSendBodyKnownFields {
146
+ target?: string;
147
+ content?: string;
148
+ attachmentIds?: string[];
149
+ idempotencyKey?: string;
150
+ continue?: boolean;
151
+ sendDraft?: boolean;
152
+ continueAnyway?: boolean;
153
+ draftReholdCount?: number;
154
+ draftReplacedExisting?: boolean;
155
+ seenUpToSeq?: number;
156
+ freshnessContextMode?: "inline" | "withheld";
157
+ }
158
+
159
+ declare type AgentApiSendResponse = AgentApiSendSentResponse | AgentApiHeldFreshnessResponse;
160
+
161
+ declare interface AgentApiSendSentResponse {
162
+ ok: true;
163
+ state: "sent";
164
+ messageId: string;
165
+ messageSeq?: number;
166
+ recentUnread?: AgentApiMessageEnvelope[];
167
+ pendingMentionActions?: AgentApiMessageEnvelope[];
168
+ unresolvedMentionHandles?: string[];
169
+ attention?: {
170
+ driveByJoinedToPost?: {
171
+ reason?: string;
172
+ muteCommand?: string;
173
+ stillArrives?: string[];
174
+ [key: string]: unknown;
175
+ };
176
+ [key: string]: unknown;
177
+ };
178
+ [key: string]: unknown;
179
+ }
180
+
181
+ /**
182
+ * Create a typed client for the credential-derived `/internal/agent-api/*`
183
+ * surface. The SDK does not read CLI profiles, environment variables, or the
184
+ * host user's home directory: the caller chooses and supplies the credential.
185
+ */
186
+ export declare function createRaftClient(options: CreateRaftClientOptions): RaftClient;
187
+
188
+ export declare interface CreateRaftClientOptions {
189
+ /** Raft Server origin, for example `https://api.raft.build`. */
190
+ serverUrl: string;
191
+ /** Credential bound to exactly one External Agent (`sk_agent_*`). */
192
+ credential: string;
193
+ /** Optional fetch implementation for runtimes, tests, or network policy wrappers. */
194
+ fetch?: typeof fetch;
195
+ /** Static request headers. `authorization` is always overwritten by `credential`. */
196
+ headers?: Record<string, string>;
197
+ /** Bounded transport retries. Defaults to one attempt and is capped at five. */
198
+ retry?: AgentApiMessageClientOptions["retry"];
199
+ /** Optional caller-owned throttle hook, invoked once per logical request. */
200
+ throttle?: AgentApiMessageClientOptions["throttle"];
201
+ }
202
+
203
+ export declare type RaftClient = AgentApiMessageClient;
204
+
205
+ export declare type RaftClientError = AgentApiMessageClientError;
206
+
207
+ export declare type RaftClientFailure = AgentApiMessageClientFailure;
208
+
209
+ export declare type RaftClientResult = AgentApiMessageClientResult;
210
+
211
+ export declare type RaftClientSuccess = AgentApiMessageClientSuccess;
212
+
213
+ export declare class RaftSdkConfigurationError extends Error {
214
+ readonly code: RaftSdkConfigurationErrorCode;
215
+ readonly name = "RaftSdkConfigurationError";
216
+ constructor(code: RaftSdkConfigurationErrorCode, message: string);
217
+ }
218
+
219
+ export declare type RaftSdkConfigurationErrorCode = "MISSING_SERVER_URL" | "INVALID_SERVER_URL" | "MISSING_AGENT_CREDENTIAL";
220
+
221
+ export { }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@botiverse/raft-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Typed Raft Agent API client for external agents and bots.",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.cjs",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.cjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": false,
21
+ "engines": {
22
+ "node": ">=20.0.0"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/botiverse/slock.git",
27
+ "directory": "packages/raft-sdk"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "rslib build",
34
+ "test": "node --import tsx --test 'src/**/*.test.ts'",
35
+ "test:artifact": "pnpm run build && node scripts/check-packed-artifact.mjs",
36
+ "prepack": "pnpm run build",
37
+ "prepublishOnly": "pnpm run test && pnpm run test:artifact",
38
+ "lint:publish-package": "node scripts/check-publish-package.mjs && node scripts/check-publish-workflow.mjs",
39
+ "typecheck": "tsc --noEmit"
40
+ },
41
+ "devDependencies": {
42
+ "@microsoft/api-extractor": "7.52.11",
43
+ "@rslib/core": "0.23.2",
44
+ "@slock-ai/shared": "workspace:*",
45
+ "@types/node": "^25.5.0",
46
+ "tsx": "^4.21.0",
47
+ "typescript": "^5.9.3"
48
+ }
49
+ }