@kraki/protocol 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kraki Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ export interface Channel {
2
+ id: string;
3
+ ownerId: string;
4
+ name?: string;
5
+ createdAt: string;
6
+ }
7
+ //# sourceMappingURL=channels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../src/channels.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,5 @@
1
+ // ------------------------------------------------------------
2
+ // Channel types
3
+ // ------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=channels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.js","sourceRoot":"","sources":["../src/channels.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gBAAgB;AAChB,+DAA+D"}
@@ -0,0 +1,43 @@
1
+ export type DeviceRole = 'tentacle' | 'app';
2
+ export type DeviceKind = 'desktop' | 'server' | 'vm' | 'web' | 'ios' | 'android';
3
+ export interface Device {
4
+ id: string;
5
+ channelId: string;
6
+ name: string;
7
+ role: DeviceRole;
8
+ kind?: DeviceKind;
9
+ publicKey?: string;
10
+ lastSeen: string;
11
+ createdAt: string;
12
+ }
13
+ export interface DeviceSummary {
14
+ id: string;
15
+ name: string;
16
+ role: DeviceRole;
17
+ kind?: DeviceKind;
18
+ /** Public key for auth (RSASSA-PKCS1-v1_5) */
19
+ publicKey?: string;
20
+ /** Public key for E2E encryption (RSA-OAEP). If absent, use publicKey. */
21
+ encryptionKey?: string;
22
+ online: boolean;
23
+ /** Capabilities reported by the device (e.g. available models) */
24
+ capabilities?: DeviceCapabilities;
25
+ }
26
+ export interface DeviceInfo {
27
+ name: string;
28
+ role: DeviceRole;
29
+ kind?: DeviceKind;
30
+ /** Public key for challenge-response auth (RSASSA-PKCS1-v1_5, SPKI base64) */
31
+ publicKey?: string;
32
+ /** Public key for E2E encryption (RSA-OAEP, SPKI base64). If omitted, publicKey is used. */
33
+ encryptionKey?: string;
34
+ /** Client-provided stable device ID for reconnection. If omitted, server generates one. */
35
+ deviceId?: string;
36
+ /** Capabilities reported by the device */
37
+ capabilities?: DeviceCapabilities;
38
+ }
39
+ export interface DeviceCapabilities {
40
+ /** Available agent models (e.g. ["claude-sonnet-4", "gpt-4.1"]) */
41
+ models?: string[];
42
+ }
43
+ //# sourceMappingURL=devices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["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@@ -0,0 +1,5 @@
1
+ // ------------------------------------------------------------
2
+ // Device types
3
+ // ------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=devices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices.js","sourceRoot":"","sources":["../src/devices.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,eAAe;AACf,+DAA+D"}
@@ -0,0 +1,6 @@
1
+ export * from './messages.js';
2
+ export * from './channels.js';
3
+ export * from './devices.js';
4
+ export * from './sessions.js';
5
+ export * from './tools.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ // ============================================================
2
+ // Kraki Protocol — The shared contract
3
+ // ============================================================
4
+ // All packages (head, tentacle, app) import from here.
5
+ // Change types here = change everywhere.
6
+ // ============================================================
7
+ export * from './messages.js';
8
+ export * from './channels.js';
9
+ export * from './devices.js';
10
+ export * from './sessions.js';
11
+ export * from './tools.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uCAAuC;AACvC,+DAA+D;AAC/D,uDAAuD;AACvD,yCAAyC;AACzC,+DAA+D;AAE/D,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,313 @@
1
+ interface BaseEnvelope {
2
+ channel: string;
3
+ deviceId: string;
4
+ seq: number;
5
+ timestamp: string;
6
+ sessionId?: string;
7
+ }
8
+ export interface SessionCreatedMessage extends BaseEnvelope {
9
+ type: 'session_created';
10
+ payload: {
11
+ agent: string;
12
+ model?: string;
13
+ /** Echoed from create_session for request tracking */
14
+ requestId?: string;
15
+ };
16
+ }
17
+ export interface SessionEndedMessage extends BaseEnvelope {
18
+ type: 'session_ended';
19
+ payload: {
20
+ reason: string;
21
+ };
22
+ }
23
+ export interface UserMessage extends BaseEnvelope {
24
+ type: 'user_message';
25
+ payload: {
26
+ content: string;
27
+ };
28
+ }
29
+ export interface AgentMessage extends BaseEnvelope {
30
+ type: 'agent_message';
31
+ payload: {
32
+ content: string;
33
+ attachments?: string[];
34
+ };
35
+ }
36
+ export interface AgentMessageDelta extends BaseEnvelope {
37
+ type: 'agent_message_delta';
38
+ payload: {
39
+ content: string;
40
+ };
41
+ }
42
+ export interface PermissionRequest extends BaseEnvelope {
43
+ type: 'permission';
44
+ payload: ToolArgs & {
45
+ id: string;
46
+ description: string;
47
+ };
48
+ }
49
+ export interface QuestionRequest extends BaseEnvelope {
50
+ type: 'question';
51
+ payload: {
52
+ id: string;
53
+ question: string;
54
+ choices?: string[];
55
+ };
56
+ }
57
+ export interface ToolStartMessage extends BaseEnvelope {
58
+ type: 'tool_start';
59
+ payload: ToolArgs & {
60
+ /** Unique ID for this tool invocation (matches tool_complete) */
61
+ toolCallId?: string;
62
+ };
63
+ }
64
+ export interface ToolCompleteMessage extends BaseEnvelope {
65
+ type: 'tool_complete';
66
+ payload: ToolArgs & {
67
+ result: string;
68
+ /** Unique ID matching the tool_start */
69
+ toolCallId?: string;
70
+ };
71
+ }
72
+ export interface IdleMessage extends BaseEnvelope {
73
+ type: 'idle';
74
+ payload: Record<string, never>;
75
+ }
76
+ export interface ErrorMessage extends BaseEnvelope {
77
+ type: 'error';
78
+ payload: {
79
+ message: string;
80
+ };
81
+ }
82
+ export interface SessionModeSetMessage extends BaseEnvelope {
83
+ type: 'session_mode_set';
84
+ payload: {
85
+ mode: 'ask' | 'auto';
86
+ };
87
+ }
88
+ export type ProducerMessage = SessionCreatedMessage | SessionEndedMessage | UserMessage | AgentMessage | AgentMessageDelta | PermissionRequest | QuestionRequest | ToolStartMessage | ToolCompleteMessage | IdleMessage | ErrorMessage | SessionModeSetMessage;
89
+ /** Message types the head persists for session recovery */
90
+ export type StoredMessageType = 'session_created' | 'session_ended' | 'user_message' | 'agent_message' | 'permission' | 'question' | 'tool_start' | 'tool_complete' | 'error' | 'send_input' | 'approve' | 'deny' | 'always_allow' | 'answer' | 'kill_session' | 'session_mode_set';
91
+ /** Message types forwarded in real-time only (not persisted) */
92
+ export type TransientMessageType = 'agent_message_delta' | 'idle' | 'create_session';
93
+ export interface SendInputMessage extends BaseEnvelope {
94
+ type: 'send_input';
95
+ payload: {
96
+ text: string;
97
+ attachments?: string[];
98
+ };
99
+ }
100
+ export interface ApproveMessage extends BaseEnvelope {
101
+ type: 'approve';
102
+ payload: {
103
+ permissionId: string;
104
+ };
105
+ }
106
+ export interface DenyMessage extends BaseEnvelope {
107
+ type: 'deny';
108
+ payload: {
109
+ permissionId: string;
110
+ };
111
+ }
112
+ export interface AlwaysAllowMessage extends BaseEnvelope {
113
+ type: 'always_allow';
114
+ payload: {
115
+ permissionId: string;
116
+ /** Tool kind to add to the allow list (e.g. 'shell', 'write') */
117
+ toolKind?: string;
118
+ };
119
+ }
120
+ export interface AnswerMessage extends BaseEnvelope {
121
+ type: 'answer';
122
+ payload: {
123
+ questionId: string;
124
+ answer: string;
125
+ };
126
+ }
127
+ export interface KillSessionMessage extends BaseEnvelope {
128
+ type: 'kill_session';
129
+ payload: Record<string, never>;
130
+ }
131
+ export interface AbortSessionMessage extends BaseEnvelope {
132
+ type: 'abort_session';
133
+ payload: Record<string, never>;
134
+ }
135
+ export interface CreateSessionMessage extends BaseEnvelope {
136
+ type: 'create_session';
137
+ payload: {
138
+ /** Client-generated request ID for tracking success/failure */
139
+ requestId: string;
140
+ /** Target tentacle device ID */
141
+ targetDeviceId: string;
142
+ /** Agent model to use (e.g. "claude-sonnet-4") */
143
+ model: string;
144
+ /** Initial prompt to send after session is created */
145
+ prompt?: string;
146
+ /** Working directory for the session */
147
+ cwd?: string;
148
+ };
149
+ }
150
+ export interface SetSessionModeMessage extends BaseEnvelope {
151
+ type: 'set_session_mode';
152
+ payload: {
153
+ mode: 'ask' | 'auto';
154
+ };
155
+ }
156
+ export type ConsumerMessage = SendInputMessage | ApproveMessage | DenyMessage | AlwaysAllowMessage | AnswerMessage | KillSessionMessage | AbortSessionMessage | CreateSessionMessage | SetSessionModeMessage;
157
+ export interface AuthMessage {
158
+ type: 'auth';
159
+ token?: string;
160
+ channelKey?: string;
161
+ /** One-time pairing token from QR code (alternative to token/channelKey) */
162
+ pairingToken?: string;
163
+ /** GitHub OAuth authorization code (exchanged server-side for access token) */
164
+ githubCode?: string;
165
+ device: DeviceInfo;
166
+ }
167
+ export interface AuthOkMessage {
168
+ type: 'auth_ok';
169
+ channel: string;
170
+ deviceId: string;
171
+ e2e: boolean;
172
+ devices: DeviceSummary[];
173
+ sessions: SessionSummary[];
174
+ /** Per-session last-read seq for this device (for unread tracking) */
175
+ readState?: Record<string, number>;
176
+ /** Channel owner identity (login, provider) for profile display */
177
+ user?: {
178
+ id: string;
179
+ login: string;
180
+ provider: string;
181
+ email?: string;
182
+ };
183
+ }
184
+ export interface AuthErrorMessage {
185
+ type: 'auth_error';
186
+ message: string;
187
+ }
188
+ export interface AuthChallengeMessage {
189
+ type: 'auth_challenge';
190
+ nonce: string;
191
+ }
192
+ export interface AuthResponseMessage {
193
+ type: 'auth_response';
194
+ deviceId: string;
195
+ signature: string;
196
+ }
197
+ export interface ServerErrorMessage {
198
+ type: 'server_error';
199
+ message: string;
200
+ /** Echoed from create_session for request tracking */
201
+ requestId?: string;
202
+ }
203
+ export interface ReplayMessage {
204
+ type: 'replay';
205
+ afterSeq: number;
206
+ sessionId?: string;
207
+ }
208
+ export interface MarkReadMessage {
209
+ type: 'mark_read';
210
+ sessionId: string;
211
+ /** The highest seq the client has seen for this session */
212
+ seq: number;
213
+ }
214
+ export interface CreatePairingTokenMessage {
215
+ type: 'create_pairing_token';
216
+ }
217
+ /** One-shot pairing token request — no device registration needed */
218
+ export interface RequestPairingTokenMessage {
219
+ type: 'request_pairing_token';
220
+ /** Auth token (e.g. GitHub token) to prove identity */
221
+ token: string;
222
+ }
223
+ export interface PairingTokenCreatedMessage {
224
+ type: 'pairing_token_created';
225
+ token: string;
226
+ expiresIn: number;
227
+ }
228
+ export interface PingMessage {
229
+ type: 'ping';
230
+ }
231
+ export interface PongMessage {
232
+ type: 'pong';
233
+ }
234
+ /** Pre-auth request to discover server capabilities. */
235
+ export interface AuthInfoRequest {
236
+ type: 'auth_info';
237
+ }
238
+ /** Server response with supported auth modes and features. */
239
+ export interface AuthInfoResponse {
240
+ type: 'auth_info_response';
241
+ /** Supported auth modes (e.g. ['github', 'apikey', 'open']) */
242
+ authModes: string[];
243
+ /** Whether E2E encryption is enabled */
244
+ e2e: boolean;
245
+ /** Whether device pairing is enabled */
246
+ pairing: boolean;
247
+ /** GitHub OAuth client ID (present when GitHub OAuth is configured for web login) */
248
+ githubClientId?: string;
249
+ }
250
+ /** Global notification from head to all connected devices (tentacles + apps) */
251
+ export type HeadNotice = {
252
+ type: 'head_notice';
253
+ event: 'device_online';
254
+ data: {
255
+ device: DeviceSummary;
256
+ };
257
+ } | {
258
+ type: 'head_notice';
259
+ event: 'device_offline';
260
+ data: {
261
+ deviceId: string;
262
+ };
263
+ } | {
264
+ type: 'head_notice';
265
+ event: 'device_added';
266
+ data: {
267
+ device: DeviceSummary;
268
+ };
269
+ } | {
270
+ type: 'head_notice';
271
+ event: 'device_removed';
272
+ data: {
273
+ deviceId: string;
274
+ };
275
+ } | {
276
+ type: 'head_notice';
277
+ event: 'session_updated';
278
+ data: {
279
+ session: SessionSummary;
280
+ };
281
+ } | {
282
+ type: 'head_notice';
283
+ event: 'update_allow_list';
284
+ data: {
285
+ allowedTools: string[];
286
+ };
287
+ };
288
+ export type ControlMessage = AuthMessage | AuthOkMessage | AuthErrorMessage | AuthChallengeMessage | AuthResponseMessage | ServerErrorMessage | ReplayMessage | MarkReadMessage | CreatePairingTokenMessage | RequestPairingTokenMessage | PairingTokenCreatedMessage | AuthInfoRequest | AuthInfoResponse | PingMessage | PongMessage | HeadNotice;
289
+ export interface EncryptedMessage extends BaseEnvelope {
290
+ type: 'encrypted';
291
+ /** AES-256-GCM initialization vector (base64) */
292
+ iv: string;
293
+ /** AES-256-GCM encrypted payload (base64) — same for all recipients */
294
+ ciphertext: string;
295
+ /** AES-256-GCM authentication tag (base64) — tamper detection */
296
+ tag: string;
297
+ /** Per-device RSA-OAEP encrypted AES key (base64) */
298
+ keys: Record<string, string>;
299
+ /** Agent name exposed from session_created for head session registration */
300
+ agent?: string;
301
+ /** Model exposed from session_created for head session registration */
302
+ model?: string;
303
+ /** Target device ID for encrypted create_session routing */
304
+ targetDeviceId?: string;
305
+ /** Delivery hint: if true, head should forward but not persist (e.g. deltas, idle) */
306
+ ephemeral?: boolean;
307
+ }
308
+ export type Message = ProducerMessage | ConsumerMessage | ControlMessage | EncryptedMessage;
309
+ import type { DeviceSummary, DeviceRole, DeviceInfo } from './devices.js';
310
+ import type { SessionSummary } from './sessions.js';
311
+ import type { ToolArgs } from './tools.js';
312
+ export type { DeviceSummary, DeviceRole, DeviceInfo, SessionSummary, ToolArgs };
313
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,E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,WAAW,gBAAiB,SAAQ,YAAY;IACpD,IAAI,EAAE,WAAW,CAAC;IAClB,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAMD,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAG5F,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ // ------------------------------------------------------------
2
+ // Message types and envelope
3
+ // ------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,6BAA6B;AAC7B,+DAA+D"}
@@ -0,0 +1,19 @@
1
+ export interface Session {
2
+ id: string;
3
+ channelId: string;
4
+ deviceId: string;
5
+ agent: string;
6
+ model?: string;
7
+ messageCount: number;
8
+ lastSeq: number;
9
+ createdAt: string;
10
+ }
11
+ export interface SessionSummary {
12
+ id: string;
13
+ deviceId: string;
14
+ deviceName: string;
15
+ agent: string;
16
+ model?: string;
17
+ messageCount: number;
18
+ }
19
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,5 @@
1
+ // ------------------------------------------------------------
2
+ // Session types
3
+ // ------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gBAAgB;AAChB,+DAA+D"}
@@ -0,0 +1,44 @@
1
+ export interface ShellToolArgs {
2
+ command: string;
3
+ }
4
+ export interface WriteFileToolArgs {
5
+ path: string;
6
+ content: string;
7
+ }
8
+ export interface ReadFileToolArgs {
9
+ path: string;
10
+ }
11
+ export interface FetchUrlToolArgs {
12
+ url: string;
13
+ method?: string;
14
+ }
15
+ export interface McpToolArgs {
16
+ server: string;
17
+ tool: string;
18
+ params: Record<string, unknown>;
19
+ }
20
+ /** Known tool types with typed arguments */
21
+ export type KnownToolArgs = {
22
+ toolName: 'shell';
23
+ args: ShellToolArgs;
24
+ } | {
25
+ toolName: 'write_file';
26
+ args: WriteFileToolArgs;
27
+ } | {
28
+ toolName: 'read_file';
29
+ args: ReadFileToolArgs;
30
+ } | {
31
+ toolName: 'fetch_url';
32
+ args: FetchUrlToolArgs;
33
+ } | {
34
+ toolName: 'mcp';
35
+ args: McpToolArgs;
36
+ };
37
+ /** Fallback for agent-specific or future tools */
38
+ export interface UnknownToolArgs {
39
+ toolName: string;
40
+ args: Record<string, unknown>;
41
+ }
42
+ /** All possible tool shapes — known tools are typed, unknown allowed */
43
+ export type ToolArgs = KnownToolArgs | UnknownToolArgs;
44
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAM,IAAI,EAAE,aAAa,CAAA;CAAE,GAC/C;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACnD;IAAE,QAAQ,EAAE,WAAW,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,WAAW,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAQ,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAElD,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC"}
package/dist/tools.js ADDED
@@ -0,0 +1,5 @@
1
+ // ------------------------------------------------------------
2
+ // Tool types — known tool argument shapes
3
+ // ------------------------------------------------------------
4
+ export {};
5
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,0CAA0C;AAC1C,+DAA+D"}
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@kraki/protocol",
3
+ "version": "0.1.0",
4
+ "description": "Shared TypeScript types and message definitions for the Kraki protocol",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.7.0"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "clean": "rm -rf dist"
21
+ }
22
+ }