hanzi-browse 2.2.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.
Files changed (78) hide show
  1. package/README.md +182 -0
  2. package/dist/agent/loop.d.ts +63 -0
  3. package/dist/agent/loop.js +186 -0
  4. package/dist/agent/system-prompt.d.ts +7 -0
  5. package/dist/agent/system-prompt.js +41 -0
  6. package/dist/agent/tools.d.ts +9 -0
  7. package/dist/agent/tools.js +154 -0
  8. package/dist/cli/detect-credentials.d.ts +31 -0
  9. package/dist/cli/detect-credentials.js +44 -0
  10. package/dist/cli/import-credentials-handler.d.ts +14 -0
  11. package/dist/cli/import-credentials-handler.js +22 -0
  12. package/dist/cli/session-files.d.ts +28 -0
  13. package/dist/cli/session-files.js +118 -0
  14. package/dist/cli/setup.d.ts +10 -0
  15. package/dist/cli/setup.js +915 -0
  16. package/dist/cli.d.ts +16 -0
  17. package/dist/cli.js +506 -0
  18. package/dist/dashboard/assets/index-CEFyesbT.js +46 -0
  19. package/dist/dashboard/assets/index-Dnht2kLU.css +1 -0
  20. package/dist/dashboard/index.html +13 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +1116 -0
  23. package/dist/ipc/index.d.ts +8 -0
  24. package/dist/ipc/index.js +8 -0
  25. package/dist/ipc/native-host.d.ts +96 -0
  26. package/dist/ipc/native-host.js +223 -0
  27. package/dist/ipc/websocket-client.d.ts +73 -0
  28. package/dist/ipc/websocket-client.js +199 -0
  29. package/dist/license/manager.d.ts +20 -0
  30. package/dist/license/manager.js +15 -0
  31. package/dist/llm/client.d.ts +72 -0
  32. package/dist/llm/client.js +227 -0
  33. package/dist/llm/credentials.d.ts +61 -0
  34. package/dist/llm/credentials.js +200 -0
  35. package/dist/llm/vertex.d.ts +22 -0
  36. package/dist/llm/vertex.js +335 -0
  37. package/dist/managed/api-http.test.d.ts +7 -0
  38. package/dist/managed/api-http.test.js +623 -0
  39. package/dist/managed/api.d.ts +51 -0
  40. package/dist/managed/api.js +1448 -0
  41. package/dist/managed/api.test.d.ts +10 -0
  42. package/dist/managed/api.test.js +146 -0
  43. package/dist/managed/auth.d.ts +38 -0
  44. package/dist/managed/auth.js +192 -0
  45. package/dist/managed/billing.d.ts +70 -0
  46. package/dist/managed/billing.js +227 -0
  47. package/dist/managed/deploy.d.ts +17 -0
  48. package/dist/managed/deploy.js +385 -0
  49. package/dist/managed/e2e.test.d.ts +15 -0
  50. package/dist/managed/e2e.test.js +151 -0
  51. package/dist/managed/hardening.test.d.ts +14 -0
  52. package/dist/managed/hardening.test.js +346 -0
  53. package/dist/managed/integration.test.d.ts +8 -0
  54. package/dist/managed/integration.test.js +274 -0
  55. package/dist/managed/log.d.ts +18 -0
  56. package/dist/managed/log.js +31 -0
  57. package/dist/managed/server.d.ts +12 -0
  58. package/dist/managed/server.js +69 -0
  59. package/dist/managed/store-pg.d.ts +191 -0
  60. package/dist/managed/store-pg.js +479 -0
  61. package/dist/managed/store.d.ts +188 -0
  62. package/dist/managed/store.js +379 -0
  63. package/dist/relay/auto-start.d.ts +19 -0
  64. package/dist/relay/auto-start.js +71 -0
  65. package/dist/relay/server.d.ts +17 -0
  66. package/dist/relay/server.js +403 -0
  67. package/dist/types/index.d.ts +5 -0
  68. package/dist/types/index.js +4 -0
  69. package/dist/types/session.d.ts +134 -0
  70. package/dist/types/session.js +16 -0
  71. package/package.json +61 -0
  72. package/skills/README.md +48 -0
  73. package/skills/a11y-auditor/SKILL.md +42 -0
  74. package/skills/e2e-tester/SKILL.md +154 -0
  75. package/skills/hanzi-browse/SKILL.md +182 -0
  76. package/skills/linkedin-prospector/SKILL.md +149 -0
  77. package/skills/social-poster/SKILL.md +146 -0
  78. package/skills/x-marketer/SKILL.md +479 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Managed API Server
3
+ *
4
+ * REST API for external clients to run browser tasks.
5
+ * Enforces: API key auth, workspace ownership, browser session validation.
6
+ *
7
+ * Endpoints:
8
+ * POST /v1/browser-sessions/pair - Create a pairing token
9
+ * POST /v1/browser-sessions/register - Exchange pairing token for session
10
+ * GET /v1/browser-sessions - List sessions for workspace
11
+ * POST /v1/tasks - Start a task (requires browser_session_id)
12
+ * GET /v1/tasks/:id - Get task status/result
13
+ * POST /v1/tasks/:id/cancel - Cancel a running task
14
+ * GET /v1/tasks - List tasks for workspace
15
+ * GET /v1/usage - Get usage summary
16
+ * POST /v1/api-keys - Create an API key (self-serve)
17
+ * GET /v1/api-keys - List API keys for workspace
18
+ * DELETE /v1/api-keys/:id - Delete an API key
19
+ * GET /v1/health - Health check (no auth)
20
+ */
21
+ import type { WebSocketClient } from "../ipc/websocket-client.js";
22
+ import * as fileStore from "./store.js";
23
+ /**
24
+ * Swap the backing store (e.g., to Postgres). Called by deploy.ts when DATABASE_URL is set.
25
+ */
26
+ export declare function setStoreModule(storeModule: typeof fileStore): void;
27
+ /**
28
+ * Startup sweep: mark any tasks still "running" from a previous process as errored.
29
+ * Call once after store initialization.
30
+ */
31
+ export declare function recoverStuckTasks(): Promise<void>;
32
+ /**
33
+ * Fail all pending tool executions for a disconnected browser session.
34
+ * Called by the relay when a managed session WebSocket closes.
35
+ * This avoids the agent loop waiting up to 15-35s for a timeout on each tool.
36
+ */
37
+ export declare function onSessionDisconnected(browserSessionId: string): void;
38
+ /**
39
+ * Initialize the managed API.
40
+ */
41
+ export declare function initManagedAPI(relay: WebSocketClient, sessionConnectedCheck?: (id: string) => boolean): void;
42
+ /**
43
+ * Handle incoming relay messages (tool results from extension).
44
+ */
45
+ export declare function handleRelayMessage(message: any): boolean;
46
+ export declare function startManagedAPI(port?: number): void;
47
+ /**
48
+ * Graceful shutdown: abort all running tasks and update their status.
49
+ * Called on SIGTERM/SIGINT to avoid leaving tasks in a permanent "running" state.
50
+ */
51
+ export declare function shutdownManagedAPI(): Promise<void>;