@poppykit/client 0.1.0 → 0.2.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/API.md CHANGED
@@ -23,3 +23,7 @@ and endpoint; never substitute profile names or model-provided URLs for that bin
23
23
  The [quickstart](examples/quickstart.mjs) is executed by CI. Integration examples
24
24
  describe adapters your application supplies; they are not built-in browser drivers
25
25
  or general API executors.
26
+
27
+ The optional Postgres entry point ships its adapters, `createPostgresPool`,
28
+ `postgresMigration`, `migratePostgres` and schema-version export; see [storage](STORAGE.md).
29
+ TypeScript Postgres consumers also install `@types/pg@8.23.1` as a development dependency.
package/CHANGELOG.md CHANGED
@@ -1,22 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 — initial development release candidate (unpublished)
3
+ ## 0.2.0 (release candidate)
4
4
 
5
- Discovery, safe HTTPS, all three sign-in methods, partial grants/replacement,
6
- owner-aware recovery, JSON/SSE conversations, API/browser/feedback hooks, targeted
7
- SQLite adapters and optional constrained hosted-identity provider.
5
+ Add bundled Postgres auth/conversation/provider stores and explicit migrations. Provider APIs and targeted storage transactions are asynchronous; await callback/result/revocation operations. SQLite and explicit legacy local-store migration remain supported.
8
6
 
9
- - Select MIT licensing and ship the complete LICENSE.
10
- - Prepare public package metadata and the initial 0.1.0 version.
11
- - Preserve J8 strict TypeScript tests, real subprocess/security regressions and
12
- immutable installed-package verification on Linux, macOS and Windows.
7
+ ## 0.1.1
13
8
 
14
- No npm publication has occurred. Version 0.x APIs/storage may still change; record
15
- compatibility and migration/reset implications with future changes. This release
16
- does not promise stable 1.0 compatibility or certify external host integrations.
9
+ Documentation refresh: registry installation, runnable quickstarts, focused guides
10
+ and the tagged GitHub/OIDC release runbook. No runtime API, storage format or
11
+ third-party dependency change.
17
12
 
18
- ## 0.0.0 — historical private development candidates
13
+ ## 0.1.0
19
14
 
20
- J1–J8 established protocol capabilities, targeted storage, durable recovery,
21
- documentation, strict tests and fail-closed release verification. Their prior
22
- commits/artifact results remain historical evidence for those exact candidates.
15
+ Initial MIT development release, published manually. Discovery, safe HTTPS, all
16
+ three sign-in methods, targeted durable storage and recovery, conversations and
17
+ API/browser/feedback hooks. The CLI uses the client SDK with trusted secure-backend
18
+ adapters. J8 established strict typed tests and exact installed-artifact checks.
19
+
20
+ Version 0.x may still change APIs/storage; future changes must explain compatibility,
21
+ migration/reset and security implications. No stable 1.0 or external-host certification
22
+ is promised. Older private 0.0.0 candidates retain their own historical evidence.
package/CONTRIBUTING.md CHANGED
@@ -1,50 +1,38 @@
1
1
  # Contributing
2
2
 
3
- This package targets Personal Agent Protocol draft 0.2. Check the current
4
- [specification](https://personalagentprotocol.org/docs/0.2/spec) and
5
- [guides](https://personalagentprotocol.org/docs/0.2/guides); retained snapshots and
6
- tests are supporting evidence. Distinguish MUST requirements, SHOULD recommendations
7
- and product choices. Individual extensions and demo/business workflows are excluded.
3
+ Follow the live draft 0.2 [specification](https://personalagentprotocol.org/docs/0.2/spec)
4
+ and [guides](https://personalagentprotocol.org/docs/0.2/guides). Tests/snapshots are
5
+ supporting evidence. Demo/business workflows and individual extensions are excluded.
6
+ Code is [MIT](LICENSE); confirm rights for third-party contributions.
8
7
 
9
8
  Use Node 24.12.0, TypeScript 5.9.3 and @types/node 24.10.0.
10
- Install with the pinned pnpm version in package.json and `pnpm install --frozen-lockfile`.
11
- Run `npm run typecheck`, `npm run build`, `npm test` and `npm run check:docs`.
12
- CI partitions tests without omitting any test file; full `npm test` remains useful
13
- locally. Read [RELEASING.md](RELEASING.md) before changing workflow/release behavior.
9
+ Install the packageManager-pinned pnpm and run pnpm install --frozen-lockfile.
14
10
 
15
- Keep changes small and complete: include callers, declarations, regression checks
16
- and documentation. Do not log credentials, weaken destination validation or silently
17
- reset persisted data. Pull requests must explain checks actually run and limitations.
18
- Use the repository's Issues for non-sensitive defects and feature discussions.
19
- Code is licensed under [MIT](LICENSE). No separate contribution agreement is
20
- configured; confirm permission for third-party contributions and obtain owner
21
- authorization before publishing.
11
+ ```sh
12
+ npm run typecheck
13
+ npm run build
14
+ npm run typecheck:tests
15
+ npm test
16
+ npm run check:docs
17
+ ```
22
18
 
23
- ## TypeScript test harness and coverage
19
+ First-party tests/workers/verification helpers are canonical `.mts`. The existing
20
+ compiler checks the whole strict program before emitting ignored adjacent `.mjs`.
21
+ Failed builds remove stale outputs; no loader/type stripping substitutes for checking.
22
+ Run `npm run build:tests` before `node scripts/run-checks.mjs GROUP` (unit, contracts,
23
+ integration, validation). Groups are exhaustive/disjoint. LF source bytes are enforced
24
+ by Git attributes. Generated test code is outside the npm allowlist; production tests
25
+ import built/installed JavaScript. Release/build tools and examples may remain JS.
24
26
 
25
- First-party tests, executable fixtures, process workers and packaged verification
26
- scripts are canonical `.mts` files. Run `npm run typecheck:tests` for the complete
27
- strict program and `npm run build:tests` before individual
28
- `node scripts/run-checks.mjs GROUP` commands (unit, contracts, integration or
29
- validation). `npm test` performs that checked harness build and runs all groups.
30
- Build production first with `npm run build`; tests import compiled `dist/*.js`,
31
- not TypeScript source. No loader or native type stripping replaces the compiler.
27
+ `npm run coverage` builds production and checked tests, then writes native Node
28
+ line/branch/function reports under `coverage/` (summary.txt, lcov.info, report.json,
29
+ raw/). Metrics cover loaded first-party dist JS: no production source maps or TS
30
+ remapping; node_modules excluded, unloaded modules listed. Raw subprocess reports
31
+ are retained, but arbitrary children may not merge and killed workers may not flush.
32
+ Installed/OS/host checks are separate evidence; no percentage proves conformance.
32
33
 
33
- The existing TypeScript compiler emits ignored adjacent `.mjs` files only after
34
- all strict diagnostics pass. Failed builds remove stale canonical outputs.
35
- `scripts/build-tests.mjs` is compiler/bootstrap tooling, not an unchecked test
36
- runner. Canonical test sources use LF, enforced by `.gitattributes`, so Linux and
37
- Windows validate the same exact source bytes. Test output stays outside the npm
38
- package allowlist. Retained JavaScript release/build tools and packaged examples
39
- are genuine production tooling/examples; retained protocol captures are references.
40
-
41
- Run `npm run coverage` for a production build, checked harness and native Node
42
- 24.12.0 line/branch/function report. `coverage/summary.txt`, `coverage/lcov.info`,
43
- `coverage/report.json` and `coverage/raw/` are generated local reports. Metrics
44
- refer to first-party compiled `dist` JavaScript; production emits no source maps
45
- and no TypeScript remapping is claimed. Third-party `node_modules` is excluded;
46
- unloaded modules are listed explicitly. Raw child-process reports are retained,
47
- but arbitrary subprocess execution is not guaranteed to be merged into the native
48
- runner summary, and killed/crashed workers may not flush counters. Actual installed
49
- package/OS checks remain separate evidence. No percentage threshold substitutes
50
- for protocol, negative/security, process and platform assertions.
34
+ Include callers, meaningful regression evidence and docs with behavior changes.
35
+ Preserve credential/destination validation, private errors and persisted data.
36
+ Report checks actually run and limits. Use Issues for non-sensitive defects and
37
+ [SECURITY.md](SECURITY.md) for vulnerabilities. Follow [RELEASING.md](RELEASING.md)
38
+ before tagging/publishing; obtain explicit owner authorization.
package/DELIVERY.md CHANGED
@@ -67,33 +67,14 @@ the durable cursor and fresh authorization.
67
67
  Metadata caching remains bounded and honors freshness, Age, validators, no-cache
68
68
  and no-store, with a 300-second upper bound. Expired entries revalidate; 304s retain
69
69
  prior caching directives. `resolver.invalidate(target?)` fences old pending cache
70
- writes without bypassing fetch concurrency/rate limits. J2 rejects changed saved
70
+ writes without bypassing fetch concurrency/rate limits. The auth lifecycle rejects changed saved
71
71
  issuer/endpoint/resource bindings rather than rerouting persisted work.
72
72
 
73
- ## Company service and retention
74
-
75
- The server accepts `supportedScopes`, the union offered by its actual sign-in
76
- methods. `directScopes` remains a compatibility alias. One coordinator must still
77
- cover authority checks and durable conversation reads/mutations.
78
-
79
- Default JSON/request/frame budget is 1 MiB; the maximum encoded event is
80
- 1 MiB minus 1025 bytes. Page sizing reserves 1024 bytes for worst-case IDs, cursors
81
- and envelopes and counts UTF-8 bytes. Company events and client messages that
82
- cannot fit are rejected before commit; no receipt/work survives a rejected write.
83
- Do not reduce configured budgets below those used for retained accepted events.
84
-
85
- Notifications are post-commit hints. Subscribe before reading; reconcile durable
86
- state on wake or every 1000 ms by default. `createConversationNotifications` is
87
- local acceleration only. Multiple processes work without a broker through targeted
88
- SQLite reconciliation; deployments can implement the same notification contract
89
- with their own distributed adapter. Lost/duplicate hints cannot erase a commit.
90
- SQLite event windows and append operations do not reload complete event histories.
91
-
92
- Server streams default to 30 seconds and apply pull backpressure, rechecking
93
- current authority before further pages. This bounded-connection policy omits
94
- periodic idle comments; proxies may close an idle stream sooner, and the client
95
- reconnects. Longer-lived deployments should supply heartbeat handling at their
96
- HTTP adapter. Hosts must propagate disconnect/AbortSignal and body cancellation.
73
+ ## Peer retention
74
+
75
+ The [server delivery guide](https://github.com/LMol-4/poppykit-server/blob/main/DELIVERY.md)
76
+ describes service configuration, byte budgets, notifications and bounded streams.
77
+ Keep the following distinct lifetimes when choosing an operator retention policy:
97
78
 
98
79
  | Record | Lifetime / deletion rule |
99
80
  | --- | --- |
package/PROVIDER.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Import `createProvider`, `createProviderClient`, and `createResultCipher` from
4
4
  `@poppykit/client/provider`; durable `SqliteProviderStore` is separately exported
5
5
  from `@poppykit/client/provider/sqlite`. Neither is loaded by the core import.
6
- This is PoppyKit provider contract **v1**, not a Personal Agent Protocol extension.
6
+ The wire protocol remains PoppyKit provider **v1**; the 0.2 TypeScript API uses async storage, not a Personal Agent Protocol extension.
7
7
  Node 24.12+ is required for the SQLite reference adapter.
8
8
 
9
9
  An operator supplies HTTPS hosting, a provider client metadata URL, JWKS URL,
@@ -65,7 +65,7 @@ issuer, and exactly one code/error; result ciphertext is sealed atomically with
65
65
  the immutable binding. Identical pending callbacks are harmless; conflicting,
66
66
  canceled, expired and consumed callbacks fail. `takeResult` requires enrollment,
67
67
  installation, operation, issuer and exact session; it consumes within the same
68
- SQLite transaction before returning private callback data. Lost retrieval delivery
68
+ storage transaction before returning private callback data. Lost retrieval delivery
69
69
  is uncertain, never a reason to exchange or retrieve again. SDK code owns PKCE and
70
70
  the exchange. Never log request URLs or responses on this route.
71
71
 
@@ -97,3 +97,26 @@ Account Tokens or DPoP keys. Revoke company authorization **before** disabling
97
97
  provider signing, or use authenticated company account controls afterward.
98
98
  This is scoped authority, redaction and provider key custody; it does not isolate
99
99
  authority from unrestricted programs running as the same OS user.
100
+
101
+ ## Migrating provider code to 0.2
102
+
103
+ Await every provider operation, including `callback`, `takeResult`, `cancel` and
104
+ `revokeEnrollment`; HTTP callback success is returned only after storage commits.
105
+ Use rejected-Promise assertions for failures. Signer, enrollment authentication,
106
+ metadata and session verification stay outside storage transactions; ResultCipher
107
+ remains synchronous local cryptography.
108
+
109
+ `ProviderSelection` declares enroll, identity, operation, begin, callback or revoke.
110
+ Remote stores load and lock only that aggregate; out-of-selection access and thenable
111
+ callbacks reject. Enroll locks a namespace capacity counter; identity mapping locks
112
+ visitor/full-issuer keys across installations; callbacks re-resolve state after the
113
+ enrollment fence. Begin/revoke inspect at most 1,001 operation rows. All valid Unicode
114
+ operation IDs count toward limits and revocation. Existing SQLite databases retain
115
+ records and initialize the capacity counter from their enrollment rows.
116
+
117
+ For an existing local synchronous custom store, explicitly wrap it with
118
+ `adaptLegacyProviderStore(legacyStore)`. This migration helper ignores selections
119
+ and cannot turn local synchronous I/O into remote persistence. New remote/custom
120
+ stores implement the targeted contract directly. The bundled Postgres adapter is
121
+ `PostgresProviderStore` from `@poppykit/client/provider/postgres`; see
122
+ [storage](STORAGE.md) for explicit migrations, TLS and lifecycle.
package/README.md CHANGED
@@ -1,30 +1,24 @@
1
1
  # PoppyKit client
2
2
 
3
- TypeScript SDK for personal-agent providers integrating [Personal Agent Protocol
4
- draft 0.2](https://personalagentprotocol.org/docs/0.2/spec). Discover companies,
5
- start sessions, use Direct/Device/Mediated sign-in, exchange JSON/SSE conversations,
6
- authorize API requests, join an agent browser and send feedback. Your application
7
- supplies the agent and trusted infrastructure.
3
+ TypeScript SDK for [Personal Agent Protocol draft 0.2](https://personalagentprotocol.org/docs/0.2/spec):
4
+ discovery, authentication, conversations and API/browser/feedback hooks. Your
5
+ application supplies the agent and trusted infrastructure. [MIT](LICENSE).
8
6
 
9
- ## Installation
7
+ ## Install
10
8
 
11
- Requires Node **24.12.0 or later**, ESM and HTTPS. CI certifies Node 24.12.0;
12
- later majors are not separately certified. Optional SQLite uses experimental
13
- `node:sqlite` and local filesystem locking.
9
+ Version 0.2.0 is a release candidate until its publishing workflow completes.
14
10
 
15
- Version **0.1.0** is an initial development release candidate under the [MIT license](LICENSE).
16
- It has not been published. Install a verified tarball:
11
+ Requires Node **24.12.0+**, ESM and HTTPS. CI tests Node 24.12.0 on Linux, macOS and
12
+ Windows; later majors are not separately certified.
17
13
 
18
14
  ```sh
19
- npm install ./poppykit-client-0.1.0.tgz
15
+ npm install @poppykit/client@0.2.0
20
16
  ```
21
17
 
22
- The only production dependency is `jose@6.2.12`. No server SDK or CLI is required.
23
- Registry installation instructions will accompany the first public release.
18
+ ## Discover a company
24
19
 
25
- ## Quickstart
26
-
27
- Discovery needs no signing key, account token or database:
20
+ No credentials or database are needed. Replace `company.example` with a company
21
+ publishing draft 0.2 discovery:
28
22
 
29
23
  ```js
30
24
  import { createMetadataResolver, createNodeTransport } from '@poppykit/client';
@@ -38,87 +32,21 @@ try {
38
32
  }
39
33
  ```
40
34
 
41
- Replace `company.example` with a company publishing draft 0.2 discovery.
42
- Run the complete [quickstart](examples/quickstart.mjs) with a real domain, or
43
- `node examples/quickstart.mjs --self-check` for a deterministic offline example.
44
-
45
- ## Configuration and authentication
46
-
47
- `createClientAuth(options)` owns sessions, all three sign-in methods, renewal,
48
- scope replacement, sign-out and recovery. Supply `namespace`, `localUserId`,
49
- `clientId`, registered `redirectUris`, an `AuthStore`, `SecretStore`, safe transport
50
- and metadata resolver. Run `recover()` at startup. Publish HTTPS client metadata
51
- and public JWKS; private signing keys stay in your signer or provider.
52
-
53
- Choose an `IdentitySigner`, or authenticated `AssertionProvider` and
54
- `ProviderIdentity` adapters. The optional `/provider` reference is documented in
55
- [PROVIDER.md](PROVIDER.md). Operators supply HTTPS hosting, enrollment authentication,
56
- company policy and signing/KMS. Anonymous sessions require a separate local signer
57
- with a published key; provider-only custody reports `anonymous_unavailable`.
58
-
59
- Call `start(domain)`, then `authorization(connectionId, scopes)` to inspect grants,
60
- missing scopes and advertised methods. `beginSignIn(connectionId, { method, scopes })`
61
- selects `direct`, `device` or `mediated`. Direct requires an authenticated browser
62
- binding and HTTPS callback. Device displays a verified human link/code and resumes
63
- with `continueSignIn`. Mediated invokes your `TrustedInput.collect` UI. Keep that UI,
64
- passwords, codes and credential adapters outside model tools. See [AUTH.md](AUTH.md)
65
- for partial consent, scope upgrades, cancellation and revocation.
66
-
67
- ## Examples and common operations
68
-
69
- Configure conversations using the verified target and the same auth lifecycle:
70
-
71
- ```js
72
- import { createConversationClient } from '@poppykit/client';
73
- const target = await auth.target(connectionId);
74
- const conversations = createConversationClient({
75
- ...target, connectionId, store: conversationStore, clock: { now: Date.now },
76
- authorizedRequest: request => auth.authorizedFetch(connectionId, request, target),
77
- authorization: (id, scopes) => auth.authorization(id, scopes),
78
- });
79
- ```
80
-
81
- `auth`, `connectionId` and `conversationStore` are your configured instances.
82
- `start`, `send`, `read`, `watch`, `ack`, `handoff` and `close` manage the lifecycle.
83
- Retain message IDs for retries; acknowledge durable deliveries after processing.
84
- [DELIVERY.md](DELIVERY.md) explains cursors, streaming, pagination and retention.
85
-
86
- Use `apiTarget`/`apiFetch` with an existing OpenAPI or MCP client. The final URL
87
- must be independently authorized; an OpenAPI `servers` entry grants no authority.
88
- `joinBrowser` accepts a trusted agent-controlled controller separate from human
89
- consent. `feedback` sends a single `missing` report expecting empty HTTP 202.
90
- [INTEGRATIONS.md](INTEGRATIONS.md) documents the adapter contracts and examples.
91
-
92
- ## Errors, cancellation, retries and limits
93
-
94
- Handle `AuthFailure.code` and `ConversationError.code`; do not parse messages or
95
- log credential headers/private adapter errors. Pending operations are resumable;
96
- an uncertain remote exchange requires reconciliation and is never silently replayed.
97
- Declined upgrades preserve old access; sign-out never automatically reconnects.
98
-
99
- Conversation operations accept `AbortSignal`. Cancellation cannot undo bytes sent.
100
- Conversation retries retain message IDs/payloads with bounded backoff and Retry-After.
101
- Auth deadlines persist across restarts. Feedback has no automatic POST retry or
102
- deduplication promise. Pools, bodies, event/page sizes and reconnects are bounded;
103
- see [DELIVERY.md](DELIVERY.md). External effects need application idempotency.
104
-
105
- ## Storage and production responsibilities
35
+ The packaged [quickstart](examples/quickstart.mjs) also supports `--self-check`
36
+ without a network service.
106
37
 
107
- Optional `/sqlite` exports `SqliteAuthStore` and `SqliteConversationStore`;
108
- `/memory` exports non-durable `MemoryConversationStore`. Consumers can implement
109
- the targeted contracts using their own databases. Store Account Tokens, DPoP keys
110
- and PKCE in a secure `SecretStore`; Session Tokens stay in memory. SQLite stores
111
- secret references and private message data, not vault encryption. Database, vault
112
- and remote exchange are separate boundaries; implement orphan-secret reconciliation
113
- and deployment ownership checks. [STORAGE.md](STORAGE.md) defines atomicity,
114
- recovery and explicit development reset.
38
+ ## Guides
115
39
 
116
- ## Reference and support
40
+ - [Authentication](AUTH.md): sessions, Direct/Device/Mediated, consent, renewal and revocation.
41
+ - [Storage](STORAGE.md): targeted adapters, secret references, recovery and explicit resets.
42
+ - [Delivery](DELIVERY.md): messages, streaming, cancellation, retries and retention.
43
+ - [Integrations](INTEGRATIONS.md): verified API targets, agent browser and feedback.
44
+ - [Optional provider](PROVIDER.md): operator-hosted signing and callback custody.
45
+ - [API exports](API.md), [contributing](CONTRIBUTING.md), [security](SECURITY.md),
46
+ [changelog](CHANGELOG.md) and [releasing](RELEASING.md).
117
47
 
118
- [API.md](API.md) maps public exports and TypeScript declarations to deeper guides.
119
- This independent draft implementation has deterministic and packaged tests;
120
- production vaults, browsers, external issuers and hosting need operator validation.
121
- Individual protocol extensions and application business logic are outside the SDK.
122
- See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md),
123
- [CHANGELOG.md](CHANGELOG.md) and [RELEASING.md](RELEASING.md). No public license grant
124
- has been selected; publication remains blocked pending the owner's license decision.
48
+ Keep Account Tokens, DPoP keys and PKCE in a secure SecretStore; never expose them
49
+ to model tools. An uncertain remote result must not be silently replayed. SQLite
50
+ is optional/experimental and is not vault encryption. Production issuers, vaults,
51
+ browsers and hosting require operator validation; individual extensions and
52
+ application business workflows are outside this SDK.