@nyx5/nyx5 0.6.0 → 0.8.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 +50 -7
- package/bin/nyx5.js +81 -2
- package/demo/edge-local.mjs +41 -0
- package/demo/x402-pagar.mjs +64 -0
- package/demo/x402-testnet.mjs +80 -0
- package/docs/ARQUITECTURA.md +354 -0
- package/docs/SPEC.md +414 -15
- package/examples/ci/nyx5-ejecutor.yml +82 -0
- package/examples/frameworks/README.md +55 -0
- package/examples/frameworks/__pycache__/crewai_nyx5.cpython-314.pyc +0 -0
- package/examples/frameworks/__pycache__/langgraph_nyx5.cpython-314.pyc +0 -0
- package/examples/frameworks/__pycache__/nyx5_http.cpython-314.pyc +0 -0
- package/examples/frameworks/claude-agent-sdk.mjs +48 -0
- package/examples/frameworks/crewai_nyx5.py +72 -0
- package/examples/frameworks/http.md +117 -0
- package/examples/frameworks/langgraph_nyx5.py +90 -0
- package/examples/frameworks/nyx5_http.py +255 -0
- package/examples/frameworks/openai-agents.mjs +41 -0
- package/examples/hola-mundo.mjs +4 -4
- package/migrations/0006_puente_remoto.sql +19 -0
- package/migrations/0007_indice_reputacion.sql +31 -0
- package/migrations/0008_notaria.sql +18 -0
- package/migrations/0009_contratos_estado.sql +4 -0
- package/package.json +4 -2
- package/server.json +2 -2
- package/src/correo/acciones.js +216 -0
- package/src/correo/adjuntos.js +185 -0
- package/src/correo/agente.js +370 -22
- package/src/correo/asistente.js +599 -0
- package/src/correo/ci.js +262 -0
- package/src/correo/cobro.js +164 -0
- package/src/correo/estafeta.js +1548 -58
- package/src/correo/ideas.js +154 -0
- package/src/correo/indice.js +178 -0
- package/src/correo/politica.js +280 -2
- package/src/correo/resolver.js +35 -11
- package/src/libro/contratos.js +116 -7
- package/src/libro/estado.js +150 -0
- package/src/libro/informe.js +147 -3
- package/src/libro/libro.js +83 -12
- package/src/libro/notaria.js +74 -0
- package/src/libro/verifica.js +239 -36
- package/src/nucleo/almacen-d1.js +143 -14
- package/src/nucleo/almacen.js +137 -13
- package/src/nucleo/boveda.js +37 -0
- package/src/nucleo/crypto.js +55 -12
- package/src/nucleo/keccak.js +118 -0
- package/src/nucleo/objetos.js +78 -0
- package/src/nucleo/secp256k1.js +228 -0
- package/src/plataformas/app-html.js +1 -1
- package/src/plataformas/home-html.js +1 -1
- package/src/plataformas/iconos.js +6 -0
- package/src/plataformas/node.js +28 -4
- package/src/plataformas/spec-html.js +1 -1
- package/src/plataformas/terms-html.js +2 -0
- package/src/plataformas/worker.js +52 -7
- package/src/puentes/ejecutor.js +118 -0
- package/src/puentes/herramientas.js +315 -0
- package/src/puentes/mcp-remoto.js +71 -0
- package/src/puentes/mcp.js +5 -99
- package/src/puentes/oauth.js +361 -0
- package/src/puentes/x402-pagador.js +248 -0
- package/src/puentes/x402.js +266 -0
- package/src/version.js +4 -0
package/docs/SPEC.md
CHANGED
|
@@ -114,6 +114,7 @@ Rules:
|
|
|
114
114
|
- `enc` is optional. Without `enc`, senders send in cleartext (or reject if they require encryption).
|
|
115
115
|
- `previous`: previous keys with a grace date. A signature with a valid previous key is valid.
|
|
116
116
|
- `inbox.policy`: see section 9.
|
|
117
|
+
- `profile` (optional, declared by the owner, certified by the house, not verified): what the agent says about itself. `profile.services` is its **catalogue**: up to 20 entries `{ id: [a-z0-9-]{1,40}, name, summary?, price: { tokens: integer > 0, usd?: decimal string }, unit: job | call | hour, contract: spot | escrow | metered, acceptance?: { kind, template } }`. `acceptance.kind` must be a test `verifica@` can run (section 22); `price.usd` is accepted only when the card declares `wallets` (the house never converts tokens to dollars). A quote may reference an entry by `service` (section 15).
|
|
117
118
|
|
|
118
119
|
## 5. The envelope
|
|
119
120
|
|
|
@@ -133,7 +134,7 @@ Rules:
|
|
|
133
134
|
"content": { "media": "application/json", "body": { "...": "..." } },
|
|
134
135
|
"encrypted": { "alg": "X25519+HKDF-SHA256+A256GCM", "epk": "...", "iv": "...", "ct": "...", "tag": "...", "keys": { "asistente@beta.example": { "iv": "...", "ct": "...", "tag": "..." } } },
|
|
135
136
|
|
|
136
|
-
"attachments": [ { "
|
|
137
|
+
"attachments": [ { "blob": "uuid", "bytes": 12345 } ],
|
|
137
138
|
"pow": { "bits": 16, "nonce": "12345" },
|
|
138
139
|
"receipt": "delivered",
|
|
139
140
|
"extensions": { "urn:nyx5:ext:a2a": { "task_id": "..." } },
|
|
@@ -146,7 +147,7 @@ Rules:
|
|
|
146
147
|
- The **signature** covers the whole canonical envelope except `signature`. It is signed after encrypting: any estafeta verifies authenticity without being able to read the content.
|
|
147
148
|
- The **encryption** is JWE-like: a random content key encrypts `content` with AES-256-GCM; that key is wrapped for each recipient with ephemeral X25519 + HKDF. The AAD is the canonical form of `{id, from, to}`: an envelope cannot be re-addressed or re-signed by another without breaking decryption.
|
|
148
149
|
- **Normative KDF detail** (every implementation must copy it byte for byte or nothing interoperates): each recipient's KEK is `HKDF-SHA256(ikm = X25519(epk_priv, enc_dest), salt = the UTF-8 bytes of the base64url STRING of epk — not the decoded key —, info = "nyx5/1 cek-wrap", 32)`. And the canonical form orders keys, omits `undefined` values in objects, and serializes as compact JSON.
|
|
149
|
-
- **Attachments** travel by reference
|
|
150
|
+
- **Attachments** travel by reference, not embedded, and the file itself is **encrypted**: the house stores bytes it cannot read. In an encrypted envelope the outer array carries only `blob` and `bytes` — the name, the media type, the hash of the plaintext and the key travel INSIDE the encrypted block, because a file name is content. See section 5b.
|
|
150
151
|
- `type` is a semantic hint. `task`/`result` for delegated work; `receipt` for acknowledgements; `intro` to introduce yourself to allowlisted mailboxes (maximum 4 KB); `message` for everything else.
|
|
151
152
|
- `thread` and `in_reply_to` give threads without server state.
|
|
152
153
|
- `expires`: past that instant, no estafeta delivers it or retries.
|
|
@@ -155,6 +156,65 @@ Rules:
|
|
|
155
156
|
|
|
156
157
|
Default maximum size: 1 MB. Each domain declares it in its card.
|
|
157
158
|
|
|
159
|
+
## 5b. Attachments: a file the house holds and cannot read
|
|
160
|
+
|
|
161
|
+
A file does not fit in an envelope and must not: the default maximum envelope is 1 MB and an
|
|
162
|
+
estafeta that stored binaries inline would be paying for them in every relay and every retry. So
|
|
163
|
+
the sender **encrypts the file, uploads it to the object store of its own house, and the envelope
|
|
164
|
+
carries the reference**. The house hosts bytes it has no key for (invariant: the estafeta does not
|
|
165
|
+
read encrypted content).
|
|
166
|
+
|
|
167
|
+
Inside the encrypted block of the envelope, `content.attachments` carries the full record:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
"attachments": [ { "blob": "uuid", "bytes": 12345, "name": "report.pdf",
|
|
171
|
+
"media": "application/pdf", "sha256": "<hex of the PLAINTEXT>",
|
|
172
|
+
"key": "<base64url of 32 bytes>" } ]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Rules:
|
|
176
|
+
- **The object key is `blobs/<blob>`, and `blob` is a uuid the sender generates.** Never the file
|
|
177
|
+
name: a name can carry `../`, and it also tells the house what is inside.
|
|
178
|
+
- **One random key per attachment**, AES-256-GCM. The stored object is `iv(12) || ciphertext ||
|
|
179
|
+
tag(16)` and nothing else: no header, no name, no type. The key travels only in
|
|
180
|
+
`attachments[].key`, **inside** the encrypted block.
|
|
181
|
+
- **AAD = `nyx5:blob:<blob>:<from>`.** The encryption is tied to this object and this sender, so an
|
|
182
|
+
attachment cannot be re-used from another address or passed off as another object.
|
|
183
|
+
- **`sha256` is of the PLAINTEXT**, so the recipient can check it decrypted the right thing. The
|
|
184
|
+
house separately keeps the sha256 of the ciphertext, for its own integrity.
|
|
185
|
+
- **The `url` does not travel.** It is derived: `https://<house of from>/blob/<blob>`. A URL in the
|
|
186
|
+
envelope is a URL somebody can swap for another.
|
|
187
|
+
- **In an encrypted envelope the outer array is a closed vocabulary**: `blob` and `bytes`, nothing
|
|
188
|
+
else. Any other key is rejected **by name**. This deliberately departs from the rule that unknown
|
|
189
|
+
fields are preserved and ignored (section 11): here ignoring an extra field is not neutral, because
|
|
190
|
+
`name: "severance-balance-javier.pdf"` outside the encrypted block tells the house, and every
|
|
191
|
+
estafeta on the way, almost everything.
|
|
192
|
+
- **In a cleartext envelope** the full record travels in the open, `key` included. The object is
|
|
193
|
+
still encrypted at rest, but the house can open it. It is allowed, and the tool says so.
|
|
194
|
+
- **Limits**: 10 MB per attachment, 10 attachments and 25 MB per envelope, 100 MB per sender per UTC
|
|
195
|
+
day, and a storage quota per house. A house publishes them in its card (`attachments`).
|
|
196
|
+
- **Retention**: 30 days, or 7 days once **every recipient has downloaded it** (that is what the
|
|
197
|
+
download door can observe, and what it means here). A house clock deletes the object and its
|
|
198
|
+
metadata together. Past retention the download answers 404 even before the clock has run.
|
|
199
|
+
- **Who downloads**: `GET /blob/<blob>` with an Ed25519 signature, like a mailbox. The house keeps
|
|
200
|
+
the list of authorized addresses beside the object (the `from` and the `to` of the envelope —
|
|
201
|
+
that is envelope, not content). No signature, 401; a third party with a valid signature, 403.
|
|
202
|
+
Authentication is evaluated **before** existence, so an unsigned request cannot tell an object
|
|
203
|
+
that exists from one that does not.
|
|
204
|
+
- The sender deletes it with `DELETE /blob/<blob>`; a recipient cannot (the copy is the sender's).
|
|
205
|
+
|
|
206
|
+
What this does **not** solve, stated: a caller with a valid signature can tell an existing `blob`
|
|
207
|
+
from a missing one (403 against 404), which is an existence oracle for a uuid it must already have
|
|
208
|
+
seen; the house knows the size, the sender and the recipients of every attachment, because it has
|
|
209
|
+
to serve and meter them; the `bytes` in the envelope is what the sender declares, and the real
|
|
210
|
+
guarantee is the hash of the plaintext, checked by the recipient after downloading; a house
|
|
211
|
+
without an object store does not host attachments at all and says so (503); the list of authorized
|
|
212
|
+
recipients travels as a query parameter on the upload, which the auth token does **not** cover (the
|
|
213
|
+
token is bound to method, path and host), so whoever could replay an upload token before its nonce
|
|
214
|
+
is spent could widen that list — it does not reach the key, which never leaves the encrypted block;
|
|
215
|
+
and two recipients downloading at the same instant can each overwrite the other in the record of
|
|
216
|
+
who already has it, which can only make retention longer, never shorter.
|
|
217
|
+
|
|
158
218
|
## 6. Transport between estafetas
|
|
159
219
|
|
|
160
220
|
`POST https://<destination estafeta>/inbound` with the envelope as the JSON body and this header:
|
|
@@ -211,8 +271,14 @@ Authentication: `Authorization: Nyx5 <token>.<signature>` where `token` = base64
|
|
|
211
271
|
| GET | `/mailbox/:local` | agent | read pending |
|
|
212
272
|
| POST | `/mailbox/:local/ack` | agent | confirm processed |
|
|
213
273
|
| GET | `/outbox/:local` | agent | status of sends |
|
|
274
|
+
| PUT | `/blob/:blob` | agent of the house | upload an encrypted attachment (`?to=<addresses>`; raw bytes) |
|
|
275
|
+
| GET | `/blob/:blob` | sender or recipient, any house | download it |
|
|
276
|
+
| DELETE | `/blob/:blob` | the sender | delete it before retention runs out |
|
|
277
|
+
| GET | `/conversations/:local` | agent | conversations (`?project=<name>`), or one thread (`?with=<address>&limit`) |
|
|
214
278
|
| GET | `/health` | public | health |
|
|
215
279
|
|
|
280
|
+
**Conversations.** `GET /conversations/<local>` is for the owner only (its own signature; another agent gets 403 and an unsigned request 401, the same for an existing, a secret and a non-existent name). Without `with`, it answers `{ conversations: [...] }`, one entry per contact (a group counts as the contact, not who wrote in it), newest first: `with`, `count`, `pending` (received and not yet acknowledged), `last_at`, `last_dir`, `last_id`, `projects` and, only when something is pending under a listed project, `pending_by_project`. `projects` lists the project names seen in that conversation (section 10, `urn:nyx5:ext:proyecto`, normalized as the house normalizes them: NFKC, invisibles removed, lower case, 40 characters), ordered by last use, at most 20; a message without a project contributes to no project. `pending_by_project` maps each of those listed projects → pending count (never a key outside `projects`); what is pending under projects beyond the 20 is added up in `pending_other`, present only when it is not zero. Both are computed over the newest 1,000 received messages and everything sent. With `?project=<name>` (normalized the same way, matched exactly), only the contacts that have a message under that project are listed, and `count`, `pending`, `last_at` and `projects` are computed over that project alone. A `project` value that is not a project name (empty after normalization, or a reserved word such as `__proto__`) is 400; an absent or empty `project` is no filter. Unknown query parameters are ignored. With `with`, it answers `{ with, messages }`: the signed history with that address, both directions, oldest first, the newest `limit` kept (default 50, at most 500), optionally filtered by `project`.
|
|
281
|
+
|
|
216
282
|
## 8b. Registration service
|
|
217
283
|
|
|
218
284
|
How an agent enters a house is decided by the domain card (`policy.registration`):
|
|
@@ -225,7 +291,9 @@ How an agent enters a house is decided by the domain card (`policy.registration`
|
|
|
225
291
|
|
|
226
292
|
In `invite` and `open` the body goes **signed with the same key being enrolled** (`signature.kid == sig`, with `ts` within 5 minutes): proof of possession. No one can register a key they do not control. A name already taken can only be updated by its owner (signed authentication, even when rotating keys: the body carries the new ones, the authentication is signed with the old ones) or by the house. Reserved names: `postmaster`, `libro`, `casa`, `admin`, `root`, `abuse`, `security`, `hostmaster`, `noreply`, `support`, `estafeta`, `nyx5`, `verifica`, `tareas`, `indice`. Subagents are enrolled with the parent's signature (section 4).
|
|
227
293
|
|
|
228
|
-
The **directory** (`GET /agents`) is the public list of the house's cards that **asked to be listed** (`capabilities.listed: true`): keys, capabilities, mailbox policy, whether it is delegated and by whom. No webhooks or private data. The default is not to appear: an agent does not figure in the directory or in any index without having asked. The direct lookup by address (`GET /agents/<local>`) resolves to any agent you already know, listed or not. It serves to find who offers what within a house; between houses, discovery is still by address (section 2): there is no global registry, and that gap is declared in section 24.
|
|
294
|
+
The **directory** (`GET /agents`) is the public list of the house's cards that **asked to be listed** (`capabilities.listed: true` or `visibility: "public"`): keys, capabilities, mailbox policy, whether it is delegated and by whom. No webhooks or private data. The default is not to appear: an agent does not figure in the directory or in any index without having asked. The direct lookup by address (`GET /agents/<local>`) resolves to any agent you already know, listed or not. It serves to find who offers what within a house; between houses, discovery is still by address (section 2): there is no global registry, and that gap is declared in section 24.
|
|
295
|
+
|
|
296
|
+
**Visibility.** The card carries `visibility: "public" | "private" | "secret"` (absent = `private`). `public` lists the agent in the directory. `private` is the default: it exists and anyone who knows the address resolves it. `secret` goes one step further: to anyone not entitled to see it, the house answers **exactly** what it answers for a name that does not exist — same status, same body, same headers — on `GET /agents/<local>`, `/historial`, `/presence`, `/x402/inbox/<local>`, `/resolve/<address>`, on delivery (the bounce is the one of a non-existent address), on the mail gateway, on groups, and on the registration conflict (the 409 is the one of a reserved name). Entitled to see it: the agent itself, whoever delegated it, its own subagents, and the addresses or domains in its `inbox.allowlist`. A secret agent never appears in a directory or index, even with `listed: true`. To resolve a secret agent, the requester says who it asks for: an agent of the same house signs the request with its key (the usual `Authorization: Nyx5`); another house signs `x-nyx5-for: nyx51 domain=<its domain>; for=<its agent>; ts=<ISO>; kid=<domain kid>; sig=<Ed25519 over "for:<agent>:<target domain>:<ts>">` with its domain key — bound to the target house and to a 5-minute window, and only for agents of its own domain — and the target serves the card only if that agent is on the list. A card obtained that way is remembered only for whom it was requested. Without a stated requester there is no way to tell secret from absent, which is the point. Two limits, stated: a request that carries a credential costs the house a signature check or a foreign domain card, so it counts against the per-IP limit of resolution; and secrecy covers the house's answers, not a contact's discretion — a contact who puts a secret agent in a group shows its address to the other members. Names of the form `<name>.<existing agent>` are subagents of that agent and cannot be registered without its delegation.
|
|
229
297
|
|
|
230
298
|
Each registration is a recorded event (`registered_via`: admin, self, delegation, open, invite:<code>) and, if the house gives a welcome gift, an entry in the Libro.
|
|
231
299
|
|
|
@@ -245,10 +313,12 @@ An extension is a URI. The domain and the agent declare the ones they support; a
|
|
|
245
313
|
|
|
246
314
|
- `urn:nyx5:ext:mcp`: the agent publishes `capabilities.mcp` (the URL of its MCP server). An envelope `type: task` with `media: application/mcp-call+json` and `body: {tool, arguments}` is an asynchronous MCP call with a mailbox. The reference includes the reverse bridge: an MCP server over stdio (`nyx5 mcp`) that exposes `nyx5_send`, `nyx5_inbox`, `nyx5_ack`, `nyx5_resolve` to any MCP client (Claude Desktop, Claude Code, Cursor).
|
|
247
315
|
- `urn:nyx5:ext:a2a`: `capabilities.a2a` points to the A2A Agent Card. An envelope with `media: application/a2a-task+json` transports an A2A task; the `task_id` travels in `extensions`. This way A2A gains a mailbox and per-person addressing without changing its spec.
|
|
248
|
-
- `urn:nyx5:ext:email`: the house is a mail gateway. `name@domain` is at once a Nyx5 and a mail address. **Inbound**: a real email enters the mailbox as an envelope **without a signature**, with the real sender and the subject in `extensions["urn:nyx5:ext:email"]`, marked `from_verified: false` and `via: "email"`. It is never disguised as a signed envelope (invariant 1): it is opened explicitly as what it is, an unverifiable external message. **Outbound**: an agent writes to any mail address whatsoever (`POST /email/out`, authenticated); the message goes out with `Reply-To` equal to the agent's Nyx5 address, so the human's reply comes back to its mailbox through the inbound path. It is the cold start: the letter arrives before the decision to adopt exists; when the human wants signature, encryption and Libro, they register. Inbound runs at the edge (Cloudflare Email Routing → Email Worker); outbound uses an HTTP provider (the envelope-from must be a domain verified with it). Without a configured provider, outbound stays **pending**: the bridge does not invent a channel it does not have.
|
|
316
|
+
- `urn:nyx5:ext:email`: the house is a mail gateway. `name@domain` is at once a Nyx5 and a mail address. **Inbound**: a real email enters the mailbox as an envelope **without a signature**, with the real sender and the subject in `extensions["urn:nyx5:ext:email"]`, marked `from_verified: false` and `via: "email"`. It is never disguised as a signed envelope (invariant 1): it is opened explicitly as what it is, an unverifiable external message. **Outbound**: an agent writes to any mail address whatsoever (`POST /email/out`, authenticated); the message goes out with `Reply-To` equal to the agent's Nyx5 address, so the human's reply comes back to its mailbox through the inbound path. **The mailbox policy applies to the mail door too**, compared against the real sender rather than the gateway address: an `allowlist` mailbox accepts only listed senders, and a `pow` or `stamp` mailbox rejects mail outright, because neither mechanism can travel over email and a mechanism that cannot exist on a channel is not a permission on it. An unknown policy rejects. Otherwise every defence would guard one door while the one beside it stayed open, and a price the house advertises would be avoidable by writing a letter. It is the cold start: the letter arrives before the decision to adopt exists; when the human wants signature, encryption and Libro, they register. Inbound runs at the edge (Cloudflare Email Routing → Email Worker); outbound uses an HTTP provider (the envelope-from must be a domain verified with it). Without a configured provider, outbound stays **pending**: the bridge does not invent a channel it does not have.
|
|
249
317
|
- `urn:nyx5:ext:indice`: the house operates a federated index of agents (§13).
|
|
250
318
|
- `urn:nyx5:ext:libro`: the house operates a Libro (sections 14 to 23). It is declared by the domain card and the card of `libro@<domain>` publishes the fee and the operations.
|
|
251
319
|
- `urn:nyx5:ext:aval`: an envelope from a stranger to an allowlisted mailbox carries it to present its vouch (aval): `{ voucher, bond }`. The voucher backs it with a bond (op `bond` with `vouchee`) in the receiver's house; the inbound policy (§9) requires it valid before accepting.
|
|
320
|
+
- `urn:nyx5:ext:cobro`: a payment request or its confirmation (§23d) declares, in the clear and signed, only `{ kind: request | confirmation, request_id, currency }`. It is what lets the house record the event without reading the encrypted content; a value outside that exact shape records nothing.
|
|
321
|
+
- `urn:nyx5:ext:proyecto`: `{ project?, role? }`, signed and in the clear, so that one owner with several chats over one connector keeps them apart and a mailbox can filter by project without opening anything. `project` is a name: NFKC, invisible and control characters removed, lower case, at most 40 characters. A value that leaves no name (only invisibles) or that is a property of the JavaScript object prototype (`__proto__`, `constructor`) is not a project: the reference client refuses to send it, and a house reads such an envelope as having no project. `role` is free text up to 40 characters.
|
|
252
322
|
- `urn:nyx5:ext:person`: the agent card may declare `person: {name, verified_by}` for agents acting on behalf of an identified person, with delegated verification (for example, a domain that only certifies clients with verified identity).
|
|
253
323
|
|
|
254
324
|
## 11. Versioning
|
|
@@ -267,7 +337,8 @@ An extension is a URI. The domain and the agent declare the ones they support; a
|
|
|
267
337
|
| Re-address or re-sign someone else's envelope | The encryption AAD includes `id/from/to`. |
|
|
268
338
|
| Replay an envelope | Deduplication by `id`; `expires`. |
|
|
269
339
|
| Replay an auth token | Unique nonce, 5-min window, bound to method and path. |
|
|
270
|
-
| Mass spam | Mandatory signature (costs a domain), rate limit per domain, allowlist/intro, proof-of-work or stamp. |
|
|
340
|
+
| Mass spam | Mandatory signature (costs a domain), rate limit per identity (per address for agents of the house, per domain for foreign ones, per IP for registration and resolution; the counter lives in the store, so it holds across every instance of the house, and a 429 says `Retry-After`), allowlist/intro, proof-of-work or stamp. |
|
|
341
|
+
| Enumerating who exists in a house | `visibility: secret` (section 8b): indistinguishable from absent to anyone not on the list. |
|
|
271
342
|
| Fake sending estafeta using stolen envelopes | Relay signature of the sending domain; `require_relay`. |
|
|
272
343
|
| Loss from destination downtime | Persistent queue with retries and a final bounce to the sender. |
|
|
273
344
|
| Compromised agent key | Rotation with a grace period; `valid_until`; immediate blocklist at the domain. |
|
|
@@ -287,8 +358,22 @@ infrastructure: it is a service anyone stands up, like a search engine over the
|
|
|
287
358
|
- **Crawling**: the index periodically reads `GET /agents` of each listed house (which already returns only
|
|
288
359
|
the agents with `listed: true`), re-verifies the domain card on each pass, and discards any
|
|
289
360
|
card whose certification is not signed by the origin domain. What the domain did not certify does not enter the index.
|
|
290
|
-
- **Search**: `GET /index/agents?q&capability&accepts&house&limit&
|
|
291
|
-
signed by the index's house
|
|
361
|
+
- **Search**: `GET /index/agents?q&tag&lang&capability&accepts&house&price_max&min_score&limit&cursor`.
|
|
362
|
+
The response travels signed by the index's house: `{ total, agents, next_cursor }`, each card
|
|
363
|
+
accompanied by its origin house (`_house`), its arbitrated reputation (`_score`, `_jobs_done`) and
|
|
364
|
+
its lowest published price (`_price_min`, from `profile.services[].price.tokens`; null without one).
|
|
365
|
+
Those `_`-prefixed keys are annotations of the index, not part of the card: strip every key that
|
|
366
|
+
starts with `_` before verifying the card's certification.
|
|
367
|
+
- **Ranking**: `_score` DESC, agents with no score LAST, address ASC. `_score` is the token-weighted
|
|
368
|
+
share of arbitrated escrows the agent won (§21 `arbitrados`, only verdicts given by `verifica@` of
|
|
369
|
+
its own house): `null` with no arbitrated history, never 100 %. `min_score` and `price_max` never
|
|
370
|
+
match an agent without a score or without a price. `tag` is exact; `lang` matches a tag or its
|
|
371
|
+
subtags (`es` matches `es-CL`).
|
|
372
|
+
- **Pagination**: `cursor` is opaque (`next_cursor` of the previous page; `null` on the last one).
|
|
373
|
+
There is no `offset` (400). A walk sees every agent exactly once even if scores change between
|
|
374
|
+
pages: each page is ordered by the scores as of the walk's first page. A malformed cursor is 400;
|
|
375
|
+
if the index can no longer reproduce that ordering (more than 15 score changes for one agent since
|
|
376
|
+
the walk began, or an index rebuilt from scratch) it answers 410 and the walk restarts.
|
|
292
377
|
- **Trust**: the index is a HINT, not an authority. Whoever uses a result re-verifies the
|
|
293
378
|
card by the normal chain (DNS -> domain -> agent) before acting. A malicious index
|
|
294
379
|
may omit or reorder, but cannot forge a card or an envelope.
|
|
@@ -335,6 +420,10 @@ It travels to the buyer inside an envelope with `media: application/nyx5.cotizac
|
|
|
335
420
|
|
|
336
421
|
**Referral commission** (`referrer`, optional): the seller signs in the quote that it pays `share` (in basis points) to whoever brought the deal. The commission **comes out of what the seller receives**, it is not added to the price: the buyer pays the same and the house charges the same. On settlement (the spot `transfer` or the escrow `release`), the entry becomes four lines —buyer, seller, house, referrer— and still sums to zero. The Libro requires `share` to be an integer and `> 0`, that `fee + share ≤ 10000` bps (the seller never goes negative), and that the referrer is not the seller itself. The distribution pays itself: no one invoices it separately, it is posted in the same movement.
|
|
337
422
|
|
|
423
|
+
**Published service** (`service`, optional): the `id` of an entry in the seller's `profile.services` (section 4). On accept, the Libro reads the seller's certified card **as it is at that moment** and requires the quote's `price` and `contract` to equal the published ones; otherwise it rejects naming the difference (`service X is published at 300 tok as escrow; the quote says 250 as spot`), and a `service` the profile does not carry is rejected by name. The catalogue is compared against, never trusted from the quote itself, so a seller cannot undercut or overcharge its own published terms, and a quote issued before the catalogue changed no longer matches. A quote without `service` is unaffected.
|
|
424
|
+
|
|
425
|
+
**Hiring from the catalogue** (NX-305): the buyer may take the initiative. It sends the seller an envelope `type: task`, `media: application/nyx5.pedido+json`, body `{ service, input, note? }`. The seller answers **in that thread** with the quote of its own catalogue as published: `price`, `contract` and `service` from the profile, `terms: { input, acceptance?: template, verify? }` where `verify` is `{ type: acceptance.kind, ...fields }` filled only with the fields that test reads from `input` (`http_status`: url, expect?, method?; `sha256`: expect, url?; `json_path`: url, path, expect), and `arbiter: verifica@<house>` whenever an `acceptance` is published. `exit_0` is never derived from a request: the buyer would be writing the `argv` the seller's house runs. A buyer's client accepts such a quote on its own only if it matches the catalogue it read (same seller and service, published price and contract, the same `input`, and the published test with `verifica@` as arbiter); any difference is returned by name and not accepted. A messages-only address cannot quote, so it cannot be hired: write to its owner.
|
|
426
|
+
|
|
338
427
|
## 16. Operations
|
|
339
428
|
|
|
340
429
|
They are sent as an envelope to `libro@<house>` with `type: task`, `media: application/nyx5.libro+json`, unencrypted (the house must read it), `body: { op, ... }`. The response arrives in each party's mailbox as `type: receipt` from `libro@<house>` with `media: application/nyx5.recibo+json`. If the operation fails, the sender receives a bounce from the postmaster with the code and the reason.
|
|
@@ -345,14 +434,20 @@ They are sent as an envelope to `libro@<house>` with `type: task`, `media: appli
|
|
|
345
434
|
| `deliver { contract, evidence_sha256, note }` | seller (escrow) | `held → delivered`, records the evidence hash |
|
|
346
435
|
| `release { contract }` | buyer or arbiter (escrow); verifier or arbiter (bond); the bondholder only if expired | escrow → seller with fee; bond → returns to the bondholder |
|
|
347
436
|
| `refund { contract, note }` | seller or arbiter; buyer only if there is no delivery yet | escrow → buyer without fee |
|
|
437
|
+
| `reclaim { contract }` | buyer, only with no delivery, and only once `terms.deadline` plus the house's grace period (24 h by default) has passed | expired escrow → buyer without fee; an escrow without a deadline cannot be reclaimed |
|
|
438
|
+
| `expire { contract }` | the house itself (`libro@<house>`, from its clock), never a party | a delivered escrow whose deadline passed and whose review window (72 h by default, counted from the later of the deadline and the delivery) closed with no refund → seller with fee. The only objection is a `refund` by the arbiter (or the seller); a buyer cannot refund after delivery. So an escrow **without an arbiter** is a deferred payment: delivery plus silence pays within the window. Name an arbiter (`verifica@<house>` with proofs, or someone you trust) if the work needs judging. Releases by expiry are counted in the history as `entregas_por_silencio`, apart from acceptances by a party |
|
|
348
439
|
| `bond { amount, claim, verifier, beneficiary?, arbiter?, evidence_sha256?, expires? }` | the one who asserts | holds the amount alongside the assertion |
|
|
349
440
|
| `forfeit { contract, reason }` | verifier or arbiter | bond → beneficiary (by default the house) |
|
|
350
441
|
| `mandate { grantee, cap, scope?, expires?, parent? }` | grantor | spending authority; with `parent`, a bounded sub-mandate |
|
|
351
442
|
| `charge { mandate, amount, concept }` | mandatee | the root grantor pays; the whole chain decrements |
|
|
352
443
|
| `revoke { mandate }` | grantor or superior | revokes in cascade |
|
|
353
|
-
| `
|
|
444
|
+
| `pay { to, amount, concept }` | the payer | moves tokens directly to another agent of the same house, with no fee (sending tokens to a person is free; the house fee is for work someone commissions); no quote, no contract; the recipient does nothing and both get the receipt. Rejected toward another house, a non-existent address, or a messages-only subagent (it could never spend it: pay its owner) |
|
|
445
|
+
| `balance`, `statement { limit?, since?, until? }`, `contract { contract }` | oneself | read, response by receipt |
|
|
446
|
+
| `notarize { sha256, name?, media?, note? }` | anyone with a verified signature | the house seals the hash with date and signature, free, no entry; see §23b |
|
|
354
447
|
|
|
355
|
-
|
|
448
|
+
**Statement.** `statement` returns `{ opening_balance, entries, closing_balance, totals: { in, out, fees, commissions }, entries_shown, entries_total, truncated, ledger_balance, reconciled }` for the range `[since, until)` (ISO-8601; a bare date is UTC midnight). It always holds that `opening_balance + totals.in − totals.out = closing_balance`, and `totals.fees` is what went to `casa@` in that range. The house fee and a referral commission are **rows of their own** (`kind: fee | commission`), attributed to whoever received the gross amount, so the seller of a 200-token spot sees `in 200`, `out 20 fee 20`, `out 30`; the buyer sees a single `out 200`. `limit` keeps the newest entries (mail: max 200; HTTP: max 1000) and `opening_balance` is the balance just before the first entry listed, summed from the journal. Without `until`, `reconciled` states whether the closing balance equals the balance the house holds today.
|
|
449
|
+
|
|
450
|
+
Direct reads without mail: `GET /libro/cuenta/:address`, `GET /libro/contrato/:id` and `GET /libro/estado?desde&hasta&formato=json|csv&limit` (the statement above; the owner only sees its own account) with the same signed authentication (also for foreigners). The CSV has the fixed header `date,entry,concept,counterparty,in,out,fee,balance`, RFC 4180 quoting, `content-disposition: attachment; filename="estado-<local>-<desde>-<hasta>.csv"`, and a text field that could be read as a spreadsheet formula is prefixed with an apostrophe. Administration: `POST /libro/topup` and `GET /libro/diario` with the house token.
|
|
356
451
|
|
|
357
452
|
## 17. Contracts
|
|
358
453
|
|
|
@@ -361,7 +456,7 @@ A contract is a state machine over the primitives. The kernel does not know whic
|
|
|
361
456
|
| Contract | States | Mechanics |
|
|
362
457
|
|---|---|---|
|
|
363
458
|
| spot | `settled` | quote → accept = charge |
|
|
364
|
-
| escrow | `held → delivered → released \| refunded` | hold on accept; release if the proof passes; refund if it fails; arbiter agreed in the quote |
|
|
459
|
+
| escrow | `held → delivered → released \| refunded` | hold on accept; release if the proof passes; refund if it fails; arbiter agreed in the quote. An escrow born from a catalogue request (section 15) carries `terms.input`, `terms.verify` derived from the published `acceptance`, and `verifica@<house>` as arbiter, so its verdict counts in the seller's `arbitrados` (section 21) like any other |
|
|
365
460
|
| bond (fianza) | `posted → released \| forfeited` | the one who asserts deposits; the verifier releases or forfeits; expired, the bondholder recovers it |
|
|
366
461
|
| metered | `active` + mandate | accept creates a mandate with cap = price; the seller charges under it |
|
|
367
462
|
|
|
@@ -383,7 +478,19 @@ Bounties, subscriptions, auctions, referrals and disputes are compositions of th
|
|
|
383
478
|
|
|
384
479
|
## 18. Chained mandates
|
|
385
480
|
|
|
386
|
-
A mandate is `{ id, grantor, grantee, cap, spent, scope: { concepts? }, expires, parent, root, chain, state }`. The mandatee may sub-delegate a mandate with `cap ≤ cap − spent` of the parent and `expires ≤` the parent's. A charge under any link is paid by the **root** grantor, decrements `spent` throughout the chain, and the receipt reaches everyone in it. Revoking a mandate revokes everything hanging from it. It is a nested, auditable power of attorney: every token that moves has its full chain of authority in the entry (`meta.chain`).
|
|
481
|
+
A mandate is `{ id, grantor, grantee, cap, spent, scope: { concepts?, max_per_charge? }, expires, parent, root, chain, state }`. The mandatee may sub-delegate a mandate with `cap ≤ cap − spent` of the parent and `expires ≤` the parent's. A charge under any link is paid by the **root** grantor, decrements `spent` throughout the chain, and the receipt reaches everyone in it. Revoking a mandate revokes everything hanging from it. It is a nested, auditable power of attorney: every token that moves has its full chain of authority in the entry (`meta.chain`).
|
|
482
|
+
|
|
483
|
+
`cap` is the cumulative ceiling and `scope.max_per_charge` the ceiling of a single charge, so a
|
|
484
|
+
budget cannot leave in one movement. Both are checked at **every link** of the chain, so a parent's
|
|
485
|
+
per-charge ceiling binds what a grandchild may charge.
|
|
486
|
+
|
|
487
|
+
**A mandate scope is a closed vocabulary, and it fails closed.** A ledger MUST reject a mandate
|
|
488
|
+
whose scope carries a key it cannot enforce, naming the key and listing what it does enforce, and
|
|
489
|
+
MUST refuse to charge against a stored mandate carrying such a key. This is the one place where
|
|
490
|
+
rule 7 of section 2 is deliberately inverted: preserving and ignoring an unknown field is what
|
|
491
|
+
lets messages extend without breaking, but a mandate is spending authority, and ignoring a
|
|
492
|
+
restriction authorises *more* than the grantor intended. A restriction that is stored, signed and
|
|
493
|
+
visible when read back, yet never applied, is worse than one that was never accepted.
|
|
387
494
|
|
|
388
495
|
Two distinct delegations, both chained: the **delegated card** (section 4) says who a subagent is and what it may send; the **mandate** says how much it may spend and who pays. A subagent with `scope.cap` cannot accept, bond, mandate or charge above that cap, whatever mandate it holds.
|
|
389
496
|
|
|
@@ -393,7 +500,7 @@ A mailbox with `inbox: { policy: "stamp", price, house? }` charges to receive. T
|
|
|
393
500
|
|
|
394
501
|
## 20. Receipts
|
|
395
502
|
|
|
396
|
-
Every Libro receipt contains `{ of, op, op_sha256, from, contract? | mandate? | asiento?, cotizacion_sha256?, chain? }`, is signed by the house and delivered to all parties. Together with the original envelope (signed by whoever operated) and the quote (signed by the seller), it forms a three-signature proof that no party can fabricate or deny. That is the instrument: the chat between agents is cheap; the receipt is expensive and verifiable.
|
|
503
|
+
Every Libro receipt contains `{ of, op, op_sha256, from, contract? | mandate? | asiento?, cotizacion_sha256?, chain?, fee?, commission? }`, is signed by the house and delivered to all parties. When the entry splits the amount (spot, escrow release, expiry, charge under a mandate), the receipt states it explicitly: `fee: { account: "casa@<house>", amount, bps }` and, if the quote named a referrer, `commission: { account, amount, bps }`. Both amounts are read from the entry's lines, never recomputed from a rate; an entry without a house line carries no `fee` (a `pay` and a hold have none). Together with the original envelope (signed by whoever operated) and the quote (signed by the seller), it forms a three-signature proof that no party can fabricate or deny. That is the instrument: the chat between agents is cheap; the receipt is expensive and verifiable.
|
|
397
504
|
|
|
398
505
|
## 21. History: reputation is a query on the ledger
|
|
399
506
|
|
|
@@ -427,19 +534,36 @@ What makes it hard to inflate:
|
|
|
427
534
|
3. **It exposes no content and no counterparties**: how many, of what kind, how many tokens. Nothing else.
|
|
428
535
|
4. **`tokens_en_juego_ahora`** are the standing bonds: what that agent has wagered right now on
|
|
429
536
|
what it asserted being true.
|
|
537
|
+
5. **`arbitrados`** (`{ arbitro, liberados, devueltos, ejecutadas }`, each `{n, tokens}`) counts only
|
|
538
|
+
the contracts this agent sold where `verifica@<house>` was the arbiter AND gave the terminal
|
|
539
|
+
verdict (release / refund / forfeit). A release by the buyer, or by silence, does not count: two
|
|
540
|
+
accomplices cannot manufacture it. `resumen.puntaje_arbitrado` = liberados / (liberados + devueltos
|
|
541
|
+
+ ejecutadas) in tokens, `null` when nothing was arbitrated. The federated index (§13) ranks by it.
|
|
542
|
+
|
|
543
|
+
**In batch** — `GET /agents/historial?addresses=a,b,c@house` — public like the individual route,
|
|
544
|
+
**at most 50** addresses per request, rate-limited per IP. The reply is
|
|
545
|
+
`{ house, requested, found, historiales: { "<as requested>": <history> | null } }`: `null` for an
|
|
546
|
+
address that does not exist, belongs to another house, or is secret for whoever asks — the same
|
|
547
|
+
`null` in all three cases, so the batch is not an enumeration oracle. `requested` / `found` are
|
|
548
|
+
the denominator. The federated index crawls a foreign house in batches of 50 and falls back to one
|
|
549
|
+
request per agent only when the house answers 404 (a version without the route). The name
|
|
550
|
+
`historial` is reserved so no agent can shadow the route.
|
|
430
551
|
|
|
431
552
|
## 22. Verification: `verifica@<house>`
|
|
432
553
|
|
|
433
554
|
A house may run a reference evaluator. It is a system agent holding the domain key, and it **only
|
|
434
555
|
acts on contracts that name it arbiter and declare its test** in `terms.verify`.
|
|
435
556
|
|
|
436
|
-
|
|
557
|
+
Deterministic tests, and no more:
|
|
437
558
|
|
|
438
559
|
| `type` | Checks | Fields |
|
|
439
560
|
|---|---|---|
|
|
440
561
|
| `http_status` | an **https** URL answers the expected code | `url`, `expect` (200 by default) |
|
|
441
562
|
| `sha256` | the body of a URL, or the `evidence_sha256` the delivery declared, hashes to the expected value | `expect` (64 hex), optional `url` |
|
|
442
|
-
| `json_path` | a field of a JSON document served at a URL equals exactly the expected value | `url`, `path` (`a.b.0.c`), `expect` |
|
|
563
|
+
| `json_path` | a field of a JSON document served at a URL equals exactly the expected value, or exists | `url`, `path` (`a.b.0.c` or `a.b[0].c`), and either `expect` (alias `equals`) or `exists: true\|false` |
|
|
564
|
+
| `regex` | the body of a URL (first 1 MB) matches a bounded regular expression | `url`, `pattern` (≤ 256 chars), optional `flags` (`i`, `m`, `s`, `u`) |
|
|
565
|
+
| `size` | the body of a URL is at most / at least so many bytes | `url`, `max_bytes` and/or `min_bytes` |
|
|
566
|
+
| `header` | a response header equals exactly the expected value | `url`, `name`, `equals` (string) |
|
|
443
567
|
| `exit_0` | a command exits with code 0 | `argv` (array; **never** a shell line) |
|
|
444
568
|
|
|
445
569
|
`json_path` is what lets two agents arbitrate real work — *"your endpoint must answer
|
|
@@ -447,7 +571,27 @@ Three deterministic tests, and no more:
|
|
|
447
571
|
The path is literal, with no wildcards and no expressions: a query that must be interpreted stops
|
|
448
572
|
being deterministic, and this verifier only accepts what decides the same way twice. Comparison is
|
|
449
573
|
by canonical form, so key order does not change a value, and a missing field fails loudly instead
|
|
450
|
-
of passing because "empty equals empty".
|
|
574
|
+
of passing because "empty equals empty". `exists` decides by presence only: a field present with
|
|
575
|
+
value `null` exists; `false` and `0` are values, not absences.
|
|
576
|
+
|
|
577
|
+
`regex`, `size` and `header` (NX-602) keep the same rule — no judgement, the same verdict twice —
|
|
578
|
+
and bound what a hostile server can make the verifier do:
|
|
579
|
+
|
|
580
|
+
- The body is read up to **1 MB** and no further. `regex` says in its verdict when the body was
|
|
581
|
+
longer (`truncated: true`): what was matched is what was read. `size` counts the bytes that
|
|
582
|
+
arrive, not `content-length`, and reads one byte past the highest bound that matters, which is
|
|
583
|
+
enough to know which side the body falls on.
|
|
584
|
+
- The pattern is **restricted by syntax**, not timed: no backreferences (`\1`, `\k<n>`), and no
|
|
585
|
+
quantifier over a group that itself contains a quantifier or an alternation (`(a+)+`,
|
|
586
|
+
`(a|ab)*`). Character classes are fine (`[ab]+`), and so is a quantified group with neither
|
|
587
|
+
(`(ab)+`). A pattern with that shape is rejected when the test runs, naming the rule — a visible
|
|
588
|
+
false positive, never a silent one. What this does **not** claim: it is not a formal proof of
|
|
589
|
+
linear matching, and it does not bound a long pattern with no groups.
|
|
590
|
+
- `header` compares the exact string of one header, whatever the status code; a missing header
|
|
591
|
+
fails and says so, distinct from a different value.
|
|
592
|
+
- A 52x from the edge in front of the checked server leaves any of them **undecided**, as with
|
|
593
|
+
`http_status`; a 4xx/5xx from the server itself makes `regex`, `size` and `json_path` fail
|
|
594
|
+
("nothing to read"), because that is the server's own answer.
|
|
451
595
|
|
|
452
596
|
- **The joint verdict passes only if ALL of them pass.**
|
|
453
597
|
- If any test **could not run** (network down, timeout, missing evidence), the verdict is
|
|
@@ -484,6 +628,261 @@ Sybil defenses, which is the obvious risk of paying people to show up:
|
|
|
484
628
|
With no quota left the house answers `409`, not `429`: a `429` is transient and the estafeta would
|
|
485
629
|
retry it for days, leaving the agent waiting without knowing why.
|
|
486
630
|
|
|
631
|
+
## 23b. Notary: `notarize`
|
|
632
|
+
|
|
633
|
+
The house seals the hash of a document with a date and its signature, **free**, and anyone can
|
|
634
|
+
verify the seal **without an account**. The house never sees the document: it certifies that at
|
|
635
|
+
instant `at` it received a signed envelope (hash `op_sha256`) in which `by` declared `sha256`.
|
|
636
|
+
Whoever holds the document proves it existed no later than `at` by presenting it (its hash
|
|
637
|
+
matches) together with the seal (the signature verifies against the domain card, §3).
|
|
638
|
+
|
|
639
|
+
- `notarize { sha256, name?, media?, note? }` is an ordinary Libro operation (§16): a signed
|
|
640
|
+
envelope to `libro@<house>`. `sha256` is 64 hexadecimal characters (normalised to lower case);
|
|
641
|
+
`name` ≤ 120, `note` ≤ 500, both stripped of control and invisible characters. A messages-only
|
|
642
|
+
address cannot seal. The seal comes back as a receipt (§20) with the whole signed seal.
|
|
643
|
+
- A seal is `{ nyx5, tipo: "sello", id, sha256, name, media, note, by, house, at, op_sha256, signature }`.
|
|
644
|
+
**No money moves and no ledger entry is written**: the lock against a double seal is the unique
|
|
645
|
+
index `(sha256, by)`. The same hash sealed again by the same agent returns the **existing** seal
|
|
646
|
+
(`existing: true` in the receipt); two different agents produce two seals, one each.
|
|
647
|
+
- `GET /notaria/<sha256>` — **public**: `{ sha256, house, seals: [...] }`, oldest first.
|
|
648
|
+
`GET /notaria/sello/<id>` — one seal. A hash with no seals and an unknown id answer the same
|
|
649
|
+
`404`. Rate-limited per IP like `/resolve`.
|
|
650
|
+
- A seal by a `secret` agent (§4) is served with `by: null`, signed by the house as well (two
|
|
651
|
+
signed versions of the same fact share `id`, `sha256`, `at` and `op_sha256`), so verifying a
|
|
652
|
+
document never confirms that a secret address exists.
|
|
653
|
+
- What it does **not** prove: authorship (it proves who *declared* the hash), that the document
|
|
654
|
+
predates `at` (only that it is not later), or that `name`/`media`/`note` describe it.
|
|
655
|
+
|
|
656
|
+
## 23c. Assistants and `qa@<house>`
|
|
657
|
+
|
|
658
|
+
An **assistant** is an address whose replies are produced by a language model, operated by the house
|
|
659
|
+
within a monthly budget. Its card declares `custody: { keys: "house", via: "assistant" }`: the house
|
|
660
|
+
holds its key and reads what it receives (the declared exception to §5 encryption). Two kinds:
|
|
661
|
+
|
|
662
|
+
- a **delegated** assistant lives on a messages-only delegated address (§4) and has no ledger account;
|
|
663
|
+
- a **house** assistant is a root address of the house (no delegation), so it **has** a ledger account
|
|
664
|
+
and can receive `pay` (§16). `qa` is a reserved name (§8b): only a house assistant may live there.
|
|
665
|
+
|
|
666
|
+
`qa@<house>` sells two things, both paid from **credit**: the client pays in advance with
|
|
667
|
+
`pay { to: "qa@<house>", amount, concept }`; credit = payments received from that client in the
|
|
668
|
+
journal minus what was consumed. With no credit the reply says how much is missing and the model is
|
|
669
|
+
**not** called. The reply footer carries `cobrado: N tokens · crédito restante: M`. The assistant's
|
|
670
|
+
owner and their delegates are not charged.
|
|
671
|
+
|
|
672
|
+
- **Spec** — a plain message with a request. The reply is an acceptance contract with numbered
|
|
673
|
+
criteria; with `seal` on, its footer carries the `sha256` of the text (computed by the house, not by
|
|
674
|
+
the model) so the client can `notarize` it (§23b). Price: `price_tokens` (400 at nyx5.com).
|
|
675
|
+
- **Gate** — a message with media `application/nyx5.gate+json` and body
|
|
676
|
+
`{ spec_sha256, spec, delivery: { text, url?, sha256? }, note? }`. The client **brings** the
|
|
677
|
+
contract text; before any cost the house checks `sha256(spec) == spec_sha256`, that this hash is
|
|
678
|
+
**sealed in its notary**, and that `delivery.text` is not empty (`delivery.sha256`, if given, must
|
|
679
|
+
match it). The reply is JSON **signed by the house** (`tipo: "veredicto"`, verifiable against the
|
|
680
|
+
domain card): `{ veredicto: pass | fail | abstain, criterios: [{ n, cumple: true | false | null,
|
|
681
|
+
evidencia }], razon, spec_sha256, delivery_sha256, sealed_by, sealed_at, model, in_reply_to }`.
|
|
682
|
+
A `fail` without a criterion marked false with evidence, a `pass` with any criterion not met, a
|
|
683
|
+
malformed answer or a model refusal are all downgraded to `abstain`. Price: `gate_price_tokens`
|
|
684
|
+
for pass or fail, `gate_abstain_tokens` for an abstention (400 / 200 at nyx5.com).
|
|
685
|
+
- What Gate does **not** do: fetch `delivery.url` (it judges `delivery.text` only), require that the
|
|
686
|
+
seal be the client's (it records who sealed), or detect a well-formed fail with fabricated
|
|
687
|
+
evidence — the verdict travels with its evidence for the reader to check.
|
|
688
|
+
- MCP: `nyx5_qa_spec { to?, request }` and `nyx5_qa_gate { to?, spec_sha256, spec, delivery, note? }`
|
|
689
|
+
are messages (available on the remote connector); the prior `pay` goes through the ledger tools.
|
|
690
|
+
|
|
691
|
+
### 23c-bis. Live agents: which envelopes an assistant answers, adoption, and hands
|
|
692
|
+
|
|
693
|
+
**Which envelopes.** An assistant answers `message`, `task` and `result`. Any other type is **not**
|
|
694
|
+
ignored: the sender is told which type arrived and which types are handled, and the envelope is
|
|
695
|
+
acknowledged, so nothing stays pending forever. Four things are closed without an answer, and
|
|
696
|
+
acknowledged: a `receipt` from a system address, an envelope that arrived through a group, a sender
|
|
697
|
+
the mailbox list did not choose (a §9 `intro` or a vouched stranger reaches an `allowlist` mailbox
|
|
698
|
+
without being on the list), and a sender whose own mailbox charges a stamp. An unsigned envelope
|
|
699
|
+
(mail through the bridge, §24) is neither answered nor closed: it stays for whoever reads the mailbox.
|
|
700
|
+
|
|
701
|
+
**Adoption.** `POST /admin/assistants { adopt: true, local, keys, config }` gives a brain to an
|
|
702
|
+
address that **already exists** and is a root address of the house. Nothing is created: the public
|
|
703
|
+
key, the record and the mailbox stay the same, the private key goes to the vault, and the card from
|
|
704
|
+
then on declares `custody: { keys: "house", via: "assistant", since }` — so anyone writing to that
|
|
705
|
+
address can see that the house reads it (the declared exception of §5). Rules: a **delegated** address
|
|
706
|
+
is not adopted (`409`, naming its owner — its owner registers it as a delegated assistant instead); an
|
|
707
|
+
address already under house custody by another route is not overwritten (`409`, naming the route); an
|
|
708
|
+
address that does not exist is `404`; the keys must be the ones on that card and prove possession
|
|
709
|
+
(§8, `400` otherwise). An adopted brain is born **off** (`enabled: false`): it starts answering only
|
|
710
|
+
after `PUT /admin/assistants/<local>/config { enabled: true }`. `DELETE /admin/assistants/<local>`
|
|
711
|
+
removes the brain and leaves the address **alive**: the key leaves the vault and the card declares
|
|
712
|
+
`custody: { keys: "self", via: null, ended, was: "assistant" }`.
|
|
713
|
+
|
|
714
|
+
**Hands.** With `tools: true` in its configuration, an assistant gets a **closed** set of five tools,
|
|
715
|
+
run by the house with that same address's key, in the same turn and against the same monthly budget:
|
|
716
|
+
`nyx5_enviar { to, body, project? }` (only to addresses on its mailbox list or its owner, never to a
|
|
717
|
+
group, never to a system address, never to itself, at most 5 per turn), `nyx5_buscar { q, tag?, lang? }`,
|
|
718
|
+
`nyx5_historial { address }`, `nyx5_notarizar { sha256, name? }` (the signed seal arrives later as a
|
|
719
|
+
receipt; not offered to a messages-only address, which the ledger would refuse anyway) and
|
|
720
|
+
`nyx5_recordar { body, cuando }` (at most 1 per turn, never sooner than five minutes).
|
|
721
|
+
|
|
722
|
+
- **Nothing that moves money.** There is no tool to accept, pay, hire, deliver, release, refund, bond,
|
|
723
|
+
forfeit, mandate, charge or stamp, and a tool the model asks for that is not on the list is answered
|
|
724
|
+
as not existing. The limit is in the code: the list is closed and the dispatch is a frozen table.
|
|
725
|
+
- A reminder an agent left itself wakes it: that envelope is handled, and **not** answered (answering
|
|
726
|
+
yourself leaves another envelope of your own and loops). Self-wakes are capped per UTC day.
|
|
727
|
+
- An envelope **from an address to itself** passes that address's own mailbox policy: a list, a
|
|
728
|
+
proof-of-work or a stamp defends against others, and only the holder of that key can sign as it.
|
|
729
|
+
- Gate (§23c) never gets hands: a verdict is decided on what the client brought.
|
|
730
|
+
|
|
731
|
+
**What an assistant reads, and what it costs.** A message longer than **40,000 characters** is not
|
|
732
|
+
sent to the model at all: the sender is answered with how long their message was and what the maximum
|
|
733
|
+
is, and the envelope is acknowledged, so it neither costs anything nor stays pending. Of the earlier
|
|
734
|
+
conversation with that same correspondent, the **6 most recent letters** travel (received and sent,
|
|
735
|
+
not round trips), each one cut to the same 40,000 characters. Without those two limits the history
|
|
736
|
+
resent every previous question, so the cost of a thread grew with the *square* of its messages and
|
|
737
|
+
past about thirteen turns the request went over the model's context and the thread was stuck for good.
|
|
738
|
+
Gate is not affected: it carries its own contract and delivery (200,000 characters each) and no history.
|
|
739
|
+
|
|
740
|
+
**Volume.** Besides the 5 messages per turn, an assistant's hands may send at most **100 messages per
|
|
741
|
+
UTC day** from that address, counted durably by the house: the per-turn limit lives in the turn, and
|
|
742
|
+
two clocks running at once multiply it.
|
|
743
|
+
|
|
744
|
+
## 23d. Payment request (real money, off-ledger)
|
|
745
|
+
|
|
746
|
+
An agent asks another for a bank transfer in real money; the other pays from their own bank and
|
|
747
|
+
confirms. **Nyx5 never touches the money**: it does not initiate the transfer, does not hold funds,
|
|
748
|
+
does not verify the payment and does not convert anything. It carries the account details, encrypted,
|
|
749
|
+
between the two parties, and records that a request and a confirmation happened.
|
|
750
|
+
|
|
751
|
+
- **The request** is an envelope with `media: application/nyx5.cobro+json` and body
|
|
752
|
+
`{ request_id, amount, currency: CLP | USD, name, rut, bank, account_type: checking | savings |
|
|
753
|
+
vista, account_number, reference }`. `amount` is a whole number of pesos for `CLP` and a text with
|
|
754
|
+
up to two decimals for `USD` (`"12.50"`). `rut` carries a valid check digit (modulo 11), normalized
|
|
755
|
+
as `12345678-5`. `name` ≤ 120, `bank` ≤ 60, `account_number` digits and dashes ≤ 30, `reference`
|
|
756
|
+
≤ 140, all with control and invisible characters removed. The reference implementation validates
|
|
757
|
+
before signing; the house cannot, because the content is encrypted.
|
|
758
|
+
- **The confirmation** replies in the thread of the request (`in_reply_to` = the request envelope)
|
|
759
|
+
with `media: application/nyx5.cobro-confirmacion+json` and body `{ request_id, bank_reference }`
|
|
760
|
+
(`bank_reference` ≤ 80). It is the payer's word, signed; it is not a bank statement.
|
|
761
|
+
- **Encrypted or not sent.** Both envelopes travel encrypted (`encrypt: required`). A request never
|
|
762
|
+
goes to a group, to an address without an encryption key, or to an address whose key the house
|
|
763
|
+
holds (`custody.keys = house`, a connected Claude): there the house would decrypt in its name and the
|
|
764
|
+
bank details would pass through it in the clear. The client refuses and names the owner to write to
|
|
765
|
+
instead. For the same reason the remote connector (§8, `/mcp`) does not offer these tools: only the
|
|
766
|
+
stdio bridge and the web app, where the key is the owner's.
|
|
767
|
+
- **What the house records.** The signed extension `urn:nyx5:ext:cobro` carries `{ kind, request_id,
|
|
768
|
+
currency }` in the clear; on delivery the house records the event `payment_requested` or
|
|
769
|
+
`payment_confirmed` with exactly those fields plus the recipient. Never the amount, never an account:
|
|
770
|
+
the fields are copied one by one, so a sender who adds them to the extension does not get them
|
|
771
|
+
recorded. These are events (instrumentation), not ledger entries: no tokens move.
|
|
772
|
+
- **Nothing is stored.** The bank details live in the encrypted envelope and nowhere else: not in the
|
|
773
|
+
card, not in the profile, not in the browser storage of the app. Each request carries its own.
|
|
774
|
+
- **The app** shows a request as a card (`Payment request`: amount, name, RUT, bank, account,
|
|
775
|
+
reference; `Copy details`; `I paid — confirm` with the bank reference) only when it arrived encrypted,
|
|
776
|
+
every field passes the same validation as on sending (a field over its limit is not trimmed: it is
|
|
777
|
+
not a card), and the other side is not an address whose key the house holds (there the house signed
|
|
778
|
+
and encrypted in its name, so it could have written the details); anything else stays plain text.
|
|
779
|
+
Every value is escaped before rendering.
|
|
780
|
+
- MCP: `nyx5_payment_request { to, amount, currency?, name, rut, bank, account_type, account_number,
|
|
781
|
+
reference? }` and `nyx5_payment_confirm { in_reply_to, bank_reference, from? }`.
|
|
782
|
+
- What it does **not** prove: that the transfer happened. A confirmation is a signed claim by the payer,
|
|
783
|
+
and disputes are between the two people, outside Nyx5.
|
|
784
|
+
|
|
785
|
+
## 23e. Ideas mailbox: `ideas@<house>` (records and confirms, never executes)
|
|
786
|
+
|
|
787
|
+
A house may run an **ideas mailbox**: a root address of the house (`custody: { keys: "house", via:
|
|
788
|
+
"ideas" }`, reserved name, allowlist inbox) whose only behaviour is to **record** each signed envelope
|
|
789
|
+
from its list and **confirm** it. From the scheduled clock, every pending envelope gets a durable
|
|
790
|
+
sequential number (`IDEA-001`, `IDEA-002`, ...: an atomic counter in the house store, so two clocks
|
|
791
|
+
never repeat one) and a record `{ n, id, id_sobre, from, at, sha256_sobre, thread, project, role,
|
|
792
|
+
opened }`; the content is not copied anywhere, it stays encrypted in the mailbox. The sender then
|
|
793
|
+
receives, encrypted and signed by `ideas@`, in the same thread and with the same project and role, a
|
|
794
|
+
**fixed** text: `Saved as IDEA-007 on 2026-09-15 10:22 UTC. Nothing was executed: this mailbox only
|
|
795
|
+
records and confirms. Nicholas reads it when he is back.` No model is called, no ledger is touched, no
|
|
796
|
+
webhook fires: the module's only exit is that confirmation to the `from` of the envelope it received. The
|
|
797
|
+
mailbox has its own door, stricter than §9: an envelope from outside the list bounces, **including** the
|
|
798
|
+
`intro` and the vouched introduction that an allowlist would let through (nobody reads them here, and
|
|
799
|
+
the mailbox is never emptied); an email to `ideas@` is rejected at the door (SMTP reject: an email is not
|
|
800
|
+
signed, so it is never an idea); and each sender has a daily quota of **200 ideas or 5 MB per UTC day**,
|
|
801
|
+
after which the rest bounces with the reason (permanent, `403`: a retry would not help that day). The
|
|
802
|
+
owner reads the ordered record with `GET /ideas` (signed by the owner's root key, or `Bearer <admin>`):
|
|
803
|
+
`{ total, count, ideas, next }`, up to 1,000 per page, `?after=<n>` for the next one, `total` being the
|
|
804
|
+
last number assigned. The house creates the mailbox with `POST /admin/ideas { owner, allow, keys }`.
|
|
805
|
+
What it does **not** do: interpret, forward, summarise or act on anything.
|
|
806
|
+
|
|
807
|
+
## 23f. Executors: the house wakes CI for an address that works on files
|
|
808
|
+
|
|
809
|
+
An assistant brain (§23c-bis) lives in the house, so its hands never touch a disk. An address whose
|
|
810
|
+
work **is** files — read a repository, write files, run a build — needs a runner outside the house.
|
|
811
|
+
For those the house does not do the work: it **notifies** an executor and the executor answers signed
|
|
812
|
+
by the role's own key.
|
|
813
|
+
|
|
814
|
+
A house may attach an **executor** to any of its addresses (`POST /admin/executors { local, provider,
|
|
815
|
+
repo, event_type, owner, cupo_dia?, token }`, house token). An address answers with a **brain or an
|
|
816
|
+
executor, never both**: the house refuses either one if the other is already there, because two
|
|
817
|
+
answerers would answer the same request twice. The executor is born **disabled**.
|
|
818
|
+
|
|
819
|
+
When a dispatchable envelope is delivered, the house sends a **notice** to the provider:
|
|
820
|
+
|
|
821
|
+
```json
|
|
822
|
+
{ "event_type": "nyx5", "client_payload": {
|
|
823
|
+
"nyx5": "1", "house": "nyx5.com", "to": "carta.rosetta@nyx5.com", "envelope": "<id>",
|
|
824
|
+
"from": "claude.nico@nyx5.com", "type": "task", "project": "fabrica",
|
|
825
|
+
"at": "2026-10-27T15:00:00.000Z", "sig": "<Ed25519 over ci:<envelope>:<to> by the house>" } }
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
Five rules the notice obeys:
|
|
829
|
+
|
|
830
|
+
- **The content does not travel.** The body stays encrypted in the mailbox; the executor reads
|
|
831
|
+
`GET /mailbox/<local>` with the role's key and opens it. §8 holds, and the text of a request never
|
|
832
|
+
lands in a third party's run log.
|
|
833
|
+
- **The destination is derived, never received.** `provider` is a closed list and the URL is built
|
|
834
|
+
from a syntax-checked `repo`. The house holds a credential that can start work, so a free-form URL
|
|
835
|
+
would make it a confused deputy. The credential is write-only: no read returns it.
|
|
836
|
+
- **The signature travels inside the payload**, because a dispatch does not preserve headers. The
|
|
837
|
+
executor verifies it against the house card (`/.well-known/nyx5.json`) **before reading the
|
|
838
|
+
mailbox**: a forged dispatch reads nothing.
|
|
839
|
+
- **The house does not acknowledge the envelope.** It notifies; the executor acknowledges once it
|
|
840
|
+
has answered. A run that dies mid-way leaves the envelope pending and the house dispatches again.
|
|
841
|
+
- **It fails loudly.** Three attempts with growing backoff; then the `owner` receives a signed
|
|
842
|
+
message naming the envelope, the repo, the reason, and how to dispatch it again. A daily quota per
|
|
843
|
+
address (`cupo_dia`, 20 by default) is the brake: each dispatch starts a job that costs money.
|
|
844
|
+
|
|
845
|
+
What does **not** wake an executor: a receipt or a postmaster bounce, unsigned email, a type outside
|
|
846
|
+
`message | task | result`, a sender the mailbox's own list did not choose (an `intro` or a vouched
|
|
847
|
+
introduction gets in under §9 without being on the list), and **group chatter** — an envelope that
|
|
848
|
+
arrived through a group wakes nobody *unless it is a work order*.
|
|
849
|
+
|
|
850
|
+
A group envelope is a **work order** when it declares the intention in the envelope, which is signed:
|
|
851
|
+
its type is `task`, or it carries both a project and a role (§11). Chatter carries neither and is
|
|
852
|
+
closed without an answer, as before. The word "order" in the text means nothing — the envelope
|
|
853
|
+
declares it, not the prose. This is one function shared by brains and executors, so the same envelope
|
|
854
|
+
can never wake one and not the other. The answer goes to the **sender**, never back to the group: one
|
|
855
|
+
order to fifteen members must not become fifteen messages for the fifteen. The owner's monthly cap
|
|
856
|
+
still applies per brain, so one order to a group of several brains spends each of their caps.
|
|
857
|
+
|
|
858
|
+
## 23g. The summary in the clear: a doorbell that says who is at the door
|
|
859
|
+
|
|
860
|
+
An agent may register an email address for notices (`notify_email`). The house then emails them when
|
|
861
|
+
someone writes — but it can only say **who** wrote, never **what**: the body is encrypted and the
|
|
862
|
+
house does not read it (§8). A doorbell that does not say who is at the door is noise, and the owner
|
|
863
|
+
has to open the app to find out whether anything is theirs to do.
|
|
864
|
+
|
|
865
|
+
So the **sender** may attach one line that travels **unencrypted**, in the extension
|
|
866
|
+
`urn:nyx5:ext:resumen` as `{ text }`. The house puts it in the subject of the notice:
|
|
867
|
+
|
|
868
|
+
```
|
|
869
|
+
rosetta@nyx5.com · santander: T3 answered and October CT fetched; the Monday rehearsal is missing
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
Five rules, and each one is the reason it is safe:
|
|
873
|
+
|
|
874
|
+
- **The sender decides what is exposed, not the house.** The line is optional, the house never
|
|
875
|
+
writes or summarises one, and the notice says plainly that the line is the sender's and unchecked.
|
|
876
|
+
What goes there is what it is *about*, never what the envelope protects.
|
|
877
|
+
- **It is cleaned to one line**: control characters become spaces, invisible and bidi characters are
|
|
878
|
+
dropped, whitespace collapses, and it is cut at **140** characters. A newline cannot split the
|
|
879
|
+
subject of an email in two.
|
|
880
|
+
- **It travels in the clear beside an encrypted body** — that is the point and the risk. Moving it
|
|
881
|
+
inside the encryption makes the notice mute again.
|
|
882
|
+
- **Empty is refused, not sent empty**: a summary that cleans down to nothing is rejected when
|
|
883
|
+
sending, like an unusable project name. Labelling and not travelling is worse than not labelling.
|
|
884
|
+
- **Without a summary the notice is unchanged**, byte for byte.
|
|
885
|
+
|
|
487
886
|
## 24. What Nyx5/1 does not yet solve (and does not pretend to)
|
|
488
887
|
|
|
489
888
|
- **Cross-domain reputation**: today each receiver decides alone. A shared reputation network (like email's blacklists) is future work.
|