melchizedek-agents 0.9.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 (111) hide show
  1. package/AGENT_SETUP.md +182 -0
  2. package/DOCUMENTATION.md +614 -0
  3. package/LICENSE +21 -0
  4. package/QUICKSTART.md +164 -0
  5. package/README.md +151 -0
  6. package/config/agents/README.md +27 -0
  7. package/config/agents/examples/ares.yaml +74 -0
  8. package/config/agents/examples/cartographers.yaml +115 -0
  9. package/config/agents/examples/claude.yaml +17 -0
  10. package/config/agents/examples/council.yaml +65 -0
  11. package/config/agents/examples/critic.yaml +74 -0
  12. package/config/agents/examples/delegation.yaml +29 -0
  13. package/config/agents/examples/hierarchical.yaml +26 -0
  14. package/config/agents/examples/image_production.yaml +112 -0
  15. package/config/agents/examples/librarian.yaml +75 -0
  16. package/config/agents/examples/model_zoo.yaml +81 -0
  17. package/config/agents/examples/patient_advocate.yaml +107 -0
  18. package/config/agents/examples/scriptorium.yaml +96 -0
  19. package/config/agents/examples/style_council.yaml +83 -0
  20. package/config/agents/examples/syndicate.yaml +34 -0
  21. package/config/agents/examples/tutor.yaml +66 -0
  22. package/config/agents/syndicateSchema.yaml +291 -0
  23. package/dist/lib/config.d.ts +108 -0
  24. package/dist/lib/config.js +110 -0
  25. package/dist/lib/dispatch.d.ts +133 -0
  26. package/dist/lib/dispatch.js +182 -0
  27. package/dist/lib/grounding.d.ts +28 -0
  28. package/dist/lib/grounding.js +61 -0
  29. package/dist/lib/index.d.ts +14 -0
  30. package/dist/lib/index.js +13 -0
  31. package/dist/lib/loadEnv.d.ts +21 -0
  32. package/dist/lib/loadEnv.js +58 -0
  33. package/dist/lib/loadSyndicate.d.ts +177 -0
  34. package/dist/lib/loadSyndicate.js +264 -0
  35. package/dist/lib/memory/supabaseMemoryService.d.ts +118 -0
  36. package/dist/lib/memory/supabaseMemoryService.js +499 -0
  37. package/dist/lib/models/claudeLlm.d.ts +93 -0
  38. package/dist/lib/models/claudeLlm.js +332 -0
  39. package/dist/lib/models/gptLlm.d.ts +110 -0
  40. package/dist/lib/models/gptLlm.js +497 -0
  41. package/dist/lib/models/grokLlm.d.ts +64 -0
  42. package/dist/lib/models/grokLlm.js +86 -0
  43. package/dist/lib/models/ollamaLlm.d.ts +105 -0
  44. package/dist/lib/models/ollamaLlm.js +134 -0
  45. package/dist/lib/models/openAiCompatibleLlm.d.ts +125 -0
  46. package/dist/lib/models/openAiCompatibleLlm.js +331 -0
  47. package/dist/lib/models/providerMap.d.ts +28 -0
  48. package/dist/lib/models/providerMap.js +45 -0
  49. package/dist/lib/models/registry.d.ts +71 -0
  50. package/dist/lib/models/registry.js +159 -0
  51. package/dist/lib/models/schemaNormalize.d.ts +22 -0
  52. package/dist/lib/models/schemaNormalize.js +58 -0
  53. package/dist/lib/observability/supabaseSpanExporter.d.ts +35 -0
  54. package/dist/lib/observability/supabaseSpanExporter.js +115 -0
  55. package/dist/lib/observability/tracer.d.ts +44 -0
  56. package/dist/lib/observability/tracer.js +242 -0
  57. package/dist/lib/persistence/supabaseProvider.d.ts +44 -0
  58. package/dist/lib/persistence/supabaseProvider.js +88 -0
  59. package/dist/lib/session/supabaseSessionService.d.ts +26 -0
  60. package/dist/lib/session/supabaseSessionService.js +193 -0
  61. package/dist/lib/session/transcript.d.ts +193 -0
  62. package/dist/lib/session/transcript.js +309 -0
  63. package/dist/lib/toolRegistry.d.ts +15 -0
  64. package/dist/lib/toolRegistry.js +58 -0
  65. package/dist/lib/tools/collectionsSearchTool.d.ts +55 -0
  66. package/dist/lib/tools/collectionsSearchTool.js +86 -0
  67. package/dist/lib/tools/generateImageTool.d.ts +16 -0
  68. package/dist/lib/tools/generateImageTool.js +119 -0
  69. package/dist/lib/tools/inspectImageTool.d.ts +21 -0
  70. package/dist/lib/tools/inspectImageTool.js +97 -0
  71. package/dist/lib/tools/mcpToolFactory.d.ts +2 -0
  72. package/dist/lib/tools/mcpToolFactory.js +116 -0
  73. package/dist/lib/tools/toolContract.d.ts +78 -0
  74. package/dist/lib/tools/toolContract.js +129 -0
  75. package/dist/lib/tools/webExtractTool.d.ts +70 -0
  76. package/dist/lib/tools/webExtractTool.js +461 -0
  77. package/dist/lib/tools/webSearchTool.d.ts +53 -0
  78. package/dist/lib/tools/webSearchTool.js +126 -0
  79. package/dist/lib/tools/wikiTools.d.ts +112 -0
  80. package/dist/lib/tools/wikiTools.js +697 -0
  81. package/dist/lib/tools/xSearchTool.d.ts +61 -0
  82. package/dist/lib/tools/xSearchTool.js +125 -0
  83. package/dist/lib/wiki/agentRun.d.ts +39 -0
  84. package/dist/lib/wiki/agentRun.js +79 -0
  85. package/dist/lib/wiki/builder.d.ts +71 -0
  86. package/dist/lib/wiki/builder.js +165 -0
  87. package/dist/lib/wiki/dive.d.ts +56 -0
  88. package/dist/lib/wiki/dive.js +208 -0
  89. package/dist/lib/wiki/entities.d.ts +220 -0
  90. package/dist/lib/wiki/entities.js +661 -0
  91. package/dist/lib/wiki/extract.d.ts +97 -0
  92. package/dist/lib/wiki/extract.js +305 -0
  93. package/dist/lib/wiki/fill.d.ts +37 -0
  94. package/dist/lib/wiki/fill.js +175 -0
  95. package/dist/lib/wiki/format.d.ts +132 -0
  96. package/dist/lib/wiki/format.js +177 -0
  97. package/dist/lib/wiki/graph.d.ts +80 -0
  98. package/dist/lib/wiki/graph.js +147 -0
  99. package/dist/lib/wiki/lint.d.ts +58 -0
  100. package/dist/lib/wiki/lint.js +267 -0
  101. package/dist/lib/wiki/markdown.d.ts +127 -0
  102. package/dist/lib/wiki/markdown.js +336 -0
  103. package/dist/lib/wiki/pipeline.d.ts +69 -0
  104. package/dist/lib/wiki/pipeline.js +119 -0
  105. package/dist/lib/wiki/vault.d.ts +84 -0
  106. package/dist/lib/wiki/vault.js +194 -0
  107. package/dist/scripts/a2a_server.d.ts +2 -0
  108. package/dist/scripts/a2a_server.js +997 -0
  109. package/dist/scripts/syndicate_chat.d.ts +2 -0
  110. package/dist/scripts/syndicate_chat.js +485 -0
  111. package/package.json +96 -0
package/AGENT_SETUP.md ADDED
@@ -0,0 +1,182 @@
1
+ # Set up melchizedek with your coding agent
2
+
3
+ A copy-paste path from zero to a running agent syndicate, written for
4
+ the way people actually work now: your coding agent (Claude Code,
5
+ Cursor, Codex — any of them) does the machine steps, you do the human
6
+ steps, and the seams between the two are explicit.
7
+
8
+ Repo: https://github.com/jhwadman/melchizedek-agents
9
+ Course: https://lyceumagents.com/curriculum/
10
+ This file lives in both places and is identical in both.
11
+
12
+ ---
13
+
14
+ ## 1. The prompt — paste this to your coding agent
15
+
16
+ ```text
17
+ Set up the melchizedek-agents framework on this machine.
18
+
19
+ 1. Check prerequisites: `node --version` must be 22 or newer. If it
20
+ isn't, stop and tell me before doing anything else.
21
+ 2. Clone and install:
22
+ git clone https://github.com/jhwadman/melchizedek-agents.git
23
+ cd melchizedek-agents
24
+ npm install
25
+ 3. Create my env file: `cp .env.example .env`. Do NOT put any values in
26
+ it. Never ask me to paste API keys into this chat, never read keys
27
+ from elsewhere on my machine, and never commit .env.
28
+ 4. Run the offline test suite (`npm test`) and confirm every shipped
29
+ syndicate compiles.
30
+ 5. Read README.md and QUICKSTART.md. Then report back with:
31
+ - what you did and the test results,
32
+ - the list of available syndicates (one line each, from the README
33
+ table),
34
+ - exactly which values I must fill into .env myself, what each one
35
+ unlocks, and which are optional (the comments in .env.example
36
+ say),
37
+ - the exact command I should run for my first conversation.
38
+ Stop there. Do not start servers, do not configure Supabase, and do not
39
+ touch anything outside the cloned directory.
40
+ ```
41
+
42
+ Why the guardrails in the prompt matter: keys belong in `.env`, entered
43
+ by your hands, never in a chat transcript — a pasted key lives in that
44
+ conversation's history forever. The stop-conditions keep the agent from
45
+ "helpfully" provisioning services you haven't decided to use yet.
46
+
47
+ ## 2. Your steps — the parts that are yours on purpose
48
+
49
+ After the agent reports back:
50
+
51
+ 1. **Optional — zero keys, fully local**: install Ollama
52
+ (https://ollama.com) and run `ollama pull qwen3:8b`. The two
53
+ open-weight syndicates (`npm run syndicate:tutor`, `npm run
54
+ syndicate:council`) then run with an empty `.env` — every agent is a
55
+ local model, nothing leaves your machine. This is the Part 1 course
56
+ path; the cloud syndicates below still want a key.
57
+ 2. **Get a Gemini API key** (free): https://aistudio.google.com →
58
+ create key → open `.env` in your editor and set
59
+ `GOOGLE_GENAI_API_KEY`. This one key runs every cloud text syndicate.
60
+ 3. **Optional — persistent memory** (free, needed for the two memory
61
+ syndicates): create a project at https://supabase.com, copy the
62
+ Project URL and `service_role` key into `SUPABASE_URL` and
63
+ `SUPABASE_SERVICE_ROLE_KEY`, then paste the schema SQL from
64
+ `DOCUMENTATION.md` §Sessions & long-term memory into the Supabase
65
+ SQL Editor and run it — followed by `db/hardening.sql`, which locks
66
+ the tables away from Supabase's public API. Do the SQL steps
67
+ yourself, in the dashboard, so you know what your database holds.
68
+ 4. **Optional — other cloud providers** (paid, usage-billed): each
69
+ provider key unlocks its model-id family, and nothing requires any
70
+ of them — set only what you'll declare in YAML:
71
+ `ANTHROPIC_API_KEY` for `claude-*` (https://console.anthropic.com),
72
+ `OPENAI_API_KEY` for `gpt-*` (https://platform.openai.com/api-keys),
73
+ `XAI_API_KEY` for `grok-*` (https://console.x.ai). Verify the whole
74
+ multi-provider surface at any time with `npm run demo:models` — it
75
+ sends one prompt to every provider you've configured (plus the local
76
+ model) and prints per-request token/latency traces; unconfigured
77
+ providers are skipped.
78
+
79
+ ## 3. First tests — meet the agents
80
+
81
+ Keyless, if you installed Ollama:
82
+
83
+ ```bash
84
+ npm run syndicate:tutor # one open-weight agent: paste material, be taught
85
+ npm run syndicate:council # advocate/skeptic council, all local
86
+ ```
87
+
88
+ With your Gemini key:
89
+
90
+ ```bash
91
+ npm run chat:syndicate # default: Global Synthesis Council REPL
92
+ ```
93
+
94
+ Ask it something that needs current information; watch the orchestrator
95
+ delegate to its research subagent. Type `exit` to end. Then try the
96
+ personalities:
97
+
98
+ ```bash
99
+ npm run syndicate:critic # drafter → critic confidence loop
100
+ npm run syndicate:delegation # router → specialists
101
+ npm run syndicate:image # spec-first image generation + blind audit
102
+ ```
103
+
104
+ One-shot mode (answers and exits — this is also how you'll script it):
105
+
106
+ ```bash
107
+ npm run syndicate:critic -- "In two sentences, why did the Library of Alexandria decline?"
108
+ ```
109
+
110
+ And the floor of the whole framework — one agent, no syndicate, plain
111
+ ADK. `scripts/direct_call.ts` is the ~30-line block you'll copy when an
112
+ agent belongs inside your own code rather than behind a YAML:
113
+
114
+ ```bash
115
+ npm run demo:direct -- "In one sentence: what is an agent?"
116
+ ```
117
+
118
+ If you configured Supabase, test the thing that makes this framework
119
+ worth keeping:
120
+
121
+ ```bash
122
+ npm run syndicate:advocate # long-term-memory patient advocate
123
+ # tell it a few facts, type exit — the session distills into records
124
+ npm run syndicate:advocate # new session: it remembers
125
+ ```
126
+
127
+ Correct a fact you told it in the second session, exit, and start a
128
+ third — the old record is superseded, not duplicated. That's the
129
+ structured memory pipeline working end to end.
130
+
131
+ And the newest capability — an agent whose tools live on the far side
132
+ of a protocol (set `ALLOW_PRIVATE_MCP=true` in `.env` first, since the
133
+ demo server runs on localhost):
134
+
135
+ ```bash
136
+ npm run mcp:demo # terminal 1: a small MCP library catalog
137
+ npm run syndicate:librarian # terminal 2: ask it to find and borrow a scroll
138
+ ```
139
+
140
+ Watch the agent discover the catalog's tools at runtime, search it, and
141
+ write a borrow record back through MCP — fetching and modifying data it
142
+ was never compiled to know about.
143
+
144
+ ## 4. Integration — putting a syndicate inside your app
145
+
146
+ The A2A server turns any syndicate into a JSON-RPC HTTP endpoint your
147
+ application calls like any other API:
148
+
149
+ 1. Generate a server secret yourself: `openssl rand -hex 32` → set
150
+ `A2A_SERVER_SECRET` in `.env`.
151
+ 2. `npm run start:a2a` — the endpoint speaks the open A2A protocol,
152
+ publishes an agent card, and enforces bearer auth + rate limiting.
153
+ 3. Every request carries three headers: `Authorization: Bearer
154
+ <A2A_SERVER_SECRET>`, `X-API-Key: <a Gemini key>` (inference bills
155
+ the caller — your server key stays yours), and `X-User-Id: <your
156
+ app's opaque user id>` — the id your backend assigns after
157
+ authenticating its own user, never one the user chooses. That last
158
+ header is what keeps one user's memory out of another's session.
159
+ 4. `demo/a2a_demo.mjs` is a complete working client; `DOCUMENTATION.md`
160
+ §A2A has the protocol details, and `lib/memory/README.md` covers
161
+ per-user memory siloing and the right-to-erasure endpoint before you
162
+ serve real people.
163
+
164
+ When you're ready, hand your coding agent a prompt shaped like this:
165
+
166
+ ```text
167
+ My melchizedek-agents A2A server runs at <URL>. Read demo/a2a_demo.mjs
168
+ and DOCUMENTATION.md §A2A in the melchizedek-agents repo, then wire my
169
+ app's <feature> to it: send each authenticated user's message via
170
+ message/send with the three required headers, stream or poll the reply,
171
+ and render it in <where>. The bearer secret and Gemini key come from my
172
+ app's server-side environment — never expose either to the browser, and
173
+ never send a request without X-User-Id set to our internal account id.
174
+ Write the integration, then show me a test I can run against a scratch
175
+ user id.
176
+ ```
177
+
178
+ Deploying the server itself (Heroku, Fly, a VPS) needs `PUBLIC_URL` set
179
+ — at which point the server refuses to start without the bearer secret,
180
+ by design. Run `db/hardening.sql` before real user data arrives, and
181
+ read the deployment notes in `lib/memory/README.md` end to end. The
182
+ patient in module 2.02's specimen would expect no less of you.