@feltdb/feltkit 0.3.36 → 0.4.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/dist/app.d.ts +153 -3
- package/dist/app.js +159 -7
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +21 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +4 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/client/index.d.ts +189 -0
- package/dist/client/index.js +201 -0
- package/dist/client/index.js.map +1 -1
- package/dist/clock.d.ts +24 -0
- package/dist/clock.js +49 -0
- package/dist/clock.js.map +1 -0
- package/dist/dashboard/assets/index-BhxrvY37.js +15 -0
- package/dist/dashboard/assets/index-CSzYeCo_.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/event-stage.js +2 -0
- package/dist/event-stage.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +9 -1
- package/dist/policy.js +16 -3
- package/dist/policy.js.map +1 -1
- package/dist/presence.d.ts +85 -0
- package/dist/presence.js +37 -0
- package/dist/presence.js.map +1 -0
- package/dist/quota.d.ts +72 -0
- package/dist/quota.js +143 -0
- package/dist/quota.js.map +1 -0
- package/dist/react/agent-control.d.ts +189 -0
- package/dist/react/agent-control.js +366 -0
- package/dist/react/agent-control.js.map +1 -0
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +41 -0
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/activity.d.ts +8 -0
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent-control.d.ts +18 -0
- package/dist/runtime/agent-control.js +34 -1
- package/dist/runtime/agent-control.js.map +1 -1
- package/dist/runtime/agent.js +16 -4
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/assemble.js +1 -1
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority.d.ts +38 -0
- package/dist/runtime/authority.js +13 -2
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/capabilities.js +2 -1
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/changes.d.ts +17 -0
- package/dist/runtime/changes.js +65 -2
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/context.d.ts +114 -0
- package/dist/runtime/contract.js +9 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/events.js +17 -1
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/integrations.js +7 -7
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +19 -2
- package/dist/runtime/invocations.js +16 -3
- package/dist/runtime/invocations.js.map +1 -1
- package/dist/runtime/policies.d.ts +5 -2
- package/dist/runtime/policies.js.map +1 -1
- package/dist/runtime/presence-host.d.ts +84 -0
- package/dist/runtime/presence-host.js +303 -0
- package/dist/runtime/presence-host.js.map +1 -0
- package/dist/runtime/providers.d.ts +130 -1
- package/dist/runtime/providers.js +251 -9
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/resource-access.d.ts +137 -0
- package/dist/runtime/resource-access.js +177 -0
- package/dist/runtime/resource-access.js.map +1 -0
- package/dist/runtime/runtime.d.ts +73 -0
- package/dist/runtime/runtime.js +594 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sessions.d.ts +11 -0
- package/dist/runtime/sessions.js +15 -0
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +59 -0
- package/dist/runtime/tenancy.js +128 -0
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/workers.d.ts +123 -0
- package/dist/runtime/workers.js +291 -0
- package/dist/runtime/workers.js.map +1 -0
- package/dist/server/admin.js +48 -1
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +0 -19
- package/dist/server/index.js +61 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.d.ts +8 -15
- package/dist/server/mcp.js +40 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.js +6 -5
- package/dist/server/project.js.map +1 -1
- package/dist/server/tenancy.d.ts +7 -0
- package/dist/server/tenancy.js +31 -0
- package/dist/server/tenancy.js.map +1 -1
- package/dist/server/watch.d.ts +10 -0
- package/dist/server/watch.js +88 -0
- package/dist/server/watch.js.map +1 -0
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-CONTROL.md +130 -4
- package/docs/APPBOUNDRY.md +37 -0
- package/docs/ARCHITECTURE.md +6 -2
- package/docs/AUTH.md +35 -0
- package/docs/COMPONENTS.md +71 -0
- package/docs/GUARANTEES.md +4 -4
- package/docs/PRESENCE-AND-SIGNALING-PROPOSAL.md +152 -0
- package/docs/PROVIDERS.md +58 -1
- package/docs/README.md +3 -2
- package/docs/SECURITY.md +71 -3
- package/docs/TRANSACTIONS.md +48 -0
- package/docs/UPSTREAM-GAPS.md +16 -2
- package/package.json +16 -16
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +11 -1
- package/skills/feltkit-data/SKILL.md +1 -1
- package/skills/feltkit-operations/SKILL.md +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
- package/dist/dashboard/assets/index-9rMS3yBm.js +0 -15
- package/dist/dashboard/assets/index-DkiYTUMR.css +0 -1
package/dist/quota.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quotas: how often a caller may run a function (K3). Declared on the function (`quota`) or for the
|
|
3
|
+
* whole application (`feltkit({ quotas })`), enforced by the runtime at the execution boundary every
|
|
4
|
+
* interface goes through (HTTP, AppPort, MCP, agents, jobs), after the role check and argument
|
|
5
|
+
* validation and before the policies, the `authorize` hook and the handler. A refusal is
|
|
6
|
+
* `RATE_LIMITED` with `details.retryAfterMs` (HTTP 429 with `Retry-After`).
|
|
7
|
+
*
|
|
8
|
+
* Counting: a sliding window per key (the timestamps of the calls admitted in the last `windowMs`),
|
|
9
|
+
* so a key is never admitted more than `limit` times in any span of `windowMs`. Checking and counting
|
|
10
|
+
* are one synchronous step, so concurrent calls never exceed the limit. A call is counted when it is
|
|
11
|
+
* admitted, whatever it then does (a refused or failing call still spent its attempt).
|
|
12
|
+
*
|
|
13
|
+
* Counters are kept in the process, outside the application's transaction and outside FeltDB: a
|
|
14
|
+
* refused call writes nothing, and counting costs no commit. They start empty when the process starts
|
|
15
|
+
* and are per process (several processes behind a balancer each count). Moving them onto FeltDB's
|
|
16
|
+
* expiring records (record TTL) would make them survive restarts and span processes; see
|
|
17
|
+
* docs/SECURITY.md ("Quotas").
|
|
18
|
+
*
|
|
19
|
+
* Runtime-neutral (no Node APIs).
|
|
20
|
+
*/
|
|
21
|
+
import { FeltKitError } from "./errors.js";
|
|
22
|
+
import type { Clock } from "./clock.js";
|
|
23
|
+
/**
|
|
24
|
+
* One limit: at most `limit` calls in any `windowMs`, counted per:
|
|
25
|
+
* "principal" each caller (anonymous callers share one count per client address when known)
|
|
26
|
+
* "function" everyone together (a function-wide ceiling)
|
|
27
|
+
* "arg:<name>" each value of that validated argument (e.g. "arg:code": per meeting code)
|
|
28
|
+
* "principal+arg:<name>" each caller, per value of the argument
|
|
29
|
+
*/
|
|
30
|
+
export interface QuotaSpec {
|
|
31
|
+
per: "principal" | "function" | `arg:${string}` | `principal+arg:${string}`;
|
|
32
|
+
limit: number;
|
|
33
|
+
windowMs: number;
|
|
34
|
+
}
|
|
35
|
+
export type QuotaDeclaration = QuotaSpec | readonly QuotaSpec[];
|
|
36
|
+
export declare const MAX_QUOTA_WINDOW_MS: number;
|
|
37
|
+
export declare const MAX_QUOTA_LIMIT = 100000;
|
|
38
|
+
/** Validate a declaration (definition time). Throws TypeError naming the problem. */
|
|
39
|
+
export declare function checkQuota(input: unknown, where: string, args?: Record<string, unknown>): readonly QuotaSpec[];
|
|
40
|
+
export interface QuotaCaller {
|
|
41
|
+
principalId: string | null;
|
|
42
|
+
/** A client address for anonymous callers, when the surface knows it. */
|
|
43
|
+
client?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface QuotaRefusal {
|
|
46
|
+
scope: string;
|
|
47
|
+
per: QuotaSpec["per"];
|
|
48
|
+
limit: number;
|
|
49
|
+
windowMs: number;
|
|
50
|
+
retryAfterMs: number;
|
|
51
|
+
}
|
|
52
|
+
/** Sliding-window counters, keyed by scope and caller. */
|
|
53
|
+
export declare class QuotaLimiter {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(clock: Clock);
|
|
56
|
+
/** How many keys hold counts (tests, diagnostics). */
|
|
57
|
+
get size(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Admit one call under every spec, or refuse it without counting it anywhere. Refusal names the
|
|
60
|
+
* spec that refused with the longest wait.
|
|
61
|
+
*/
|
|
62
|
+
admit(scope: string, specs: readonly QuotaSpec[], caller: QuotaCaller, args?: Record<string, unknown>): {
|
|
63
|
+
ok: true;
|
|
64
|
+
} | {
|
|
65
|
+
ok: false;
|
|
66
|
+
refusal: QuotaRefusal;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** The refusal a caller sees. */
|
|
70
|
+
export declare function rateLimited(refusal: QuotaRefusal, what: string): FeltKitError;
|
|
71
|
+
/** Seconds for an HTTP Retry-After header from a RATE_LIMITED error's details, or null. */
|
|
72
|
+
export declare function retryAfterSeconds(details: unknown): number | null;
|
package/dist/quota.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quotas: how often a caller may run a function (K3). Declared on the function (`quota`) or for the
|
|
3
|
+
* whole application (`feltkit({ quotas })`), enforced by the runtime at the execution boundary every
|
|
4
|
+
* interface goes through (HTTP, AppPort, MCP, agents, jobs), after the role check and argument
|
|
5
|
+
* validation and before the policies, the `authorize` hook and the handler. A refusal is
|
|
6
|
+
* `RATE_LIMITED` with `details.retryAfterMs` (HTTP 429 with `Retry-After`).
|
|
7
|
+
*
|
|
8
|
+
* Counting: a sliding window per key (the timestamps of the calls admitted in the last `windowMs`),
|
|
9
|
+
* so a key is never admitted more than `limit` times in any span of `windowMs`. Checking and counting
|
|
10
|
+
* are one synchronous step, so concurrent calls never exceed the limit. A call is counted when it is
|
|
11
|
+
* admitted, whatever it then does (a refused or failing call still spent its attempt).
|
|
12
|
+
*
|
|
13
|
+
* Counters are kept in the process, outside the application's transaction and outside FeltDB: a
|
|
14
|
+
* refused call writes nothing, and counting costs no commit. They start empty when the process starts
|
|
15
|
+
* and are per process (several processes behind a balancer each count). Moving them onto FeltDB's
|
|
16
|
+
* expiring records (record TTL) would make them survive restarts and span processes; see
|
|
17
|
+
* docs/SECURITY.md ("Quotas").
|
|
18
|
+
*
|
|
19
|
+
* Runtime-neutral (no Node APIs).
|
|
20
|
+
*/
|
|
21
|
+
import { FeltKitError } from "./errors.js";
|
|
22
|
+
const PER = /^(principal|function|arg:[A-Za-z_$][\w$]*|principal\+arg:[A-Za-z_$][\w$]*)$/;
|
|
23
|
+
export const MAX_QUOTA_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
24
|
+
export const MAX_QUOTA_LIMIT = 100_000;
|
|
25
|
+
/** Validate a declaration (definition time). Throws TypeError naming the problem. */
|
|
26
|
+
export function checkQuota(input, where, args) {
|
|
27
|
+
const list = Array.isArray(input) ? input : [input];
|
|
28
|
+
if (!list.length)
|
|
29
|
+
throw new TypeError(`${where}: quota needs at least one limit.`);
|
|
30
|
+
return Object.freeze(list.map((spec, i) => {
|
|
31
|
+
const at = list.length > 1 ? `${where}: quota[${i}]` : `${where}: quota`;
|
|
32
|
+
if (!spec || typeof spec !== "object")
|
|
33
|
+
throw new TypeError(`${at} is { per, limit, windowMs }.`);
|
|
34
|
+
const { per, limit, windowMs, ...rest } = spec;
|
|
35
|
+
if (Object.keys(rest).length)
|
|
36
|
+
throw new TypeError(`${at}: unknown member ${Object.keys(rest).map((k) => `"${k}"`).join(", ")} (a quota is { per, limit, windowMs }).`);
|
|
37
|
+
if (typeof per !== "string" || !PER.test(per))
|
|
38
|
+
throw new TypeError(`${at}.per is "principal", "function", "arg:<argument>" or "principal+arg:<argument>" (got ${JSON.stringify(per)}).`);
|
|
39
|
+
const arg = per.includes("arg:") ? per.slice(per.indexOf("arg:") + 4) : undefined;
|
|
40
|
+
if (arg !== undefined && args && !Object.prototype.hasOwnProperty.call(args, arg))
|
|
41
|
+
throw new TypeError(`${at}.per names argument "${arg}", which the function does not declare.`);
|
|
42
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_QUOTA_LIMIT)
|
|
43
|
+
throw new TypeError(`${at}.limit is an integer from 1 to ${MAX_QUOTA_LIMIT}.`);
|
|
44
|
+
if (!Number.isInteger(windowMs) || windowMs < 1 || windowMs > MAX_QUOTA_WINDOW_MS)
|
|
45
|
+
throw new TypeError(`${at}.windowMs is an integer from 1 to ${MAX_QUOTA_WINDOW_MS} (one day).`);
|
|
46
|
+
return Object.freeze({ per, limit, windowMs });
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
/** Sliding-window counters, keyed by scope and caller. */
|
|
50
|
+
export class QuotaLimiter {
|
|
51
|
+
#clock;
|
|
52
|
+
#windows = new Map();
|
|
53
|
+
#sweptAt = 0;
|
|
54
|
+
constructor(clock) {
|
|
55
|
+
this.#clock = clock;
|
|
56
|
+
}
|
|
57
|
+
/** How many keys hold counts (tests, diagnostics). */
|
|
58
|
+
get size() {
|
|
59
|
+
return this.#windows.size;
|
|
60
|
+
}
|
|
61
|
+
#key(scope, spec, caller, args) {
|
|
62
|
+
const who = caller.principalId ?? `anonymous:${caller.client ?? "?"}`;
|
|
63
|
+
const arg = spec.per.includes("arg:") ? spec.per.slice(spec.per.indexOf("arg:") + 4) : undefined;
|
|
64
|
+
const value = arg === undefined ? "" : JSON.stringify(args[arg] ?? null);
|
|
65
|
+
const subject = spec.per === "function" ? "*" : spec.per === "principal" ? who : spec.per.startsWith("principal+") ? `${who}\u0000${value}` : value;
|
|
66
|
+
return `${scope}\u0000${spec.per}\u0000${spec.limit}/${spec.windowMs}\u0000${subject}`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Admit one call under every spec, or refuse it without counting it anywhere. Refusal names the
|
|
70
|
+
* spec that refused with the longest wait.
|
|
71
|
+
*/
|
|
72
|
+
admit(scope, specs, caller, args = {}) {
|
|
73
|
+
const now = this.#clock.now();
|
|
74
|
+
this.#sweep(now);
|
|
75
|
+
const keyed = specs.map((spec) => ({ spec, key: this.#key(scope, spec, caller, args) }));
|
|
76
|
+
let refusal = null;
|
|
77
|
+
for (const { spec, key } of keyed) {
|
|
78
|
+
const window = this.#prune(key, now, spec.windowMs);
|
|
79
|
+
if (window.length >= spec.limit) {
|
|
80
|
+
const retryAfterMs = Math.max(1, window[window.length - spec.limit] + spec.windowMs - now);
|
|
81
|
+
if (!refusal || retryAfterMs > refusal.retryAfterMs)
|
|
82
|
+
refusal = { scope, per: spec.per, limit: spec.limit, windowMs: spec.windowMs, retryAfterMs };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (refusal)
|
|
86
|
+
return { ok: false, refusal };
|
|
87
|
+
for (const { key } of keyed) {
|
|
88
|
+
const window = this.#windows.get(key) ?? [];
|
|
89
|
+
window.push(now);
|
|
90
|
+
this.#windows.set(key, window);
|
|
91
|
+
}
|
|
92
|
+
return { ok: true };
|
|
93
|
+
}
|
|
94
|
+
#prune(key, now, windowMs) {
|
|
95
|
+
const window = this.#windows.get(key);
|
|
96
|
+
if (!window)
|
|
97
|
+
return [];
|
|
98
|
+
let drop = 0;
|
|
99
|
+
while (drop < window.length && window[drop] <= now - windowMs)
|
|
100
|
+
drop += 1;
|
|
101
|
+
if (drop)
|
|
102
|
+
window.splice(0, drop);
|
|
103
|
+
if (!window.length)
|
|
104
|
+
this.#windows.delete(key);
|
|
105
|
+
return window;
|
|
106
|
+
}
|
|
107
|
+
/** Forget windows with nothing in them any more (at most once a minute; bounded memory). */
|
|
108
|
+
#sweep(now) {
|
|
109
|
+
if (now - this.#sweptAt < 60_000)
|
|
110
|
+
return;
|
|
111
|
+
this.#sweptAt = now;
|
|
112
|
+
for (const [key, window] of this.#windows) {
|
|
113
|
+
const windowMs = Number(key.split("\u0000")[2].split("/")[1]);
|
|
114
|
+
while (window.length && window[0] <= now - windowMs)
|
|
115
|
+
window.shift();
|
|
116
|
+
if (!window.length)
|
|
117
|
+
this.#windows.delete(key);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** The refusal a caller sees. */
|
|
122
|
+
export function rateLimited(refusal, what) {
|
|
123
|
+
const seconds = Math.ceil(refusal.retryAfterMs / 1000);
|
|
124
|
+
return new FeltKitError("RATE_LIMITED", `Too many calls to ${what}: at most ${refusal.limit} per ${describeWindow(refusal.windowMs)} (${refusal.per}). Try again in ${seconds} s.`, {
|
|
125
|
+
details: { retryAfterMs: refusal.retryAfterMs, quota: { scope: refusal.scope, per: refusal.per, limit: refusal.limit, windowMs: refusal.windowMs } },
|
|
126
|
+
hint: "QUOTA",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function describeWindow(ms) {
|
|
130
|
+
if (ms % 3_600_000 === 0)
|
|
131
|
+
return ms === 3_600_000 ? "hour" : `${ms / 3_600_000} hours`;
|
|
132
|
+
if (ms % 60_000 === 0)
|
|
133
|
+
return ms === 60_000 ? "minute" : `${ms / 60_000} minutes`;
|
|
134
|
+
if (ms % 1000 === 0)
|
|
135
|
+
return ms === 1000 ? "second" : `${ms / 1000} s`;
|
|
136
|
+
return `${ms} ms`;
|
|
137
|
+
}
|
|
138
|
+
/** Seconds for an HTTP Retry-After header from a RATE_LIMITED error's details, or null. */
|
|
139
|
+
export function retryAfterSeconds(details) {
|
|
140
|
+
const ms = details?.retryAfterMs;
|
|
141
|
+
return typeof ms === "number" && Number.isFinite(ms) && ms >= 0 ? Math.max(1, Math.ceil(ms / 1000)) : null;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../src/quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkB3C,MAAM,GAAG,GAAG,6EAA6E,CAAC;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEvC,qFAAqF;AACrF,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,KAAa,EAAE,IAA8B;IACtF,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,mCAAmC,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,MAAM,CAClB,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACnB,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC;QACzE,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,MAAM,IAAI,SAAS,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAC;QACjG,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,IAA+B,CAAC;QAC1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AAG,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,UAAU,CAAC;IAClF,IAAI,EAAE,GAAG,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC;IACtE,OAAO,GAAG,EAAE,KAAK,CAAC;AACpB,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,MAAM,EAAE,GAAI,OAAyD,EAAE,YAAY,CAAC;IACpF,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7G,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Steering a running agent from React (docs/AGENT-CONTROL.md, "React").
|
|
3
|
+
*
|
|
4
|
+
* const control = useAgentControl(taskId); // live state, ops, per-op pending and errors
|
|
5
|
+
* <AgentControlBar taskId={taskId} /> // Update coming · Pause/Resume · Interrupt · Stop
|
|
6
|
+
* <AgentUpdateComposer taskId={taskId} /> // "Tell the agent what changed", with the bar and send
|
|
7
|
+
*
|
|
8
|
+
* Every button reflects the state the server reported (its `control` frames), never a guess; the only
|
|
9
|
+
* local state is which operation is in flight. Unstyled-but-usable: plain buttons with aria-labels, a
|
|
10
|
+
* small stylesheet (`fk-agent-*` classes, themed with the same --fk-* variables as the auth screens),
|
|
11
|
+
* `className` on every component, and `unstyled` to drop the stylesheet.
|
|
12
|
+
*/
|
|
13
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
14
|
+
import { type AgentControlPhase, type AgentControlState, type AgentUpdate, type AgentUpdateState, type OwnAction } from "../client/index.js";
|
|
15
|
+
export type { AgentControlPhase, AgentControlState, AgentUpdate, AgentUpdateState } from "../client/index.js";
|
|
16
|
+
/** Why the server refused a steering operation, typed for the UI. */
|
|
17
|
+
export type AgentControlRefusal =
|
|
18
|
+
/** CONFLICT with details.reason (AGENT_PAUSED, CONCURRENT_CHANGE, INSTRUCTIONS_OPEN, …). */
|
|
19
|
+
"conflict"
|
|
20
|
+
/** The same idempotency key was sent with different text. */
|
|
21
|
+
| "idempotency-key-reused"
|
|
22
|
+
/** Not allowed: not a person with feltkit.agent.write in the task's workspace, or not the update's sender. */
|
|
23
|
+
| "forbidden"
|
|
24
|
+
/** Signed out, or the session ended. */
|
|
25
|
+
| "unauthorized"
|
|
26
|
+
/** No such task (or not visible to this caller). */
|
|
27
|
+
| "not-found" | "other";
|
|
28
|
+
export declare class AgentControlError extends Error {
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly kind: AgentControlRefusal;
|
|
31
|
+
/** CONFLICT's `details.reason`, when the server gave one. */
|
|
32
|
+
readonly reason: string | null;
|
|
33
|
+
readonly cause: unknown;
|
|
34
|
+
constructor(error: unknown);
|
|
35
|
+
}
|
|
36
|
+
export interface AgentControlButtons {
|
|
37
|
+
/** "Update coming" (signal) and submitting an update. */
|
|
38
|
+
update: {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
why?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Pause while running or blocked; Resume while pausing, paused or interrupted. */
|
|
43
|
+
toggle: {
|
|
44
|
+
action: "pause" | "resume";
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
why?: string;
|
|
47
|
+
};
|
|
48
|
+
interrupt: {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
why?: string;
|
|
51
|
+
};
|
|
52
|
+
stop: {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
why?: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The enabled-state matrix, from the server's derived phase (never a local guess):
|
|
59
|
+
*
|
|
60
|
+
* phase update toggle interrupt stop
|
|
61
|
+
* running yes Pause yes yes
|
|
62
|
+
* blocked yes Pause only while a model generation runs yes
|
|
63
|
+
* pausing yes Resume yes (cancels the generation still running) yes
|
|
64
|
+
* paused yes Resume no: nothing is running to cancel yes
|
|
65
|
+
* interrupted yes Resume no: already interrupted yes
|
|
66
|
+
* completed no (Pause) no no no
|
|
67
|
+
* stopped no (Pause) no no no
|
|
68
|
+
*
|
|
69
|
+
* Blocked (waiting for a person's approval of a proposed action, mode still running): the agent can still
|
|
70
|
+
* be told about an update, paused (an approval is refused while paused) or stopped. Interrupt only cancels
|
|
71
|
+
* model generations, so it is offered only when one is in flight. Unknown state (loading): all disabled.
|
|
72
|
+
*/
|
|
73
|
+
export declare function agentControlButtons(state: Pick<AgentControlState, "phase" | "inFlight"> | null | undefined): AgentControlButtons;
|
|
74
|
+
/** Updates a person may still take back (the server decides; this only offers the button). */
|
|
75
|
+
export declare const WITHDRAWABLE: readonly AgentUpdateState[];
|
|
76
|
+
export type AgentControlOp = "signal" | "submit" | "withdraw" | "pause" | "resume" | "interrupt" | "stop";
|
|
77
|
+
export interface UseAgentControl {
|
|
78
|
+
/** The state the server last reported (undefined until the first frame). */
|
|
79
|
+
state: AgentControlState | undefined;
|
|
80
|
+
phase: AgentControlPhase | undefined;
|
|
81
|
+
/** Every update, oldest first. */
|
|
82
|
+
updates: AgentUpdate[];
|
|
83
|
+
buttons: AgentControlButtons;
|
|
84
|
+
/** Which operations are in flight. */
|
|
85
|
+
pending: Partial<Record<AgentControlOp, boolean>>;
|
|
86
|
+
/** The last refusal per operation (cleared when it next succeeds). */
|
|
87
|
+
errors: Partial<Record<AgentControlOp, AgentControlError>>;
|
|
88
|
+
/** The stream's own error (no access, signed out), if it stopped. */
|
|
89
|
+
error: AgentControlError | undefined;
|
|
90
|
+
signal(options?: {
|
|
91
|
+
note?: string;
|
|
92
|
+
}): Promise<AgentUpdate>;
|
|
93
|
+
submit(text: string, options?: {
|
|
94
|
+
instructionId?: string;
|
|
95
|
+
idempotencyKey?: string;
|
|
96
|
+
}): Promise<AgentUpdate>;
|
|
97
|
+
withdraw(instructionId: string, reason?: string): Promise<AgentUpdate>;
|
|
98
|
+
pause(reason?: string): Promise<AgentControlState>;
|
|
99
|
+
resume(reason?: string): Promise<AgentControlState>;
|
|
100
|
+
interrupt(reason?: string): Promise<AgentControlState>;
|
|
101
|
+
stop(reason?: string): Promise<AgentControlState>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The idempotency key for a submit: one per draft text, kept until it is sent, so a double click or a retry of the
|
|
105
|
+
* same text is one update on the server. Exported for tests; the hook uses one per mounted control.
|
|
106
|
+
*/
|
|
107
|
+
export declare function submitKeys(): {
|
|
108
|
+
keyFor(text: string): string;
|
|
109
|
+
sent(text: string): void;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* A task's control state, live (the server's SSE stream), with every steering operation. Pass "skip" to do nothing.
|
|
113
|
+
* Operations answer what the server answered and throw AgentControlError when it refuses; the state shown is always
|
|
114
|
+
* a frame the server sent.
|
|
115
|
+
*/
|
|
116
|
+
export declare function useAgentControl(taskId: string | "skip"): UseAgentControl;
|
|
117
|
+
/** Turn the agent control stylesheet off (render it once near the root): every class stays, unstyled. */
|
|
118
|
+
export declare function FeltKitAgentControlStyles({ disabled }: {
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
}): null;
|
|
121
|
+
export interface AgentControlBarProps {
|
|
122
|
+
taskId: string;
|
|
123
|
+
/** Show text beside each icon ("Update coming", "Pause", "Interrupt", "Stop"). Default: icons, with aria-label and title. */
|
|
124
|
+
labels?: boolean;
|
|
125
|
+
/** Ask before stopping (default true). */
|
|
126
|
+
confirmStop?: boolean | string;
|
|
127
|
+
/** Hide the "Update coming" button (the composer has its own). */
|
|
128
|
+
hideUpdate?: boolean;
|
|
129
|
+
className?: string;
|
|
130
|
+
style?: CSSProperties;
|
|
131
|
+
unstyled?: boolean;
|
|
132
|
+
/** Use a control from useAgentControl instead of opening another stream. */
|
|
133
|
+
control?: UseAgentControl;
|
|
134
|
+
}
|
|
135
|
+
export declare const AGENT_CONTROL_LABELS: {
|
|
136
|
+
readonly update: "Update coming";
|
|
137
|
+
readonly pause: "Pause";
|
|
138
|
+
readonly resume: "Resume";
|
|
139
|
+
readonly interrupt: "Interrupt";
|
|
140
|
+
readonly stop: "Stop";
|
|
141
|
+
};
|
|
142
|
+
export declare function AgentControlBar(props: AgentControlBarProps): import("react").JSX.Element;
|
|
143
|
+
export interface AgentUpdateComposerProps {
|
|
144
|
+
taskId: string;
|
|
145
|
+
/** Signal "update coming" once when the person focuses or types in the box (default true). */
|
|
146
|
+
signalOnType?: boolean;
|
|
147
|
+
/** Show text on the control buttons. */
|
|
148
|
+
labels?: boolean;
|
|
149
|
+
confirmStop?: boolean | string;
|
|
150
|
+
/** Show the list of updates with their lifecycle (default true). */
|
|
151
|
+
showUpdates?: boolean;
|
|
152
|
+
placeholder?: string;
|
|
153
|
+
className?: string;
|
|
154
|
+
unstyled?: boolean;
|
|
155
|
+
control?: UseAgentControl;
|
|
156
|
+
}
|
|
157
|
+
/** The helper text under the box, from the reported phase and whether this person signaled. */
|
|
158
|
+
export declare function composerHelp(phase: AgentControlPhase | undefined, signaled: boolean): string;
|
|
159
|
+
export declare function AgentUpdateComposer(props: AgentUpdateComposerProps): import("react").JSX.Element;
|
|
160
|
+
/** What a person may do with one of their agent actions, from the state the server reported (and its deadline). */
|
|
161
|
+
export declare function approvalOptions(action: Pick<OwnAction, "state" | "expiresAt">, now?: number): {
|
|
162
|
+
approve: {
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
why?: string;
|
|
165
|
+
};
|
|
166
|
+
reject: {
|
|
167
|
+
enabled: boolean;
|
|
168
|
+
why?: string;
|
|
169
|
+
};
|
|
170
|
+
expired: boolean;
|
|
171
|
+
};
|
|
172
|
+
export interface ActionApprovalProps {
|
|
173
|
+
action: OwnAction;
|
|
174
|
+
/** useOwnActions' approve and reject (default: the same client calls): approve binds to the input shown (its inputDigest). */
|
|
175
|
+
approve?: (action: Pick<OwnAction, "taskId" | "actionId" | "inputDigest">) => Promise<OwnAction | null>;
|
|
176
|
+
reject?: (action: Pick<OwnAction, "taskId" | "actionId">, reason?: string) => Promise<OwnAction | null>;
|
|
177
|
+
/** The time to judge the deadline by (tests; default now). */
|
|
178
|
+
now?: number;
|
|
179
|
+
className?: string;
|
|
180
|
+
unstyled?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** One proposed action: its operation and exact input, Approve (bound to that input) and Reject with a reason. */
|
|
183
|
+
export declare function ActionApproval(props: ActionApprovalProps): import("react").JSX.Element;
|
|
184
|
+
/** Your agents' proposals waiting for you, live (useOwnActions), each with <ActionApproval>. */
|
|
185
|
+
export declare function PendingApprovals(props: {
|
|
186
|
+
className?: string;
|
|
187
|
+
unstyled?: boolean;
|
|
188
|
+
empty?: ReactNode;
|
|
189
|
+
}): import("react").JSX.Element | null;
|