@theokit/sdk 4.41.1 → 4.42.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{agent-JDJEBJHU.cjs → agent-HGDXQEQQ.cjs} +8 -7
  3. package/dist/{agent-JDJEBJHU.cjs.map → agent-HGDXQEQQ.cjs.map} +1 -1
  4. package/dist/{agent-LVKAYADR.js → agent-WUVYXIFX.js} +7 -6
  5. package/dist/{agent-LVKAYADR.js.map → agent-WUVYXIFX.js.map} +1 -1
  6. package/dist/chunk-22EMHGBO.cjs +351 -0
  7. package/dist/chunk-22EMHGBO.cjs.map +1 -0
  8. package/dist/{chunk-GTLH2NI2.cjs → chunk-EYEZDADP.cjs} +5 -5
  9. package/dist/{chunk-GTLH2NI2.cjs.map → chunk-EYEZDADP.cjs.map} +1 -1
  10. package/dist/{chunk-ZO2L5U6F.cjs → chunk-FAUKVJCC.cjs} +3 -3
  11. package/dist/{chunk-ZO2L5U6F.cjs.map → chunk-FAUKVJCC.cjs.map} +1 -1
  12. package/dist/{chunk-DHLVOLUX.js → chunk-KO5V6L3E.js} +10 -340
  13. package/dist/chunk-KO5V6L3E.js.map +1 -0
  14. package/dist/{chunk-AUMSEL33.js → chunk-MPD5EGJ6.js} +3 -3
  15. package/dist/{chunk-AUMSEL33.js.map → chunk-MPD5EGJ6.js.map} +1 -1
  16. package/dist/chunk-Q2PPSHBS.js +344 -0
  17. package/dist/chunk-Q2PPSHBS.js.map +1 -0
  18. package/dist/{chunk-FMIKUGF2.cjs → chunk-QFFNMJAS.cjs} +5 -5
  19. package/dist/{chunk-FMIKUGF2.cjs.map → chunk-QFFNMJAS.cjs.map} +1 -1
  20. package/dist/{chunk-UTYCG4RB.js → chunk-TDDRPFO3.js} +3 -3
  21. package/dist/{chunk-UTYCG4RB.js.map → chunk-TDDRPFO3.js.map} +1 -1
  22. package/dist/{chunk-IMX5YODO.js → chunk-UJ7HK7BX.js} +3 -3
  23. package/dist/{chunk-IMX5YODO.js.map → chunk-UJ7HK7BX.js.map} +1 -1
  24. package/dist/{chunk-RPL3POFZ.cjs → chunk-YHQ3DG24.cjs} +48 -378
  25. package/dist/chunk-YHQ3DG24.cjs.map +1 -0
  26. package/dist/{compact-session-65XCKO6H.js → compact-session-GF2CBKXB.js} +4 -4
  27. package/dist/{compact-session-65XCKO6H.js.map → compact-session-GF2CBKXB.js.map} +1 -1
  28. package/dist/{compact-session-OU6SRPVJ.cjs → compact-session-UUCBTBCZ.cjs} +12 -12
  29. package/dist/{compact-session-OU6SRPVJ.cjs.map → compact-session-UUCBTBCZ.cjs.map} +1 -1
  30. package/dist/context/index.cjs +35 -0
  31. package/dist/context/index.cjs.map +1 -0
  32. package/dist/context/index.d.cts +78 -0
  33. package/dist/context/index.d.ts +78 -0
  34. package/dist/context/index.js +18 -0
  35. package/dist/context/index.js.map +1 -0
  36. package/dist/cron.cjs +7 -6
  37. package/dist/cron.js +6 -5
  38. package/dist/eval.cjs +6 -5
  39. package/dist/eval.cjs.map +1 -1
  40. package/dist/eval.js +5 -4
  41. package/dist/eval.js.map +1 -1
  42. package/dist/index.cjs +34 -33
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.js +9 -8
  45. package/dist/index.js.map +1 -1
  46. package/dist/{inject-session-DDC36KKP.cjs → inject-session-I3HK3AHB.cjs} +4 -4
  47. package/dist/{inject-session-DDC36KKP.cjs.map → inject-session-I3HK3AHB.cjs.map} +1 -1
  48. package/dist/{inject-session-UBM4KVSV.js → inject-session-NR64GB3T.js} +3 -3
  49. package/dist/{inject-session-UBM4KVSV.js.map → inject-session-NR64GB3T.js.map} +1 -1
  50. package/dist/server/auth/index.d.cts +11 -207
  51. package/dist/server/auth/index.d.ts +11 -207
  52. package/dist/server/errors-envelope.d.cts +6 -12
  53. package/dist/server/errors-envelope.d.ts +6 -12
  54. package/package.json +11 -1
  55. package/dist/chunk-DHLVOLUX.js.map +0 -1
  56. package/dist/chunk-RPL3POFZ.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkZO2L5U6F_cjs = require('./chunk-ZO2L5U6F.cjs');
3
+ var chunkFAUKVJCC_cjs = require('./chunk-FAUKVJCC.cjs');
4
4
  var chunk4JBHSLQO_cjs = require('./chunk-4JBHSLQO.cjs');
5
5
  require('./chunk-FZ4YMZA3.cjs');
6
6
  var chunkWCXOKGOQ_cjs = require('./chunk-WCXOKGOQ.cjs');
@@ -9,7 +9,7 @@ require('./chunk-ZHPET3LZ.cjs');
9
9
 
10
10
  // src/internal/session/inject-session.ts
11
11
  async function injectSessionTurn(opts) {
12
- await chunkZO2L5U6F_cjs.enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
12
+ await chunkFAUKVJCC_cjs.enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
13
13
  const prior = await opts.store.readRecords(opts.loc.agentId);
14
14
  const transcript = chunkWCXOKGOQ_cjs.SessionTranscript.fromRecords(prior, {
15
15
  cwd: opts.loc.cwd,
@@ -24,5 +24,5 @@ async function injectSessionTurn(opts) {
24
24
  }
25
25
 
26
26
  exports.injectSessionTurn = injectSessionTurn;
27
- //# sourceMappingURL=inject-session-DDC36KKP.cjs.map
28
- //# sourceMappingURL=inject-session-DDC36KKP.cjs.map
27
+ //# sourceMappingURL=inject-session-I3HK3AHB.cjs.map
28
+ //# sourceMappingURL=inject-session-I3HK3AHB.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":["enqueueSessionWrite","SessionTranscript","invalidateSessionCache"],"mappings":";;;;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAMA,sCAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAaC,mCAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAAC,wCAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-DDC36KKP.cjs","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":["enqueueSessionWrite","SessionTranscript","invalidateSessionCache"],"mappings":";;;;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAMA,sCAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAaC,mCAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAAC,wCAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-I3HK3AHB.cjs","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { enqueueSessionWrite } from './chunk-IMX5YODO.js';
1
+ import { enqueueSessionWrite } from './chunk-UJ7HK7BX.js';
2
2
  import { invalidateSessionCache } from './chunk-4QEC4CCS.js';
3
3
  import './chunk-ZTEAJAE6.js';
4
4
  import { SessionTranscript } from './chunk-AF4BBKIF.js';
@@ -22,5 +22,5 @@ async function injectSessionTurn(opts) {
22
22
  }
23
23
 
24
24
  export { injectSessionTurn };
25
- //# sourceMappingURL=inject-session-UBM4KVSV.js.map
26
- //# sourceMappingURL=inject-session-UBM4KVSV.js.map
25
+ //# sourceMappingURL=inject-session-NR64GB3T.js.map
26
+ //# sourceMappingURL=inject-session-NR64GB3T.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAM,oBAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAA,sBAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-UBM4KVSV.js","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAM,oBAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAA,sBAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-NR64GB3T.js","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
@@ -1,211 +1,15 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
2
-
3
1
  /**
4
- * @theokit/sdk/server/auth — typed error classes
2
+ * @theokit/sdk/server/auth — public barrel
5
3
  *
6
- * Plan T1.2 + v1.1 EC-1 (AuthCancelledError for OAuth provider error response RFC 6749 §4.1.2.1).
7
- */
8
- /**
9
- * Thrown at `defineAuth()` time when configuration is invalid
10
- * (e.g., duplicate provider name, invalid email shape per EC-V1-12).
11
- */
12
- declare class AuthConfigError extends Error {
13
- readonly name = "AuthConfigError";
14
- readonly code: string;
15
- constructor(code: string, message: string);
16
- }
17
- /**
18
- * Thrown at `startSignIn(providerName, ...)` or `finishSignIn(providerName, ...)`
19
- * when the named provider is not registered in `providers[]`.
20
- */
21
- declare class AuthProviderNotFoundError extends Error {
22
- readonly name = "AuthProviderNotFoundError";
23
- readonly providerName: string;
24
- constructor(providerName: string);
25
- }
26
- /**
27
- * Thrown during OAuth callback handling for state mismatches, expired
28
- * transactions, missing query params, or provider 4xx/5xx errors.
29
- *
30
- * Typed `code` field lets consumers branch on cause:
31
- * - 'oauth_transaction_expired' — cookie tx > 10min old (per ADR D5)
32
- * - 'oauth_state_mismatch' — query state ≠ cookie state (CSRF defense per RFC 6749 §10.12)
33
- * - 'oauth_provider_error' — non-access_denied error in callback URL
34
- * - 'oauth_token_exchange_failed' — provider rejected code-for-tokens swap
35
- * - 'oauth_userinfo_failed' — userinfo endpoint returned error
36
- * - 'oauth_missing_code_or_state' — required query params absent
37
- */
38
- declare class AuthCallbackError extends Error {
39
- readonly name: string;
40
- readonly code: string;
41
- constructor(code: string, message?: string);
42
- }
43
- /**
44
- * Per v1.1 EC-1 MUST FIX — typed subclass of AuthCallbackError for the
45
- * specific case where user declined consent at provider screen.
46
- *
47
- * OAuth 2.0 RFC 6749 §4.1.2.1: provider redirects with `?error=access_denied`.
48
- * Apps can catch this distinctly from network/server errors to render
49
- * "Login cancelled — try again" UX instead of opaque "callback failed".
50
- */
51
- declare class AuthCancelledError extends AuthCallbackError {
52
- readonly name: string;
53
- readonly errorDescription?: string;
54
- constructor(errorDescription?: string);
55
- }
56
-
57
- /**
58
- * @theokit/sdk/server/auth — orchestrator types (Path C Hybrid per G11)
59
- *
60
- * Plan: g11-auth-architecture-implementation v1.4 (sha256 4d381020...)
61
- * Blueprint: g11-auth-architecture-decision v1.1 (SHIPPABLE 97.9)
62
- * AUTH-DELEGATION lock (theokit/CLAUDE.md:217-225) — these types are the
63
- * orchestrator contract; concrete OAuth/email providers ship in opt-in
64
- * @theokit/auth-* packages (adapters layer per ADR D11).
65
- */
66
-
67
- /**
68
- * SessionManager contract (matches theokit/packages/theo/src/server/auth/session.ts:49).
69
- * Imported as type-only — runtime depends via peerDep `theokit@>=0.2.4`.
70
- */
71
- interface SessionManager<TSession> {
72
- getSession(req: IncomingMessage): Promise<TSession | null>;
73
- createSession(res: ServerResponse, data: TSession): Promise<void>;
74
- destroySession(res: ServerResponse): void;
75
- rotateSession(req: IncomingMessage, res: ServerResponse): Promise<TSession | null>;
76
- }
77
- /**
78
- * Per ADR D5 — OAuth transaction state stored in encrypted HttpOnly cookie
79
- * (cookie-state pattern). Expires within 10 minutes per invariant.
80
- */
81
- interface OAuthTransaction {
82
- state: string;
83
- pkceVerifier?: string;
84
- returnTo?: string;
85
- createdAt: number;
86
- expiresAt: number;
87
- }
88
- /**
89
- * Per ADR D9 — provider profile types are provider-specific (not unified).
90
- * Each @theokit/auth-* package exports its own profile shape.
91
- * Generic param TProfile lets consumers narrow via discriminated unions on providerName.
92
- */
93
- interface AuthResult<TProfile, TName extends string = string> {
94
- profile: TProfile;
95
- providerName: TName;
96
- rawTokens?: {
97
- accessToken: string;
98
- refreshToken?: string;
99
- idToken?: string;
100
- expiresAt?: number;
101
- };
102
- }
103
- /**
104
- * Provider contract — each @theokit/auth-* package implements this.
105
- * Per blueprint Q5 + ADR D11 (adapters layer).
106
- */
107
- interface AuthProvider<TProfile, TName extends string = string> {
108
- name: TName;
109
- createAuthorizationURL(tx: OAuthTransaction): URL | Promise<URL>;
110
- handleCallback(req: IncomingMessage, tx: OAuthTransaction): Promise<AuthResult<TProfile, TName>>;
111
- }
112
- /**
113
- * `defineAuth(opts)` configuration shape — Path C (Hybrid).
114
- * `providers` optional: empty = Path A escape hatch (manual signIn only).
115
- * `onSignIn` invoked after provider callback success; returns TSession to persist.
116
- */
117
- interface DefineAuthOptions<TSession> {
118
- session: SessionManager<TSession>;
119
- providers?: AuthProvider<unknown, string>[];
120
- onSignIn?: <TProfile>(args: {
121
- profile: TProfile;
122
- provider: string;
123
- }) => Promise<TSession>;
124
- onSignOut?: (session: TSession | null) => Promise<void> | void;
125
- }
126
- /**
127
- * Returned by `defineAuth<TSession>(opts)` — 5-method orchestrator surface.
128
- *
129
- * - startSignIn: returns Response.redirect to provider authorization URL with state cookie
130
- * - finishSignIn: handles provider callback; verifies state; calls onSignIn; rotates session ID
131
- * (OWASP A07:2021 per EC-10); creates session cookie; clears transaction cookie
132
- * - signIn: Path A escape hatch — skip OAuth flow; directly persist session from external profile
133
- * - signOut: destroys session cookie + invokes onSignOut callback
134
- * - getSession: read-only passthrough to session.getSession
135
- */
136
- interface AuthOrchestrator<TSession> {
137
- startSignIn(providerName: string, req: IncomingMessage, opts?: {
138
- returnTo?: string;
139
- }): Promise<Response>;
140
- finishSignIn(providerName: string, req: IncomingMessage, res: ServerResponse): Promise<{
141
- session: TSession;
142
- returnTo?: string;
143
- }>;
144
- signIn<TProfile>(profile: TProfile, providerName: string, req: IncomingMessage, res: ServerResponse): Promise<TSession>;
145
- signOut(res: ServerResponse): void | Promise<void>;
146
- getSession(req: IncomingMessage): Promise<TSession | null>;
147
- }
148
-
149
- /**
150
- * @theokit/sdk/server/auth — encrypted OAuth transaction cookie store
151
- *
152
- * Per ADR D5 — cookie-state pattern (no Redis/db dependency in core).
153
- *
154
- * Stores OAuthTransaction (state + pkceVerifier + returnTo + expiry) in a
155
- * single signed+encrypted HttpOnly cookie. Stateless, works in edge/serverless.
156
- *
157
- * Cookie name: `__Host-theo_oauth_tx` (T5.3 — RFC 6265bis prefix)
158
- * Lifetime: 10 minutes (per D5 invariant)
159
- * Encryption: AES-256-GCM via Node's webcrypto subtle API
160
- *
161
- * Note: this is a minimal in-package implementation. Production deployments
162
- * may prefer using `theokit/server/auth/crypto`'s encrypt/decrypt helpers
163
- * via the SessionManager's existing secret rotation chain. For T1.2 we keep
164
- * it self-contained to avoid cross-package peer-dep complexity; T2+ may
165
- * refactor to share SessionManager's encrypt path.
166
- */
167
-
168
- /**
169
- * T5.1 — Typed error thrown when an OAuth tx-cookie secret has < 32
170
- * bytes of entropy. Surfaces the actual byte length so operators can
171
- * diagnose mis-configured env vars without leaking the secret itself.
172
- *
173
- * @public
174
- */
175
- declare class AuthSecretTooShortError extends Error {
176
- readonly name = "AuthSecretTooShortError";
177
- constructor(actualBytes: number);
178
- }
179
-
180
- /**
181
- * @theokit/sdk/server/auth — defineAuth orchestrator runtime (Path C Hybrid)
182
- *
183
- * Plan T1.2 implementation per blueprint Q5 § Path C signatures.
184
- * Composes existing primitives + the v1.1 EC-1/EC-2/EC-10 fixes.
185
- */
186
-
187
- /** SE36 — `Auth.create` replaces `defineAuth` (ADR 0015). @public */
188
- declare class Auth {
189
- private constructor();
190
- static create<TSession>(opts: DefineAuthOptions<TSession>): AuthOrchestrator<TSession>;
191
- }
192
-
193
- /**
194
- * @theokit/sdk/server/auth — same-origin returnTo validator
195
- *
196
- * Per v1.1 EC-2 MUST FIX — OWASP A01:2021 open-redirect mitigation.
197
- *
198
- * Without this check, attacker craft `/login?returnTo=https://evil.com` would
199
- * cause post-login redirect to attacker domain with authenticated session cookie.
4
+ * Per ADR D6 (sub-path export) consumers import via `@theokit/sdk/server/auth`
5
+ * NOT main `@theokit/sdk` barrel. Tree-shaking + allows breaking changes in
6
+ * auth surface without affecting Agent runtime consumers.
200
7
  *
201
- * Rules:
202
- * - undefined/empty returnTo default '/'
203
- * - protocol-relative `//evil.com` → default '/' (URL parser would resolve to baseUrl protocol)
204
- * - absolute URL with origin ≠ baseUrl.origin → default '/' (cross-origin redirect)
205
- * - absolute URL with origin === baseUrl.origin → keep (same-origin allowed)
206
- * - relative path starting with '/' → keep (same-app navigation)
207
- * - relative path not starting with '/' → default '/' (defensive)
8
+ * T1.1 shipped types-only.
9
+ * T1.2 adds runtime: defineAuth() + 4 typed error classes + validateReturnTo helper.
208
10
  */
209
- declare function validateReturnTo(returnTo: string | undefined, baseUrl: URL): string;
210
-
211
- export { Auth, AuthCallbackError, AuthCancelledError, AuthConfigError, type AuthOrchestrator, type AuthProvider, AuthProviderNotFoundError, type AuthResult, AuthSecretTooShortError, type DefineAuthOptions, type OAuthTransaction, type SessionManager, validateReturnTo };
11
+ export { AuthCallbackError, AuthCancelledError, AuthConfigError, AuthProviderNotFoundError, } from "./errors.js";
12
+ export { AuthSecretTooShortError } from "./oauth-transaction-store.js";
13
+ export { Auth } from "./orchestrator.js";
14
+ export type { AuthOrchestrator, AuthProvider, AuthResult, DefineAuthOptions, OAuthTransaction, SessionManager, } from "./types.js";
15
+ export { validateReturnTo } from "./validate-return-to.js";
@@ -1,211 +1,15 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
2
-
3
1
  /**
4
- * @theokit/sdk/server/auth — typed error classes
2
+ * @theokit/sdk/server/auth — public barrel
5
3
  *
6
- * Plan T1.2 + v1.1 EC-1 (AuthCancelledError for OAuth provider error response RFC 6749 §4.1.2.1).
7
- */
8
- /**
9
- * Thrown at `defineAuth()` time when configuration is invalid
10
- * (e.g., duplicate provider name, invalid email shape per EC-V1-12).
11
- */
12
- declare class AuthConfigError extends Error {
13
- readonly name = "AuthConfigError";
14
- readonly code: string;
15
- constructor(code: string, message: string);
16
- }
17
- /**
18
- * Thrown at `startSignIn(providerName, ...)` or `finishSignIn(providerName, ...)`
19
- * when the named provider is not registered in `providers[]`.
20
- */
21
- declare class AuthProviderNotFoundError extends Error {
22
- readonly name = "AuthProviderNotFoundError";
23
- readonly providerName: string;
24
- constructor(providerName: string);
25
- }
26
- /**
27
- * Thrown during OAuth callback handling for state mismatches, expired
28
- * transactions, missing query params, or provider 4xx/5xx errors.
29
- *
30
- * Typed `code` field lets consumers branch on cause:
31
- * - 'oauth_transaction_expired' — cookie tx > 10min old (per ADR D5)
32
- * - 'oauth_state_mismatch' — query state ≠ cookie state (CSRF defense per RFC 6749 §10.12)
33
- * - 'oauth_provider_error' — non-access_denied error in callback URL
34
- * - 'oauth_token_exchange_failed' — provider rejected code-for-tokens swap
35
- * - 'oauth_userinfo_failed' — userinfo endpoint returned error
36
- * - 'oauth_missing_code_or_state' — required query params absent
37
- */
38
- declare class AuthCallbackError extends Error {
39
- readonly name: string;
40
- readonly code: string;
41
- constructor(code: string, message?: string);
42
- }
43
- /**
44
- * Per v1.1 EC-1 MUST FIX — typed subclass of AuthCallbackError for the
45
- * specific case where user declined consent at provider screen.
46
- *
47
- * OAuth 2.0 RFC 6749 §4.1.2.1: provider redirects with `?error=access_denied`.
48
- * Apps can catch this distinctly from network/server errors to render
49
- * "Login cancelled — try again" UX instead of opaque "callback failed".
50
- */
51
- declare class AuthCancelledError extends AuthCallbackError {
52
- readonly name: string;
53
- readonly errorDescription?: string;
54
- constructor(errorDescription?: string);
55
- }
56
-
57
- /**
58
- * @theokit/sdk/server/auth — orchestrator types (Path C Hybrid per G11)
59
- *
60
- * Plan: g11-auth-architecture-implementation v1.4 (sha256 4d381020...)
61
- * Blueprint: g11-auth-architecture-decision v1.1 (SHIPPABLE 97.9)
62
- * AUTH-DELEGATION lock (theokit/CLAUDE.md:217-225) — these types are the
63
- * orchestrator contract; concrete OAuth/email providers ship in opt-in
64
- * @theokit/auth-* packages (adapters layer per ADR D11).
65
- */
66
-
67
- /**
68
- * SessionManager contract (matches theokit/packages/theo/src/server/auth/session.ts:49).
69
- * Imported as type-only — runtime depends via peerDep `theokit@>=0.2.4`.
70
- */
71
- interface SessionManager<TSession> {
72
- getSession(req: IncomingMessage): Promise<TSession | null>;
73
- createSession(res: ServerResponse, data: TSession): Promise<void>;
74
- destroySession(res: ServerResponse): void;
75
- rotateSession(req: IncomingMessage, res: ServerResponse): Promise<TSession | null>;
76
- }
77
- /**
78
- * Per ADR D5 — OAuth transaction state stored in encrypted HttpOnly cookie
79
- * (cookie-state pattern). Expires within 10 minutes per invariant.
80
- */
81
- interface OAuthTransaction {
82
- state: string;
83
- pkceVerifier?: string;
84
- returnTo?: string;
85
- createdAt: number;
86
- expiresAt: number;
87
- }
88
- /**
89
- * Per ADR D9 — provider profile types are provider-specific (not unified).
90
- * Each @theokit/auth-* package exports its own profile shape.
91
- * Generic param TProfile lets consumers narrow via discriminated unions on providerName.
92
- */
93
- interface AuthResult<TProfile, TName extends string = string> {
94
- profile: TProfile;
95
- providerName: TName;
96
- rawTokens?: {
97
- accessToken: string;
98
- refreshToken?: string;
99
- idToken?: string;
100
- expiresAt?: number;
101
- };
102
- }
103
- /**
104
- * Provider contract — each @theokit/auth-* package implements this.
105
- * Per blueprint Q5 + ADR D11 (adapters layer).
106
- */
107
- interface AuthProvider<TProfile, TName extends string = string> {
108
- name: TName;
109
- createAuthorizationURL(tx: OAuthTransaction): URL | Promise<URL>;
110
- handleCallback(req: IncomingMessage, tx: OAuthTransaction): Promise<AuthResult<TProfile, TName>>;
111
- }
112
- /**
113
- * `defineAuth(opts)` configuration shape — Path C (Hybrid).
114
- * `providers` optional: empty = Path A escape hatch (manual signIn only).
115
- * `onSignIn` invoked after provider callback success; returns TSession to persist.
116
- */
117
- interface DefineAuthOptions<TSession> {
118
- session: SessionManager<TSession>;
119
- providers?: AuthProvider<unknown, string>[];
120
- onSignIn?: <TProfile>(args: {
121
- profile: TProfile;
122
- provider: string;
123
- }) => Promise<TSession>;
124
- onSignOut?: (session: TSession | null) => Promise<void> | void;
125
- }
126
- /**
127
- * Returned by `defineAuth<TSession>(opts)` — 5-method orchestrator surface.
128
- *
129
- * - startSignIn: returns Response.redirect to provider authorization URL with state cookie
130
- * - finishSignIn: handles provider callback; verifies state; calls onSignIn; rotates session ID
131
- * (OWASP A07:2021 per EC-10); creates session cookie; clears transaction cookie
132
- * - signIn: Path A escape hatch — skip OAuth flow; directly persist session from external profile
133
- * - signOut: destroys session cookie + invokes onSignOut callback
134
- * - getSession: read-only passthrough to session.getSession
135
- */
136
- interface AuthOrchestrator<TSession> {
137
- startSignIn(providerName: string, req: IncomingMessage, opts?: {
138
- returnTo?: string;
139
- }): Promise<Response>;
140
- finishSignIn(providerName: string, req: IncomingMessage, res: ServerResponse): Promise<{
141
- session: TSession;
142
- returnTo?: string;
143
- }>;
144
- signIn<TProfile>(profile: TProfile, providerName: string, req: IncomingMessage, res: ServerResponse): Promise<TSession>;
145
- signOut(res: ServerResponse): void | Promise<void>;
146
- getSession(req: IncomingMessage): Promise<TSession | null>;
147
- }
148
-
149
- /**
150
- * @theokit/sdk/server/auth — encrypted OAuth transaction cookie store
151
- *
152
- * Per ADR D5 — cookie-state pattern (no Redis/db dependency in core).
153
- *
154
- * Stores OAuthTransaction (state + pkceVerifier + returnTo + expiry) in a
155
- * single signed+encrypted HttpOnly cookie. Stateless, works in edge/serverless.
156
- *
157
- * Cookie name: `__Host-theo_oauth_tx` (T5.3 — RFC 6265bis prefix)
158
- * Lifetime: 10 minutes (per D5 invariant)
159
- * Encryption: AES-256-GCM via Node's webcrypto subtle API
160
- *
161
- * Note: this is a minimal in-package implementation. Production deployments
162
- * may prefer using `theokit/server/auth/crypto`'s encrypt/decrypt helpers
163
- * via the SessionManager's existing secret rotation chain. For T1.2 we keep
164
- * it self-contained to avoid cross-package peer-dep complexity; T2+ may
165
- * refactor to share SessionManager's encrypt path.
166
- */
167
-
168
- /**
169
- * T5.1 — Typed error thrown when an OAuth tx-cookie secret has < 32
170
- * bytes of entropy. Surfaces the actual byte length so operators can
171
- * diagnose mis-configured env vars without leaking the secret itself.
172
- *
173
- * @public
174
- */
175
- declare class AuthSecretTooShortError extends Error {
176
- readonly name = "AuthSecretTooShortError";
177
- constructor(actualBytes: number);
178
- }
179
-
180
- /**
181
- * @theokit/sdk/server/auth — defineAuth orchestrator runtime (Path C Hybrid)
182
- *
183
- * Plan T1.2 implementation per blueprint Q5 § Path C signatures.
184
- * Composes existing primitives + the v1.1 EC-1/EC-2/EC-10 fixes.
185
- */
186
-
187
- /** SE36 — `Auth.create` replaces `defineAuth` (ADR 0015). @public */
188
- declare class Auth {
189
- private constructor();
190
- static create<TSession>(opts: DefineAuthOptions<TSession>): AuthOrchestrator<TSession>;
191
- }
192
-
193
- /**
194
- * @theokit/sdk/server/auth — same-origin returnTo validator
195
- *
196
- * Per v1.1 EC-2 MUST FIX — OWASP A01:2021 open-redirect mitigation.
197
- *
198
- * Without this check, attacker craft `/login?returnTo=https://evil.com` would
199
- * cause post-login redirect to attacker domain with authenticated session cookie.
4
+ * Per ADR D6 (sub-path export) consumers import via `@theokit/sdk/server/auth`
5
+ * NOT main `@theokit/sdk` barrel. Tree-shaking + allows breaking changes in
6
+ * auth surface without affecting Agent runtime consumers.
200
7
  *
201
- * Rules:
202
- * - undefined/empty returnTo default '/'
203
- * - protocol-relative `//evil.com` → default '/' (URL parser would resolve to baseUrl protocol)
204
- * - absolute URL with origin ≠ baseUrl.origin → default '/' (cross-origin redirect)
205
- * - absolute URL with origin === baseUrl.origin → keep (same-origin allowed)
206
- * - relative path starting with '/' → keep (same-app navigation)
207
- * - relative path not starting with '/' → default '/' (defensive)
8
+ * T1.1 shipped types-only.
9
+ * T1.2 adds runtime: defineAuth() + 4 typed error classes + validateReturnTo helper.
208
10
  */
209
- declare function validateReturnTo(returnTo: string | undefined, baseUrl: URL): string;
210
-
211
- export { Auth, AuthCallbackError, AuthCancelledError, AuthConfigError, type AuthOrchestrator, type AuthProvider, AuthProviderNotFoundError, type AuthResult, AuthSecretTooShortError, type DefineAuthOptions, type OAuthTransaction, type SessionManager, validateReturnTo };
11
+ export { AuthCallbackError, AuthCancelledError, AuthConfigError, AuthProviderNotFoundError, } from "./errors.js";
12
+ export { AuthSecretTooShortError } from "./oauth-transaction-store.js";
13
+ export { Auth } from "./orchestrator.js";
14
+ export type { AuthOrchestrator, AuthProvider, AuthResult, DefineAuthOptions, OAuthTransaction, SessionManager, } from "./types.js";
15
+ export { validateReturnTo } from "./validate-return-to.js";
@@ -1,8 +1,3 @@
1
- import { T as TheokitAgentError } from '../errors-BSoXcl3F.cjs';
2
- export { M as MemoryAdapterError } from '../errors-BSoXcl3F.cjs';
3
- import '../run-C8FBAC8o.cjs';
4
- import 'zod';
5
-
6
1
  /**
7
2
  * @theokit/sdk/server/errors-envelope — G5 T2.2 boundary translation.
8
3
  *
@@ -17,7 +12,7 @@ import 'zod';
17
12
  * dependency on `theokit`. Consumer code that uses both packages gets the
18
13
  * same shape via duck-typing.
19
14
  */
20
-
15
+ import { MemoryAdapterError, TheokitAgentError } from "../errors.js";
21
16
  /**
22
17
  * Canonical envelope code union for cross-layer SDK boundary. Subset of the
23
18
  * full `TheoErrorCode` (theokit/server) covering codes the SDK actually emits.
@@ -26,13 +21,13 @@ import 'zod';
26
21
  *
27
22
  * @public
28
23
  */
29
- type TheokitErrorCode = "UNAUTHORIZED" | "RATE_LIMITED" | "INTERNAL_SERVER_ERROR" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "AGENT_RUN_ERROR" | "PROVIDER_KEY_MISSING" | "BUDGET_EXCEEDED" | "CREDENTIAL_POOL_EXHAUSTED";
24
+ export type TheokitErrorCode = "UNAUTHORIZED" | "RATE_LIMITED" | "INTERNAL_SERVER_ERROR" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "AGENT_RUN_ERROR" | "PROVIDER_KEY_MISSING" | "BUDGET_EXCEEDED" | "CREDENTIAL_POOL_EXHAUSTED";
30
25
  /**
31
26
  * Envelope shape — structurally identical to theokit/server `TheoErrorEnvelope`.
32
27
  *
33
28
  * @public
34
29
  */
35
- interface TheokitErrorEnvelope<TExt = unknown> {
30
+ export interface TheokitErrorEnvelope<TExt = unknown> {
36
31
  readonly code: TheokitErrorCode;
37
32
  readonly message: string;
38
33
  readonly cause?: unknown;
@@ -54,7 +49,7 @@ interface TheokitErrorEnvelope<TExt = unknown> {
54
49
  *
55
50
  * @public
56
51
  */
57
- declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
52
+ export declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
58
53
  /**
59
54
  * Hydrate an envelope back into the SDK class hierarchy. Use at the inbound
60
55
  * boundary (e.g., on a worker process receiving an envelope from the main
@@ -62,6 +57,5 @@ declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
62
57
  *
63
58
  * @public
64
59
  */
65
- declare function fromEnvelope(env: TheokitErrorEnvelope): TheokitAgentError;
66
-
67
- export { type TheokitErrorCode, type TheokitErrorEnvelope, fromEnvelope, toEnvelope };
60
+ export declare function fromEnvelope(env: TheokitErrorEnvelope): TheokitAgentError;
61
+ export { MemoryAdapterError };
@@ -1,8 +1,3 @@
1
- import { T as TheokitAgentError } from '../errors-CHllybaU.js';
2
- export { M as MemoryAdapterError } from '../errors-CHllybaU.js';
3
- import '../run-C8FBAC8o.js';
4
- import 'zod';
5
-
6
1
  /**
7
2
  * @theokit/sdk/server/errors-envelope — G5 T2.2 boundary translation.
8
3
  *
@@ -17,7 +12,7 @@ import 'zod';
17
12
  * dependency on `theokit`. Consumer code that uses both packages gets the
18
13
  * same shape via duck-typing.
19
14
  */
20
-
15
+ import { MemoryAdapterError, TheokitAgentError } from "../errors.js";
21
16
  /**
22
17
  * Canonical envelope code union for cross-layer SDK boundary. Subset of the
23
18
  * full `TheoErrorCode` (theokit/server) covering codes the SDK actually emits.
@@ -26,13 +21,13 @@ import 'zod';
26
21
  *
27
22
  * @public
28
23
  */
29
- type TheokitErrorCode = "UNAUTHORIZED" | "RATE_LIMITED" | "INTERNAL_SERVER_ERROR" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "AGENT_RUN_ERROR" | "PROVIDER_KEY_MISSING" | "BUDGET_EXCEEDED" | "CREDENTIAL_POOL_EXHAUSTED";
24
+ export type TheokitErrorCode = "UNAUTHORIZED" | "RATE_LIMITED" | "INTERNAL_SERVER_ERROR" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "AGENT_RUN_ERROR" | "PROVIDER_KEY_MISSING" | "BUDGET_EXCEEDED" | "CREDENTIAL_POOL_EXHAUSTED";
30
25
  /**
31
26
  * Envelope shape — structurally identical to theokit/server `TheoErrorEnvelope`.
32
27
  *
33
28
  * @public
34
29
  */
35
- interface TheokitErrorEnvelope<TExt = unknown> {
30
+ export interface TheokitErrorEnvelope<TExt = unknown> {
36
31
  readonly code: TheokitErrorCode;
37
32
  readonly message: string;
38
33
  readonly cause?: unknown;
@@ -54,7 +49,7 @@ interface TheokitErrorEnvelope<TExt = unknown> {
54
49
  *
55
50
  * @public
56
51
  */
57
- declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
52
+ export declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
58
53
  /**
59
54
  * Hydrate an envelope back into the SDK class hierarchy. Use at the inbound
60
55
  * boundary (e.g., on a worker process receiving an envelope from the main
@@ -62,6 +57,5 @@ declare function toEnvelope(value: unknown): TheokitErrorEnvelope;
62
57
  *
63
58
  * @public
64
59
  */
65
- declare function fromEnvelope(env: TheokitErrorEnvelope): TheokitAgentError;
66
-
67
- export { type TheokitErrorCode, type TheokitErrorEnvelope, fromEnvelope, toEnvelope };
60
+ export declare function fromEnvelope(env: TheokitErrorEnvelope): TheokitAgentError;
61
+ export { MemoryAdapterError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk",
3
- "version": "4.41.1",
3
+ "version": "4.42.0",
4
4
  "description": "TypeScript SDK for the Theo agent harness — same surface, local or cloud.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/usetheodev/theokit-sdk#readme",
@@ -58,6 +58,16 @@
58
58
  "default": "./dist/compaction.cjs"
59
59
  }
60
60
  },
61
+ "./context": {
62
+ "import": {
63
+ "types": "./dist/context/index.d.ts",
64
+ "default": "./dist/context/index.js"
65
+ },
66
+ "require": {
67
+ "types": "./dist/context/index.d.cts",
68
+ "default": "./dist/context/index.cjs"
69
+ }
70
+ },
61
71
  "./messages": {
62
72
  "import": {
63
73
  "types": "./dist/messages.d.ts",