@gea-ai/extensions-sdk 0.1.260508-alpha

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/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work (an example is provided in the Appendix
36
+ below).
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ "Contribution" shall mean any work of authorship, including the original version
46
+ of the Work and any modifications or additions to that Work or Derivative Works
47
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
48
+ by the copyright owner or by an individual or Legal Entity authorized to submit
49
+ on behalf of the copyright owner. For the purposes of this definition,
50
+ "submitted" means any form of electronic, verbal, or written communication sent
51
+ to the Licensor or its representatives, including but not limited to
52
+ communication on electronic mailing lists, source code control systems, and
53
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
54
+ the purpose of discussing and improving the Work, but excluding communication
55
+ that is conspicuously marked or otherwise designated in writing by the copyright
56
+ owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
63
+ License, each Contributor hereby grants to You a perpetual, worldwide,
64
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
65
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
66
+ sublicense, and distribute the Work and such Derivative Works in Source or
67
+ Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
70
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
71
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
72
+ license to make, have made, use, offer to sell, sell, import, and otherwise
73
+ transfer the Work, where such license applies only to those patent claims
74
+ licensable by such Contributor that are necessarily infringed by their
75
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
76
+ to which such Contribution(s) was submitted. If You institute patent litigation
77
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
78
+ alleging that the Work or a Contribution incorporated within the Work
79
+ constitutes direct or contributory patent infringement, then any patent licenses
80
+ granted to You under this License for that Work shall terminate as of the date
81
+ such litigation is filed.
82
+
83
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
84
+ Derivative Works thereof in any medium, with or without modifications, and in
85
+ Source or Object form, provided that You meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
88
+ this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices stating that
91
+ You changed the files; and
92
+
93
+ (c) You must retain, in the Source form of any Derivative Works that You
94
+ distribute, all copyright, patent, trademark, and attribution notices from the
95
+ Source form of the Work, excluding those notices that do not pertain to any part
96
+ of the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
99
+ any Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents of
106
+ the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+
112
+ You may add Your own copyright statement to Your modifications and may provide
113
+ additional or different license terms and conditions for use, reproduction, or
114
+ distribution of Your modifications, or for any such Derivative Works as a whole,
115
+ provided Your use, reproduction, and distribution of the Work otherwise complies
116
+ with the conditions stated in this License.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
119
+ Contribution intentionally submitted for inclusion in the Work by You to the
120
+ Licensor shall be under the terms and conditions of this License, without any
121
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
122
+ supersede or modify the terms of any separate license agreement you may have
123
+ executed with Licensor regarding such Contributions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade names,
126
+ trademarks, service marks, or product names of the Licensor, except as required
127
+ for reasonable and customary use in describing the origin of the Work and
128
+ reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
131
+ writing, Licensor provides the Work (and each Contributor provides its
132
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
133
+ KIND, either express or implied, including, without limitation, any warranties or
134
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
135
+ PARTICULAR PURPOSE. You are solely responsible for determining the
136
+ appropriateness of using or redistributing the Work and assume any risks
137
+ associated with Your exercise of permissions under this License.
138
+
139
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
140
+ tort (including negligence), contract, or otherwise, unless required by
141
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
142
+ writing, shall any Contributor be liable to You for damages, including any
143
+ direct, indirect, special, incidental, or consequential damages of any character
144
+ arising as a result of this License or out of the use or inability to use the
145
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
146
+ computer failure or malfunction, or any and all other commercial damages or
147
+ losses), even if such Contributor has been advised of the possibility of such
148
+ damages.
149
+
150
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
151
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
152
+ acceptance of support, warranty, indemnity, or other liability obligations
153
+ and/or rights consistent with this License. However, in accepting such
154
+ obligations, You may act only on Your own behalf and on Your sole
155
+ responsibility, not on behalf of any other Contributor, and only if You agree to
156
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
157
+ by, or claims asserted against, such Contributor by reason of your accepting any
158
+ such warranty or additional liability.
159
+
160
+ END OF TERMS AND CONDITIONS
161
+
162
+ APPENDIX: How to apply the Apache License to your work.
163
+
164
+ To apply the Apache License to your work, attach the following boilerplate
165
+ notice, with the fields enclosed by brackets "[]" replaced with your own
166
+ identifying information. (Don't include the brackets!) The text should be
167
+ enclosed in the appropriate comment syntax for the file format. We also
168
+ recommend that a file or class name and description of purpose be included on
169
+ the same "printed page" as the copyright notice for easier identification
170
+ within third-party archives.
171
+
172
+ Copyright 2026 Tezign
173
+
174
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
175
+ this file except in compliance with the License. You may obtain a copy of the
176
+ License at
177
+
178
+ https://www.apache.org/licenses/LICENSE-2.0
179
+
180
+ Unless required by applicable law or agreed to in writing, software distributed
181
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
182
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
183
+ specific language governing permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @gea-ai/extensions-sdk
2
+
3
+ Public frontend SDK for GEA extensions.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @gea-ai/extensions-sdk zod
9
+ ```
10
+
11
+ When testing unpublished SDK changes from this repository, build the SDK and
12
+ link the workspace package from the standalone extension repo:
13
+
14
+ ```bash
15
+ pnpm --filter @gea-ai/extensions-sdk build
16
+ pnpm add @gea-ai/extensions-sdk@link:/path/to/gea/packages/extensions-sdk
17
+ ```
18
+
19
+ ## Minimal Shape
20
+
21
+ ```tsx
22
+ import {
23
+ defineExtension,
24
+ type ExtensionComponentProps,
25
+ } from "@gea-ai/extensions-sdk";
26
+ import { sdk } from "@gea-ai/extensions-sdk/ui";
27
+ import { z } from "zod";
28
+
29
+ const searchSchema = z.object({}).default({});
30
+
31
+ async function loader() {
32
+ const resources = await sdk.gea.context.resources.listChildren({
33
+ path: "/",
34
+ });
35
+
36
+ return resources;
37
+ }
38
+
39
+ function ExtensionPage(props: ExtensionComponentProps) {
40
+ return <pre>{JSON.stringify(props.loaderData, null, 2)}</pre>;
41
+ }
42
+
43
+ export const extension = defineExtension({
44
+ frontend: {
45
+ component: ExtensionPage,
46
+ loader,
47
+ validateSearch: searchSchema,
48
+ },
49
+ slug: "customer-research",
50
+ });
51
+ ```
52
+
53
+ Frontend code calls host APIs through SDK helpers. The SDK uses the GEA host
54
+ `postMessage` bridge by default, so extension authors do not need to write
55
+ message plumbing or know the host ORPC transport.
56
+
57
+ Third-party backend execution is intentionally not part of this V1 SDK. The
58
+ root SDK avoids private monorepo imports so extension projects can type-check
59
+ and build outside the GEA monorepo. Public host context result types are
60
+ exported from `@gea-ai/extensions-sdk/context`. The portable schemas and
61
+ TypeScript types are owned by `@gea-ai/orpc-contracts` and re-exported by the
62
+ SDK.
@@ -0,0 +1,12 @@
1
+ import type { ListContextResourceChildrenInput, ListContextResourceChildrenOutput } from "@gea-ai/orpc-contracts";
2
+ export { listContextResourceChildrenInputSchema as extensionContextListChildrenInputSchema, listContextResourceChildrenOutputSchema as extensionContextListChildrenOutputSchema, contextResourceCapabilitiesSchema as extensionContextResourceCapabilitiesSchema, contextResourceKindSchema as extensionContextResourceKindSchema, contextResourceSchema as extensionContextResourceSchema, orpcContractsRouter as extensionSdkContractRouter, isListContextResourceChildrenInput as isExtensionContextListChildrenInput, type ContextResource as ExtensionContextResource, type ContextResourceCapabilities as ExtensionContextResourceCapabilities, type ContextResourceKind as ExtensionContextResourceKind, type ListContextResourceChildrenInput as ExtensionContextResourceListChildrenInput, type ListContextResourceChildrenOutput as ExtensionContextResourceListChildrenOutput, type ListContextResourceChildrenParsedInput as ExtensionContextResourceListChildrenParsedInput, type OrpcContractsRouter as ExtensionSdkContractRouter, } from "@gea-ai/orpc-contracts";
3
+ export type ExtensionSdkListContextResourceChildrenInput = ListContextResourceChildrenInput;
4
+ export type ExtensionSdkListContextResourceChildrenOutput = ListContextResourceChildrenOutput;
5
+ export type ExtensionContextResourceListChildren = (input?: ListContextResourceChildrenInput) => Promise<ListContextResourceChildrenOutput>;
6
+ export type ExtensionContextResourcesClient = {
7
+ listChildren: ExtensionContextResourceListChildren;
8
+ };
9
+ export type ExtensionContextClient = {
10
+ resources: ExtensionContextResourcesClient;
11
+ };
12
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,sCAAsC,IAAI,uCAAuC,EACjF,uCAAuC,IAAI,wCAAwC,EACnF,iCAAiC,IAAI,0CAA0C,EAC/E,yBAAyB,IAAI,kCAAkC,EAC/D,qBAAqB,IAAI,8BAA8B,EACvD,mBAAmB,IAAI,0BAA0B,EACjD,kCAAkC,IAAI,mCAAmC,EACzE,KAAK,eAAe,IAAI,wBAAwB,EAChD,KAAK,2BAA2B,IAAI,oCAAoC,EACxE,KAAK,mBAAmB,IAAI,4BAA4B,EACxD,KAAK,gCAAgC,IAAI,yCAAyC,EAClF,KAAK,iCAAiC,IAAI,0CAA0C,EACpF,KAAK,sCAAsC,IAAI,+CAA+C,EAC9F,KAAK,mBAAmB,IAAI,0BAA0B,GACvD,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,4CAA4C,GACtD,gCAAgC,CAAC;AACnC,MAAM,MAAM,6CAA6C,GACvD,iCAAiC,CAAC;AAEpC,MAAM,MAAM,oCAAoC,GAAG,CACjD,KAAK,CAAC,EAAE,gCAAgC,KACrC,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAEhD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,YAAY,EAAE,oCAAoC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,+BAA+B,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { listContextResourceChildrenInputSchema as extensionContextListChildrenInputSchema, listContextResourceChildrenOutputSchema as extensionContextListChildrenOutputSchema, contextResourceCapabilitiesSchema as extensionContextResourceCapabilitiesSchema, contextResourceKindSchema as extensionContextResourceKindSchema, contextResourceSchema as extensionContextResourceSchema, orpcContractsRouter as extensionSdkContractRouter, isListContextResourceChildrenInput as isExtensionContextListChildrenInput, } from "@gea-ai/orpc-contracts";
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,sCAAsC,IAAI,uCAAuC,EACjF,uCAAuC,IAAI,wCAAwC,EACnF,iCAAiC,IAAI,0CAA0C,EAC/E,yBAAyB,IAAI,kCAAkC,EAC/D,qBAAqB,IAAI,8BAA8B,EACvD,mBAAmB,IAAI,0BAA0B,EACjD,kCAAkC,IAAI,mCAAmC,GAQ1E,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,32 @@
1
+ export type { ExtensionContextClient, ExtensionContextResource, ExtensionContextResourceCapabilities, ExtensionContextResourceKind, ExtensionContextResourceListChildren, ExtensionContextResourceListChildrenInput, ExtensionContextResourceListChildrenOutput, ExtensionContextResourcesClient, ExtensionSdkContractRouter, ExtensionSdkListContextResourceChildrenInput, ExtensionSdkListContextResourceChildrenOutput, } from "./context";
2
+ export type ExtensionSchema<TOutput = unknown> = {
3
+ parse(input: unknown): TOutput;
4
+ };
5
+ export type ExtensionNavigate = (options: {
6
+ replace?: boolean;
7
+ search: Record<string, unknown>;
8
+ }) => Promise<void> | void;
9
+ export type ExtensionComponentProps<TSearch = unknown, TLoaderData = unknown> = {
10
+ loaderData: TLoaderData;
11
+ navigate: ExtensionNavigate;
12
+ search: TSearch;
13
+ };
14
+ export type ExtensionFrontendDefinition<TSearch = unknown, TLoaderData = unknown, TRenderOutput = any> = {
15
+ component: (props: ExtensionComponentProps<TSearch, TLoaderData>) => TRenderOutput;
16
+ loader: (input: {
17
+ search: TSearch;
18
+ }) => Promise<TLoaderData>;
19
+ validateSearch: ExtensionSchema<TSearch>;
20
+ };
21
+ export type ExtensionDefinition = {
22
+ frontend?: ExtensionFrontendDefinition<any, any, any>;
23
+ slug: string;
24
+ };
25
+ export type AnyFrontendExtensionDefinition = ExtensionDefinition & {
26
+ frontend: ExtensionFrontendDefinition;
27
+ };
28
+ export declare function defineExtension<const TDefinition extends {
29
+ frontend?: unknown;
30
+ slug: string;
31
+ }>(definition: TDefinition): TDefinition;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,oCAAoC,EACpC,4BAA4B,EAC5B,oCAAo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CACvC,CAAC;AAEF,wBAAgB,eAAe,CAC7B,KAAK,CAAC,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,EACD,UAAU,EAAE,WAAW,eAExB"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export function defineExtension(definition) {
2
+ return definition;
3
+ }
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqDA,MAAM,UAAU,eAAe,CAK7B,UAAuB;IACvB,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { type ExtensionContextClient, type ExtensionContextResourceListChildrenInput } from "./context";
2
+ export type { ExtensionContextClient, ExtensionContextResource, ExtensionContextResourceCapabilities, ExtensionContextResourceKind, ExtensionContextResourceListChildrenInput, ExtensionContextResourceListChildrenOutput, ExtensionContextResourcesClient, } from "./context";
3
+ export declare const GEA_EXTENSION_UI_MESSAGE_SOURCE = "gea-extension-ui";
4
+ export declare const GEA_EXTENSION_HOST_MESSAGE_SOURCE = "gea-extension-host";
5
+ export type ExtensionHostMethod = "gea.context.resources.listChildren";
6
+ export type ExtensionHostRequestPayload = {
7
+ "gea.context.resources.listChildren": {
8
+ input?: ExtensionContextResourceListChildrenInput;
9
+ };
10
+ };
11
+ export type ExtensionUiHostRequest<TMethod extends ExtensionHostMethod = ExtensionHostMethod> = {
12
+ id: string;
13
+ method: TMethod;
14
+ payload: ExtensionHostRequestPayload[TMethod];
15
+ source: typeof GEA_EXTENSION_UI_MESSAGE_SOURCE;
16
+ };
17
+ export type ExtensionHostUiResponse<TResult = unknown> = {
18
+ id: string;
19
+ ok: true;
20
+ result: TResult;
21
+ source: typeof GEA_EXTENSION_HOST_MESSAGE_SOURCE;
22
+ } | {
23
+ error: {
24
+ message: string;
25
+ };
26
+ id: string;
27
+ ok: false;
28
+ source: typeof GEA_EXTENSION_HOST_MESSAGE_SOURCE;
29
+ };
30
+ export type ExtensionUiRuntime = {
31
+ app: ExtensionClientSdk;
32
+ };
33
+ export type ExtensionHostMessageClientOptions = {
34
+ targetOrigin?: string;
35
+ timeoutMs?: number;
36
+ window?: ExtensionMessageWindow;
37
+ };
38
+ export type ExtensionClientSdk = {
39
+ gea: {
40
+ context: ExtensionContextClient;
41
+ };
42
+ };
43
+ type ExtensionMessageWindow = {
44
+ addEventListener(type: "message", listener: (event: MessageEvent) => void): void;
45
+ parent: {
46
+ postMessage(message: unknown, targetOrigin: string): void;
47
+ };
48
+ removeEventListener(type: "message", listener: (event: MessageEvent) => void): void;
49
+ };
50
+ export declare function initExtensionUiRuntime(nextRuntime: ExtensionUiRuntime): void;
51
+ export declare function isExtensionUiHostRequest(value: unknown): value is ExtensionUiHostRequest;
52
+ export declare function createExtensionHostMessageClient(options?: ExtensionHostMessageClientOptions): ExtensionClientSdk;
53
+ export declare function getExtensionUiRuntime(options?: ExtensionHostMessageClientOptions): ExtensionUiRuntime;
54
+ export declare function getExtensionAppSdk(options?: ExtensionHostMessageClientOptions): ExtensionClientSdk;
55
+ export declare function createExtensionClientSdk(options?: ExtensionHostMessageClientOptions): ExtensionClientSdk;
56
+ export declare const sdk: ExtensionClientSdk;
57
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,yCAAyC,EAE/C,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,oCAAoC,EACpC,4BAA4B,EAC5B,yCAAyC,EACzC,0CAA0C,EAC1C,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,+BAA+B,qBAAqB,CAAC;AAClE,eAAO,MAAM,iCAAiC,uBAAuB,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CAAC;IACR,MAAM,EAAE;QACN,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3D,CAAC;IACF,mBAAmB,CACjB,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GACtC,IAAI,CAAC;CACT,CAAC;AAKF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,kBAAkB,QAErE;AA6CD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CA+BjC;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,GAAE,iCAAsC,GAC9C,kBAAkB,CAkEpB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,iCAAiC,sBAS5C;AAED,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,iCAAiC,sBAG5C;AAED,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,iCAAiC,GAC1C,kBAAkB,CAEpB;AAED,eAAO,MAAM,GAAG,EAAE,kBAA+C,CAAC"}
package/dist/ui.js ADDED
@@ -0,0 +1,118 @@
1
+ import { isExtensionContextListChildrenInput, } from "./context";
2
+ export const GEA_EXTENSION_UI_MESSAGE_SOURCE = "gea-extension-ui";
3
+ export const GEA_EXTENSION_HOST_MESSAGE_SOURCE = "gea-extension-host";
4
+ let runtime = null;
5
+ let nextMessageId = 0;
6
+ export function initExtensionUiRuntime(nextRuntime) {
7
+ runtime = nextRuntime;
8
+ }
9
+ function createMessageId() {
10
+ nextMessageId += 1;
11
+ return `gea-extension-ui-${Date.now()}-${nextMessageId}`;
12
+ }
13
+ function getDefaultMessageWindow() {
14
+ return typeof window === "undefined" ? null : window;
15
+ }
16
+ function isExtensionHostUiResponse(value) {
17
+ if (!value || typeof value !== "object") {
18
+ return false;
19
+ }
20
+ const message = value;
21
+ if (message.source !== GEA_EXTENSION_HOST_MESSAGE_SOURCE ||
22
+ typeof message.id !== "string" ||
23
+ typeof message.ok !== "boolean") {
24
+ return false;
25
+ }
26
+ if (message.ok) {
27
+ return true;
28
+ }
29
+ if (!message.error || typeof message.error !== "object") {
30
+ return false;
31
+ }
32
+ return typeof message.error.message === "string";
33
+ }
34
+ export function isExtensionUiHostRequest(value) {
35
+ if (!value || typeof value !== "object") {
36
+ return false;
37
+ }
38
+ const message = value;
39
+ if (message.source !== GEA_EXTENSION_UI_MESSAGE_SOURCE ||
40
+ typeof message.id !== "string" ||
41
+ message.method !== "gea.context.resources.listChildren" ||
42
+ !message.payload ||
43
+ typeof message.payload !== "object" ||
44
+ Array.isArray(message.payload)) {
45
+ return false;
46
+ }
47
+ const payload = message.payload;
48
+ return (Object.keys(payload).every((key) => key === "input") &&
49
+ isExtensionContextListChildrenInput(payload.input));
50
+ }
51
+ export function createExtensionHostMessageClient(options = {}) {
52
+ async function callHostMethod(method, payload) {
53
+ const messageWindow = options.window ?? getDefaultMessageWindow();
54
+ if (!messageWindow) {
55
+ throw new Error("Extension UI host window is not available.");
56
+ }
57
+ const id = createMessageId();
58
+ const request = {
59
+ id,
60
+ method,
61
+ payload,
62
+ source: GEA_EXTENSION_UI_MESSAGE_SOURCE,
63
+ };
64
+ return await new Promise((resolve, reject) => {
65
+ const timeout = setTimeout(() => {
66
+ cleanup();
67
+ reject(new Error("Timed out waiting for extension host response."));
68
+ }, options.timeoutMs ?? 30_000);
69
+ function cleanup() {
70
+ clearTimeout(timeout);
71
+ messageWindow?.removeEventListener("message", handleMessage);
72
+ }
73
+ function handleMessage(event) {
74
+ if (!isExtensionHostUiResponse(event.data)) {
75
+ return;
76
+ }
77
+ if (event.data.id !== id) {
78
+ return;
79
+ }
80
+ cleanup();
81
+ if (event.data.ok) {
82
+ resolve(event.data.result);
83
+ return;
84
+ }
85
+ reject(new Error(event.data.error.message));
86
+ }
87
+ messageWindow.addEventListener("message", handleMessage);
88
+ messageWindow.parent.postMessage(request, options.targetOrigin ?? "*");
89
+ });
90
+ }
91
+ return {
92
+ gea: {
93
+ context: {
94
+ resources: {
95
+ listChildren: async (input) => (await callHostMethod("gea.context.resources.listChildren", {
96
+ input,
97
+ })),
98
+ },
99
+ },
100
+ },
101
+ };
102
+ }
103
+ export function getExtensionUiRuntime(options) {
104
+ if (runtime) {
105
+ return runtime;
106
+ }
107
+ return {
108
+ app: createExtensionHostMessageClient(options),
109
+ };
110
+ }
111
+ export function getExtensionAppSdk(options) {
112
+ return getExtensionUiRuntime(options).app;
113
+ }
114
+ export function createExtensionClientSdk(options) {
115
+ return createExtensionHostMessageClient(options);
116
+ }
117
+ export const sdk = createExtensionClientSdk();
118
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,GAIpC,MAAM,WAAW,CAAC;AAYnB,MAAM,CAAC,MAAM,+BAA+B,GAAG,kBAAkB,CAAC;AAClE,MAAM,CAAC,MAAM,iCAAiC,GAAG,oBAAoB,CAAC;AAiEtE,IAAI,OAAO,GAA8B,IAAI,CAAC;AAC9C,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,sBAAsB,CAAC,WAA+B;IACpE,OAAO,GAAG,WAAW,CAAC;AACxB,CAAC;AAED,SAAS,eAAe;IACtB,aAAa,IAAI,CAAC,CAAC;IAEnB,OAAO,oBAAoB,IAAI,CAAC,GAAG,EAAE,IAAI,aAAa,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,uBAAuB;IAC9B,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACvD,CAAC;AAED,SAAS,yBAAyB,CAChC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAA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OAAO,CAAC,CAAC,CAAC;YAC9C,CAAC;YAED,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YACzD,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,GAAG,EAAE;YACH,OAAO,EAAE;gBACP,SAAS,EAAE;oBACT,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAC5B,CAAC,MAAM,cAAc,CAAC,oCAAoC,EAAE;wBAC1D,KAAK;qBACN,CAAC,CAA+C;iBACpD;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAA2C;IAE3C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO;QACL,GAAG,EAAE,gCAAgC,CAAC,OAAO,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAA2C;IAE3C,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,OAA2C;IAE3C,OAAO,gCAAgC,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAuB,wBAAwB,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@gea-ai/extensions-sdk",
3
+ "version": "0.1.260508-alpha",
4
+ "private": false,
5
+ "license": "Apache-2.0",
6
+ "files": [
7
+ "dist",
8
+ "LICENSE",
9
+ "README.md"
10
+ ],
11
+ "type": "module",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./context": {
19
+ "types": "./dist/context.d.ts",
20
+ "import": "./dist/context.js"
21
+ },
22
+ "./ui": {
23
+ "types": "./dist/ui.d.ts",
24
+ "import": "./dist/ui.js"
25
+ }
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@gea-ai/orpc-contracts": "0.1.260508-alpha"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react": "^19.2.0",
35
+ "typescript": "^6.0.3"
36
+ },
37
+ "scripts": {
38
+ "build": "pnpm --filter @gea-ai/orpc-contracts build && rm -rf dist && tsc -p tsconfig.build.json",
39
+ "publish:npm": "pnpm publish --access public --tag alpha",
40
+ "type-check": "tsgo --noEmit"
41
+ }
42
+ }