@wordinweb/agent 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -27,29 +27,50 @@ An AI invitation link can bootstrap a live shell session without an MCP
27
27
  installation:
28
28
 
29
29
  ```bash
30
- npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-3' wordinweb-agent connect '<short invitation URL>'
30
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent connect '<short invitation URL>'
31
31
  ```
32
32
 
33
- The command starts a detached local bridge, captures the current Codex or
34
- Claude session, and returns a `sessionId`. The bridge waits without model turns.
35
- It resumes the agent session when the inviter sends a private message. Run each
36
- JSON document command through a short process:
33
+ The command starts a detached local bridge and returns a `sessionId`. For Codex,
34
+ the bridge starts one dedicated resident document thread. Each private message
35
+ starts a turn on that thread, so its document context stays warm. The bridge
36
+ waits without model turns. Claude uses its captured session for each private
37
+ message. Each started turn supplies a `wakeId`. Include it in every document
38
+ command for that turn:
37
39
 
38
40
  ```bash
39
- npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-3' wordinweb-agent session '<sessionId>' '{"command":"sync"}'
41
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent session '<sessionId>' '{"command":"sync","wakeId":"<wakeId>"}'
40
42
  ```
41
43
 
42
- The bridge supports `sync`, `capabilities`, `inspect`, `edit`, `chat`, and
43
- `close`. `wait` remains available for manual clients. Every edit includes the
44
- inspected revision. When the room advances, the package compares the edit's
45
- inspected targets with their current state. Unchanged targets proceed across
46
- the newer revision. Changed targets return `needs_sync`. The bridge places the
47
- agent's visible collaboration cursor after its latest edit.
44
+ The bridge supports `sync`, `capabilities`, `inspect`, `edit`, `project`,
45
+ `patch`, `chat`, and `close`. `wait` remains available for manual clients. Every
46
+ edit includes the inspected revision. When the room advances, the package
47
+ compares the edit's inspected targets with their current state. Unchanged
48
+ targets proceed across the newer revision. Changed targets return `needs_sync`.
49
+ A `patch` against a stale window returns `needs_sync` the same way. In
50
+ suggestion mode the bridge applies every patch as tracked changes. The bridge
51
+ places the agent's visible collaboration cursor after its latest edit. A
52
+ successful turn ends with a `chat` command for the current `wakeId`. The bridge
53
+ interrupts a turn after 60 seconds and reports the failure in the private
54
+ document chat.
55
+
56
+ For a bulk prose rewrite, project the story once and send the changed lines
57
+ back:
58
+
59
+ ```bash
60
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent session '<sessionId>' '{"command":"project","wakeId":"<wakeId>","request":{"mode":"md"}}'
61
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent session '<sessionId>' '{"command":"patch","wakeId":"<wakeId>","request":{"revision":"<projection revision>","mode":"md","edits":[{"startLine":4,"endLine":4,"newText":"Adopt the managed platform."}]}}'
62
+ ```
63
+
64
+ Inspect the current wake state with a short status command:
65
+
66
+ ```bash
67
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent session '<sessionId>' '{"daemon":"status"}'
68
+ ```
48
69
 
49
70
  For a broad text task, read all non-empty stories in one bounded compact call:
50
71
 
51
72
  ```bash
52
- npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-3' wordinweb-agent session '<sessionId>' '{"command":"inspect","request":{"kind":"context"}}'
73
+ npx -y --package='https://collab.word-in-web.com/wordinweb-agent.tgz?v=short-invite-6' wordinweb-agent session '<sessionId>' '{"command":"inspect","wakeId":"<wakeId>","request":{"kind":"context"}}'
53
74
  ```
54
75
 
55
76
  ## Headless use
@@ -129,9 +150,31 @@ const result = await document.compose({
129
150
  console.log(result.overview.outline, result.createdObjects);
130
151
  ```
131
152
 
132
- `AgentDocument.create()` starts a blank DOCX. `tools()` returns six portable
133
- tool objects for composition, capabilities, inspection, edits, asset reads,
134
- and DOCX saves.
153
+ `AgentDocument.create()` starts a blank DOCX. `tools()` returns eight portable
154
+ tool objects for composition, capabilities, inspection, edits, text projection,
155
+ projection patches, asset reads, and DOCX saves.
156
+
157
+ ## Text projection
158
+
159
+ `project` renders a story as deterministic text — plain paragraphs, structural
160
+ markdown, or the outline — with an anchor map that carries every line back to
161
+ its block, its runs, and their wire offsets. `patch` takes line-range hunks or
162
+ a unified diff written against that projection and compiles them into the same
163
+ intents an editor emits, so a bulk rewrite costs one window and one call.
164
+
165
+ ```ts
166
+ const projection = agentDoc.project({ mode: "md" });
167
+ await agentDoc.patch({
168
+ revision: projection.revision,
169
+ mode: "md",
170
+ edits: [{ startLine: 4, endLine: 4, newText: "Adopt the managed platform." }],
171
+ });
172
+ ```
173
+
174
+ Agents read the text and never see a wire offset: the anchor map is built in
175
+ the same pass as the text and owns that translation. Projecting never changes
176
+ the document. The projection contract, the atom placeholders, and the patch
177
+ rules live in the skill's `references/interface.md`.
135
178
 
136
179
  ## Progressive inspection
137
180