agentic-assistant 0.0.0-stage → 0.2.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +261 -2
- package/SKILL.md +64 -0
- package/dist/chat-pBg4wRjQ.d.ts +120 -0
- package/dist/chunk-6UD2QQA4.js +82 -0
- package/dist/chunk-BDXAUNMR.js +698 -0
- package/dist/chunk-HYT732TN.js +36 -0
- package/dist/chunk-T4ZMDOB4.js +674 -0
- package/dist/cli.d.ts +29 -0
- package/dist/cli.js +327 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +77 -0
- package/dist/loop-42giKLVa.d.ts +285 -0
- package/dist/mcp-server-X5VTHZVM.js +11 -0
- package/dist/react.css +57 -0
- package/dist/react.d.ts +56 -0
- package/dist/react.js +327 -0
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +6 -0
- package/dist/types-DGH8FS56.d.ts +84 -0
- package/dist/worker.d.ts +41 -0
- package/dist/worker.js +276 -0
- package/llms.txt +17 -0
- package/package.json +95 -4
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { J as JsonSchema, U as Usage, A as AnsweredBy, c as Message, M as ModelProvider } from './types-DGH8FS56.js';
|
|
2
|
+
|
|
3
|
+
declare const ACTIONS: readonly ["read", "comment", "write", "admin"];
|
|
4
|
+
type Action = (typeof ACTIONS)[number];
|
|
5
|
+
type Scope = string;
|
|
6
|
+
declare function parseScope(scope: Scope): {
|
|
7
|
+
resource: string;
|
|
8
|
+
action: Action;
|
|
9
|
+
};
|
|
10
|
+
/** True when `grant` allows everything `required` asks for. */
|
|
11
|
+
declare function scopeCovers(grant: Scope, required: Scope): boolean;
|
|
12
|
+
/** True when any granted scope covers the required one. A malformed scope never matches. */
|
|
13
|
+
declare function hasScope(granted: readonly Scope[], required: Scope): boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The acting principal. The assistant always acts as an agent of a signed-in
|
|
17
|
+
* person. The host passes the scopes, already narrowed to what the person
|
|
18
|
+
* granted this agent. The assistant never widens them.
|
|
19
|
+
*/
|
|
20
|
+
interface AssistantPrincipal {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly kind: "agent_of_human";
|
|
23
|
+
/** The person the assistant acts for. */
|
|
24
|
+
readonly parentId: string;
|
|
25
|
+
readonly scopes: readonly Scope[];
|
|
26
|
+
/** Epoch milliseconds. Calls stop at this time. */
|
|
27
|
+
readonly expiresAt?: number;
|
|
28
|
+
/** Host check, run before every tool call. A throw or a true result denies the call. */
|
|
29
|
+
readonly isRevoked?: () => boolean | Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
interface PrincipalInput {
|
|
32
|
+
id: string;
|
|
33
|
+
kind?: string;
|
|
34
|
+
parentId: string;
|
|
35
|
+
scopes: readonly Scope[];
|
|
36
|
+
expiresAt?: number;
|
|
37
|
+
isRevoked?: () => boolean | Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
declare class PrincipalError extends Error {
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
/** Validates host input. A missing or other kind is an error, never a default. */
|
|
43
|
+
declare function createPrincipal(input: PrincipalInput): AssistantPrincipal;
|
|
44
|
+
/** Re-checks a principal at the start of a run. A cast or a plain JS caller cannot skip validation. */
|
|
45
|
+
declare function assertPrincipal(principal: AssistantPrincipal): void;
|
|
46
|
+
/** Who a run, a tool call, and every audit row is attributed to. Always machine-made. */
|
|
47
|
+
interface Actor {
|
|
48
|
+
principalId: string;
|
|
49
|
+
kind: "agent_of_human";
|
|
50
|
+
onBehalfOf: string;
|
|
51
|
+
machineMade: true;
|
|
52
|
+
}
|
|
53
|
+
declare function actorOf(principal: AssistantPrincipal): Actor;
|
|
54
|
+
|
|
55
|
+
/** `safe` runs at once. `risky` and `irreversible` wait for a person. */
|
|
56
|
+
type ToolRisk = "safe" | "risky" | "irreversible";
|
|
57
|
+
declare const TOOL_RISKS: readonly ToolRisk[];
|
|
58
|
+
interface ApprovalRequest {
|
|
59
|
+
id: string;
|
|
60
|
+
tool: string;
|
|
61
|
+
risk: "risky" | "irreversible";
|
|
62
|
+
/** A frozen copy of the arguments the tool will get. */
|
|
63
|
+
input: Readonly<Record<string, unknown>>;
|
|
64
|
+
/** Binds the tool, the arguments, and the acting principal. The decision must echo it. */
|
|
65
|
+
digest: string;
|
|
66
|
+
actor: Actor;
|
|
67
|
+
}
|
|
68
|
+
/** Who gave an approval. The gate says it. `human` means a signed-in person, `host` means a rule the host set up, `agent` means another agent. */
|
|
69
|
+
type ApproverKind = "human" | "agent" | "host";
|
|
70
|
+
type ApprovalDecision = {
|
|
71
|
+
requestId: string;
|
|
72
|
+
approved: true;
|
|
73
|
+
digest: string;
|
|
74
|
+
decidedBy: string; /** Leave it out when you do not know. The record then says "unknown". */
|
|
75
|
+
approverKind?: ApproverKind;
|
|
76
|
+
} | {
|
|
77
|
+
requestId: string;
|
|
78
|
+
approved: false;
|
|
79
|
+
decidedBy?: string;
|
|
80
|
+
reason?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The approval port. Answer a request with a decision, or fail. The loop treats
|
|
84
|
+
* a failure, a timeout, and a decision that does not match the request as a refusal.
|
|
85
|
+
*/
|
|
86
|
+
interface ApprovalGate {
|
|
87
|
+
request(request: ApprovalRequest, signal: AbortSignal): Promise<ApprovalDecision>;
|
|
88
|
+
}
|
|
89
|
+
/** JSON with sorted keys, so equal values give equal text. */
|
|
90
|
+
declare function canonicalJson(value: unknown): string;
|
|
91
|
+
declare function digestCall(call: {
|
|
92
|
+
tool: string;
|
|
93
|
+
input: unknown;
|
|
94
|
+
principalId: string;
|
|
95
|
+
onBehalfOf: string;
|
|
96
|
+
}): string;
|
|
97
|
+
/**
|
|
98
|
+
* An in-memory gate. `request` waits until `approve` or `reject` is called with the request id.
|
|
99
|
+
* A panel, a CLI, or a test calls them. `approve` signs the stored digest, so a caller cannot
|
|
100
|
+
* approve other arguments than the ones the loop asked about.
|
|
101
|
+
*/
|
|
102
|
+
declare class QueueApprovalGate implements ApprovalGate {
|
|
103
|
+
private readonly waiting;
|
|
104
|
+
pending(): ApprovalRequest[];
|
|
105
|
+
request(request: ApprovalRequest, signal: AbortSignal): Promise<ApprovalDecision>;
|
|
106
|
+
approve(id: string, decidedBy: string, approverKind?: ApproverKind): void;
|
|
107
|
+
reject(id: string, decidedBy?: string, reason?: string): void;
|
|
108
|
+
private take;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Says that a machine made an output, and which one. Attach it to every result and every edit. */
|
|
112
|
+
interface Provenance {
|
|
113
|
+
generator: "ai";
|
|
114
|
+
/** The model that answered. After a fallback, this is the fallback model. */
|
|
115
|
+
model: string;
|
|
116
|
+
provider: string;
|
|
117
|
+
/** ISO 8601 time, in UTC. */
|
|
118
|
+
createdAt: string;
|
|
119
|
+
/** The id of the assistant principal that acted. */
|
|
120
|
+
actor: string;
|
|
121
|
+
/** The person the assistant acts for. */
|
|
122
|
+
onBehalfOf: string;
|
|
123
|
+
/** The tool that ran. Set on a tool result. */
|
|
124
|
+
tool?: string;
|
|
125
|
+
/** The risk of that tool. A host may mark only `risky` and `irreversible` results as edits. */
|
|
126
|
+
risk?: "safe" | "risky" | "irreversible";
|
|
127
|
+
/** Who approved the action, and what kind of approver it was. Check `kind` before you say a person approved. */
|
|
128
|
+
approvedBy?: Approver[];
|
|
129
|
+
}
|
|
130
|
+
interface Approver {
|
|
131
|
+
id: string;
|
|
132
|
+
/** `unknown` when the approval gate did not say. */
|
|
133
|
+
kind: ApproverKind | "unknown";
|
|
134
|
+
}
|
|
135
|
+
interface ProvenanceInput {
|
|
136
|
+
model: string;
|
|
137
|
+
provider: string;
|
|
138
|
+
/** Epoch milliseconds. */
|
|
139
|
+
createdAt: number;
|
|
140
|
+
actor: string;
|
|
141
|
+
onBehalfOf: string;
|
|
142
|
+
tool?: string;
|
|
143
|
+
risk?: Provenance["risk"];
|
|
144
|
+
approvedBy?: readonly Approver[];
|
|
145
|
+
}
|
|
146
|
+
/** The IPTC digital source type for content made by a model. */
|
|
147
|
+
declare const TRAINED_ALGORITHMIC_MEDIA = "http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia";
|
|
148
|
+
declare function createProvenance(input: ProvenanceInput): Provenance;
|
|
149
|
+
/**
|
|
150
|
+
* A JSON-LD marker for a document or a file. Store it next to the content the assistant made.
|
|
151
|
+
* It uses schema.org terms and the IPTC `trainedAlgorithmicMedia` source type.
|
|
152
|
+
*/
|
|
153
|
+
declare function provenanceMarker(provenance: Provenance): Record<string, unknown>;
|
|
154
|
+
/** A short text for a person to read, such as "AI-generated by model-1 (acme), approved by ana". */
|
|
155
|
+
declare function provenanceLabel(provenance: Provenance): string;
|
|
156
|
+
|
|
157
|
+
interface ToolContext {
|
|
158
|
+
principal: AssistantPrincipal;
|
|
159
|
+
toolUseId: string;
|
|
160
|
+
signal?: AbortSignal;
|
|
161
|
+
}
|
|
162
|
+
interface ToolDefinition<Input = Record<string, unknown>> {
|
|
163
|
+
name: string;
|
|
164
|
+
description: string;
|
|
165
|
+
/** A JSON Schema with `type: "object"`. The loop validates the model's input against it. */
|
|
166
|
+
inputSchema: JsonSchema;
|
|
167
|
+
/** The scope the acting principal must hold to call this tool. */
|
|
168
|
+
scope: Scope;
|
|
169
|
+
/** How much harm a call can do. `risky` and `irreversible` wait for a person's approval. Every tool must say. */
|
|
170
|
+
risk: ToolRisk;
|
|
171
|
+
handler(input: Input, context: ToolContext): Promise<unknown> | unknown;
|
|
172
|
+
}
|
|
173
|
+
/** Types a tool for an SDK function. The loop checks the input against `inputSchema` before it calls `handler`. */
|
|
174
|
+
declare function defineTool<Input>(tool: ToolDefinition<Input>): ToolDefinition;
|
|
175
|
+
declare class ToolRegistry {
|
|
176
|
+
private readonly tools;
|
|
177
|
+
private readonly ajv;
|
|
178
|
+
register(tool: ToolDefinition): this;
|
|
179
|
+
registerAll(tools: readonly ToolDefinition[]): this;
|
|
180
|
+
get(name: string): ToolDefinition | undefined;
|
|
181
|
+
list(): ToolDefinition[];
|
|
182
|
+
/** Returns a short description of the first schema violation, or undefined when the input is valid. */
|
|
183
|
+
checkInput(name: string, input: unknown): string | undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface RunLimits {
|
|
187
|
+
/** Most model turns in one run. Default 8. */
|
|
188
|
+
maxTurns?: number;
|
|
189
|
+
/** Most input plus output tokens, summed over all turns. */
|
|
190
|
+
maxTotalTokens?: number;
|
|
191
|
+
/** Most estimated cost in US dollars. Needs `pricing` on the provider. */
|
|
192
|
+
maxCostUsd?: number;
|
|
193
|
+
/** Output token ceiling for one turn. Default 4096. */
|
|
194
|
+
maxOutputTokensPerTurn?: number;
|
|
195
|
+
/** Time to wait for a person to decide. No decision in time means the call is refused. Default 300000. */
|
|
196
|
+
approvalTimeoutMs?: number;
|
|
197
|
+
/** Most tool calls the model may make in one turn. A larger turn runs none. Default 16. */
|
|
198
|
+
maxToolCallsPerTurn?: number;
|
|
199
|
+
/** Longest tool result, in characters, sent to the model. Longer results are cut. Default 32768. */
|
|
200
|
+
maxToolResultChars?: number;
|
|
201
|
+
}
|
|
202
|
+
interface RunOptions {
|
|
203
|
+
provider: ModelProvider;
|
|
204
|
+
registry: ToolRegistry;
|
|
205
|
+
principal: AssistantPrincipal;
|
|
206
|
+
/** The conversation so far, ending with the new user message. */
|
|
207
|
+
messages: readonly Message[];
|
|
208
|
+
system?: string;
|
|
209
|
+
/** Asked before a `risky` or `irreversible` tool runs. Without it, those tools are not offered and are refused. */
|
|
210
|
+
approvals?: ApprovalGate;
|
|
211
|
+
limits?: RunLimits;
|
|
212
|
+
signal?: AbortSignal;
|
|
213
|
+
now?: () => number;
|
|
214
|
+
}
|
|
215
|
+
type DoneReason = "end_turn" | "max_tokens" | "refusal" | "provider_stop" | "max_turns" | "token_cap" | "cost_cap" | "tool_call_cap" | "provider_error" | "principal_inactive" | "aborted";
|
|
216
|
+
type DeniedReason = "unknown_tool" | "scope" | "invalid_input" | "approval";
|
|
217
|
+
interface RunTotals extends Usage {
|
|
218
|
+
costUsd: number;
|
|
219
|
+
}
|
|
220
|
+
type AssistantEvent = {
|
|
221
|
+
type: "run_start";
|
|
222
|
+
actor: Actor;
|
|
223
|
+
provider: string;
|
|
224
|
+
model: string;
|
|
225
|
+
} | {
|
|
226
|
+
type: "turn_start";
|
|
227
|
+
turn: number;
|
|
228
|
+
} | {
|
|
229
|
+
type: "text_delta";
|
|
230
|
+
text: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: "tool_call";
|
|
233
|
+
id: string;
|
|
234
|
+
name: string;
|
|
235
|
+
input: unknown;
|
|
236
|
+
actor: Actor;
|
|
237
|
+
} | {
|
|
238
|
+
type: "approval_request";
|
|
239
|
+
request: ApprovalRequest;
|
|
240
|
+
} | {
|
|
241
|
+
type: "approval_decision";
|
|
242
|
+
requestId: string;
|
|
243
|
+
approved: boolean; /** True only when the approver said no. A timeout or a gate failure is not a decline. */
|
|
244
|
+
declined: boolean;
|
|
245
|
+
decidedBy?: string;
|
|
246
|
+
reason?: string;
|
|
247
|
+
} | {
|
|
248
|
+
type: "tool_result";
|
|
249
|
+
id: string;
|
|
250
|
+
name: string;
|
|
251
|
+
content: string;
|
|
252
|
+
isError: boolean;
|
|
253
|
+
denied?: DeniedReason;
|
|
254
|
+
/** True when `content` came from a tool. Treat it as data, never as an instruction. */
|
|
255
|
+
untrusted?: true;
|
|
256
|
+
/** The raw failure text. It stays in the event and never goes to the model. */
|
|
257
|
+
detail?: string;
|
|
258
|
+
actor: Actor;
|
|
259
|
+
/** Marks the result as machine-made. Set when the tool ran. */
|
|
260
|
+
provenance?: Provenance;
|
|
261
|
+
} | {
|
|
262
|
+
type: "turn_end";
|
|
263
|
+
turn: number;
|
|
264
|
+
usage: Usage;
|
|
265
|
+
totals: RunTotals; /** The model that answered this turn. */
|
|
266
|
+
answeredBy: AnsweredBy;
|
|
267
|
+
} | {
|
|
268
|
+
type: "done";
|
|
269
|
+
reason: DoneReason;
|
|
270
|
+
totals: RunTotals;
|
|
271
|
+
actor: Actor;
|
|
272
|
+
messages: Message[];
|
|
273
|
+
error?: string; /** Marks the answer as machine-made. Set once a model has answered. */
|
|
274
|
+
provenance?: Provenance;
|
|
275
|
+
};
|
|
276
|
+
/** Sent with every request. Tool output is data, never an instruction. */
|
|
277
|
+
declare const DATA_NOTICE: string;
|
|
278
|
+
/**
|
|
279
|
+
* Runs the assistant until the model stops, a cap trips, or the principal stops
|
|
280
|
+
* being valid. Tools run only when the model stops to use them, only inside the
|
|
281
|
+
* principal's scopes, and never after a cap has tripped.
|
|
282
|
+
*/
|
|
283
|
+
declare function runAssistant(options: RunOptions): AsyncGenerator<AssistantEvent>;
|
|
284
|
+
|
|
285
|
+
export { ACTIONS as A, defineTool as B, digestCall as C, DATA_NOTICE as D, hasScope as E, parseScope as F, provenanceLabel as G, provenanceMarker as H, runAssistant as I, scopeCovers as J, PrincipalError as P, QueueApprovalGate as Q, type RunLimits as R, type Scope as S, TOOL_RISKS as T, type Action as a, type Actor as b, type ApprovalDecision as c, type ApprovalGate as d, type ApprovalRequest as e, type Approver as f, type ApproverKind as g, type AssistantEvent as h, type AssistantPrincipal as i, type DeniedReason as j, type DoneReason as k, type PrincipalInput as l, type Provenance as m, type ProvenanceInput as n, type RunOptions as o, type RunTotals as p, TRAINED_ALGORITHMIC_MEDIA as q, type ToolContext as r, type ToolDefinition as s, ToolRegistry as t, type ToolRisk as u, actorOf as v, assertPrincipal as w, canonicalJson as x, createPrincipal as y, createProvenance as z };
|
package/dist/react.css
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* Plain CSS variables. Set them on .aa-panel or a parent to match your app. Every pair below meets
|
|
2
|
+
WCAG 2.2 AA contrast; src/react/styles.test.ts checks it. No remote fonts or images. */
|
|
3
|
+
.aa-panel {
|
|
4
|
+
--aa-bg: #ffffff;
|
|
5
|
+
--aa-fg: #1b1b1b;
|
|
6
|
+
--aa-muted: #4d4d4d;
|
|
7
|
+
--aa-border: #767676;
|
|
8
|
+
--aa-accent: #0b57d0;
|
|
9
|
+
--aa-accent-fg: #ffffff;
|
|
10
|
+
--aa-focus: #0b57d0;
|
|
11
|
+
--aa-machine-bg: #e8eefc;
|
|
12
|
+
--aa-machine-fg: #0a2a6b;
|
|
13
|
+
--aa-card-bg: #f4f4f4;
|
|
14
|
+
--aa-warn-bg: #fff4d6;
|
|
15
|
+
--aa-warn-fg: #5c3d00;
|
|
16
|
+
--aa-danger: #b3261e;
|
|
17
|
+
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
height: 100%;
|
|
21
|
+
min-width: 18rem;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
background: var(--aa-bg);
|
|
24
|
+
color: var(--aa-fg);
|
|
25
|
+
border: 1px solid var(--aa-border);
|
|
26
|
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
27
|
+
font-size: 1rem;
|
|
28
|
+
line-height: 1.5;
|
|
29
|
+
}
|
|
30
|
+
.aa-panel *, .aa-panel *::before, .aa-panel *::after { box-sizing: border-box; }
|
|
31
|
+
.aa-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--aa-border); }
|
|
32
|
+
.aa-title { margin: 0; font-size: 1.125rem; }
|
|
33
|
+
.aa-log { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
|
|
34
|
+
.aa-empty { color: var(--aa-muted); margin: 0; }
|
|
35
|
+
.aa-msg { padding: 0.5rem 0.75rem; border: 1px solid var(--aa-border); border-radius: 0.5rem; }
|
|
36
|
+
.aa-assistant { background: var(--aa-card-bg); }
|
|
37
|
+
.aa-who { margin: 0 0 0.25rem; font-weight: 600; color: var(--aa-muted); }
|
|
38
|
+
.aa-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
39
|
+
.aa-badge { display: inline-block; padding: 0 0.5rem; border-radius: 0.25rem; background: var(--aa-machine-bg); color: var(--aa-machine-fg); font-size: 0.875rem; font-weight: 600; border: 1px solid var(--aa-machine-fg); }
|
|
40
|
+
.aa-card, .aa-approval { padding: 0.5rem 0.75rem; border: 1px solid var(--aa-border); border-radius: 0.5rem; background: var(--aa-card-bg); }
|
|
41
|
+
.aa-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
|
|
42
|
+
.aa-status { color: var(--aa-muted); font-weight: 600; }
|
|
43
|
+
.aa-pre { margin: 0.25rem 0 0; padding: 0.5rem; max-height: 12rem; overflow: auto; background: var(--aa-bg); border: 1px solid var(--aa-border); white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.875rem; }
|
|
44
|
+
.aa-approval { background: var(--aa-warn-bg); color: var(--aa-warn-fg); border-width: 2px; border-color: var(--aa-warn-fg); }
|
|
45
|
+
.aa-approval-title { margin: 0 0 0.25rem; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
|
|
46
|
+
.aa-warn { color: var(--aa-danger); background: var(--aa-bg); padding: 0.25rem 0.5rem; border: 2px solid var(--aa-danger); border-radius: 0.25rem; }
|
|
47
|
+
.aa-notice { margin: 0; padding: 0.5rem 0.75rem; border: 1px solid var(--aa-border); border-radius: 0.5rem; }
|
|
48
|
+
.aa-composer { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--aa-border); }
|
|
49
|
+
.aa-label { font-weight: 600; }
|
|
50
|
+
.aa-input { width: 100%; resize: vertical; padding: 0.5rem; font: inherit; color: var(--aa-fg); background: var(--aa-bg); border: 1px solid var(--aa-border); border-radius: 0.25rem; }
|
|
51
|
+
.aa-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
|
|
52
|
+
.aa-composer .aa-actions { margin-top: 0; }
|
|
53
|
+
.aa-button { min-height: 2rem; min-width: 2rem; padding: 0.25rem 1rem; font: inherit; font-weight: 600; color: var(--aa-fg); background: var(--aa-bg); border: 2px solid var(--aa-border); border-radius: 0.25rem; cursor: pointer; }
|
|
54
|
+
.aa-button.aa-primary { color: var(--aa-accent-fg); background: var(--aa-accent); border-color: var(--aa-accent); }
|
|
55
|
+
.aa-button:disabled { cursor: not-allowed; opacity: 0.6; }
|
|
56
|
+
.aa-panel :focus-visible { outline: 3px solid var(--aa-focus); outline-offset: 2px; }
|
|
57
|
+
@media (forced-colors: active) { .aa-badge, .aa-button, .aa-approval, .aa-warn { border: 2px solid CanvasText; } }
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { h as AssistantEvent, u as ToolRisk } from './loop-42giKLVa.js';
|
|
3
|
+
import { c as Message } from './types-DGH8FS56.js';
|
|
4
|
+
|
|
5
|
+
type PanelItem = {
|
|
6
|
+
kind: "user";
|
|
7
|
+
id: string;
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "assistant";
|
|
11
|
+
id: string;
|
|
12
|
+
text: string;
|
|
13
|
+
streaming: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "tool";
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
input: unknown;
|
|
19
|
+
status: "running" | "waiting" | "done" | "failed" | "denied" | "not_run";
|
|
20
|
+
/** Text a tool returned. It is data. Show it as text. */
|
|
21
|
+
content?: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "approval";
|
|
24
|
+
id: string;
|
|
25
|
+
tool: string;
|
|
26
|
+
risk: Exclude<ToolRisk, "safe">;
|
|
27
|
+
input: unknown;
|
|
28
|
+
/** `expired`: the run ended before a decision was used. `unavailable`: the approval did not complete. */
|
|
29
|
+
status: "pending" | "approved" | "declined" | "unavailable" | "expired";
|
|
30
|
+
busy: boolean;
|
|
31
|
+
decidedBy?: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "notice";
|
|
34
|
+
id: string;
|
|
35
|
+
text: string;
|
|
36
|
+
};
|
|
37
|
+
interface UseAssistantOptions {
|
|
38
|
+
/** Runs the assistant for this conversation. The host owns the model, the tools, and the principal. */
|
|
39
|
+
run(messages: Message[], signal: AbortSignal): AsyncIterable<AssistantEvent>;
|
|
40
|
+
/** Passes a person's decision to the approval gate. The host owns the gate and knows who the person is. */
|
|
41
|
+
decide(requestId: string, approved: boolean, reason?: string): void | Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
declare function useAssistant(options: UseAssistantOptions): {
|
|
44
|
+
items: PanelItem[];
|
|
45
|
+
running: boolean;
|
|
46
|
+
send: (text: string) => Promise<void>;
|
|
47
|
+
stop: () => void | undefined;
|
|
48
|
+
decide: (requestId: string, approved: boolean, reason?: string) => Promise<boolean>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface AssistantPanelProps extends UseAssistantOptions {
|
|
52
|
+
title?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function AssistantPanel({ title, run, decide }: AssistantPanelProps): react.JSX.Element;
|
|
55
|
+
|
|
56
|
+
export { AssistantPanel, type AssistantPanelProps, type PanelItem, type UseAssistantOptions, useAssistant };
|