@adonis-agora/authkit-server 1.0.0-rc.1 → 1.0.0-rc.2

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +4 -5
  3. package/build/index.d.ts +5 -11
  4. package/build/index.js +4 -9
  5. package/build/providers/authkit_server_provider.js +6 -8
  6. package/build/src/agents/config.d.ts +9 -13
  7. package/build/src/agents/config.js +17 -11
  8. package/build/src/agents/delegation_service.js +3 -3
  9. package/build/src/agents/delegation_store.d.ts +3 -2
  10. package/build/src/agents/delegation_store.js +6 -5
  11. package/build/src/agents/extension.d.ts +261 -0
  12. package/build/src/agents/extension.js +40 -0
  13. package/build/src/agents/middleware.js +1 -1
  14. package/build/src/agents/protocol.d.ts +4 -4
  15. package/build/src/agents/registry_store.d.ts +3 -2
  16. package/build/src/agents/registry_store.js +1 -1
  17. package/build/src/agents/runtime.d.ts +26 -7
  18. package/build/src/agents/runtime.js +110 -75
  19. package/build/src/audit/audit_sink.js +1 -1
  20. package/build/src/define_config.d.ts +0 -12
  21. package/build/src/define_config.js +9 -7
  22. package/build/src/host/account_api/account_api_controller.js +8 -6
  23. package/build/src/host/account_session_sign_in.d.ts +12 -0
  24. package/build/src/host/account_session_sign_in.js +19 -0
  25. package/build/src/host/admin_console/console_personal_agents_controller.d.ts +1 -6
  26. package/build/src/host/admin_console/console_personal_agents_controller.js +50 -30
  27. package/build/src/host/admin_sessions_service.js +8 -5
  28. package/build/src/host/auth_host_config.d.ts +6 -2
  29. package/build/src/host/controllers/account_apps_controller.js +15 -11
  30. package/build/src/host/csrf.d.ts +3 -3
  31. package/build/src/host/csrf.js +3 -13
  32. package/build/src/host/default_mailer.d.ts +11 -6
  33. package/build/src/host/default_mailer.js +16 -12
  34. package/build/src/host/i18n.d.ts +3 -14
  35. package/build/src/host/i18n.js +15 -13
  36. package/build/src/host/register_auth_host.js +26 -61
  37. package/build/src/host/ui-dist/assets/index-BqyJYRVX.js +67 -0
  38. package/build/src/host/ui-dist/index.html +1 -1
  39. package/build/src/provider/oidc_service.d.ts +1 -1
  40. package/build/src/provider/oidc_service.js +1 -1
  41. package/build/src/schema/ensure.d.ts +14 -0
  42. package/build/src/schema/ensure.js +43 -150
  43. package/package.json +2 -2
  44. package/build/src/agents/poppy/client_registry.d.ts +0 -50
  45. package/build/src/agents/poppy/client_registry.js +0 -260
  46. package/build/src/agents/poppy/config.d.ts +0 -396
  47. package/build/src/agents/poppy/config.js +0 -228
  48. package/build/src/agents/poppy/dpop.d.ts +0 -61
  49. package/build/src/agents/poppy/dpop.js +0 -158
  50. package/build/src/agents/poppy/email_code_sign_in.d.ts +0 -27
  51. package/build/src/agents/poppy/email_code_sign_in.js +0 -140
  52. package/build/src/agents/poppy/errors.d.ts +0 -25
  53. package/build/src/agents/poppy/errors.js +0 -25
  54. package/build/src/agents/poppy/replay.d.ts +0 -25
  55. package/build/src/agents/poppy/replay.js +0 -106
  56. package/build/src/agents/poppy/resource.d.ts +0 -100
  57. package/build/src/agents/poppy/resource.js +0 -129
  58. package/build/src/agents/poppy/safe_fetch.d.ts +0 -48
  59. package/build/src/agents/poppy/safe_fetch.js +0 -262
  60. package/build/src/agents/poppy/service.d.ts +0 -293
  61. package/build/src/agents/poppy/service.js +0 -1458
  62. package/build/src/agents/poppy/session_jwt.d.ts +0 -30
  63. package/build/src/agents/poppy/session_jwt.js +0 -133
  64. package/build/src/agents/poppy/store.d.ts +0 -106
  65. package/build/src/agents/poppy/store.js +0 -261
  66. package/build/src/agents/poppy/web_session.d.ts +0 -39
  67. package/build/src/agents/poppy/web_session.js +0 -122
  68. package/build/src/host/controllers/poppy_consent_controller.d.ts +0 -19
  69. package/build/src/host/controllers/poppy_consent_controller.js +0 -199
  70. package/build/src/host/controllers/poppy_controller.d.ts +0 -33
  71. package/build/src/host/controllers/poppy_controller.js +0 -219
  72. package/build/src/host/poppy_session_key.d.ts +0 -9
  73. package/build/src/host/poppy_session_key.js +0 -9
  74. package/build/src/host/ui-dist/assets/index-D0EIeyKK.js +0 -67
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @adonis-agora/authkit-server
2
2
 
3
+ ## 1.0.0-rc.2
4
+
5
+ ### Major Changes
6
+
7
+ - [#456](https://github.com/DavideCarvalho/adonis-agora-authkit/pull/456) [`9c12ef9`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/9c12ef9c1c49db9d54a7da6d241264499ad76e18) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Poppy (the Personal Agent Protocol) moves out of `@adonis-agora/authkit-server` into the new `@adonis-agora/authkit-poppy` package, and authkit-server gains a stable extension surface for personal-agent protocols. See [Install `@adonis-agora/authkit-poppy` for Poppy](https://github.com/DavideCarvalho/adonis-agora-authkit/blob/main/apps/docs/content/docs/migrating-to-1-0.mdx#install-adonis-agoraauthkit-poppy-for-poppy).
8
+
9
+ Breaking changes (`@adonis-agora/authkit-server`):
10
+
11
+ - `personalAgents.poppy` is removed: install `@adonis-agora/authkit-poppy` and use `personalAgents: { extensions: [poppy({ ... })] }` with the same options. A config that still has `personalAgents.poppy` fails at boot. Routes, tables, tokens and sessions are unchanged, so no data migration is needed.
12
+ - Every Poppy export (`PoppyConfigInput` and the other `Poppy*` types, `poppyEmailCodeSignIn`, `verifyPoppyRequest`, `poppyAuth`, `poppyOf`, `poppyWebSession`, `poppyWebSessionOf`, `installPoppySlots`, `POPPY_AUTHENTICATE_SLOT`, `POPPY_WEB_SESSION_KEY`, `PoppyError`, `verifyDpopProof`, `accessTokenHash`, `hmacNonceSource`, `databaseReplayStore`, `memoryReplayStore`, `redisReplayStore`, `safeFetchJson`, `isBlockedAddress`, `SafeFetchError`, `maskEmail`) now comes from `@adonis-agora/authkit-poppy`.
13
+ - `mail.onPoppySignInCode` is removed: pass `sendCode` to `poppyEmailCodeSignIn()`.
14
+ - `authkitCsrfExceptions` no longer takes `poppyPrefix`; extensions' endpoints are exempted from the config (`personalAgentExtensions: false` turns that off).
15
+ - `ensureAuthkitSchema()` no longer creates the `auth_poppy_*` tables (the extension's tables are ensured at boot; `ensurePoppySchema()` for migrations).
16
+ - Admin console API: an extension's `protocols` entry is `{ label, requireRegistration, hostResolver, allowHttpIdentifiers, identifierLabel, identifierPlaceholder }`.
17
+
18
+ New, stable for 1.x: `personalAgents.extensions` and the types `PersonalAgentExtension`, `PersonalAgentExtensionDefinition`, `PersonalAgentExtensionContext`, `PersonalAgentRouteKit`, `PersonalAgentHost`, `PersonalAgentGrantLedger`, `PersonalAgentGrant`, `PersonalAgentRefreshToken`, `PersonalAgentAccessTokens`, `PersonalAgentProtocolRuntime`, `PersonalAgentGrantSummary`, `PersonalAgentConsoleSummary`, `ResolvedPersonalAgentExtension`, `AuthkitTable`; the functions `personalAgentExtensionRuntime`, `ensureAuthkitTables`, `sendAuthkitCodeEmail`, `signInAccountSession` and `signOutAccountSession`; and the `tables` option of `ensureAuthkitSchema`.
19
+
20
+ Breaking changes (`@adonis-agora/authkit-react`):
21
+
22
+ - `PersonalAgentProtocol` is `'pact'` or any extension id, and `PersonalAgentsOverview.protocols` has one entry per extension (`PersonalAgentExtensionOverview`) instead of a fixed `poppy` key. `AccountAgentGrant.protocol` uses `PersonalAgentProtocol`.
23
+
3
24
  ## 1.0.0-rc.1
4
25
 
5
26
  ### Major Changes
package/README.md CHANGED
@@ -15,11 +15,10 @@ wrapper around [`oidc-provider`](https://github.com/panva/node-oidc-provider).
15
15
  auth via `acr_values`, Dynamic Client Registration (RFC 7591/7592).
16
16
  - **Personal agents** — AI assistants acting for your users: agent identity by signed JWT
17
17
  (JWKS, no shared secrets) and user-approved, revocable delegation with scopes you define,
18
- over a pluggable protocol adapter ([PACT](https://openpactprotocol.org) built in).
19
- Plus the [Personal Agent Protocol ("Poppy")](https://personalagentprotocol.org/docs/spec):
20
- discovery, signed `Poppy-Session` agent sessions, Direct/Device/Mediated sign-in, MCP and browser sessions.
21
- ⚠️ **Experimental** — tracks the spec's Draft 0.3 and will change (possibly breaking, outside
22
- semver majors) while the spec is a draft.
18
+ over a pluggable protocol adapter ([PACT](https://openpactprotocol.org) built in), plus
19
+ `personalAgents.extensions` for protocols shipped as their own packages — the
20
+ [Personal Agent Protocol ("Poppy")](https://personalagentprotocol.org/docs/spec) is
21
+ [`@adonis-agora/authkit-poppy`](https://www.npmjs.com/package/@adonis-agora/authkit-poppy).
23
22
  - **Native apps** — RFC 8252 native clients (`authkit:clients:create --native`: private-use
24
23
  scheme / claimed https / loopback redirects, always public + PKCE) and the `@adonisjs/auth`
25
24
  guards `oidcRpGuard` (session) and `oidcBearerGuard` (`Authorization: Bearer` access tokens,
package/build/index.d.ts CHANGED
@@ -15,19 +15,12 @@ export type { PersonalAgentIdentity } from './src/agents/agent_identity.js';
15
15
  export { PersonalAgentVerifier } from './src/agents/agent_identity.js';
16
16
  export type { PersonalAgentDelegationConfigInput, PersonalAgentRegistration, PersonalAgentResolver, PersonalAgentsConfigInput, ResolvedPersonalAgentsConfig, } from './src/agents/config.js';
17
17
  export type { DelegationContext, DelegationGrantSummary, DelegationReceipt, } from './src/agents/delegation_service.js';
18
+ export type { AuthkitTable, PersonalAgentAccessTokens, PersonalAgentConsoleSummary, PersonalAgentExtension, PersonalAgentExtensionContext, PersonalAgentExtensionDefinition, PersonalAgentGrant, PersonalAgentGrantLedger, PersonalAgentGrantSummary, PersonalAgentHost, PersonalAgentProtocolRuntime, PersonalAgentRefreshToken, PersonalAgentRouteKit, ResolvedPersonalAgentExtension, } from './src/agents/extension.js';
18
19
  export type { PersonalAgentAuthOptions, PersonalAgentRequestContext, } from './src/agents/middleware.js';
19
20
  export { personalAgentAuth, personalAgentOf, personalAgentReceipt, personalAgentSecurity, personalAgentStepUp, } from './src/agents/middleware.js';
20
- export type { PoppyAgentProtocolEntry, PoppyApiEntry, PoppyBrowserLogin, PoppyClientsConfigInput, PoppyConfigInput, PoppyLimiter, PoppyMediatedConfigInput, PoppyMediatedField, PoppyMediatedResult, PoppyMediatedVerifyInput, PoppyPrincipalBase, PoppyReplayStore, PoppyScopeHint, ResolvedPoppyConfig, } from './src/agents/poppy/config.js';
21
- export { accessTokenHash, type DpopNonceSource, type DpopResult, hmacNonceSource, type VerifyDpopInput, verifyDpopProof, } from './src/agents/poppy/dpop.js';
22
- export { maskEmail, type PoppyEmailCodeSignInOptions, poppyEmailCodeSignIn, } from './src/agents/poppy/email_code_sign_in.js';
23
- export { PoppyError, type PoppyErrorCode } from './src/agents/poppy/errors.js';
24
- export { databaseReplayStore, memoryReplayStore, redisReplayStore, } from './src/agents/poppy/replay.js';
25
- export { installPoppySlots, POPPY_AUTHENTICATE_SLOT, type PoppyAuthenticate, type PoppyAuthResult, type PoppyPrincipal, type PoppySlotRequest, poppyAuth, poppyOf, verifyPoppyRequest, writePoppyAuthError, } from './src/agents/poppy/resource.js';
26
- export { isBlockedAddress, SafeFetchError, safeFetchJson, } from './src/agents/poppy/safe_fetch.js';
27
- export type { PoppyAuthError, PoppyGrantSummary, PoppySessionState, PoppyTokenResponse, PoppyVerifyOptions, } from './src/agents/poppy/service.js';
28
- export { type PoppyWebSessionMarker, poppyWebSession, poppyWebSessionOf, } from './src/agents/poppy/web_session.js';
29
21
  export type { BuiltinProtocolId, PactOptions, PersonalAgentProtocol, } from './src/agents/protocol.js';
30
22
  export { pact, pactProtocol } from './src/agents/protocol.js';
23
+ export { type PersonalAgentRuntimeSource, personalAgentExtensionRuntime, } from './src/agents/runtime.js';
31
24
  export type { AuditEvent, AuditEventType, AuditPage, AuditSink, ListAuditParams, StoredAuditEvent, } from './src/audit/audit_sink.js';
32
25
  export { lucidAuditSink } from './src/audit/lucid_audit_sink.js';
33
26
  export type { ConsoleAuthorize, ConsoleAuthorizeResult, ConsoleAuthorizer, ConsoleAuthorizerClass, } from './src/console_authorize.js';
@@ -58,6 +51,7 @@ export type { AccountPathKey, AccountPathsOptions } from './src/host/account_pat
58
51
  export { accountPath, accountPrefix, joinAccountPath, } from './src/host/account_paths.js';
59
52
  export type { AccountConfirmMethod, AccountConfirmProps, AccountEmailConfirmedProps, AccountLoginProps, AccountMfaProps, AccountSecurityProps, } from './src/host/account_screen_props.js';
60
53
  export { ACCOUNT_SESSION_KEY } from './src/host/account_session_key.js';
54
+ export { signInAccountSession, signOutAccountSession, } from './src/host/account_session_sign_in.js';
61
55
  export { ACTIVE_ORG_COOKIE, ACTIVE_ORG_COOKIE_TTL, decodeActiveOrgCookie, encodeActiveOrgCookie, readActiveOrgFromKoaCtx, } from './src/host/active_org_cookie.js';
62
56
  export type { AddMemberInput as AdminAddMemberInput, CreateInvitationInput as AdminCreateInvitationInput, CreateOrgInput as AdminCreateOrgInput, OrgDetail, OrgWithMemberCount, UpdateOrgInput as AdminUpdateOrgInput, } from './src/host/admin_api/admin_orgs_service.js';
63
57
  export { AdminOrgsService } from './src/host/admin_api/admin_orgs_service.js';
@@ -92,6 +86,7 @@ export type { CustomLoginIdentity, CustomLoginMethod, CustomLoginMethodBinding,
92
86
  export { authenticateCustomLogin, beginCustomLogin, completeCustomLogin, } from './src/host/custom_login.js';
93
87
  export type { CustomMfaContext, CustomMfaDescription, CustomMfaDescriptor, CustomMfaField, CustomMfaMethod, CustomMfaMethodBinding, CustomMfaMethodConstructor, CustomMfaMethods, } from './src/host/custom_mfa.js';
94
88
  export { beginCustomMfa, customMfaViewProps, verifyCustomMfa } from './src/host/custom_mfa.js';
89
+ export { sendAuthkitCodeEmail } from './src/host/default_mailer.js';
95
90
  export { normalizeEmailIdentifier } from './src/host/email_identifier.js';
96
91
  export type { ResolveGeo } from './src/host/geo.js';
97
92
  export { GEO_RESOLVE_TIMEOUT_MS, resolveGeoSafe } from './src/host/geo.js';
@@ -111,7 +106,6 @@ export { OidcRpGuard, oidcRpGuard } from './src/host/oidc_rp_guard.js';
111
106
  export { evaluateLoginOtp, generateOtpCode, OTP_LOGIN_DEFAULTS, type OtpLoginConfigInput, type OtpVerifyOutcome, type ResolvedOtpLoginConfig, resolveOtpLoginConfig, } from './src/host/otp_login.js';
112
107
  export type { PersistentRpOptions } from './src/host/persistent_rp_session.js';
113
108
  export { endRpSession } from './src/host/persistent_rp_session.js';
114
- export { POPPY_WEB_SESSION_KEY } from './src/host/poppy_session_key.js';
115
109
  export type { AuthThrottles, ThrottleMiddleware } from './src/host/rate_limit.js';
116
110
  export { createAuthThrottles } from './src/host/rate_limit.js';
117
111
  export type { AccountScreensOptions, AuthHostOptions, AuthHostRouteMap, } from './src/host/register_auth_host.js';
@@ -163,5 +157,5 @@ export { OidcService } from './src/provider/oidc_service.js';
163
157
  export { checkClientRegistration, classifyRedirect, type RedirectUriPolicy, type RegistrationOperation, RegistrationPolicyError, type ResolvedRedirectUriPolicy, type ValidateRegistrationHook, } from './src/provider/registration_policy.js';
164
158
  export { registerOidcRoutes } from './src/register_routes.js';
165
159
  export type { EnsureSchemaOptions, EnsureSchemaReport } from './src/schema/ensure.js';
166
- export { ensureAuthkitSchema } from './src/schema/ensure.js';
160
+ export { ensureAuthkitSchema, ensureAuthkitTables } from './src/schema/ensure.js';
167
161
  export { stubsRoot } from './stubs/main.js';
package/build/index.js CHANGED
@@ -10,14 +10,8 @@ export { lucidStores } from './src/accounts/lucid_stores.js';
10
10
  export { ProviderIdentities, ProviderIdentitiesUnsupportedError, } from './src/accounts/provider_identities.js';
11
11
  export { PersonalAgentVerifier } from './src/agents/agent_identity.js';
12
12
  export { personalAgentAuth, personalAgentOf, personalAgentReceipt, personalAgentSecurity, personalAgentStepUp, } from './src/agents/middleware.js';
13
- export { accessTokenHash, hmacNonceSource, verifyDpopProof, } from './src/agents/poppy/dpop.js';
14
- export { maskEmail, poppyEmailCodeSignIn, } from './src/agents/poppy/email_code_sign_in.js';
15
- export { PoppyError } from './src/agents/poppy/errors.js';
16
- export { databaseReplayStore, memoryReplayStore, redisReplayStore, } from './src/agents/poppy/replay.js';
17
- export { installPoppySlots, POPPY_AUTHENTICATE_SLOT, poppyAuth, poppyOf, verifyPoppyRequest, writePoppyAuthError, } from './src/agents/poppy/resource.js';
18
- export { isBlockedAddress, SafeFetchError, safeFetchJson, } from './src/agents/poppy/safe_fetch.js';
19
- export { poppyWebSession, poppyWebSessionOf, } from './src/agents/poppy/web_session.js';
20
13
  export { pact, pactProtocol } from './src/agents/protocol.js';
14
+ export { personalAgentExtensionRuntime, } from './src/agents/runtime.js';
21
15
  export { lucidAuditSink } from './src/audit/lucid_audit_sink.js';
22
16
  export { authorizeByToken } from './src/console_authorize.js';
23
17
  export { adapters, defineConfig, resolveAdmin, resolveAdminApi, resolveAuthMethodsConfig, resolveDynamicRegistration, resolveLogin, resolveNotifications, resolveOrganizations, resolvePasswordless, resolveRateLimit, resolveRegistration, resolveWebauthn, toSeconds, } from './src/define_config.js';
@@ -39,6 +33,7 @@ export { AccountExportService } from './src/host/account_export_service.js';
39
33
  */
40
34
  export { accountPath, accountPrefix, joinAccountPath, } from './src/host/account_paths.js';
41
35
  export { ACCOUNT_SESSION_KEY } from './src/host/account_session_key.js';
36
+ export { signInAccountSession, signOutAccountSession, } from './src/host/account_session_sign_in.js';
42
37
  // Organizations (multi-tenancy)
43
38
  export { ACTIVE_ORG_COOKIE, ACTIVE_ORG_COOKIE_TTL, decodeActiveOrgCookie, encodeActiveOrgCookie, readActiveOrgFromKoaCtx, } from './src/host/active_org_cookie.js';
44
39
  export { AdminOrgsService } from './src/host/admin_api/admin_orgs_service.js';
@@ -65,6 +60,7 @@ export { consoleLoginUrl, getAccountId, hasAccountSession, realAccountId, } from
65
60
  export { authkitCsrfExceptions } from './src/host/csrf.js';
66
61
  export { authenticateCustomLogin, beginCustomLogin, completeCustomLogin, } from './src/host/custom_login.js';
67
62
  export { beginCustomMfa, customMfaViewProps, verifyCustomMfa } from './src/host/custom_mfa.js';
63
+ export { sendAuthkitCodeEmail } from './src/host/default_mailer.js';
68
64
  export { normalizeEmailIdentifier } from './src/host/email_identifier.js';
69
65
  export { GEO_RESOLVE_TIMEOUT_MS, resolveGeoSafe } from './src/host/geo.js';
70
66
  export { BUILTIN_MESSAGES, DEFAULT_LOCALE, DEFAULT_MESSAGES, PT_BR_MESSAGES, resolveMessages, translate, } from './src/host/i18n.js';
@@ -89,7 +85,6 @@ export { OidcRpGuard, oidcRpGuard } from './src/host/oidc_rp_guard.js';
89
85
  // Login por OTP (código digitável): config + helpers puros.
90
86
  export { evaluateLoginOtp, generateOtpCode, OTP_LOGIN_DEFAULTS, resolveOtpLoginConfig, } from './src/host/otp_login.js';
91
87
  export { endRpSession } from './src/host/persistent_rp_session.js';
92
- export { POPPY_WEB_SESSION_KEY } from './src/host/poppy_session_key.js';
93
88
  export { createAuthThrottles } from './src/host/rate_limit.js';
94
89
  export { registerAuthHost } from './src/host/register_auth_host.js';
95
90
  export { edgeRenderer } from './src/host/renderers/edge_renderer.js';
@@ -140,5 +135,5 @@ export { generatePatToken, hashPatToken } from './src/pat/pat_tokens.js';
140
135
  export { OidcService } from './src/provider/oidc_service.js';
141
136
  export { checkClientRegistration, classifyRedirect, RegistrationPolicyError, } from './src/provider/registration_policy.js';
142
137
  export { registerOidcRoutes } from './src/register_routes.js';
143
- export { ensureAuthkitSchema } from './src/schema/ensure.js';
138
+ export { ensureAuthkitSchema, ensureAuthkitTables } from './src/schema/ensure.js';
144
139
  export { stubsRoot } from './stubs/main.js';
@@ -134,8 +134,8 @@ export default class AuthkitServerProvider {
134
134
  personalAgents: config.personalAgents
135
135
  ? {
136
136
  prefix: config.personalAgents.prefix,
137
- ...(config.personalAgents.poppy
138
- ? { poppyPrefix: config.personalAgents.poppy.prefix }
137
+ ...(config.personalAgents.extensions?.length
138
+ ? { extensions: config.personalAgents.extensions }
139
139
  : {}),
140
140
  }
141
141
  : undefined,
@@ -154,12 +154,9 @@ export default class AuthkitServerProvider {
154
154
  const logger = await this.app.container.make('logger').catch(() => null);
155
155
  warnAdminConsoleUnauthorized(logger);
156
156
  }
157
- // Poppy: o slot global que o `@adonis-agora/agent` usa para autenticar o endpoint de
158
- // conversas (e o MCP) sem importar este pacote — o contrato é o símbolo.
159
- if (config.personalAgents?.poppy) {
160
- const { installPoppySlots } = await import('../src/agents/poppy/resource.js');
161
- const { poppyUrls } = await import('../src/agents/poppy/service.js');
162
- installPoppySlots(poppyUrls(config.issuer, config.personalAgents.poppy.prefix).issuer);
157
+ // `personalAgents.extensions`: o boot de cada uma (slots globais, etc.).
158
+ for (const extension of config.personalAgents?.extensions ?? []) {
159
+ await extension.boot?.();
163
160
  }
164
161
  // Auto-montagem das rotas (`config.routes`). Chama a MESMA função exportada que o
165
162
  // `start/routes.ts` chamaria; não há segunda implementação. "As rotas não subiram" não pode
@@ -268,6 +265,7 @@ export default class AuthkitServerProvider {
268
265
  const report = await ensureAuthkitSchema(db, {
269
266
  connection: config.schema.connection,
270
267
  accountTable: config.accountStore?.accountTable,
268
+ tables: config.personalAgents?.extensions?.flatMap((e) => e.tables ?? []),
271
269
  });
272
270
  const logger = await this.app.container.make('logger').catch(() => null);
273
271
  if (report.created.length > 0) {
@@ -12,7 +12,7 @@
12
12
  * recibos) não depende de protocolo; o formato do fio vem do adapter em
13
13
  * `protocol` (default: PACT — https://openpactprotocol.org). Ver `protocol.ts`.
14
14
  */
15
- import { type PoppyConfigInput, type ResolvedPoppyConfig } from './poppy/config.js';
15
+ import { type PersonalAgentExtension, type ResolvedPersonalAgentExtension } from './extension.js';
16
16
  import { type BuiltinProtocolId, type PersonalAgentProtocol } from './protocol.js';
17
17
  /** Registro de um personal agent conhecido (PACT §3.1). */
18
18
  export interface PersonalAgentRegistration {
@@ -58,8 +58,8 @@ export interface PersonalAgentsConfigInput {
58
58
  /**
59
59
  * Valor que os personal agents põem no `aud` do JWT deles (PACT). Opaco e
60
60
  * atribuído por ESTE app no registro do agente — um valor por app, não
61
- * derivado de URL. Liga o PACT; obrigatório, a não ser num app só-Poppy
62
- * (`poppy` sem `audience`).
61
+ * derivado de URL. Liga o PACT; obrigatório, a não ser num app que só usa
62
+ * `extensions` (sem `audience`).
63
63
  */
64
64
  audience?: string;
65
65
  /**
@@ -79,14 +79,10 @@ export interface PersonalAgentsConfigInput {
79
79
  /** Prefixo das rotas (`{prefix}/oauth/*`, `{prefix}/consent`). Default: `/agents`. */
80
80
  prefix?: string;
81
81
  /**
82
- * Personal Agent Protocol ("Poppy", https://personalagentprotocol.org) — o
83
- * segundo protocolo, ao lado do PACT. Um app pode servir os dois. Ver
84
- * `poppy/config.ts`.
85
- *
86
- * @experimental Poppy (Personal Agent Protocol) Draft 0.3 — acompanha a spec em desenvolvimento e PODE MUDAR
87
- * de forma incompatível fora de majors enquanto ela for draft.
82
+ * Outros protocolos de personal agents, de pacotes à parte, ao lado do PACT
83
+ * (ex.: `poppy()` de `@adonis-agora/authkit-poppy`). Ver {@link PersonalAgentExtension}.
88
84
  */
89
- poppy?: PoppyConfigInput;
85
+ extensions?: PersonalAgentExtension[];
90
86
  }
91
87
  export interface ResolvedPersonalAgentDelegationConfig {
92
88
  interfaceUrl: string;
@@ -108,11 +104,11 @@ export interface ResolvedPersonalAgentsConfig {
108
104
  open: boolean;
109
105
  delegation?: ResolvedPersonalAgentDelegationConfig;
110
106
  prefix: string;
111
- /** Poppy resolvido (undefined = desligado). */
112
- poppy?: ResolvedPoppyConfig;
107
+ /** `extensions` resolvidas, na ordem do config. */
108
+ extensions: ResolvedPersonalAgentExtension[];
113
109
  }
114
110
  export declare function normalizePersonalAgentsPrefix(prefix: string | undefined): string;
115
- export declare function resolvePersonalAgentsConfig(input: PersonalAgentsConfigInput | undefined): ResolvedPersonalAgentsConfig | undefined;
111
+ export declare function resolvePersonalAgentsConfig(input: PersonalAgentsConfigInput | undefined, issuer?: string): ResolvedPersonalAgentsConfig | undefined;
116
112
  /** `"a b c"` → `['a','b','c']` sem duplicatas, na ordem. */
117
113
  export declare function parseScope(value: string | null | undefined): string[];
118
114
  export declare function formatScope(scopes: Iterable<string>): string;
@@ -12,7 +12,7 @@
12
12
  * recibos) não depende de protocolo; o formato do fio vem do adapter em
13
13
  * `protocol` (default: PACT — https://openpactprotocol.org). Ver `protocol.ts`.
14
14
  */
15
- import { resolvePoppyConfig, } from './poppy/config.js';
15
+ import { resolvePersonalAgentExtensions, } from './extension.js';
16
16
  import { BUILTIN_PROTOCOLS, } from './protocol.js';
17
17
  const SCOPE_ID = /^[\x21\x23-\x5B\x5D-\x7E]+$/; // RFC 6749 §3.3 scope-token
18
18
  function assertUrl(value, what) {
@@ -37,19 +37,20 @@ export function normalizePersonalAgentsPrefix(prefix) {
37
37
  return '/agents';
38
38
  return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
39
39
  }
40
- export function resolvePersonalAgentsConfig(input) {
40
+ export function resolvePersonalAgentsConfig(input, issuer = '') {
41
41
  if (!input)
42
42
  return undefined;
43
+ // 0.x → 1.0: o Poppy virou o pacote `@adonis-agora/authkit-poppy`.
44
+ if ('poppy' in input) {
45
+ throw new Error('authkit: `personalAgents.poppy` saiu do authkit-server — instale `@adonis-agora/authkit-poppy` e use `personalAgents.extensions: [poppy({ ... })]`.');
46
+ }
43
47
  const pact = !!input.audience?.trim();
44
- if (!pact && !input.poppy) {
45
- throw new Error('authkit: personalAgents.audience é obrigatório (o `aud` dos JWTs dos agentes PACT) — ou configure só `personalAgents.poppy`.');
48
+ if (!pact && !input.extensions?.length) {
49
+ throw new Error('authkit: personalAgents.audience é obrigatório (o `aud` dos JWTs dos agentes PACT) — ou configure só `personalAgents.extensions`.');
46
50
  }
47
51
  if (!pact && input.delegation) {
48
52
  throw new Error('authkit: personalAgents.delegation é do PACT e exige `personalAgents.audience`.');
49
53
  }
50
- if (input.protocol === 'poppy') {
51
- throw new Error('authkit: o Poppy não é um `protocol` do PACT — configure-o em `personalAgents.poppy` (os dois convivem).');
52
- }
53
54
  let resolveAgent;
54
55
  let staticAgents = null;
55
56
  if (typeof input.agents === 'function') {
@@ -94,9 +95,14 @@ export function resolvePersonalAgentsConfig(input) {
94
95
  throw new Error(`authkit: personalAgents.protocol "${String(input.protocol)}" desconhecido (embutidos: ${Object.keys(BUILTIN_PROTOCOLS).join(', ')}).`);
95
96
  }
96
97
  const prefix = normalizePersonalAgentsPrefix(input.prefix);
97
- const poppy = resolvePoppyConfig(input.poppy, input.delegation?.scopes);
98
- if (poppy && pact && (poppy.prefix === prefix || poppy.prefix.startsWith(`${prefix}/`))) {
99
- throw new Error(`authkit: personalAgents.poppy.prefix "${poppy.prefix}" não pode ficar debaixo de personalAgents.prefix ("${prefix}").`);
98
+ const extensions = resolvePersonalAgentExtensions(input.extensions, {
99
+ issuer,
100
+ delegationScopes: input.delegation?.scopes ? { ...input.delegation.scopes } : null,
101
+ });
102
+ for (const extension of extensions) {
103
+ if (pact && (extension.prefix === prefix || extension.prefix.startsWith(`${prefix}/`))) {
104
+ throw new Error(`authkit: o prefixo "${extension.prefix}" de personalAgents.extensions "${extension.id}" não pode ficar debaixo de personalAgents.prefix ("${prefix}").`);
105
+ }
100
106
  }
101
107
  return {
102
108
  pact,
@@ -107,7 +113,7 @@ export function resolvePersonalAgentsConfig(input) {
107
113
  open: input.open === true,
108
114
  delegation,
109
115
  prefix,
110
- poppy,
116
+ extensions,
111
117
  };
112
118
  }
113
119
  /** `"a b c"` → `['a','b','c']` sem duplicatas, na ordem. */
@@ -31,11 +31,11 @@ function newUserCode() {
31
31
  return `${code.slice(0, 4)}-${code.slice(4)}`;
32
32
  }
33
33
  /**
34
- * A tabela de grants é compartilhada com o Poppy (refresh tokens, `pgrant_`):
35
- * o PACT só enxerga os dele.
34
+ * A tabela de grants é compartilhada com as `personalAgents.extensions` (cada uma com o seu
35
+ * prefixo de id): o PACT só enxerga os dele, `agrant_`.
36
36
  */
37
37
  function isPactGrant(id) {
38
- return !id.startsWith('pgrant_');
38
+ return id.startsWith('agrant_');
39
39
  }
40
40
  /** Aceita o código como o usuário digitar: minúsculas, sem hífen, com espaços. */
41
41
  export function normalizeUserCode(input) {
@@ -38,7 +38,8 @@ export interface GrantRow {
38
38
  updatedAt: Date;
39
39
  }
40
40
  export interface LiveGrantFilter {
41
- protocol?: 'pact' | 'poppy';
41
+ /** Só os grants com este prefixo de id (`agrant_` = PACT; o `grantIdPrefix` de uma extension). */
42
+ idPrefix?: string;
42
43
  clientId?: string;
43
44
  accountId?: string;
44
45
  }
@@ -88,7 +89,7 @@ export declare class DelegationStore {
88
89
  }): Promise<GrantRow[]>;
89
90
  countLiveGrants(now: Date, filter?: LiveGrantFilter): Promise<number>;
90
91
  /** Conexões vivas de um protocolo por agente: `client_id` → número de grants. */
91
- countLiveGrantsByClient(now: Date, protocol: 'pact' | 'poppy'): Promise<Map<string, number>>;
92
+ countLiveGrantsByClient(now: Date, idPrefix: string): Promise<Map<string, number>>;
92
93
  /** Ids dos grants não revogados de um agente (vivos ou não) — para revogar todos. */
93
94
  unrevokedGrantIdsOfClient(clientId: string): Promise<string[]>;
94
95
  /** Revoga um grant sem checar a conta — reação a reuso de refresh token. */
@@ -186,12 +186,13 @@ export class DelegationStore {
186
186
  // ─── console admin (todas as contas) ──────────────────────────────────────
187
187
  /**
188
188
  * Grants vivos (não revogados nem expirados em `now`), de todas as contas. O
189
- * protocolo sai do prefixo do id: `agrant_` (PACT) ou `pgrant_` (Poppy).
189
+ * protocolo sai do prefixo do id: `agrant_` (PACT) ou o `grantIdPrefix` de uma extension.
190
190
  */
191
191
  #live(now, filter = {}) {
192
192
  let q = this.conn().from(GRANT_TABLE).whereNull('revoked_at').where('expires_at', '>', now);
193
- if (filter.protocol)
194
- q = q.where('id', 'like', filter.protocol === 'poppy' ? 'pgrant_%' : 'agrant_%');
193
+ // O prefixo é `[a-z0-9]+_`: o `_` do LIKE (um caractere qualquer) casa com ele mesmo.
194
+ if (filter.idPrefix)
195
+ q = q.where('id', 'like', `${filter.idPrefix}%`);
195
196
  if (filter.clientId)
196
197
  q = q.where('client_id', filter.clientId);
197
198
  if (filter.accountId)
@@ -211,8 +212,8 @@ export class DelegationStore {
211
212
  return Number(row?.total ?? 0);
212
213
  }
213
214
  /** Conexões vivas de um protocolo por agente: `client_id` → número de grants. */
214
- async countLiveGrantsByClient(now, protocol) {
215
- const rows = await this.#live(now, { protocol })
215
+ async countLiveGrantsByClient(now, idPrefix) {
216
+ const rows = await this.#live(now, { idPrefix })
216
217
  .select('client_id')
217
218
  .count('* as total')
218
219
  .groupBy('client_id');
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Personal-agent protocol extensions — the surface another package uses to plug a personal-agent
3
+ * protocol into the auth host (`personalAgents.extensions` in `config/authkit.ts`).
4
+ *
5
+ * **Stable for all of 1.x.** Everything in this file follows semver: a 1.x release only adds
6
+ * optional members. A protocol package (such as `@adonis-agora/authkit-poppy`) can change as fast
7
+ * as its spec does without forcing a major here.
8
+ *
9
+ * What an extension gets:
10
+ *
11
+ * - its own routes under the auth host, with the account guard and the rate-limit buckets of the
12
+ * built-in screens ({@link PersonalAgentRouteKit});
13
+ * - a shared grant ledger (`auth_agent_grants` / `auth_agent_refresh_tokens`) scoped to its grant-id
14
+ * prefix, so the account console ("Connected apps"), the account API, "sign out everywhere", account
15
+ * deletion and the admin console list and revoke its connections with no extra code
16
+ * ({@link PersonalAgentGrantLedger});
17
+ * - the admin console's allow/block registry (`auth_agent_registry`), keyed by its protocol id;
18
+ * - its own lib-owned tables, created with AuthKit's (`schema.autoManage`) — {@link AuthkitTable};
19
+ * - access tokens minted by the OIDC provider for MCP resources ({@link PersonalAgentAccessTokens});
20
+ * - message catalogs merged into AuthKit's i18n (host overrides in `i18n.messages` still win).
21
+ *
22
+ * What it gives back: a {@link PersonalAgentProtocolRuntime} — list, revoke and name its
23
+ * connections.
24
+ */
25
+ import type { HttpContext } from '@adonisjs/core/http';
26
+ /**
27
+ * A lib-owned table: created when missing, new columns added with `ALTER ADD`, never dropped or
28
+ * altered. The builders receive a Knex `TableBuilder`.
29
+ */
30
+ export interface AuthkitTable {
31
+ name: string;
32
+ /** Full builder — runs when the table does not exist. */
33
+ create: (table: any) => void;
34
+ /**
35
+ * One builder per column — runs (`ALTER ADD`) when the table exists but the column does not.
36
+ * No constraints that break on populated tables (unique/FK belong in `create`).
37
+ */
38
+ columns: Record<string, (table: any) => void>;
39
+ /** Indexes ensured by name, also on tables that already existed. `create` must declare them. */
40
+ indexes?: Array<{
41
+ name: string;
42
+ columns: string[];
43
+ }>;
44
+ }
45
+ /** A row of the shared grant ledger (`auth_agent_grants`). */
46
+ export interface PersonalAgentGrant {
47
+ /** Starts with the extension's `grantIdPrefix`. */
48
+ id: string;
49
+ accountId: string;
50
+ /** The agent's identifier in its protocol (a PACT `iss`, a Poppy `client_id`…). */
51
+ clientId: string;
52
+ /** The agent's own user id, when the protocol has one. `''` otherwise. */
53
+ agentSub: string;
54
+ /** Space-separated scopes. */
55
+ scope: string;
56
+ expiresAt: Date;
57
+ revokedAt: Date | null;
58
+ createdAt: Date;
59
+ updatedAt: Date;
60
+ }
61
+ /** A refresh token of the ledger — only its hash is stored. */
62
+ export interface PersonalAgentRefreshToken {
63
+ grantId: string;
64
+ expiresAt: Date;
65
+ usedAt: Date | null;
66
+ }
67
+ /**
68
+ * The shared grant ledger, scoped to one extension: every read and write only sees grants whose id
69
+ * starts with the extension's `grantIdPrefix`. Grants written here show up in the account and admin
70
+ * consoles and are revoked by "sign out everywhere", password reset and account deletion.
71
+ */
72
+ export interface PersonalAgentGrantLedger {
73
+ /** Throws when `grant.id` does not start with the extension's prefix. */
74
+ insertGrant(grant: Omit<PersonalAgentGrant, 'revokedAt'>): Promise<void>;
75
+ /** `null` when missing or not this extension's. */
76
+ findGrant(id: string): Promise<PersonalAgentGrant | null>;
77
+ /** Unrevoked grants of the account (expired ones included), newest first. */
78
+ listGrants(accountId: string): Promise<PersonalAgentGrant[]>;
79
+ /** Ids of the agent's unrevoked grants, across accounts. */
80
+ unrevokedGrantIdsOfClient(clientId: string): Promise<string[]>;
81
+ /** Revokes the grant (no-op when already revoked or not this extension's). */
82
+ revokeGrantById(id: string, at: Date): Promise<void>;
83
+ insertRefreshToken(token: {
84
+ tokenHash: string;
85
+ grantId: string;
86
+ expiresAt: Date;
87
+ createdAt: Date;
88
+ }): Promise<void>;
89
+ /** `null` when unknown. The caller checks the grant through {@link findGrant}. */
90
+ findRefreshToken(tokenHash: string): Promise<PersonalAgentRefreshToken | null>;
91
+ }
92
+ /**
93
+ * Access tokens of the OIDC provider for MCP resources — the same tokens AuthKit's MCP integration
94
+ * (`mcp` in `defineConfig`, or `Symbol.for('@adonis-agora/oauth:resources')`) already accepts.
95
+ */
96
+ export interface PersonalAgentAccessTokens {
97
+ /** `mcp` is enabled in `defineConfig`. */
98
+ readonly mcpEnabled: boolean;
99
+ /** `url` is a registered MCP resource of this app. */
100
+ isMcpResource(url: string): boolean;
101
+ /**
102
+ * Mints an access token bound to `resource`, under a provider grant with `grantId` (created when
103
+ * missing). `grantType` becomes the token's `gty`. `null` when the provider is not available.
104
+ */
105
+ mint(input: {
106
+ grantId: string;
107
+ accountId: string;
108
+ clientId: string;
109
+ scope: string;
110
+ resource: string;
111
+ /** Seconds. */
112
+ expiresIn: number;
113
+ /** When the extension's grant expires — the provider grant lives as long. */
114
+ grantExpiresAt: Date;
115
+ grantType: string;
116
+ }): Promise<string | null>;
117
+ /** Revokes the provider grant and its access tokens. */
118
+ revokeGrant(grantId: string): Promise<void>;
119
+ }
120
+ /** What the host hands to {@link PersonalAgentExtensionDefinition.setup}. */
121
+ export interface PersonalAgentHost {
122
+ /** The extension's protocol id. */
123
+ readonly protocol: string;
124
+ /** The OIDC issuer (`defineConfig({ issuer })`). Derive public URLs from its origin. */
125
+ readonly issuer: string;
126
+ /** The Lucid connection AuthKit's tables live on (`schema.connection`). */
127
+ db(): any;
128
+ readonly grants: PersonalAgentGrantLedger;
129
+ /** The admin console's verdict on an agent of this protocol. `null` = not listed. */
130
+ registryStatus(identifier: string): Promise<'allowed' | 'blocked' | null>;
131
+ /** A stable per-app secret for `label` (HMAC of the app key). Same on every instance. */
132
+ deriveSecret(label: string): Buffer;
133
+ /** The account exists and is not disabled. */
134
+ isAccountActive(accountId: string): Promise<boolean>;
135
+ /** Resolves a container binding (`'redis'`…). Throws outside an app. */
136
+ make(binding: string): Promise<any>;
137
+ readonly accessTokens: PersonalAgentAccessTokens;
138
+ /** The clock (tests inject one). */
139
+ now(): Date;
140
+ }
141
+ /** One connection of an account, as the account console and API show it. */
142
+ export interface PersonalAgentGrantSummary {
143
+ id: string;
144
+ clientId: string;
145
+ scopes: Array<{
146
+ id: string;
147
+ description: string;
148
+ }>;
149
+ createdAt: Date;
150
+ updatedAt: Date;
151
+ expiresAt: Date;
152
+ }
153
+ /** What the admin console shows about an extension. */
154
+ export interface PersonalAgentConsoleSummary {
155
+ /** Only listed agents may connect. */
156
+ requireRegistration: boolean;
157
+ /** The config's allow/block list is a function, which the console cannot list. */
158
+ hostResolver: boolean;
159
+ /** Agent identifiers may be `http://` URLs (development only). */
160
+ allowHttpIdentifiers: boolean;
161
+ /** Agents the config lists, by identifier. */
162
+ configured: {
163
+ allowed: readonly string[];
164
+ blocked: readonly string[];
165
+ };
166
+ /** Label of the identifier field (`'Client ID (metadata URL)'`). */
167
+ identifierLabel: string;
168
+ /** Example identifier for the field. */
169
+ identifierPlaceholder?: string;
170
+ }
171
+ /** The running protocol, built once per app by {@link PersonalAgentExtensionDefinition.setup}. */
172
+ export interface PersonalAgentProtocolRuntime {
173
+ /** Live connections of the account (account console and `GET /account/api/agents`). */
174
+ listAccountGrants(accountId: string): Promise<PersonalAgentGrantSummary[]>;
175
+ /** Revokes one connection OF THE ACCOUNT. `false` = not found, not the account's, or revoked. */
176
+ revokeAccountGrant(accountId: string, grantId: string): Promise<boolean>;
177
+ /** Revokes every connection of the account. Returns how many were live. */
178
+ revokeAllAccountGrants(accountId: string): Promise<number>;
179
+ /** Revokes a connection of any account (admin console). The host checked that it is live. */
180
+ revokeGrant(grantId: string): Promise<void>;
181
+ /** Disconnects an agent from every account (admin console block). Returns how many were live. */
182
+ disconnectAgent(identifier: string): Promise<number>;
183
+ /** The agent's display name. */
184
+ displayName(identifier: string): Promise<string>;
185
+ consoleSummary(): PersonalAgentConsoleSummary;
186
+ }
187
+ /** Route helpers for {@link PersonalAgentExtensionDefinition.routes}. */
188
+ export interface PersonalAgentRouteKit {
189
+ /**
190
+ * The account-session guard of the consent screens: a signed-out visitor goes to the login and
191
+ * comes back, idle sessions end, and a personal agent's own browser gets 403.
192
+ */
193
+ accountGuard: (ctx: HttpContext, next: () => Promise<void>) => Promise<unknown>;
194
+ /** Rate-limit buckets of the built-in screens (no-op when `rateLimit` is off). */
195
+ throttle: {
196
+ /** Per IP, the login bucket — pages that write something without authentication. */
197
+ login<R>(route: R): R;
198
+ /** Per IP, the one-time-code bucket — screens that take a typed code. */
199
+ otp<R>(route: R): R;
200
+ };
201
+ }
202
+ /** What {@link PersonalAgentExtension.resolve} receives. */
203
+ export interface PersonalAgentExtensionContext {
204
+ /** The OIDC issuer. */
205
+ issuer: string;
206
+ /** `personalAgents.delegation.scopes`, when PACT delegation is configured. */
207
+ delegationScopes: Readonly<Record<string, string>> | null;
208
+ }
209
+ /** A resolved extension. */
210
+ export interface PersonalAgentExtensionDefinition<R extends PersonalAgentProtocolRuntime = PersonalAgentProtocolRuntime> {
211
+ /** Name shown in the admin console (`'Poppy'`). */
212
+ label: string;
213
+ /**
214
+ * Prefix of the ids of the grants it writes to the ledger (`'pgrant_'`). Ends with `_`, unique
215
+ * among extensions, never `agrant_` (PACT).
216
+ */
217
+ grantIdPrefix: string;
218
+ /**
219
+ * Path prefix of its routes (`'/poppy'`). Must not sit under the OIDC `mountPath` nor under
220
+ * `personalAgents.prefix`.
221
+ */
222
+ prefix: string;
223
+ /** Exact paths `authkitCsrfExceptions` exempts (server-to-server or cross-site POSTs). */
224
+ csrfExemptPaths?: readonly string[];
225
+ /** Lib-owned tables, ensured with AuthKit's own. */
226
+ tables?: readonly AuthkitTable[];
227
+ /** `locale → key → text`, merged under AuthKit's catalogs (host overrides win). */
228
+ messages?: Readonly<Record<string, Readonly<Record<string, string>>>>;
229
+ /**
230
+ * The session belongs to a personal agent's browser: the account and admin consoles answer 403
231
+ * to it. Synchronous — reads the session only.
232
+ */
233
+ isAgentBrowser?(ctx: HttpContext): boolean;
234
+ /** Runs once when the provider boots, after the config resolved. */
235
+ boot?(): void | Promise<void>;
236
+ /** Registers its routes on the app router (from `registerAuthHost`). */
237
+ routes?(router: any, kit: PersonalAgentRouteKit): void;
238
+ /** Builds the runtime — once per app, on first use. */
239
+ setup(host: PersonalAgentHost): Promise<R>;
240
+ }
241
+ /**
242
+ * A personal-agent protocol packaged for `personalAgents.extensions`.
243
+ *
244
+ * ```ts
245
+ * // config/authkit.ts
246
+ * import { poppy } from '@adonis-agora/authkit-poppy'
247
+ * personalAgents: { extensions: [poppy({ organization: { name: 'Shop', domain: 'shop.example' } })] }
248
+ * ```
249
+ */
250
+ export interface PersonalAgentExtension<R extends PersonalAgentProtocolRuntime = PersonalAgentProtocolRuntime> {
251
+ /** Protocol id: 2–16 characters of `a-z`, `0-9`, `-`. Never `pact`. */
252
+ readonly id: string;
253
+ /** Validates the extension's own config and resolves it. Runs when `defineConfig` resolves. */
254
+ resolve(context: PersonalAgentExtensionContext): PersonalAgentExtensionDefinition<R>;
255
+ }
256
+ /** A resolved extension, with its id. */
257
+ export type ResolvedPersonalAgentExtension = PersonalAgentExtensionDefinition & {
258
+ readonly id: string;
259
+ };
260
+ /** Resolves and validates `personalAgents.extensions`. */
261
+ export declare function resolvePersonalAgentExtensions(input: readonly PersonalAgentExtension[] | undefined, context: PersonalAgentExtensionContext): ResolvedPersonalAgentExtension[];