@anna-ai/cli 0.1.12 → 0.1.16

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.
Files changed (46) hide show
  1. package/dist/agent-DUmINbo4.js +372 -0
  2. package/dist/{apps-CDe6Fjq2.js → apps-Bt9CT5Sl.js} +1 -1
  3. package/dist/bridge-AJilXBw2.js +3 -0
  4. package/dist/{bridge-BQUo6ehX.js → bridge-nqQ3-j-t.js} +1 -1
  5. package/dist/cli.js +78 -9
  6. package/dist/dev-BRlFgo2I.js +3 -0
  7. package/dist/{dev-DoY58pBM.js → dev-C6v5yRV2.js} +4 -4
  8. package/dist/dev-account-DCyjamBa.js +44 -0
  9. package/dist/dev-app-cache-DAHcq46m.js +175 -0
  10. package/dist/dev-app-cache-DGF2Kuzd.js +4 -0
  11. package/dist/{doctor-DP2UB10l.js → doctor-C8MWfLt8.js} +1 -1
  12. package/dist/executa-dev-4FZ7AJHR.js +259 -0
  13. package/dist/executa-init-COEmKDOE.js +68 -0
  14. package/dist/executa-register-66WKIwQQ.js +47 -0
  15. package/dist/host_upload-C_pGOS6p.js +136 -0
  16. package/dist/image-bwolX7pa.js +131 -0
  17. package/dist/mascot-wlYTJqMs.js +218 -0
  18. package/dist/runner-DmGLdat0.js +322 -0
  19. package/dist/sampling-CJUDG-mf.js +155 -0
  20. package/dist/storage-EQJA_0UW.js +316 -0
  21. package/package.json +1 -1
  22. package/templates/executa/go/README.md +10 -0
  23. package/templates/executa/go/executa.json +4 -0
  24. package/templates/executa/go/go.mod +3 -0
  25. package/templates/executa/go/main.go +148 -0
  26. package/templates/executa/node/README.md +12 -0
  27. package/templates/executa/node/executa.json +4 -0
  28. package/templates/executa/node/package.json +12 -0
  29. package/templates/executa/node/plugin.mjs +126 -0
  30. package/templates/executa/node/sampling-fixture.jsonl +1 -0
  31. package/templates/executa/python/README.md +23 -0
  32. package/templates/executa/python/__SLUG_PY___plugin.py +146 -0
  33. package/templates/executa/python/executa.json +4 -0
  34. package/templates/executa/python/pyproject.toml +15 -0
  35. package/templates/executa/python/sampling-fixture.jsonl +4 -0
  36. package/templates/minimal/bundle/app.js +2 -0
  37. package/templates/minimal/bundle/index.html +1 -2
  38. package/dist/bridge-BEHyfpPI.js +0 -3
  39. package/dist/dev-app-cache-BMfOlTHd.js +0 -93
  40. package/dist/dev-app-cache-cXvO2XwQ.js +0 -4
  41. /package/dist/{credentials-CIOYq2Lm.js → credentials-DDqx6XMQ.js} +0 -0
  42. /package/dist/{fixture-BEu4LXLG.js → fixture-CATHyLLI.js} +0 -0
  43. /package/dist/{login-dl1Zfny8.js → login-CsIVbrmf.js} +0 -0
  44. /package/dist/{logout-DablvlFs.js → logout-gfmKQxMj.js} +0 -0
  45. /package/dist/{server-NXmiWJjX.js → server-D8R6ppOp.js} +0 -0
  46. /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,4 @@
1
+ {
2
+ "tool_id": "__TOOL_ID__",
3
+ "type": "python"
4
+ }
@@ -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"}}
@@ -1,4 +1,6 @@
1
1
  // Minimal Anna App bundle entry. Replace with real logic.
2
+ import { AnnaAppRuntime } from "/static/anna-apps/_sdk/latest/index.js";
3
+
2
4
  const TOOL_ID = "__TOOL_ID__";
3
5
 
4
6
  async function main() {
@@ -3,8 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>__SLUG__</title>
6
- <script src="/static/anna-apps/_sdk/0.1.0/index.js" defer></script>
7
- <script src="./app.js" defer></script>
6
+ <script src="./app.js" type="module"></script>
8
7
  </head>
9
8
  <body>
10
9
  <h1>__SLUG__</h1>
@@ -1,3 +0,0 @@
1
- import { PINNED_RUNTIME_VERSION, PythonBridge } from "./bridge-BQUo6ehX.js";
2
-
3
- export { PINNED_RUNTIME_VERSION, PythonBridge };
@@ -1,93 +0,0 @@
1
- import { canonicalHost } from "./credentials-BTv2IfUZ.js";
2
- import { dirname, join, resolve } from "node:path";
3
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
-
5
- //#region src/dev-app-cache.ts
6
- const CACHE_DIR = ".anna";
7
- const CACHE_FILE = "dev-app.json";
8
- function cachePath(cwd) {
9
- return resolve(cwd, CACHE_DIR, CACHE_FILE);
10
- }
11
- function readDevAppCache(cwd) {
12
- const p = cachePath(cwd);
13
- if (!existsSync(p)) return null;
14
- try {
15
- const raw = JSON.parse(readFileSync(p, "utf-8"));
16
- if (typeof raw.host === "string" && typeof raw.slug === "string" && typeof raw.app_id === "number") return {
17
- host: raw.host,
18
- slug: raw.slug,
19
- app_id: raw.app_id,
20
- name: raw.name ?? raw.slug,
21
- registered_at: raw.registered_at ?? ""
22
- };
23
- } catch {}
24
- return null;
25
- }
26
- function writeDevAppCache(cwd, entry) {
27
- const p = cachePath(cwd);
28
- mkdirSync(dirname(p), { recursive: true });
29
- writeFileSync(p, JSON.stringify(entry, null, 2) + "\n", "utf-8");
30
- }
31
- /** Call POST /api/v1/anna-apps/dev/apps/register. Idempotent server-side. */
32
- async function registerDevApp(args) {
33
- const url = `${canonicalHost(args.host)}/api/v1/anna-apps/dev/apps/register`;
34
- const res = await fetch(url, {
35
- method: "POST",
36
- headers: { "content-type": "application/json" },
37
- body: JSON.stringify({
38
- pat: args.pat,
39
- slug: args.input.slug,
40
- name: args.input.name,
41
- category: args.input.category,
42
- tagline: args.input.tagline
43
- })
44
- });
45
- if (!res.ok) {
46
- const text = await res.text().catch(() => "");
47
- throw new Error(`/dev/apps/register failed: HTTP ${res.status} ${text}`);
48
- }
49
- return await res.json();
50
- }
51
- /** Call GET /api/v1/anna-apps/dev/apps. */
52
- async function listDevApps(args) {
53
- const url = new URL(`${canonicalHost(args.host)}/api/v1/anna-apps/dev/apps`);
54
- url.searchParams.set("pat", args.pat);
55
- const res = await fetch(url, { method: "GET" });
56
- if (!res.ok) {
57
- const text = await res.text().catch(() => "");
58
- throw new Error(`/dev/apps failed: HTTP ${res.status} ${text}`);
59
- }
60
- const body = await res.json();
61
- return body.apps;
62
- }
63
- /**
64
- * Convenience helper for `anna-app dev`: returns a valid cached entry if
65
- * it still matches the manifest slug, otherwise hits the server to
66
- * (re-)register. Throws if no PAT is available on disk.
67
- */
68
- async function ensureDevAppRegistered(args) {
69
- const canonical = canonicalHost(args.host);
70
- const cached = readDevAppCache(args.cwd);
71
- if (cached && cached.host === canonical && cached.slug === args.input.slug) return cached;
72
- const r = await registerDevApp({
73
- host: args.host,
74
- pat: args.pat,
75
- input: args.input
76
- });
77
- const entry = {
78
- host: canonical,
79
- slug: r.slug,
80
- app_id: r.app_id,
81
- name: r.name,
82
- registered_at: new Date().toISOString()
83
- };
84
- writeDevAppCache(args.cwd, entry);
85
- return entry;
86
- }
87
- const _internal = {
88
- cachePath,
89
- CACHE_DIR: join(CACHE_DIR, CACHE_FILE)
90
- };
91
-
92
- //#endregion
93
- export { ensureDevAppRegistered, listDevApps, readDevAppCache, registerDevApp, writeDevAppCache };
@@ -1,4 +0,0 @@
1
- import "./credentials-BTv2IfUZ.js";
2
- import { ensureDevAppRegistered, listDevApps, readDevAppCache, registerDevApp, writeDevAppCache } from "./dev-app-cache-BMfOlTHd.js";
3
-
4
- export { ensureDevAppRegistered };
File without changes
File without changes
File without changes
File without changes