@react-grab/ami 0.1.0-beta.8 → 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.
@@ -1,5 +1,77 @@
1
- var ReactGrabAmi=(function(exports){'use strict';var p="ami://new-chat",c=()=>({send:async function*(n){let o=`${n.prompt}
1
+ var ReactGrabAmi = (function (exports) {
2
+ 'use strict';
2
3
 
3
- ${n.content.join(`
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
- `)}`,i=encodeURIComponent(o),e=`${p}?prompt=${i}`;window.open(e,"_self"),yield "Opened";},checkConnection:async()=>true,supportsResume:false,supportsFollowUp:false,undo:void 0,redo:void 0,dismissButtonText:"Copy"}),u=()=>c(),r=t=>typeof t=="object"&&t!==null&&"registerPlugin"in t,A=()=>{if(typeof window>"u")return;let t=c(),n=e=>{let s={provider:t,storage:sessionStorage},a={name:"ami-agent",actions:[{id:"edit-with-ami",label:"Edit with Ami",shortcut:"Enter",onAction:d=>{d.enterPromptMode?.(s);},agent:s}]};e.registerPlugin(a);},o=window.__REACT_GRAB__;if(r(o)){n(o);return}window.addEventListener("react-grab:init",e=>{e instanceof CustomEvent&&r(e.detail)&&n(e.detail);},{once:true});let i=window.__REACT_GRAB__;r(i)&&n(i);};A();exports.attachAgent=A;exports.createAmiAgentProvider=u;return exports;})({});
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-beta.8",
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
- "browser": "dist/client.global.js",
15
- "files": [
16
- "dist"
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.8"
24
- },
25
25
  "scripts": {
26
26
  "dev": "tsup --watch",
27
27
  "build": "rm -rf dist && NODE_ENV=production tsup"