@agent-native/core 0.114.10 → 0.114.11
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/extensions/actions.ts +219 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +48 -0
- package/corpus/templates/clips/app/lib/fmp4.ts +26 -4
- package/corpus/templates/clips/app/lib/mse-video-loader.ts +13 -2
- package/corpus/templates/clips/changelog/2026-07-20-rewind-capture-status.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +81 -71
- package/corpus/templates/clips/desktop/src/lib/rewind-status.ts +103 -0
- package/corpus/templates/clips/desktop/src/styles.css +10 -0
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +193 -1
- package/dist/extensions/actions.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +6 -6
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
- package/package.json +1 -1
- package/src/extensions/actions.ts +219 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +19 -0
|
@@ -49,8 +49,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
49
49
|
}>;
|
|
50
50
|
/** DELETE /_agent-native/resources/:id — delete a resource */
|
|
51
51
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
52
|
-
ok?: undefined;
|
|
53
52
|
error: string;
|
|
53
|
+
ok?: undefined;
|
|
54
54
|
} | {
|
|
55
55
|
error?: undefined;
|
|
56
56
|
ok: boolean;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -37,17 +37,17 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
|
|
|
37
37
|
status?: undefined;
|
|
38
38
|
ok?: undefined;
|
|
39
39
|
} | {
|
|
40
|
+
error?: undefined;
|
|
40
41
|
ok: boolean;
|
|
41
42
|
status: string;
|
|
42
|
-
error?: undefined;
|
|
43
43
|
} | {
|
|
44
44
|
error: string;
|
|
45
45
|
removed?: undefined;
|
|
46
46
|
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
+
error?: undefined;
|
|
48
49
|
ok: boolean;
|
|
49
50
|
removed: boolean;
|
|
50
|
-
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — re-run the validator against the
|
|
@@ -58,13 +58,13 @@ export declare function createTestSecretHandler(): import("h3").EventHandlerWith
|
|
|
58
58
|
note?: undefined;
|
|
59
59
|
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
|
+
error?: undefined;
|
|
61
62
|
ok: boolean;
|
|
62
63
|
note?: undefined;
|
|
63
|
-
error?: undefined;
|
|
64
64
|
} | {
|
|
65
|
+
error?: undefined;
|
|
65
66
|
ok: boolean;
|
|
66
67
|
note: string;
|
|
67
|
-
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
+
error?: undefined;
|
|
98
99
|
ok: boolean;
|
|
99
100
|
key: string;
|
|
100
|
-
error?: undefined;
|
|
101
101
|
} | {
|
|
102
|
+
error?: undefined;
|
|
102
103
|
ok: boolean;
|
|
103
104
|
removed: boolean;
|
|
104
|
-
error?: undefined;
|
|
105
105
|
}>>;
|
|
106
106
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -153,6 +153,25 @@ persistence** — it handles everything automatically. Only use
|
|
|
153
153
|
`dbQuery`/`dbExec` when querying the app's existing tables. See
|
|
154
154
|
`references/api.md` for the full `get`/`remove`/scope reference.
|
|
155
155
|
|
|
156
|
+
### Agent-side extension data access
|
|
157
|
+
|
|
158
|
+
The agent can read and write `extensionData` directly using two dedicated
|
|
159
|
+
actions — no need to go through the iframe bridge or raw SQL:
|
|
160
|
+
|
|
161
|
+
| Action | Purpose |
|
|
162
|
+
| --------------------- | ------------------------------------------------- |
|
|
163
|
+
| `extension-data-set` | Upsert an item in an extension's data store |
|
|
164
|
+
| `extension-data-get` | Read items from an extension's data store |
|
|
165
|
+
|
|
166
|
+
Use `extension-data-set` when the agent needs to seed, refresh, or update
|
|
167
|
+
data that an extension reads at render time via `extensionData.get()`. This
|
|
168
|
+
is the correct path for agent-driven dashboard refreshes — the agent
|
|
169
|
+
fetches fresh data from providers, then writes the merged result with
|
|
170
|
+
`extension-data-set`, and the extension picks it up on next load.
|
|
171
|
+
|
|
172
|
+
Use `extension-data-get` to inspect what data an extension currently stores,
|
|
173
|
+
or to verify a write succeeded.
|
|
174
|
+
|
|
156
175
|
## What extensions are
|
|
157
176
|
|
|
158
177
|
Extensions are mini Alpine.js apps that run inside sandboxed iframes. They
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.11",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
1
3
|
import { ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER } from "../action-ui.js";
|
|
2
4
|
import { AgentActionStopError, type ActionRunContext } from "../action.js";
|
|
3
5
|
import type { ActionEntry } from "../agent/production-agent.js";
|
|
4
6
|
import type { AgentChatAttachment } from "../agent/types.js";
|
|
5
7
|
import { writeAppState } from "../application-state/script-helpers.js";
|
|
8
|
+
import { getDbExec, isPostgres } from "../db/client.js";
|
|
6
9
|
import { readResource } from "../resources/script-helpers.js";
|
|
7
10
|
import {
|
|
8
11
|
getRequestOrgId,
|
|
@@ -36,6 +39,7 @@ import {
|
|
|
36
39
|
import {
|
|
37
40
|
createExtension,
|
|
38
41
|
deleteExtension,
|
|
42
|
+
ensureExtensionsTables,
|
|
39
43
|
findRecentDuplicateExtension,
|
|
40
44
|
getHiddenExtensionIdsForCurrentUser,
|
|
41
45
|
getExtension,
|
|
@@ -45,6 +49,7 @@ import {
|
|
|
45
49
|
hideExtension,
|
|
46
50
|
listExtensionHistory,
|
|
47
51
|
listExtensions,
|
|
52
|
+
notifyExtensionChangeForResource,
|
|
48
53
|
restoreExtensionHistoryVersion,
|
|
49
54
|
unhideExtension,
|
|
50
55
|
updateExtension,
|
|
@@ -818,6 +823,220 @@ export function createExtensionActionEntries(): Record<string, ActionEntry> {
|
|
|
818
823
|
},
|
|
819
824
|
},
|
|
820
825
|
|
|
826
|
+
"extension-data-set": {
|
|
827
|
+
tool: {
|
|
828
|
+
description:
|
|
829
|
+
"Write a value to an extension's extensionData store (the tool_data table) from the agent side. Use this when the agent needs to update or seed data that an extension reads via extensionData.get() at render time. Requires editor access to the extension.",
|
|
830
|
+
parameters: {
|
|
831
|
+
type: "object",
|
|
832
|
+
properties: {
|
|
833
|
+
extensionId: {
|
|
834
|
+
type: "string",
|
|
835
|
+
description: "Extension id whose data store to write to.",
|
|
836
|
+
},
|
|
837
|
+
collection: {
|
|
838
|
+
type: "string",
|
|
839
|
+
description: "Collection name within the extension's data store.",
|
|
840
|
+
},
|
|
841
|
+
itemId: {
|
|
842
|
+
type: "string",
|
|
843
|
+
description:
|
|
844
|
+
"Item id within the collection. Upserts if it already exists.",
|
|
845
|
+
},
|
|
846
|
+
data: {
|
|
847
|
+
description:
|
|
848
|
+
"The data value to store. Objects are JSON-serialized automatically.",
|
|
849
|
+
},
|
|
850
|
+
scope: {
|
|
851
|
+
type: "string",
|
|
852
|
+
enum: ["user", "org"],
|
|
853
|
+
description:
|
|
854
|
+
"Storage scope. 'user' (default) is private to the current user; 'org' is shared across the organization.",
|
|
855
|
+
},
|
|
856
|
+
},
|
|
857
|
+
required: ["extensionId", "collection", "itemId", "data"],
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
run: async (args) => {
|
|
861
|
+
const extensionId = String(args?.extensionId ?? "").trim();
|
|
862
|
+
const collection = String(args?.collection ?? "").trim();
|
|
863
|
+
const itemId = String(args?.itemId ?? "").trim();
|
|
864
|
+
if (!extensionId || !collection || !itemId)
|
|
865
|
+
return "Error: extensionId, collection, and itemId are required.";
|
|
866
|
+
if (args?.data === undefined) return "Error: data is required.";
|
|
867
|
+
|
|
868
|
+
await ensureExtensionsTables();
|
|
869
|
+
const access = await resolveAccess("extension", extensionId);
|
|
870
|
+
if (!access || access.role === "viewer")
|
|
871
|
+
return `Error: editor access required for extension ${extensionId}.`;
|
|
872
|
+
|
|
873
|
+
const userEmail = getRequestUserEmail()?.toLowerCase() ?? "";
|
|
874
|
+
const scope = args?.scope === "org" ? "org" : "user";
|
|
875
|
+
const orgId = getRequestOrgId();
|
|
876
|
+
if (scope === "org" && !orgId)
|
|
877
|
+
return "Error: org context required for scope=org.";
|
|
878
|
+
|
|
879
|
+
const data =
|
|
880
|
+
typeof args.data === "string" ? args.data : JSON.stringify(args.data);
|
|
881
|
+
const MAX_BYTES = 1024 * 1024;
|
|
882
|
+
if (Buffer.byteLength(data, "utf8") > MAX_BYTES)
|
|
883
|
+
return `Error: data exceeds ${MAX_BYTES} byte limit. Store large payloads in file storage instead.`;
|
|
884
|
+
|
|
885
|
+
const now = new Date().toISOString();
|
|
886
|
+
const scopeKey = scope === "org" ? `org:${orgId}` : userEmail;
|
|
887
|
+
const client = getDbExec();
|
|
888
|
+
const pg = isPostgres();
|
|
889
|
+
const conflictClause = pg
|
|
890
|
+
? `ON CONFLICT (tool_id, collection, scope_key, item_id)
|
|
891
|
+
DO UPDATE SET data = EXCLUDED.data, updated_at = EXCLUDED.updated_at`
|
|
892
|
+
: `ON CONFLICT (tool_id, collection, scope_key, item_id)
|
|
893
|
+
DO UPDATE SET data = excluded.data, updated_at = excluded.updated_at`;
|
|
894
|
+
|
|
895
|
+
await client.execute({
|
|
896
|
+
sql: `UPDATE tools SET updated_at = ? WHERE id = ?`,
|
|
897
|
+
args: [now, extensionId],
|
|
898
|
+
});
|
|
899
|
+
await client.execute({
|
|
900
|
+
sql: `INSERT INTO tool_data (id, tool_id, collection, item_id, data, owner_email, scope, org_id, scope_key, created_at, updated_at)
|
|
901
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
902
|
+
${conflictClause}`,
|
|
903
|
+
args: [
|
|
904
|
+
randomUUID(),
|
|
905
|
+
extensionId,
|
|
906
|
+
collection,
|
|
907
|
+
itemId,
|
|
908
|
+
data,
|
|
909
|
+
userEmail,
|
|
910
|
+
scope,
|
|
911
|
+
scope === "org" ? orgId! : null,
|
|
912
|
+
scopeKey,
|
|
913
|
+
now,
|
|
914
|
+
now,
|
|
915
|
+
],
|
|
916
|
+
});
|
|
917
|
+
await notifyExtensionChangeForResource(extensionId);
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
ok: true,
|
|
921
|
+
id: itemId,
|
|
922
|
+
extensionId,
|
|
923
|
+
collection,
|
|
924
|
+
scope,
|
|
925
|
+
updatedAt: now,
|
|
926
|
+
};
|
|
927
|
+
},
|
|
928
|
+
},
|
|
929
|
+
|
|
930
|
+
"extension-data-get": {
|
|
931
|
+
tool: {
|
|
932
|
+
description:
|
|
933
|
+
"Read items from an extension's extensionData store (the tool_data table) from the agent side. Use this to inspect what data an extension currently has stored, or to verify a write succeeded. Requires viewer access to the extension.",
|
|
934
|
+
parameters: {
|
|
935
|
+
type: "object",
|
|
936
|
+
properties: {
|
|
937
|
+
extensionId: {
|
|
938
|
+
type: "string",
|
|
939
|
+
description: "Extension id whose data store to read from.",
|
|
940
|
+
},
|
|
941
|
+
collection: {
|
|
942
|
+
type: "string",
|
|
943
|
+
description: "Collection name within the extension's data store.",
|
|
944
|
+
},
|
|
945
|
+
itemId: {
|
|
946
|
+
type: "string",
|
|
947
|
+
description:
|
|
948
|
+
"Optional specific item id. If omitted, lists all items in the collection.",
|
|
949
|
+
},
|
|
950
|
+
scope: {
|
|
951
|
+
type: "string",
|
|
952
|
+
enum: ["user", "org", "all"],
|
|
953
|
+
description:
|
|
954
|
+
"Storage scope to read. 'user' (default) reads the current user's items; 'org' reads organization-shared items; 'all' reads both.",
|
|
955
|
+
},
|
|
956
|
+
limit: {
|
|
957
|
+
type: "number",
|
|
958
|
+
description:
|
|
959
|
+
"Maximum items to return when listing (default 100, max 1000).",
|
|
960
|
+
},
|
|
961
|
+
},
|
|
962
|
+
required: ["extensionId", "collection"],
|
|
963
|
+
},
|
|
964
|
+
},
|
|
965
|
+
run: async (args) => {
|
|
966
|
+
const extensionId = String(args?.extensionId ?? "").trim();
|
|
967
|
+
const collection = String(args?.collection ?? "").trim();
|
|
968
|
+
if (!extensionId || !collection)
|
|
969
|
+
return "Error: extensionId and collection are required.";
|
|
970
|
+
|
|
971
|
+
await ensureExtensionsTables();
|
|
972
|
+
const access = await resolveAccess("extension", extensionId);
|
|
973
|
+
if (!access) return `Error: no access to extension ${extensionId}.`;
|
|
974
|
+
|
|
975
|
+
const userEmail = getRequestUserEmail()?.toLowerCase() ?? "";
|
|
976
|
+
const scope = args?.scope ?? "user";
|
|
977
|
+
const orgId = getRequestOrgId();
|
|
978
|
+
if ((scope === "org" || scope === "all") && !orgId)
|
|
979
|
+
return "Error: org context required for scope=org or scope=all.";
|
|
980
|
+
const itemId = args?.itemId ? String(args.itemId).trim() : null;
|
|
981
|
+
const limit = Math.min(Math.max(1, Number(args?.limit) || 100), 1000);
|
|
982
|
+
const client = getDbExec();
|
|
983
|
+
|
|
984
|
+
if (itemId) {
|
|
985
|
+
const scopeClause =
|
|
986
|
+
scope === "org"
|
|
987
|
+
? `AND scope = 'org' AND org_id = ?`
|
|
988
|
+
: scope === "all"
|
|
989
|
+
? `AND ((scope = 'user' AND lower(owner_email) = ?) OR (scope = 'org' AND org_id = ?))`
|
|
990
|
+
: `AND scope = 'user' AND lower(owner_email) = ?`;
|
|
991
|
+
const scopeArgs =
|
|
992
|
+
scope === "org"
|
|
993
|
+
? [orgId ?? ""]
|
|
994
|
+
: scope === "all"
|
|
995
|
+
? [userEmail, orgId ?? ""]
|
|
996
|
+
: [userEmail];
|
|
997
|
+
|
|
998
|
+
const result = await client.execute({
|
|
999
|
+
sql: `SELECT COALESCE(item_id, id) AS id, data, scope, owner_email, updated_at
|
|
1000
|
+
FROM tool_data
|
|
1001
|
+
WHERE tool_id = ? AND collection = ? AND COALESCE(item_id, id) = ? ${scopeClause}`,
|
|
1002
|
+
args: [extensionId, collection, itemId, ...scopeArgs],
|
|
1003
|
+
});
|
|
1004
|
+
const row = result.rows?.[0];
|
|
1005
|
+
if (!row) return { found: false, extensionId, collection, itemId };
|
|
1006
|
+
return { found: true, ...row };
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
const scopeClause =
|
|
1010
|
+
scope === "org"
|
|
1011
|
+
? `AND scope = 'org' AND org_id = ?`
|
|
1012
|
+
: scope === "all"
|
|
1013
|
+
? `AND ((scope = 'user' AND lower(owner_email) = ?) OR (scope = 'org' AND org_id = ?))`
|
|
1014
|
+
: `AND scope = 'user' AND lower(owner_email) = ?`;
|
|
1015
|
+
const scopeArgs =
|
|
1016
|
+
scope === "org"
|
|
1017
|
+
? [orgId ?? ""]
|
|
1018
|
+
: scope === "all"
|
|
1019
|
+
? [userEmail, orgId ?? ""]
|
|
1020
|
+
: [userEmail];
|
|
1021
|
+
|
|
1022
|
+
const result = await client.execute({
|
|
1023
|
+
sql: `SELECT COALESCE(item_id, id) AS id, data, scope, owner_email, updated_at
|
|
1024
|
+
FROM tool_data
|
|
1025
|
+
WHERE tool_id = ? AND collection = ? ${scopeClause}
|
|
1026
|
+
ORDER BY updated_at DESC
|
|
1027
|
+
LIMIT ?`,
|
|
1028
|
+
args: [extensionId, collection, ...scopeArgs, limit],
|
|
1029
|
+
});
|
|
1030
|
+
return {
|
|
1031
|
+
extensionId,
|
|
1032
|
+
collection,
|
|
1033
|
+
scope,
|
|
1034
|
+
count: result.rows?.length ?? 0,
|
|
1035
|
+
items: result.rows ?? [],
|
|
1036
|
+
};
|
|
1037
|
+
},
|
|
1038
|
+
},
|
|
1039
|
+
|
|
821
1040
|
"delete-extension": {
|
|
822
1041
|
tool: {
|
|
823
1042
|
description:
|
|
@@ -153,6 +153,25 @@ persistence** — it handles everything automatically. Only use
|
|
|
153
153
|
`dbQuery`/`dbExec` when querying the app's existing tables. See
|
|
154
154
|
`references/api.md` for the full `get`/`remove`/scope reference.
|
|
155
155
|
|
|
156
|
+
### Agent-side extension data access
|
|
157
|
+
|
|
158
|
+
The agent can read and write `extensionData` directly using two dedicated
|
|
159
|
+
actions — no need to go through the iframe bridge or raw SQL:
|
|
160
|
+
|
|
161
|
+
| Action | Purpose |
|
|
162
|
+
| --------------------- | ------------------------------------------------- |
|
|
163
|
+
| `extension-data-set` | Upsert an item in an extension's data store |
|
|
164
|
+
| `extension-data-get` | Read items from an extension's data store |
|
|
165
|
+
|
|
166
|
+
Use `extension-data-set` when the agent needs to seed, refresh, or update
|
|
167
|
+
data that an extension reads at render time via `extensionData.get()`. This
|
|
168
|
+
is the correct path for agent-driven dashboard refreshes — the agent
|
|
169
|
+
fetches fresh data from providers, then writes the merged result with
|
|
170
|
+
`extension-data-set`, and the extension picks it up on next load.
|
|
171
|
+
|
|
172
|
+
Use `extension-data-get` to inspect what data an extension currently stores,
|
|
173
|
+
or to verify a write succeeded.
|
|
174
|
+
|
|
156
175
|
## What extensions are
|
|
157
176
|
|
|
158
177
|
Extensions are mini Alpine.js apps that run inside sandboxed iframes. They
|