@react-grab/ami 0.1.0-beta.9 → 0.1.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/client.global.js +75 -3
- package/package.json +8 -8
package/dist/client.global.js
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
|
-
var ReactGrabAmi=(function(exports)
|
|
1
|
+
var ReactGrabAmi = (function (exports) {
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// src/client.ts
|
|
5
|
+
var AMI_DEEPLINK_BASE = "ami://new-chat";
|
|
6
|
+
var createDeeplinkAgentProvider = () => {
|
|
7
|
+
const send = async function* (context) {
|
|
8
|
+
const combinedPrompt = `${context.prompt}
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
${context.content.join("\n\n")}`;
|
|
11
|
+
const encodedPrompt = encodeURIComponent(combinedPrompt);
|
|
12
|
+
const deeplinkUrl = `${AMI_DEEPLINK_BASE}?prompt=${encodedPrompt}`;
|
|
13
|
+
window.open(deeplinkUrl, "_self");
|
|
14
|
+
yield "Opened";
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
send,
|
|
18
|
+
checkConnection: async () => true,
|
|
19
|
+
supportsResume: false,
|
|
20
|
+
supportsFollowUp: false,
|
|
21
|
+
undo: void 0,
|
|
22
|
+
redo: void 0,
|
|
23
|
+
dismissButtonText: "Copy"
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var createAmiAgentProvider = () => {
|
|
27
|
+
return createDeeplinkAgentProvider();
|
|
28
|
+
};
|
|
29
|
+
var isReactGrabApi = (value) => typeof value === "object" && value !== null && "registerPlugin" in value;
|
|
30
|
+
var attachAgent = () => {
|
|
31
|
+
if (typeof window === "undefined") return;
|
|
32
|
+
const provider = createDeeplinkAgentProvider();
|
|
33
|
+
const attach = (api) => {
|
|
34
|
+
const agent = { provider, storage: sessionStorage };
|
|
35
|
+
const plugin = {
|
|
36
|
+
name: "ami-agent",
|
|
37
|
+
actions: [
|
|
38
|
+
{
|
|
39
|
+
id: "edit-with-ami",
|
|
40
|
+
label: "Edit with Ami",
|
|
41
|
+
shortcut: "Enter",
|
|
42
|
+
onAction: (actionContext) => {
|
|
43
|
+
actionContext.enterPromptMode?.(agent);
|
|
44
|
+
},
|
|
45
|
+
agent
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
api.registerPlugin(plugin);
|
|
50
|
+
};
|
|
51
|
+
const existingApi = window.__REACT_GRAB__;
|
|
52
|
+
if (isReactGrabApi(existingApi)) {
|
|
53
|
+
attach(existingApi);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
window.addEventListener(
|
|
57
|
+
"react-grab:init",
|
|
58
|
+
(event) => {
|
|
59
|
+
if (!(event instanceof CustomEvent)) return;
|
|
60
|
+
if (!isReactGrabApi(event.detail)) return;
|
|
61
|
+
attach(event.detail);
|
|
62
|
+
},
|
|
63
|
+
{ once: true }
|
|
64
|
+
);
|
|
65
|
+
const apiAfterListener = window.__REACT_GRAB__;
|
|
66
|
+
if (isReactGrabApi(apiAfterListener)) {
|
|
67
|
+
attach(apiAfterListener);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
attachAgent();
|
|
71
|
+
|
|
72
|
+
exports.attachAgent = attachAgent;
|
|
73
|
+
exports.createAmiAgentProvider = createAmiAgentProvider;
|
|
74
|
+
|
|
75
|
+
return exports;
|
|
76
|
+
|
|
77
|
+
})({});
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/ami",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
4
7
|
"type": "module",
|
|
8
|
+
"browser": "dist/client.global.js",
|
|
5
9
|
"exports": {
|
|
6
10
|
"./client": {
|
|
7
11
|
"types": "./dist/client.d.ts",
|
|
@@ -11,17 +15,13 @@
|
|
|
11
15
|
"./dist/*": "./dist/*.js",
|
|
12
16
|
"./dist/*.js": "./dist/*.js"
|
|
13
17
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"react-grab": "0.1.0"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@types/node": "^22.10.7",
|
|
20
23
|
"tsup": "^8.4.0"
|
|
21
24
|
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"react-grab": "0.1.0-beta.9"
|
|
24
|
-
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"dev": "tsup --watch",
|
|
27
27
|
"build": "rm -rf dist && NODE_ENV=production tsup"
|