@aidy-dev/spec 0.0.0-stage → 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 +18 -0
- package/README.md +25 -2
- package/dist/catalog.d.ts +187 -0
- package/dist/catalog.js +426 -0
- package/dist/delegation.d.ts +96 -0
- package/dist/delegation.js +154 -0
- package/dist/protocol.d.ts +273 -0
- package/dist/protocol.js +243 -0
- package/dist/search.d.ts +69 -0
- package/dist/search.js +63 -0
- package/package.json +48 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation assertions: how aidy calls the host as the user, and how approvals
|
|
3
|
+
* bind to frozen arguments. See spec/delegation.md.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
export declare const ASSERTION_HEADER = "aidy-assertion";
|
|
7
|
+
export declare const HOST_ASSERTION_HEADER = "aidy-host-assertion";
|
|
8
|
+
export declare const ASSERTION_TYPE = "aidy-call+jwt";
|
|
9
|
+
export declare const MAX_ASSERTION_SECONDS = 60;
|
|
10
|
+
export declare const AssertionClaims: z.ZodObject<{
|
|
11
|
+
iss: z.ZodURL;
|
|
12
|
+
aud: z.ZodURL;
|
|
13
|
+
sub: z.ZodString;
|
|
14
|
+
ten: z.ZodOptional<z.ZodString>;
|
|
15
|
+
sid: z.ZodString;
|
|
16
|
+
rid: z.ZodString;
|
|
17
|
+
cid: z.ZodString;
|
|
18
|
+
op: z.ZodString;
|
|
19
|
+
htm: z.ZodEnum<{
|
|
20
|
+
DELETE: "DELETE";
|
|
21
|
+
GET: "GET";
|
|
22
|
+
HEAD: "HEAD";
|
|
23
|
+
PATCH: "PATCH";
|
|
24
|
+
POST: "POST";
|
|
25
|
+
PUT: "PUT";
|
|
26
|
+
}>;
|
|
27
|
+
htu: z.ZodURL;
|
|
28
|
+
bsh: z.ZodString;
|
|
29
|
+
apr: z.ZodOptional<z.ZodString>;
|
|
30
|
+
iat: z.ZodInt;
|
|
31
|
+
exp: z.ZodInt;
|
|
32
|
+
jti: z.ZodString;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type AssertionClaims = z.infer<typeof AssertionClaims>;
|
|
35
|
+
export type AssertionErrorCode = 'malformed' | 'unknown_key' | 'bad_signature' | 'expired' | 'not_yet_valid' | 'too_long' | 'audience' | 'method' | 'url' | 'body' | 'replay' | 'subject' | 'tenant' | 'operation' | 'approval_missing';
|
|
36
|
+
export declare class AssertionError extends Error {
|
|
37
|
+
readonly code: AssertionErrorCode;
|
|
38
|
+
constructor(code: AssertionErrorCode, message: string);
|
|
39
|
+
}
|
|
40
|
+
export declare function base64url(bytes: Uint8Array): string;
|
|
41
|
+
export declare function fromBase64url(text: string): Uint8Array;
|
|
42
|
+
/** base64url SHA-256 of bytes, or of a string's UTF-8 encoding. */
|
|
43
|
+
export declare function sha256(data: Uint8Array | string): Promise<string>;
|
|
44
|
+
/** JSON Canonicalization Scheme (RFC 8785) for JSON values. */
|
|
45
|
+
export declare function canonicalJson(value: unknown): string;
|
|
46
|
+
/** The hash an approval binds to: SHA-256 of the canonical JSON of the frozen arguments. */
|
|
47
|
+
export declare function argsHash(args: Record<string, unknown>): Promise<string>;
|
|
48
|
+
export interface SigningKey {
|
|
49
|
+
readonly kid: string;
|
|
50
|
+
readonly privateKey: CryptoKey;
|
|
51
|
+
}
|
|
52
|
+
/** Public keys by `kid`. Hosts pin these in configuration. */
|
|
53
|
+
export type VerificationKeys = ReadonlyMap<string, CryptoKey>;
|
|
54
|
+
export interface KeyPair {
|
|
55
|
+
readonly signing: SigningKey;
|
|
56
|
+
readonly publicJwk: JsonWebKey & {
|
|
57
|
+
kid: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export declare function generateKeyPair(kid: string): Promise<KeyPair>;
|
|
61
|
+
export declare function importPublicKeys(jwks: readonly (JsonWebKey & {
|
|
62
|
+
kid: string;
|
|
63
|
+
})[]): Promise<VerificationKeys>;
|
|
64
|
+
export declare function signAssertion(claims: AssertionClaims, key: SigningKey): Promise<string>;
|
|
65
|
+
export interface ReceivedRequest {
|
|
66
|
+
readonly method: string;
|
|
67
|
+
/** The full URL as received, including the query string. */
|
|
68
|
+
readonly url: string;
|
|
69
|
+
/** The exact body bytes; empty for none. */
|
|
70
|
+
readonly body: Uint8Array | string;
|
|
71
|
+
}
|
|
72
|
+
export interface VerifyOptions {
|
|
73
|
+
readonly keys: VerificationKeys;
|
|
74
|
+
/** The host's own origin, e.g. https://console.example.com. */
|
|
75
|
+
readonly audience: string;
|
|
76
|
+
readonly request: ReceivedRequest;
|
|
77
|
+
/** Seconds since the epoch; defaults to now. */
|
|
78
|
+
readonly now?: number;
|
|
79
|
+
/** Records `jti` until `exp` and answers false when it was already seen. */
|
|
80
|
+
readonly remember: (jti: string, exp: number) => boolean | Promise<boolean>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Verifies the signature, lifetime, audience and request binding of an
|
|
84
|
+
* assertion (checks 1–3 of spec/delegation.md). Use checkCall for the rest.
|
|
85
|
+
*/
|
|
86
|
+
export declare function verifyAssertion(token: string, options: VerifyOptions): Promise<AssertionClaims>;
|
|
87
|
+
export interface CallContext {
|
|
88
|
+
/** The identity the host resolved from the request's own credential. */
|
|
89
|
+
readonly subject: string;
|
|
90
|
+
readonly tenant?: string;
|
|
91
|
+
/** The catalog operation serving this method and path. */
|
|
92
|
+
readonly op: string;
|
|
93
|
+
readonly approval: 'never' | 'always';
|
|
94
|
+
}
|
|
95
|
+
/** Checks 4–6 of spec/delegation.md: the assertion matches the user and the operation. */
|
|
96
|
+
export declare function checkCall(claims: AssertionClaims, call: CallContext): void;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { OPERATION_NAME } from "./catalog.js";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
// src/delegation.ts
|
|
4
|
+
/**
|
|
5
|
+
* Delegation assertions: how aidy calls the host as the user, and how approvals
|
|
6
|
+
* bind to frozen arguments. See spec/delegation.md.
|
|
7
|
+
*/
|
|
8
|
+
const ASSERTION_HEADER = "aidy-assertion";
|
|
9
|
+
const HOST_ASSERTION_HEADER = "aidy-host-assertion";
|
|
10
|
+
const ASSERTION_TYPE = "aidy-call+jwt";
|
|
11
|
+
const MAX_ASSERTION_SECONDS = 60;
|
|
12
|
+
const CLOCK_SKEW_SECONDS = 60;
|
|
13
|
+
const AssertionClaims = z.strictObject({
|
|
14
|
+
iss: z.url(),
|
|
15
|
+
aud: z.url(),
|
|
16
|
+
sub: z.string().min(1),
|
|
17
|
+
ten: z.string().min(1).optional(),
|
|
18
|
+
sid: z.string().min(1),
|
|
19
|
+
rid: z.string().min(1),
|
|
20
|
+
cid: z.string().min(1),
|
|
21
|
+
op: z.string().regex(OPERATION_NAME),
|
|
22
|
+
htm: z.enum([
|
|
23
|
+
"GET",
|
|
24
|
+
"HEAD",
|
|
25
|
+
"POST",
|
|
26
|
+
"PUT",
|
|
27
|
+
"PATCH",
|
|
28
|
+
"DELETE"
|
|
29
|
+
]),
|
|
30
|
+
htu: z.url(),
|
|
31
|
+
bsh: z.string().min(43),
|
|
32
|
+
apr: z.string().min(1).optional(),
|
|
33
|
+
iat: z.int(),
|
|
34
|
+
exp: z.int(),
|
|
35
|
+
jti: z.string().min(16)
|
|
36
|
+
}).meta({
|
|
37
|
+
id: "assertion-claims",
|
|
38
|
+
title: "Delegation assertion claims",
|
|
39
|
+
description: "Claims of the Aidy-Assertion JWS."
|
|
40
|
+
});
|
|
41
|
+
var AssertionError = class extends Error {
|
|
42
|
+
code;
|
|
43
|
+
constructor(code, message) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = "AssertionError";
|
|
46
|
+
this.code = code;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const encoder = new TextEncoder();
|
|
50
|
+
function base64url(bytes) {
|
|
51
|
+
let binary = "";
|
|
52
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
53
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
54
|
+
}
|
|
55
|
+
function fromBase64url(text) {
|
|
56
|
+
const binary = atob(text.replaceAll("-", "+").replaceAll("_", "/"));
|
|
57
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
58
|
+
}
|
|
59
|
+
/** base64url SHA-256 of bytes, or of a string's UTF-8 encoding. */
|
|
60
|
+
async function sha256(data) {
|
|
61
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
62
|
+
return base64url(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)));
|
|
63
|
+
}
|
|
64
|
+
/** JSON Canonicalization Scheme (RFC 8785) for JSON values. */
|
|
65
|
+
function canonicalJson(value) {
|
|
66
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
|
|
67
|
+
if (typeof value === "number") {
|
|
68
|
+
if (!Number.isFinite(value)) throw new TypeError("non-finite numbers are not JSON");
|
|
69
|
+
return JSON.stringify(value);
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
72
|
+
if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonicalJson(item)}`).join(",")}}`;
|
|
73
|
+
throw new TypeError(`${typeof value} is not JSON`);
|
|
74
|
+
}
|
|
75
|
+
/** The hash an approval binds to: SHA-256 of the canonical JSON of the frozen arguments. */
|
|
76
|
+
function argsHash(args) {
|
|
77
|
+
return sha256(canonicalJson(args));
|
|
78
|
+
}
|
|
79
|
+
async function generateKeyPair(kid) {
|
|
80
|
+
const pair = await crypto.subtle.generateKey({ name: "Ed25519" }, true, ["sign", "verify"]);
|
|
81
|
+
const jwk = await crypto.subtle.exportKey("jwk", pair.publicKey);
|
|
82
|
+
return {
|
|
83
|
+
signing: {
|
|
84
|
+
kid,
|
|
85
|
+
privateKey: pair.privateKey
|
|
86
|
+
},
|
|
87
|
+
publicJwk: {
|
|
88
|
+
kty: jwk.kty,
|
|
89
|
+
crv: jwk.crv,
|
|
90
|
+
x: jwk.x,
|
|
91
|
+
kid
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async function importPublicKeys(jwks) {
|
|
96
|
+
const keys = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const jwk of jwks) keys.set(jwk.kid, await crypto.subtle.importKey("jwk", jwk, { name: "Ed25519" }, false, ["verify"]));
|
|
98
|
+
return keys;
|
|
99
|
+
}
|
|
100
|
+
async function signAssertion(claims, key) {
|
|
101
|
+
const valid = AssertionClaims.parse(claims);
|
|
102
|
+
if (valid.exp - valid.iat > 60) throw new AssertionError("too_long", `assertions live at most 60s`);
|
|
103
|
+
const header = {
|
|
104
|
+
alg: "EdDSA",
|
|
105
|
+
kid: key.kid,
|
|
106
|
+
typ: ASSERTION_TYPE
|
|
107
|
+
};
|
|
108
|
+
const input = `${base64url(encoder.encode(JSON.stringify(header)))}.${base64url(encoder.encode(JSON.stringify(valid)))}`;
|
|
109
|
+
const signature = await crypto.subtle.sign("Ed25519", key.privateKey, encoder.encode(input));
|
|
110
|
+
return `${input}.${base64url(new Uint8Array(signature))}`;
|
|
111
|
+
}
|
|
112
|
+
function decodeJson(part) {
|
|
113
|
+
try {
|
|
114
|
+
return JSON.parse(new TextDecoder().decode(fromBase64url(part)));
|
|
115
|
+
} catch {
|
|
116
|
+
throw new AssertionError("malformed", "assertion is not valid base64url JSON");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Verifies the signature, lifetime, audience and request binding of an
|
|
121
|
+
* assertion (checks 1–3 of spec/delegation.md). Use checkCall for the rest.
|
|
122
|
+
*/
|
|
123
|
+
async function verifyAssertion(token, options) {
|
|
124
|
+
const parts = token.split(".");
|
|
125
|
+
if (parts.length !== 3) throw new AssertionError("malformed", "assertion is not a compact JWS");
|
|
126
|
+
const [headerPart, payloadPart, signaturePart] = parts;
|
|
127
|
+
const header = decodeJson(headerPart);
|
|
128
|
+
if (typeof header !== "object" || header === null || header.alg !== "EdDSA" || header.typ !== "aidy-call+jwt") throw new AssertionError("malformed", "unexpected assertion header");
|
|
129
|
+
const kid = header.kid;
|
|
130
|
+
const key = typeof kid === "string" ? options.keys.get(kid) : void 0;
|
|
131
|
+
if (!key) throw new AssertionError("unknown_key", `no pinned key ${String(kid)}`);
|
|
132
|
+
if (!await crypto.subtle.verify("Ed25519", key, fromBase64url(signaturePart), encoder.encode(`${headerPart}.${payloadPart}`))) throw new AssertionError("bad_signature", "assertion signature does not verify");
|
|
133
|
+
const parsed = AssertionClaims.safeParse(decodeJson(payloadPart));
|
|
134
|
+
if (!parsed.success) throw new AssertionError("malformed", "assertion claims are invalid");
|
|
135
|
+
const claims = parsed.data;
|
|
136
|
+
const now = options.now ?? Math.floor(Date.now() / 1e3);
|
|
137
|
+
if (claims.exp - claims.iat > 60) throw new AssertionError("too_long", "assertion lifetime exceeds 60s");
|
|
138
|
+
if (now > claims.exp + CLOCK_SKEW_SECONDS) throw new AssertionError("expired", "assertion expired");
|
|
139
|
+
if (claims.iat > now + CLOCK_SKEW_SECONDS) throw new AssertionError("not_yet_valid", "assertion issued in the future");
|
|
140
|
+
if (claims.aud !== options.audience) throw new AssertionError("audience", "wrong audience");
|
|
141
|
+
if (claims.htm !== options.request.method.toUpperCase()) throw new AssertionError("method", "method does not match the request");
|
|
142
|
+
if (claims.htu !== options.request.url) throw new AssertionError("url", "URL does not match");
|
|
143
|
+
if (claims.bsh !== await sha256(options.request.body)) throw new AssertionError("body", "body hash does not match");
|
|
144
|
+
if (!await options.remember(claims.jti, claims.exp + CLOCK_SKEW_SECONDS)) throw new AssertionError("replay", "assertion was already used");
|
|
145
|
+
return claims;
|
|
146
|
+
}
|
|
147
|
+
/** Checks 4–6 of spec/delegation.md: the assertion matches the user and the operation. */
|
|
148
|
+
function checkCall(claims, call) {
|
|
149
|
+
if (claims.sub !== call.subject) throw new AssertionError("subject", "subject mismatch");
|
|
150
|
+
if (claims.ten !== call.tenant) throw new AssertionError("tenant", "tenant mismatch");
|
|
151
|
+
if (claims.op !== call.op) throw new AssertionError("operation", "operation mismatch");
|
|
152
|
+
if (call.approval === "always" && !claims.apr) throw new AssertionError("approval_missing", "operation requires an approval");
|
|
153
|
+
}
|
|
154
|
+
export { ASSERTION_HEADER, ASSERTION_TYPE, AssertionClaims, AssertionError, HOST_ASSERTION_HEADER, MAX_ASSERTION_SECONDS, argsHash, base64url, canonicalJson, checkCall, fromBase64url, generateKeyPair, importPublicKeys, sha256, signAssertion, verifyAssertion };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* aidy's AG-UI 1.0 profile: interrupts, forms, tool metadata and custom events.
|
|
3
|
+
* See spec/protocol.md.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
export declare const PROTOCOL_VERSION = "aidy/0";
|
|
7
|
+
export declare const API_PREFIX = "/aidy/v0";
|
|
8
|
+
/** Key under which aidy's data sits in AG-UI `metadata`. */
|
|
9
|
+
export declare const METADATA_KEY = "aidy";
|
|
10
|
+
/** `metadata.aidy` on every event. `seq` increases per thread and is the SSE id. */
|
|
11
|
+
export declare const EventMeta: z.ZodObject<{
|
|
12
|
+
seq: z.ZodInt;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export type EventMeta = z.infer<typeof EventMeta>;
|
|
15
|
+
export declare const InterruptReason: {
|
|
16
|
+
readonly approval: 'aidy:approval';
|
|
17
|
+
readonly input: 'aidy:input';
|
|
18
|
+
readonly task: 'aidy:task';
|
|
19
|
+
};
|
|
20
|
+
export declare const APPROVAL_TTL_SECONDS: number;
|
|
21
|
+
export declare const RunErrorCode: z.ZodEnum<{
|
|
22
|
+
history_conflict: "history_conflict";
|
|
23
|
+
internal: "internal";
|
|
24
|
+
invalid_interaction: "invalid_interaction";
|
|
25
|
+
max_steps: "max_steps";
|
|
26
|
+
model_unavailable: "model_unavailable";
|
|
27
|
+
open_interrupts: "open_interrupts";
|
|
28
|
+
}>;
|
|
29
|
+
export type RunErrorCode = z.infer<typeof RunErrorCode>;
|
|
30
|
+
export declare const ToolErrorCode: z.ZodString;
|
|
31
|
+
/**
|
|
32
|
+
* `TOOL_CALL_START.metadata.aidy`: the call's operation, beside the event's `seq` (which a
|
|
33
|
+
* reader may have taken out already). Built-in tools (`search`, `request_input`) use their own
|
|
34
|
+
* name as op.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ToolCallMeta: z.ZodObject<{
|
|
37
|
+
seq: z.ZodOptional<z.ZodInt>;
|
|
38
|
+
op: z.ZodString;
|
|
39
|
+
title: z.ZodString;
|
|
40
|
+
effect: z.ZodEnum<{
|
|
41
|
+
create: "create";
|
|
42
|
+
delete: "delete";
|
|
43
|
+
external: "external";
|
|
44
|
+
read: "read";
|
|
45
|
+
update: "update";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type ToolCallMeta = z.infer<typeof ToolCallMeta>;
|
|
49
|
+
/** `TOOL_CALL_RESULT.metadata.aidy`: the call's outcome, beside the event's `seq`. */
|
|
50
|
+
export declare const ToolResultMeta: z.ZodObject<{
|
|
51
|
+
seq: z.ZodOptional<z.ZodInt>;
|
|
52
|
+
status: z.ZodEnum<{
|
|
53
|
+
failed: "failed";
|
|
54
|
+
succeeded: "succeeded";
|
|
55
|
+
}>;
|
|
56
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
code: z.ZodString;
|
|
58
|
+
message: z.ZodString;
|
|
59
|
+
}, z.core.$strict>>;
|
|
60
|
+
deduplicated: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
export type ToolResultMeta = z.infer<typeof ToolResultMeta>;
|
|
63
|
+
export declare const ApprovalImpact: z.ZodObject<{
|
|
64
|
+
title: z.ZodString;
|
|
65
|
+
target: z.ZodNullable<z.ZodString>;
|
|
66
|
+
effect: z.ZodEnum<{
|
|
67
|
+
create: "create";
|
|
68
|
+
delete: "delete";
|
|
69
|
+
external: "external";
|
|
70
|
+
read: "read";
|
|
71
|
+
update: "update";
|
|
72
|
+
}>;
|
|
73
|
+
risk: z.ZodNullable<z.ZodEnum<{
|
|
74
|
+
high: "high";
|
|
75
|
+
low: "low";
|
|
76
|
+
medium: "medium";
|
|
77
|
+
}>>;
|
|
78
|
+
costHint: z.ZodNullable<z.ZodString>;
|
|
79
|
+
changes: z.ZodArray<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export type ApprovalImpact = z.infer<typeof ApprovalImpact>;
|
|
82
|
+
/** `Interrupt.metadata.aidy` for `aidy:approval`. */
|
|
83
|
+
export declare const ApprovalInterruptMeta: z.ZodObject<{
|
|
84
|
+
op: z.ZodString;
|
|
85
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
86
|
+
argsHash: z.ZodString;
|
|
87
|
+
impact: z.ZodObject<{
|
|
88
|
+
title: z.ZodString;
|
|
89
|
+
target: z.ZodNullable<z.ZodString>;
|
|
90
|
+
effect: z.ZodEnum<{
|
|
91
|
+
create: "create";
|
|
92
|
+
delete: "delete";
|
|
93
|
+
external: "external";
|
|
94
|
+
read: "read";
|
|
95
|
+
update: "update";
|
|
96
|
+
}>;
|
|
97
|
+
risk: z.ZodNullable<z.ZodEnum<{
|
|
98
|
+
high: "high";
|
|
99
|
+
low: "low";
|
|
100
|
+
medium: "medium";
|
|
101
|
+
}>>;
|
|
102
|
+
costHint: z.ZodNullable<z.ZodString>;
|
|
103
|
+
changes: z.ZodArray<z.ZodString>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
}, z.core.$strict>;
|
|
106
|
+
export type ApprovalInterruptMeta = z.infer<typeof ApprovalInterruptMeta>;
|
|
107
|
+
export declare const ApprovalPayload: z.ZodObject<{
|
|
108
|
+
approved: z.ZodBoolean;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
export type ApprovalPayload = z.infer<typeof ApprovalPayload>;
|
|
111
|
+
/** `ResumeEntry.metadata.aidy` answering an approval: the hash the user saw. */
|
|
112
|
+
export declare const ApprovalResumeMeta: z.ZodObject<{
|
|
113
|
+
argsHash: z.ZodString;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
export declare const APPROVAL_RESPONSE_SCHEMA: Record<string, unknown>;
|
|
116
|
+
export declare const FormOption: z.ZodObject<{
|
|
117
|
+
id: z.ZodString;
|
|
118
|
+
label: z.ZodString;
|
|
119
|
+
description: z.ZodOptional<z.ZodString>;
|
|
120
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
+
}, z.core.$strict>;
|
|
122
|
+
export declare const FormQuestion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
prompt: z.ZodString;
|
|
125
|
+
kind: z.ZodLiteral<"text">;
|
|
126
|
+
required: z.ZodBoolean;
|
|
127
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
128
|
+
default: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
prompt: z.ZodString;
|
|
132
|
+
kind: z.ZodLiteral<"choice">;
|
|
133
|
+
required: z.ZodBoolean;
|
|
134
|
+
options: z.ZodArray<z.ZodObject<{
|
|
135
|
+
id: z.ZodString;
|
|
136
|
+
label: z.ZodString;
|
|
137
|
+
description: z.ZodOptional<z.ZodString>;
|
|
138
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
139
|
+
}, z.core.$strict>>;
|
|
140
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
141
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
143
|
+
}, z.core.$strict>], "kind">;
|
|
144
|
+
export type FormQuestion = z.infer<typeof FormQuestion>;
|
|
145
|
+
export declare const MAX_FORM_QUESTIONS = 24;
|
|
146
|
+
export declare const Form: z.ZodObject<{
|
|
147
|
+
prompt: z.ZodString;
|
|
148
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
prompt: z.ZodString;
|
|
151
|
+
kind: z.ZodLiteral<"text">;
|
|
152
|
+
required: z.ZodBoolean;
|
|
153
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
154
|
+
default: z.ZodOptional<z.ZodString>;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
prompt: z.ZodString;
|
|
158
|
+
kind: z.ZodLiteral<"choice">;
|
|
159
|
+
required: z.ZodBoolean;
|
|
160
|
+
options: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
label: z.ZodString;
|
|
163
|
+
description: z.ZodOptional<z.ZodString>;
|
|
164
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
+
}, z.core.$strict>>;
|
|
166
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
167
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
168
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
169
|
+
}, z.core.$strict>], "kind">>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
export type Form = z.infer<typeof Form>;
|
|
172
|
+
export declare const ChoiceAnswer: z.ZodObject<{
|
|
173
|
+
selected: z.ZodArray<z.ZodString>;
|
|
174
|
+
custom: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strict>;
|
|
176
|
+
export type ChoiceAnswer = z.infer<typeof ChoiceAnswer>;
|
|
177
|
+
export declare const FormAnswers: z.ZodObject<{
|
|
178
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
179
|
+
selected: z.ZodArray<z.ZodString>;
|
|
180
|
+
custom: z.ZodOptional<z.ZodString>;
|
|
181
|
+
}, z.core.$strict>]>>;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
export type FormAnswers = z.infer<typeof FormAnswers>;
|
|
184
|
+
/** `Interrupt.metadata.aidy` for `aidy:input`. */
|
|
185
|
+
export declare const InputInterruptMeta: z.ZodObject<{
|
|
186
|
+
form: z.ZodObject<{
|
|
187
|
+
prompt: z.ZodString;
|
|
188
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
189
|
+
id: z.ZodString;
|
|
190
|
+
prompt: z.ZodString;
|
|
191
|
+
kind: z.ZodLiteral<"text">;
|
|
192
|
+
required: z.ZodBoolean;
|
|
193
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
194
|
+
default: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
196
|
+
id: z.ZodString;
|
|
197
|
+
prompt: z.ZodString;
|
|
198
|
+
kind: z.ZodLiteral<"choice">;
|
|
199
|
+
required: z.ZodBoolean;
|
|
200
|
+
options: z.ZodArray<z.ZodObject<{
|
|
201
|
+
id: z.ZodString;
|
|
202
|
+
label: z.ZodString;
|
|
203
|
+
description: z.ZodOptional<z.ZodString>;
|
|
204
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
205
|
+
}, z.core.$strict>>;
|
|
206
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
209
|
+
}, z.core.$strict>], "kind">>;
|
|
210
|
+
}, z.core.$strict>;
|
|
211
|
+
}, z.core.$strict>;
|
|
212
|
+
/** `Interrupt.metadata.aidy` for `aidy:task`. */
|
|
213
|
+
export declare const TaskInterruptMeta: z.ZodObject<{
|
|
214
|
+
taskId: z.ZodString;
|
|
215
|
+
op: z.ZodString;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
/** The AG-UI `responseSchema` of a form interrupt. */
|
|
218
|
+
export declare function formResponseSchema(form: Form): Record<string, unknown>;
|
|
219
|
+
export interface AnswerIssue {
|
|
220
|
+
readonly question: string;
|
|
221
|
+
readonly message: string;
|
|
222
|
+
}
|
|
223
|
+
/** Validates a form answer. An empty list means it is acceptable. */
|
|
224
|
+
export declare function checkAnswers(form: Form, answers: FormAnswers['answers']): AnswerIssue[];
|
|
225
|
+
export declare const CustomEvents: {
|
|
226
|
+
readonly 'aidy.ui.open': z.ZodObject<{
|
|
227
|
+
path: z.ZodString;
|
|
228
|
+
}, z.core.$strict>;
|
|
229
|
+
readonly 'aidy.citation': z.ZodObject<{
|
|
230
|
+
messageId: z.ZodString;
|
|
231
|
+
hits: z.ZodArray<z.ZodObject<{
|
|
232
|
+
type: z.ZodString;
|
|
233
|
+
id: z.ZodString;
|
|
234
|
+
title: z.ZodString;
|
|
235
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
236
|
+
url: z.ZodString;
|
|
237
|
+
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
238
|
+
}, z.core.$strict>>;
|
|
239
|
+
}, z.core.$strict>;
|
|
240
|
+
readonly 'aidy.context': z.ZodObject<{
|
|
241
|
+
usedTokens: z.ZodInt;
|
|
242
|
+
budgetTokens: z.ZodInt;
|
|
243
|
+
source: z.ZodEnum<{
|
|
244
|
+
estimated: "estimated";
|
|
245
|
+
provider: "provider";
|
|
246
|
+
}>;
|
|
247
|
+
}, z.core.$strict>;
|
|
248
|
+
readonly 'aidy.model.retry': z.ZodObject<{
|
|
249
|
+
step: z.ZodInt;
|
|
250
|
+
attempt: z.ZodInt;
|
|
251
|
+
maxAttempts: z.ZodInt;
|
|
252
|
+
reason: z.ZodString;
|
|
253
|
+
}, z.core.$strict>;
|
|
254
|
+
readonly 'aidy.message.discard': z.ZodObject<{
|
|
255
|
+
messageId: z.ZodString;
|
|
256
|
+
}, z.core.$strict>;
|
|
257
|
+
readonly 'aidy.task': z.ZodObject<{
|
|
258
|
+
taskId: z.ZodString;
|
|
259
|
+
status: z.ZodEnum<{
|
|
260
|
+
cancelled: "cancelled";
|
|
261
|
+
failed: "failed";
|
|
262
|
+
running: "running";
|
|
263
|
+
succeeded: "succeeded";
|
|
264
|
+
}>;
|
|
265
|
+
message: z.ZodOptional<z.ZodString>;
|
|
266
|
+
}, z.core.$strict>;
|
|
267
|
+
};
|
|
268
|
+
export type CustomEventName = keyof typeof CustomEvents;
|
|
269
|
+
export type CustomEventValue<N extends CustomEventName> = z.infer<(typeof CustomEvents)[N]>;
|
|
270
|
+
export declare const PROGRESS_ACTIVITY = "aidy.progress";
|
|
271
|
+
export declare const ProgressContent: z.ZodObject<{
|
|
272
|
+
message: z.ZodString;
|
|
273
|
+
}, z.core.$strict>;
|