@feltdb/feltkit 0.3.37 → 0.5.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/agent-engine.d.ts +93 -0
- package/dist/agent-engine.js +40 -0
- package/dist/agent-engine.js.map +1 -0
- package/dist/app.d.ts +306 -7
- package/dist/app.js +289 -28
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +7 -0
- package/dist/appboundry/build.js +25 -1
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +8 -0
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.d.ts +21 -0
- package/dist/appboundry/host.js +25 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/appboundry/runtime.js +1 -0
- package/dist/appboundry/runtime.js.map +1 -1
- package/dist/boards/index.d.ts +1258 -0
- package/dist/boards/index.js +1410 -0
- package/dist/boards/index.js.map +1 -0
- package/dist/boards/model.d.ts +177 -0
- package/dist/boards/model.js +177 -0
- package/dist/boards/model.js.map +1 -0
- package/dist/boards/react.d.ts +18 -0
- package/dist/boards/react.js +339 -0
- package/dist/boards/react.js.map +1 -0
- package/dist/cli/deploy-appboundry-self-hosted.js +2 -2
- package/dist/cli/deploy.js +19 -6
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +70 -5
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +454 -4
- package/dist/client/index.js +371 -3
- 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/cron.d.ts +18 -0
- package/dist/cron.js +67 -0
- package/dist/cron.js.map +1 -0
- package/dist/dashboard/assets/index-iIj7SL77.js +15 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +4 -0
- package/dist/docs.js.map +1 -1
- package/dist/eve/index.d.ts +77 -0
- package/dist/eve/index.js +128 -0
- package/dist/eve/index.js.map +1 -0
- package/dist/event-stage.js +2 -0
- package/dist/event-stage.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/native/build.d.ts +112 -0
- package/dist/native/build.js +472 -0
- package/dist/native/build.js.map +1 -0
- package/dist/native/index.d.ts +67 -0
- package/dist/native/index.js +113 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/instance.d.ts +3 -0
- package/dist/native/instance.js +18 -0
- package/dist/native/instance.js.map +1 -0
- 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 +191 -0
- package/dist/react/agent-control.js +366 -0
- package/dist/react/agent-control.js.map +1 -0
- package/dist/react/auth.d.ts +15 -1
- package/dist/react/auth.js +28 -5
- package/dist/react/auth.js.map +1 -1
- package/dist/react/hooks.d.ts +88 -0
- package/dist/react/hooks.js +188 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +5 -75
- package/dist/react/index.js +4 -145
- 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 +28 -0
- package/dist/runtime/agent-control.js +43 -2
- package/dist/runtime/agent-control.js.map +1 -1
- package/dist/runtime/agent-run.d.ts +166 -0
- package/dist/runtime/agent-run.js +431 -0
- package/dist/runtime/agent-run.js.map +1 -0
- package/dist/runtime/agent.d.ts +158 -1
- package/dist/runtime/agent.js +345 -12
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/assemble.js +15 -2
- package/dist/runtime/assemble.js.map +1 -1
- package/dist/runtime/authority.d.ts +47 -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 +123 -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 +5 -1
- package/dist/runtime/providers.js +11 -5
- package/dist/runtime/providers.js.map +1 -1
- package/dist/runtime/required-capabilities.d.ts +73 -0
- package/dist/runtime/required-capabilities.js +69 -0
- package/dist/runtime/required-capabilities.js.map +1 -0
- 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 +143 -1
- package/dist/runtime/runtime.js +853 -44
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sessions.d.ts +12 -0
- package/dist/runtime/sessions.js +16 -1
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/tenancy.d.ts +68 -1
- package/dist/runtime/tenancy.js +150 -0
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/transactions.d.ts +3 -1
- package/dist/runtime/transactions.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/eve.d.ts +287 -0
- package/dist/server/eve.js +1071 -0
- package/dist/server/eve.js.map +1 -0
- package/dist/server/index.d.ts +2 -19
- package/dist/server/index.js +102 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.d.ts +15 -22
- package/dist/server/mcp.js +40 -3
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.js +26 -8
- package/dist/server/project.js.map +1 -1
- package/dist/server/tenancy.d.ts +9 -0
- package/dist/server/tenancy.js +62 -1
- 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 +4 -5
- package/dist/testing/index.js +3 -2
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-CONTROL.md +166 -4
- package/docs/APPBOUNDRY.md +73 -0
- package/docs/ARCHITECTURE.md +6 -2
- package/docs/AUTH.md +37 -0
- package/docs/COMPONENTS.md +71 -0
- package/docs/EVE-COMPOSITION.md +75 -0
- package/docs/GUARANTEES.md +4 -4
- package/docs/NATIVE-AGENTS.md +353 -0
- package/docs/NATIVE.md +137 -0
- package/docs/PRESENCE-AND-SIGNALING-PROPOSAL.md +152 -0
- package/docs/README.md +6 -2
- package/docs/SECURITY.md +71 -3
- package/docs/TRANSACTIONS.md +48 -0
- package/docs/UPSTREAM-GAPS.md +16 -2
- package/package.json +42 -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-BhxrvY37.js +0 -15
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feltkit/react (the hooks; feltkit/native re-exports them for React Native)
|
|
3
|
+
*
|
|
4
|
+
* <FeltKitProvider client={createClient()}> … </FeltKitProvider>
|
|
5
|
+
* const tasks = useQuery(api.tasks.list, { projectId }); // undefined while loading
|
|
6
|
+
* const create = useMutation(api.tasks.create); // (args) => Promise<result>
|
|
7
|
+
*
|
|
8
|
+
* useQuery re-runs when a collection the query read changes — including changes made
|
|
9
|
+
* by other users, agents through AppPort, and services — because the server's change
|
|
10
|
+
* feed is FeltDB's own operation journal.
|
|
11
|
+
*/
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
13
|
+
import { FeltKitClientError } from "../client/index.js";
|
|
14
|
+
import { useFeltKit } from "./context.js";
|
|
15
|
+
export { FeltKitProvider, useFeltKit } from "./context.js";
|
|
16
|
+
/** Full state of a live query. Pass "skip" as args to not run it. */
|
|
17
|
+
export function useQueryState(fn, args) {
|
|
18
|
+
const client = useFeltKit();
|
|
19
|
+
const key = args === "skip" ? "skip" : JSON.stringify(args ?? {});
|
|
20
|
+
const [state, setState] = useState({ data: undefined, error: undefined, isLoading: args !== "skip" });
|
|
21
|
+
const argsRef = useRef(args);
|
|
22
|
+
argsRef.current = args;
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (key === "skip") {
|
|
25
|
+
setState({ data: undefined, error: undefined, isLoading: false });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setState((s) => ({ ...s, isLoading: true }));
|
|
29
|
+
return client.watchQuery(fn, argsRef.current, {
|
|
30
|
+
next: (data) => setState({ data, error: undefined, isLoading: false }),
|
|
31
|
+
error: (error) => setState((s) => ({ data: s.data, error, isLoading: false })),
|
|
32
|
+
});
|
|
33
|
+
}, [client, fn.name, key]);
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
/** The value of a live query, or undefined while it first loads. Errors are thrown to the nearest error boundary. */
|
|
37
|
+
export function useQuery(fn, args) {
|
|
38
|
+
const state = useQueryState(fn, args);
|
|
39
|
+
if (state.error && state.data === undefined)
|
|
40
|
+
throw state.error;
|
|
41
|
+
return state.data;
|
|
42
|
+
}
|
|
43
|
+
/** A function that runs the mutation. */
|
|
44
|
+
/**
|
|
45
|
+
* Receive an ephemeral event (`app.event`) while the component is mounted. Pass "skip" to not
|
|
46
|
+
* subscribe. The latest `listener` is always called; resubscribes when the event or scope changes.
|
|
47
|
+
*/
|
|
48
|
+
export function useEvent(event, options, listener) {
|
|
49
|
+
const client = useFeltKit();
|
|
50
|
+
const latest = useRef(listener);
|
|
51
|
+
latest.current = listener;
|
|
52
|
+
const name = typeof event === "string" ? event : event.name;
|
|
53
|
+
const scope = options === "skip" ? null : options.scope ?? "";
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (scope === null)
|
|
56
|
+
return;
|
|
57
|
+
return client.subscribe(name, scope ? { scope } : {}, (payload, meta) => latest.current(payload, meta));
|
|
58
|
+
}, [client, name, scope]);
|
|
59
|
+
}
|
|
60
|
+
export function useMutation(fn) {
|
|
61
|
+
const client = useFeltKit();
|
|
62
|
+
return useCallback((args) => client.mutation(fn, args), [client, fn.name]);
|
|
63
|
+
}
|
|
64
|
+
/** Run an action with streaming: text appears as the model writes it; `cancel()` stops it. */
|
|
65
|
+
export function useAction(fn) {
|
|
66
|
+
const client = useFeltKit();
|
|
67
|
+
const [state, setState] = useState({ running: false, text: "", events: [], error: null });
|
|
68
|
+
const controller = useRef(null);
|
|
69
|
+
useEffect(() => () => controller.current?.abort(), []);
|
|
70
|
+
const cancel = useCallback(() => controller.current?.abort(), []);
|
|
71
|
+
const run = useCallback(async (args) => {
|
|
72
|
+
controller.current?.abort();
|
|
73
|
+
const current = new AbortController();
|
|
74
|
+
controller.current = current;
|
|
75
|
+
setState({ running: true, text: "", events: [], error: null });
|
|
76
|
+
try {
|
|
77
|
+
const value = await client.action(fn, args, {
|
|
78
|
+
signal: current.signal,
|
|
79
|
+
onDelta: (text) => setState((s) => ({ ...s, text: s.text + text })),
|
|
80
|
+
onEvent: (event) => setState((s) => ({ ...s, events: [...s.events, event] })),
|
|
81
|
+
});
|
|
82
|
+
if (controller.current === current)
|
|
83
|
+
setState((s) => ({ ...s, running: false }));
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const e = error instanceof FeltKitClientError ? error : new FeltKitClientError({ code: current.signal.aborted ? "UNAVAILABLE" : "INTERNAL", message: current.signal.aborted ? "Cancelled." : String(error?.message ?? error) });
|
|
88
|
+
if (controller.current === current)
|
|
89
|
+
setState((s) => ({ ...s, running: false, error: current.signal.aborted ? null : e }));
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
}, [client, fn.name]);
|
|
93
|
+
return useMemo(() => ({ run, cancel, ...state }), [run, cancel, state]);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Your agent actions (e.g. `{ state: "proposed" }`: what waits for your approval), live: an approval,
|
|
97
|
+
* rejection or execution from any client appears without a refresh. With approve/reject.
|
|
98
|
+
*/
|
|
99
|
+
export function useOwnActions(filter = {}) {
|
|
100
|
+
const client = useFeltKit();
|
|
101
|
+
const [actions, setActions] = useState();
|
|
102
|
+
const [tick, setTick] = useState(0);
|
|
103
|
+
const key = `${filter.state ?? ""}:${filter.limit ?? ""}`;
|
|
104
|
+
useEffect(() => client.watchOwnActions(filter.state ? { state: filter.state } : {}, (list) => setActions(filter.limit ? list.slice(0, filter.limit) : list)), [client, key, tick]);
|
|
105
|
+
const refresh = useCallback(() => setTick((t) => t + 1), []);
|
|
106
|
+
return {
|
|
107
|
+
actions,
|
|
108
|
+
refresh,
|
|
109
|
+
// The approval binds to the action as shown: its digest goes back with it.
|
|
110
|
+
approve: (a) => client.approveAction(a.taskId, a.actionId, a.inputDigest ? { inputDigest: a.inputDigest } : undefined),
|
|
111
|
+
reject: (a, reason) => client.rejectAction(a.taskId, a.actionId, reason),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What happened to one of your calls, and the means to settle it within your authority: `status` (from
|
|
116
|
+
* `appport.invocation.status`), `refresh()`, `verify()` (ask the external system), `settle(outcome, note)`. Pass the
|
|
117
|
+
* request id an unknown outcome named (`unknownCallId(error)`), or `{ idempotencyKey, capability }`; "skip" for none.
|
|
118
|
+
*/
|
|
119
|
+
export function useInvocationStatus(query) {
|
|
120
|
+
const client = useFeltKit();
|
|
121
|
+
const [status, setStatus] = useState();
|
|
122
|
+
const [error, setError] = useState();
|
|
123
|
+
const [tick, setTick] = useState(0);
|
|
124
|
+
const key = query === "skip" ? "skip" : JSON.stringify(query);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (query === "skip")
|
|
127
|
+
return;
|
|
128
|
+
let live = true;
|
|
129
|
+
client.invocationStatus(query).then((s) => live && (setStatus(s), setError(undefined)), (e) => live && setError(e));
|
|
130
|
+
return () => {
|
|
131
|
+
live = false;
|
|
132
|
+
};
|
|
133
|
+
}, [client, key, tick]);
|
|
134
|
+
const refresh = useCallback(() => setTick((t) => t + 1), []);
|
|
135
|
+
const callId = () => status?.requestId ?? (query !== "skip" && "requestId" in query ? query.requestId : undefined);
|
|
136
|
+
return {
|
|
137
|
+
status,
|
|
138
|
+
error,
|
|
139
|
+
refresh,
|
|
140
|
+
verify: async () => {
|
|
141
|
+
const id = callId();
|
|
142
|
+
if (id)
|
|
143
|
+
await client.verifyCall(id);
|
|
144
|
+
refresh();
|
|
145
|
+
},
|
|
146
|
+
settle: async (outcome, note) => {
|
|
147
|
+
const id = callId();
|
|
148
|
+
if (id)
|
|
149
|
+
await client.settleCall(id, { outcome, note });
|
|
150
|
+
refresh();
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Who the current user is, plus development sign-in when the server allows it. */
|
|
155
|
+
export function useSession() {
|
|
156
|
+
const client = useFeltKit();
|
|
157
|
+
const [session, setSession] = useState();
|
|
158
|
+
const [tick, setTick] = useState(0);
|
|
159
|
+
useEffect(() => client.onSessionChange(() => setTick((t) => t + 1)), [client]);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
let live = true;
|
|
162
|
+
client.session().then((s) => live && setSession(s), () => live && setSession(undefined));
|
|
163
|
+
return () => {
|
|
164
|
+
live = false;
|
|
165
|
+
};
|
|
166
|
+
}, [client, tick]);
|
|
167
|
+
return useMemo(() => ({
|
|
168
|
+
session,
|
|
169
|
+
signInAsDevUser: async (userId) => {
|
|
170
|
+
await client.signInAsDevUser(userId);
|
|
171
|
+
},
|
|
172
|
+
signUp: async (input) => {
|
|
173
|
+
await client.signUp(input);
|
|
174
|
+
},
|
|
175
|
+
signIn: async (input) => {
|
|
176
|
+
await client.signIn(input);
|
|
177
|
+
},
|
|
178
|
+
signOut: () => client.signOut(),
|
|
179
|
+
refresh: () => setTick((t) => t + 1),
|
|
180
|
+
}), [client, session]);
|
|
181
|
+
}
|
|
182
|
+
/** True while the change stream is connected (queries are live). */
|
|
183
|
+
export function useConnectionState() {
|
|
184
|
+
const client = useFeltKit();
|
|
185
|
+
return useSyncExternalStore((notify) => client.onConnectionChange(notify), () => client.connected, () => false);
|
|
186
|
+
}
|
|
187
|
+
export { FeltKitClientError };
|
|
188
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/react/hooks.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAA6J,MAAM,oBAAoB,CAAC;AACnN,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ3D,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAuC,EAAK,EAAE,IAAyB;IAClG,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,KAAK,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AAO,oBAAoB,CACzB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAC7C,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,EACtB,GAAG,EAAE,CAAC,KAAK,CACZ,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,77 +1,7 @@
|
|
|
1
|
-
import { FeltKitClientError, type ActionEvent, type ArgsOf, type FunctionReference, type OwnAction, type ResultOf, type SessionInfo } from "../client/index.js";
|
|
2
|
-
export { FeltKitProvider, useFeltKit } from "./context.js";
|
|
3
|
-
export * from "./auth.js";
|
|
4
|
-
export interface QueryState<T> {
|
|
5
|
-
data: T | undefined;
|
|
6
|
-
error: FeltKitClientError | undefined;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
}
|
|
9
|
-
/** Full state of a live query. Pass "skip" as args to not run it. */
|
|
10
|
-
export declare function useQueryState<F extends FunctionReference<"query">>(fn: F, args?: ArgsOf<F> | "skip"): QueryState<ResultOf<F>>;
|
|
11
|
-
/** The value of a live query, or undefined while it first loads. Errors are thrown to the nearest error boundary. */
|
|
12
|
-
export declare function useQuery<F extends FunctionReference<"query">>(fn: F, args?: ArgsOf<F> | "skip"): ResultOf<F> | undefined;
|
|
13
|
-
/** A function that runs the mutation. */
|
|
14
|
-
/**
|
|
15
|
-
* Receive an ephemeral event (`app.event`) while the component is mounted. Pass "skip" to not
|
|
16
|
-
* subscribe. The latest `listener` is always called; resubscribes when the event or scope changes.
|
|
17
|
-
*/
|
|
18
|
-
export declare function useEvent<P = unknown>(event: string | {
|
|
19
|
-
name: string;
|
|
20
|
-
__payload?: P;
|
|
21
|
-
}, options: {
|
|
22
|
-
scope?: string;
|
|
23
|
-
} | "skip", listener: (payload: P, meta: {
|
|
24
|
-
scope?: string;
|
|
25
|
-
eventId: string;
|
|
26
|
-
timestamp: string;
|
|
27
|
-
}) => void): void;
|
|
28
|
-
export declare function useMutation<F extends FunctionReference<"mutation">>(fn: F): (args?: ArgsOf<F>) => Promise<ResultOf<F>>;
|
|
29
|
-
export interface UseAction<F extends FunctionReference<"action">> {
|
|
30
|
-
/** Start the action. Streams into `text` and `events`; resolves with its value. A previous run is cancelled first. */
|
|
31
|
-
run(args?: ArgsOf<F>): Promise<ResultOf<F>>;
|
|
32
|
-
/** Cancel the running action (and its model call on the server). */
|
|
33
|
-
cancel(): void;
|
|
34
|
-
running: boolean;
|
|
35
|
-
/** Model text streamed so far in the current run. */
|
|
36
|
-
text: string;
|
|
37
|
-
/** Every event of the current run (`ctx.emit`, model deltas, generation receipts, proposals). */
|
|
38
|
-
events: ActionEvent[];
|
|
39
|
-
error: FeltKitClientError | null;
|
|
40
|
-
}
|
|
41
|
-
/** Run an action with streaming: text appears as the model writes it; `cancel()` stops it. */
|
|
42
|
-
export declare function useAction<F extends FunctionReference<"action">>(fn: F): UseAction<F>;
|
|
43
1
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
2
|
+
* feltkit/react: the hooks (hooks.tsx, shared with React Native through feltkit/native) and the DOM components
|
|
3
|
+
* (auth.tsx, agent-control.tsx), which only a browser renders.
|
|
46
4
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}): {
|
|
51
|
-
actions: OwnAction[] | undefined;
|
|
52
|
-
refresh(): void;
|
|
53
|
-
approve(a: Pick<OwnAction, "taskId" | "actionId" | "inputDigest">): Promise<OwnAction | null>;
|
|
54
|
-
reject(a: Pick<OwnAction, "taskId" | "actionId">, reason?: string): Promise<OwnAction | null>;
|
|
55
|
-
};
|
|
56
|
-
export interface UseSession {
|
|
57
|
-
session: SessionInfo | undefined;
|
|
58
|
-
signInAsDevUser(userId: string): Promise<void>;
|
|
59
|
-
/** Built-in accounts (`auth.accounts`). */
|
|
60
|
-
signUp(input: {
|
|
61
|
-
email: string;
|
|
62
|
-
password: string;
|
|
63
|
-
name?: string;
|
|
64
|
-
}): Promise<void>;
|
|
65
|
-
signIn(input: {
|
|
66
|
-
email: string;
|
|
67
|
-
password: string;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
signOut(): Promise<void>;
|
|
70
|
-
refresh(): void;
|
|
71
|
-
}
|
|
72
|
-
/** Who the current user is, plus development sign-in when the server allows it. */
|
|
73
|
-
export declare function useSession(): UseSession;
|
|
74
|
-
/** True while the change stream is connected (queries are live). */
|
|
75
|
-
export declare function useConnectionState(): boolean;
|
|
76
|
-
export { FeltKitClientError };
|
|
77
|
-
export type { ActionEvent, OwnAction } from "../client/index.js";
|
|
5
|
+
export * from "./hooks.js";
|
|
6
|
+
export * from "./auth.js";
|
|
7
|
+
export * from "./agent-control.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,149 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* feltkit/react
|
|
3
|
-
*
|
|
4
|
-
* <FeltKitProvider client={createClient()}> … </FeltKitProvider>
|
|
5
|
-
* const tasks = useQuery(api.tasks.list, { projectId }); // undefined while loading
|
|
6
|
-
* const create = useMutation(api.tasks.create); // (args) => Promise<result>
|
|
7
|
-
*
|
|
8
|
-
* useQuery re-runs when a collection the query read changes — including changes made
|
|
9
|
-
* by other users, agents through AppPort, and services — because the server's change
|
|
10
|
-
* feed is FeltDB's own operation journal.
|
|
2
|
+
* feltkit/react: the hooks (hooks.tsx, shared with React Native through feltkit/native) and the DOM components
|
|
3
|
+
* (auth.tsx, agent-control.tsx), which only a browser renders.
|
|
11
4
|
*/
|
|
12
|
-
|
|
13
|
-
import { FeltKitClientError } from "../client/index.js";
|
|
14
|
-
import { useFeltKit } from "./context.js";
|
|
15
|
-
export { FeltKitProvider, useFeltKit } from "./context.js";
|
|
5
|
+
export * from "./hooks.js";
|
|
16
6
|
export * from "./auth.js";
|
|
17
|
-
|
|
18
|
-
export function useQueryState(fn, args) {
|
|
19
|
-
const client = useFeltKit();
|
|
20
|
-
const key = args === "skip" ? "skip" : JSON.stringify(args ?? {});
|
|
21
|
-
const [state, setState] = useState({ data: undefined, error: undefined, isLoading: args !== "skip" });
|
|
22
|
-
const argsRef = useRef(args);
|
|
23
|
-
argsRef.current = args;
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (key === "skip") {
|
|
26
|
-
setState({ data: undefined, error: undefined, isLoading: false });
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
setState((s) => ({ ...s, isLoading: true }));
|
|
30
|
-
return client.watchQuery(fn, argsRef.current, {
|
|
31
|
-
next: (data) => setState({ data, error: undefined, isLoading: false }),
|
|
32
|
-
error: (error) => setState((s) => ({ data: s.data, error, isLoading: false })),
|
|
33
|
-
});
|
|
34
|
-
}, [client, fn.name, key]);
|
|
35
|
-
return state;
|
|
36
|
-
}
|
|
37
|
-
/** The value of a live query, or undefined while it first loads. Errors are thrown to the nearest error boundary. */
|
|
38
|
-
export function useQuery(fn, args) {
|
|
39
|
-
const state = useQueryState(fn, args);
|
|
40
|
-
if (state.error && state.data === undefined)
|
|
41
|
-
throw state.error;
|
|
42
|
-
return state.data;
|
|
43
|
-
}
|
|
44
|
-
/** A function that runs the mutation. */
|
|
45
|
-
/**
|
|
46
|
-
* Receive an ephemeral event (`app.event`) while the component is mounted. Pass "skip" to not
|
|
47
|
-
* subscribe. The latest `listener` is always called; resubscribes when the event or scope changes.
|
|
48
|
-
*/
|
|
49
|
-
export function useEvent(event, options, listener) {
|
|
50
|
-
const client = useFeltKit();
|
|
51
|
-
const latest = useRef(listener);
|
|
52
|
-
latest.current = listener;
|
|
53
|
-
const name = typeof event === "string" ? event : event.name;
|
|
54
|
-
const scope = options === "skip" ? null : options.scope ?? "";
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (scope === null)
|
|
57
|
-
return;
|
|
58
|
-
return client.subscribe(name, scope ? { scope } : {}, (payload, meta) => latest.current(payload, meta));
|
|
59
|
-
}, [client, name, scope]);
|
|
60
|
-
}
|
|
61
|
-
export function useMutation(fn) {
|
|
62
|
-
const client = useFeltKit();
|
|
63
|
-
return useCallback((args) => client.mutation(fn, args), [client, fn.name]);
|
|
64
|
-
}
|
|
65
|
-
/** Run an action with streaming: text appears as the model writes it; `cancel()` stops it. */
|
|
66
|
-
export function useAction(fn) {
|
|
67
|
-
const client = useFeltKit();
|
|
68
|
-
const [state, setState] = useState({ running: false, text: "", events: [], error: null });
|
|
69
|
-
const controller = useRef(null);
|
|
70
|
-
useEffect(() => () => controller.current?.abort(), []);
|
|
71
|
-
const cancel = useCallback(() => controller.current?.abort(), []);
|
|
72
|
-
const run = useCallback(async (args) => {
|
|
73
|
-
controller.current?.abort();
|
|
74
|
-
const current = new AbortController();
|
|
75
|
-
controller.current = current;
|
|
76
|
-
setState({ running: true, text: "", events: [], error: null });
|
|
77
|
-
try {
|
|
78
|
-
const value = await client.action(fn, args, {
|
|
79
|
-
signal: current.signal,
|
|
80
|
-
onDelta: (text) => setState((s) => ({ ...s, text: s.text + text })),
|
|
81
|
-
onEvent: (event) => setState((s) => ({ ...s, events: [...s.events, event] })),
|
|
82
|
-
});
|
|
83
|
-
if (controller.current === current)
|
|
84
|
-
setState((s) => ({ ...s, running: false }));
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const e = error instanceof FeltKitClientError ? error : new FeltKitClientError({ code: current.signal.aborted ? "UNAVAILABLE" : "INTERNAL", message: current.signal.aborted ? "Cancelled." : String(error?.message ?? error) });
|
|
89
|
-
if (controller.current === current)
|
|
90
|
-
setState((s) => ({ ...s, running: false, error: current.signal.aborted ? null : e }));
|
|
91
|
-
throw e;
|
|
92
|
-
}
|
|
93
|
-
}, [client, fn.name]);
|
|
94
|
-
return useMemo(() => ({ run, cancel, ...state }), [run, cancel, state]);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Your agent actions (e.g. `{ state: "proposed" }`: what waits for your approval), live: an approval,
|
|
98
|
-
* rejection or execution from any client appears without a refresh. With approve/reject.
|
|
99
|
-
*/
|
|
100
|
-
export function useOwnActions(filter = {}) {
|
|
101
|
-
const client = useFeltKit();
|
|
102
|
-
const [actions, setActions] = useState();
|
|
103
|
-
const [tick, setTick] = useState(0);
|
|
104
|
-
const key = `${filter.state ?? ""}:${filter.limit ?? ""}`;
|
|
105
|
-
useEffect(() => client.watchOwnActions(filter.state ? { state: filter.state } : {}, (list) => setActions(filter.limit ? list.slice(0, filter.limit) : list)), [client, key, tick]);
|
|
106
|
-
const refresh = useCallback(() => setTick((t) => t + 1), []);
|
|
107
|
-
return {
|
|
108
|
-
actions,
|
|
109
|
-
refresh,
|
|
110
|
-
// The approval binds to the action as shown: its digest goes back with it.
|
|
111
|
-
approve: (a) => client.approveAction(a.taskId, a.actionId, a.inputDigest ? { inputDigest: a.inputDigest } : undefined),
|
|
112
|
-
reject: (a, reason) => client.rejectAction(a.taskId, a.actionId, reason),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/** Who the current user is, plus development sign-in when the server allows it. */
|
|
116
|
-
export function useSession() {
|
|
117
|
-
const client = useFeltKit();
|
|
118
|
-
const [session, setSession] = useState();
|
|
119
|
-
const [tick, setTick] = useState(0);
|
|
120
|
-
useEffect(() => client.onSessionChange(() => setTick((t) => t + 1)), [client]);
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
let live = true;
|
|
123
|
-
client.session().then((s) => live && setSession(s), () => live && setSession(undefined));
|
|
124
|
-
return () => {
|
|
125
|
-
live = false;
|
|
126
|
-
};
|
|
127
|
-
}, [client, tick]);
|
|
128
|
-
return useMemo(() => ({
|
|
129
|
-
session,
|
|
130
|
-
signInAsDevUser: async (userId) => {
|
|
131
|
-
await client.signInAsDevUser(userId);
|
|
132
|
-
},
|
|
133
|
-
signUp: async (input) => {
|
|
134
|
-
await client.signUp(input);
|
|
135
|
-
},
|
|
136
|
-
signIn: async (input) => {
|
|
137
|
-
await client.signIn(input);
|
|
138
|
-
},
|
|
139
|
-
signOut: () => client.signOut(),
|
|
140
|
-
refresh: () => setTick((t) => t + 1),
|
|
141
|
-
}), [client, session]);
|
|
142
|
-
}
|
|
143
|
-
/** True while the change stream is connected (queries are live). */
|
|
144
|
-
export function useConnectionState() {
|
|
145
|
-
const client = useFeltKit();
|
|
146
|
-
return useSyncExternalStore((notify) => client.onConnectionChange(notify), () => client.connected, () => false);
|
|
147
|
-
}
|
|
148
|
-
export { FeltKitClientError };
|
|
7
|
+
export * from "./agent-control.js";
|
|
149
8
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC"}
|
|
@@ -58,6 +58,14 @@ export interface ActivityEntry {
|
|
|
58
58
|
};
|
|
59
59
|
/** An agent's call on this principal's behalf, as AuthBoundry verified it (runtime/delegation.ts). */
|
|
60
60
|
delegation?: import("./delegation.js").Delegation;
|
|
61
|
+
/**
|
|
62
|
+
* The call's invocation context (runtime/workers.ts): the worker (`principal`) acts for `verified.actor` under the
|
|
63
|
+
* work grant `verified.grantRef`, with an approval `verified.approvalRef`; `claimed` is what the caller said.
|
|
64
|
+
*/
|
|
65
|
+
invocation?: {
|
|
66
|
+
claimed: import("@appport/protocol").InvocationContext;
|
|
67
|
+
verified: import("@appport/protocol").InvocationContext;
|
|
68
|
+
};
|
|
61
69
|
/** The application's `authorize` hook, when it has one: its decision for this call. */
|
|
62
70
|
resource?: {
|
|
63
71
|
allowed: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/runtime/activity.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,M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O,EAAG,KAAe,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAClH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/E,MAAM,CAAC,GAAG,KAA8C,CAAC;IACzD,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1I,CAAC"}
|
|
@@ -71,7 +71,28 @@ export interface ControlPort {
|
|
|
71
71
|
/** Abort this process's running generations for a task (interrupt). */
|
|
72
72
|
abortGenerations(taskId: string, reason: string): number;
|
|
73
73
|
activity(name: string, p: Principal, taskId: string, outcome: "success" | "error" | "denied", detail: Record<string, unknown>): void;
|
|
74
|
+
/**
|
|
75
|
+
* A change is durable: publish `appport.agent.changed@1` (the runtime allocates the per-task `sequence`). Never
|
|
76
|
+
* fails the operation that made the change: the event is a notification, the state is the authority.
|
|
77
|
+
*/
|
|
78
|
+
changed?(taskId: string, changes: AgentChangeKind[], instructionId: string | undefined, state: {
|
|
79
|
+
revision: string;
|
|
80
|
+
phase: ExecutionPhase;
|
|
81
|
+
mode: ControlMode;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/** The `sequence` of the last `appport.agent.changed` event for a task (0 before any). */
|
|
84
|
+
sequence?(taskId: string): Promise<number>;
|
|
85
|
+
/**
|
|
86
|
+
* The task's reasoner runs outside this process (an agent on the agent runtime): carry an interrupt or a resume to
|
|
87
|
+
* it once the mode is recorded. Rejects when the reasoner could not be reached; the recorded mode stands and the
|
|
88
|
+
* operation can be repeated.
|
|
89
|
+
*/
|
|
90
|
+
external?(taskId: string, op: "pause" | "interrupt" | "resume", p: Principal, reason?: string): Promise<boolean>;
|
|
91
|
+
/** The task's external reasoner has ended for good (its session ended), even before the task is recorded stopped. */
|
|
92
|
+
ended?(taskId: string): Promise<boolean>;
|
|
74
93
|
}
|
|
94
|
+
/** What changed, in `appport.agent.changed@1` (AppPort spec/agent-control-1.md §7). */
|
|
95
|
+
export type AgentChangeKind = "mode" | "phase" | "instruction" | "checkpoint" | "in-flight";
|
|
75
96
|
export interface ControlView {
|
|
76
97
|
taskId: string;
|
|
77
98
|
objective: string;
|
|
@@ -91,6 +112,8 @@ export interface ControlView {
|
|
|
91
112
|
checkpoint: number;
|
|
92
113
|
/** Changes whenever anything above changes; clients use it to drop stale snapshots. */
|
|
93
114
|
revision: string;
|
|
115
|
+
/** The `sequence` of the last `appport.agent.changed` event for this task (0 before any): where this snapshot is. */
|
|
116
|
+
sequence: number;
|
|
94
117
|
}
|
|
95
118
|
export interface Checkpoint {
|
|
96
119
|
/** False while paused or interrupted: start no new work, call checkpoint again later. */
|
|
@@ -112,6 +135,10 @@ export interface Checkpoint {
|
|
|
112
135
|
export declare class AgentControl {
|
|
113
136
|
#private;
|
|
114
137
|
constructor(port: ControlPort);
|
|
138
|
+
/** In-flight work started or finished (a generation, an action): the phase may have moved (pausing → paused). */
|
|
139
|
+
inFlightChanged(taskId: string): Promise<void>;
|
|
140
|
+
/** Every change of mode, oldest first: who paused, resumed or interrupted the task, when, and why (the last 50). */
|
|
141
|
+
history(taskId: string): Promise<ControlRecord["history"]>;
|
|
115
142
|
mode(taskId: string): Promise<{
|
|
116
143
|
mode: ControlMode;
|
|
117
144
|
reason: string | null;
|
|
@@ -157,6 +184,7 @@ export declare class AgentControl {
|
|
|
157
184
|
* The safe boundary. Hands every received update to the reasoner (received → delivered, recorded
|
|
158
185
|
* with the checkpoint it was delivered at) and returns them with any delivered earlier and not yet
|
|
159
186
|
* acknowledged (redelivered after a restart). Idempotent: calling it again delivers nothing twice.
|
|
187
|
+
* While the task is held (paused or interrupted) nothing new is delivered: `proceed` is false.
|
|
160
188
|
*/
|
|
161
189
|
checkpoint(taskId: string, p: Principal): Promise<Checkpoint>;
|
|
162
190
|
/**
|