{"_id":"@baguette-studios/kernl-client","_rev":"4-595a2d97322ec9f613fb04b7448ab458","name":"@baguette-studios/kernl-client","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@baguette-studios/kernl-client","version":"0.1.0","license":"ISC","_id":"@baguette-studios/kernl-client@0.1.0","maintainers":[{"name":"baguette-studios","email":"astier.jules@gmail.com"}],"homepage":"https://github.com/Jules-Astier/agent-context#readme","bugs":{"url":"https://github.com/Jules-Astier/agent-context/issues"},"dist":{"shasum":"c7a7a5fd7d1cb9347187092d58248d42debe7d0f","tarball":"https://registry.npmjs.org/@baguette-studios/kernl-client/-/kernl-client-0.1.0.tgz","fileCount":7,"integrity":"sha512-/QxNo7VWAQxK9iieBCsSZlqZ1qGSmDwbmHm62HzIPNfvoE4bFvTYYLa6qFdnjA0lXDoKH5gU413fyue/kyh3PA==","signatures":[{"sig":"MEUCIEl6icLzk7B8kQFz/pOyZXWiHIbJFeG/ZkTo+05lPR80AiEA4hz3Px7boNuyAtQqUXQPe8hqsRzM9Zj6LKZwLA6zEBM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57193},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"8a1785f4716e17064cce879e285c95ef7b10d371","private":false,"scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"baguette-studios","email":"astier.jules@gmail.com"},"repository":{"url":"git+https://github.com/Jules-Astier/agent-context.git","type":"git","directory":"packages/client"},"_npmVersion":"10.9.3","description":"Browser-safe Kernl client, session transport, and capability snapshot contracts.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@baguette-studios/kernl-core":"0.1.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.9","typescript":"^5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/kernl-client_0.1.0_1784066859682_0.1752177897554288","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@baguette-studios/kernl-client","version":"0.1.1","license":"ISC","_id":"@baguette-studios/kernl-client@0.1.1","maintainers":[{"name":"baguette-studios","email":"astier.jules@gmail.com"}],"homepage":"https://github.com/Jules-Astier/agent-context#readme","bugs":{"url":"https://github.com/Jules-Astier/agent-context/issues"},"dist":{"shasum":"3dcbb5eea9fb65581e4fe02dcea44be8d2bffec7","tarball":"https://registry.npmjs.org/@baguette-studios/kernl-client/-/kernl-client-0.1.1.tgz","fileCount":7,"integrity":"sha512-Edmy7KB+eA8js9NiZbaQJGWOFXfbbB2pndhZTFr+3jzULnd54/T09YIQM5QlkjQTCj36Ya//uIjN40uOkmesmw==","signatures":[{"sig":"MEYCIQC9QWOu5BQ1lRnED7Tg/VfCoa5C4pXH+lJxF47C8LFvhAIhAP7rU9MHV0hlfDIKguNrdK5IpbZheN7b7GzrEI/sDoJi","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57229},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"gitHead":"8a1785f4716e17064cce879e285c95ef7b10d371","private":false,"scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"baguette-studios","email":"astier.jules@gmail.com"},"repository":{"url":"git+https://github.com/Jules-Astier/agent-context.git","type":"git","directory":"packages/client"},"_npmVersion":"10.9.3","description":"Browser-safe Kernl client, session transport, and capability snapshot contracts.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@baguette-studios/kernl-core":"0.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.9","typescript":"^5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/kernl-client_0.1.1_1784104257192_0.9990586305885283","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@baguette-studios/kernl-client","version":"0.1.2","license":"ISC","_id":"@baguette-studios/kernl-client@0.1.2","maintainers":[{"name":"baguette-studios","email":"astier.jules@gmail.com"}],"homepage":"https://github.com/Jules-Astier/agent-context#readme","bugs":{"url":"https://github.com/Jules-Astier/agent-context/issues"},"dist":{"shasum":"5f51c57e17d02b1deafe042355a2ab45fc056e35","tarball":"https://registry.npmjs.org/@baguette-studios/kernl-client/-/kernl-client-0.1.2.tgz","fileCount":7,"integrity":"sha512-HzfcveyQr3vrPoIzr8sz1ILc1n942ZUEHhGyQxyzgHvqtbEv/HEPed9zOKQE9MVipUS9Er6EMk163zN3HBm2RQ==","signatures":[{"sig":"MEUCIQDJeOY2CDePcmYpV8QuiDtGeRABDS7zdiJ6hrhnKpLiAQIgc5iO5RDIZLvawsf4h0vPuy32swV3YvsU5m9RYXneRig=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57229},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"gitHead":"8a1785f4716e17064cce879e285c95ef7b10d371","private":false,"scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"baguette-studios","email":"astier.jules@gmail.com"},"repository":{"url":"git+https://github.com/Jules-Astier/agent-context.git","type":"git","directory":"packages/client"},"_npmVersion":"10.9.8","description":"Browser-safe Kernl client, session transport, and capability snapshot contracts.","directories":{},"_nodeVersion":"22.23.1","dependencies":{"@baguette-studios/kernl-core":"0.1.2"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.9","typescript":"^5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/kernl-client_0.1.2_1784114031333_0.03868048568644533","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@baguette-studios/kernl-client","version":"0.2.0","type":"module","private":false,"description":"Browser-safe Kernl client, session transport, and capability snapshot contracts.","license":"ISC","repository":{"type":"git","url":"git+https://github.com/Jules-Astier/agent-context.git","directory":"packages/client"},"homepage":"https://github.com/Jules-Astier/agent-context#readme","bugs":{"url":"https://github.com/Jules-Astier/agent-context/issues"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit","test":"vitest run"},"dependencies":{"@baguette-studios/kernl-core":"0.2.0"},"devDependencies":{"typescript":"^5.8.3","vitest":"^4.1.9"},"_id":"@baguette-studios/kernl-client@0.2.0","gitHead":"d8fc5415769275ee958ad9ede38126edaba34a91","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-2TWJUujgAtTnfR7g2mYT/emAFNDKSqz8R0COAP6MTnyc3Jm1/8RLqb8uBXhhUsDZLtMt8izIqhqZVkG25MuG7Q==","shasum":"5486e95e31001986ce9bee43b1a3c89dcb43521c","tarball":"https://registry.npmjs.org/@baguette-studios/kernl-client/-/kernl-client-0.2.0.tgz","fileCount":7,"unpackedSize":112428,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFbs9aB6W3nDpAbPajPCXz/QoUJz7OVtIoal4QzY4X51AiEAwWMD2Td7DMn50aRJ4mOZzKll67dJvCqpJG6XWspGhvA="}]},"_npmUser":{"name":"baguette-studios","email":"astier.jules@gmail.com"},"directories":{},"maintainers":[{"name":"baguette-studios","email":"astier.jules@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kernl-client_0.2.0_1784736177511_0.389707011021853"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-14T22:07:39.481Z","modified":"2026-07-22T16:02:57.823Z","0.1.0":"2026-07-14T22:07:39.826Z","0.1.1":"2026-07-15T08:30:57.336Z","0.1.2":"2026-07-15T11:13:51.505Z","0.2.0":"2026-07-22T16:02:57.656Z"},"bugs":{"url":"https://github.com/Jules-Astier/agent-context/issues"},"license":"ISC","homepage":"https://github.com/Jules-Astier/agent-context#readme","repository":{"type":"git","url":"git+https://github.com/Jules-Astier/agent-context.git","directory":"packages/client"},"description":"Browser-safe Kernl client, session transport, and capability snapshot contracts.","maintainers":[{"name":"baguette-studios","email":"astier.jules@gmail.com"}],"readme":"# @baguette-studios/kernl-client\n\nBrowser-safe client for appending user messages and browser tool results to the Kernl hosted service. It also defines the capability snapshot and browser event contracts used by framework SDKs.\n\n```bash\nnpm install @baguette-studios/kernl-client\n```\n\n```ts\nimport { createKernlSessionClient } from \"@baguette-studios/kernl-client\";\n\nconst client = createKernlSessionClient({\n  projectId: \"your-project\",\n  clientKey: \"kernlpk_live_...\",\n  baseUrl: \"https://api.kernl.dev\",\n  session: { id: \"conversation:123\" },\n  auth: {\n    getSessionToken: async ({ sessionId, forceRefresh, signal }) => {\n      const response = await fetch(\"/api/kernl/session-token\", {\n        method: \"POST\",\n        credentials: \"include\",\n        headers: { \"content-type\": \"application/json\" },\n        body: JSON.stringify({ sessionId, forceRefresh }),\n        signal\n      });\n      if (!response.ok) throw new Error(\"Unable to create Kernl session token\");\n      return (await response.json()).token;\n    }\n  }\n});\n```\n\n## Production authentication\n\n`auth.getSessionToken({ sessionId, forceRefresh, signal })` should call your backend using the user's normal application session. Your backend authenticates the user, checks that they may use the requested session, and signs a short-lived JWT with an `exp` claim. Do not put the JWT signing key in browser code.\n\nThe client keeps tokens in memory, isolated by session id. It reuses a token until its JWT `exp` enters the refresh window (60 seconds by default, configurable with `auth.refreshSkewMs`), and deduplicates concurrent token requests for the same session. A `401` causes exactly one retry after calling the provider with `forceRefresh: true`; providers should bypass any host-side token cache in that case. The request `AbortSignal`, when present, is passed to the provider.\n\nThe bearer token is attached to user-message appends, browser tool-result appends, event replay, and transcript reads. Provider failures and HTTP errors are sanitized so known tokens, bearer values, and JWT-shaped values are not exposed in client-visible error text.\n\nFramework providers restore the server-owned visible transcript on mount by\ndefault when a client is configured and no explicit initial messages or local\n`sessionPersistence` adapter is supplied. Set `restoreTranscript: false` only\nfor an intentionally fresh or externally managed UI. The browser cache is not\nthe conversation system of record.\n\nThe same client instance exposes `listEvents({ afterSequence })` for browser-safe replay and `listTranscript({ afterSequence, limit })` for server-owned visible conversation history. Both reads use the same session token cache, refresh, retry, and redaction path as appends.\n\nCall `client.clearSessionToken(sessionId)` after logout, account or tenant switching, or an authorization change. Calling `client.clearSessionToken()` clears all session-token cache and pending-deduplication state held by that client instance. This clears browser memory only; it does not revoke an already issued token on the server.\n\nFor compatibility with existing integrations, `session: { id, token }` still sends a static bearer token when `auth` is omitted. Prefer `auth.getSessionToken` in production so tokens can expire and refresh without rebuilding the client. When `auth` is configured, its token provider is authoritative over `session.token`.\n\nAfter verification, the Kernl server is authoritative for the identity, tenant, budget, and restriction claims used by hosted execution. Browser metadata is not authority. Application tools still call your existing authenticated APIs, where your backend remains the final authority for object permissions, validation, and side effects.\n\nThis package is a client SDK. It does not contain the private Kernl hosted runtime, provider execution, control-plane validation, storage, queues, or model credentials.\n\nMost React applications can use the `client` configuration on `@baguette-studios/kernl-react` without importing this package directly.\n\nSee the [session protocol](https://github.com/Jules-Astier/agent-context/blob/main/docs/sdk-server-protocol.md) for the wire contract.\n","readmeFilename":"README.md"}