@archon-claw/cli 0.0.3 → 0.0.4
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/public/embed/widget.js +1 -123
- package/package.json +2 -1
|
@@ -1,124 +1,2 @@
|
|
|
1
|
-
(function () {
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var script = document.currentScript;
|
|
5
|
-
var serverUrl = (script && script.getAttribute("data-server-url")) || "";
|
|
6
|
-
var containerSelector =
|
|
7
|
-
(script && script.getAttribute("data-container")) || "body";
|
|
8
|
-
|
|
9
|
-
var iframe = null;
|
|
10
|
-
var iframeReady = false;
|
|
11
|
-
var pendingMessages = [];
|
|
12
|
-
var hostContext = null;
|
|
13
|
-
var hostTools = [];
|
|
14
|
-
var toolHandlers = {};
|
|
15
|
-
|
|
16
|
-
function createIframe() {
|
|
17
|
-
var container = document.querySelector(containerSelector);
|
|
18
|
-
if (!container) return;
|
|
19
|
-
iframe = document.createElement("iframe");
|
|
20
|
-
iframe.src = serverUrl + "/embed.html";
|
|
21
|
-
iframe.style.cssText = "width:100%;height:100%;border:none;display:block;";
|
|
22
|
-
iframe.setAttribute("allow", "clipboard-read; clipboard-write");
|
|
23
|
-
container.appendChild(iframe);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function sendToIframe(msg) {
|
|
27
|
-
if (iframe && iframeReady) {
|
|
28
|
-
iframe.contentWindow.postMessage(msg, "*");
|
|
29
|
-
} else {
|
|
30
|
-
pendingMessages.push(msg);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function flushPendingMessages() {
|
|
35
|
-
while (pendingMessages.length > 0) {
|
|
36
|
-
iframe.contentWindow.postMessage(pendingMessages.shift(), "*");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Listen for postMessage from iframe
|
|
41
|
-
window.addEventListener("message", function (event) {
|
|
42
|
-
var data = event.data;
|
|
43
|
-
if (!data || typeof data.type !== "string") return;
|
|
44
|
-
|
|
45
|
-
switch (data.type) {
|
|
46
|
-
case "archon-claw:ready":
|
|
47
|
-
iframeReady = true;
|
|
48
|
-
if (hostContext) {
|
|
49
|
-
sendToIframe({ type: "archon-claw:set-context", context: hostContext });
|
|
50
|
-
}
|
|
51
|
-
if (hostTools.length > 0) {
|
|
52
|
-
sendToIframe({ type: "archon-claw:register-tools", tools: hostTools });
|
|
53
|
-
}
|
|
54
|
-
flushPendingMessages();
|
|
55
|
-
break;
|
|
56
|
-
|
|
57
|
-
case "archon-claw:request-close":
|
|
58
|
-
// Notify host — host decides what to do
|
|
59
|
-
window.dispatchEvent(new CustomEvent("archon-claw:request-close"));
|
|
60
|
-
break;
|
|
61
|
-
|
|
62
|
-
case "archon-claw:execute-tool":
|
|
63
|
-
var handler = toolHandlers[data.name];
|
|
64
|
-
if (handler) {
|
|
65
|
-
try {
|
|
66
|
-
Promise.resolve(handler(data.args))
|
|
67
|
-
.then(function (res) {
|
|
68
|
-
sendToIframe({
|
|
69
|
-
type: "archon-claw:tool-result",
|
|
70
|
-
toolCallId: data.toolCallId,
|
|
71
|
-
result: res,
|
|
72
|
-
});
|
|
73
|
-
})
|
|
74
|
-
.catch(function (err) {
|
|
75
|
-
sendToIframe({
|
|
76
|
-
type: "archon-claw:tool-result",
|
|
77
|
-
toolCallId: data.toolCallId,
|
|
78
|
-
error: err.message || String(err),
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
} catch (err) {
|
|
82
|
-
sendToIframe({
|
|
83
|
-
type: "archon-claw:tool-result",
|
|
84
|
-
toolCallId: data.toolCallId,
|
|
85
|
-
error: err.message || String(err),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
sendToIframe({
|
|
90
|
-
type: "archon-claw:tool-result",
|
|
91
|
-
toolCallId: data.toolCallId,
|
|
92
|
-
error: "Unknown host tool: " + data.name,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Create iframe immediately — host controls container visibility
|
|
100
|
-
createIframe();
|
|
101
|
-
|
|
102
|
-
// Expose global API
|
|
103
|
-
window.ArchonClaw = {
|
|
104
|
-
setContext: function (data) {
|
|
105
|
-
hostContext = data;
|
|
106
|
-
sendToIframe({ type: "archon-claw:set-context", context: data });
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
registerTools: function (tools) {
|
|
110
|
-
hostTools = tools.map(function (t) {
|
|
111
|
-
if (t.handler) {
|
|
112
|
-
toolHandlers[t.name] = t.handler;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
name: t.name,
|
|
116
|
-
description: t.description,
|
|
117
|
-
input_schema: t.input_schema,
|
|
118
|
-
execution_target: "host",
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
sendToIframe({ type: "archon-claw:register-tools", tools: hostTools });
|
|
122
|
-
},
|
|
123
|
-
};
|
|
1
|
+
(function(){(function(){const a=document.currentScript,u=(a==null?void 0:a.getAttribute("data-server-url"))??"",w=(a==null?void 0:a.getAttribute("data-container"))??"body";let n=null,i=!1;const c=[];let s=null,l=[];const d={};function f(){const t=document.querySelector(w);t&&(n=document.createElement("iframe"),n.src=u+"/embed.html",n.style.cssText="width:100%;height:100%;border:none;display:block;",n.setAttribute("allow","clipboard-read; clipboard-write"),t.appendChild(n))}function r(t){n&&i?n.contentWindow.postMessage(t,"*"):c.push(t)}function p(){for(;c.length>0;)n.contentWindow.postMessage(c.shift(),"*")}window.addEventListener("message",function(t){const e=t.data;if(!(!e||typeof e.type!="string"))switch(e.type){case"archon-claw:ready":i=!0,s&&r({type:"archon-claw:set-context",context:s}),l.length>0&&r({type:"archon-claw:register-tools",tools:l}),p();break;case"archon-claw:request-close":window.dispatchEvent(new CustomEvent("archon-claw:request-close"));break;case"archon-claw:execute-tool":{const h=d[e.name];if(h)try{Promise.resolve(h(e.args)).then(function(o){r({type:"archon-claw:tool-result",toolCallId:e.toolCallId,result:o})}).catch(function(o){r({type:"archon-claw:tool-result",toolCallId:e.toolCallId,error:o instanceof Error?o.message:String(o)})})}catch(o){r({type:"archon-claw:tool-result",toolCallId:e.toolCallId,error:o instanceof Error?o.message:String(o)})}else r({type:"archon-claw:tool-result",toolCallId:e.toolCallId,error:"Unknown host tool: "+e.name});break}}}),f();const m={setContext(t){s=t,r({type:"archon-claw:set-context",context:t})},registerTools(t){l=t.map(function(e){return e.handler&&(d[e.name]=e.handler),{name:e.name,description:e.description,input_schema:e.input_schema,execution_target:"host"}}),r({type:"archon-claw:register-tools",tools:l})}};window.ArchonClaw=m})();
|
|
124
2
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archon-claw/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "AI Agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"vitest": "^4.0.18"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@archon-claw/web": "workspace:*",
|
|
32
33
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
33
34
|
"commander": "^14.0.3",
|
|
34
35
|
"dotenv": "^17.3.1",
|