@anna-ai/cli 0.1.14 → 0.1.17

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,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-D6YyP9DM.js";
2
-
3
- export { PINNED_RUNTIME_VERSION, PythonBridge };
@@ -1,3 +0,0 @@
1
- import { parseExecutaSpec, runDev } from "./dev-BfLGxpiT.js";
2
-
3
- export { parseExecutaSpec, runDev };
@@ -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-C3D1Sp_V.js";
3
-
4
- export { ensureDevAppRegistered };