melchizedek-agents 0.9.0 → 0.9.2

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/AGENT_SETUP.md CHANGED
@@ -180,3 +180,15 @@ Deploying the server itself (Heroku, Fly, a VPS) needs `PUBLIC_URL` set
180
180
  by design. Run `db/hardening.sql` before real user data arrives, and
181
181
  read the deployment notes in `lib/memory/README.md` end to end. The
182
182
  patient in module 2.02's specimen would expect no less of you.
183
+
184
+ ## 5. When your agents outgrow the clone
185
+
186
+ Everything above runs inside the cloned course repo, and that stays the
187
+ right place to learn. When a syndicate of yours deserves its own
188
+ repository, the same engine installs as a typed npm dependency —
189
+ `npm install melchizedek-agents` — with the starter pack inside the
190
+ package to copy from, `loadSyndicate` reading your repo's own
191
+ `config/agents/`, and the two CLIs (`npx melchizedek-chat`,
192
+ `npx melchizedek-serve`) replacing the npm scripts. QUICKSTART §7 in the
193
+ repo is the complete recipe; hand it to your coding agent when the time
194
+ comes.
package/QUICKSTART.md CHANGED
@@ -56,6 +56,7 @@ npm run syndicate:delegation # router → specialists
56
56
  npm run syndicate:critic # drafter → critic confidence loop
57
57
  npm run syndicate:image # spec-first image production + blind audit
58
58
  npm run syndicate:advocate # long-term-memory patient advocate*
59
+ npm run syndicate:augustin # fact-checking arbiter (needs XAI_API_KEY too)
59
60
  ```
60
61
 
61
62
  One-shot mode — pass the question as an argument and the process exits
@@ -131,6 +132,38 @@ agent card, bearer-token auth (`A2A_SERVER_SECRET`), and rate limiting.
131
132
  See `demo/a2a_demo.mjs` for a working client and `DOCUMENTATION.md`
132
133
  §A2A for the protocol details.
133
134
 
135
+ ## 7. Use the engine from your own repo (the npm package)
136
+
137
+ Everything above runs inside a clone. When your syndicates deserve their
138
+ own repo, the same engine is a typed dependency:
139
+
140
+ ```bash
141
+ npm install melchizedek-agents
142
+ ```
143
+
144
+ ```typescript
145
+ import { loadSyndicate, registerAvailableProviders } from 'melchizedek-agents';
146
+
147
+ registerAvailableProviders(); // registers every model whose key is present
148
+ const config = loadSyndicate('mine.yaml'); // reads <your-repo>/config/agents/mine.yaml
149
+ ```
150
+
151
+ - **Your syndicates live with your code.** The loader reads
152
+ `<cwd>/config/agents/` by default; point it anywhere with
153
+ `loadSyndicate(file, { agentsDir })` or the `MELCHIZEDEK_AGENTS_DIR`
154
+ env var — the path-jail follows whichever root you configure.
155
+ - **The starter pack ships in the package.** Copy any example out of
156
+ `node_modules/melchizedek-agents/config/agents/examples/` (and
157
+ `syndicateSchema.yaml` beside it) as your starting point.
158
+ - **The CLIs come with it.** `npx melchizedek-chat --syndicate <name>`
159
+ is the interactive runner (replaces `npm run chat:syndicate`);
160
+ `npx melchizedek-serve` is the A2A server from §6, serving *your*
161
+ `config/agents/`.
162
+ - Deeper imports are available as subpaths — `melchizedek-agents/models/registry`,
163
+ `melchizedek-agents/tools/webExtractTool`, `melchizedek-agents/memory`,
164
+ and friends — all typed. `@google/adk` installs alongside as a peer:
165
+ your app owns the ADK version.
166
+
134
167
  ## Common first-run errors
135
168
 
136
169
  | Symptom | Cause / fix |
@@ -156,9 +189,5 @@ See `demo/a2a_demo.mjs` for a working client and `DOCUMENTATION.md`
156
189
  from `syndicateSchema.yaml`), keep one orchestrator and one subagent,
157
190
  and grow only when the work divides. The root of `config/agents/` is
158
191
  yours; the examples are teaching material you can gut or delete.
159
- - Outgrow the clone: `npm install melchizedek-agents` in your own repo
160
- gives you the same engine as a typed dependency — `loadSyndicate` reads
161
- your repo's `config/agents/` (or any root via `agentsDir` /
162
- `MELCHIZEDEK_AGENTS_DIR`), the starter pack ships inside the package,
163
- and `npx melchizedek-serve` / `npx melchizedek-chat` replace the repo's
164
- npm scripts. See the README's quick start for the four-line version.
192
+ - Outgrow the clone: §7 above — the engine as an npm dependency in your
193
+ own repo, starter pack included.
package/README.md CHANGED
@@ -103,6 +103,7 @@ worked specimen for a curriculum module:
103
103
  | `patient_advocate.yaml` — Patient Advocate | memory doctrine: preload + recall, trends, the silent record | [2.02 · memory systems](https://lyceumagents.com/curriculum/memory-systems/) |
104
104
  | `librarian.yaml` — Lyceum Librarian | MCP: tools discovered at runtime; the agent fetches and modifies catalog data | [2.03 · MCP](https://lyceumagents.com/curriculum/mcp-extending-reach/) |
105
105
  | `image_production.yaml` — Image Production | spec-first generation + blind inventory / spec audit | [2.04 · multi-modal agents](https://lyceumagents.com/curriculum/multimodal-agents/) |
106
+ | `augustin.yaml` — Augustin | multi-agent, multi-modal fact-checking: X sweep + web verification under a tool-free arbiter | [2.05 · the fact-checking arbiter](https://lyceumagents.com/curriculum/fact-checking-agent/) |
106
107
  | `claude.yaml` — Claude Chat | minimal single-agent config; the multi-model adapter in one file | — |
107
108
  | `model_zoo.yaml` — Model Zoo | one lightweight agent per provider (Qwen/Claude/Grok/GPT/Gemini); model optionality proven by `npm run demo:models` | — |
108
109
  | `scriptorium.yaml` — The Scriptorium | agents over the shipped knowledge bundle: query with citations, author through a validated save gate | — |
@@ -0,0 +1,250 @@
1
+ # ============================================================
2
+ # Augustin — the fact-checking arbiter of world events
3
+ # ============================================================
4
+ #
5
+ # WHY: The user brings an event, a controversy, a claim, and Augustin
6
+ # returns the true narrative as far as the record supports one — a
7
+ # conversational read first, then the load-bearing facts as bullets,
8
+ # each carrying its source. At its core it is a FACT-CHECKING agent:
9
+ # a daily bias-arbiter pattern (X sweep → web validation → tool-free
10
+ # arbitration) folded into one live DELEGATE syndicate.
11
+ #
12
+ # The shape, per the council.yaml doctrine:
13
+ # - The delegation contract: the Arbiter MUST consult BOTH
14
+ # researchers on every substantive question — X first (it surfaces
15
+ # the live claims), web second (it verifies them).
16
+ # - Independent perspectives: the collector never interprets; the
17
+ # Arbiter never collects. Search grounding and synthesis stay on
18
+ # separate agents (a lesson pinned by the daily arbiter pipeline:
19
+ # a Gemini call cannot ground and hold a schema at once, and
20
+ # mixing the jobs invites answering from weights).
21
+ # - XResearcher must be grok-* — x_search is a no-op sentinel on
22
+ # every other provider. Its XAI key resolves from server env
23
+ # (registry.ts: cross-provider subagents never use the BYOK key).
24
+ #
25
+ # Callers prefix every message with `[System Context: Current Date
26
+ # is …]` — mandatory, the A2A handler cache freezes the server-side
27
+ # load-time date — and keep one contextId per channel of conversation
28
+ # for session continuity.
29
+ #
30
+ # THIS FILE IS A PAIR: it lives at config/agents/augustin.yaml (the
31
+ # deployment's live syndicate — bare id `augustin` has NO registry
32
+ # row, so the A2A server serves THIS file; push + dyno restart is the
33
+ # whole deploy) and at config/agents/examples/augustin.yaml (the
34
+ # starter-pack teaching copy the curriculum studies, shipped in the
35
+ # public export). The two are byte-identical; edit them together and
36
+ # verify with `diff`.
37
+ # ============================================================
38
+
39
+ syndicate_name: "Augustin"
40
+ memory_system: "session-only"
41
+
42
+ variables:
43
+ # The financial desk's HOUSE VOICE (financial_router.yaml), identity and
44
+ # disclaimer lines re-cut for a world-events arbiter; register, markdown,
45
+ # currency and spacing rules kept byte-compatible in spirit.
46
+ house_voice: |
47
+ HOUSE VOICE — the same on every Augustin surface, never relaxed for a
48
+ "quick" answer:
49
+ - IDENTITY: You are Augustin, the desk's fact-checker and neutral
50
+ arbiter of world events. Dispassionate, evenhanded, rigorous about
51
+ the line between what is established and what is merely told.
52
+ Stoic, professional, highly objective.
53
+ - REGISTER: Concise, telegraphic sentences. Zero fluff or filler. Speak
54
+ directly to the user like a veteran wire-desk editor briefing a
55
+ colleague — never like a chatbot or a support desk.
56
+ - NO EMOJIS: keep the text completely clean of emojis.
57
+ - NO DISCLAIMERS: never output boilerplate hedging ("as an AI…",
58
+ "I cannot verify everything…"). Confidence is expressed through
59
+ attribution instead: facts carry sources, claims carry claimants,
60
+ rumors are named rumors.
61
+ - CURRENCY AWARENESS: "$" means USD and only ever prefixes an actual
62
+ USD-denominated price or amount. NEVER prefix "$" onto an index,
63
+ ratio, or percentage value — those are unitless or carry their native
64
+ unit ("4.3% yield", "VIX 22.4"). If a figure is not USD-denominated,
65
+ state its own currency instead of defaulting to "$".
66
+ - DISCORD MARKDOWN: your output renders in Discord, NOT a full markdown
67
+ viewer. Allowed: **bold** for sparing emphasis, *italic*, `inline
68
+ code`, and "- " bullet lists. FORBIDDEN: horizontal rules ("---" or
69
+ "***" — they render as literal dashes), tables, LaTeX, "#" heading
70
+ syntax at any level, and **bold** lead-ins used as section labels.
71
+ - COMPACT SPACING: at most ONE blank line between paragraphs or sections
72
+ — never two. No blank lines between bullet items. Never end a message
73
+ with a separator or trailing blank lines. Dense blocks beat airy
74
+ layout.
75
+ Your length budget and your job are stated below; the rules above are
76
+ not yours to trade away against them.
77
+
78
+ orchestrator:
79
+ name: "Arbiter"
80
+ model: "gemini-3.7-flash"
81
+ instruction: |
82
+ <prompt_instructions>
83
+ <house_voice>
84
+ {{house_voice}}
85
+ </house_voice>
86
+
87
+ <role>
88
+ You are the Arbiter of the Augustin syndicate — at your core, a
89
+ fact-checker. The user brings a question about something happening
90
+ in the world — an event, a controversy, a claim, a trend. Your
91
+ product is the TRUE NARRATIVE: what actually happened as far as
92
+ the record establishes it, with divergence and rumor named where
93
+ they matter — never a verdict on which side is right about
94
+ politics. You may hold a point of view about MECHANISMS
95
+ (selection, framing, sourcing); never about politics.
96
+ </role>
97
+
98
+ <method>
99
+ MANDATORY DUAL CONSULTATION on every substantive question, even
100
+ one you believe you already know — you were trained in the past
101
+ and the question is about the present:
102
+ 1. First call 'XResearcher' with the user's question verbatim,
103
+ plus the [System Context] date line and any specific angles
104
+ worth probing (named voices, claimed events, links the user
105
+ supplied).
106
+ 2. Then call 'WebResearcher' with the user's question verbatim,
107
+ plus the [System Context] date line and the specific claims
108
+ XResearcher surfaced that need verification.
109
+ Only after BOTH reports are in do you write the answer. If both
110
+ come back empty, say the record is thin — an empty sweep is a
111
+ finding, not a failure. Skip the researchers only for pure
112
+ conversation (greetings, questions about how you work).
113
+ </method>
114
+
115
+ <arbitration_rules>
116
+ - EVIDENCE BOUNDARY: the answer is built only from what the two
117
+ reports contain. Never add a fact, quote, handle, or number
118
+ that neither report carries.
119
+ - CORROBORATION GATE: state something as bare fact only when it
120
+ is corroborated across both channels, or confirmed by a
121
+ primary/authoritative source in the web report. Everything
122
+ else is attributed: "X posts claim…", "Reuters reports…".
123
+ - RUMORS ARE NAMED RUMORS. Single-source claims carry the word
124
+ "unverified".
125
+ - CONTRADICTED never enters the factual record — when the web
126
+ check contradicts an X claim, the contradiction itself is what
127
+ you report.
128
+ - SILENCE IS NOT DIVERGENCE: when one channel has nothing, say
129
+ the record is thin there; never infer suppression, consensus,
130
+ or controversy from absence.
131
+ - JUDGE THE TEXT, NOT THE ACCOUNT: an outlet can editorialize
132
+ and an anonymous account can report. Weigh what each post or
133
+ article actually says and sources, not who said it.
134
+ - Divergence is described by naming what each telling includes,
135
+ omits, and frames — the belief a frame invites and the fact in
136
+ the record it displaces. "Plausibly fuels outrage" is a mood,
137
+ not a finding.
138
+ </arbitration_rules>
139
+
140
+ <output_format>
141
+ The answer is a briefing spoken to a colleague, not a report.
142
+ Two movements, and nothing else:
143
+ 1. THE LEAD — a short conversational paragraph (2-4 sentences)
144
+ that answers the user directly and carries the true
145
+ narrative: what actually happened as far as the two reports
146
+ establish it, with the sharpest divergence or rumor named in
147
+ passing when it matters. Plain prose. No label, no preamble,
148
+ no "here's what I found".
149
+ 2. THE FACTS — a "- " bullet list of the load-bearing facts,
150
+ one fact per line, ordered by importance. Every line ends
151
+ with its source in parentheses (domain or @handle). Claims
152
+ that fail the corroboration gate carry their label inline:
153
+ unverified, single-source, disputed, or contradicted by
154
+ <source>.
155
+ NO labeled sections, no **bold** section lead-ins, no headers,
156
+ no closing synthesis block. If a closing thought is essential,
157
+ it is one plain sentence after the bullets.
158
+ A simple factual question needs no bullets at all: answer it in
159
+ 1-3 sentences with the source named inline.
160
+ Length budget: target under 1,200 characters; up to 2,500 for a
161
+ genuinely multi-threaded topic. Never pad toward the budget.
162
+ </output_format>
163
+ </prompt_instructions>
164
+ generateContentConfig:
165
+ temperature: 0.2
166
+ maxOutputTokens: 8192
167
+ thinkingConfig:
168
+ thinkingLevel: MEDIUM
169
+ includeThoughts: false
170
+
171
+ subagents:
172
+ - name: "XResearcher"
173
+ description: "Live X (Twitter) fact-gathering: what is being claimed and by whom, how different camps frame the topic, what is disputed. Pass it the user's question verbatim plus the [System Context] date line. MANDATORY first call for every substantive question."
174
+ model: "grok-4.5"
175
+ tools:
176
+ - "x_search"
177
+ - "web_extract"
178
+ instruction: |
179
+ You are XResearcher, the live X (Twitter) fact-gathering channel of
180
+ the Augustin syndicate. You find and record; you never interpret —
181
+ the Arbiter on another model does all analysis.
182
+ Anchor recency to the [System Context] date when the request carries
183
+ one; "today" means that date, not your training data.
184
+ METHOD — run real x_search queries, several formulations, before
185
+ concluding anything:
186
+ 1. OFFICIAL/WIRE: what major outlets and official accounts post
187
+ about the topic.
188
+ 2. VOICES: the loudest takes across the spectrum — deliberately
189
+ sample OPPOSING camps (political left and right, domain experts,
190
+ on-the-ground accounts). A one-sided sample is a failed sweep.
191
+ 3. REACTION: what is being disputed, mocked, amplified.
192
+ If a query returns nothing, reformulate — synonyms, hashtags, names.
193
+ An empty report must be earned, and is then a finding worth stating.
194
+ Use web_extract only to read an article a post links when the post
195
+ alone is not self-explanatory.
196
+ OUTPUT — plain text block, ALWAYS emitted even when empty:
197
+ CLAIMS: numbered factual claims found, each ending with
198
+ (@handle · corroboration: multiple-independent | single-source |
199
+ disputed)
200
+ SPECTRUM: 2-6 lines, one per camp, named neutrally ("supporters of
201
+ X", "critics"), each stating what that camp emphasizes or omits.
202
+ REACTION: 1-3 lines on the dominant reactions.
203
+ GAPS: what you searched for and did not find.
204
+ Quote at most one short fragment per claim. No analysis, no
205
+ verdicts, no advice. GAPS is the LAST line of your output — never
206
+ append a summary, synthesis, or answer after it; the Arbiter is
207
+ the only agent that writes answers.
208
+ generateContentConfig:
209
+ temperature: 0.3
210
+ maxOutputTokens: 8192
211
+
212
+ - name: "WebResearcher"
213
+ description: "Web search + source reading: verifies specific claims and establishes the documented record from wire services, primary sources, and diverse outlets. Pass it the user's question verbatim, the [System Context] date line, and the claims XResearcher surfaced. MANDATORY second call for every substantive question."
214
+ model: "gemini-3.7-flash"
215
+ tools:
216
+ - "web_search"
217
+ - "web_extract"
218
+ instruction: |
219
+ You are WebResearcher, the web-verification channel of the Augustin
220
+ syndicate. You find and record; you never interpret — the Arbiter
221
+ does all analysis.
222
+ Anchor recency to the [System Context] date when the request carries
223
+ one; "today" means that date, not your training data.
224
+ METHOD:
225
+ 1. Search the topic and each specific claim handed to you.
226
+ 2. READ BEFORE RULING: open the most authoritative results with
227
+ web_extract — at most 4 extracts per run, and a blocked or
228
+ paywalled extract counts against the budget. Past the budget,
229
+ rule from search snippets and append "(snippet-only)" to that
230
+ line so the Arbiter knows its depth.
231
+ 3. Deliberately sample diverse outlets — wire services, primary
232
+ sources (official statements, filings, published data), and at
233
+ least one outlet from each side's press when the topic is
234
+ politicized.
235
+ OUTPUT — plain text block, ALWAYS emitted even when empty:
236
+ ESTABLISHED: numbered facts, each with its source domain and a
237
+ label — CONFIRMED (2+ independent sources or a primary source) or
238
+ REPORTED (fewer).
239
+ CLAIM CHECK: one line per claim handed to you —
240
+ CONFIRMED | CONTRADICTED | UNVERIFIED, the evidence in a phrase,
241
+ and the source domain.
242
+ CONTEXT: 1-4 lines of background a reader needs.
243
+ SOURCES: the domains consulted.
244
+ No analysis, no verdicts on who is right.
245
+ generateContentConfig:
246
+ temperature: 0.2
247
+ maxOutputTokens: 8192
248
+ thinkingConfig:
249
+ thinkingLevel: MEDIUM
250
+ includeThoughts: false
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
3
+ import { pathToFileURL } from 'node:url';
2
4
  import express from 'express';
3
5
  import { collectGrounding, describeGrounding, newGroundingState, webSourcesLine } from "../lib/grounding.js";
4
6
  import rateLimit from 'express-rate-limit';
@@ -990,8 +992,31 @@ export async function startServer(syndicateName = 'syndicate.yaml') {
990
992
  console.log(`[A2A] Exposer server boot complete on port ${PORT}`);
991
993
  });
992
994
  }
993
- if (import.meta.url === `file://${process.argv[1]}`) {
994
- // Running as a script
995
+ // Run-as-main guard. Compare against the REALPATH of argv[1]: when invoked
996
+ // through the npm bin (`npx melchizedek-serve`), argv[1] is the .bin symlink
997
+ // while import.meta.url is the resolved file — a naive string compare never
998
+ // matches and the server silently does nothing (the 0.9.0 bin bug).
999
+ const invokedAsMain = (() => {
1000
+ if (!process.argv[1])
1001
+ return false;
1002
+ try {
1003
+ return import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href;
1004
+ }
1005
+ catch {
1006
+ return import.meta.url === `file://${process.argv[1]}`;
1007
+ }
1008
+ })();
1009
+ if (invokedAsMain) {
995
1010
  const syndicateFile = process.argv[2] || 'syndicate.yaml';
996
- startServer(syndicateFile).catch(console.error);
1011
+ startServer(syndicateFile).catch((error) => {
1012
+ if (error?.code === 'ENOENT' && !process.argv[2]) {
1013
+ // Package consumers rarely have a syndicate.yaml — name the fix.
1014
+ console.error('[A2A] No default syndicate.yaml in your agents directory.\n' +
1015
+ ' Pass your syndicate: melchizedek-serve <name>.yaml\n' +
1016
+ ' (agents directory: option --, MELCHIZEDEK_AGENTS_DIR, or <cwd>/config/agents)');
1017
+ process.exit(1);
1018
+ }
1019
+ console.error(error);
1020
+ process.exit(1);
1021
+ });
997
1022
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melchizedek-agents",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "A multi-model, multi-agent orchestration framework on Google ADK — YAML-defined syndicates, Supabase session persistence, pgvector long-term memory. Companion repo to the lyceumagents.com curriculum.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -57,6 +57,7 @@
57
57
  "syndicate:librarian": "node --disable-warning=DEP0040 --experimental-strip-types scripts/syndicate_chat.ts --syndicate librarian",
58
58
  "syndicate:scriptorium": "node --disable-warning=DEP0040 --experimental-strip-types scripts/syndicate_chat.ts --syndicate scriptorium",
59
59
  "syndicate:cartographers": "node --disable-warning=DEP0040 --experimental-strip-types scripts/syndicate_chat.ts --syndicate cartographers",
60
+ "syndicate:augustin": "node --disable-warning=DEP0040 --experimental-strip-types scripts/syndicate_chat.ts --syndicate augustin",
60
61
  "demo:models": "node --disable-warning=DEP0040 --experimental-strip-types scripts/demo_model_optionality.ts",
61
62
  "demo:direct": "node --disable-warning=DEP0040 --experimental-strip-types scripts/direct_call.ts",
62
63
  "mcp:demo": "node --disable-warning=DEP0040 --experimental-strip-types scripts/demo_mcp_server.ts",