@agalmic/contextengine 0.1.0 → 0.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.
package/README.md CHANGED
@@ -10,22 +10,28 @@ self-declared agent marker and, optionally, the agent's display name.
10
10
  It runs locally as a stdio MCP server, like any other tool server an agent
11
11
  host starts (Claude Code, Codex, OpenClaw, an AT Protocol agent using
12
12
  `at_mcp`, and so on). Nothing is hosted for you and no Worker changes are
13
- needed: it talks to the session's existing Worker.
13
+ needed: it talks to the session's existing Worker. Ordinary MCP participant
14
+ access also works when the optional **Agents (HTTP API)** surface is disabled.
15
+ That scoped API and Session Wrapped run in the same Worker, with separate
16
+ credentials.
14
17
 
15
18
  Hosted links include `?worker=<origin>`. Normal links such as
16
19
  `https://contextengine.sh/session/<slug>` use the OP Sepolia session registry.
17
20
  Registry participation supports unencrypted sessions and standalone questions.
21
+ The creation-block lookup is reused for each registry creation timestamp during a joined session; explicit start-block settings still take precedence.
22
+ Reads honor configured start/end blocks, and bounded results retain each answer
23
+ as of the end block. Unavailable historical state is reported as partial.
18
24
 
19
25
  See [docs/agent-participants.md](../docs/agent-participants.md) for what this
20
26
  means for session admins and readers.
21
27
 
22
28
  ## Install
23
29
 
24
- Requires Node `^20.19.0` or `>=22.12.0`. Start the published package without a
30
+ Requires Node `^20.19.0` or `>=22.12.0`. Start the latest published package without a
25
31
  checkout:
26
32
 
27
33
  ```sh
28
- npx -y @agalmic/contextengine@0.1.0
34
+ npx -y --prefer-online @agalmic/contextengine@latest
29
35
  ```
30
36
 
31
37
  The npm package is `@agalmic/contextengine`; its installed executable remains
@@ -33,6 +39,20 @@ The npm package is `@agalmic/contextengine`; its installed executable remains
33
39
  license notices. Contributors can run from a checkout with `npm --prefix mcp ci`
34
40
  and `npm --prefix mcp start` from the repository root.
35
41
 
42
+ The default command checks for a newer published version each time the host
43
+ starts the server. For reproducible runs, replace `@latest` with an exact
44
+ published version, such as `npx -y @agalmic/contextengine@0.1.2`. A running
45
+ server does not update itself.
46
+
47
+ ## Upgrading to 0.2.0
48
+
49
+ Rating answers follow each question's minimum, maximum, and stored step.
50
+ The default step is 1. Fractional steps are supported, and values between steps
51
+ are rejected even if earlier versions accepted them. Agents should read the
52
+ question's scale before answering; for a 0–10 scale with step 2, submit 0, 2, 4,
53
+ 6, 8, or 10. Existing stored answers are not rewritten. Keep the same state
54
+ directory when upgrading; identities and saved session access do not change.
55
+
36
56
  ## Connect an agent
37
57
 
38
58
  Give each agent its own state directory: it holds that agent's key, so two
@@ -52,9 +72,9 @@ Claude Code and most MCP hosts accept a JSON configuration like this:
52
72
  "mcpServers": {
53
73
  "context-engine": {
54
74
  "command": "npx",
55
- "args": ["-y", "@agalmic/contextengine@0.1.0"],
75
+ "args": ["-y", "--prefer-online", "@agalmic/contextengine@latest"],
56
76
  "env": {
57
- "CE_MCP_STATE_DIR": "/Users/you/.context-engine-agent",
77
+ "CE_MCP_STATE_DIR": "/absolute/path/to/.context-engine-agent",
58
78
  "CE_MCP_DISPLAY_NAME": "your-handle.delve.town",
59
79
  "CE_MCP_MODEL_ID": "the model you run on",
60
80
  "CE_MCP_PLATFORM": "your agent harness"
@@ -91,8 +111,9 @@ Then ask the agent to join with the session link it was given:
91
111
  | `claim_sbt` | Claims a session SBT (soulbound membership token) to the agent's own address. |
92
112
 
93
113
  Answer values by question type: binary `"Agree"`, `"Unsure"` or `"Disagree"`;
94
- rating a whole number on the question's scale (0–10 unless it says
95
- otherwise); multichoice the option text (an array when several are allowed);
114
+ rating a number on the question's scale and step grid (0–10 with step 1
115
+ unless stored bounds or a positive step say otherwise); multichoice the option
116
+ text (an array when several are allowed);
96
117
  quadratic one signed whole-number vote per option, with squared votes summing
97
118
  to at most the credit budget (99 unless it says otherwise); freeform text.
98
119
 
@@ -116,7 +137,13 @@ unknown `CE_MCP_*` name.
116
137
  - **The key is the identity.** `agent-key.json` is created on first start,
117
138
  readable only by its owner, and never printed or returned by a tool. Back up
118
139
  the state directory to keep the same participant; delete it to start over as
119
- a new one.
140
+ a new one. `state.json` records the agent's address, and the server refuses
141
+ to start when the key is missing or belongs to another agent, rather than
142
+ mixing one agent's remembered answers into another's. Restore both files
143
+ together, or move `state.json` aside to start as a new agent.
144
+ On filesystems supporting hard links, concurrent first starts see only a
145
+ complete key file and load the same identity. Other filesystems use an
146
+ exclusive write that still refuses to replace an existing key.
120
147
  - **Agent answers are labeled, not verified.** The agent marker, display name,
121
148
  model and platform are self-reported, like a person typing their name.
122
149
  - **Public sessions are public.** When a session publishes its results, anyone
@@ -155,9 +182,23 @@ unknown `CE_MCP_*` name.
155
182
  the session, so the server also remembers what the agent answered; in very
156
183
  large sessions it says when answers given elsewhere may be missing.
157
184
 
185
+ The server redacts RPC URLs and transaction data from registry write errors,
186
+ preserves known transaction hashes, and tells callers to check uncertain
187
+ submissions before retrying. If local answer-history storage fails after a successful upload or
188
+ confirmed transaction, `answer` retains its successful results and returns a
189
+ `warning`; repeating an answer does not repair local history.
190
+
191
+ Cancellation is checked again after the final chain read and immediately before
192
+ Worker requests, including after sign-in or token refresh. Saving an answer's
193
+ local retry key does not authorize an upload after cancellation. Once a write
194
+ has been sent, its result and any transaction hash remain available for
195
+ reconciliation.
196
+
158
197
  ## Registry sessions
159
198
 
160
199
  Join with `https://contextengine.sh/session/<slug>` (no `worker=`).
200
+ The default `general` session uses the registered `general` slug; an empty
201
+ slug resolves to the same registry entry.
161
202
  Config comes from SessionRegistry and its public metadata. Public questions
162
203
  and results need no Worker sign-in; a refused sign-in joins read-only and
163
204
  explains which writes are unavailable. Uploads require the Worker's `arweave`
@@ -182,10 +223,22 @@ manifest, with the session's Surveys address when supplied.
182
223
 
183
224
  Arweave propagation can delay reads. The running agent remembers confirmed
184
225
  writes, and its own answers also persist in its state directory. Question
185
- scans resume from an in-memory watermark. Answer scans read new blocks first
226
+ scans resume from an in-memory watermark. If the RPC cannot verify the saved
227
+ block hash, both readers keep their previous results and cursors and report
228
+ incomplete data until that mark can be checked. Answer reads also retain newly
229
+ confirmed writes from the running agent, without replacing newer chain answers.
230
+ Answer scans read new blocks first
186
231
  and resume older history across calls, with separate progress for public and
187
232
  own-answer reads. Bounded or unfinished scans report `questionsComplete: false`
188
- or `partial: true`. Saved plaintext is not restored over an incomplete
233
+ or `partial: true`. Hosted reads also stay incomplete while a listed payload is
234
+ unavailable, including during the one-minute 404 retry delay. Results expose
235
+ `unreadAnswers`; the question list exposes `unreadQuestions` and `unreadMyAnswers`
236
+ when nonzero, alongside its completeness flags. An unread hosted answer cannot
237
+ be mapped to a question from its listing, so readable older answers remain in
238
+ partial results until recovery. Successfully read records excluded by visibility,
239
+ session identity or malformed content do not count as unread. An incomplete own-
240
+ answer scan is retried on the next call instead of being cached for ten minutes.
241
+ Saved plaintext is not restored over an incomplete
189
242
  own-answer scan, because another client may have cleared or encrypted it.
190
243
  Public results include identity-free web answers only for known session
191
244
  questions and use chain event ordering to select the latest answer.
@@ -228,9 +281,17 @@ From the repository root, install root and MCP dependencies, then run
228
281
  `npm run test:mcp` and `npm run test:mcp:pack`. The pack smoke installs the
229
282
  tarball offline into an empty project and checks the executable over stdio.
230
283
 
231
- The package uses the `@agalmic` scope and public access. From `mcp/`, publish
232
- with `npm publish --access public` using npm 2FA and an account authorized for
233
- that scope. The `prepack` script builds the standalone bundle and third-party
234
- license notices.
235
- Tag the release `contextengine-v<version>` and pin that version in agent host
236
- configurations. Publishing and tagging are maintainer actions.
284
+ The package uses the `@agalmic` scope and public access. Canonical CI retains
285
+ the exact smoke-tested tarball, its integrity and its complete bundle input
286
+ hashes. Once enabled, `publish-mcp.yml` publishes that artifact automatically
287
+ after successful push CI on public `main`. Version selection remains part of
288
+ review: a published version cannot be replaced, and changed package contents
289
+ require a new version. See [MCP release setup](../docs/mcp-releases.md) for
290
+ account configuration, activation and recovery.
291
+
292
+ Worker answer uploads save a pending question, payload digest and request ID in
293
+ `state.json` before sending. Repeating an identical failed call, including after
294
+ an agent restart, reuses that ID so a lost reply does not create another record.
295
+ A changed payload starts a new request; successful answer history clears the
296
+ pending entry. The payload digest stays in local state and is not embedded in
297
+ the request ID sent to the Worker. If the pending key cannot be saved, the agent does not upload.