@colixsystems/widget-sdk 0.153.0 → 0.155.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/README.md +18 -2
- package/dist/contract.cjs +23 -2
- package/dist/contract.js +23 -2
- package/dist/hooks.js +32 -4
- package/dist/index.d.ts +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
47
47
|
| **DATASTORE** | `useDatastoreSchema(tableId)` | `{ schema, loading, error, refetch }` | `schema(tableId)` — `datastore.read:<table>` |
|
|
48
48
|
| **DATASTORE** | `useBoundColumns(tableId, shape, props)` | `{ columns, resolved, missing, loading, error }` | `schema(tableId)` (built on `useDatastoreSchema`) — `datastore.read:<table>`. Resolves author-bound column NAMES from `props` by exact name → case-insensitive name → first unclaimed column matching `shape[key].dataType`, so a column an author renamed after install still resolves instead of `record[props.titleField]` reading `undefined`. `columns` holds the resolved NAME (`record[columns.titleField]`); `resolved` holds the full `Column`; `missing` lists non-`optional` keys that never resolved. Falsy `tableId` collapses to `{ columns: {}, resolved: {}, missing: Object.keys(shape), loading: false, error: null }`. |
|
|
49
49
|
| **DATASTORE** | `useInterpretDraft(tableId)` | `{ interpret, interpreting, error, result, available }` | `interpret(tableId, body)` — `datastore.read:<table>`. Turns ONE sentence a user typed ("walk at 11 am tomorrow") into DRAFT column values so a form can prefill itself. IMPERATIVE: call `interpret(text, { fields?, timeZone? })` from an event handler, never on mount. It DRAFTS and writes nothing — show the values for review, then submit through `useDatastoreMutation().create`. Resolves to `{ values, unresolved }`; `values` is keyed by column NAME (the shape `create()` takes) and `unresolved` names the fields the sentence did not state. Only text / number / boolean / date / datetime / array columns are drafted — `FILE`, `RELATION`, `USER` and `USER_GROUP` carry ids and are never guessed. Fails closed to an empty draft. **Every call spends the workspace's AI credits** and is rate-limited per actor, so call it once per user action (never on mount or in a render loop); once the workspace runs out the call is refused with a generic 429 — an app user is deliberately **not** told the workspace's billing state, since they have never heard of an AI credit and cannot buy one. Never surface a raw error to the person filling the form: say drafting is unavailable and keep every field editable by hand. `available` is false where the host brokers no interpreter. |
|
|
50
|
-
| **AGENTS** | `useAgent(agentRef)` | `{ send, reset, messages, sending, error, available }` | `ctx.agents` — `ai.invoke:*`. Hold a conversation with one of the WORKSPACE's own AI agents (an author-written name + system prompt). IMPERATIVE: call `send(text)` from an event handler, never on mount — the first send opens the conversation, so a widget nobody types into costs nothing. `messages` is the running transcript, oldest first. You **cannot** set or read the system prompt, replay an edited transcript, or pick a model: the server assembles every turn from the stored prompt plus the stored history, and `content` is the only thing that reaches the wire. `reset()` drops the thread (a "new chat" affordance). **Every send spends the workspace's AI credits** and is rate-limited per caller AND per workspace. Rejects with `AgentError`; branch on `.code` — `AI_QUOTA_EXCEEDED` (429) is the workspace's credit ceiling and will NOT clear on a retry, unlike `RATE_LIMITED`, so never offer "try again" for it, and `AGENT_DISABLED` (409) means the author turned it off, so hide the affordance. Never surface a raw error or the workspace's billing state to an app user. `available` is false when no agent is bound or the host brokers none — render a visible unbound state, never a blank box. |
|
|
50
|
+
| **AGENTS** | `useAgent(agentRef)` | `{ send, reset, messages, sending, error, available }` | `ctx.agents` — `ai.invoke:*`. Hold a conversation with one of the WORKSPACE's own AI agents (an author-written name + system prompt). IMPERATIVE: call `send(text)` from an event handler, never on mount — the first send opens the conversation, so a widget nobody types into costs nothing. `messages` is the running transcript, oldest first. You **cannot** set or read the system prompt, replay an edited transcript, or pick a model: the server assembles every turn from the stored prompt plus the stored history, and `content` is the only thing that reaches the wire. `reset()` drops the thread (a "new chat" affordance). **Every send spends the workspace's AI credits** and is rate-limited per caller AND per workspace. Rejects with `AgentError`; branch on `.code` — `AI_QUOTA_EXCEEDED` (429) is the workspace's credit ceiling and will NOT clear on a retry, unlike `RATE_LIMITED`, so never offer "try again" for it, and `AGENT_DISABLED` (409) means the author turned it off, so hide the affordance. Never surface a raw error or the workspace's billing state to an app user. `available` is false when no agent is bound or the host brokers none — render a visible unbound state, never a blank box. An assistant message that used a tool also carries **`activity`** — what the agent DID with the user's data: the table it read, or the table and columns it CHANGED (never the values, and never a row the permissions refused). **Render a write.** A reply saying "done!" is not evidence a row was written, and if the agent got it wrong the user has no other way to notice. A talk-only turn omits the key entirely. |
|
|
51
51
|
| **DATASTORE** | `useDatastoreMutation(table)` | `{ create, update, delete }` | `records(table).{ create, update (PATCH), delete }` — `datastore.write:*`. **To CLEAR a cell, pass it empty** — `update(id, { when: null })` (also `""` or `[]`) empties that cell and it reads back as `null` (`[]` on an array column). There is no separate clear call, so never write a sentinel such as `0` or a placeholder date to mean "no value". `false` and `0` are values, not clears, and a REQUIRED column cannot be cleared. |
|
|
52
52
|
| **DATASTORE** | `useDatastoreSubscription(table, handlers, options)` (optional: options) | `{ status }` — `"connecting" \| "live" \| "reconnecting" \| "fallback"` | `records(table).subscribe` — `datastore.read:<table>`. Live `onCreated` / `onUpdated` / `onDeleted` off the REQ-RT-07 socket; never throws, resolving to `{ status: "fallback" }` so the widget polls instead. A whole-table subscribe is gated on read-EVERY-row, because one envelope reaches every subscriber of the table — so for a table governed by per-record grants pass `options.scope`: `{ kind: "record", record_id }` for one row, or `{ kind: "parent", relation_column, record_id }` for the rows whose RELATION column points at that parent (the column must carry `inheritAcl`, else the subscribe reports `"fallback"`). Re-subscribes on the scope's VALUES, so a fresh object literal each render is fine. |
|
|
53
53
|
| **DATASTORE** | `useRecordPermissions(tableId, recordId)` | `{ permissions, loading, error, grant, revoke, update, refetch }` | `records(table).permissions(record).{ list, grant, update, revoke }` — `acl.write:records` (+ `can_grant` on the record) |
|
|
@@ -72,7 +72,23 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
72
72
|
|
|
73
73
|
## Status
|
|
74
74
|
|
|
75
|
-
`v0.
|
|
75
|
+
`v0.155.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
76
|
+
|
|
77
|
+
### What's new in 0.155.0 (contract 1.121.0)
|
|
78
|
+
|
|
79
|
+
**`useAgent()` returns `cancel()` — and two error codes that tell the truth about a slow turn (sc-8519).** A turn can legitimately run for minutes; the client used to give up after 10 seconds and report it as `NETWORK`, so a widget showed "you appear to be offline" to a user whose connection was fine, while the server finished the turn and the workspace paid for a reply nobody saw.
|
|
80
|
+
|
|
81
|
+
- **`cancel()`** stops WAITING for the turn in flight. The abort never reaches the server, which finishes and bills the turn either way — so label the control **stop**, not *cancel*, and never imply the work was called off.
|
|
82
|
+
- **`TIMEOUT`** — the client stopped waiting. Still running, still billed: say it is taking longer than usual, never that it failed.
|
|
83
|
+
- **`CANCELLED`** — the user pressed your stop control. Render no error at all.
|
|
84
|
+
|
|
85
|
+
Additive: `send` is unchanged for callers who ignore the new return key, and a widget that never calls `cancel()` behaves exactly as before.
|
|
86
|
+
|
|
87
|
+
### What's new in 0.154.0 (contract 1.120.0)
|
|
88
|
+
|
|
89
|
+
**An agent can now tell you what it DID (sc-8332).** An assistant `AgentMessage` may carry `activity`: one entry per tool the agent ran, naming the table it read, or the table and the columns it changed. Additive — a talk-only turn omits the key, so nothing existing changes shape.
|
|
90
|
+
|
|
91
|
+
Render the writes. An assistant that silently changes a person's data is not trustworthy however correct its permissions are, and a chat bubble saying "done!" is not evidence a row was written. Reads can stay quiet; a change should not. The summary never carries row VALUES and never names a row the permissions refused, so showing it cannot leak what the reader could not already see.
|
|
76
92
|
|
|
77
93
|
### What's new in 0.153.0 (contract 1.118.0 — unchanged)
|
|
78
94
|
|
package/dist/contract.cjs
CHANGED
|
@@ -1286,6 +1286,11 @@ const HOOKS = [
|
|
|
1286
1286
|
"opens the conversation, so a widget nobody types into costs nothing. " +
|
|
1287
1287
|
"`messages` is the running transcript, oldest first, each " +
|
|
1288
1288
|
"{ id, role, content, created_at } with role 'user' | 'assistant'. " +
|
|
1289
|
+
"An assistant message that used a tool also carries `activity`: what " +
|
|
1290
|
+
"the agent DID — the table it read, or the table and columns it " +
|
|
1291
|
+
"CHANGED. Render a write: a reply saying 'done!' is not evidence a " +
|
|
1292
|
+
"row was written, and the user has no other way to notice a mistake. " +
|
|
1293
|
+
"A talk-only turn omits the key entirely. " +
|
|
1289
1294
|
"You CANNOT set the system prompt, replay an edited transcript, " +
|
|
1290
1295
|
"or pick a model. No API returns the prompt — but that is a guarantee " +
|
|
1291
1296
|
"about the WIRE, not secrecy: a model can be talked into repeating its " +
|
|
@@ -1303,7 +1308,12 @@ const HOOKS = [
|
|
|
1303
1308
|
"AI_QUOTA_EXCEEDED (429) is the workspace's credit ceiling and will " +
|
|
1304
1309
|
"NOT clear on a retry — never offer 'try again' for it — where " +
|
|
1305
1310
|
"RATE_LIMITED (429) will; AGENT_DISABLED (409) means the author turned " +
|
|
1306
|
-
"it off, so hide the affordance rather than retrying
|
|
1311
|
+
"it off, so hide the affordance rather than retrying; TIMEOUT means the " +
|
|
1312
|
+
"client stopped waiting and the turn is STILL running and billed, so " +
|
|
1313
|
+
"say it is taking longer, never that it failed or that they are " +
|
|
1314
|
+
"offline; CANCELLED is the user pressing your stop control, so render " +
|
|
1315
|
+
"no error at all. Call cancel() to stop waiting -- it ends the WAIT, " +
|
|
1316
|
+
"not the turn. NEVER surface a " +
|
|
1307
1317
|
"raw error or the workspace's billing state to an app user. " +
|
|
1308
1318
|
"Reads ctx.agents.",
|
|
1309
1319
|
returnShape: {
|
|
@@ -4227,6 +4237,17 @@ const CONTRACT = deepFreeze({
|
|
|
4227
4237
|
// and the inherited colours are hex-guarded on the way out as well as in.
|
|
4228
4238
|
// Every colour still falls back to the sidebar's: an untouched workspace is
|
|
4229
4239
|
// unchanged.
|
|
4240
|
+
// 1.121.0: additive (sc-8519) — `useAgent()` returns `cancel()`, which
|
|
4241
|
+
// stops WAITING for the turn in flight. The abort is client-side: the
|
|
4242
|
+
// server finishes the turn and the workspace is billed, so label the
|
|
4243
|
+
// control 'stop', never 'cancel'. Two new AgentError codes ride with it —
|
|
4244
|
+
// TIMEOUT (the client stopped waiting; still running, still billed) and
|
|
4245
|
+
// CANCELLED (the user pressed stop; render no error at all).
|
|
4246
|
+
// 1.120.0: additive (sc-8332) — an assistant `AgentMessage` may carry
|
|
4247
|
+
// `activity`, a compact record of what the agent DID with the user's data
|
|
4248
|
+
// (the table it read; the table and columns it CHANGED). Absent on a
|
|
4249
|
+
// talk-only turn, so nothing existing changes shape. Render a write: a
|
|
4250
|
+
// reply saying "done!" is not evidence a row was written.
|
|
4230
4251
|
// 1.116.0: additive (sc-7991) — `useAgent(agentRef)` + the `agents` host
|
|
4231
4252
|
// client + the `agentRef` propertySchema type + the `ai.invoke:*` scope. A
|
|
4232
4253
|
// widget can hold a conversation with one of the WORKSPACE's own AI agents.
|
|
@@ -4288,7 +4309,7 @@ const CONTRACT = deepFreeze({
|
|
|
4288
4309
|
// untouched and renders byte-identically, and an unresolvable binding
|
|
4289
4310
|
// fails the existing hex guard, dropping the wash rather than painting it
|
|
4290
4311
|
// blank.
|
|
4291
|
-
version: "1.
|
|
4312
|
+
version: "1.121.0",
|
|
4292
4313
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
4293
4314
|
hooks: HOOKS,
|
|
4294
4315
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -1286,6 +1286,11 @@ const HOOKS = [
|
|
|
1286
1286
|
"opens the conversation, so a widget nobody types into costs nothing. " +
|
|
1287
1287
|
"`messages` is the running transcript, oldest first, each " +
|
|
1288
1288
|
"{ id, role, content, created_at } with role 'user' | 'assistant'. " +
|
|
1289
|
+
"An assistant message that used a tool also carries `activity`: what " +
|
|
1290
|
+
"the agent DID — the table it read, or the table and columns it " +
|
|
1291
|
+
"CHANGED. Render a write: a reply saying 'done!' is not evidence a " +
|
|
1292
|
+
"row was written, and the user has no other way to notice a mistake. " +
|
|
1293
|
+
"A talk-only turn omits the key entirely. " +
|
|
1289
1294
|
"You CANNOT set the system prompt, replay an edited transcript, " +
|
|
1290
1295
|
"or pick a model. No API returns the prompt — but that is a guarantee " +
|
|
1291
1296
|
"about the WIRE, not secrecy: a model can be talked into repeating its " +
|
|
@@ -1303,7 +1308,12 @@ const HOOKS = [
|
|
|
1303
1308
|
"AI_QUOTA_EXCEEDED (429) is the workspace's credit ceiling and will " +
|
|
1304
1309
|
"NOT clear on a retry — never offer 'try again' for it — where " +
|
|
1305
1310
|
"RATE_LIMITED (429) will; AGENT_DISABLED (409) means the author turned " +
|
|
1306
|
-
"it off, so hide the affordance rather than retrying
|
|
1311
|
+
"it off, so hide the affordance rather than retrying; TIMEOUT means the " +
|
|
1312
|
+
"client stopped waiting and the turn is STILL running and billed, so " +
|
|
1313
|
+
"say it is taking longer, never that it failed or that they are " +
|
|
1314
|
+
"offline; CANCELLED is the user pressing your stop control, so render " +
|
|
1315
|
+
"no error at all. Call cancel() to stop waiting -- it ends the WAIT, " +
|
|
1316
|
+
"not the turn. NEVER surface a " +
|
|
1307
1317
|
"raw error or the workspace's billing state to an app user. " +
|
|
1308
1318
|
"Reads ctx.agents.",
|
|
1309
1319
|
returnShape: {
|
|
@@ -4223,6 +4233,17 @@ const CONTRACT = deepFreeze({
|
|
|
4223
4233
|
// and the inherited colours are hex-guarded on the way out as well as in.
|
|
4224
4234
|
// Every colour still falls back to the sidebar's: an untouched workspace is
|
|
4225
4235
|
// unchanged.
|
|
4236
|
+
// 1.121.0: additive (sc-8519) — `useAgent()` returns `cancel()`, which
|
|
4237
|
+
// stops WAITING for the turn in flight. The abort is client-side: the
|
|
4238
|
+
// server finishes the turn and the workspace is billed, so label the
|
|
4239
|
+
// control 'stop', never 'cancel'. Two new AgentError codes ride with it —
|
|
4240
|
+
// TIMEOUT (the client stopped waiting; still running, still billed) and
|
|
4241
|
+
// CANCELLED (the user pressed stop; render no error at all).
|
|
4242
|
+
// 1.120.0: additive (sc-8332) — an assistant `AgentMessage` may carry
|
|
4243
|
+
// `activity`, a compact record of what the agent DID with the user's data
|
|
4244
|
+
// (the table it read; the table and columns it CHANGED). Absent on a
|
|
4245
|
+
// talk-only turn, so nothing existing changes shape. Render a write: a
|
|
4246
|
+
// reply saying "done!" is not evidence a row was written.
|
|
4226
4247
|
// 1.116.0: additive (sc-7991) — `useAgent(agentRef)` + the `agents` host
|
|
4227
4248
|
// client + the `agentRef` propertySchema type + the `ai.invoke:*` scope. A
|
|
4228
4249
|
// widget can hold a conversation with one of the WORKSPACE's own AI agents.
|
|
@@ -4284,7 +4305,7 @@ const CONTRACT = deepFreeze({
|
|
|
4284
4305
|
// untouched and renders byte-identically, and an unresolvable binding
|
|
4285
4306
|
// fails the existing hex guard, dropping the wash rather than painting it
|
|
4286
4307
|
// blank.
|
|
4287
|
-
version: "1.
|
|
4308
|
+
version: "1.121.0",
|
|
4288
4309
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
4289
4310
|
hooks: HOOKS,
|
|
4290
4311
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -2713,7 +2713,15 @@ export function useInterpretDraft(tableId) {
|
|
|
2713
2713
|
* - "AI_UNAVAILABLE" — 503 (no AI provider configured)
|
|
2714
2714
|
* - "AI_GENERATION_FAILED" — 502 (the provider did not answer)
|
|
2715
2715
|
* - "AUTH_REQUIRED" — 401 (no signed-in app user)
|
|
2716
|
-
* - "
|
|
2716
|
+
* - "NETWORK" — the request never reached the server
|
|
2717
|
+
* - "TIMEOUT" — the client stopped waiting. NOT a failed
|
|
2718
|
+
* turn: the server finishes it and the
|
|
2719
|
+
* workspace is billed, so say "still
|
|
2720
|
+
* working", never "failed"
|
|
2721
|
+
* - "CANCELLED" — `cancel()` was called. The user chose it,
|
|
2722
|
+
* so render no error at all (the turn is
|
|
2723
|
+
* still billed — never imply it stopped)
|
|
2724
|
+
* - "INTERNAL" — anything else (a 5xx carrying no code)
|
|
2717
2725
|
*/
|
|
2718
2726
|
export class AgentError extends Error {
|
|
2719
2727
|
constructor(code, message, opts) {
|
|
@@ -2762,7 +2770,9 @@ function toAgentError(err) {
|
|
|
2762
2770
|
* who places the widget and never types costs the workspace nothing.
|
|
2763
2771
|
*
|
|
2764
2772
|
* `messages` is the running transcript this widget has seen, oldest first,
|
|
2765
|
-
* each `{ id, role, content, created_at }` with `role` of "user" | "assistant".
|
|
2773
|
+
* each `{ id, role, content, created_at }` with `role` of "user" | "assistant".
|
|
2774
|
+
* An assistant message that used a tool also carries `activity` — what the
|
|
2775
|
+
* agent DID with the user's data. Render the writes: "done!" is not evidence.
|
|
2766
2776
|
* The SERVER owns the real transcript and the system prompt: the widget sends
|
|
2767
2777
|
* one message and can neither read nor set the prompt.
|
|
2768
2778
|
*
|
|
@@ -2814,12 +2824,21 @@ export function useAgent(agentRef) {
|
|
|
2814
2824
|
pendingResetRef.current = true;
|
|
2815
2825
|
}
|
|
2816
2826
|
|
|
2827
|
+
const abortRef = useRef(null);
|
|
2828
|
+
|
|
2817
2829
|
const reset = useCallback(() => {
|
|
2818
2830
|
conversationRef.current = null;
|
|
2819
2831
|
setMessages([]);
|
|
2820
2832
|
setError(null);
|
|
2821
2833
|
}, []);
|
|
2822
2834
|
|
|
2835
|
+
// Ends the WAIT, not the turn: the abort never reaches the server, which
|
|
2836
|
+
// finishes and bills it either way. Never imply the work was stopped.
|
|
2837
|
+
const cancel = useCallback(() => {
|
|
2838
|
+
const controller = abortRef.current;
|
|
2839
|
+
if (controller) controller.abort();
|
|
2840
|
+
}, []);
|
|
2841
|
+
|
|
2823
2842
|
const send = useCallback(async (text) => {
|
|
2824
2843
|
const client = clientRef.current;
|
|
2825
2844
|
const agentId = agentIdRef.current;
|
|
@@ -2853,7 +2872,13 @@ export function useAgent(agentRef) {
|
|
|
2853
2872
|
conversationRef.current = null;
|
|
2854
2873
|
throw err;
|
|
2855
2874
|
}
|
|
2856
|
-
const
|
|
2875
|
+
const controller =
|
|
2876
|
+
typeof AbortController === "function" ? new AbortController() : null;
|
|
2877
|
+
abortRef.current = controller;
|
|
2878
|
+
const turn = await thread
|
|
2879
|
+
.messages(conversationId)
|
|
2880
|
+
.send({ content }, controller ? { signal: controller.signal } : undefined);
|
|
2881
|
+
abortRef.current = null;
|
|
2857
2882
|
// A rebind during the round trip makes this the PREVIOUS agent's reply;
|
|
2858
2883
|
// writing it now would render it under the new one.
|
|
2859
2884
|
if (agentIdRef.current !== agentId) {
|
|
@@ -2872,8 +2897,10 @@ export function useAgent(agentRef) {
|
|
|
2872
2897
|
// A stale thread is recoverable on the next send rather than permanently
|
|
2873
2898
|
// broken: drop it so the widget opens a fresh one.
|
|
2874
2899
|
if (e.code === "CONVERSATION_NOT_FOUND") conversationRef.current = null;
|
|
2900
|
+
abortRef.current = null;
|
|
2875
2901
|
// Same rebind guard: a new agent must not inherit the old one's error.
|
|
2876
|
-
|
|
2902
|
+
// A cancel is the user's own choice, so it is not a failure to report.
|
|
2903
|
+
if (e.code !== "CANCELLED" && agentIdRef.current === agentId) setError(e);
|
|
2877
2904
|
setSending(false);
|
|
2878
2905
|
throw e;
|
|
2879
2906
|
}
|
|
@@ -2895,6 +2922,7 @@ export function useAgent(agentRef) {
|
|
|
2895
2922
|
|
|
2896
2923
|
return {
|
|
2897
2924
|
send,
|
|
2925
|
+
cancel,
|
|
2898
2926
|
reset,
|
|
2899
2927
|
messages: visibleMessages,
|
|
2900
2928
|
sending,
|
package/dist/index.d.ts
CHANGED
|
@@ -1212,12 +1212,39 @@ export interface AgentMessage {
|
|
|
1212
1212
|
/** The system prompt is NOT part of the transcript — it lives on the agent. */
|
|
1213
1213
|
role: "user" | "assistant";
|
|
1214
1214
|
content: string;
|
|
1215
|
+
/**
|
|
1216
|
+
* sc-8332 — what the agent DID on this turn, for the person to see. Present
|
|
1217
|
+
* only on an assistant message that used a tool; a talk-only turn omits the
|
|
1218
|
+
* key rather than carrying an empty marker you would have to special-case.
|
|
1219
|
+
*
|
|
1220
|
+
* Show a WRITE. A reply saying "done!" is not evidence a row was changed,
|
|
1221
|
+
* and if the agent got it wrong the user has no other way to notice.
|
|
1222
|
+
*/
|
|
1223
|
+
activity?: AgentActivity[];
|
|
1215
1224
|
created_at: string;
|
|
1216
1225
|
}
|
|
1217
1226
|
|
|
1227
|
+
/**
|
|
1228
|
+
* One tool the agent ran. Names the table it touched and, for a write, the
|
|
1229
|
+
* columns it set — never the values, and never a row the permissions refused.
|
|
1230
|
+
*/
|
|
1231
|
+
export interface AgentActivity {
|
|
1232
|
+
tool: string;
|
|
1233
|
+
ok: boolean;
|
|
1234
|
+
table?: string;
|
|
1235
|
+
record_id?: string;
|
|
1236
|
+
fields?: string[];
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1218
1239
|
export interface AgentApi {
|
|
1219
1240
|
/** Imperative — call from an event handler. The first send opens the thread. */
|
|
1220
1241
|
send(text: string): Promise<AgentMessage | null>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Stop WAITING for the turn in flight. The abort never reaches the server,
|
|
1244
|
+
* which finishes and bills it either way — label the control "stop", not
|
|
1245
|
+
* "cancel", and show no error when the user presses it.
|
|
1246
|
+
*/
|
|
1247
|
+
cancel(): void;
|
|
1221
1248
|
/** Drop the open thread and clear the transcript this widget has seen. */
|
|
1222
1249
|
reset(): void;
|
|
1223
1250
|
/** Oldest first. The SERVER owns the real transcript. */
|
|
@@ -1976,6 +2003,9 @@ export class AgentError extends Error {
|
|
|
1976
2003
|
| "AI_UNAVAILABLE"
|
|
1977
2004
|
| "AI_GENERATION_FAILED"
|
|
1978
2005
|
| "AUTH_REQUIRED"
|
|
2006
|
+
| "NETWORK"
|
|
2007
|
+
| "TIMEOUT"
|
|
2008
|
+
| "CANCELLED"
|
|
1979
2009
|
| "INTERNAL"
|
|
1980
2010
|
| (string & {});
|
|
1981
2011
|
constructor(code: string, message: string, opts?: { cause?: unknown });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.155.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"homepage": "https://github.com/Colix-AB/AppStudio",
|
|
6
6
|
"type": "module",
|