{"_id":"@ao-barbosa/phi-client","_rev":"2-d0292a78333aacef7f02a24bd8e569d4","name":"@ao-barbosa/phi-client","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ao-barbosa/phi-client","version":"1.0.0","keywords":["phi","client","protocol","cbor","binary"],"author":{"name":"Earendil Works"},"license":"MIT","_id":"@ao-barbosa/phi-client@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":"cf51be6b3f203000d07861551bc6b0386ace689a","tarball":"https://registry.npmjs.org/@ao-barbosa/phi-client/-/phi-client-1.0.0.tgz","fileCount":35,"integrity":"sha512-vQ6+l4PjjcXFFPysbivWNllVDKOchVp5aFEihdSLDEHNg4xn1+p4KJRerWd85+PwJhGO3apAFgarxbfVoeORtA==","signatures":[{"sig":"MEUCIQDMhTwQbLOW9MEQKpnjh2lQixhxsxF8IBO0v4QUM9Q5ngIgZAGLntCsRQ5jQ/uiUOeM/W4y7h8d26VELyQff2heMG4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":164400},"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"},"./unix":{"types":"./dist/unix.d.ts","import":"./dist/unix.js"},"./package.json":"./package.json"},"gitHead":"69be3c28c70d249af6bf11fe4d911198b5c70af4","scripts":{"test":"bun test --isolate --preload ../../test-support/setup.ts --timeout 30000","build":"tsgo -p tsconfig.build.json","clean":"rm -rf dist","typecheck":"tsgo -p tsconfig.test.json","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/client"},"_npmVersion":"11.17.0","description":"Transport-neutral client for remote phi sessions over framed CBOR bytes","directories":{},"sideEffects":false,"_nodeVersion":"24.19.0","dependencies":{"@ao-barbosa/phi-chord":"^1.0.0","@ao-barbosa/phi-protocol":"^1.0.0"},"_hasShrinkwrap":false,"packageManager":"bun@1.4.2","devDependencies":{"vitest":"4.1.9"},"_npmOperationalInternal":{"tmp":"tmp/phi-client_1.0.0_1788806508362_0.4254685777818643","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"_id":"@ao-barbosa/phi-client@1.0.1","bugs":{"url":"https://github.com/ao-Barbosa/phi/issues"},"dist":{"shasum":"f091cf395ba9e4dcc08904076ab55a5b17a215cf","tarball":"https://registry.npmjs.org/@ao-barbosa/phi-client/-/phi-client-1.0.1.tgz","fileCount":35,"integrity":"sha512-+zhUsQ0EDQIIUcft0P5ZjJ05zpOdgJAvA2SQweL8a1uH7b9ZR/tglGqXsFcLj/ZZLUFKrpucLAYUWXF4KyrulA==","signatures":[{"sig":"MEUCIANHwzZYzwk/AhU4APGiM6iwVdRRpzqtzZ+nJnhnI8tdAiEAsftQDuA2cuAlCmCxX052sKRONKb2+zXR11kriisg1Ng=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBAH6EH8foWk+xXYnpUK45gK/QNrkMwtdcwiYTFjiDlwAiBfPDttfMXhYEYjLU5/AeVne2YWFM2vycE12fU8g3ebuQ=="}],"unpackedSize":164424},"main":"./dist/index.js","name":"@ao-barbosa/phi-client","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"},"./unix":{"types":"./dist/unix.d.ts","import":"./dist/unix.js"},"./package.json":"./package.json"},"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","typecheck":"tsgo -p tsconfig.test.json","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","client","protocol","cbor","binary"],"repository":{"url":"git+https://github.com/ao-Barbosa/phi.git","type":"git","directory":"packages/client"},"_npmVersion":"11.17.0","description":"Transport-neutral client for remote phi sessions over framed CBOR bytes","directories":{},"maintainers":[{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"}],"sideEffects":false,"_nodeVersion":"24.19.0","contributors":[{"url":"https://github.com/ao-Barbosa","name":"ao-Barbosa"}],"dependencies":{"@ao-barbosa/phi-chord":"^1.0.1","@ao-barbosa/phi-protocol":"^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-client_1.0.1_1789684918802_0.746575816358745"}}},"time":{"created":"2026-09-07T18:41:47.902Z","modified":"2026-09-17T22:41:59.079Z","1.0.0":"2026-09-07T18:41:48.505Z","1.0.1":"2026-09-17T22:41:58.885Z"},"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","client","protocol","cbor","binary"],"repository":{"url":"git+https://github.com/ao-Barbosa/phi.git","type":"git","directory":"packages/client"},"description":"Transport-neutral client for remote phi sessions over framed CBOR bytes","contributors":[{"url":"https://github.com/ao-Barbosa","name":"ao-Barbosa"}],"maintainers":[{"name":"ao-barbosa","email":"arthur_o.b@hotmail.com"}],"readme":"# @ao-Barbosa/phi-client\n\nTransport-neutral client for the experimental Phi service protocol.\n\n```ts\nimport { Client, type ByteTransportFactory } from \"@ao-Barbosa/phi-client\";\n\nconst transportFactory: ByteTransportFactory = async (handlers) => {\n  // Connect using WebSocket, Unix socket, or another ordered byte transport.\n  return {\n    async send(chunk) {\n      // Deliver bytes in invocation order and honor backpressure.\n    },\n    close() {},\n  };\n};\n\nconst client = await Client.connect({\n  serverId: \"01234567-89ab-4def-8123-456789abcdef\",\n  transportFactory,\n});\nconst result = await client.request(\n  { serverId: client.hello.serverId },\n  { serviceId: \"example.service\", member: \"read\", args: [] },\n);\n```\n\nThe client verifies that the physical endpoint reports the expected logical `serverId`. Server-wide requests carry that ID, and every Session request carries the full live target `{ serverId, sessionId, attachmentId }`. The combined durable address prevents cross-server or cross-session misrouting; the server-generated attachment ID rejects delayed frames after switching or reattaching.\n\nTyped server and Session APIs are provided by Chord service bindings owned by the application. `createClientServiceTransport()` adapts a lazily resolved server or Session route to a Chord transport; `request()` and `subscribeService()` remain its low-level primitives. The client uses Chord's service-control parsers and per-subscription state decoder; `phi-protocol` only validates the routed envelope and strict-JSON boundary. A service subscription returns a complete provider snapshot; the binding installs it and then calls `start()` to release updates buffered during hydration. `Client` applies ordered out-of-band attachment changes but deliberately does not construct typed service proxies or interpret application contracts.\n\nApplication observation APIs such as the coding agent's `Transcript` are ordinary Chord services. The client does not interpret their snapshots or updates.\n\nOn disconnect or disposal, pending requests reject locally, but accepted work may still complete remotely before the attachment is released. The client clears its live attachment route. It never reconnects or replays requests automatically. After disconnection, call `reconnect()`, attach through the application's management service again, and explicitly repeat only operations known to be safe.\n\nThe experimental local coordinator only provides a stable endpoint and relays traffic. Replaceable server processes own Session and worker lifecycle outside the public client protocol.\n\nCall transport handlers as follows:\n\n- `handlers.onData(chunk)` for inbound bytes;\n- `handlers.onClose()` for an orderly terminal close;\n- `handlers.onError(error)` for transport failures.\n\nA transport factory creates a fresh authenticated connection for each attempt. Requests are correlated by ID, and server failures are exposed as `ServerError`.\n\n## Unix-domain sockets\n\nNode.js and Bun consumers can use the separate Unix transport:\n\n```ts\nimport { Client } from \"@ao-Barbosa/phi-client\";\nimport { createUnixTransportFactory } from \"@ao-Barbosa/phi-client/unix\";\n\nconst client = new Client({\n  serverId: \"01234567-89ab-4def-8123-456789abcdef\",\n  transportFactory: createUnixTransportFactory({ path: \"/tmp/phi.sock\" }),\n});\nawait client.connect();\n```\n\nUnix discovery scans an explicit physical-route directory, derives each expected server ID from its filename, and verifies it through the existing handshake:\n\n```ts\nimport { discoverUnixServers } from \"@ao-Barbosa/phi-client/unix\";\n\nconst routes = await discoverUnixServers({ directory: \"/run/user/1000/phi\" });\n// [{ serverId: \"...\", path: \"/run/user/1000/phi/<serverId>.sock\" }]\n```\n\nMalformed entries, non-sockets, stale or unresponsive endpoints, and server-ID mismatches are ignored. Discovery is read-only and probes at most 16 sockets concurrently. Unexpected filesystem and socket errors reject discovery. Pass `timeoutMs` to override the default probe timeout.\n\n`ClientOptions.maxFrameLength` bounds protocol payloads. `maxPendingBytes` bounds queued Unix transport output. Configure matching limits on both peers.\n","readmeFilename":"README.md"}