@ferricstore/ferricstore 0.11.11 → 0.12.1

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 (87) hide show
  1. package/README.md +19 -1
  2. package/dist/durability-DlDCsdlo.d.cts +16 -0
  3. package/dist/durability-DplL0SbW.d.ts +16 -0
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +5 -162
  7. package/dist/index.d.ts +5 -162
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/internal-lEEDZpPH.d.cts +4 -0
  11. package/dist/internal-lEEDZpPH.d.ts +4 -0
  12. package/dist/langgraph.cjs +1548 -0
  13. package/dist/langgraph.cjs.map +1 -0
  14. package/dist/langgraph.d.cts +158 -0
  15. package/dist/langgraph.d.ts +158 -0
  16. package/dist/langgraph.js +1522 -0
  17. package/dist/langgraph.js.map +1 -0
  18. package/dist/openai-agents.cjs +717 -0
  19. package/dist/openai-agents.cjs.map +1 -0
  20. package/dist/openai-agents.d.cts +50 -0
  21. package/dist/openai-agents.d.ts +50 -0
  22. package/dist/openai-agents.js +692 -0
  23. package/dist/openai-agents.js.map +1 -0
  24. package/dist/outcomes-BbFDp3AH.d.ts +160 -0
  25. package/dist/outcomes-DmBwnq0Y.d.cts +160 -0
  26. package/docs/agent-api/assets/hierarchy.js +1 -0
  27. package/docs/agent-api/assets/highlight.css +92 -0
  28. package/docs/agent-api/assets/icons.js +18 -0
  29. package/docs/agent-api/assets/icons.svg +1 -0
  30. package/docs/agent-api/assets/main.js +60 -0
  31. package/docs/agent-api/assets/navigation.js +1 -0
  32. package/docs/agent-api/assets/search.js +1 -0
  33. package/docs/agent-api/assets/style.css +1648 -0
  34. package/docs/agent-api/classes/langgraph.FerricStoreSaver.html +297 -0
  35. package/docs/agent-api/classes/langgraph.FerricStoreStore.html +298 -0
  36. package/docs/agent-api/classes/langgraph.LangGraphFlow.html +190 -0
  37. package/docs/agent-api/classes/langgraph.LangGraphFlowContext.html +158 -0
  38. package/docs/agent-api/classes/langgraph.LangGraphFlowRun.html +133 -0
  39. package/docs/agent-api/classes/openai-agents.FerricStoreSession.html +241 -0
  40. package/docs/agent-api/hierarchy.html +44 -0
  41. package/docs/agent-api/index.html +142 -0
  42. package/docs/agent-api/interfaces/langgraph.FerricFlowHandlerContext.html +94 -0
  43. package/docs/agent-api/interfaces/langgraph.FerricStoreCommandClient.html +77 -0
  44. package/docs/agent-api/interfaces/langgraph.FerricStoreLockOptions.html +81 -0
  45. package/docs/agent-api/interfaces/langgraph.FerricStoreSaverOptions.html +106 -0
  46. package/docs/agent-api/interfaces/langgraph.FerricStoreStoreOptions.html +98 -0
  47. package/docs/agent-api/interfaces/langgraph.InvokableLangGraph.html +83 -0
  48. package/docs/agent-api/interfaces/langgraph.LangGraphFlowOptions.html +116 -0
  49. package/docs/agent-api/interfaces/openai-agents.FerricStoreSessionOptions.html +114 -0
  50. package/docs/agent-api/interfaces/openai-agents.Session.html +208 -0
  51. package/docs/agent-api/interfaces/openai-agents.SessionHistoryRewriteAwareSession.html +230 -0
  52. package/docs/agent-api/interfaces/openai-agents.SessionHistoryTransactionAwareSession.html +237 -0
  53. package/docs/agent-api/modules/langgraph.html +44 -0
  54. package/docs/agent-api/modules/openai-agents.html +44 -0
  55. package/docs/agent-api/modules.html +35 -0
  56. package/docs/agent-api/types/langgraph.LangGraphChannelVersions.html +33 -0
  57. package/docs/agent-api/types/langgraph.LangGraphInvocationConfig.html +33 -0
  58. package/docs/agent-api/types/langgraph.LangGraphOutcomeMapper.html +50 -0
  59. package/docs/agent-api/types/langgraph.LangGraphPendingWrite.html +33 -0
  60. package/docs/agent-api/types/openai-agents.AgentInputItem.html +35 -0
  61. package/docs/agent-frameworks.md +176 -0
  62. package/docs/api/assets/highlight.css +12 -12
  63. package/docs/api/classes/ClaimHydrationError.html +2 -2
  64. package/docs/api/classes/ConnectionClosedError.html +2 -2
  65. package/docs/api/classes/FerricStoreError.html +2 -2
  66. package/docs/api/classes/FlowAlreadyExistsError.html +2 -2
  67. package/docs/api/classes/FlowBatchError.html +2 -2
  68. package/docs/api/classes/FlowNotFoundError.html +2 -2
  69. package/docs/api/classes/FlowQueryError.html +2 -2
  70. package/docs/api/classes/FlowWrongStateError.html +2 -2
  71. package/docs/api/classes/HTTPTransportError.html +2 -2
  72. package/docs/api/classes/InvalidCommandError.html +2 -2
  73. package/docs/api/classes/LeaseRenewalError.html +2 -2
  74. package/docs/api/classes/LockHeldError.html +2 -2
  75. package/docs/api/classes/LockNotOwnedError.html +2 -2
  76. package/docs/api/classes/OverloadedError.html +2 -2
  77. package/docs/api/classes/QueueCompletionError.html +2 -2
  78. package/docs/api/classes/RequestTimeoutError.html +2 -2
  79. package/docs/api/classes/RerouteError.html +2 -2
  80. package/docs/api/classes/StaleLeaseError.html +2 -2
  81. package/docs/api/classes/StalePolicyGenerationError.html +2 -2
  82. package/docs/api/index.html +37 -24
  83. package/docs/api/media/agent-frameworks.md +176 -0
  84. package/docs/api/media/langgraph.ts +23 -0
  85. package/docs/api/media/openai-agents-session.ts +13 -0
  86. package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +1 -1
  87. package/package.json +43 -4
@@ -0,0 +1,176 @@
1
+ # Agent framework persistence
2
+
3
+ FerricStore's TypeScript package has optional adapters for LangGraph.js and the
4
+ OpenAI Agents SDK. They live in separate package entry points, so the base SDK
5
+ does not load either framework.
6
+
7
+ ## Install
8
+
9
+ For LangGraph.js:
10
+
11
+ ```bash
12
+ npm install @ferricstore/ferricstore @langchain/langgraph @langchain/core
13
+ ```
14
+
15
+ For the OpenAI Agents SDK:
16
+
17
+ ```bash
18
+ npm install @ferricstore/ferricstore @openai/agents
19
+ ```
20
+
21
+ Both adapters accept the normal `FerricStoreClient`. Their serialization is
22
+ independent of the client's configured codec.
23
+
24
+ ## LangGraph.js checkpoints
25
+
26
+ `FerricStoreSaver` implements LangGraph's `BaseCheckpointSaver` contract:
27
+
28
+ ```ts
29
+ import { Annotation, END, START, StateGraph } from "@langchain/langgraph";
30
+ import { FerricStoreClient } from "@ferricstore/ferricstore";
31
+ import { FerricStoreSaver } from "@ferricstore/ferricstore/langgraph";
32
+
33
+ const client = await FerricStoreClient.fromUrl("ferric://127.0.0.1:6388");
34
+ const saver = new FerricStoreSaver(client);
35
+
36
+ const State = Annotation.Root({ count: Annotation<number>() });
37
+ const graph = new StateGraph(State)
38
+ .addNode("increment", ({ count }) => ({ count: count + 1 }))
39
+ .addEdge(START, "increment")
40
+ .addEdge("increment", END)
41
+ .compile({ checkpointer: saver });
42
+
43
+ await graph.invoke(
44
+ { count: 0 },
45
+ { configurable: { thread_id: "agent-42" } }
46
+ );
47
+ ```
48
+
49
+ The saver supports named checkpoint namespaces, latest and exact reads,
50
+ ordered and filtered listing, parent chains, pending writes, retry-safe write
51
+ indexes, global listing, and complete thread deletion. It uses LangGraph's
52
+ serializer, so framework-specific values round-trip correctly.
53
+
54
+ Checkpoint mutations are serialized per thread with renewable,
55
+ ownership-checked locks. Indexes are published before the final checkpoint
56
+ record; readers validate each record and skip incomplete entries. This makes a
57
+ process failure during publication invisible and a retry safe.
58
+
59
+ ## LangGraph.js long-term memory
60
+
61
+ `FerricStoreStore` implements `BaseStore`:
62
+
63
+ ```ts
64
+ import { FerricStoreStore } from "@ferricstore/ferricstore/langgraph";
65
+
66
+ const store = new FerricStoreStore(client);
67
+
68
+ await store.put(["users", "u-42"], "preferences", {
69
+ language: "en",
70
+ notifications: true
71
+ });
72
+
73
+ const memories = await store.search(["users", "u-42"], {
74
+ filter: { notifications: true }
75
+ });
76
+ ```
77
+
78
+ It supports hierarchical namespaces, atomic per-item mutation ordering,
79
+ batched operations, exact and comparison filters (`$eq`, `$ne`, `$gt`, `$gte`,
80
+ `$lt`, `$lte`, `$in`, `$nin`), ordered pagination, namespace listing, updates,
81
+ and deletion.
82
+ Semantic `query` search currently throws a clear error because no vector index
83
+ is configured; it never silently returns unranked data.
84
+
85
+ ## Run LangGraph inside FerricFlow
86
+
87
+ The checkpointer makes graph steps resumable. `LangGraphFlow` adds the durable
88
+ outer lifecycle: leases and fencing, retries, scheduled work, signals,
89
+ approvals, workflow history, and terminal state.
90
+
91
+ ```ts
92
+ import { LangGraphFlow } from "@ferricstore/ferricstore/langgraph";
93
+
94
+ const agentFlow = new LangGraphFlow(graph, {
95
+ interruptState: "waiting_for_approval"
96
+ });
97
+
98
+ workflow.state("running", agentFlow.handler.bind(agentFlow));
99
+ ```
100
+
101
+ By default, the bridge derives a stable LangGraph `thread_id` from the Flow
102
+ type, partition, and ID. It sends the Flow payload on the first invocation and
103
+ uses `null` input when a checkpoint already exists. LangGraph runtime context
104
+ includes the active `WorkflowContext`. Completed graphs become `complete()`
105
+ outcomes; interrupts can transition to a chosen Flow state or use a custom
106
+ outcome mapper. Call `resume(flowContext, value)` from a handler to send a
107
+ LangGraph `Command({ resume: value })`.
108
+
109
+ Static `invokeOptions` and values returned by the `config` callback are merged,
110
+ including their nested `configurable` and `metadata` objects. Dynamic values
111
+ override static values; the bridge always owns `thread_id`, `checkpoint_ns`, and
112
+ the `ferricflow_*` metadata fields. An explicitly supplied runtime context is
113
+ preserved.
114
+
115
+ The graph checkpointer and FerricFlow solve different layers and are intended
116
+ to be used together:
117
+
118
+ ```text
119
+ FerricFlow durable run lifecycle
120
+ ↓
121
+ LangGraphFlow invocation bridge
122
+ ↓
123
+ LangGraph graph + FerricStoreSaver
124
+ ↓
125
+ FerricStore
126
+ ```
127
+
128
+ ## OpenAI Agents SDK Session
129
+
130
+ `FerricStoreSession` implements the base `Session` contract plus the optional
131
+ history rewrite and atomic transaction capabilities used by the current
132
+ OpenAI Agents SDK:
133
+
134
+ ```ts
135
+ import { Agent, run } from "@openai/agents";
136
+ import { FerricStoreSession } from "@ferricstore/ferricstore/openai-agents";
137
+
138
+ const session = new FerricStoreSession(client, {
139
+ sessionId: "customer-42"
140
+ });
141
+ const agent = new Agent({ name: "Support", instructions: "Be helpful." });
142
+
143
+ await run(agent, "Where is my order?", { session });
144
+ ```
145
+
146
+ The adapter provides chronological reads with tail limits, append, pop,
147
+ clear, compaction replacement, function-call history rewrites, and atomic
148
+ `append_items` / `replace_suffix` transactions. A transaction stores its
149
+ operation ID and history mutation in one atomic record. Repeating the same
150
+ operation is a no-op; reusing its ID for different content or replacing a
151
+ non-matching suffix fails without changing history. Versioned transaction
152
+ digests are deterministic across worker locales, while receipts created by the
153
+ original locale-ordered format remain valid during migration. When an existing
154
+ deployment also changes locale, pass its previous locale tags through
155
+ `legacyReceiptLocales` until its receipts have been replayed and upgraded.
156
+
157
+ All session mutations use a renewable FerricStore lock for contention control
158
+ and a native compare-and-swap commit for correctness. Reads see either the old
159
+ or new complete session record, never a partial history, and a writer whose
160
+ lock expires cannot overwrite a newer state. `clearSession()` also clears
161
+ transaction receipts. Session persistence stores conversation history; put the
162
+ overall agent run in FerricFlow when it also needs durable leases, retries,
163
+ timers, signals, or multi-step business state.
164
+
165
+ ## Operational options
166
+
167
+ All three adapters accept `keyPrefix`, `lockTtlMs`, `lockWaitMs`, and
168
+ `lockRetryMs`. The saver and store also accept `scanCount`; the saver accepts a
169
+ custom LangGraph serializer. Defaults are suitable for ordinary use. Give
170
+ different applications or environments different prefixes when they share a
171
+ FerricStore deployment. `lockRetryMs` must be lower than `lockTtlMs`. Before
172
+ publishing authoritative state, the adapters use FerricStore CAS. LangGraph
173
+ checkpoint deletion advances a thread epoch, and BaseStore deletion writes a
174
+ CAS tombstone; their discovery indexes are append-only and validated on reads.
175
+ These rules make late commands from expired writers harmless even across
176
+ processes.
@@ -0,0 +1,23 @@
1
+ import { Annotation, END, START, StateGraph } from "@langchain/langgraph";
2
+ import { FerricStoreClient } from "@ferricstore/ferricstore";
3
+ import { FerricStoreSaver, FerricStoreStore } from "@ferricstore/ferricstore/langgraph";
4
+
5
+ const client = await FerricStoreClient.fromUrl(
6
+ process.env.FERRICSTORE_URL ?? "ferric://127.0.0.1:6388"
7
+ );
8
+ const checkpointer = new FerricStoreSaver(client);
9
+ const store = new FerricStoreStore(client);
10
+
11
+ const State = Annotation.Root({ count: Annotation<number>() });
12
+ const graph = new StateGraph(State)
13
+ .addNode("increment", ({ count }) => ({ count: count + 1 }))
14
+ .addEdge(START, "increment")
15
+ .addEdge("increment", END)
16
+ .compile({ checkpointer, store });
17
+
18
+ const result = await graph.invoke(
19
+ { count: 0 },
20
+ { configurable: { thread_id: "example-agent" } }
21
+ );
22
+ console.log(result);
23
+ await client.close();
@@ -0,0 +1,13 @@
1
+ import { Agent, run } from "@openai/agents";
2
+ import { FerricStoreClient } from "@ferricstore/ferricstore";
3
+ import { FerricStoreSession } from "@ferricstore/ferricstore/openai-agents";
4
+
5
+ const client = await FerricStoreClient.fromUrl(
6
+ process.env.FERRICSTORE_URL ?? "ferric://127.0.0.1:6388"
7
+ );
8
+ const session = new FerricStoreSession(client, { sessionId: "example-conversation" });
9
+ const agent = new Agent({ name: "Assistant", instructions: "Be concise and helpful." });
10
+
11
+ const result = await run(agent, "Remember that my preferred language is TypeScript.", { session });
12
+ console.log(result.finalOutput);
13
+ await client.close();
@@ -10,7 +10,7 @@
10
10
  <ul class="tsd-breadcrumb" aria-label="Breadcrumb">
11
11
  <li><a href="" aria-current="page">FERRICSTORE_SDK_VERSION</a></li></ul>
12
12
  <h1>Variable FERRICSTORE_SDK_VERSION<code class="tsd-tag">Const</code></h1></div>
13
- <div class="tsd-signature"><span class="tsd-kind-variable">FERRICSTORE_SDK_VERSION</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;0.11.11&quot;</span></div>
13
+ <div class="tsd-signature"><span class="tsd-kind-variable">FERRICSTORE_SDK_VERSION</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;0.12.0&quot;</span></div>
14
14
  <div class="tsd-comment tsd-typography"><p>TypeScript SDK package version.</p>
15
15
  </div><aside class="tsd-sources">
16
16
  <ul>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferricstore/ferricstore",
3
- "version": "0.11.11",
3
+ "version": "0.12.1",
4
4
  "description": "TypeScript SDK for FerricStore and FerricFlow",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -52,6 +52,26 @@
52
52
  "default": "./dist/index.cjs"
53
53
  }
54
54
  },
55
+ "./langgraph": {
56
+ "import": {
57
+ "types": "./dist/langgraph.d.ts",
58
+ "default": "./dist/langgraph.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/langgraph.d.cts",
62
+ "default": "./dist/langgraph.cjs"
63
+ }
64
+ },
65
+ "./openai-agents": {
66
+ "import": {
67
+ "types": "./dist/openai-agents.d.ts",
68
+ "default": "./dist/openai-agents.js"
69
+ },
70
+ "require": {
71
+ "types": "./dist/openai-agents.d.cts",
72
+ "default": "./dist/openai-agents.cjs"
73
+ }
74
+ },
55
75
  "./package.json": "./package.json"
56
76
  },
57
77
  "files": [
@@ -61,10 +81,10 @@
61
81
  "LICENSE"
62
82
  ],
63
83
  "scripts": {
64
- "build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean",
84
+ "build": "tsup src/index.ts src/langgraph.ts src/openai-agents.ts --format esm,cjs --dts --sourcemap --clean --splitting false",
65
85
  "check": "npm run typecheck && npm run lint && npm run test && npm run build && npm run test:exports && npm run docs:check",
66
- "docs": "typedoc",
67
- "docs:check": "typedoc --logLevel Warn && node scripts/check-generated-docs.mjs",
86
+ "docs": "typedoc --logLevel Warn && typedoc --options typedoc.agent.json --logLevel Warn",
87
+ "docs:check": "npm run docs && node scripts/check-generated-docs.mjs",
68
88
  "integration:down": "docker compose down -v",
69
89
  "integration:up": "docker compose up -d ferricstore && node scripts/wait-for-ferricstore.mjs",
70
90
  "lint": "eslint .",
@@ -84,6 +104,9 @@
84
104
  "@emnapi/core": "^1.11.3",
85
105
  "@emnapi/runtime": "^1.11.3",
86
106
  "@eslint/js": "^10.0.1",
107
+ "@langchain/core": "^1.2.9",
108
+ "@langchain/langgraph": "^1.4.12",
109
+ "@openai/agents": "^0.17.0",
87
110
  "@types/node": "^22.20.1",
88
111
  "eslint": "^10.9.0",
89
112
  "tsup": "^8.5.1",
@@ -91,5 +114,21 @@
91
114
  "typescript": "^6.0.3",
92
115
  "typescript-eslint": "^8.67.0",
93
116
  "vitest": "^4.1.11"
117
+ },
118
+ "peerDependencies": {
119
+ "@langchain/core": ">=1.1.48 <2",
120
+ "@langchain/langgraph": ">=1.4.12 <2",
121
+ "@openai/agents": ">=0.17.0 <1"
122
+ },
123
+ "peerDependenciesMeta": {
124
+ "@langchain/core": {
125
+ "optional": true
126
+ },
127
+ "@langchain/langgraph": {
128
+ "optional": true
129
+ },
130
+ "@openai/agents": {
131
+ "optional": true
132
+ }
94
133
  }
95
134
  }