@crewx/sdk 0.9.0-rc.9 → 0.9.0-rc.90

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 (191) hide show
  1. package/README.md +1 -1
  2. package/dist/account/auth-client.d.ts +61 -0
  3. package/dist/account/auth-json-v2.d.ts +1 -0
  4. package/dist/account/auth-json.d.ts +30 -0
  5. package/dist/account/config.d.ts +8 -0
  6. package/dist/account/errors.d.ts +24 -0
  7. package/dist/account/index.d.ts +10 -0
  8. package/dist/account/index.js +1 -0
  9. package/dist/account/session-manager.d.ts +47 -0
  10. package/dist/activity-log/builder.d.ts +55 -6
  11. package/dist/config/canonicalize-agent-options.d.ts +17 -0
  12. package/dist/config/global-settings.d.ts +33 -0
  13. package/dist/config/migrate-grok-mode.d.ts +6 -0
  14. package/dist/config/model-compat.d.ts +31 -0
  15. package/dist/config/models.generated.d.ts +37 -0
  16. package/dist/config/models.remote.d.ts +1 -0
  17. package/dist/config/overdrive.d.ts +7 -0
  18. package/dist/config/pricing.d.ts +8 -5
  19. package/dist/config/pricing.generated.d.ts +4 -0
  20. package/dist/config/pricing.types.d.ts +4 -10
  21. package/dist/config/timeout.config.d.ts +3 -0
  22. package/dist/config/wi-boards.d.ts +19 -0
  23. package/dist/context-budget/continuity.d.ts +61 -0
  24. package/dist/context-budget/index.d.ts +140 -0
  25. package/dist/conversation/index.d.ts +1 -1
  26. package/dist/conversation/sqlite-provider.d.ts +5 -1
  27. package/dist/conversation/to-template-messages.d.ts +7 -0
  28. package/dist/conversation/types.d.ts +43 -0
  29. package/dist/desktop/command-runner.d.ts +4 -0
  30. package/dist/desktop/default-adapters.d.ts +4 -0
  31. package/dist/desktop/global-install.d.ts +19 -0
  32. package/dist/desktop/index.d.ts +2 -0
  33. package/dist/desktop/index.js +3 -0
  34. package/dist/desktop/install.d.ts +5 -0
  35. package/dist/desktop/lnk.d.ts +22 -0
  36. package/dist/desktop/manifest.d.ts +21 -0
  37. package/dist/desktop/types.d.ts +67 -0
  38. package/dist/desktop/version.d.ts +1 -0
  39. package/dist/desktop/windows-paths.d.ts +21 -0
  40. package/dist/desktop/wrapper.d.ts +18 -0
  41. package/dist/esm/account/index.js +1 -0
  42. package/dist/esm/desktop/index.js +3 -0
  43. package/dist/esm/index.js +353 -98
  44. package/dist/esm/plugins/index.js +213 -103
  45. package/dist/esm/publish/index.js +1 -0
  46. package/dist/esm/repository/index.js +200 -94
  47. package/dist/esm/testing/index.js +1 -1
  48. package/dist/events/types.d.ts +4 -0
  49. package/dist/facade/Crewx.d.ts +40 -2
  50. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  51. package/dist/highlight/thread-highlighter.d.ts +326 -0
  52. package/dist/index.browser.d.ts +11 -1
  53. package/dist/index.browser.js +6 -2
  54. package/dist/index.d.ts +71 -11
  55. package/dist/index.js +353 -98
  56. package/dist/internal/windows-spawn.d.ts +10 -0
  57. package/dist/layout/types.d.ts +17 -1
  58. package/dist/local-server/base-url.d.ts +18 -0
  59. package/dist/local-server/index.d.ts +8 -0
  60. package/dist/local-server/opencode.d.ts +8 -0
  61. package/dist/local-server/probe.d.ts +3 -0
  62. package/dist/local-server/runtime.d.ts +26 -0
  63. package/dist/local-server/types.d.ts +43 -0
  64. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  65. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  66. package/dist/migrations/0010_analyze_stats.sql +6 -0
  67. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  68. package/dist/migrations/0012_blue_turbo.sql +23 -0
  69. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  70. package/dist/migrations/0014_organic_mongu.sql +73 -0
  71. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  72. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  73. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  74. package/dist/migrations/0018_bored_jackal.sql +33 -0
  75. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  76. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  77. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  78. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  79. package/dist/migrations/0023_red_payback.sql +1 -0
  80. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  81. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  82. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  83. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  84. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  85. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  86. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  87. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  88. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  89. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  90. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  91. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  92. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  93. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  94. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  95. package/dist/migrations/meta/_journal.json +112 -0
  96. package/dist/paths.d.ts +1 -0
  97. package/dist/plugin/types.d.ts +1 -0
  98. package/dist/plugins/index.js +213 -103
  99. package/dist/plugins/sqlite-tracing.d.ts +23 -0
  100. package/dist/provider/acp/connection.d.ts +4 -0
  101. package/dist/provider/acp/meta.d.ts +11 -0
  102. package/dist/provider/bridge.d.ts +6 -0
  103. package/dist/provider/classify-task-error.d.ts +2 -0
  104. package/dist/provider/cli/adapter.types.d.ts +8 -1
  105. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  106. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  107. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  108. package/dist/provider/cli/adapters/index.d.ts +1 -0
  109. package/dist/provider/cli/index.d.ts +1 -1
  110. package/dist/provider/cli/meta.d.ts +5 -0
  111. package/dist/provider/cli/protocol-envelope.d.ts +2 -0
  112. package/dist/provider/errors.d.ts +1 -0
  113. package/dist/provider/idle-watchdog.d.ts +19 -0
  114. package/dist/provider/models.d.ts +17 -12
  115. package/dist/provider/order.d.ts +1 -1
  116. package/dist/provider/parse-usage.d.ts +6 -0
  117. package/dist/provider/provider-selection.d.ts +8 -0
  118. package/dist/provider/redact-technical-message.d.ts +1 -0
  119. package/dist/provider/task-error.types.d.ts +16 -0
  120. package/dist/publish/constants.d.ts +6 -0
  121. package/dist/publish/index.d.ts +26 -0
  122. package/dist/publish/index.js +1 -0
  123. package/dist/publish/manifest.d.ts +17 -0
  124. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  125. package/dist/publish/pack.d.ts +2 -0
  126. package/dist/publish/scan.d.ts +9 -0
  127. package/dist/publish/secrets.d.ts +6 -0
  128. package/dist/publish/upload.d.ts +18 -0
  129. package/dist/remote/execution-profile.d.ts +9 -0
  130. package/dist/remote/index.d.ts +1 -0
  131. package/dist/remote/types.d.ts +28 -0
  132. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  133. package/dist/repository/common-code.repository.d.ts +45 -0
  134. package/dist/repository/db.d.ts +8 -0
  135. package/dist/repository/index.d.ts +28 -4
  136. package/dist/repository/index.js +200 -94
  137. package/dist/repository/notification.repository.d.ts +58 -0
  138. package/dist/repository/project.repository.d.ts +90 -0
  139. package/dist/repository/request-log.repository.d.ts +1 -0
  140. package/dist/repository/task-log-migration.d.ts +74 -0
  141. package/dist/repository/task-log.repository.d.ts +44 -0
  142. package/dist/repository/task.repository.d.ts +120 -0
  143. package/dist/repository/thread-history.repository.d.ts +193 -0
  144. package/dist/repository/thread-title-common-code-migration.d.ts +13 -0
  145. package/dist/repository/thread-title.types.d.ts +29 -0
  146. package/dist/repository/thread.repository.d.ts +21 -2
  147. package/dist/repository/usage-report.repository.d.ts +27 -0
  148. package/dist/repository/workspace.repository.d.ts +3 -0
  149. package/dist/schema/agent-suggestions.d.ts +199 -0
  150. package/dist/schema/common-codes.d.ts +216 -0
  151. package/dist/schema/index.d.ts +9 -0
  152. package/dist/schema/notifications.d.ts +303 -0
  153. package/dist/schema/projects.d.ts +610 -0
  154. package/dist/schema/task-log-events.d.ts +119 -0
  155. package/dist/schema/tasks.d.ts +53 -0
  156. package/dist/schema/thread-history.d.ts +734 -0
  157. package/dist/schema/threads.d.ts +2 -0
  158. package/dist/schema/ui-action-receipts.d.ts +303 -0
  159. package/dist/schema/ui-instances.d.ts +267 -0
  160. package/dist/schema/usage-reports.d.ts +252 -0
  161. package/dist/schema/workspaces.d.ts +17 -0
  162. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  163. package/dist/task-log/delegation-trailer.d.ts +34 -0
  164. package/dist/testing/index.js +1 -1
  165. package/dist/types/index.d.ts +1536 -3
  166. package/dist/types/task-log.types.d.ts +2 -0
  167. package/dist/ui-card/index.d.ts +2 -0
  168. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  169. package/dist/ui-instance/definition.d.ts +6 -0
  170. package/dist/ui-instance/errors.d.ts +17 -0
  171. package/dist/ui-instance/index.d.ts +6 -0
  172. package/dist/ui-instance/json.d.ts +5 -0
  173. package/dist/ui-instance/runtime.d.ts +13 -0
  174. package/dist/ui-instance/store.d.ts +65 -0
  175. package/dist/ui-instance/types.d.ts +200 -0
  176. package/dist/ui-plugin/index.d.ts +3 -0
  177. package/dist/ui-plugin/manifest.d.ts +3 -0
  178. package/dist/ui-plugin/types.d.ts +76 -0
  179. package/dist/ui-plugin/validator.d.ts +9 -0
  180. package/dist/utils/crewx-executable.d.ts +54 -0
  181. package/dist/utils/crewx-home.d.ts +1 -0
  182. package/dist/utils/env-defaults.d.ts +2 -0
  183. package/dist/utils/id.d.ts +1 -1
  184. package/dist/utils/timestamp.d.ts +1 -0
  185. package/dist/wi/create.d.ts +48 -0
  186. package/dist/wi/select.d.ts +20 -0
  187. package/package.json +25 -2
  188. package/templates/agents/default.yaml +244 -120
  189. package/templates/documents/crewx-manual.md +138 -138
  190. package/templates/workflows/wi-default-flow.yaml +65 -0
  191. package/templates/workflows/wi-plan-flow.yaml +140 -0
package/README.md CHANGED
@@ -128,7 +128,7 @@ const result = await crewx.query('assistant', 'Translate to Korean', {
128
128
  });
129
129
  ```
130
130
 
131
- > **Note**: `'@assistant'` 형태도 동작합니다 (CLI 호환). SDK에서는 bare id가 권장됩니다.
131
+ > **Note**: The `'@assistant'` form also works (CLI-compatible). The SDK recommends using the bare id.
132
132
 
133
133
  **Returns**: [`QueryResult`](#queryresult)
134
134
 
@@ -0,0 +1,61 @@
1
+ export declare const DEVICE_CODE_PATH: "/auth/v1/oauth/device/code";
2
+ export declare const TOKEN_PATH: "/auth/v1/oauth/token";
3
+ export declare const REVOKE_PATH: "/auth/v1/oauth/revoke";
4
+ export declare const OAUTH_CLIENT_ID: "crewx-cli";
5
+ export declare const DEVICE_CODE_GRANT_TYPE: "urn:ietf:params:oauth:grant-type:device_code";
6
+ export interface DeviceCodeResponse {
7
+ device_code: string;
8
+ user_code: string;
9
+ verification_uri: string;
10
+ verification_uri_complete?: string;
11
+ expires_in: number;
12
+ interval?: number;
13
+ }
14
+ export type DeviceCodeResult = DeviceCodeResponse;
15
+ export interface AccountIdentity {
16
+ sub: string;
17
+ email: string;
18
+ }
19
+ export interface OAuthTokenResponse {
20
+ access_token: string;
21
+ refresh_token: string;
22
+ expires_in: number;
23
+ token_type?: string;
24
+ scope?: string;
25
+ account: AccountIdentity;
26
+ }
27
+ export type TokenResponse = OAuthTokenResponse;
28
+ export type AuthTokenGrant = {
29
+ grant_type: typeof DEVICE_CODE_GRANT_TYPE;
30
+ device_code: string;
31
+ } | {
32
+ grant_type: 'refresh_token';
33
+ refresh_token: string;
34
+ };
35
+ export interface AuthClientOptions {
36
+ baseUrl?: string;
37
+ fetch?: typeof fetch;
38
+ fetchImpl?: typeof fetch;
39
+ timeoutMs?: number;
40
+ }
41
+ export declare class AuthClient {
42
+ private readonly configuredBaseUrl?;
43
+ private readonly fetchImpl?;
44
+ private readonly timeoutMs;
45
+ constructor(options?: AuthClientOptions | string);
46
+ private baseUrl;
47
+ private signal;
48
+ private request;
49
+ requestDeviceCode(): Promise<DeviceCodeResponse>;
50
+ requestToken(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
51
+ exchangeDeviceCode(deviceCode: string): Promise<OAuthTokenResponse>;
52
+ refreshToken(refreshToken: string): Promise<OAuthTokenResponse>;
53
+ deviceCode(): Promise<DeviceCodeResponse>;
54
+ getDeviceCode(): Promise<DeviceCodeResponse>;
55
+ token(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
56
+ getToken(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
57
+ refresh(refreshToken: string): Promise<OAuthTokenResponse>;
58
+ refreshAccessToken(refreshToken: string): Promise<OAuthTokenResponse>;
59
+ revokeToken(refreshToken: string): Promise<void>;
60
+ revoke(refreshToken: string): Promise<void>;
61
+ }
@@ -0,0 +1 @@
1
+ export * from './auth-json';
@@ -0,0 +1,30 @@
1
+ export declare const AUTH_JSON_FILENAME: "auth.json";
2
+ export declare const AUTH_JSON_VERSION: 2;
3
+ export interface AuthJsonV2 {
4
+ version: 2;
5
+ sub: string;
6
+ email: string;
7
+ access_token: string;
8
+ refresh_token: string;
9
+ expires_at: number;
10
+ updated_at: string;
11
+ }
12
+ export type AuthJson = AuthJsonV2;
13
+ export type AuthSession = AuthJsonV2;
14
+ export declare function isAuthJsonV2(value: unknown): value is AuthJsonV2;
15
+ export declare function validateAuthJson(value: unknown): AuthJsonV2;
16
+ export declare function parseAuthJson(raw: string): AuthJsonV2;
17
+ export declare function authJsonPath(filePath?: string): string;
18
+ export declare class AuthJsonStore {
19
+ private readonly configuredPath?;
20
+ constructor(options?: {
21
+ filePath?: string;
22
+ } | string);
23
+ path(): string;
24
+ read(): AuthJsonV2 | null;
25
+ write(value: AuthJsonV2): void;
26
+ clear(): void;
27
+ }
28
+ export declare function readAuthJson(filePath?: string): AuthJsonV2;
29
+ export declare function writeAuthJson(value: AuthJsonV2, filePath?: string): void;
30
+ export declare function clearAuthJson(filePath?: string): void;
@@ -0,0 +1,8 @@
1
+ export declare const ACCOUNT_BASE_URL_ENV: "CREWX_ACCOUNT_BASE_URL";
2
+ export declare const ACCOUNT_ISSUER_ENV: "CREWX_ACCOUNT_ISSUER";
3
+ export declare const MARKETPLACE_URL_ENV: "CREWX_MARKETPLACE_URL";
4
+ export type Environment = Readonly<Record<string, string | undefined>>;
5
+ export declare function resolveAccountBaseUrl(env?: Environment): string;
6
+ export declare function resolveMarketplaceUrl(env?: Environment): string;
7
+ export declare function resolveAccountIssuer(env?: Environment): string;
8
+ export declare function appendEndpoint(baseUrl: string, endpoint: string): string;
@@ -0,0 +1,24 @@
1
+ export type AccountAuthErrorKind = 'configuration' | 'network' | 'server' | 'invalid_refresh' | 'pending' | 'denied' | 'expired' | 'http' | 'protocol';
2
+ export declare class AccountAuthError extends Error {
3
+ readonly code: string;
4
+ readonly kind: AccountAuthErrorKind;
5
+ readonly status?: number;
6
+ constructor(code: string, kind: AccountAuthErrorKind, status?: number, message?: string);
7
+ }
8
+ export { AccountAuthError as AuthClientError, AccountAuthError as AuthError };
9
+ export declare class LoginRequiredError extends Error {
10
+ readonly code: "LOGIN_REQUIRED";
11
+ constructor();
12
+ }
13
+ export declare class SessionManagerError extends Error {
14
+ readonly code: string;
15
+ constructor(code: string, message: string);
16
+ }
17
+ export type AuthJsonValidationCode = 'AUTH_JSON_LEGACY' | 'AUTH_JSON_INVALID';
18
+ export declare class AuthJsonValidationError extends Error {
19
+ readonly code: AuthJsonValidationCode;
20
+ constructor(code: AuthJsonValidationCode, message?: string);
21
+ }
22
+ export declare class AccountConfigurationError extends AccountAuthError {
23
+ constructor(code: 'ACCOUNT_BASE_URL_MISSING' | 'ACCOUNT_BASE_URL_INVALID' | 'ACCOUNT_ISSUER_MISSING' | 'ACCOUNT_ISSUER_INVALID' | 'MARKETPLACE_URL_MISSING' | 'MARKETPLACE_URL_INVALID');
24
+ }
@@ -0,0 +1,10 @@
1
+ export { ACCOUNT_BASE_URL_ENV, ACCOUNT_ISSUER_ENV, MARKETPLACE_URL_ENV, appendEndpoint, resolveAccountBaseUrl, resolveAccountIssuer, resolveMarketplaceUrl, } from './config';
2
+ export type { Environment } from './config';
3
+ export { AccountAuthError, AuthClientError, AuthError, AccountConfigurationError, AuthJsonValidationError, LoginRequiredError, SessionManagerError, } from './errors';
4
+ export type { AccountAuthErrorKind, AuthJsonValidationCode } from './errors';
5
+ export { AUTH_JSON_FILENAME, AUTH_JSON_VERSION, AuthJsonStore, authJsonPath, clearAuthJson, isAuthJsonV2, parseAuthJson, readAuthJson, validateAuthJson, writeAuthJson, } from './auth-json';
6
+ export type { AuthJson, AuthJsonV2, AuthSession } from './auth-json';
7
+ export { AuthClient, DEVICE_CODE_GRANT_TYPE, DEVICE_CODE_PATH, OAUTH_CLIENT_ID, REVOKE_PATH, TOKEN_PATH, } from './auth-client';
8
+ export type { AccountIdentity, AuthClientOptions, AuthTokenGrant, DeviceCodeResponse, DeviceCodeResult, OAuthTokenResponse, TokenResponse, } from './auth-client';
9
+ export { SessionManager } from './session-manager';
10
+ export type { AccountAuthClient, AuthJsonStorage, AuthSessionStore, SessionManagerOptions } from './session-manager';
@@ -0,0 +1 @@
1
+ 'use strict';var crypto=require('crypto'),V=require('fs'),y=require('path'),R=require('os');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var V__namespace=/*#__PURE__*/_interopNamespace(V);var y__namespace=/*#__PURE__*/_interopNamespace(y);var R__namespace=/*#__PURE__*/_interopNamespace(R);var s=class extends Error{code;kind;status;constructor(e,n,r,o){super(o??`Account authentication request failed (${e})`),this.name="AccountAuthError",this.code=e,this.kind=n,this.status=r;}};var p=class extends Error{code="LOGIN_REQUIRED";constructor(){super("Login required \u2014 please log in again"),this.name="LoginRequiredError";}},d=class extends Error{code;constructor(e,n){super(n),this.name="SessionManagerError",this.code=e;}},u=class extends Error{code;constructor(e,n="auth.json is invalid \u2014 please log in again"){super(n),this.name="AuthJsonValidationError",this.code=e;}},c=class extends s{constructor(e){let n=e.startsWith("ACCOUNT_BASE_URL")?"CREWX_ACCOUNT_BASE_URL":e.startsWith("ACCOUNT_ISSUER")?"CREWX_ACCOUNT_ISSUER":"CREWX_MARKETPLACE_URL";super(e,"configuration",void 0,`${n} is missing or invalid \u2014 configure it and try again`),this.name="AccountConfigurationError";}};var x="CREWX_ACCOUNT_BASE_URL",b="CREWX_ACCOUNT_ISSUER",L="CREWX_MARKETPLACE_URL";function P(t,e,n,r=false){let o=t?.trim();if(!o)throw new c(e);try{let i=new URL(o);if(i.protocol!=="http:"&&i.protocol!=="https:"||i.username.length>0||i.password.length>0||i.hostname.length===0||i.search.length>0||i.hash.length>0||r&&i.pathname!=="/")throw new Error("invalid URL")}catch{throw new c(n)}return o.replace(/\/+$/,"")}function T(t=process.env){return P(t[x],"ACCOUNT_BASE_URL_MISSING","ACCOUNT_BASE_URL_INVALID",true)}function F(t=process.env){return P(t[L],"MARKETPLACE_URL_MISSING","MARKETPLACE_URL_INVALID")}function k(t=process.env){let e=t[b]?.trim();if(!e)throw new c("ACCOUNT_ISSUER_MISSING");try{let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.username.length>0||n.password.length>0||n.hostname.length===0||n.search.length>0||n.hash.length>0)throw new Error("invalid issuer")}catch{throw new c("ACCOUNT_ISSUER_INVALID")}return e}function C(t,e){return `${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`}function D(){if(process.env.CREWX_HOME)try{return V__namespace.realpathSync(process.env.CREWX_HOME)}catch{return y__namespace.join(R__namespace.homedir(),".crewx")}return process.platform!=="win32"&&process.env.XDG_CONFIG_HOME?y__namespace.join(process.env.XDG_CONFIG_HOME,"crewx"):y__namespace.join(R__namespace.homedir(),".crewx")}var G="auth.json",N=2,H=["version","sub","email","access_token","refresh_token","expires_at","updated_at"];function h(t="auth.json is invalid \u2014 please log in again"){throw new u("AUTH_JSON_INVALID",t)}function re(){throw new u("AUTH_JSON_LEGACY","auth.json uses an unsupported legacy format \u2014 please log in again")}function oe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function se(t){try{return A(t),!0}catch{return false}}function A(t){if(!oe(t))return h();if(t.version===1)return re();if(t.version!==N)return h();let e=Object.keys(t);if(e.length!==H.length||e.some(r=>!H.includes(r))||typeof t.sub!="string"||t.sub.length===0||typeof t.email!="string"||t.email.length===0||typeof t.access_token!="string"||t.access_token.length===0||typeof t.refresh_token!="string"||t.refresh_token.length===0)return h();let n=t.expires_at;return typeof n!="number"||!Number.isSafeInteger(n)||n<0||typeof t.updated_at!="string"||t.updated_at.length===0||Number.isNaN(Date.parse(t.updated_at))?h():{version:N,sub:t.sub,email:t.email,access_token:t.access_token,refresh_token:t.refresh_token,expires_at:n,updated_at:t.updated_at}}function B(t){let e;try{e=JSON.parse(t);}catch{return h()}return A(e)}function K(t){return t??y.join(D(),G)}var f=class{configuredPath;constructor(e={}){this.configuredPath=typeof e=="string"?e:e.filePath;}path(){return K(this.configuredPath)}read(){let e=this.path();if(!V.existsSync(e))return null;try{return B(V.readFileSync(e,"utf8"))}catch(n){throw n instanceof u?n:new u("AUTH_JSON_INVALID")}}write(e){let n=A(e),r=this.path(),o=y.dirname(r);V.mkdirSync(o,{recursive:true,mode:448});let i=`${r}.tmp.${process.pid}.${crypto.randomUUID()}`;try{V.writeFileSync(i,JSON.stringify(n,null,2),{encoding:"utf8",mode:384}),V.chmodSync(i,384),V.renameSync(i,r),V.chmodSync(r,384);}catch{try{V.existsSync(i)&&V.unlinkSync(i);}catch{}throw new Error("Could not persist auth.json securely")}}clear(){let e=this.path();try{V.existsSync(e)&&V.unlinkSync(e);}catch{throw new Error("Could not clear auth.json")}}};function ie(t){let e=new f({filePath:t}).read();if(!e)throw new p;return e}function ce(t,e){new f({filePath:e}).write(t);}function ae(t){new f({filePath:t}).clear();}var j="/auth/v1/oauth/device/code",W="/auth/v1/oauth/token",X="/auth/v1/oauth/revoke",w="crewx-cli",g="urn:ietf:params:oauth:grant-type:device_code";function a(t){return typeof t=="string"&&t.trim().length>0}function m(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}function ue(t){let e=m(t),n=e?.error??e?.code;if(typeof n=="string")return n.toLowerCase();let r=m(n),o=r?.code??r?.error;return typeof o=="string"?o.toLowerCase():void 0}function he(t){let e=m(t);if(!e||!a(e.device_code)||!a(e.user_code)||!a(e.verification_uri))throw new s("AUTH_RESPONSE_INVALID","protocol");let n=e.expires_in,r=e.interval;if(typeof n!="number"||!Number.isSafeInteger(n)||n<=0)throw new s("AUTH_RESPONSE_INVALID","protocol");if(e.verification_uri_complete!==void 0&&!a(e.verification_uri_complete))throw new s("AUTH_RESPONSE_INVALID","protocol");if(r!==void 0&&(typeof r!="number"||!Number.isSafeInteger(r)||r<0))throw new s("AUTH_RESPONSE_INVALID","protocol");let o={device_code:e.device_code,user_code:e.user_code,verification_uri:e.verification_uri,expires_in:n};return e.verification_uri_complete!==void 0&&(o.verification_uri_complete=e.verification_uri_complete),r!==void 0&&(o.interval=r),o}function pe(t){let e=m(t),n=m(e?.account),r=e?.expires_in;if(!e||!a(e.access_token)||!a(e.refresh_token)||typeof r!="number"||!Number.isSafeInteger(r)||r<=0||!n||!a(n.sub)||!a(n.email))throw new s("AUTH_RESPONSE_INVALID","protocol");let o={access_token:e.access_token,refresh_token:e.refresh_token,expires_in:r,account:{sub:n.sub,email:n.email}};return typeof e.token_type=="string"&&e.token_type.length>0&&(o.token_type=e.token_type),typeof e.scope=="string"&&e.scope.length>0&&(o.scope=e.scope),o}var S=class{configuredBaseUrl;fetchImpl;timeoutMs;constructor(e={}){let n=typeof e=="string"?{baseUrl:e}:e;this.configuredBaseUrl=n.baseUrl===void 0?void 0:de(n.baseUrl),this.fetchImpl=n.fetch??n.fetchImpl,this.timeoutMs=n.timeoutMs??1e4;}baseUrl(){return this.configuredBaseUrl!==void 0?this.configuredBaseUrl:T()}signal(e){if(!(e<=0||typeof AbortSignal>"u"||typeof AbortSignal.timeout!="function"))return AbortSignal.timeout(e)}async request(e,n,r,o={}){let i=C(this.baseUrl(),e),U=this.fetchImpl??globalThis.fetch;if(typeof U!="function")throw new s("AUTH_NETWORK_ERROR","network");let l;try{l=await U(i,{...n,signal:n.signal??this.signal(o.timeoutMs??this.timeoutMs)});}catch{throw new s("AUTH_NETWORK_ERROR","network")}if(o.parseBody===false){if(!l.ok)throw q(l.status,null,r);return}let E=null;try{E=await l.json();}catch{E=null;}if(!l.ok)throw q(l.status,E,r);return E}async requestDeviceCode(){let e=new URLSearchParams;e.set("client_id",w);let n=await this.request(j,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e.toString()});return he(n)}async requestToken(e){fe(e);let n=new URLSearchParams;n.set("grant_type",e.grant_type),n.set("client_id",w),e.grant_type===g?n.set("device_code",e.device_code):n.set("refresh_token",e.refresh_token);let r=await this.request(W,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()},e);return pe(r)}async exchangeDeviceCode(e){return this.requestToken({grant_type:g,device_code:e})}async refreshToken(e){return this.requestToken({grant_type:"refresh_token",refresh_token:e})}async deviceCode(){return this.requestDeviceCode()}async getDeviceCode(){return this.requestDeviceCode()}async token(e){return this.requestToken(e)}async getToken(e){return this.requestToken(e)}async refresh(e){return this.refreshToken(e)}async refreshAccessToken(e){return this.refreshToken(e)}async revokeToken(e){if(!a(e))throw new s("AUTH_INPUT_INVALID","protocol");let n=new URLSearchParams;n.set("token",e),n.set("token_type_hint","refresh_token"),n.set("client_id",w),await this.request(X,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()},void 0,{parseBody:false,timeoutMs:3e3});}async revoke(e){return this.revokeToken(e)}};function de(t){if(typeof t!="string"||!t.trim())throw new c("ACCOUNT_BASE_URL_MISSING");try{let e=new URL(t.trim());if(e.protocol!=="http:"&&e.protocol!=="https:"||e.username.length>0||e.password.length>0||e.hostname.length===0||e.pathname!=="/"||e.search.length>0||e.hash.length>0)throw new Error("invalid URL")}catch{throw new c("ACCOUNT_BASE_URL_INVALID")}return t.trim().replace(/\/+$/,"")}function fe(t){if(!t||t.grant_type!==g&&t.grant_type!=="refresh_token"||t.grant_type===g&&!a(t.device_code)||t.grant_type==="refresh_token"&&!a(t.refresh_token))throw new s("AUTH_INPUT_INVALID","protocol")}function q(t,e,n){let r=ue(e);if(t>=500)return new s("AUTH_SERVER_ERROR","server",t);if(n?.grant_type==="refresh_token"&&(r==="invalid_grant"||t===401))return new s("INVALID_REFRESH_TOKEN","invalid_refresh",t);if(n?.grant_type===g){if(r==="authorization_pending")return new s("AUTHORIZATION_PENDING","pending",t);if(r==="slow_down")return new s("SLOW_DOWN","pending",t);if(r==="access_denied")return new s("ACCESS_DENIED","denied",t);if(r==="expired_token")return new s("EXPIRED_TOKEN","expired",t)}return new s("AUTH_HTTP_ERROR","http",t)}var O=class{client;store;refreshSkewSeconds;now;nowSecondsOverride;refreshPromise=null;constructor(e={},n){let r=le(e)?e:void 0,o=r?{}:e;this.client=r??o.client??o.authClient??new S,this.store=o.store??o.storage??n??new f,this.refreshSkewSeconds=o.refreshSkewSeconds??60,this.now=o.now??(()=>Date.now()),this.nowSecondsOverride=o.nowSeconds;}getSession(){return this.readSession()}isLoggedIn(){return this.readSession()!==null}async getAccessToken(){let e=this.requireSession();return e.expires_at>this.epochSeconds()+this.refreshSkewSeconds?e.access_token:(await this.refreshSession(e)).access_token}async getValidAccessToken(){return this.getAccessToken()}async getToken(){return this.getAccessToken()}async refresh(){return this.refreshSession(this.requireSession())}async loginWithDeviceCode(e){let n=await this.client.exchangeDeviceCode(e);return this.persistTokenResponse(n)}async login(e){return this.loginWithDeviceCode(e)}async setSession(e){return this.persistTokenResponse(e)}clear(){this.store.clear();}async withAccessToken(e){return e(await this.getAccessToken())}readSession(){try{let e=this.store.read();if(e===null)return null;let n=A(e);return $(n.access_token,n.sub),n}catch(e){throw e instanceof u?new p:e}}requireSession(){let e=this.readSession();if(!e)throw new p;return e}epochSeconds(){return this.nowSecondsOverride?.()??Math.floor(this.now()/1e3)}refreshSession(e){if(this.refreshPromise)return this.refreshPromise;let n;return n=this.performRefresh(e).finally(()=>{this.refreshPromise===n&&(this.refreshPromise=null);}),this.refreshPromise=n,n}async performRefresh(e){try{let n=await this.client.refreshToken(e.refresh_token);return this.persistTokenResponse(n,e.sub)}catch(n){throw Ae(n)?(this.store.clear(),new p):n}}persistTokenResponse(e,n){let r=e?.account;if(!e||typeof e.access_token!="string"||e.access_token.length===0||typeof e.refresh_token!="string"||e.refresh_token.length===0||!Number.isSafeInteger(e.expires_in)||e.expires_in<=0||!r||typeof r.sub!="string"||r.sub.length===0||typeof r.email!="string"||r.email.length===0)throw new d("AUTH_RESPONSE_INVALID","Account token response is malformed");if(n!==void 0&&r.sub!==n)throw new d("ACCOUNT_SUB_MISMATCH","Account subject changed during token refresh \u2014 please log in again");$(e.access_token,r.sub);let o=A({version:2,sub:r.sub,email:r.email,access_token:e.access_token,refresh_token:e.refresh_token,expires_at:this.epochSeconds()+e.expires_in,updated_at:new Date(this.now()).toISOString()});return this.store.write(o),o}};function Ae(t){return t instanceof s?t.kind==="invalid_refresh":typeof t=="object"&&t!==null&&(t.kind==="invalid_refresh"||t.code==="INVALID_REFRESH_TOKEN")}function le(t){return typeof t.exchangeDeviceCode=="function"&&typeof t.refreshToken=="function"}function $(t,e){let n=k(),r=_e(t);if(r.iss!==n)throw new d("ACCOUNT_ISSUER_MISMATCH","Access token issuer does not match the configured account issuer \u2014 please log in again");if(r.sub!==e)throw new d("ACCOUNT_SUB_MISMATCH","Access token subject does not match the account session \u2014 please log in again")}function _e(t){if(typeof t!="string")throw v();let e=t.split(".");if(e.length!==3||e.some(n=>!/^[A-Za-z0-9_-]+$/.test(n)))throw v();try{let n=JSON.parse(Buffer.from(e[1],"base64url").toString("utf8"));if(typeof n!="object"||n===null||Array.isArray(n)||typeof n.iss!="string"||n.iss.length===0||typeof n.sub!="string"||n.sub.length===0)throw new Error("missing identity claims");return {iss:n.iss,sub:n.sub}}catch{throw v()}}function v(){return new d("ACCESS_TOKEN_INVALID","Access token identity could not be verified \u2014 please log in again")}exports.ACCOUNT_BASE_URL_ENV=x;exports.ACCOUNT_ISSUER_ENV=b;exports.AUTH_JSON_FILENAME=G;exports.AUTH_JSON_VERSION=N;exports.AccountAuthError=s;exports.AccountConfigurationError=c;exports.AuthClient=S;exports.AuthClientError=s;exports.AuthError=s;exports.AuthJsonStore=f;exports.AuthJsonValidationError=u;exports.DEVICE_CODE_GRANT_TYPE=g;exports.DEVICE_CODE_PATH=j;exports.LoginRequiredError=p;exports.MARKETPLACE_URL_ENV=L;exports.OAUTH_CLIENT_ID=w;exports.REVOKE_PATH=X;exports.SessionManager=O;exports.SessionManagerError=d;exports.TOKEN_PATH=W;exports.appendEndpoint=C;exports.authJsonPath=K;exports.clearAuthJson=ae;exports.isAuthJsonV2=se;exports.parseAuthJson=B;exports.readAuthJson=ie;exports.resolveAccountBaseUrl=T;exports.resolveAccountIssuer=k;exports.resolveMarketplaceUrl=F;exports.validateAuthJson=A;exports.writeAuthJson=ce;
@@ -0,0 +1,47 @@
1
+ import { type OAuthTokenResponse } from './auth-client';
2
+ import { type AuthJsonV2 } from './auth-json';
3
+ export interface AuthSessionStore {
4
+ read(): AuthJsonV2 | null;
5
+ write(value: AuthJsonV2): void;
6
+ clear(): void;
7
+ }
8
+ export interface AccountAuthClient {
9
+ exchangeDeviceCode(deviceCode: string): Promise<OAuthTokenResponse>;
10
+ refreshToken(refreshToken: string): Promise<OAuthTokenResponse>;
11
+ }
12
+ export interface SessionManagerOptions {
13
+ client?: AccountAuthClient;
14
+ authClient?: AccountAuthClient;
15
+ store?: AuthSessionStore;
16
+ storage?: AuthSessionStore;
17
+ refreshSkewSeconds?: number;
18
+ now?: () => number;
19
+ nowSeconds?: () => number;
20
+ }
21
+ export type AuthJsonStorage = AuthSessionStore;
22
+ export declare class SessionManager {
23
+ private readonly client;
24
+ private readonly store;
25
+ private readonly refreshSkewSeconds;
26
+ private readonly now;
27
+ private readonly nowSecondsOverride?;
28
+ private refreshPromise;
29
+ constructor(options?: SessionManagerOptions | AccountAuthClient, store?: AuthSessionStore);
30
+ getSession(): AuthJsonV2 | null;
31
+ isLoggedIn(): boolean;
32
+ getAccessToken(): Promise<string>;
33
+ getValidAccessToken(): Promise<string>;
34
+ getToken(): Promise<string>;
35
+ refresh(): Promise<AuthJsonV2>;
36
+ loginWithDeviceCode(deviceCode: string): Promise<AuthJsonV2>;
37
+ login(deviceCode: string): Promise<AuthJsonV2>;
38
+ setSession(token: OAuthTokenResponse): Promise<AuthJsonV2>;
39
+ clear(): void;
40
+ withAccessToken<T>(callback: (accessToken: string) => Promise<T>): Promise<T>;
41
+ private readSession;
42
+ private requireSession;
43
+ private epochSeconds;
44
+ private refreshSession;
45
+ private performRefresh;
46
+ private persistTokenResponse;
47
+ }
@@ -1,3 +1,10 @@
1
+ export interface ActivityLogRenderedEntry {
2
+ entry: ActivityEntry;
3
+ newestIndex: number;
4
+ bodyLimitChars: number;
5
+ bodyCharsShown: number | null;
6
+ originalBodyChars: number | null;
7
+ }
1
8
  export declare function checkStale(tool: string, input: string | null, taskCompletedAt?: string | null): 'ok' | 'stale' | 'unknown';
2
9
  export interface ActivityEntry {
3
10
  tool: string;
@@ -6,18 +13,60 @@ export interface ActivityEntry {
6
13
  status: 'ok' | 'stale' | 'unknown';
7
14
  reusable: boolean;
8
15
  }
9
- export interface ActivityLogResult {
16
+ export type CountTokens = (text: string) => number;
17
+ export type ActivityLogOmissionReason = 'token_cap' | 'repository_limit';
18
+ export interface ActivityLogOmission {
19
+ reason: ActivityLogOmissionReason;
20
+ count: number;
21
+ message: string;
22
+ }
23
+ export interface ActivityLogTaskResult {
24
+ taskId: string;
25
+ taskDistance: number;
26
+ tokenCap: number;
27
+ tokenCount: number;
28
+ includedEntries: number;
29
+ omittedEntries: number;
30
+ totalEntries: number;
31
+ omissions: ActivityLogOmission[];
32
+ entries: ActivityLogRenderedEntry[];
33
+ activityLog: string;
34
+ }
35
+ export interface ActivityLogByTaskResult {
10
36
  threadId: string;
11
37
  agentId: string;
12
38
  lookback: number;
13
- entries: ActivityEntry[];
14
- totalEntries: number;
15
- truncated: boolean;
39
+ activityLogTokenBudget: number;
40
+ baseEntryChars: number;
41
+ tasks: ActivityLogTaskResult[];
42
+ activityLogByTask: Map<string, string>;
43
+ }
44
+ export interface BuildActivityLogByTaskBudgetOptions {
45
+ threadId: string;
46
+ agentId: string;
47
+ lookback: number;
48
+ maxEntryChars?: number;
49
+ activityLogTokenBudget: number;
50
+ countTokens: CountTokens;
51
+ repositoryEntryLimit?: number;
16
52
  }
17
- export declare function buildActivityLogByTask(opts: {
53
+ export interface BuildActivityLogByTaskOptions {
18
54
  threadId: string;
19
55
  agentId: string;
20
56
  lookback: number;
21
57
  maxEntryChars?: number;
22
58
  decayRate?: number;
23
- }): Map<string, string>;
59
+ activityLogTokenBudget?: number;
60
+ countTokens?: CountTokens;
61
+ repositoryEntryLimit?: number;
62
+ }
63
+ export interface ActivityLogResult {
64
+ threadId: string;
65
+ agentId: string;
66
+ lookback: number;
67
+ entries: ActivityEntry[];
68
+ totalEntries: number;
69
+ truncated: boolean;
70
+ }
71
+ export declare function buildActivityLogByTaskResult(opts: BuildActivityLogByTaskBudgetOptions): ActivityLogByTaskResult;
72
+ export declare function buildActivityLogByTask(opts: BuildActivityLogByTaskOptions): Map<string, string>;
@@ -0,0 +1,17 @@
1
+ export declare function normalizeClaudeMode(mode: string): string;
2
+ export interface AgentOptionsLike {
3
+ query?: unknown;
4
+ execute?: unknown;
5
+ [key: string]: unknown;
6
+ }
7
+ export interface CanonicalizeAgentOptionsInput {
8
+ provider?: string;
9
+ model?: string;
10
+ options: unknown;
11
+ }
12
+ export interface CanonicalizeAgentOptionsResult {
13
+ options: unknown;
14
+ changed: boolean;
15
+ removed: string[];
16
+ }
17
+ export declare function canonicalizeAgentOptions(input: CanonicalizeAgentOptionsInput): CanonicalizeAgentOptionsResult;
@@ -0,0 +1,33 @@
1
+ import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'fs';
2
+ import type { LocalServerSettings } from '../local-server/types';
3
+ export interface GlobalSettings {
4
+ cron?: {
5
+ auto_start?: boolean;
6
+ [key: string]: unknown;
7
+ };
8
+ ai_server?: LocalServerSettings;
9
+ [key: string]: unknown;
10
+ }
11
+ export type DeepPartial<T> = T extends object ? {
12
+ [K in keyof T]?: DeepPartial<T[K]>;
13
+ } : T;
14
+ export interface GlobalSettingsStore {
15
+ read(): GlobalSettings;
16
+ update(patch: DeepPartial<GlobalSettings>): GlobalSettings;
17
+ set(key: string, value: unknown): GlobalSettings;
18
+ remove(key: string): GlobalSettings;
19
+ readonly path: string;
20
+ }
21
+ interface GlobalSettingsFileSystem {
22
+ mkdirSync: typeof mkdirSync;
23
+ readFileSync: typeof readFileSync;
24
+ renameSync: typeof renameSync;
25
+ statSync: typeof statSync;
26
+ writeFileSync: typeof writeFileSync;
27
+ }
28
+ export interface CreateGlobalSettingsStoreOptions {
29
+ filePath?: string;
30
+ fileSystem?: Partial<GlobalSettingsFileSystem>;
31
+ }
32
+ export declare function createGlobalSettingsStore(opts?: CreateGlobalSettingsStoreOptions): GlobalSettingsStore;
33
+ export {};
@@ -0,0 +1,6 @@
1
+ export type GrokSandbox = 'workspace' | 'read-only' | 'off';
2
+ export interface GrokNativeOptions {
3
+ alwaysApprove?: boolean;
4
+ sandbox?: GrokSandbox;
5
+ }
6
+ export declare function migrateGrokLegacyMode<T>(slot: T): T;
@@ -0,0 +1,31 @@
1
+ export declare const CLAUDE_OPUS_4_8_BASE_MODEL_ID: "claude-opus-4-8";
2
+ export declare const CLAUDE_OPUS_4_8_LEGACY_MODEL_ID: "claude-opus-4-8[1m]";
3
+ export declare const CLAUDE_MODEL_COMPATIBILITY_PAIRS: readonly [{
4
+ readonly baseModelId: "claude-opus-4-8";
5
+ readonly catalogModelId: "claude-opus-4-8[1m]";
6
+ }, {
7
+ readonly baseModelId: "claude-opus-4-7";
8
+ readonly catalogModelId: "claude-opus-4-7[1m]";
9
+ }, {
10
+ readonly baseModelId: "claude-opus-4-6";
11
+ readonly catalogModelId: "claude-opus-4-6[1m]";
12
+ }, {
13
+ readonly baseModelId: "claude-sonnet-4-6";
14
+ readonly catalogModelId: "claude-sonnet-4-6[1m]";
15
+ }];
16
+ export declare function normalizeAntigravityMode(mode: string): string;
17
+ export declare function resolveCatalogModelId(model: string): string;
18
+ export declare const ANTIGRAVITY_MODEL_COMPATIBILITY: ReadonlyArray<{
19
+ legacyId: string;
20
+ model: string;
21
+ effort?: string;
22
+ }>;
23
+ export type AntigravityResolvedModel = {
24
+ model?: string;
25
+ effort?: string;
26
+ };
27
+ export declare function resolveAntigravityModel(model?: string): AntigravityResolvedModel;
28
+ export declare function resolveProviderCatalogModel(providerId: string, model?: string): {
29
+ model?: string;
30
+ effort?: string;
31
+ };
@@ -1,7 +1,20 @@
1
+ import type { ModelApiPricing } from './pricing.types.js';
2
+ export declare const MODEL_TIERS: readonly ["flagship", "balanced", "speed"];
3
+ export type ModelTier = (typeof MODEL_TIERS)[number];
4
+ export declare const EFFORT_LEVELS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
5
+ export type EffortLevel = (typeof EFFORT_LEVELS)[number];
6
+ export type KnownEffortLevel = EffortLevel;
7
+ export declare const PROVIDER_ARGV_EFFORTS: Record<string, readonly string[]>;
8
+ export declare const MODEL_CATALOG_VERSION = 22;
9
+ export declare const MODEL_CATALOG_UPDATED = "2026-09-04T00:00:00Z";
1
10
  export interface ModelCatalogEntry {
2
11
  id: string;
3
12
  name: string;
4
13
  description?: string;
14
+ contextWindowTokens?: number;
15
+ tier?: ModelTier;
16
+ recommended?: boolean;
17
+ apiPricing?: ModelApiPricing;
5
18
  }
6
19
  export interface ProviderModeEntry {
7
20
  id: string;
@@ -12,11 +25,35 @@ export interface ProviderModelOverride {
12
25
  effort?: string[];
13
26
  defaultEffort?: string;
14
27
  }
28
+ export type ProviderOptionSpec = {
29
+ key: string;
30
+ type: 'boolean';
31
+ } | {
32
+ key: string;
33
+ type: 'enum';
34
+ values: string[];
35
+ };
36
+ export interface ProviderExecutionOptions {
37
+ mode: string;
38
+ effort: string;
39
+ providerOptions?: Record<string, unknown>;
40
+ }
41
+ export interface ProviderDefaultProfile {
42
+ model: string;
43
+ query: ProviderExecutionOptions;
44
+ execute: ProviderExecutionOptions;
45
+ }
46
+ export interface ProviderDefaults {
47
+ version: number;
48
+ providers: Record<string, ProviderDefaultProfile>;
49
+ }
15
50
  export interface ProviderCatalogEntry {
16
51
  models: ModelCatalogEntry[];
17
52
  modes: ProviderModeEntry[];
18
53
  effort: string[];
19
54
  modelOverrides: Record<string, ProviderModelOverride>;
55
+ providerOptions?: ProviderOptionSpec[];
20
56
  }
21
57
  export declare const PROVIDER_CATALOGS: Record<string, ProviderCatalogEntry>;
58
+ export declare const PROVIDER_DEFAULTS: ProviderDefaults;
22
59
  export declare const PROVIDER_MODELS: Record<string, ModelCatalogEntry[]>;
@@ -1,3 +1,4 @@
1
+ export declare const MIN_REMOTE_CATALOG_VERSION = 20;
1
2
  export declare function initModelsRemote(opts?: {
2
3
  endpoint?: string;
3
4
  ttlMs?: number;
@@ -3,6 +3,7 @@ export interface OverdriveProfile {
3
3
  model?: string;
4
4
  mode?: string;
5
5
  effort?: string;
6
+ providerOptions?: Record<string, unknown>;
6
7
  }
7
8
  export type OverdriveSignalInput = boolean | {
8
9
  mode?: 'count' | 'latch';
@@ -20,5 +21,11 @@ export interface OverdriveResolution {
20
21
  mode?: string;
21
22
  effort?: string;
22
23
  crossProvider: boolean;
24
+ providerOptions?: Record<string, unknown>;
23
25
  }
24
26
  export declare function resolveOverdrive(agentOptions: unknown, mode: 'query' | 'execute', baseProvider: string, signal: OverdriveSignal): OverdriveResolution;
27
+ export interface ModeOverrideResolution {
28
+ provider?: string;
29
+ model?: string;
30
+ }
31
+ export declare function resolveModeOverride(agentOptions: unknown, mode: 'query' | 'execute'): ModeOverrideResolution;
@@ -1,9 +1,12 @@
1
- import type { ModelPricing } from './pricing.types.js';
2
- export type { ModelPricing } from './pricing.types.js';
3
- export { MODEL_PRICING } from './pricing.generated.js';
1
+ import type { ModelApiPricing, ModelPricing } from './pricing.types.js';
2
+ export type { ModelApiPricing, ModelPricing } from './pricing.types.js';
3
+ export { MODEL_PRICING, UNPUBLISHED_MODEL_IDS } from './pricing.generated.js';
4
4
  export declare function setPricingOverride(models: Record<string, ModelPricing>): void;
5
5
  export declare function clearPricingOverride(): void;
6
+ export declare function setApiPricingOverride(models: Record<string, ModelApiPricing>): void;
7
+ export declare function clearApiPricingOverride(): void;
8
+ export declare function normalizeModel(model: string): string;
9
+ export declare function lookupApiPricing(model: string | null | undefined): ModelApiPricing | undefined;
6
10
  export declare function getPricing(model: string | null | undefined): ModelPricing;
7
- export declare function getCostMultiplier(model: string | null | undefined, date?: Date): number;
8
- export declare function calculateCost(inputTokens: number, outputTokens: number, model: string | null | undefined, cachedInputTokens?: number, date?: Date): number;
11
+ export declare function calculateCost(inputTokens: number, outputTokens: number, model: string | null | undefined, cachedInputTokens?: number, _date?: Date): number;
9
12
  export declare function resolveCost(costUsd: number | undefined, inputTokens: number | undefined, outputTokens: number | undefined, cachedInputTokens: number | undefined, model: string | null | undefined, date?: Date): number;
@@ -1,2 +1,6 @@
1
1
  import type { ModelPricing } from './pricing.types.js';
2
2
  export declare const MODEL_PRICING: Record<string, ModelPricing>;
3
+ export declare const MODEL_PRICING_VERSION = 22;
4
+ export declare const MODEL_PRICING_UPDATED = "2026-09-04T00:00:00Z";
5
+ export declare const UNPUBLISHED_MODEL_IDS: ReadonlySet<string>;
6
+ export declare const CATALOG_MODEL_IDS: ReadonlySet<string>;
@@ -2,14 +2,8 @@ export interface ModelPricing {
2
2
  input: number;
3
3
  cachedInput: number;
4
4
  output: number;
5
- metadata?: {
6
- billing?: {
7
- peakMultiplier: number;
8
- offPeakMultiplier: number;
9
- peakHoursUtc?: {
10
- start: number;
11
- end: number;
12
- };
13
- };
14
- };
5
+ }
6
+ export interface ModelApiPricing {
7
+ inputPerMillionTokensUsd: number;
8
+ outputPerMillionTokensUsd: number;
15
9
  }
@@ -1,5 +1,8 @@
1
1
  export interface TimeoutConfig {
2
2
  queryMs: number;
3
3
  executeMs: number;
4
+ idleMs: number;
4
5
  }
6
+ export declare const DEFAULT_IDLE_MS: number;
7
+ export declare function parseIdleEnvOverride(env?: NodeJS.ProcessEnv): number | undefined;
5
8
  export declare function getProviderTimeoutConfig(env?: NodeJS.ProcessEnv): TimeoutConfig;
@@ -0,0 +1,19 @@
1
+ import type { CrewxProjectConfig } from '../types';
2
+ export declare const DEFAULT_WI_BOARD_ID = "default";
3
+ export declare const ARCHIVE_WI_BOARD_ID = "archive";
4
+ export declare const DEFAULT_WI_WORKFLOW_ID = "wi-default-flow";
5
+ export declare const WI_PLAN_WORKFLOW_ID = "wi-plan-flow";
6
+ export declare const WI_DEFAULT_FLOW_FILENAME = "wi-default-flow.yaml";
7
+ export declare const WI_PLAN_FLOW_FILENAME = "wi-plan-flow.yaml";
8
+ export declare const WI_BOARD_ID_PATTERN: RegExp;
9
+ export declare function isReservedWiBoardId(id: string): boolean;
10
+ export interface ResolvedWiBoard {
11
+ id: string;
12
+ name: string;
13
+ workflowId: string;
14
+ description?: string;
15
+ goalId?: string;
16
+ system: boolean;
17
+ readOnly: boolean;
18
+ }
19
+ export declare function resolveWiBoards(config: CrewxProjectConfig | undefined): ResolvedWiBoard[];
@@ -0,0 +1,61 @@
1
+ import type { ConversationHighlight, ConversationThreadState, SemanticContinuityContext, TemplateMessage } from '../conversation/types.js';
2
+ export declare const DEFAULT_PROTECTED_TURN_COUNT = 5;
3
+ export declare const DEFAULT_HIGHLIGHT_BUDGET_PERCENT = 5;
4
+ export declare const MAX_ACTIVE_HIGHLIGHTS = 12;
5
+ export declare const MAX_ACTIVE_HIGHLIGHT_CHARS = 2000;
6
+ export declare const MAX_THREAD_TITLE_CHARS = 200;
7
+ export declare const MAX_THREAD_STATE_VALUE_CHARS = 64;
8
+ export interface ConversationTurn {
9
+ taskId?: string;
10
+ messages: TemplateMessage[];
11
+ ordinal: number;
12
+ }
13
+ export interface GroupedConversationTurns {
14
+ turns: ConversationTurn[];
15
+ unpairedMessages: TemplateMessage[];
16
+ }
17
+ export interface ConversationTurnSelection {
18
+ includedTurns: ConversationTurn[];
19
+ omittedTurns: ConversationTurn[];
20
+ protectedTurns: ConversationTurn[];
21
+ tokenCount: number;
22
+ protectedTokenCount: number;
23
+ overBudget: boolean;
24
+ }
25
+ export interface SelectConversationTurnsOptions {
26
+ turns: readonly ConversationTurn[];
27
+ maxTokenCount: number;
28
+ countTokens: (text: string) => number;
29
+ protectedTurnCount?: number;
30
+ materializeTurn?: (turn: ConversationTurn) => string;
31
+ }
32
+ export interface ConversationHighlightSelection {
33
+ includedHighlights: ConversationHighlight[];
34
+ omittedHighlights: ConversationHighlight[];
35
+ truncatedHighlights: number;
36
+ representedTaskIds: string[];
37
+ unrepresentedTaskIds: string[];
38
+ tokenCount: number;
39
+ budgetTokens: number;
40
+ }
41
+ export interface SelectConversationHighlightsOptions {
42
+ highlights: readonly ConversationHighlight[];
43
+ omittedTaskIds: readonly string[];
44
+ taskOrder: readonly string[];
45
+ maxTokenCount: number;
46
+ countTokens: (text: string) => number;
47
+ applySafetyCap?: boolean;
48
+ }
49
+ export declare function getConversationMessageTaskId(message: TemplateMessage): string | undefined;
50
+ export declare function groupConversationTurns(messages: readonly TemplateMessage[]): GroupedConversationTurns;
51
+ export declare function materializeConversationTurn(turn: ConversationTurn, includeActivityLog?: boolean): string;
52
+ export declare function selectConversationTurns(options: SelectConversationTurnsOptions): ConversationTurnSelection;
53
+ export declare function buildThreadStateContext(state: ConversationThreadState | undefined): ConversationThreadState | undefined;
54
+ export declare function selectConversationHighlights(options: SelectConversationHighlightsOptions): ConversationHighlightSelection;
55
+ export interface BuildSemanticContinuityContextOptions {
56
+ highlights: readonly ConversationHighlight[];
57
+ omittedTaskIds: readonly string[];
58
+ representedTaskIds: readonly string[];
59
+ applySafetyCap?: boolean;
60
+ }
61
+ export declare function buildSemanticContinuityContext(options: BuildSemanticContinuityContextOptions): SemanticContinuityContext;