@harnesys/sdk 0.0.0-stage → 1.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 +21 -0
- package/README.md +80 -2
- package/dist/addon-context-factory.d.ts +6 -0
- package/dist/addon-context-factory.js +160 -0
- package/dist/addon-context.d.ts +346 -0
- package/dist/addon-context.js +0 -0
- package/dist/define-addon.d.ts +57 -0
- package/dist/define-addon.js +53 -0
- package/dist/families/config.d.ts +14 -0
- package/dist/families/config.js +16 -0
- package/dist/families/content.d.ts +28 -0
- package/dist/families/content.js +19 -0
- package/dist/families/field-spec.d.ts +100 -0
- package/dist/families/field-spec.js +85 -0
- package/dist/families/hook.d.ts +37 -0
- package/dist/families/hook.js +25 -0
- package/dist/families/job.d.ts +45 -0
- package/dist/families/job.js +26 -0
- package/dist/families/json-schema-value.d.ts +12 -0
- package/dist/families/json-schema-value.js +243 -0
- package/dist/families/json-schema.d.ts +36 -0
- package/dist/families/json-schema.js +101 -0
- package/dist/families/lsp.d.ts +18 -0
- package/dist/families/lsp.js +18 -0
- package/dist/families/mcp.d.ts +18 -0
- package/dist/families/mcp.js +18 -0
- package/dist/families/registry.d.ts +9 -0
- package/dist/families/registry.js +34 -0
- package/dist/families/route.d.ts +38 -0
- package/dist/families/route.js +37 -0
- package/dist/families/source-kind.d.ts +24 -0
- package/dist/families/source-kind.js +21 -0
- package/dist/families/tool-pack.d.ts +68 -0
- package/dist/families/tool-pack.js +57 -0
- package/dist/families/transport.d.ts +52 -0
- package/dist/families/transport.js +29 -0
- package/dist/families/trigger.d.ts +97 -0
- package/dist/families/trigger.js +46 -0
- package/dist/families/view.d.ts +255 -0
- package/dist/families/view.js +87 -0
- package/dist/families/viewer.d.ts +31 -0
- package/dist/families/viewer.js +26 -0
- package/dist/families/worker.d.ts +23 -0
- package/dist/families/worker.js +19 -0
- package/dist/host-client.d.ts +11 -0
- package/dist/host-client.js +30 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/manifest/branding.d.ts +14 -0
- package/dist/manifest/branding.js +18 -0
- package/dist/manifest/connections.d.ts +21 -0
- package/dist/manifest/connections.js +10 -0
- package/dist/manifest/json-schema.d.ts +2 -0
- package/dist/manifest/json-schema.js +13 -0
- package/dist/manifest/l10n.d.ts +9 -0
- package/dist/manifest/l10n.js +28 -0
- package/dist/manifest/manifest.d.ts +112 -0
- package/dist/manifest/manifest.js +45 -0
- package/dist/manifest/validate.d.ts +14 -0
- package/dist/manifest/validate.js +144 -0
- package/dist/permissions/permissions.d.ts +31 -0
- package/dist/permissions/permissions.js +53 -0
- package/dist/process-entry.d.ts +26 -0
- package/dist/process-entry.js +146 -0
- package/dist/protocol/envelope.d.ts +115 -0
- package/dist/protocol/envelope.js +72 -0
- package/dist/protocol/error.d.ts +67 -0
- package/dist/protocol/error.js +61 -0
- package/dist/protocol/handshake.d.ts +55 -0
- package/dist/protocol/handshake.js +26 -0
- package/dist/protocol/map.d.ts +1090 -0
- package/dist/protocol/map.js +127 -0
- package/dist/protocol/meta.d.ts +31 -0
- package/dist/protocol/meta.js +14 -0
- package/dist/protocol/method-spec.d.ts +13 -0
- package/dist/protocol/method-spec.js +9 -0
- package/dist/protocol/org-service-methods.d.ts +135 -0
- package/dist/protocol/org-service-methods.js +106 -0
- package/dist/protocol/shared.d.ts +389 -0
- package/dist/protocol/shared.js +231 -0
- package/dist/protocol/source-methods.d.ts +218 -0
- package/dist/protocol/source-methods.js +18 -0
- package/dist/protocol/thread-service-methods.d.ts +50 -0
- package/dist/protocol/thread-service-methods.js +32 -0
- package/dist/runtime.d.ts +25 -0
- package/dist/runtime.js +229 -0
- package/dist/testing/fake-db.d.ts +15 -0
- package/dist/testing/fake-db.js +120 -0
- package/dist/testing/fake-files.d.ts +9 -0
- package/dist/testing/fake-files.js +87 -0
- package/dist/testing/fake-host.d.ts +115 -0
- package/dist/testing/fake-host.js +217 -0
- package/dist/testing/fake-services.d.ts +63 -0
- package/dist/testing/fake-services.js +277 -0
- package/dist/testing/fixtures.d.ts +5 -0
- package/dist/testing/fixtures.js +101 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +2 -0
- package/package.json +66 -4
- package/src/addon-context-factory.ts +236 -0
- package/src/addon-context.ts +313 -0
- package/src/define-addon.ts +178 -0
- package/src/families/config.ts +24 -0
- package/src/families/content.ts +35 -0
- package/src/families/field-spec.ts +175 -0
- package/src/families/hook.ts +34 -0
- package/src/families/job.ts +41 -0
- package/src/families/json-schema-value.ts +322 -0
- package/src/families/json-schema.ts +167 -0
- package/src/families/lsp.ts +28 -0
- package/src/families/mcp.ts +28 -0
- package/src/families/registry.ts +44 -0
- package/src/families/route.ts +52 -0
- package/src/families/source-kind.ts +34 -0
- package/src/families/tool-pack.ts +92 -0
- package/src/families/transport.ts +52 -0
- package/src/families/trigger.ts +92 -0
- package/src/families/view.ts +144 -0
- package/src/families/viewer.ts +43 -0
- package/src/families/worker.ts +30 -0
- package/src/host-client.ts +52 -0
- package/src/index.ts +345 -0
- package/src/manifest/branding.ts +24 -0
- package/src/manifest/connections.ts +21 -0
- package/src/manifest/json-schema.ts +24 -0
- package/src/manifest/l10n.ts +39 -0
- package/src/manifest/manifest.ts +94 -0
- package/src/manifest/validate.ts +200 -0
- package/src/permissions/permissions.ts +79 -0
- package/src/process-entry.ts +205 -0
- package/src/protocol/envelope.ts +126 -0
- package/src/protocol/error.ts +81 -0
- package/src/protocol/handshake.ts +43 -0
- package/src/protocol/map.ts +339 -0
- package/src/protocol/meta.ts +26 -0
- package/src/protocol/method-spec.ts +40 -0
- package/src/protocol/org-service-methods.ts +148 -0
- package/src/protocol/shared.ts +345 -0
- package/src/protocol/source-methods.ts +61 -0
- package/src/protocol/thread-service-methods.ts +50 -0
- package/src/runtime.ts +332 -0
- package/src/testing/fake-db.ts +140 -0
- package/src/testing/fake-files.ts +114 -0
- package/src/testing/fake-host.ts +350 -0
- package/src/testing/fake-services.ts +345 -0
- package/src/testing/fixtures.ts +106 -0
- package/src/testing/index.ts +12 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const SqlParamSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
4
|
+
|
|
5
|
+
export const DbRowSchema = z.record(z.string(), z.unknown());
|
|
6
|
+
|
|
7
|
+
export const LogLevelSchema = z.enum(['debug', 'info', 'warn', 'error']);
|
|
8
|
+
export type LogLevel = z.infer<typeof LogLevelSchema>;
|
|
9
|
+
|
|
10
|
+
export const LogWriteParamsSchema = z.object({
|
|
11
|
+
level: LogLevelSchema,
|
|
12
|
+
message: z.string().min(1),
|
|
13
|
+
fields: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type MessageFormat = 'text' | 'markdown' | 'html';
|
|
17
|
+
|
|
18
|
+
export interface TransportAttachment {
|
|
19
|
+
id?: string;
|
|
20
|
+
kind?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
mimeType?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
path?: string;
|
|
25
|
+
dataBase64?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TransportOption {
|
|
29
|
+
id: string;
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TransportBindingSummary {
|
|
34
|
+
provider: string;
|
|
35
|
+
channel: string;
|
|
36
|
+
threadId: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const TransportBindingSummarySchema = z.object({
|
|
41
|
+
provider: z.string().min(1),
|
|
42
|
+
channel: z.string().min(1),
|
|
43
|
+
threadId: z.string().min(1),
|
|
44
|
+
createdAt: z.string().min(1),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const BindingWriteParamsSchema = z.object({
|
|
48
|
+
provider: z.string().min(1),
|
|
49
|
+
channel: z.string().min(1),
|
|
50
|
+
threadId: z.string().min(1),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const BindingChannelParamsSchema = z.object({
|
|
54
|
+
provider: z.string().min(1),
|
|
55
|
+
channel: z.string().min(1),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const OkResultSchema = z.object({ ok: z.literal(true) });
|
|
59
|
+
|
|
60
|
+
export interface TransportMessage {
|
|
61
|
+
channel: string;
|
|
62
|
+
text: string;
|
|
63
|
+
format?: MessageFormat;
|
|
64
|
+
replyTo?: string;
|
|
65
|
+
topic?: string;
|
|
66
|
+
attachments?: TransportAttachment[];
|
|
67
|
+
options?: TransportOption[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const TransportAttachmentSchema = z
|
|
71
|
+
.object({
|
|
72
|
+
id: z.string().optional(),
|
|
73
|
+
kind: z.string().optional(),
|
|
74
|
+
name: z.string().optional(),
|
|
75
|
+
mimeType: z.string().optional(),
|
|
76
|
+
url: z.string().min(1).optional(),
|
|
77
|
+
path: z.string().min(1).optional(),
|
|
78
|
+
dataBase64: z.string().min(1).optional(),
|
|
79
|
+
})
|
|
80
|
+
.refine(
|
|
81
|
+
(value) =>
|
|
82
|
+
[value.url, value.path, value.dataBase64].filter((entry) => entry !== undefined).length === 1,
|
|
83
|
+
{ message: 'exactly one of url, path or dataBase64 is required' },
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export const TransportOptionSchema = z.object({
|
|
87
|
+
id: z.string().min(1),
|
|
88
|
+
label: z.string().min(1),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const TransportMessageSchema = z.object({
|
|
92
|
+
channel: z.string().min(1),
|
|
93
|
+
text: z.string(),
|
|
94
|
+
format: z.enum(['text', 'markdown', 'html']).optional(),
|
|
95
|
+
replyTo: z.string().optional(),
|
|
96
|
+
topic: z.string().optional(),
|
|
97
|
+
attachments: z.array(TransportAttachmentSchema).optional(),
|
|
98
|
+
options: z.array(TransportOptionSchema).optional(),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export const HttpAuthSchema = z.object({
|
|
102
|
+
connection: z.string().min(1),
|
|
103
|
+
accountId: z.string().optional(),
|
|
104
|
+
scheme: z.enum(['bearer', 'basic', 'header', 'path']),
|
|
105
|
+
credentialKey: z.string().optional(),
|
|
106
|
+
header: z.string().optional(),
|
|
107
|
+
placeholder: z.string().min(1).optional(),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const HttpFetchParamsSchema = z.object({
|
|
111
|
+
url: z.string().url(),
|
|
112
|
+
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD']).default('GET'),
|
|
113
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
114
|
+
body: z.string().optional(),
|
|
115
|
+
bodyBase64: z.string().optional(),
|
|
116
|
+
responseEncoding: z.enum(['text', 'base64']).optional(),
|
|
117
|
+
auth: HttpAuthSchema.optional(),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export const HttpFetchResultSchema = z.object({
|
|
121
|
+
status: z.number().int(),
|
|
122
|
+
headers: z.record(z.string(), z.string()),
|
|
123
|
+
body: z.string().nullable(),
|
|
124
|
+
bodyBase64: z.string().optional(),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const CloudRemoteExportSchema = z.object({
|
|
128
|
+
mimeType: z.string().min(1),
|
|
129
|
+
extension: z.string().min(1),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export const CloudRemoteEntrySchema = z.object({
|
|
133
|
+
id: z.string().min(1),
|
|
134
|
+
name: z.string().min(1),
|
|
135
|
+
kind: z.enum(['file', 'folder']),
|
|
136
|
+
size: z.number().int().nonnegative().optional(),
|
|
137
|
+
modifiedAt: z.string().min(1).optional(),
|
|
138
|
+
mimeType: z.string().min(1).optional(),
|
|
139
|
+
export: CloudRemoteExportSchema.optional(),
|
|
140
|
+
});
|
|
141
|
+
export type CloudRemoteEntryWire = z.infer<typeof CloudRemoteEntrySchema>;
|
|
142
|
+
export type CloudRemoteExportWire = z.infer<typeof CloudRemoteExportSchema>;
|
|
143
|
+
|
|
144
|
+
const sourceSelector = {
|
|
145
|
+
sourceKind: z.string().min(1),
|
|
146
|
+
accountId: z.string().min(1).optional(),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const SourceListParamsSchema = z.object({
|
|
150
|
+
...sourceSelector,
|
|
151
|
+
folderId: z.string().min(1),
|
|
152
|
+
pageToken: z.string().optional(),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const SourceListResultSchema = z.object({
|
|
156
|
+
entries: z.array(CloudRemoteEntrySchema),
|
|
157
|
+
nextPageToken: z.string().optional(),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export const SourceStatParamsSchema = z.object({
|
|
161
|
+
...sourceSelector,
|
|
162
|
+
fileId: z.string().min(1),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const SourceStatResultSchema = z.object({
|
|
166
|
+
entry: CloudRemoteEntrySchema,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export const SourceReadParamsSchema = z.object({
|
|
170
|
+
...sourceSelector,
|
|
171
|
+
fileId: z.string().min(1),
|
|
172
|
+
offset: z.number().int().nonnegative().optional(),
|
|
173
|
+
length: z.number().int().positive().optional(),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const SourceBytesResultSchema = z.object({
|
|
177
|
+
data: z.string(),
|
|
178
|
+
eof: z.boolean(),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
export const SourceUploadParamsSchema = z.object({
|
|
182
|
+
...sourceSelector,
|
|
183
|
+
parentId: z.string().min(1),
|
|
184
|
+
fileId: z.string().min(1).optional(),
|
|
185
|
+
name: z.string().min(1),
|
|
186
|
+
data: z.string(),
|
|
187
|
+
mimeType: z.string().min(1).optional(),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
export const SourceUploadResultSchema = z.object({
|
|
191
|
+
id: z.string().min(1),
|
|
192
|
+
name: z.string().min(1),
|
|
193
|
+
modifiedAt: z.string().min(1).optional(),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const SourceMkdirParamsSchema = z.object({
|
|
197
|
+
...sourceSelector,
|
|
198
|
+
parentId: z.string().min(1),
|
|
199
|
+
name: z.string().min(1),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const SourceMkdirResultSchema = z.object({
|
|
203
|
+
id: z.string().min(1),
|
|
204
|
+
name: z.string().min(1),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
export const SourceRemoveParamsSchema = z.object({
|
|
208
|
+
...sourceSelector,
|
|
209
|
+
fileId: z.string().min(1),
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
export const SourceExportParamsSchema = z.object({
|
|
213
|
+
...sourceSelector,
|
|
214
|
+
fileId: z.string().min(1),
|
|
215
|
+
mimeType: z.string().min(1),
|
|
216
|
+
offset: z.number().int().nonnegative().optional(),
|
|
217
|
+
length: z.number().int().positive().optional(),
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
export const AccountSummarySchema = z.object({
|
|
221
|
+
accountId: z.string().min(1),
|
|
222
|
+
label: z.string(),
|
|
223
|
+
externalAccountId: z.string(),
|
|
224
|
+
status: z.string(),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
export interface AppCredentials {
|
|
228
|
+
kind: string;
|
|
229
|
+
values: Record<string, unknown>;
|
|
230
|
+
credentials: Record<string, string>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const AppCredentialsSchema = z.object({
|
|
234
|
+
kind: z.string().min(1),
|
|
235
|
+
values: z.record(z.string(), z.unknown()),
|
|
236
|
+
credentials: z.record(z.string(), z.string()),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const TriggerFireOutcomeSchema = z.object({
|
|
240
|
+
outcome: z.enum(['fired', 'suppressed', 'busy', 'failed']),
|
|
241
|
+
runId: z.string().nullable().optional(),
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
export const InboundAttachmentSchema = z
|
|
245
|
+
.object({
|
|
246
|
+
name: z.string().min(1),
|
|
247
|
+
mediaType: z.string().min(1).optional(),
|
|
248
|
+
path: z.string().min(1).optional(),
|
|
249
|
+
dataBase64: z.string().min(1).optional(),
|
|
250
|
+
})
|
|
251
|
+
.refine((value) => (value.path === undefined) !== (value.dataBase64 === undefined), {
|
|
252
|
+
message: 'exactly one of path or dataBase64 is required',
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export type InboundAttachment = z.infer<typeof InboundAttachmentSchema>;
|
|
256
|
+
|
|
257
|
+
export const InboundMessageSchema = z.object({
|
|
258
|
+
channel: z.string().min(1),
|
|
259
|
+
from: z.string().optional(),
|
|
260
|
+
text: z.string(),
|
|
261
|
+
payload: z.unknown().optional(),
|
|
262
|
+
attachments: z.array(InboundAttachmentSchema).max(10).optional(),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
export const BridgeInboundOutcomeSchema = z.enum([
|
|
266
|
+
'echo_suppressed',
|
|
267
|
+
'dispatched',
|
|
268
|
+
'auto_replied',
|
|
269
|
+
'skipped',
|
|
270
|
+
'busy',
|
|
271
|
+
'failed',
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
export type BridgeInboundOutcome = z.infer<typeof BridgeInboundOutcomeSchema>;
|
|
275
|
+
|
|
276
|
+
export interface RouteRequest {
|
|
277
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
278
|
+
path: string;
|
|
279
|
+
query: Record<string, string>;
|
|
280
|
+
headers: Record<string, string>;
|
|
281
|
+
body?: unknown;
|
|
282
|
+
/**
|
|
283
|
+
* Original request body as text, before JSON parsing. Signature verifiers
|
|
284
|
+
* need the exact bytes: re-serialized JSON does not match what the sender
|
|
285
|
+
* signed.
|
|
286
|
+
*/
|
|
287
|
+
rawBody?: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface RouteHandleResult {
|
|
291
|
+
status: number;
|
|
292
|
+
headers?: Record<string, string>;
|
|
293
|
+
body?: unknown;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export const RouteRequestSchema = z.object({
|
|
297
|
+
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
|
|
298
|
+
path: z.string().min(1),
|
|
299
|
+
query: z.record(z.string(), z.string()),
|
|
300
|
+
headers: z.record(z.string(), z.string()),
|
|
301
|
+
body: z.unknown().optional(),
|
|
302
|
+
rawBody: z.string().optional(),
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
export const RouteHandleResultSchema = z.object({
|
|
306
|
+
status: z.number().int(),
|
|
307
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
308
|
+
body: z.unknown().optional(),
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
export const FileStatParamsSchema = z.object({
|
|
312
|
+
path: z.string().min(1),
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
export const FileStatResultSchema = z.object({
|
|
316
|
+
path: z.string().min(1),
|
|
317
|
+
name: z.string().min(1),
|
|
318
|
+
size: z.number().int().nonnegative(),
|
|
319
|
+
mediaType: z.string().min(1),
|
|
320
|
+
modifiedAt: z.string().min(1),
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
export const FileReadParamsSchema = z.object({
|
|
324
|
+
path: z.string().min(1),
|
|
325
|
+
offset: z.number().int().nonnegative().optional(),
|
|
326
|
+
length: z.number().int().positive().optional(),
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
export const FileReadResultSchema = z.object({
|
|
330
|
+
data: z.string(),
|
|
331
|
+
eof: z.boolean(),
|
|
332
|
+
size: z.number().int().nonnegative(),
|
|
333
|
+
mediaType: z.string().min(1),
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
export const FileWriteParamsSchema = z.object({
|
|
337
|
+
path: z.string().min(1),
|
|
338
|
+
data: z.string(),
|
|
339
|
+
append: z.boolean().optional(),
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
export const FileWriteResultSchema = z.object({
|
|
343
|
+
path: z.string().min(1),
|
|
344
|
+
size: z.number().int().nonnegative(),
|
|
345
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CallMetaSchema } from './meta.ts';
|
|
3
|
+
import { hostMethod } from './method-spec.ts';
|
|
4
|
+
import {
|
|
5
|
+
SourceBytesResultSchema,
|
|
6
|
+
SourceExportParamsSchema,
|
|
7
|
+
SourceListParamsSchema,
|
|
8
|
+
SourceListResultSchema,
|
|
9
|
+
SourceMkdirParamsSchema,
|
|
10
|
+
SourceMkdirResultSchema,
|
|
11
|
+
SourceReadParamsSchema,
|
|
12
|
+
SourceRemoveParamsSchema,
|
|
13
|
+
SourceStatParamsSchema,
|
|
14
|
+
SourceStatResultSchema,
|
|
15
|
+
SourceUploadParamsSchema,
|
|
16
|
+
SourceUploadResultSchema,
|
|
17
|
+
} from './shared.ts';
|
|
18
|
+
|
|
19
|
+
const empty = z.object({});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Knowledge-source backend calls: the host mirror pipeline drives an add-on through
|
|
23
|
+
* these methods and the add-on owns vendor auth and API calls.
|
|
24
|
+
*/
|
|
25
|
+
export const sourceMethods = {
|
|
26
|
+
'source.list': hostMethod(
|
|
27
|
+
SourceListParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
28
|
+
SourceListResultSchema,
|
|
29
|
+
'source',
|
|
30
|
+
),
|
|
31
|
+
'source.stat': hostMethod(
|
|
32
|
+
SourceStatParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
33
|
+
SourceStatResultSchema,
|
|
34
|
+
'source',
|
|
35
|
+
),
|
|
36
|
+
'source.download': hostMethod(
|
|
37
|
+
SourceReadParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
38
|
+
SourceBytesResultSchema,
|
|
39
|
+
'source',
|
|
40
|
+
),
|
|
41
|
+
'source.upload': hostMethod(
|
|
42
|
+
SourceUploadParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
43
|
+
SourceUploadResultSchema,
|
|
44
|
+
'source',
|
|
45
|
+
),
|
|
46
|
+
'source.mkdir': hostMethod(
|
|
47
|
+
SourceMkdirParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
48
|
+
SourceMkdirResultSchema,
|
|
49
|
+
'source',
|
|
50
|
+
),
|
|
51
|
+
'source.remove': hostMethod(
|
|
52
|
+
SourceRemoveParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
53
|
+
empty,
|
|
54
|
+
'source',
|
|
55
|
+
),
|
|
56
|
+
'source.export': hostMethod(
|
|
57
|
+
SourceExportParamsSchema.extend({ _meta: CallMetaSchema }),
|
|
58
|
+
SourceBytesResultSchema,
|
|
59
|
+
'source',
|
|
60
|
+
),
|
|
61
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { addonMethod } from './method-spec.ts';
|
|
3
|
+
|
|
4
|
+
const str = z.string();
|
|
5
|
+
const empty = z.object({});
|
|
6
|
+
|
|
7
|
+
/** Threads read/write and the agents roster: addon-to-host service methods. */
|
|
8
|
+
export const threadServiceMethods = {
|
|
9
|
+
'threads.create': addonMethod(
|
|
10
|
+
z.object({
|
|
11
|
+
title: str.optional(),
|
|
12
|
+
agentId: z.string().uuid(),
|
|
13
|
+
kind: z.enum(['chat', 'group']).optional(),
|
|
14
|
+
responderMode: z.enum(['auto', 'mention']).optional(),
|
|
15
|
+
}),
|
|
16
|
+
z.object({ threadId: str }),
|
|
17
|
+
'threads.create',
|
|
18
|
+
),
|
|
19
|
+
'threads.get': addonMethod(
|
|
20
|
+
z.object({ threadId: str }),
|
|
21
|
+
z.object({
|
|
22
|
+
thread: z
|
|
23
|
+
.object({
|
|
24
|
+
threadId: str,
|
|
25
|
+
kind: str,
|
|
26
|
+
title: str,
|
|
27
|
+
responderMode: z.enum(['auto', 'mention']),
|
|
28
|
+
autoReplyAgentId: str.nullable(),
|
|
29
|
+
agents: z.array(z.object({ id: str, name: str })),
|
|
30
|
+
})
|
|
31
|
+
.optional(),
|
|
32
|
+
}),
|
|
33
|
+
'threads.read',
|
|
34
|
+
),
|
|
35
|
+
'threads.patch': addonMethod(
|
|
36
|
+
z.object({
|
|
37
|
+
threadId: str,
|
|
38
|
+
responderMode: z.enum(['auto', 'mention']).optional(),
|
|
39
|
+
}),
|
|
40
|
+
empty,
|
|
41
|
+
'threads.write',
|
|
42
|
+
),
|
|
43
|
+
'agents.list': addonMethod(
|
|
44
|
+
z.object({}),
|
|
45
|
+
z.object({
|
|
46
|
+
agents: z.array(z.object({ id: str, name: str, status: str.optional() })),
|
|
47
|
+
}),
|
|
48
|
+
'agents.read',
|
|
49
|
+
),
|
|
50
|
+
};
|