@gea-ai/extensions-sdk 0.1.260514-alpha → 0.1.260706-alpha.1
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 +259 -28
- package/dist/actions.d.ts +34 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +50 -0
- package/dist/actions.js.map +1 -0
- package/dist/backend.d.ts +159 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +16 -0
- package/dist/backend.js.map +1 -0
- package/dist/context.d.ts +45 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +115 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +51 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +147 -0
- package/dist/react.js.map +1 -0
- package/dist/tables.d.ts +120 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +99 -0
- package/dist/tables.js.map +1 -0
- package/dist/ui.d.ts +131 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +222 -4
- package/dist/ui.js.map +1 -1
- package/package.json +28 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Public frontend SDK for GEA extensions.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npm install @gea-ai/extensions-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
When testing unpublished SDK changes from this repository, build the SDK and
|
|
@@ -13,50 +13,281 @@ link the workspace package from the standalone extension repo:
|
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
pnpm --filter @gea-ai/extensions-sdk build
|
|
16
|
-
|
|
16
|
+
npm install @gea-ai/extensions-sdk@file:/path/to/gea/packages/extensions-sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Minimal Shape
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import {
|
|
23
|
+
document,
|
|
23
24
|
defineExtension,
|
|
24
|
-
|
|
25
|
+
field,
|
|
26
|
+
table,
|
|
27
|
+
wiki,
|
|
25
28
|
} from "@gea-ai/extensions-sdk";
|
|
26
|
-
import { sdk } from "@gea-ai/extensions-sdk/ui";
|
|
27
|
-
import { z } from "zod";
|
|
28
29
|
|
|
29
|
-
const
|
|
30
|
+
export const extensionDeclaration = defineExtension({
|
|
31
|
+
frontend: {
|
|
32
|
+
entry: "src/index.tsx",
|
|
33
|
+
},
|
|
34
|
+
name: "Customer Research",
|
|
35
|
+
resources: {
|
|
36
|
+
workspace: wiki({
|
|
37
|
+
children: {
|
|
38
|
+
notes: table({
|
|
39
|
+
fields: {
|
|
40
|
+
note: field.text({
|
|
41
|
+
indexed: true,
|
|
42
|
+
required: true,
|
|
43
|
+
title: "Note",
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
title: "Notes",
|
|
47
|
+
}),
|
|
48
|
+
summary: document({
|
|
49
|
+
initialContent: {
|
|
50
|
+
format: "markdown",
|
|
51
|
+
markdown: "# Customer Research Summary\n",
|
|
52
|
+
},
|
|
53
|
+
title: "Summary",
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
title: "Customer Research",
|
|
57
|
+
visibility: "workspace",
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
slug: "customer-research",
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// src/extension-runtime.ts
|
|
66
|
+
import { createExtensionRuntime } from "@gea-ai/extensions-sdk/react";
|
|
67
|
+
import extensionDeclaration from "../gea.extension";
|
|
30
68
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
69
|
+
export const { mount, useExtensionApp, useLocale, useTranslations } =
|
|
70
|
+
createExtensionRuntime({
|
|
71
|
+
declaration: extensionDeclaration,
|
|
34
72
|
});
|
|
73
|
+
```
|
|
35
74
|
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
```tsx
|
|
76
|
+
// src/index.tsx
|
|
77
|
+
import { useExtensionApp } from "./extension-runtime";
|
|
38
78
|
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
}
|
|
79
|
+
export default function CustomerResearch() {
|
|
80
|
+
const app = useExtensionApp();
|
|
42
81
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
82
|
+
async function submitNote(note: string) {
|
|
83
|
+
await app.resources.notes.records.create({
|
|
84
|
+
note,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return <button onClick={() => void submitNote("Follow up")}>Add</button>;
|
|
89
|
+
}
|
|
51
90
|
```
|
|
52
91
|
|
|
53
92
|
Frontend code calls host APIs through SDK helpers. The SDK uses the GEA host
|
|
54
93
|
`postMessage` bridge by default, so extension authors do not need to write
|
|
55
94
|
message plumbing or know the host ORPC transport.
|
|
56
95
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
## Actions And Backend Packages
|
|
97
|
+
|
|
98
|
+
Curated backend-capable extension packages can share one typed action contract
|
|
99
|
+
between frontend and backend code. The frontend calls the host transport, while
|
|
100
|
+
the backend exports handlers that the host loads through ORPC after install,
|
|
101
|
+
membership, and runtime resource checks.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
// src/contract.ts
|
|
105
|
+
import { defineActions } from "@gea-ai/extensions-sdk/actions";
|
|
106
|
+
import z from "zod";
|
|
107
|
+
|
|
108
|
+
export const actions = defineActions({
|
|
109
|
+
ping: {
|
|
110
|
+
inputSchema: z.object({ value: z.string() }),
|
|
111
|
+
outputSchema: z.object({ echoed: z.string() }),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
// src/backend/index.ts
|
|
118
|
+
import { defineBackendActions } from "@gea-ai/extensions-sdk/backend";
|
|
119
|
+
import { actions } from "../contract";
|
|
120
|
+
|
|
121
|
+
export const backend = defineBackendActions(actions, {
|
|
122
|
+
ping: async ({ input }) => ({ echoed: input.value }),
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
// src/frontend/index.tsx
|
|
128
|
+
import {
|
|
129
|
+
createExtensionActionClient,
|
|
130
|
+
type ExtensionActionTransport,
|
|
131
|
+
} from "@gea-ai/extensions-sdk/actions";
|
|
132
|
+
import { actions } from "../contract";
|
|
133
|
+
|
|
134
|
+
declare const callExtensionAction: ExtensionActionTransport;
|
|
135
|
+
|
|
136
|
+
const client = createExtensionActionClient({
|
|
137
|
+
actions,
|
|
138
|
+
extensionSlug: "example-extension",
|
|
139
|
+
transport: callExtensionAction,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
await client.call("ping", { value: "hello" });
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
M1 backend actions run through a trusted in-process executor for curated
|
|
146
|
+
marketplace packages. Arbitrary hosted third-party backend execution still
|
|
147
|
+
requires the future sandbox executor; hosted extension uploads reject backend
|
|
148
|
+
declarations for now. Remote marketplace backend files are checked against
|
|
149
|
+
manifest `sha256` and `sizeBytes` metadata before import, and the host dispatches
|
|
150
|
+
only declaration-listed backend actions when the installed manifest declares
|
|
151
|
+
them. The public backend SDK surface is intentionally narrow:
|
|
152
|
+
|
|
153
|
+
- `sdk.state.records.*` for extension-private workflow state.
|
|
154
|
+
- `sdk.connectors.execute(...)` for host-managed connector calls.
|
|
155
|
+
- `sdk.artifacts.path(...)`, `writeText(...)`, and `writeJson(...)` for
|
|
156
|
+
extension artifacts.
|
|
157
|
+
- `sdk.resources.records.create/update(...)` and
|
|
158
|
+
`sdk.resources.documents.update(...)` for declared GEA resources.
|
|
159
|
+
- `sdk.agents.<handle>.run(...)` for declared nested agents.
|
|
160
|
+
|
|
161
|
+
Any broader host helpers are reserved for internal built-in workflows and are
|
|
162
|
+
not a third-party SDK contract.
|
|
163
|
+
|
|
164
|
+
`state.records.update({ data })` merges the provided object into the existing
|
|
165
|
+
record data. Use this for partial progress updates; model full replacement as a
|
|
166
|
+
future explicit API if an extension needs it.
|
|
167
|
+
|
|
168
|
+
Backend actions execute external systems through host-managed connectors:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const result = await sdk.connectors.execute({
|
|
172
|
+
connector: "bocha-search",
|
|
173
|
+
params: {
|
|
174
|
+
method: "GET",
|
|
175
|
+
operation: "request",
|
|
176
|
+
path: "/search",
|
|
177
|
+
query: { q: "consumer trend" },
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Connector credentials are resolved by normal GEA connector credential scope
|
|
183
|
+
rules. Extensions should declare every connector dependency in
|
|
184
|
+
`connectorRequirements` so install and setup flows can surface missing
|
|
185
|
+
connectors or credentials before backend actions run. Provider-specific request
|
|
186
|
+
details should live in API, MCP, or native connector implementations; backend
|
|
187
|
+
actions should call those connectors instead of embedding provider credentials or
|
|
188
|
+
direct network integration code.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
export const extensionDeclaration = defineExtension({
|
|
192
|
+
// ...
|
|
193
|
+
connectorRequirements: [
|
|
194
|
+
{
|
|
195
|
+
slug: "bocha-search",
|
|
196
|
+
source: { type: "app_resource", slug: "bocha-search" },
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
slug: "wechat-official-account",
|
|
200
|
+
source: {
|
|
201
|
+
type: "builtin_connector",
|
|
202
|
+
slug: "wechat-official-account",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Installed extension summaries expose each declared connector as `connected`,
|
|
210
|
+
`missing_connector`, or `missing_credentials`. Backend action dispatch preflights
|
|
211
|
+
the same setup state before creating the connector runtime and fails with
|
|
212
|
+
`connector_setup_required` when setup is incomplete.
|
|
213
|
+
|
|
214
|
+
## Host Context, Theme, And Locale
|
|
215
|
+
|
|
216
|
+
The local-dev host sends a `host-context` message to the extension iframe on
|
|
217
|
+
load and when the host document theme or locale attributes change. React
|
|
218
|
+
extensions should normally use `createExtensionRuntime` from
|
|
219
|
+
`@gea-ai/extensions-sdk/react`; it wires host-context sync into
|
|
220
|
+
`ExtensionRuntimeProvider` and exposes:
|
|
221
|
+
|
|
222
|
+
- `useExtensionApp()` for the typed host SDK client and resolved resource
|
|
223
|
+
handles.
|
|
224
|
+
- `useLocale()` for the current resolved locale.
|
|
225
|
+
- `useTranslations(namespace)` for extension-owned local dictionaries.
|
|
226
|
+
- `mount(Component)` for rendering the default no-props React component into
|
|
227
|
+
`#root`.
|
|
228
|
+
|
|
229
|
+
The context includes `locale`, text direction, resolved color scheme, resolved
|
|
230
|
+
theme, and CSS custom properties such as `--background`, `--foreground`, and
|
|
231
|
+
`--border`. The CLI scaffold wires this into `src/extension-runtime.ts`,
|
|
232
|
+
includes a small local i18n dictionary, and configures Tailwind CSS so utilities like
|
|
233
|
+
`bg-background`, `text-foreground`, and `border-border` follow the host theme.
|
|
234
|
+
Extension messages remain extension-owned; the host only supplies the active
|
|
235
|
+
locale.
|
|
236
|
+
|
|
237
|
+
## Upload And Publish
|
|
238
|
+
|
|
239
|
+
Use `gea ext package` for local package inspection, then `gea ext deploy` to
|
|
240
|
+
upload the package to the hosted server as an extension app-resource draft.
|
|
241
|
+
Deployment does not publish. Review and publish that app resource from the GEA
|
|
242
|
+
web UI, using the same lifecycle as other app resources.
|
|
243
|
+
|
|
244
|
+
The app-resource publish version is the canonical hosted version.
|
|
245
|
+
`gea.extension.ts` version metadata is stored in the normalized manifest as package
|
|
246
|
+
metadata. Published extension frontend assets are served by the host through a
|
|
247
|
+
sandboxed iframe asset route, and SDK calls still go through the same
|
|
248
|
+
postMessage bridge.
|
|
249
|
+
|
|
250
|
+
## Resource Handles
|
|
251
|
+
|
|
252
|
+
Extensions declare durable resources in `defineExtension`. Draft uploads store
|
|
253
|
+
the normalized declaration only. Publishing and local-dev registration provision
|
|
254
|
+
real GEA resources and bind them to the extension scope. The iframe URL carries
|
|
255
|
+
only extension identity. The host sends `lifecycle.stage = "ready"` plus
|
|
256
|
+
resolved resource handles through the host-context postMessage, and the React
|
|
257
|
+
runtime exposes them as typed `app.resources` when the frontend uses
|
|
258
|
+
`useExtensionApp()` from a runtime created with the declaration.
|
|
259
|
+
|
|
260
|
+
Use those handles for extension-owned durable data:
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
await app.resources.notes.records.create({
|
|
264
|
+
note: "Follow up with the design team",
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The full demo lives at `examples/research-queue` in the GEA repo. It declares a
|
|
269
|
+
workspace-visible extension wiki, stores submitted URLs in a declared context
|
|
270
|
+
table inside that wiki, declares one aggregate summary document next to the
|
|
271
|
+
table, and starts a hosted agent task with only the resolved table and document
|
|
272
|
+
locations in the prompt.
|
|
273
|
+
|
|
274
|
+
Third-party iframe extensions should not persist private UI state through
|
|
275
|
+
production `extension_record`. Use browser-local or dev-runtime-local state for
|
|
276
|
+
UI-only state. Durable user-visible data should be modeled as declared GEA
|
|
277
|
+
resources so users and admins can inspect, recover, export, permission, and
|
|
278
|
+
delete it through normal resource flows.
|
|
279
|
+
|
|
280
|
+
Current table APIs are not yet optimized for large database workloads. Treat
|
|
281
|
+
10k to 100k row scenarios, server-side filtering/sorting, relation joins, and
|
|
282
|
+
benchmarks as a separate table performance track.
|
|
283
|
+
|
|
284
|
+
The root SDK avoids private monorepo imports so extension projects can
|
|
285
|
+
type-check and build outside the GEA monorepo. Public context resource result
|
|
286
|
+
types are exported from `@gea-ai/extensions-sdk/context`. The portable schemas
|
|
287
|
+
and TypeScript types are owned by `@gea-ai/contract` and re-exported by the SDK.
|
|
288
|
+
|
|
289
|
+
Local-dev extensions are trusted developer code. They do not declare manifest
|
|
290
|
+
permissions yet. The host bridge exposes only curated SDK methods, but it does
|
|
291
|
+
not enforce extension-specific grants. SDK calls run as the current signed-in
|
|
292
|
+
user and remain constrained by normal hosted ORPC user, workspace, and resource
|
|
293
|
+
permissions.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type QueryKey, type UseMutationOptions, type UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import type z from "zod";
|
|
3
|
+
export type ExtensionActionContract<TInput = unknown, TOutput = unknown> = {
|
|
4
|
+
inputSchema: z.ZodType<TInput>;
|
|
5
|
+
outputSchema: z.ZodType<TOutput>;
|
|
6
|
+
};
|
|
7
|
+
type AnyExtensionActionContract = ExtensionActionContract<any, any>;
|
|
8
|
+
type ExtensionActionsInput = Record<string, AnyExtensionActionContract>;
|
|
9
|
+
export type ExtensionActionInput<TActions extends ExtensionActionsInput, TAction extends keyof TActions> = TActions[TAction] extends ExtensionActionContract<infer TInput> ? TInput : never;
|
|
10
|
+
export type ExtensionActionOutput<TActions extends ExtensionActionsInput, TAction extends keyof TActions> = TActions[TAction] extends ExtensionActionContract<any, infer TOutput> ? TOutput : never;
|
|
11
|
+
export type ExtensionActionTransport = (input: {
|
|
12
|
+
action: string;
|
|
13
|
+
extensionSlug: string;
|
|
14
|
+
input: unknown;
|
|
15
|
+
}) => Promise<unknown>;
|
|
16
|
+
export declare function defineActions<const TActions extends Record<string, AnyExtensionActionContract>>(actions: TActions): TActions;
|
|
17
|
+
export declare function createExtensionActionClient<const TActions extends ExtensionActionsInput>(input: {
|
|
18
|
+
actions: TActions;
|
|
19
|
+
extensionSlug: string;
|
|
20
|
+
transport: ExtensionActionTransport;
|
|
21
|
+
}): {
|
|
22
|
+
call: <const TAction extends keyof TActions & string>(action: TAction, inputValue: ExtensionActionInput<TActions, TAction>) => Promise<ExtensionActionOutput<TActions, TAction>>;
|
|
23
|
+
mutationOptions<const TAction extends keyof TActions & string, TInput extends ExtensionActionInput<TActions, TAction> = ExtensionActionInput<TActions, TAction>, TOutput extends ExtensionActionOutput<TActions, TAction> = ExtensionActionOutput<TActions, TAction>>(action: TAction, options?: Omit<UseMutationOptions<TOutput, Error, TInput, unknown>, "mutationFn" | "mutationKey">): import("@tanstack/react-query").WithRequired<UseMutationOptions<TOutput, Error, TInput, unknown>, "mutationKey">;
|
|
24
|
+
queryOptions<const TAction extends keyof TActions & string, TInput extends ExtensionActionInput<TActions, TAction> = ExtensionActionInput<TActions, TAction>, TOutput extends ExtensionActionOutput<TActions, TAction> = ExtensionActionOutput<TActions, TAction>>(action: TAction, inputValue: TInput, options?: Omit<UseQueryOptions<TOutput, Error, TOutput, QueryKey>, "queryFn" | "queryKey">): import("@tanstack/react-query").OmitKeyof<UseQueryOptions<TOutput, Error, TOutput, readonly unknown[]>, "queryFn"> & {
|
|
25
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<TOutput, readonly unknown[], never> | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
queryKey: readonly unknown[] & {
|
|
28
|
+
[dataTagSymbol]: TOutput;
|
|
29
|
+
[dataTagErrorSymbol]: Error;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,MAAM,uBAAuB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IACzE,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC,CAAC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AC7C,MAAM,SAAS,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,4CAEtD,OAAO,SAAS,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,qDAGhD,OAAO,YACL,IAAI,CACZ,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EACnD,YAAY,GAAG,aAAa,CAC7B;uBAiBK,OAAO,SAAS,MAAM,QAAQ,GAAG,MAAM,EAC7C,MAAM,SAAS,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,4CAEtD,OAAO,SAAS,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,qDAGhD,OAAO,cACH,MAAM,YACR,IAAI,CACZ,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAClD,SAAS,GAAG,UAAU,CACvB;;;;;;;;EAmBN"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { mutationOptions as createTanStackMutationOptions, queryOptions as createTanStackQueryOptions, } from "@tanstack/react-query";
|
|
2
|
+
export function defineActions(actions) {
|
|
3
|
+
return actions;
|
|
4
|
+
}
|
|
5
|
+
export function createExtensionActionClient(input) {
|
|
6
|
+
const { actions, extensionSlug, transport } = input;
|
|
7
|
+
async function call(action, inputValue) {
|
|
8
|
+
const actionContract = actions[action];
|
|
9
|
+
const parsedInput = actionContract.inputSchema.parse(inputValue);
|
|
10
|
+
const result = await transport({
|
|
11
|
+
action,
|
|
12
|
+
extensionSlug,
|
|
13
|
+
input: parsedInput,
|
|
14
|
+
});
|
|
15
|
+
return actionContract.outputSchema.parse(result);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
call,
|
|
19
|
+
mutationOptions(action, options) {
|
|
20
|
+
const mutationKey = [
|
|
21
|
+
"extension",
|
|
22
|
+
extensionSlug,
|
|
23
|
+
"action",
|
|
24
|
+
action,
|
|
25
|
+
];
|
|
26
|
+
return createTanStackMutationOptions({
|
|
27
|
+
...options,
|
|
28
|
+
mutationFn: (inputValue) => call(action, inputValue),
|
|
29
|
+
mutationKey,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
queryOptions(action, inputValue, options) {
|
|
33
|
+
const actionContract = actions[action];
|
|
34
|
+
const parsedInput = actionContract.inputSchema.parse(inputValue);
|
|
35
|
+
const queryKey = [
|
|
36
|
+
"extension",
|
|
37
|
+
extensionSlug,
|
|
38
|
+
"action",
|
|
39
|
+
action,
|
|
40
|
+
parsedInput,
|
|
41
|
+
];
|
|
42
|
+
return createTanStackQueryOptions({
|
|
43
|
+
...options,
|
|
44
|
+
queryFn: () => call(action, parsedInput),
|
|
45
|
+
queryKey,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,IAAI,6BAA6B,EAChD,YAAY,IAAI,0BAA0B,GAI3C,MAAM,uBAAuB,CAAC;AAkC/B,MAAM,UAAU,aAAa,CAE3B,OAAiB;IACjB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAEzC,KAID;IACC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAEpD,KAAK,UAAU,IAAI,CACjB,MAAe,EACf,UAAmD;QAEnD,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;YAC7B,MAAM;YACN,aAAa;YACb,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,IAAI;QACJ,eAAe,CAOb,MAAe,EACf,OAGC;YAED,MAAM,WAAW,GAAG;gBAClB,WAAW;gBACX,aAAa;gBACb,QAAQ;gBACR,MAAM;aACqB,CAAC;YAE9B,OAAO,6BAA6B,CAAC;gBACnC,GAAG,OAAO;gBACV,UAAU,EAAE,CAAC,UAAkB,EAAE,EAAE,CACjC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAqB;gBAC9C,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;QACD,YAAY,CAOV,MAAe,EACf,UAAkB,EAClB,OAGC;YAED,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG;gBACf,WAAW;gBACX,aAAa;gBACb,QAAQ;gBACR,MAAM;gBACN,WAAW;aACgB,CAAC;YAE9B,OAAO,0BAA0B,CAAC;gBAChC,GAAG,OAAO;gBACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAqB;gBAC5D,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { ExtensionResolvedResource } from "@gea-ai/contract/extensions";
|
|
2
|
+
import type z from "zod";
|
|
3
|
+
import type { ExtensionActionContract, ExtensionActionInput, ExtensionActionOutput } from "./actions";
|
|
4
|
+
import type { ExtensionDocumentContentInput, ExtensionTableRecord } from "./tables";
|
|
5
|
+
type AnyExtensionActionContract = ExtensionActionContract<any, any>;
|
|
6
|
+
type ExtensionActionsInput = Record<string, AnyExtensionActionContract>;
|
|
7
|
+
export type ExtensionBackendStateRecord<TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
8
|
+
createdAt: string;
|
|
9
|
+
data: TData;
|
|
10
|
+
id: string;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
ownerId: string | null;
|
|
13
|
+
recordKey: string;
|
|
14
|
+
recordType: string;
|
|
15
|
+
status: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
};
|
|
18
|
+
export type ExtensionBackendStateRecordsClient = {
|
|
19
|
+
create<TData extends Record<string, unknown>>(input: {
|
|
20
|
+
data: TData;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
ownerId?: string | null;
|
|
23
|
+
recordKey?: string;
|
|
24
|
+
recordType: string;
|
|
25
|
+
status?: string;
|
|
26
|
+
}): Promise<ExtensionBackendStateRecord<TData>>;
|
|
27
|
+
get<TData extends Record<string, unknown>>(input: {
|
|
28
|
+
id: string;
|
|
29
|
+
recordType: string;
|
|
30
|
+
}): Promise<ExtensionBackendStateRecord<TData> | null>;
|
|
31
|
+
list<TData extends Record<string, unknown>>(input: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
recordType: string;
|
|
34
|
+
}): Promise<Array<ExtensionBackendStateRecord<TData>>>;
|
|
35
|
+
update<TData extends Record<string, unknown>>(input: {
|
|
36
|
+
data?: Partial<TData>;
|
|
37
|
+
id: string;
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
status?: string;
|
|
40
|
+
}): Promise<ExtensionBackendStateRecord<TData>>;
|
|
41
|
+
};
|
|
42
|
+
export type ExtensionBackendArtifactsClient = {
|
|
43
|
+
path(...segments: string[]): string;
|
|
44
|
+
readJson<TOutput>(input: {
|
|
45
|
+
chatId: string;
|
|
46
|
+
maxCharacters?: number;
|
|
47
|
+
path: string;
|
|
48
|
+
schema: z.ZodType<TOutput>;
|
|
49
|
+
}): Promise<TOutput>;
|
|
50
|
+
readText(input: {
|
|
51
|
+
chatId: string;
|
|
52
|
+
maxCharacters?: number;
|
|
53
|
+
path: string;
|
|
54
|
+
}): Promise<string>;
|
|
55
|
+
writeJson(input: {
|
|
56
|
+
data: unknown;
|
|
57
|
+
path: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
path: string;
|
|
60
|
+
sizeBytes: number;
|
|
61
|
+
}>;
|
|
62
|
+
writeText(input: {
|
|
63
|
+
content: string;
|
|
64
|
+
path: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
path: string;
|
|
67
|
+
sizeBytes: number;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
export type ExtensionBackendConnectorExecuteInput = {
|
|
71
|
+
connector: string;
|
|
72
|
+
params: unknown;
|
|
73
|
+
requestId?: string;
|
|
74
|
+
resourceSnapshot?: Record<string, unknown>;
|
|
75
|
+
};
|
|
76
|
+
export type ExtensionBackendConnectorResult = {
|
|
77
|
+
connector: string;
|
|
78
|
+
data?: unknown;
|
|
79
|
+
ok: boolean;
|
|
80
|
+
} & Record<string, unknown>;
|
|
81
|
+
export type ExtensionBackendConnectorsClient = {
|
|
82
|
+
execute(input: ExtensionBackendConnectorExecuteInput): Promise<ExtensionBackendConnectorResult>;
|
|
83
|
+
};
|
|
84
|
+
export type ExtensionBackendResourcesClient = {
|
|
85
|
+
documents: {
|
|
86
|
+
update(input: {
|
|
87
|
+
content: ExtensionDocumentContentInput;
|
|
88
|
+
resourceKey: string;
|
|
89
|
+
}): Promise<unknown>;
|
|
90
|
+
};
|
|
91
|
+
records: {
|
|
92
|
+
create<TData extends Record<string, unknown>>(input: {
|
|
93
|
+
data: TData;
|
|
94
|
+
resourceKey: string;
|
|
95
|
+
scopeResourceId?: string | null;
|
|
96
|
+
}): Promise<ExtensionTableRecord<TData>>;
|
|
97
|
+
update<TData extends Record<string, unknown>>(input: {
|
|
98
|
+
data: Partial<TData>;
|
|
99
|
+
recordId: string;
|
|
100
|
+
resourceKey: string;
|
|
101
|
+
scopeResourceId?: string | null;
|
|
102
|
+
}): Promise<ExtensionTableRecord<TData>>;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export type ExtensionBackendAgentRunInput = {
|
|
106
|
+
chatId?: string;
|
|
107
|
+
message: string;
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
onSettledAction?: {
|
|
110
|
+
action: string;
|
|
111
|
+
input: Record<string, unknown>;
|
|
112
|
+
};
|
|
113
|
+
visibility?: "hidden" | "visible";
|
|
114
|
+
};
|
|
115
|
+
export type ExtensionBackendAgentHandle = {
|
|
116
|
+
run(input: ExtensionBackendAgentRunInput): Promise<{
|
|
117
|
+
agentRunId: string;
|
|
118
|
+
chatId: string;
|
|
119
|
+
}>;
|
|
120
|
+
};
|
|
121
|
+
export type ExtensionBackendSdk = {
|
|
122
|
+
agents: Record<string, ExtensionBackendAgentHandle>;
|
|
123
|
+
artifacts: ExtensionBackendArtifactsClient;
|
|
124
|
+
connectors: ExtensionBackendConnectorsClient;
|
|
125
|
+
resources: ExtensionBackendResourcesClient;
|
|
126
|
+
state: {
|
|
127
|
+
records: ExtensionBackendStateRecordsClient;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export type ExtensionBackendActionContext = {
|
|
131
|
+
extension: {
|
|
132
|
+
appResourceId: string;
|
|
133
|
+
resources: ExtensionResolvedResource[];
|
|
134
|
+
};
|
|
135
|
+
organizationId: string;
|
|
136
|
+
principalUserId: string;
|
|
137
|
+
workspaceId: string;
|
|
138
|
+
};
|
|
139
|
+
export type ExtensionBackendActionHandlerInput<TInput, TSdk> = {
|
|
140
|
+
context: ExtensionBackendActionContext;
|
|
141
|
+
input: TInput;
|
|
142
|
+
sdk: TSdk;
|
|
143
|
+
};
|
|
144
|
+
export type ExtensionBackendHandlers<TActions extends ExtensionActionsInput, TSdk> = {
|
|
145
|
+
[TAction in keyof TActions & string]: (input: ExtensionBackendActionHandlerInput<ExtensionActionInput<TActions, TAction>, TSdk>) => ExtensionActionOutput<TActions, TAction> | Promise<ExtensionActionOutput<TActions, TAction>>;
|
|
146
|
+
};
|
|
147
|
+
export type ExtensionBackendActionDefinition<TInput = unknown, TOutput = unknown, TSdk = ExtensionBackendSdk> = {
|
|
148
|
+
handler: (input: ExtensionBackendActionHandlerInput<TInput, TSdk>) => Promise<TOutput>;
|
|
149
|
+
inputSchema: z.ZodType<TInput>;
|
|
150
|
+
outputSchema: z.ZodType<TOutput>;
|
|
151
|
+
};
|
|
152
|
+
export type ExtensionBackendDefinition<TActions extends ExtensionActionsInput, TSdk = ExtensionBackendSdk> = {
|
|
153
|
+
actions: {
|
|
154
|
+
[TAction in keyof TActions & string]: ExtensionBackendActionDefinition<ExtensionActionInput<TActions, TAction>, ExtensionActionOutput<TActions, TAction>, TSdk>;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
export declare function defineBackendActions<const TActions extends ExtensionActionsInput, TSdk = ExtensionBackendSdk>(actions: TActions, handlers: ExtensionBackendHandlers<TActions, TSdk>): ExtensionBackendDefinition<TActions, TSdk>;
|
|
158
|
+
export {};
|
|
159
|
+
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,6BAA6B,EAC7B,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB,KAAK,0BAA0B,GAAG,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACpE,KAAK,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;AAExE,MAAM,MAAM,2BAA2B,CACrC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC7D;IACF,SAAS,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ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function defineBackendActions(actions, handlers) {
|
|
2
|
+
const backendActions = {};
|
|
3
|
+
for (const action of Object.keys(actions)) {
|
|
4
|
+
const actionContract = actions[action];
|
|
5
|
+
const handler = handlers[action];
|
|
6
|
+
backendActions[action] = {
|
|
7
|
+
handler: async (handlerInput) => actionContract.outputSchema.parse(await handler(handlerInput)),
|
|
8
|
+
inputSchema: actionContract.inputSchema,
|
|
9
|
+
outputSchema: actionContract.outputSchema,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
actions: backendActions,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAyMA,MAAM,UAAU,oBAAoB,CAIlC,OAAiB,EACjB,QAAkD;IAElD,MAAM,cAAc,GAGhB,EAAE,CAAC;IAEP,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEjC,cAAc,CAAC,MAAM,CAAC,GAAG;YACvB,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAC9B,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;YAChE,WAAW,EAAE,cAAc,CAAC,WAAW;YACvC,YAAY,EAAE,cAAc,CAAC,YAAY;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,cAAc;KACsB,CAAC;AAClD,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -4,6 +4,50 @@ export type ExtensionSdkListContextResourceChildrenInput = ListContextResourceCh
|
|
|
4
4
|
export type ExtensionSdkListContextResourceChildrenOutput = ListContextResourceChildrenOutput;
|
|
5
5
|
export type ExtensionContextResourceListChildren = OrpcContractsContextResourceListChildren;
|
|
6
6
|
export type ExtensionContextResourcesClient = OrpcContractsContextResourcesClient;
|
|
7
|
+
export type ExtensionDocumentContentInput = {
|
|
8
|
+
format: "markdown";
|
|
9
|
+
markdown: string;
|
|
10
|
+
} | {
|
|
11
|
+
format: "plainText";
|
|
12
|
+
text: string;
|
|
13
|
+
} | {
|
|
14
|
+
doc: unknown;
|
|
15
|
+
format: "tiptapJson";
|
|
16
|
+
};
|
|
17
|
+
export type ExtensionDocumentOutputFormat = "markdown" | "plainText" | "tiptapJson";
|
|
18
|
+
type AwaitedMethodReturn<TMethod> = TMethod extends (...args: never[]) => infer TReturn ? Awaited<TReturn> : never;
|
|
19
|
+
type ExtensionContextDocument = AwaitedMethodReturn<OrpcContractsContextClient["documents"]["get"]>;
|
|
20
|
+
export type ExtensionDocumentContentForFormat<TFormat extends ExtensionDocumentOutputFormat | undefined> = TFormat extends "markdown" ? Extract<ExtensionDocumentContentInput, {
|
|
21
|
+
format: "markdown";
|
|
22
|
+
}> : TFormat extends "plainText" ? Extract<ExtensionDocumentContentInput, {
|
|
23
|
+
format: "plainText";
|
|
24
|
+
}> : TFormat extends "tiptapJson" ? Extract<ExtensionDocumentContentInput, {
|
|
25
|
+
format: "tiptapJson";
|
|
26
|
+
}> : unknown;
|
|
27
|
+
export type ExtensionDocument<TBody = unknown> = Omit<ExtensionContextDocument, "body"> & {
|
|
28
|
+
body: TBody;
|
|
29
|
+
};
|
|
30
|
+
export type ExtensionDocumentForFormat<TFormat extends ExtensionDocumentOutputFormat | undefined = undefined> = ExtensionDocument<ExtensionDocumentContentForFormat<TFormat>>;
|
|
31
|
+
export type ExtensionContextDocumentsClient = Omit<Pick<OrpcContractsContextClient["documents"], "create" | "get" | "getByPath" | "update">, "get" | "getByPath"> & {
|
|
32
|
+
get<TFormat extends ExtensionDocumentOutputFormat | undefined = undefined>(input: {
|
|
33
|
+
format?: TFormat;
|
|
34
|
+
resourceId: string;
|
|
35
|
+
}): Promise<ExtensionDocumentForFormat<TFormat>>;
|
|
36
|
+
getByPath<TFormat extends ExtensionDocumentOutputFormat | undefined = undefined>(input: {
|
|
37
|
+
format?: TFormat;
|
|
38
|
+
path: string;
|
|
39
|
+
}): Promise<ExtensionDocumentForFormat<TFormat>>;
|
|
40
|
+
};
|
|
7
41
|
export type ExtensionContextClient = OrpcContractsContextClient;
|
|
8
|
-
export type ExtensionGeaClient =
|
|
42
|
+
export type ExtensionGeaClient = {
|
|
43
|
+
agents: Pick<OrpcContractsClient["agents"], "getDefault">;
|
|
44
|
+
context: {
|
|
45
|
+
documents: ExtensionContextDocumentsClient;
|
|
46
|
+
records: Pick<OrpcContractsContextClient["records"], "archive" | "create" | "list" | "update">;
|
|
47
|
+
resources: Pick<OrpcContractsContextResourcesClient, "listChildren">;
|
|
48
|
+
tables: Pick<OrpcContractsContextClient["tables"], "create" | "getByPath">;
|
|
49
|
+
wikis: Pick<OrpcContractsContextClient["wikis"], "create" | "list">;
|
|
50
|
+
};
|
|
51
|
+
tasks: Pick<OrpcContractsClient["tasks"], "create" | "getById" | "listDispatchHistory">;
|
|
52
|
+
};
|
|
9
53
|
//# sourceMappingURL=context.d.ts.map
|