@collective-intelligence/extensions-sdk-frontend-react 0.9.2 → 0.9.4

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.
@@ -226,7 +226,7 @@ Your server invokes an Agent with `agents.invoke({ agentId, input })`, which ret
226
226
 
227
227
  For a multi-turn chat, use the shared chat. Start a Conversation with the Agent with `ci.chat.createConversation({ organizationId, payload: { agentId } })`, send each message with `createChatClient(ci, { organizationId }).send({ conversationId, message })` from `@collective-intelligence/external-apps-server-sdk/chat`, and read earlier turns with `ci.chat.getTranscript`. Each turn is an ordinary Agent run, and the earlier successful turns, with their saved Agent Output, become the model's conversation history. A message sent while a turn still runs steers that turn and starts no second turn, and a resend with the same message `id` adds nothing.
228
228
 
229
- `send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream` and `runs.cancel` read only runs that `agents.invoke` started: follow a turn with `GET /runs/:runId/stream` of the chat mount, and stop it with `ci.chat.cancelTurn`.
229
+ `send` resolves `{ ok: true, value, runId }`: `runId` is the id of the turn's run, which the answer message also carries as `metadata.invocationId`, and `turnRunId(message)` reads it from any answer message. `runs.get`, `runs.sources` and `runs.feedback` accept that id like the `runId` of `agents.invoke`. They answer only the caller that owns the Conversation (the member, the app server or the visitor) through the application where the Conversation started, and answer `not_found` to every other caller. As for any run, only a signed-in member reads `runs.sources` and gives `runs.feedback`. `runs.get` gives the status and `result: { message, output? }`, where `output` is the Agent Output that the turn saved. `runs.feedback` also rates a succeeded turn whose answer is only its Agent Output, with the Output's JSON text as the rated answer; a turn with neither text nor Output has no answer to rate and gets `not_found`. The member can also rate and clear the answer with `ci.chat.putAnswerFeedback` and `ci.chat.clearAnswerFeedback` (`params: { invocationId: runId }`); it is the same rating. Each completed Agent turn with an answer to rate (its text or its Agent Output) of `ci.chat.getTranscript` gives that member `feedbackTargetId` (the turn's run id) and `currentUserFeedback`, so the app shows a saved rating again after a reload. `runs.sources` gives the searched Document Versions with their pages and a download link. `runs.stream` and `runs.cancel` read only runs that `agents.invoke` started: follow a turn with `GET /runs/:runId/stream` of the chat mount, and stop it with `ci.chat.cancelTurn`.
230
230
 
231
231
  Anonymous visitors can chat with an Agent only when its audience has `anonymous: [app]` for that application and the call passes `caller: { kind: "anonymous_visitor", visitor: { issuer, subjectId } }`. Their turns run with the Agent's own bindings, never with the application's grants, and visitors never see each other's conversations.
232
232
 
@@ -110,11 +110,21 @@ const auth = createFederatedAuth({
110
110
 
111
111
  `createFederatedAuth` handles the PKCE login, the callback, session reads and logout under `/api/auth`. Register `<origin>/api/auth/callback` as a redirect URI and the origin as an allowed origin. A package-declared app lists both in its declaration; an app created with the CLI adds them with `ci apps redirect-uris add` and `ci apps origins add`. The session cookie is `__Host-ci-federated` with `Secure`, `HttpOnly` and `SameSite=Lax`, which is why `APP_ORIGIN` must use HTTPS. On a laptop without a TLS proxy, `allowLoopbackHttp: true` lets `http://localhost:3000` work with a cookie named `ci-federated` and no `Secure` flag. Keep that option off in production.
112
112
 
113
- Access tokens always live 300 seconds. A confidential client that passes its `clientSecret` to `createFederatedAuth` renews them silently: when a token has 30 seconds or less left, the session lookup gets a new one first. The renewed token stays in process memory and the cookie is written once at sign-in, so a server restart only triggers another renewal. The session itself lasts `sessionTtlSeconds`, 86400 by default and at most 604800, and never longer than the user's CI session.
113
+ Access tokens always live 300 seconds, and every setup renews them with no redirect. A confidential client that passes its `clientSecret` to `createFederatedAuth` renews in each session lookup: when a token has 30 seconds or less left, the lookup gets a new one first. The renewed token stays in process memory and the cookie is written once at sign-in, so a server restart only triggers another renewal. A public client renews too: with the session store in each lookup, and with the sealed cookie only in the session route and the Renew route.
114
114
 
115
- > **Warning:** If users are logged out after five minutes, the app is a public client. A
116
- > public client gets no renewal credential, so the session ends when the first
117
- > access token expires, whatever `sessionTtlSeconds` says.
115
+ CI ends the user's sign-in to the app at the Idle limit, 14 days after the last renewal, and never after the user's CI session. So a user who comes back within 14 days stays signed in. `sessionTtlSeconds` is optional. Leave it out and the session follows that rule; set it, from 300 to 2592000 seconds (30 days), for a shorter limit counted from sign-in.
116
+
117
+ > **Warning:** A public client with the sealed cookie cannot renew in a session lookup,
118
+ > because a lookup cannot rewrite the cookie. After the access token expires,
119
+ > `getSession`, `getAccessToken` and `getEntityContext` throw
120
+ > `RenewalRequiredError`. A page sends the browser to `error.renewUrl`, the
121
+ > Renew route, which renews and comes back to the page. An app route answers
122
+ > `401` with the nested `renewal_required` body, as the SDK routes do; the
123
+ > client SDK runtime `fetch` then reads the session and repeats the call once.
124
+ > The client SDK also renews an open page on a timer. A confidential client and
125
+ > the session store need none of this.
126
+
127
+ After each start, the first signed-in request also reads CI's token key set. Call `auth.warm?.()` at boot, for example in Next.js `instrumentation.ts` `register`, without waiting for it before the server starts. It reads the key set into the SDK's cache, never rejects, and resolves `{ ok: false, error }` when CI does not answer; the first request then reads the key set itself, as without a warm-up.
118
128
 
119
129
  A revoked grant reaches the app at the next renewal, so within 300 seconds. It reaches the app at once when a forwarded CI answer is a `401` or carries a changed `x-access-version`, which `auth.observeCiResponse` watches for. A user who signs in without a grant that holds the app gate does not bounce straight back with `access_denied`. CI first shows its own access-denied page with "Switch account" and "Back to the application".
120
130
 
@@ -220,14 +220,14 @@ The Connect Studio link that the Dashboard shows only tells the Studio desktop a
220
220
 
221
221
  #### Held by your external app
222
222
 
223
- | Credential | Type | Lifetime or rotation | Used for |
224
- | ------------------ | ------------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------- |
225
- | Client id | Public OAuth identifier | Fixed for the app | Sign-in; safe in the browser |
226
- | Client secret | Opaque secret, confidential apps only | Until rotated; a rotation replaces it at once | Sign-in, token renewal and member-session exchange |
227
- | Server Credential | Opaque secret with the prefix `dsc_` | A rotation keeps the old secret 24 hours; a revocation ends both | The server's own calls to CI in service mode |
228
- | User access token | ES256 token, kept on the server | 300 seconds | Application API calls as the signed-in user |
229
- | Renewal credential | Opaque secret, confidential apps only | At most 7 days from sign-in, never past the user's CI session | New access tokens without a browser redirect |
230
- | Session cookie | Cookie sealed with `SESSION_SECRETS` | `sessionTtlSeconds`: 1 day by default, from 300 seconds to 7 days | The browser's same-origin `/api/*` calls to your BFF |
223
+ | Credential | Type | Lifetime or rotation | Used for |
224
+ | ------------------ | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
225
+ | Client id | Public OAuth identifier | Fixed for the app | Sign-in; safe in the browser |
226
+ | Client secret | Opaque secret, confidential apps only | Until rotated; a rotation replaces it at once | Sign-in, token renewal and member-session exchange |
227
+ | Server Credential | Opaque secret with the prefix `dsc_` | A rotation keeps the old secret 24 hours; a revocation ends both | The server's own calls to CI in service mode |
228
+ | User access token | ES256 token, kept on the server | 300 seconds | Application API calls as the signed-in user |
229
+ | Renewal credential | Opaque secret; a public app gets a new one at each renewal | 14 days after the last renewal, never past the user's CI session | New access tokens without a browser redirect |
230
+ | Session cookie | Cookie sealed with `SESSION_SECRETS` | Set once at sign-in: until the end of the user's CI session, or `sessionTtlSeconds` (300 seconds to 30 days) when that is earlier | The browser's same-origin `/api/*` calls to your BFF |
231
231
 
232
232
  The browser holds only the sealed cookie and the application id. The access token and the renewal credential stay on the server.
233
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/extensions-sdk-frontend-react",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -80,12 +80,12 @@
80
80
  "type-check": "bun check --no-script -p tsconfig.json && bun check --no-script -p tsconfig.type-tests.json"
81
81
  },
82
82
  "dependencies": {
83
- "@collective-intelligence/effect-xstate": "0.9.2",
84
- "@collective-intelligence/extensions-sdk": "0.9.2",
85
- "@collective-intelligence/extensions-sdk-frontend": "0.9.2"
83
+ "@collective-intelligence/effect-xstate": "0.9.4",
84
+ "@collective-intelligence/extensions-sdk": "0.9.4",
85
+ "@collective-intelligence/extensions-sdk-frontend": "0.9.4"
86
86
  },
87
87
  "peerDependencies": {
88
- "@collective-intelligence/ui-react": "0.9.2",
88
+ "@collective-intelligence/ui-react": "0.9.4",
89
89
  "@tanstack/react-query": ">=5 <6",
90
90
  "@xyflow/react": ">=12 <13",
91
91
  "effect": "^4.1.0",
@@ -102,7 +102,7 @@
102
102
  "access": "public"
103
103
  },
104
104
  "devDependencies": {
105
- "@collective-intelligence/ui-react": "0.9.2",
105
+ "@collective-intelligence/ui-react": "0.9.4",
106
106
  "@effect/eslint-plugin": "0.3.2",
107
107
  "@effect/vitest": "4.1.4",
108
108
  "@hey-api/openapi-ts": "^0.96.0",
@@ -130,5 +130,5 @@
130
130
  "vitest": "5.0.2",
131
131
  "xstate": "5.33.3"
132
132
  },
133
- "gitHead": "f2c8453ab95578ca84aaf1032db4370153a76ceb"
133
+ "gitHead": "a9d7006ee83b3aacb2ddb2b7d3790e0b3d43d0ed"
134
134
  }