@theokit/agents 7.4.2 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 usetheo.dev
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/auth.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { OAuthProviderConfig, CredentialStoreConfig, ResolvedCredential, ensureFreshCredential, OpenAIDeviceConfig, openaiDeviceLogin, OAuthTokens, DeviceDeps } from '@theokit/sdk/auth';
2
- export { CredentialError, CredentialStoreConfig, DeviceCodeGrant, DeviceDeps, DeviceOAuthConfig, OAuthProviderConfig, OAuthTokens, OpenAIDeviceConfig, ResolveCredentialOptions, ResolvedCredential, authFilePath, credentialHome, deviceLogin, ensureFreshCredential, extractAccountId, openaiDeviceLogin, persistOAuthTokens, pollDeviceToken, readAuthFile, readStoredOAuth, refreshOAuthTokens, requestDeviceCode, writeCredential } from '@theokit/sdk/auth';
2
+ export { CredentialError, CredentialStoreConfig, DeviceCodeGrant, DeviceDeps, DeviceOAuthConfig, OAuthProviderConfig, OAuthTokens, OpenAIDeviceConfig, ResolveCredentialOptions, ResolvedCredential, assertSecureModes, authFilePath, credentialHome, deviceLogin, ensureFreshCredential, extractAccountId, openaiDeviceLogin, persistOAuthTokens, pollDeviceToken, readAuthFile, readStoredOAuth, refreshOAuthTokens, requestDeviceCode, writeCredential } from '@theokit/sdk/auth';
3
3
 
4
4
  /**
5
5
  * M60 — `AuthProvider`, the OO contract that unifies the SDK's free OAuth-lifecycle functions
package/dist/auth.js CHANGED
@@ -1,19 +1,19 @@
1
- // src/auth/auth-provider.ts
2
1
  import {
3
- authFilePath,
4
- ensureFreshCredential,
5
- openaiDeviceLogin,
6
- persistOAuthTokens,
7
- readStoredOAuth
8
- } from "@theokit/sdk/auth";
2
+ __name
3
+ } from "./chunk-Z4QWC7IK.js";
4
+
5
+ // src/auth/auth-provider.ts
6
+ import { authFilePath, ensureFreshCredential, openaiDeviceLogin, persistOAuthTokens, readStoredOAuth } from "@theokit/sdk/auth";
9
7
  import { withFileLock } from "@theokit/sdk/persistence";
10
8
  var RefreshFailure = class extends Error {
9
+ static {
10
+ __name(this, "RefreshFailure");
11
+ }
12
+ transient;
11
13
  constructor(message, transient) {
12
- super(message);
13
- this.transient = transient;
14
+ super(message), this.transient = transient;
14
15
  this.name = "RefreshFailure";
15
16
  }
16
- transient;
17
17
  };
18
18
  var TRANSIENT_REASONS = [
19
19
  "ETIMEDOUT",
@@ -26,36 +26,39 @@ var TRANSIENT_REASONS = [
26
26
  function classifyRefreshFailure(err) {
27
27
  const text = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
28
28
  if (/invalid_grant|invalid_request|unauthorized_client/i.test(text)) {
29
- return new RefreshFailure(
30
- "the refresh token is no longer valid \u2014 log in again. Retrying does not change the outcome.",
31
- false
32
- );
29
+ return new RefreshFailure("the refresh token is no longer valid \u2014 log in again. Retrying does not change the outcome.", false);
33
30
  }
34
31
  const transient = TRANSIENT_REASONS.some((m) => text.includes(m)) || /\b(5\d{2})\b|timeout|network/i.test(text);
35
- return new RefreshFailure(
36
- transient ? "transient failure refreshing the credential" : "failure refreshing the credential",
37
- transient
38
- );
32
+ return new RefreshFailure(transient ? "transient failure refreshing the credential" : "failure refreshing the credential", transient);
39
33
  }
34
+ __name(classifyRefreshFailure, "classifyRefreshFailure");
40
35
  function waitWithJitter(attempt, baseMs = 200, random = Math.random) {
41
36
  const base = baseMs * 2 ** attempt;
42
37
  return Math.round(base * (0.75 + random() * 0.5));
43
38
  }
39
+ __name(waitWithJitter, "waitWithJitter");
44
40
  var AuthProvider = class _AuthProvider {
41
+ static {
42
+ __name(this, "AuthProvider");
43
+ }
44
+ config;
45
+ store;
45
46
  constructor(config, store) {
46
47
  this.config = config;
47
48
  this.store = store;
48
49
  }
49
- config;
50
- store;
51
50
  /**
52
- * Refresh a resolved credential if stale. Delegates to `ensureFreshCredential` with the held
53
- * `config` + `store`; `env` (for reading the store's env overrides) + the `{ fetch, now }` HTTP deps
54
- * thread through. Returns the fresh `ResolvedCredential` — never logs the rotated token.
55
- */
51
+ * Refresh a resolved credential if stale. Delegates to `ensureFreshCredential` with the held
52
+ * `config` + `store`; `env` (for reading the store's env overrides) + the `{ fetch, now }` HTTP deps
53
+ * thread through. Returns the fresh `ResolvedCredential` — never logs the rotated token.
54
+ */
56
55
  async ensureFresh(resolved, deps, env) {
57
56
  if (resolved.kind !== "oauth") {
58
- return ensureFreshCredential(resolved, { config: this.config, store: this.store, env }, deps);
57
+ return ensureFreshCredential(resolved, {
58
+ config: this.config,
59
+ store: this.store,
60
+ env
61
+ }, deps);
59
62
  }
60
63
  const filePath = authFilePath(this.store, env);
61
64
  const inFlight = _AuthProvider.refreshInFlight.get(filePath);
@@ -71,25 +74,29 @@ var AuthProvider = class _AuthProvider {
71
74
  /** In-flight refresh per store path — the key is the file, not the instance. */
72
75
  static refreshInFlight = /* @__PURE__ */ new Map();
73
76
  /**
74
- * The refresh itself, serialized across PROCESSES and with a re-read.
75
- *
76
- * The re-read is not a detail: without it the lock merely serializes, and the second process
77
- * decides using the state it read BEFORE waiting — refreshing again and invalidating the token the
78
- * first one just wrote. It is classic double-checked locking, and it is what the two-process test
79
- * catches.
80
- */
77
+ * The refresh itself, serialized across PROCESSES and with a re-read.
78
+ *
79
+ * The re-read is not a detail: without it the lock merely serializes, and the second process
80
+ * decides using the state it read BEFORE waiting — refreshing again and invalidating the token the
81
+ * first one just wrote. It is classic double-checked locking, and it is what the two-process test
82
+ * catches.
83
+ */
81
84
  refreshUnderLock(filePath, resolved, deps, env) {
82
85
  return withFileLock(filePath, async () => {
83
86
  const doDisco = readStoredOAuth(this.store, env);
84
- const current = doDisco !== void 0 ? { ...resolved, apiKey: doDisco.access, expiresAt: doDisco.expires } : resolved;
87
+ const current = doDisco !== void 0 ? {
88
+ ...resolved,
89
+ apiKey: doDisco.access,
90
+ expiresAt: doDisco.expires
91
+ } : resolved;
85
92
  const MAX_ATTEMPTS = 3;
86
93
  for (let attempt = 0; ; attempt++) {
87
94
  try {
88
- return await ensureFreshCredential(
89
- current,
90
- { config: this.config, store: this.store, env },
91
- deps
92
- );
95
+ return await ensureFreshCredential(current, {
96
+ config: this.config,
97
+ store: this.store,
98
+ env
99
+ }, deps);
93
100
  } catch (err) {
94
101
  const failure = classifyRefreshFailure(err);
95
102
  if (!failure.transient || attempt >= MAX_ATTEMPTS - 1) throw failure;
@@ -99,43 +106,26 @@ var AuthProvider = class _AuthProvider {
99
106
  });
100
107
  }
101
108
  /**
102
- * Run the headless OpenAI device-login flow. Delegates to `openaiDeviceLogin` (which JWT-extracts the
103
- * account id). `deviceConfig` is passed per-call because it is a distinct endpoint set from the
104
- * refresh `config`. Returns `OAuthTokens` — the caller persists them via {@link AuthProvider.persist}.
105
- */
109
+ * Run the headless OpenAI device-login flow. Delegates to `openaiDeviceLogin` (which JWT-extracts the
110
+ * account id). `deviceConfig` is passed per-call because it is a distinct endpoint set from the
111
+ * refresh `config`. Returns `OAuthTokens` — the caller persists them via {@link AuthProvider.persist}.
112
+ */
106
113
  deviceLogin(deviceConfig, deps, hooks) {
107
114
  return openaiDeviceLogin(deviceConfig, deps, hooks);
108
115
  }
109
116
  /**
110
- * Persist freshly-obtained tokens through the held `store`. Delegates to `persistOAuthTokens` and
111
- * returns the credential-file path (never the token). `env` selects the store's home override.
112
- */
117
+ * Persist freshly-obtained tokens through the held `store`. Delegates to `persistOAuthTokens` and
118
+ * returns the credential-file path (never the token). `env` selects the store's home override.
119
+ */
113
120
  persist(provider, tokens, env) {
114
121
  return persistOAuthTokens(provider, tokens, this.store, env);
115
122
  }
116
123
  };
117
124
 
118
125
  // src/auth-entry.ts
119
- import {
120
- authFilePath as authFilePath2,
121
- CredentialError,
122
- credentialHome,
123
- readAuthFile,
124
- readStoredOAuth as readStoredOAuth2,
125
- writeCredential
126
- } from "@theokit/sdk/auth";
127
- import {
128
- deviceLogin,
129
- openaiDeviceLogin as openaiDeviceLogin3,
130
- pollDeviceToken,
131
- requestDeviceCode
132
- } from "@theokit/sdk/auth";
133
- import {
134
- ensureFreshCredential as ensureFreshCredential2,
135
- extractAccountId,
136
- persistOAuthTokens as persistOAuthTokens2,
137
- refreshOAuthTokens
138
- } from "@theokit/sdk/auth";
126
+ import { assertSecureModes, authFilePath as authFilePath2, CredentialError, credentialHome, readAuthFile, readStoredOAuth as readStoredOAuth2, writeCredential } from "@theokit/sdk/auth";
127
+ import { deviceLogin, openaiDeviceLogin as openaiDeviceLogin3, pollDeviceToken, requestDeviceCode } from "@theokit/sdk/auth";
128
+ import { ensureFreshCredential as ensureFreshCredential2, extractAccountId, persistOAuthTokens as persistOAuthTokens2, refreshOAuthTokens } from "@theokit/sdk/auth";
139
129
 
140
130
  // src/auth/device-provider.ts
141
131
  import { openaiDeviceLogin as openaiDeviceLogin2 } from "@theokit/sdk/auth";
@@ -147,7 +137,12 @@ var CODEX_OAUTH = {
147
137
  clientId: process.env[CODEX_CLIENT_ID_ENV_VAR] ?? CODEX_CLIENT_ID,
148
138
  authorizeEndpoint: `${CODEX_ISSUER}/oauth/authorize`,
149
139
  tokenEndpoint: `${CODEX_ISSUER}/oauth/token`,
150
- scopes: ["openid", "profile", "email", "offline_access"],
140
+ scopes: [
141
+ "openid",
142
+ "profile",
143
+ "email",
144
+ "offline_access"
145
+ ],
151
146
  redirectUri: `${CODEX_ISSUER}/deviceauth/callback`
152
147
  };
153
148
  var CODEX_DEVICE = {
@@ -165,7 +160,7 @@ var CODEX_PROVIDER = Object.freeze({
165
160
  type: "oauth",
166
161
  // Points at OpenAI's variant. An RFC 8628 provider would point at `deviceLogin`, and that is
167
162
  // how the two shapes coexist with no discriminant.
168
- authorize: (deps, hooks) => openaiDeviceLogin2(CODEX_DEVICE, deps, hooks)
163
+ authorize: /* @__PURE__ */ __name((deps, hooks) => openaiDeviceLogin2(CODEX_DEVICE, deps, hooks), "authorize")
169
164
  }),
170
165
  Object.freeze({
171
166
  label: "Manually enter API Key",
@@ -180,29 +175,33 @@ function comDefaults(deps) {
180
175
  now: deps?.now ?? Date.now
181
176
  };
182
177
  }
178
+ __name(comDefaults, "comDefaults");
183
179
  async function loginWithDevice(provider, method, store, hooks, opts = {}) {
184
180
  if (provider.methods.length === 0) {
185
- throw new TypeError(
186
- `provider "${provider.name}" declares no authentication method \u2014 there is nothing to choose`
187
- );
181
+ throw new TypeError(`provider "${provider.name}" declares no authentication method \u2014 there is nothing to choose`);
188
182
  }
189
183
  if (!provider.methods.includes(method)) {
190
184
  throw new TypeError(`method "${method.label}" does not belong to provider "${provider.name}"`);
191
185
  }
192
186
  if (method.type !== "oauth") {
193
- throw new TypeError(
194
- `method "${method.label}" is an api-key method, not a device method \u2014 use the api-key path`
195
- );
187
+ throw new TypeError(`method "${method.label}" is an api-key method, not a device method \u2014 use the api-key path`);
196
188
  }
197
189
  const tokens = await method.authorize(comDefaults(opts.deps), hooks);
198
190
  const path = new AuthProvider(provider.oauth, store).persist(provider.name, tokens, opts.env);
199
- return tokens.accountId === void 0 ? { path } : { path, accountId: tokens.accountId };
191
+ return tokens.accountId === void 0 ? {
192
+ path
193
+ } : {
194
+ path,
195
+ accountId: tokens.accountId
196
+ };
200
197
  }
198
+ __name(loginWithDevice, "loginWithDevice");
201
199
  export {
202
200
  AuthProvider,
203
201
  CODEX_CLIENT_ID_ENV_VAR,
204
202
  CODEX_PROVIDER,
205
203
  CredentialError,
204
+ assertSecureModes,
206
205
  authFilePath2 as authFilePath,
207
206
  credentialHome,
208
207
  deviceLogin,
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,oBAAoB;AAkCtB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACE,SAES,WACT;AACA,U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AAG;AACjC,UAAM,IAAI;AAAA,MACR,aAAa,SAAS,IAAI;AAAA,IAC5B;AAAA,EACF;AACA,MAAI,CAAC,SAAS,QAAQ,SAAS,MAAM,GAAG;AACtC,UAAM,IAAI,UAAU,WAAW,OAAO,KAAK,kCAAkC,SAAS,IAAI,GAAG;AAAA,EAC/F;AACA,MAAI,OAAO,SAAS,SAAS;AAC3B,UAAM,IAAI;AAAA,MACR,WAAW,OAAO,KAAK;AAAA,IACzB;AAAA,EACF;AAEA,QAAM,SAAS,MAAM,OAAO,UAAU,YAAY,KAAK,IAAI,GAAG,KAAK;AACnE,QAAM,OAAO,IAAI,aAAa,SAAS,OAAO,KAAK,EAAE,QAAQ,SAAS,MAAM,QAAQ,KAAK,GAAG;AAE5F,SAAO,OAAO,cAAc,SAAY,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,OAAO,UAAU;AACzF;","names":["authFilePath","readStoredOAuth","openaiDeviceLogin","ensureFreshCredential","persistOAuthTokens","openaiDeviceLogin","openaiDeviceLogin"]}
1
+ {"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts"],"mappings":";;;;;AAAA,SACEA,cACAC,uBACAC,mBACAC,oBACAC,uBACK;AAQP,SAASC,oBAAoB;AAkCtB,IAAMC,iBAAN,cAA6BC,MAAAA;EAhDpC,OAgDoCA;;;;EAClC,YACEC,SAESC,WACT;AACA,UAAMD,OAAAA,GAAAA,KAFGC,YAAAA;AAGT,SAAKC,OAAO;EACd;AACF;AAMA,IAAMC,oBAAoB;EACxB;EACA;EACA;EACA;EACA;EACA;;AAIK,SAASC,uBAAuBC,KAAY;AACjD,QAAMC,OAAOD,eAAeN,QAAQ,GAAGM,IAAIH,IAAI,KAAKG,IAAIL,OAAO,KAAKO,OAAOF,GAAAA;AAC3E,MAAI,qDAAqDG,KAAKF,IAAAA,GAAO;AACnE,WAAO,IAAIR,eACT,mGACA,KAAA;EAEJ;AACA,QAAMG,YACJE,kBAAkBM,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WAAWJ,OAAOI;EAAU;AACzF;AA5BsBX;","names":["authFilePath","ensureFreshCredential","openaiDeviceLogin","persistOAuthTokens","readStoredOAuth","withFileLock","RefreshFailure","Error","message","transient","name","TRANSIENT_REASONS","classifyRefreshFailure","err","text","String","test","some","m","includes","waitWithJitter","attempt","baseMs","random","Math","base","round","AuthProvider","config","store","ensureFresh","resolved","deps","env","kind","ensureFreshCredential","filePath","authFilePath","inFlight","refreshInFlight","get","undefined","promise","refreshUnderLock","set","delete","Map","withFileLock","doDisco","readStoredOAuth","current","apiKey","access","expiresAt","expires","MAX_ATTEMPTS","failure","Promise","resolve","setTimeout","deviceLogin","deviceConfig","hooks","openaiDeviceLogin","persist","provider","tokens","persistOAuthTokens","assertSecureModes","authFilePath","CredentialError","credentialHome","readAuthFile","readStoredOAuth","writeCredential","deviceLogin","openaiDeviceLogin","pollDeviceToken","requestDeviceCode","ensureFreshCredential","extractAccountId","persistOAuthTokens","refreshOAuthTokens","openaiDeviceLogin","CODEX_CLIENT_ID","CODEX_ISSUER","CODEX_CLIENT_ID_ENV_VAR","CODEX_OAUTH","provider","clientId","process","env","authorizeEndpoint","tokenEndpoint","scopes","redirectUri","CODEX_DEVICE","deviceUsercodeEndpoint","devicePollEndpoint","verificationUri","CODEX_PROVIDER","Object","freeze","name","oauth","methods","label","type","authorize","deps","hooks","openaiDeviceLogin","comDefaults","fetch","sleep","ms","Promise","resolve","setTimeout","now","Date","loginWithDevice","method","store","opts","length","TypeError","includes","tokens","path","AuthProvider","persist","accountId","undefined"]}
@@ -1,5 +1,5 @@
1
1
  import { ExecutionContext } from '@theokit/http';
2
- import { McpServerConfig, SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings, PreToolCallContext, PreToolCallDecision, PostToolCallContext, ToolResultTransformContext, TransformContext, SessionLifecycleContext, PreUserSendContext, PreUserSendResult, PostAssistantReplyContext, CustomTool, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, RunEventSink } from '@theokit/sdk';
2
+ import { McpServerConfig, SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings, PreToolCallContext, PreToolCallDecision, PostToolCallContext, ToolResultTransformContext, TransformContext, SessionLifecycleContext, PreUserSendContext, PreUserSendResult, PostAssistantReplyContext, CustomTool, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, RunEventSink, TrustPosture } from '@theokit/sdk';
3
3
  import { z } from 'zod';
4
4
  import { WireChunk } from '@theokit/presenter/wire';
5
5
  import { RetryOptions } from '@theokit/sdk/retry';
@@ -480,9 +480,11 @@ declare function compileContextWindow(options: ContextWindowOptions): CompiledCo
480
480
  * composes the documented `systemPrompt` seam (`string | SystemPromptResolver`):
481
481
  * the resolver prepends `buildEnvContext` + `buildRepoMap` (`@theokit/sdk-tools`)
482
482
  * and the nearest `THEO.md` (`@theokit/sdk/project#readProjectInstructions`) to
483
- * the agent's base prompt (ADR D3). The SDK primitives are dynamically imported
484
- * so `@theokit/sdk-tools` stays an OPTIONAL peer — only loaded when a `@ProjectContext`
485
- * agent actually sends.
483
+ * the agent's base prompt (ADR D3). The SDK primitives are dynamically imported so they stay out of
484
+ * the eager module graph — only loaded when a `@ProjectContext` agent actually sends. (The original
485
+ * reason given here was "so `@theokit/sdk-tools` stays an OPTIONAL peer"; it is a hard dependency of
486
+ * this package, and `tools-entry.ts` re-exports it statically. The laziness is still worth keeping,
487
+ * for the reason above.)
486
488
  *
487
489
  * Knobs with no primitive mapping (`indexStrategy`, `relevanceStrategy`,
488
490
  * `maxFilesInContext`, `includeExtensions`, `rootMarkers`) are reported via
@@ -2180,6 +2182,100 @@ declare class McpFileError extends TheokitAgentError {
2180
2182
  */
2181
2183
  declare function loadMcpJson(cwd: string, opts?: LoadMcpJsonOptions): McpServersMap;
2182
2184
 
2185
+ /**
2186
+ * M68 — the trust gate for `settingSources`.
2187
+ *
2188
+ * ## The defect this module closes
2189
+ *
2190
+ * `settingSources` enables on-disk config discovery. `'user'` reads `~/.theokit/` — the operator's
2191
+ * own machine, which no third party controls. `'project'` reads `<cwd>/.theokit/`, **including
2192
+ * `hooks.json`, which executes shell**.
2193
+ *
2194
+ * The previous API took `readonly SettingSource[]`, and its JSDoc justified the risk this way:
2195
+ * *"it is opt-in because `.theokit/` is the app's own repo (informed consent)"*. That premise holds
2196
+ * for a web app whose `cwd` is its own deploy. It does **not** hold for the class of product this
2197
+ * framework addresses — an agent whose `cwd` is a repository the user just cloned. There `.theokit/`
2198
+ * is attacker-controlled content, and enabling `'project'` is remote code execution on the first
2199
+ * `build()`.
2200
+ *
2201
+ * Documenting it did not prevent it. The measured consumer (TheoCode) did not trust the API: it
2202
+ * gated from the outside, with a `posture.allows` of its own (`chat.ts:386`, comment B-008). It
2203
+ * already **had** the right decision and could not pass it through, because the API only accepted
2204
+ * strings. The gate existed on its side and evaporated at the boundary.
2205
+ *
2206
+ * ## The evidence is the SDK's, not one invented here
2207
+ *
2208
+ * `TrustPosture` is `@theokit/sdk`'s own trust primitive, and `recordWiring`'s doc says *"a posture
2209
+ * is the only thing in this package that retains a capability"*. A bespoke type would make two trust
2210
+ * grammars coexist and drift apart (ADR 0063).
2211
+ */
2212
+ /**
2213
+ * The framework's capability vocabulary — deliberately a single name (ADR 0065).
2214
+ *
2215
+ * `allows` is all-or-nothing in the SDK: every declared `K` gets the same boolean. A finer
2216
+ * vocabulary (`hooks`, `skills`, `subagents`, `mcp`) would promise the consumer it can gate one
2217
+ * without gating the other, and the primitive does not deliver that. An API that suggests a
2218
+ * distinction the runtime does not make teaches the wrong thing, and the error only surfaces when
2219
+ * somebody depends on the distinction.
2220
+ */
2221
+ type SettingSourceCapability = 'projectSettings';
2222
+ /** Authorization to read config from the working directory. Requires the posture, never a claim. */
2223
+ interface ProjectSettingsGrant {
2224
+ /**
2225
+ * Typically the output of `resolveTrustPosture` — which is what gives it `source` (`'env' |
2226
+ * 'store' | 'default'`) and therefore a refusal that says WHERE the decision came from instead of
2227
+ * merely denying.
2228
+ */
2229
+ readonly trustedBy: TrustPosture<SettingSourceCapability>;
2230
+ }
2231
+ /**
2232
+ * Which on-disk config roots the agent may read.
2233
+ *
2234
+ * The asymmetry is the design: `user` is a boolean because `~/.theokit/` belongs to the operator;
2235
+ * `project` requires evidence because `<cwd>/.theokit/` may not. Omitting a root is not enabling it
2236
+ * — never "enabling without a gate". The asymmetry is inherited from the SDK itself, whose
2237
+ * `TrustPostureInput.envOverride` documents that `false` and `undefined` both mean "the operator did
2238
+ * not turn it on", not "turned it off".
2239
+ */
2240
+ interface SettingSourcesSelection {
2241
+ /** `~/.theokit/` — the operator's machine. No gate: no third party controls it. */
2242
+ readonly user?: boolean;
2243
+ /** `<cwd>/.theokit/` — controlled by whoever wrote the open repository. Requires evidence. */
2244
+ readonly project?: ProjectSettingsGrant;
2245
+ }
2246
+ /**
2247
+ * Refusal to read the working directory for lack of trust.
2248
+ *
2249
+ * Descends from `TheokitAgentError` because typed errors are an unbreakable rule here — and because
2250
+ * `isTransientError` only sees this hierarchy. A class extending plain `Error` would be invisible to
2251
+ * the predicate that separates recoverable from unrecoverable (the defect M67 fixed in five
2252
+ * classes).
2253
+ */
2254
+ declare class UntrustedSettingSourceError extends TheokitAgentError {
2255
+ /** Where the trust decision came from: `'env' | 'store' | 'default'`. */
2256
+ readonly trustSource: string;
2257
+ /** The refused capability. */
2258
+ readonly capability: SettingSourceCapability;
2259
+ readonly name = "UntrustedSettingSourceError";
2260
+ constructor(message: string,
2261
+ /** Where the trust decision came from: `'env' | 'store' | 'default'`. */
2262
+ trustSource: string,
2263
+ /** The refused capability. */
2264
+ capability: SettingSourceCapability);
2265
+ }
2266
+ /**
2267
+ * Translate the declared selection into the `SettingSource`s the SDK accepts, refusing what the
2268
+ * posture does not authorize.
2269
+ *
2270
+ * Refuses rather than ignores (ADR 0064). Ignoring would leave the product running in the belief
2271
+ * that the repository's hooks are active — a silent failure mode, on the wrong side. The SDK already
2272
+ * picked that side for the same problem: `recordWiring` throws `UngatedCapabilityError` when
2273
+ * somebody registers a capability the posture does not gate.
2274
+ *
2275
+ * @throws {UntrustedSettingSourceError} when `project` is requested and the posture does not grant it.
2276
+ */
2277
+ declare function resolveSettingSources(selection: SettingSourcesSelection | undefined): readonly SettingSource[];
2278
+
2183
2279
  /**
2184
2280
  * Agent manifest generator — build-time JSON describing all agents, tools, guards, policies.
2185
2281
  *
@@ -2325,4 +2421,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
2325
2421
  register(app: PluginApp): void;
2326
2422
  };
2327
2423
 
2328
- export { type DelegateOptions as $, type ApprovalOptions as A, type ApiErrorDecision as B, type CompiledAgentOptions as C, type DelegationResult as D, type ApiErrorPolicy as E, type ApprovalRequiredEvent as F, type Guardrail as G, type HumanInTheLoopOptions as H, type ArtifactChunkEvent as I, type ArtifactStartEvent as J, type BackgroundDelegation as K, type LoopStrategy as L, type MainLoopMeta as M, type BeforeToolCallContext as N, BudgetExceededError as O, type BudgetOptions as P, type CheckpointSavedEvent as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, type CompiledContextWindow as U, ContextualTool as V, CostBudgetExceededError as W, DEFAULT_MAX_ITERATIONS as X, type DefineAgentConfig as Y, type DefinitionOrThunk as Z, type DelegateFn as _, type CompiledTool as a, createSdkAgentStream as a$, DelegationBudgetExceededError as a0, DelegationError as a1, type DoneEvent as a2, type ErrorEvent as a3, type FileEditEvent as a4, type GuardrailAction as a5, type GuardrailPhase as a6, type GuardrailResult as a7, GuardrailViolationError as a8, type HookHandlers as a9, type SdkSendOptions as aA, type SdkTurnHandle as aB, type Segment as aC, type SkillsRequestContext as aD, type SkillsSelection as aE, type StateUpdateEvent as aF, type TextDeltaEvent as aG, type ThinkingEvent as aH, type TimeoutAction as aI, type ToolCallEvent as aJ, type ToolCallVeto as aK, type ToolHooks as aL, type ToolHooksPlugin as aM, type ToolResultEvent as aN, type ToolWalkResult as aO, type ToolboxOptions as aP, type ToolboxWalkResult as aQ, agentsPlugin as aR, buildModelSelection as aS, compileAgentDefinition as aT, compileAgentModule as aU, compileContextWindow as aV, compileProjectContext as aW, compileSkills as aX, compileTools as aY, createAgentExecutionContext as aZ, createApiErrorHandler as a_, type InferAgentInput as aa, type InferAgentToolNames as ab, type IterationEvent as ac, type LLMCallContext as ad, type LoopFinishReason as ae, type LoopOutcome as af, type LoopStrategyConfig as ag, type MainLoopOptions as ah, type McpApprovalSpec as ai, McpFileError as aj, type McpRegistryConfig as ak, type McpRequestContext as al, type McpSelection as am, type McpServersMap as an, type PartialToolCallEvent as ao, type PolicyHandler as ap, type ProcessInputContext as aq, type ReflectionContext as ar, type ReflectionResult as as, type ReflectionStrategyConfig as at, type RunStartedEvent as au, type ScoreVerdict as av, type ScoredDelegation as aw, type Scorer as ax, type SdkAgentHandle as ay, type SdkMessage as az, type ReasoningEffort as b, createThinkTagExtractor as b0, createToolHooksPlugin as b1, delegate as b2, delegateBackground as b3, delegateWithScoring as b4, extractThinkTagStream as b5, generateAgentManifest as b6, generateAgentRoutes as b7, isAgentContext as b8, isAgentDefinition as b9, isApprovalRequired as ba, isDone as bb, isError as bc, isPartialToolCall as bd, isTextDelta as be, isToolCall as bf, isToolResult as bg, ladderReflectionStrategy as bh, loadMcpJson as bi, loopStrategyConfigSchema as bj, mcpRegistry as bk, mcpToolApprovals as bl, noopReflectionStrategy as bm, presentUIMessageStream as bn, projectContextMetadataOnlyKnobs as bo, reasoningEffortOf as bp, reflectionStrategyConfigSchema as bq, resolveEnabledSkills as br, resolveLoopStrategy as bs, resolveMcpServers as bt, runWithApiErrorHandling as bu, streamAgentResponse as bv, toAgentFactory as bw, translateSdkEvent as bx, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, type HitlDecision as g, type ApprovalPosture as h, AGENT_BRAND as i, type AfterToolCallContext as j, AgentBuilder as k, type AgentDefinition as l, AgentDefinitionError as m, type AgentExecutionContext as n, type AgentManifest as o, type AgentManifestSource as p, type AgentManifestTool as q, type AgentOptions as r, streamAgentUIMessages as s, type AgentRoute as t, type AgentRouteContext as u, type AgentRunInfo as v, type AgentStreamEvent as w, type AgentTurnMetadata as x, type AgentsPluginOptions as y, type ApiErrorContext as z };
2424
+ export { type DelegateOptions as $, type ApprovalOptions as A, type ApiErrorDecision as B, type CompiledAgentOptions as C, type DelegationResult as D, type ApiErrorPolicy as E, type ApprovalRequiredEvent as F, type Guardrail as G, type HumanInTheLoopOptions as H, type ArtifactChunkEvent as I, type ArtifactStartEvent as J, type BackgroundDelegation as K, type LoopStrategy as L, type MainLoopMeta as M, type BeforeToolCallContext as N, BudgetExceededError as O, type BudgetOptions as P, type CheckpointSavedEvent as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, type CompiledContextWindow as U, ContextualTool as V, CostBudgetExceededError as W, DEFAULT_MAX_ITERATIONS as X, type DefineAgentConfig as Y, type DefinitionOrThunk as Z, type DelegateFn as _, type CompiledTool as a, compileSkills as a$, DelegationBudgetExceededError as a0, DelegationError as a1, type DoneEvent as a2, type ErrorEvent as a3, type FileEditEvent as a4, type GuardrailAction as a5, type GuardrailPhase as a6, type GuardrailResult as a7, GuardrailViolationError as a8, type HookHandlers as a9, type SdkMessage as aA, type SdkSendOptions as aB, type SdkTurnHandle as aC, type Segment as aD, type SettingSourceCapability as aE, type SettingSourcesSelection as aF, type SkillsRequestContext as aG, type SkillsSelection as aH, type StateUpdateEvent as aI, type TextDeltaEvent as aJ, type ThinkingEvent as aK, type TimeoutAction as aL, type ToolCallEvent as aM, type ToolCallVeto as aN, type ToolHooks as aO, type ToolHooksPlugin as aP, type ToolResultEvent as aQ, type ToolWalkResult as aR, type ToolboxOptions as aS, type ToolboxWalkResult as aT, UntrustedSettingSourceError as aU, agentsPlugin as aV, buildModelSelection as aW, compileAgentDefinition as aX, compileAgentModule as aY, compileContextWindow as aZ, compileProjectContext as a_, type InferAgentInput as aa, type InferAgentToolNames as ab, type IterationEvent as ac, type LLMCallContext as ad, type LoopFinishReason as ae, type LoopOutcome as af, type LoopStrategyConfig as ag, type MainLoopOptions as ah, type McpApprovalSpec as ai, McpFileError as aj, type McpRegistryConfig as ak, type McpRequestContext as al, type McpSelection as am, type McpServersMap as an, type PartialToolCallEvent as ao, type PolicyHandler as ap, type ProcessInputContext as aq, type ProjectSettingsGrant as ar, type ReflectionContext as as, type ReflectionResult as at, type ReflectionStrategyConfig as au, type RunStartedEvent as av, type ScoreVerdict as aw, type ScoredDelegation as ax, type Scorer as ay, type SdkAgentHandle as az, type ReasoningEffort as b, compileTools as b0, createAgentExecutionContext as b1, createApiErrorHandler as b2, createSdkAgentStream as b3, createThinkTagExtractor as b4, createToolHooksPlugin as b5, delegate as b6, delegateBackground as b7, delegateWithScoring as b8, extractThinkTagStream as b9, streamAgentResponse as bA, toAgentFactory as bB, translateSdkEvent as bC, generateAgentManifest as ba, generateAgentRoutes as bb, isAgentContext as bc, isAgentDefinition as bd, isApprovalRequired as be, isDone as bf, isError as bg, isPartialToolCall as bh, isTextDelta as bi, isToolCall as bj, isToolResult as bk, ladderReflectionStrategy as bl, loadMcpJson as bm, loopStrategyConfigSchema as bn, mcpRegistry as bo, mcpToolApprovals as bp, noopReflectionStrategy as bq, presentUIMessageStream as br, projectContextMetadataOnlyKnobs as bs, reasoningEffortOf as bt, reflectionStrategyConfigSchema as bu, resolveEnabledSkills as bv, resolveLoopStrategy as bw, resolveMcpServers as bx, resolveSettingSources as by, runWithApiErrorHandling as bz, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, type HitlDecision as g, type ApprovalPosture as h, AGENT_BRAND as i, type AfterToolCallContext as j, AgentBuilder as k, type AgentDefinition as l, AgentDefinitionError as m, type AgentExecutionContext as n, type AgentManifest as o, type AgentManifestSource as p, type AgentManifestTool as q, type AgentOptions as r, streamAgentUIMessages as s, type AgentRoute as t, type AgentRouteContext as u, type AgentRunInfo as v, type AgentStreamEvent as w, type AgentTurnMetadata as x, type AgentsPluginOptions as y, type ApiErrorContext as z };