{"_id":"@ao-barbosa/phi-protocol","_rev":"2-db918c01ccc0d772f534e0eccdf7b680","name":"@ao-barbosa/phi-protocol","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ao-barbosa/phi-protocol","version":"1.0.0","keywords":["phi","protocol","cbor","binary","framing"],"author":{"name":"Earendil Works"},"license":"MIT","_id":"@ao-barbosa/phi-protocol@1.0.0","maintainers":[{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"}],"contributors":[{"url":"https://github.com/ao-Barbosa","name":"ao-Barbosa"}],"homepage":"https://github.com/ao-Barbosa/phi#readme","bugs":{"url":"https://github.com/ao-Barbosa/phi/issues"},"dist":{"shasum":"54733c019a41f10ede03ff913dce874c80b197a2","tarball":"https://registry.npmjs.org/@ao-barbosa/phi-protocol/-/phi-protocol-1.0.0.tgz","fileCount":34,"integrity":"sha512-/m7xVQBzRN8xZDhCHioShW2TNq4NEiGALkmzM+uvpIxLeUEb54COwPS1CZiWUrldytuvFV6ftbjB4c0CkHf0Kw==","signatures":[{"sig":"MEYCIQDITv5CxcBJoN169dRliNxRV/3xlFkBLiykCburfi0sZQIhAJixpwlhhJpUF+QAvySWfXoLRe/lcGwIbTPqcqoTTQEF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":141601},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"bun":">=1.4.2"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"69be3c28c70d249af6bf11fe4d911198b5c70af4","scripts":{"test":"bun test --isolate --preload ../../test-support/setup.ts --timeout 30000","build":"tsgo -p tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"bun run clean && bun run build"},"_npmUser":{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"},"repository":{"url":"git+https://github.com/ao-Barbosa/phi.git","type":"git","directory":"packages/protocol"},"_npmVersion":"11.17.0","description":"Transport-neutral CBOR protocol for remote phi sessions","directories":{},"_nodeVersion":"24.19.0","dependencies":{"typebox":"1.3.7","@ao-barbosa/phi-chord":"^1.0.0"},"_hasShrinkwrap":false,"packageManager":"bun@1.4.2","devDependencies":{"vitest":"4.1.9"},"_npmOperationalInternal":{"tmp":"tmp/phi-protocol_1.0.0_1788806489821_0.7269251072475871","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"_id":"@ao-barbosa/phi-protocol@1.0.1","bugs":{"url":"https://github.com/ao-Barbosa/phi/issues"},"dist":{"shasum":"e35f0aa564d51428a10f5d6ff0193d732a9556cd","tarball":"https://registry.npmjs.org/@ao-barbosa/phi-protocol/-/phi-protocol-1.0.1.tgz","fileCount":34,"integrity":"sha512-CimxrUNAN6wgtIArOSmvImEVY/Ly9yUixywLLVDThiyyZ2aajG0seEEm8weQn1wZ7iWAAPJrm6p8Y7GUdKXVkw==","signatures":[{"sig":"MEQCIGQ3an5EjhfAbfnNkBv87cD4EBf2u3ZzWsVB+R/p/xYtAiAmP45UxXjeFARuSkzwB7eXPe6ad1giCzm8eodSOWOFYw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBOpJEhS+uTDosQ7zXLGaxvom7b29nVk96D/JPVzKxJYAiEAk3i+xH+FsK0AXUkV8iZLXMJTTpcnlZslta3KPM9myvM="}],"unpackedSize":141600},"main":"./dist/index.js","name":"@ao-barbosa/phi-protocol","type":"module","types":"./dist/index.d.ts","author":{"name":"Mario Zechner"},"engines":{"bun":">=1.4.2"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"d4a3bef54ccdc2ab06cff573949ae42c8e28f068","license":"MIT","scripts":{"test":"bun test --isolate --preload ../../test-support/setup.ts --timeout 30000","build":"tsgo -p tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"bun run clean && bun run build"},"version":"1.0.1","_npmUser":{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"},"homepage":"https://github.com/ao-Barbosa/phi#readme","keywords":["phi","protocol","cbor","binary","framing"],"repository":{"url":"git+https://github.com/ao-Barbosa/phi.git","type":"git","directory":"packages/protocol"},"_npmVersion":"11.17.0","description":"Transport-neutral CBOR protocol for remote phi sessions","directories":{},"maintainers":[{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"}],"_nodeVersion":"24.19.0","contributors":[{"url":"https://github.com/ao-Barbosa","name":"ao-Barbosa"}],"dependencies":{"typebox":"1.3.7","@ao-barbosa/phi-chord":"^1.0.1"},"_hasShrinkwrap":false,"packageManager":"bun@1.4.2","devDependencies":{"vitest":"4.1.9"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/phi-protocol_1.0.1_1789684929152_0.565942993175859"}}},"time":{"created":"2026-09-07T18:41:29.652Z","modified":"2026-09-17T22:42:09.380Z","1.0.0":"2026-09-07T18:41:29.956Z","1.0.1":"2026-09-17T22:42:09.229Z"},"bugs":{"url":"https://github.com/ao-Barbosa/phi/issues"},"author":{"name":"Mario Zechner"},"license":"MIT","homepage":"https://github.com/ao-Barbosa/phi#readme","keywords":["phi","protocol","cbor","binary","framing"],"repository":{"url":"git+https://github.com/ao-Barbosa/phi.git","type":"git","directory":"packages/protocol"},"description":"Transport-neutral CBOR protocol for remote phi sessions","contributors":[{"url":"https://github.com/ao-Barbosa","name":"ao-Barbosa"}],"maintainers":[{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"}],"readme":"# @ao-Barbosa/phi-protocol\n\nRuntime-neutral routed envelopes, CBOR encoding, and byte-stream framing for the experimental Phi protocol.\n\nProtocol version `8` defines:\n\n- a version handshake that identifies the logical `serverId`;\n- explicit server and Session request targets;\n- correlated requests and responses with opaque strict-JSON payloads;\n- request cancellation, opaque subscription updates, and out-of-band attachment changes;\n- non-empty opaque error codes and bounded transport messages.\n\nA server target contains `{ serverId }`; a Session target contains `{ serverId, sessionId, attachmentId }`. The combined route fences calls to one logical server, durable Session, and live presentation attachment. Management `attach()` and `detach()` return no routing identifiers; the server publishes the selected live route in an out-of-band `attachment` message. Disconnecting releases only that presentation's attachment after admitted calls settle.\n\nChord owns the payload semantics carried inside these envelopes: `{ serviceId, instance?, member, args }` calls, the `$chord.service` control vocabulary, service catalogues, subscription snapshots and updates, service error codes, and the independent Delta path codecs for replicated states. `phi-protocol` validates that each opaque payload is strict JSON but does not validate or export its Chord grammar. Clients and servers parse those values through `@ao-barbosa/phi-chord` at the service adapter boundary.\n\nSession-directory state, management results, transcripts, models, plugins, and all other application values remain opaque service data. The real `Session` and `AgentHarness` remain process-local. Server and Session calls route opaquely to their owning providers, where Chord and the application validate and invoke them.\n\nServer and worker lifecycle is intentionally outside this public protocol. The experimental local coordinator is only an opaque message router; each replaceable server process owns the private lifecycle protocol.\n\nEach wire frame consists of a four-byte unsigned big-endian payload length followed by one definite-length CBOR item. `encodeClientMessage()` and `encodeServerMessage()` validate and encode complete frames. `ClientMessageDecoder` and `ServerMessageDecoder` accept arbitrary stream fragmentation and coalescing.\n\n```ts\nimport {\n  PROTOCOL_VERSION,\n  encodeClientMessage,\n  ServerMessageDecoder,\n  type ClientHello,\n} from \"@ao-Barbosa/phi-protocol\";\n\nconst hello: ClientHello = { type: \"hello\", version: PROTOCOL_VERSION };\ntransport.send(encodeClientMessage(hello));\n\nconst decoder = new ServerMessageDecoder({ maxFrameLength: 1024 * 1024 });\nfor (const message of decoder.push(incomingChunk)) handleServerMessage(message);\ndecoder.end();\n```\n\nAll envelope schemas reject unknown object properties, and codecs recursively reject non-JSON opaque payloads, including non-finite numbers, byte arrays, `undefined`, prototypes, and cycles. Envelope violations, malformed CBOR, and invalid framing throw `ProtocolValidationError`. Payload-specific adapters must perform their own semantic validation after decoding. Transports must preserve byte order. Peer authentication and authenticated service contexts are not implemented by the experimental transport.\n\nDefault limits are 16 MiB per CBOR payload/frame, 1,000,000 array elements or map entries, and 64 nested item levels. The protocol is experimental and has no compatibility guarantees.\n","readmeFilename":"README.md"}