graphjin 3.18.41 → 3.18.43

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 (2) hide show
  1. package/README.md +36 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,10 +15,12 @@ Works with PostgreSQL, MySQL, MongoDB, SQLite, Oracle, MSSQL, Snowflake, Redshif
15
15
 
16
16
  ## Why GraphJin For Agents
17
17
 
18
+ - **A built-in agent, one call away** - POST one instruction to `/api/v1/agent` (or call the `ask_graphjin_agent` MCP tool) and GraphJin runs the discovery loop itself - as the caller, under the caller's permissions - and returns a typed, evidence-backed answer. See [Server-Side Agent](#server-side-agent).
18
19
  - **One governed surface for many systems** - Query operational databases, warehouses, MongoDB, object stores, local files, CodeSQL source indexes, workflows, and GraphJin system roots through GraphQL and MCP.
19
20
  - **Smart discovery before action** - Agents start with `query_catalog(search: "<user instruction>")`, `graphql_help`, relationship evidence, examples, config recipes, and safety notes before writing or running queries.
20
21
  - **Guarded action, not raw access** - Source-mode access, query allow-lists, read-only boundaries, policy-aware MCP tools, local encrypted secrets, and `gj_config` preview/apply keep changes auditable.
21
22
  - **Operational awareness** - `gj_security`, `gj_runtime`, and the built-in console expose policy and bounded runtime status so agents can check what is safe before they act.
23
+ - **Durable memory and standing questions** - Saved queries, fragments, and workflows live in the owner-scoped `gj_artifacts` store; cursor-backed watches (`gj_watch`) run standing questions under the owner's permissions, resume from persisted subscription cursors, and deliver fired events to a durable inbox (`gj_watch_event`), webhooks, or workflows. Normal watches are durable by default; explicit ephemeral watches use TTL leases.
22
24
 
23
25
  ## Installation
24
26
 
@@ -72,6 +74,12 @@ executable workflows:
72
74
  graphjin serve --demo --path examples/coffee-roastery
73
75
  ```
74
76
 
77
+ More demo verticals — a MySQL corrugated-box plant with JWT roles, a PCB fab
78
+ spanning Postgres + Snowflake-emu + MongoDB + a file source + an OpenAPI
79
+ supplier API, and a zero-Docker SQLite clinic scheduler — live in
80
+ [examples/](examples/README.md), each with an end-to-end smoke suite
81
+ (`make smoke-all` runs them all).
82
+
75
83
  You'll see output like this:
76
84
  ```
77
85
  GraphJin started
@@ -83,6 +91,18 @@ GraphJin started
83
91
  MCP: http://localhost:8080/api/v1/mcp
84
92
  ```
85
93
 
94
+ **Ask the built-in agent**
95
+
96
+ With a model API key in `./.env` (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GOOGLE_APIKEY`), `--demo` also switches into agentic mode and enables GraphJin's built-in agent - one instruction in, a typed, evidence-backed answer out. Against the coffee-roastery demo:
97
+
98
+ ```bash
99
+ curl -sS localhost:8080/api/v1/agent \
100
+ -H 'content-type: application/json' \
101
+ -d '{"instruction": "What production work should we prioritize next?"}'
102
+ ```
103
+
104
+ Answers come back as `{status, answer, data, evidence, actions, next}`, grounded by server-side protocol guards. See [Server-Side Agent](#server-side-agent) below, [AGENTIC.md](AGENTIC.md#server-side-agent), and [graphjin.com/agentic/server-agent](https://graphjin.com/agentic/server-agent/).
105
+
86
106
  ## Add GraphJin To Your AI Client
87
107
 
88
108
  ### Local / Dev
@@ -517,6 +537,7 @@ federation:
517
537
  | `/api/v1/openapi.json` | `GET` | OpenAPI 3 spec generated from your saved REST queries. |
518
538
  | `/api/v1/mcp` | `POST` | MCP (Model Context Protocol) HTTP transport — Streamable HTTP, stateless. |
519
539
  | `/api/v1/mcp/message` | `POST` | Legacy MCP message route for older local proxy/client integrations. New clients should use `/api/v1/mcp`. |
540
+ | `/api/v1/agent` | `POST` | Server-side agent: send one instruction, get a typed evidence-backed answer (only when `agent.enabled`). See [Server-Side Agent](#server-side-agent). |
520
541
  | `/.well-known/oauth-protected-resource[/api/v1/mcp]` | `GET` | MCP OAuth protected-resource metadata (only when `mcp.oauth.enabled`). |
521
542
  | `/.well-known/oauth-authorization-server` | `GET` | Built-in MCP OAuth authorization-server metadata (only when `mcp.oauth.enabled`). |
522
543
  | `/api/v1/oauth/register` | `POST` | Built-in MCP OAuth dynamic client registration (only in builtin mode). |
@@ -547,6 +568,8 @@ GraphJin exposes a catalog-first MCP surface that guides AI models to discover b
547
568
  - Act through governed GraphQL roots such as `gj_workflow_execution(insert)`, `gj_workflow(insert/update/delete)`, and `gj_config(id: "current", update: ...)` only when policy exposes them.
548
569
  - In source mode, `gj_config` writes must run `mode: "preview"` with `expected_catalog_revision`, then resend the exact same payload with `mode: "apply"` and `preview_id`.
549
570
  - Source access and GraphJin root changes should use `source_patches` by exact source name instead of rewriting the full `sources` array.
571
+ - Watches are managed through `gj_watch` / `gj_watch_event` and REST wrappers (`/api/v1/watches`, `/api/v1/watch-events/unseen`). MCP clients can subscribe to `graphjin://watch-events/unseen` for caller-scoped unseen-event notifications; unsubscribing does not pause or delete durable watches.
572
+ - Use `/api/v1/watches/cleanup-preview` before `/api/v1/watches/cleanup-apply`. Expired ephemeral watches can be expired automatically, but durable watch deletion is always explicit.
550
573
  - Legacy discovery tools are migration shims and are disabled unless `mcp.legacy_discovery: true`.
551
574
 
552
575
  Schema reloads, schema changes, where-clause validation, and query repair remain MCP action tools.
@@ -566,6 +589,19 @@ For JS orchestration, use:
566
589
 
567
590
  Legacy prompts such as `write_query` and `fix_query_error` are available only when the caller's MCP surface lists them; in source mode their guidance lives in `graphql_help`, `query_catalog`, and GraphJin repair hints.
568
591
 
592
+ ## Server-Side Agent
593
+
594
+ Optional: instead of your client chaining `query_catalog` → `validate_where_clause` → `execute_saved_query`, let GraphJin run the catalog-first discovery loop for you. When enabled, GraphJin exposes one MCP tool `ask_graphjin_agent` and one REST endpoint `POST /api/v1/agent` that take a single instruction and return a typed, evidence-backed answer (`status`, `answer`, `data`, `evidence`, `actions`, `next`).
595
+
596
+ - **Enable** by loading `agentic.yml` (`GO_ENV=agentic`) with `agent.enabled: true` plus a provider, model, and `api_key_env`.
597
+ - **Execution control:** there are no per-request agent modes. `agent.read_only: true` forces the server-side agent to reject mutations, including saved-query mutations; otherwise core roles, row-level security, source/table `read_only`, and Go protocol guards decide what can run.
598
+ - **Caller-scoped:** the agent runs as the caller, so core roles + row-level security enforce access. The caller's role only changes which *guidance* the agent follows, never what it can read or write.
599
+ - **Grounded:** Go protocol guards keep every answer backed by real catalog/validation/execution evidence and downgrade to `blocked` (with evidence) when a step is skipped.
600
+ - **Machine-actionable refusals:** blocked responses carry a structured `refusal` (code, reasons, unblock steps, `policy_final`/`retryable`) so a calling agent can course-correct in one step instead of guessing.
601
+ - **Model sampling:** with `agent.sampling: auto` (or `require`), the agent borrows the calling MCP client's model via MCP sampling — no server-side model key needed; caller identity and permissions are unchanged.
602
+
603
+ It is an RLM loop — the model writes JavaScript that calls the discovery tools, and the typed result is parsed from `key: value` output. So it needs a model that is good at **code generation**, not provider tool-calling or structured-output modes; any OpenAI-compatible endpoint works via `agent.base_url`. See [AGENTIC.md](AGENTIC.md#server-side-agent) and [CONFIG.md](CONFIG.md#agent-configuration).
604
+
569
605
  ## JS Workflows (GraphQL + REST)
570
606
 
571
607
  Workflows let an LLM run multi-step logic in JavaScript while still using GraphJin MCP tools for DB-aware operations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphjin",
3
- "version": "3.18.41",
3
+ "version": "3.18.43",
4
4
  "description": "GraphJin CLI - Build APIs in 5 minutes with GraphQL",
5
5
  "bin": {
6
6
  "graphjin": "bin/graphjin.js"