@harnesys/sdk 0.0.0-stage → 1.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.
- 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.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 +35 -0
- package/dist/index.js +35 -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 +152 -0
- package/dist/testing/fake-services.d.ts +63 -0
- package/dist/testing/fake-services.js +277 -0
- package/dist/testing/fixtures.d.ts +4 -0
- package/dist/testing/fixtures.js +84 -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.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 +341 -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 +261 -0
- package/src/testing/fake-services.ts +345 -0
- package/src/testing/fixtures.ts +88 -0
- package/src/testing/index.ts +12 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EffectivePermissionSchema } from "../permissions/permissions.js";
|
|
3
|
+
import { CancelNotificationSchema, ProgressNotificationSchema } from "./envelope.js";
|
|
4
|
+
import { InitializeParamsSchema, InitializeResultSchema } from "./handshake.js";
|
|
5
|
+
import { CallMetaSchema } from "./meta.js";
|
|
6
|
+
import { addonMethod, hostMethod, notificationSpec } from "./method-spec.js";
|
|
7
|
+
import { orgServiceMethods } from "./org-service-methods.js";
|
|
8
|
+
import { AccountSummarySchema, AppCredentialsSchema, BindingChannelParamsSchema, BindingWriteParamsSchema, BridgeInboundOutcomeSchema, DbRowSchema, FileReadParamsSchema, FileReadResultSchema, FileStatParamsSchema, FileStatResultSchema, FileWriteParamsSchema, FileWriteResultSchema, HttpFetchParamsSchema, HttpFetchResultSchema, InboundMessageSchema, LogWriteParamsSchema, OkResultSchema, RouteHandleResultSchema, RouteRequestSchema, SqlParamSchema, TransportBindingSummarySchema, TransportMessageSchema, } from "./shared.js";
|
|
9
|
+
import { sourceMethods } from "./source-methods.js";
|
|
10
|
+
import { threadServiceMethods } from "./thread-service-methods.js";
|
|
11
|
+
export { addonMethod, hostMethod, notificationSpec } from "./method-spec.js";
|
|
12
|
+
const empty = z.object({});
|
|
13
|
+
const str = z.string().min(1);
|
|
14
|
+
const secretKey = z.string().regex(/^[A-Za-z0-9_.-]{1,128}$/);
|
|
15
|
+
const MAX_SECRET_BYTES = 8 * 1024;
|
|
16
|
+
export const protocolMap = {
|
|
17
|
+
...sourceMethods,
|
|
18
|
+
...orgServiceMethods,
|
|
19
|
+
...threadServiceMethods,
|
|
20
|
+
initialize: hostMethod(InitializeParamsSchema, InitializeResultSchema),
|
|
21
|
+
initialized: notificationSpec(empty, 'host'),
|
|
22
|
+
shutdown: hostMethod(z
|
|
23
|
+
.object({ reason: z.string().min(1), deadlineMs: z.number().int().positive() })
|
|
24
|
+
.extend({ _meta: CallMetaSchema }), empty),
|
|
25
|
+
ping: hostMethod(empty.extend({ _meta: CallMetaSchema }), empty),
|
|
26
|
+
'config.changed': notificationSpec(z.object({ keys: z.array(z.string()) }), 'host'),
|
|
27
|
+
'permissions.changed': notificationSpec(z.object({ permissions: z.array(EffectivePermissionSchema) }), 'host'),
|
|
28
|
+
'accounts.changed': notificationSpec(z.object({ connection: str, accountId: str, status: z.string() }), 'host'),
|
|
29
|
+
'lifecycle.upgrade': hostMethod(z.object({ fromVersion: str }).extend({ _meta: CallMetaSchema }), empty),
|
|
30
|
+
'tools.call': hostMethod(z
|
|
31
|
+
.object({ pack: str, tool: str, input: z.record(z.string(), z.unknown()).default({}) })
|
|
32
|
+
.extend({ _meta: CallMetaSchema }), z.object({ output: z.unknown() })),
|
|
33
|
+
'route.handle': hostMethod(z.object({ routeId: str, request: RouteRequestSchema }).extend({ _meta: CallMetaSchema }), RouteHandleResultSchema),
|
|
34
|
+
'trigger.start': hostMethod(z
|
|
35
|
+
.object({
|
|
36
|
+
instanceId: str,
|
|
37
|
+
kind: str,
|
|
38
|
+
label: str.optional(),
|
|
39
|
+
config: z.record(z.string(), z.unknown()),
|
|
40
|
+
target: z.unknown().optional(),
|
|
41
|
+
})
|
|
42
|
+
.extend({ _meta: CallMetaSchema }), empty, 'trigger'),
|
|
43
|
+
'trigger.stop': hostMethod(z
|
|
44
|
+
.object({
|
|
45
|
+
instanceId: str,
|
|
46
|
+
reason: z.enum(['paused', 'removed']).optional(),
|
|
47
|
+
})
|
|
48
|
+
.extend({ _meta: CallMetaSchema }), empty, 'trigger'),
|
|
49
|
+
'job.run': hostMethod(z.object({ jobId: str }).extend({ _meta: CallMetaSchema }), empty),
|
|
50
|
+
'worker.start': hostMethod(z.object({ workerId: str }).extend({ _meta: CallMetaSchema }), empty),
|
|
51
|
+
'worker.stop': hostMethod(z.object({ workerId: str }).extend({ _meta: CallMetaSchema }), empty),
|
|
52
|
+
'transport.send': hostMethod(z.object({ message: TransportMessageSchema }).extend({ _meta: CallMetaSchema }), z.object({ messageId: str.optional() })),
|
|
53
|
+
'transport.edit': hostMethod(z.object({ messageId: str, message: TransportMessageSchema }).extend({ _meta: CallMetaSchema }), empty),
|
|
54
|
+
'transport.typing': hostMethod(z.object({ channel: str, on: z.boolean() }).extend({ _meta: CallMetaSchema }), empty),
|
|
55
|
+
'hook.deliver': hostMethod(z
|
|
56
|
+
.object({ hookId: str, event: z.record(z.string(), z.unknown()) })
|
|
57
|
+
.extend({ _meta: CallMetaSchema }), empty),
|
|
58
|
+
'config.get': addonMethod(z.object({ keys: z.array(z.string()).optional() }), z.object({ values: z.record(z.string(), z.unknown()) }), null),
|
|
59
|
+
'secrets.get': addonMethod(z.object({ key: secretKey }), z.object({ value: z.string().nullable() }), null),
|
|
60
|
+
'secrets.set': addonMethod(z.object({ key: secretKey, value: z.string().min(1).max(MAX_SECRET_BYTES) }), empty, null),
|
|
61
|
+
'secrets.delete': addonMethod(z.object({ key: secretKey }), empty, null),
|
|
62
|
+
'db.exec': addonMethod(z.object({ sql: str }), empty, null),
|
|
63
|
+
'db.all': addonMethod(z.object({ sql: str, params: z.array(SqlParamSchema).optional() }), z.object({ rows: z.array(DbRowSchema) }), null),
|
|
64
|
+
'db.get': addonMethod(z.object({ sql: str, params: z.array(SqlParamSchema).optional() }), z.object({ row: DbRowSchema.nullable() }), null),
|
|
65
|
+
'db.run': addonMethod(z.object({ sql: str, params: z.array(SqlParamSchema).optional() }), z.object({
|
|
66
|
+
changes: z.number().int().nonnegative(),
|
|
67
|
+
lastInsertRowid: z.union([z.string(), z.number()]),
|
|
68
|
+
}), null),
|
|
69
|
+
'db.batch': addonMethod(z.object({
|
|
70
|
+
statements: z
|
|
71
|
+
.array(z.object({ sql: str, params: z.array(SqlParamSchema).optional() }))
|
|
72
|
+
.max(100),
|
|
73
|
+
}), z.object({
|
|
74
|
+
results: z.array(z.object({
|
|
75
|
+
changes: z.number().int().nonnegative(),
|
|
76
|
+
lastInsertRowid: z.union([z.string(), z.number()]),
|
|
77
|
+
})),
|
|
78
|
+
}), null),
|
|
79
|
+
'log.write': addonMethod(LogWriteParamsSchema, empty, null),
|
|
80
|
+
'events.emit': addonMethod(z.object({ name: str, payload: z.unknown() }), empty, null),
|
|
81
|
+
'http.fetch': addonMethod(HttpFetchParamsSchema, HttpFetchResultSchema, 'http.fetch'),
|
|
82
|
+
'files.stat': addonMethod(FileStatParamsSchema, FileStatResultSchema, 'files.read'),
|
|
83
|
+
'files.read': addonMethod(FileReadParamsSchema, FileReadResultSchema, 'files.read'),
|
|
84
|
+
'files.write': addonMethod(FileWriteParamsSchema, FileWriteResultSchema, 'files.write'),
|
|
85
|
+
'bindings.channels': addonMethod(z.object({ provider: str.optional() }), z.object({ channels: z.array(TransportBindingSummarySchema) }), null),
|
|
86
|
+
'bindings.bind': addonMethod(BindingWriteParamsSchema, OkResultSchema, 'bindings.write'),
|
|
87
|
+
'bindings.unbind': addonMethod(BindingChannelParamsSchema, OkResultSchema, 'bindings.write'),
|
|
88
|
+
'accounts.list': addonMethod(z.object({ connection: str }), z.object({ accounts: z.array(AccountSummarySchema) }), 'accounts.use'),
|
|
89
|
+
'accounts.report': addonMethod(z.object({ connection: str, accountId: str.optional(), code: str }), empty, 'accounts.use'),
|
|
90
|
+
'accounts.access': addonMethod(z.object({ connection: str, accountId: str.optional() }), z.object({
|
|
91
|
+
credentials: z.unknown(),
|
|
92
|
+
expiresAt: str.optional(),
|
|
93
|
+
app: AppCredentialsSchema.nullable().optional(),
|
|
94
|
+
}), 'accounts.credentials'),
|
|
95
|
+
'runs.dispatch': addonMethod(z.object({ threadId: str.optional(), agentId: str.optional(), input: str }), z.object({ runId: str }), 'runs.dispatch'),
|
|
96
|
+
'runs.cancel': addonMethod(z.object({ threadId: str, runId: str }), z.object({ ok: z.literal(true) }), 'runs.dispatch'),
|
|
97
|
+
'bridge.inbound': addonMethod(z.object({ message: InboundMessageSchema }), z.object({ outcome: BridgeInboundOutcomeSchema }), 'bridge.inbound'),
|
|
98
|
+
'workers.lease': addonMethod(z.object({
|
|
99
|
+
workerId: str,
|
|
100
|
+
ttlMs: z.number().int().min(5_000).max(3_600_000).optional(),
|
|
101
|
+
}), z.object({
|
|
102
|
+
held: z.boolean(),
|
|
103
|
+
epoch: z.number().int().nonnegative(),
|
|
104
|
+
expiresAt: z.string().nullable(),
|
|
105
|
+
}), 'worker'),
|
|
106
|
+
'workers.release': addonMethod(z.object({ workerId: str }), empty, 'worker'),
|
|
107
|
+
'workers.report': addonMethod(z.object({
|
|
108
|
+
workerId: str,
|
|
109
|
+
state: z.enum(['running', 'stopped', 'failed']),
|
|
110
|
+
code: str.optional(),
|
|
111
|
+
}), empty, 'worker'),
|
|
112
|
+
'$/cancel': notificationSpec(CancelNotificationSchema, 'both'),
|
|
113
|
+
'$/progress': notificationSpec(ProgressNotificationSchema, 'addon'),
|
|
114
|
+
};
|
|
115
|
+
export const PROTOCOL_METHODS = Object.keys(protocolMap);
|
|
116
|
+
export function stripMeta(params) {
|
|
117
|
+
const copy = { ...params };
|
|
118
|
+
delete copy._meta;
|
|
119
|
+
return copy;
|
|
120
|
+
}
|
|
121
|
+
export function protocolEntries() {
|
|
122
|
+
return Object.entries(protocolMap).map(([method, spec]) => ({ method, spec }));
|
|
123
|
+
}
|
|
124
|
+
export function methodSpec(method) {
|
|
125
|
+
const spec = protocolMap[method];
|
|
126
|
+
return spec;
|
|
127
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface CallMeta {
|
|
3
|
+
correlationId: string;
|
|
4
|
+
deadline: number | null;
|
|
5
|
+
principal: {
|
|
6
|
+
type: 'agent' | 'user' | 'system';
|
|
7
|
+
id?: string;
|
|
8
|
+
};
|
|
9
|
+
agentId?: string;
|
|
10
|
+
threadId?: string;
|
|
11
|
+
runId?: string;
|
|
12
|
+
orgId?: string;
|
|
13
|
+
locale: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const CallMetaSchema: z.ZodObject<{
|
|
16
|
+
correlationId: z.ZodString;
|
|
17
|
+
deadline: z.ZodNullable<z.ZodNumber>;
|
|
18
|
+
principal: z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<{
|
|
20
|
+
agent: "agent";
|
|
21
|
+
user: "user";
|
|
22
|
+
system: "system";
|
|
23
|
+
}>;
|
|
24
|
+
id: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
27
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
orgId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
locale: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CallMetaSchema = z.object({
|
|
3
|
+
correlationId: z.string().min(1),
|
|
4
|
+
deadline: z.number().nullable(),
|
|
5
|
+
principal: z.object({
|
|
6
|
+
type: z.enum(['agent', 'user', 'system']),
|
|
7
|
+
id: z.string().optional(),
|
|
8
|
+
}),
|
|
9
|
+
agentId: z.string().optional(),
|
|
10
|
+
threadId: z.string().optional(),
|
|
11
|
+
runId: z.string().optional(),
|
|
12
|
+
orgId: z.string().optional(),
|
|
13
|
+
locale: z.string().min(1),
|
|
14
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export type MethodDirection = 'host-to-addon' | 'addon-to-host' | 'notification';
|
|
3
|
+
export type NotificationSender = 'host' | 'addon' | 'both';
|
|
4
|
+
export interface MethodSpec<SParams extends z.ZodType, SResult extends z.ZodType | null, D extends MethodDirection = MethodDirection> {
|
|
5
|
+
readonly direction: D;
|
|
6
|
+
readonly params: SParams;
|
|
7
|
+
readonly result: SResult;
|
|
8
|
+
readonly permission: string | null;
|
|
9
|
+
readonly sender?: NotificationSender;
|
|
10
|
+
}
|
|
11
|
+
export declare function hostMethod<SParams extends z.ZodType, SResult extends z.ZodType>(params: SParams, result: SResult, permission?: string | null): MethodSpec<SParams, SResult, 'host-to-addon'>;
|
|
12
|
+
export declare function addonMethod<SParams extends z.ZodType, SResult extends z.ZodType>(params: SParams, result: SResult, permission: string | null): MethodSpec<SParams, SResult, 'addon-to-host'>;
|
|
13
|
+
export declare function notificationSpec<SParams extends z.ZodType>(params: SParams, sender: NotificationSender, permission?: string | null): MethodSpec<SParams, null, 'notification'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function hostMethod(params, result, permission = null) {
|
|
2
|
+
return { direction: 'host-to-addon', params, result, permission };
|
|
3
|
+
}
|
|
4
|
+
export function addonMethod(params, result, permission) {
|
|
5
|
+
return { direction: 'addon-to-host', params, result, permission };
|
|
6
|
+
}
|
|
7
|
+
export function notificationSpec(params, sender, permission = null) {
|
|
8
|
+
return { direction: 'notification', params, result: null, permission, sender };
|
|
9
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Read/action methods over org-scoped thread, run, usage and skill state (§6.4). */
|
|
3
|
+
export declare const orgServiceMethods: {
|
|
4
|
+
'runs.list': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
5
|
+
threadId: z.ZodString;
|
|
6
|
+
status: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
8
|
+
runs: z.ZodArray<z.ZodObject<{
|
|
9
|
+
runId: z.ZodString;
|
|
10
|
+
status: z.ZodString;
|
|
11
|
+
startedAt: z.ZodNullable<z.ZodString>;
|
|
12
|
+
agentId: z.ZodNullable<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
15
|
+
'threads.compact': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
16
|
+
threadId: z.ZodString;
|
|
17
|
+
}, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
|
|
18
|
+
compacted: z.ZodLiteral<true>;
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
coveredFrom: z.ZodNumber;
|
|
21
|
+
coveredUntil: z.ZodNumber;
|
|
22
|
+
tokensBefore: z.ZodNumber;
|
|
23
|
+
tokensAfter: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
|
+
compacted: z.ZodLiteral<false>;
|
|
26
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>]>, "addon-to-host">;
|
|
28
|
+
'usage.summary': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
29
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
since: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
+
inputTokens: z.ZodNumber;
|
|
33
|
+
outputTokens: z.ZodNumber;
|
|
34
|
+
costUsd: z.ZodNumber;
|
|
35
|
+
byModel: z.ZodArray<z.ZodObject<{
|
|
36
|
+
model: z.ZodString;
|
|
37
|
+
inputTokens: z.ZodNumber;
|
|
38
|
+
outputTokens: z.ZodNumber;
|
|
39
|
+
costUsd: z.ZodNumber;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
42
|
+
'skills.list': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
43
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
description: z.ZodNullable<z.ZodString>;
|
|
49
|
+
source: z.ZodString;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
52
|
+
'org.settings.get': import("./method-spec.ts").MethodSpec<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
timezone: z.ZodString;
|
|
54
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
55
|
+
'approvals.request': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
56
|
+
interruptId: z.ZodString;
|
|
57
|
+
agentId: z.ZodString;
|
|
58
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
kind: z.ZodEnum<{
|
|
60
|
+
tool: "tool";
|
|
61
|
+
spend: "spend";
|
|
62
|
+
memory: "memory";
|
|
63
|
+
question: "question";
|
|
64
|
+
file_access: "file_access";
|
|
65
|
+
}>;
|
|
66
|
+
question: z.ZodString;
|
|
67
|
+
options: z.ZodArray<z.ZodEnum<{
|
|
68
|
+
approve: "approve";
|
|
69
|
+
approve_once: "approve_once";
|
|
70
|
+
deny: "deny";
|
|
71
|
+
block_path: "block_path";
|
|
72
|
+
close: "close";
|
|
73
|
+
}>>;
|
|
74
|
+
context: z.ZodObject<{
|
|
75
|
+
source: z.ZodString;
|
|
76
|
+
ops: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
tool: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
inputPreview: z.ZodOptional<z.ZodString>;
|
|
80
|
+
command: z.ZodOptional<z.ZodString>;
|
|
81
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
note: z.ZodOptional<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
88
|
+
'triggers.fire': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
89
|
+
instanceId: z.ZodString;
|
|
90
|
+
runKey: z.ZodString;
|
|
91
|
+
text: z.ZodOptional<z.ZodString>;
|
|
92
|
+
title: z.ZodOptional<z.ZodString>;
|
|
93
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
94
|
+
label: z.ZodString;
|
|
95
|
+
value: z.ZodString;
|
|
96
|
+
href: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strip>>>;
|
|
98
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
99
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
100
|
+
outcome: z.ZodEnum<{
|
|
101
|
+
fired: "fired";
|
|
102
|
+
suppressed: "suppressed";
|
|
103
|
+
busy: "busy";
|
|
104
|
+
failed: "failed";
|
|
105
|
+
}>;
|
|
106
|
+
runId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
107
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
108
|
+
'triggers.create': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
109
|
+
kind: z.ZodString;
|
|
110
|
+
label: z.ZodString;
|
|
111
|
+
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
112
|
+
target: z.ZodObject<{
|
|
113
|
+
threadId: z.ZodString;
|
|
114
|
+
agentId: z.ZodString;
|
|
115
|
+
modeId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
119
|
+
instanceId: z.ZodString;
|
|
120
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
121
|
+
'triggers.update': import("./method-spec.ts").MethodSpec<z.ZodObject<{
|
|
122
|
+
instanceId: z.ZodString;
|
|
123
|
+
label: z.ZodOptional<z.ZodString>;
|
|
124
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
125
|
+
target: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
threadId: z.ZodString;
|
|
127
|
+
agentId: z.ZodString;
|
|
128
|
+
modeId: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
131
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
+
instanceId: z.ZodString;
|
|
134
|
+
}, z.core.$strip>, "addon-to-host">;
|
|
135
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { addonMethod } from "./method-spec.js";
|
|
3
|
+
import { TriggerFireOutcomeSchema } from "./shared.js";
|
|
4
|
+
const str = z.string().min(1);
|
|
5
|
+
/** Read/action methods over org-scoped thread, run, usage and skill state (§6.4). */
|
|
6
|
+
export const orgServiceMethods = {
|
|
7
|
+
'runs.list': addonMethod(z.object({ threadId: str, status: z.string().optional() }), z.object({
|
|
8
|
+
runs: z.array(z.object({
|
|
9
|
+
runId: str,
|
|
10
|
+
status: z.string(),
|
|
11
|
+
startedAt: z.string().nullable(),
|
|
12
|
+
agentId: z.string().nullable(),
|
|
13
|
+
})),
|
|
14
|
+
}), 'runs.read'),
|
|
15
|
+
'threads.compact': addonMethod(z.object({ threadId: str }), z.union([
|
|
16
|
+
z.object({
|
|
17
|
+
compacted: z.literal(true),
|
|
18
|
+
id: str,
|
|
19
|
+
coveredFrom: z.number(),
|
|
20
|
+
coveredUntil: z.number(),
|
|
21
|
+
tokensBefore: z.number(),
|
|
22
|
+
tokensAfter: z.number(),
|
|
23
|
+
}),
|
|
24
|
+
z.object({ compacted: z.literal(false), reason: z.string().optional() }),
|
|
25
|
+
]), 'threads.compact'),
|
|
26
|
+
'usage.summary': addonMethod(z.object({ threadId: str.optional(), since: str.optional() }), z.object({
|
|
27
|
+
inputTokens: z.number(),
|
|
28
|
+
outputTokens: z.number(),
|
|
29
|
+
costUsd: z.number(),
|
|
30
|
+
byModel: z.array(z.object({
|
|
31
|
+
model: str,
|
|
32
|
+
inputTokens: z.number(),
|
|
33
|
+
outputTokens: z.number(),
|
|
34
|
+
costUsd: z.number(),
|
|
35
|
+
})),
|
|
36
|
+
}), 'usage.read'),
|
|
37
|
+
'skills.list': addonMethod(z.object({ threadId: str.optional() }), z.object({
|
|
38
|
+
skills: z.array(z.object({
|
|
39
|
+
id: str,
|
|
40
|
+
name: str,
|
|
41
|
+
description: z.string().nullable(),
|
|
42
|
+
source: z.string(),
|
|
43
|
+
})),
|
|
44
|
+
}), 'skills.read'),
|
|
45
|
+
'org.settings.get': addonMethod(z.object({}), z.object({ timezone: str }), 'org.read'),
|
|
46
|
+
'approvals.request': addonMethod(z.object({
|
|
47
|
+
interruptId: str,
|
|
48
|
+
agentId: str,
|
|
49
|
+
threadId: str.optional(),
|
|
50
|
+
kind: z.enum(['tool', 'spend', 'memory', 'question', 'file_access']),
|
|
51
|
+
question: str,
|
|
52
|
+
options: z.array(z.enum(['approve', 'approve_once', 'deny', 'block_path', 'close'])).min(1),
|
|
53
|
+
context: z.object({
|
|
54
|
+
source: str,
|
|
55
|
+
ops: z.array(str).optional(),
|
|
56
|
+
tool: z
|
|
57
|
+
.object({
|
|
58
|
+
name: str,
|
|
59
|
+
inputPreview: z.string().optional(),
|
|
60
|
+
command: z.string().optional(),
|
|
61
|
+
truncated: z.boolean().optional(),
|
|
62
|
+
})
|
|
63
|
+
.optional(),
|
|
64
|
+
note: z.string().optional(),
|
|
65
|
+
}),
|
|
66
|
+
}), z.object({ id: str }), 'approvals.request'),
|
|
67
|
+
'triggers.fire': addonMethod(z.object({
|
|
68
|
+
instanceId: str,
|
|
69
|
+
runKey: str,
|
|
70
|
+
text: z.string().optional(),
|
|
71
|
+
title: z.string().optional(),
|
|
72
|
+
fields: z
|
|
73
|
+
.array(z.object({
|
|
74
|
+
label: str,
|
|
75
|
+
value: str,
|
|
76
|
+
href: str.optional(),
|
|
77
|
+
}))
|
|
78
|
+
.optional(),
|
|
79
|
+
payload: z.unknown().optional(),
|
|
80
|
+
}), TriggerFireOutcomeSchema, 'trigger'),
|
|
81
|
+
'triggers.create': addonMethod(z.object({
|
|
82
|
+
kind: str,
|
|
83
|
+
label: str,
|
|
84
|
+
config: z.record(z.string(), z.unknown()).default({}),
|
|
85
|
+
target: z.object({
|
|
86
|
+
threadId: str,
|
|
87
|
+
agentId: str,
|
|
88
|
+
modeId: str.optional(),
|
|
89
|
+
}),
|
|
90
|
+
instructions: str.optional(),
|
|
91
|
+
}), z.object({ instanceId: str }), 'trigger'),
|
|
92
|
+
'triggers.update': addonMethod(z.object({
|
|
93
|
+
instanceId: str,
|
|
94
|
+
label: str.optional(),
|
|
95
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
96
|
+
target: z
|
|
97
|
+
.object({
|
|
98
|
+
threadId: str,
|
|
99
|
+
agentId: str,
|
|
100
|
+
modeId: str.optional(),
|
|
101
|
+
})
|
|
102
|
+
.optional(),
|
|
103
|
+
instructions: str.optional(),
|
|
104
|
+
enabled: z.boolean().optional(),
|
|
105
|
+
}), z.object({ instanceId: str }), 'trigger'),
|
|
106
|
+
};
|