@anna-ai/cli 0.1.12 → 0.1.14
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/agent-DUmINbo4.js +372 -0
- package/dist/{apps-CDe6Fjq2.js → apps-BEJUn9Ws.js} +1 -1
- package/dist/bridge-C0DWb5eQ.js +3 -0
- package/dist/cli.js +72 -9
- package/dist/{dev-DoY58pBM.js → dev-BfLGxpiT.js} +4 -4
- package/dist/dev-C81H9c9_.js +3 -0
- package/dist/dev-account-DCyjamBa.js +44 -0
- package/dist/{dev-app-cache-cXvO2XwQ.js → dev-app-cache-CZ8lIKiw.js} +1 -1
- package/dist/{doctor-DP2UB10l.js → doctor-B3u0edUg.js} +1 -1
- package/dist/executa-dev-BhouP8jh.js +212 -0
- package/dist/executa-init-COEmKDOE.js +68 -0
- package/dist/executa-register-66WKIwQQ.js +47 -0
- package/dist/mascot-wlYTJqMs.js +218 -0
- package/dist/runner-Bral1LFW.js +279 -0
- package/dist/sampling-3EfSlDHM.js +155 -0
- package/dist/storage-CnWTZqq_.js +316 -0
- package/package.json +1 -1
- package/templates/executa/go/README.md +10 -0
- package/templates/executa/go/executa.json +4 -0
- package/templates/executa/go/go.mod +3 -0
- package/templates/executa/go/main.go +148 -0
- package/templates/executa/node/README.md +12 -0
- package/templates/executa/node/executa.json +4 -0
- package/templates/executa/node/package.json +12 -0
- package/templates/executa/node/plugin.mjs +126 -0
- package/templates/executa/node/sampling-fixture.jsonl +1 -0
- package/templates/executa/python/README.md +23 -0
- package/templates/executa/python/__SLUG_PY___plugin.py +146 -0
- package/templates/executa/python/executa.json +4 -0
- package/templates/executa/python/pyproject.toml +15 -0
- package/templates/executa/python/sampling-fixture.jsonl +4 -0
- package/dist/bridge-BEHyfpPI.js +0 -3
- /package/dist/{bridge-BQUo6ehX.js → bridge-D6YyP9DM.js} +0 -0
- /package/dist/{credentials-CIOYq2Lm.js → credentials-DDqx6XMQ.js} +0 -0
- /package/dist/{dev-app-cache-BMfOlTHd.js → dev-app-cache-C3D1Sp_V.js} +0 -0
- /package/dist/{fixture-BEu4LXLG.js → fixture-CATHyLLI.js} +0 -0
- /package/dist/{login-dl1Zfny8.js → login-CsIVbrmf.js} +0 -0
- /package/dist/{logout-DablvlFs.js → logout-gfmKQxMj.js} +0 -0
- /package/dist/{server-NXmiWJjX.js → server-q6nKCeEV.js} +0 -0
- /package/dist/{whoami-giXOY415.js → whoami-BS5wy-Nh.js} +0 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Minimal stdio Executa plugin scaffold (Python).
|
|
2
|
+
|
|
3
|
+
Speaks Executa JSON-RPC 2.0 over stdin/stdout. Implements both v1
|
|
4
|
+
methods (`describe`, `health`, `invoke`) and the v2 `initialize`
|
|
5
|
+
handshake so a host that knows sampling can attach reverse-RPC support.
|
|
6
|
+
|
|
7
|
+
Run locally:
|
|
8
|
+
|
|
9
|
+
anna-app executa dev --describe
|
|
10
|
+
anna-app executa dev --invoke ping
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
import uuid
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
MANIFEST: dict[str, Any] = {
|
|
21
|
+
"name": "__TOOL_ID__",
|
|
22
|
+
"display_name": "__TOOL_ID__",
|
|
23
|
+
"version": "0.1.0",
|
|
24
|
+
"description": "A minimal Executa plugin scaffold.",
|
|
25
|
+
# Declaring `host_capabilities` here is informational for the
|
|
26
|
+
# registry; `client_capabilities.sampling` in the initialize
|
|
27
|
+
# response is what actually unlocks reverse-RPC sampling.
|
|
28
|
+
"host_capabilities": ["llm.sample"],
|
|
29
|
+
"tools": [
|
|
30
|
+
{
|
|
31
|
+
"name": "ping",
|
|
32
|
+
"description": "Smoke-test method.",
|
|
33
|
+
"parameters": [],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "summarize",
|
|
37
|
+
"description": "Summarize a piece of text via host sampling.",
|
|
38
|
+
"parameters": [
|
|
39
|
+
{
|
|
40
|
+
"name": "text",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Text to summarize.",
|
|
43
|
+
"required": True,
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Track in-flight reverse-RPC requests we initiate to the host.
|
|
51
|
+
_PENDING: dict[str, Any] = {}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _write(envelope: dict[str, Any]) -> None:
|
|
55
|
+
sys.stdout.write(json.dumps(envelope) + "\n")
|
|
56
|
+
sys.stdout.flush()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _request_sampling(prompt: str) -> dict[str, Any]:
|
|
60
|
+
"""Issue a reverse-RPC `sampling/createMessage` and block until response."""
|
|
61
|
+
rid = str(uuid.uuid4())
|
|
62
|
+
_write(
|
|
63
|
+
{
|
|
64
|
+
"jsonrpc": "2.0",
|
|
65
|
+
"id": rid,
|
|
66
|
+
"method": "sampling/createMessage",
|
|
67
|
+
"params": {
|
|
68
|
+
"messages": [
|
|
69
|
+
{"role": "user", "content": {"type": "text", "text": prompt}}
|
|
70
|
+
],
|
|
71
|
+
"maxTokens": 400,
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
# Loop on stdin until our response arrives. Anything that's not the
|
|
76
|
+
# expected response is dispatched normally.
|
|
77
|
+
for line in sys.stdin:
|
|
78
|
+
line = line.strip()
|
|
79
|
+
if not line:
|
|
80
|
+
continue
|
|
81
|
+
env = json.loads(line)
|
|
82
|
+
if env.get("id") == rid and "method" not in env:
|
|
83
|
+
if "error" in env:
|
|
84
|
+
raise RuntimeError(env["error"].get("message", "sampling failed"))
|
|
85
|
+
return env.get("result", {})
|
|
86
|
+
# Re-queue other requests by handling them inline.
|
|
87
|
+
_dispatch(env)
|
|
88
|
+
raise RuntimeError("stdin closed before sampling response arrived")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def invoke(method: str, args: dict[str, Any]) -> dict[str, Any]:
|
|
92
|
+
if method == "ping":
|
|
93
|
+
return {"success": True, "data": {"pong": True}}
|
|
94
|
+
if method == "summarize":
|
|
95
|
+
text = args.get("text", "")
|
|
96
|
+
if not text:
|
|
97
|
+
return {"success": False, "error": "text is required"}
|
|
98
|
+
try:
|
|
99
|
+
sample = _request_sampling(f"Summarize in one sentence:\n{text}")
|
|
100
|
+
summary = sample.get("content", {}).get("text", "")
|
|
101
|
+
return {"success": True, "data": {"summary": summary}}
|
|
102
|
+
except Exception as e: # noqa: BLE001
|
|
103
|
+
return {"success": False, "error": f"sampling failed: {e}"}
|
|
104
|
+
return {"success": False, "error": f"unknown method: {method}"}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _dispatch(env: dict[str, Any]) -> None:
|
|
108
|
+
method = env.get("method")
|
|
109
|
+
rid = env.get("id")
|
|
110
|
+
try:
|
|
111
|
+
if method == "initialize":
|
|
112
|
+
result = {
|
|
113
|
+
"protocolVersion": "2.0",
|
|
114
|
+
"server_info": {"name": MANIFEST["name"], "version": MANIFEST["version"]},
|
|
115
|
+
"capabilities": {"sampling": {}},
|
|
116
|
+
}
|
|
117
|
+
elif method == "describe":
|
|
118
|
+
result = MANIFEST
|
|
119
|
+
elif method == "health":
|
|
120
|
+
result = {"status": "ok"}
|
|
121
|
+
elif method == "invoke":
|
|
122
|
+
params = env.get("params", {})
|
|
123
|
+
result = invoke(params.get("tool", ""), params.get("arguments", {}))
|
|
124
|
+
else:
|
|
125
|
+
raise ValueError(f"unknown rpc: {method}")
|
|
126
|
+
_write({"jsonrpc": "2.0", "id": rid, "result": result})
|
|
127
|
+
except Exception as e: # noqa: BLE001
|
|
128
|
+
_write(
|
|
129
|
+
{
|
|
130
|
+
"jsonrpc": "2.0",
|
|
131
|
+
"id": rid,
|
|
132
|
+
"error": {"code": -32601, "message": str(e)},
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def main() -> None:
|
|
138
|
+
for line in sys.stdin:
|
|
139
|
+
line = line.strip()
|
|
140
|
+
if not line:
|
|
141
|
+
continue
|
|
142
|
+
_dispatch(json.loads(line))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if __name__ == "__main__":
|
|
146
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "__TOOL_ID__"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Executa plugin: __SLUG__"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
|
|
11
|
+
[project.scripts]
|
|
12
|
+
"__TOOL_ID__" = "__SLUG_PY___plugin:main"
|
|
13
|
+
|
|
14
|
+
[tool.setuptools]
|
|
15
|
+
py-modules = ["__SLUG_PY___plugin"]
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# Sampling fixture for `anna-app executa dev --mock-sampling`.
|
|
2
|
+
# One JSON object per line. Match the first entry whose `ns`+`method`
|
|
3
|
+
# (and optional content substring) matches the reverse-RPC.
|
|
4
|
+
{"ns":"sampling","method":"createMessage","result":{"role":"assistant","content":{"type":"text","text":"(mock) a one-line summary"},"model":"mock-model","stopReason":"endTurn"}}
|
package/dist/bridge-BEHyfpPI.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|