@crewx/sdk 0.9.0-rc.7 → 0.9.0-rc.71

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 (143) hide show
  1. package/README.md +1 -1
  2. package/dist/activity-log/builder.d.ts +55 -6
  3. package/dist/config/canonicalize-agent-options.d.ts +17 -0
  4. package/dist/config/global-settings.d.ts +33 -0
  5. package/dist/config/migrate-grok-mode.d.ts +6 -0
  6. package/dist/config/model-compat.d.ts +31 -0
  7. package/dist/config/models.generated.d.ts +33 -0
  8. package/dist/config/models.remote.d.ts +1 -0
  9. package/dist/config/overdrive.d.ts +7 -0
  10. package/dist/config/pricing.d.ts +8 -5
  11. package/dist/config/pricing.generated.d.ts +4 -0
  12. package/dist/config/pricing.types.d.ts +4 -10
  13. package/dist/config/timeout.config.d.ts +3 -0
  14. package/dist/config/wi-boards.d.ts +19 -0
  15. package/dist/context-budget/index.d.ts +105 -0
  16. package/dist/conversation/index.d.ts +1 -1
  17. package/dist/conversation/to-template-messages.d.ts +7 -0
  18. package/dist/conversation/types.d.ts +1 -0
  19. package/dist/desktop/command-runner.d.ts +4 -0
  20. package/dist/desktop/default-adapters.d.ts +4 -0
  21. package/dist/desktop/global-install.d.ts +19 -0
  22. package/dist/desktop/index.d.ts +2 -0
  23. package/dist/desktop/index.js +3 -0
  24. package/dist/desktop/install.d.ts +5 -0
  25. package/dist/desktop/lnk.d.ts +22 -0
  26. package/dist/desktop/manifest.d.ts +21 -0
  27. package/dist/desktop/types.d.ts +67 -0
  28. package/dist/desktop/version.d.ts +1 -0
  29. package/dist/desktop/windows-paths.d.ts +21 -0
  30. package/dist/desktop/wrapper.d.ts +18 -0
  31. package/dist/esm/desktop/index.js +3 -0
  32. package/dist/esm/index.js +271 -102
  33. package/dist/esm/plugins/index.js +166 -75
  34. package/dist/esm/publish/index.js +1 -0
  35. package/dist/esm/repository/index.js +184 -78
  36. package/dist/esm/testing/index.js +1 -1
  37. package/dist/events/types.d.ts +4 -0
  38. package/dist/facade/Crewx.d.ts +30 -0
  39. package/dist/index.browser.d.ts +7 -1
  40. package/dist/index.browser.js +6 -2
  41. package/dist/index.d.ts +36 -8
  42. package/dist/index.js +271 -102
  43. package/dist/internal/windows-spawn.d.ts +10 -0
  44. package/dist/local-server/base-url.d.ts +18 -0
  45. package/dist/local-server/index.d.ts +8 -0
  46. package/dist/local-server/opencode.d.ts +8 -0
  47. package/dist/local-server/probe.d.ts +3 -0
  48. package/dist/local-server/runtime.d.ts +26 -0
  49. package/dist/local-server/types.d.ts +43 -0
  50. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  51. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  52. package/dist/migrations/0010_analyze_stats.sql +6 -0
  53. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  54. package/dist/migrations/0012_blue_turbo.sql +23 -0
  55. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  56. package/dist/migrations/0014_organic_mongu.sql +73 -0
  57. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  58. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  59. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  60. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  61. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  62. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  63. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  64. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  65. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  66. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  67. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  68. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  69. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  70. package/dist/migrations/meta/_journal.json +71 -1
  71. package/dist/paths.d.ts +1 -0
  72. package/dist/plugin/types.d.ts +1 -0
  73. package/dist/plugins/index.js +166 -75
  74. package/dist/provider/acp/connection.d.ts +4 -0
  75. package/dist/provider/acp/meta.d.ts +11 -0
  76. package/dist/provider/bridge.d.ts +16 -1
  77. package/dist/provider/classify-task-error.d.ts +2 -0
  78. package/dist/provider/cli/adapter.types.d.ts +6 -0
  79. package/dist/provider/cli/adapters/cli-knob.util.d.ts +8 -0
  80. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  81. package/dist/provider/cli/adapters/index.d.ts +1 -0
  82. package/dist/provider/cli/index.d.ts +1 -1
  83. package/dist/provider/cli/meta.d.ts +5 -0
  84. package/dist/provider/errors.d.ts +1 -0
  85. package/dist/provider/idle-watchdog.d.ts +19 -0
  86. package/dist/provider/models.d.ts +17 -12
  87. package/dist/provider/order.d.ts +1 -1
  88. package/dist/provider/parse-usage.d.ts +6 -0
  89. package/dist/provider/provider-selection.d.ts +8 -0
  90. package/dist/provider/redact-technical-message.d.ts +1 -0
  91. package/dist/provider/task-error.types.d.ts +16 -0
  92. package/dist/publish/auth-boundary.d.ts +22 -0
  93. package/dist/publish/auth-json.d.ts +11 -0
  94. package/dist/publish/constants.d.ts +6 -0
  95. package/dist/publish/index.d.ts +30 -0
  96. package/dist/publish/index.js +1 -0
  97. package/dist/publish/manifest.d.ts +17 -0
  98. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  99. package/dist/publish/pack.d.ts +2 -0
  100. package/dist/publish/scan.d.ts +9 -0
  101. package/dist/publish/secrets.d.ts +6 -0
  102. package/dist/publish/upload.d.ts +18 -0
  103. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  104. package/dist/repository/db.d.ts +8 -0
  105. package/dist/repository/index.d.ts +16 -3
  106. package/dist/repository/index.js +184 -78
  107. package/dist/repository/notification.repository.d.ts +58 -0
  108. package/dist/repository/project.repository.d.ts +90 -0
  109. package/dist/repository/task-log-migration.d.ts +74 -0
  110. package/dist/repository/task-log.repository.d.ts +44 -0
  111. package/dist/repository/task.repository.d.ts +114 -0
  112. package/dist/repository/thread.repository.d.ts +5 -2
  113. package/dist/repository/usage-report.repository.d.ts +27 -0
  114. package/dist/schema/agent-suggestions.d.ts +199 -0
  115. package/dist/schema/index.d.ts +7 -0
  116. package/dist/schema/notifications.d.ts +303 -0
  117. package/dist/schema/projects.d.ts +610 -0
  118. package/dist/schema/task-log-events.d.ts +119 -0
  119. package/dist/schema/tasks.d.ts +53 -0
  120. package/dist/schema/ui-action-receipts.d.ts +303 -0
  121. package/dist/schema/ui-instances.d.ts +267 -0
  122. package/dist/schema/usage-reports.d.ts +252 -0
  123. package/dist/testing/index.js +1 -1
  124. package/dist/types/index.d.ts +445 -3
  125. package/dist/ui-card/index.d.ts +2 -0
  126. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  127. package/dist/ui-instance/definition.d.ts +6 -0
  128. package/dist/ui-instance/errors.d.ts +17 -0
  129. package/dist/ui-instance/index.d.ts +6 -0
  130. package/dist/ui-instance/json.d.ts +5 -0
  131. package/dist/ui-instance/runtime.d.ts +13 -0
  132. package/dist/ui-instance/store.d.ts +65 -0
  133. package/dist/ui-instance/types.d.ts +200 -0
  134. package/dist/utils/crewx-home.d.ts +1 -0
  135. package/dist/utils/id.d.ts +1 -1
  136. package/dist/utils/timestamp.d.ts +1 -0
  137. package/dist/wi/create.d.ts +48 -0
  138. package/dist/wi/select.d.ts +20 -0
  139. package/package.json +18 -2
  140. package/templates/agents/default.yaml +175 -117
  141. package/templates/documents/crewx-manual.md +138 -138
  142. package/templates/workflows/wi-default-flow.yaml +65 -0
  143. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -6,6 +6,7 @@ export interface AcpConnectionOptions {
6
6
  env?: Record<string, string>;
7
7
  cwd?: string;
8
8
  timeoutMs?: number;
9
+ idleMs?: number;
9
10
  onStderr?: (line: string) => void;
10
11
  onPid?: (pid: number) => void;
11
12
  configOptions?: Record<string, string>;
@@ -18,6 +19,9 @@ export declare class AcpConnection {
18
19
  private stderrBuffer;
19
20
  private collectedStderr;
20
21
  private pendingUpdateCallback;
22
+ private idleWatchdog;
23
+ private idleReject;
24
+ private idlePromise;
21
25
  private authMethods;
22
26
  private _initResponse;
23
27
  get initResponse(): InitializeResponse | null;
@@ -1,3 +1,7 @@
1
+ import type { ProviderDefaultProfile } from '../models.js';
2
+ import type { ProviderOptionSpec } from '../models.js';
3
+ import type { ModelTier } from '../../config/models.generated.js';
4
+ import type { ModelApiPricing } from '../../config/pricing.types.js';
1
5
  import type { InitializeResponse, NewSessionResponse } from './types.js';
2
6
  export interface AcpProviderMetaResult {
3
7
  id: string;
@@ -11,11 +15,18 @@ export interface AcpProviderMetaResult {
11
15
  models: Array<{
12
16
  id: string;
13
17
  name?: string;
18
+ description?: string;
19
+ contextWindowTokens?: number;
20
+ tier?: ModelTier;
21
+ recommended?: boolean;
22
+ apiPricing?: ModelApiPricing;
14
23
  }>;
15
24
  modelOverrides?: Record<string, {
16
25
  effort?: string[];
17
26
  defaultEffort?: string;
18
27
  }>;
28
+ providerOptions?: ProviderOptionSpec[];
29
+ defaults?: ProviderDefaultProfile;
19
30
  capabilities: Record<string, boolean>;
20
31
  }
21
32
  declare function extractProviderMeta(adapterId: string, displayName: string | undefined, initResponse: InitializeResponse, sessionResponse: NewSessionResponse): AcpProviderMetaResult;
@@ -3,8 +3,10 @@ export declare function parseStreamJsonOutput(raw: string): string;
3
3
  export declare function parseResultEventUsage(raw: string): ProviderUsage | null;
4
4
  export { ProviderError, IdleTimeoutError, TotalTimeoutError, type ProviderErrorCode, type ProviderErrorKind, type ProviderErrorOptions, } from './errors.js';
5
5
  export declare function shouldFallbackToGhCopilot(providerId: string, err: unknown, platform?: NodeJS.Platform): boolean;
6
+ export declare const KILL_GRACE_MS = 2000;
6
7
  export interface RunCliProcessOptions {
7
8
  timeoutMs?: number;
9
+ idleMs?: number;
8
10
  env?: Record<string, string>;
9
11
  cwd?: string;
10
12
  onOutput?: (line: string, level: 'stdout' | 'stderr') => void;
@@ -37,6 +39,11 @@ export declare class ClientToolCallRequiredError extends Error {
37
39
  constructor(toolCall: ClientToolCall, continuationState: ContinuationState);
38
40
  }
39
41
  export type ProviderFactory = (id: string, providerStr: string) => ProviderRuntime;
42
+ export type AdditionalArgsProvider = (ctx: {
43
+ providerStr: string;
44
+ providerId: string;
45
+ mode?: string;
46
+ }) => string[];
40
47
  export declare function registerProviderFactory(namespace: string, factory: ProviderFactory): void;
41
48
  export interface ProviderUsage {
42
49
  inputTokens: number;
@@ -48,10 +55,13 @@ export interface ProviderQueryOptions {
48
55
  model?: string;
49
56
  effort?: string;
50
57
  mode?: string;
58
+ providerOptions?: Record<string, unknown>;
51
59
  context?: string;
52
60
  systemPrompt?: string;
53
61
  additionalArgs?: string[];
54
62
  resumeSessionId?: string;
63
+ providerSessionId?: string;
64
+ onProviderSessionId?: (id: string) => void;
55
65
  onOutput?: (line: string, level: 'stdout' | 'stderr') => void;
56
66
  onPid?: (pid: number) => void;
57
67
  onCommand?: (command: string) => void;
@@ -62,6 +72,7 @@ export interface ProviderQueryOptions {
62
72
  env?: Record<string, string>;
63
73
  cwd?: string;
64
74
  timeoutMs?: number;
75
+ idleMs?: number;
65
76
  configOptions?: Record<string, string>;
66
77
  tools?: import('../facade/Crewx').ToolDefinition[];
67
78
  maxSteps?: number;
@@ -76,4 +87,8 @@ export interface ProviderRuntime {
76
87
  }>, options?: ProviderQueryOptions): Promise<string>;
77
88
  dispose?(): Promise<void>;
78
89
  }
79
- export declare function createProvider(providerStr: string): ProviderRuntime;
90
+ export declare function createProvider(providerStr: string, additionalArgsProvider?: AdditionalArgsProvider): ProviderRuntime;
91
+ export declare function mergeAdditionalArgs(options: ProviderQueryOptions | undefined, provider: AdditionalArgsProvider | undefined, ctx: {
92
+ providerStr: string;
93
+ providerId: string;
94
+ }): ProviderQueryOptions;
@@ -0,0 +1,2 @@
1
+ import type { TaskErrorProjection } from './task-error.types.js';
2
+ export declare function classifyTaskError(input: unknown): TaskErrorProjection;
@@ -1,18 +1,24 @@
1
1
  import type { ProviderQueryOptions, ProviderUsage } from '../bridge.js';
2
2
  import type { TaskLogEntry } from '../../types/task-log.types.js';
3
+ import type { ModelTier } from '../../config/models.generated.js';
3
4
  import { ProviderError } from '../errors.js';
4
5
  export interface CliProviderAdapter {
5
6
  readonly command: string;
7
+ createSessionId?(): string;
6
8
  readonly meta?: {
7
9
  displayName?: string;
8
10
  models?: Array<{
9
11
  id: string;
10
12
  name?: string;
13
+ description?: string;
14
+ contextWindowTokens?: number;
15
+ tier?: ModelTier;
11
16
  }>;
12
17
  defaultTimeoutMs?: {
13
18
  query?: number;
14
19
  execute?: number;
15
20
  };
21
+ defaultIdleMs?: number;
16
22
  capabilities?: {
17
23
  resume?: boolean;
18
24
  image?: boolean;
@@ -3,5 +3,13 @@ export declare function decodeModelEffort(model?: string): {
3
3
  effort?: string;
4
4
  };
5
5
  export declare function codexModeArgs(mode?: string): string[];
6
+ export declare function codexResumeModeArgs(mode?: string): string[];
6
7
  export declare function codexEffortArgs(effort?: string): string[];
7
8
  export declare function claudeModeArgs(mode?: string): string[];
9
+ export declare function claudeEffortArgs(effort?: string): string[];
10
+ export declare function grokModeArgs(mode?: string): string[];
11
+ export declare function grokAlwaysApproveArgs(alwaysApprove?: unknown): string[];
12
+ export declare function grokSandboxArgs(sandbox?: unknown, onWarning?: (message: string) => void): string[];
13
+ export declare function grokEffortArgs(effort?: string): string[];
14
+ export declare function antigravityModeArgs(mode?: string): string[];
15
+ export declare function antigravityEffortArgs(effort?: string): string[];
@@ -0,0 +1,2 @@
1
+ import type { CliProviderAdapter } from '../adapter.types.js';
2
+ export declare const grokAdapter: CliProviderAdapter;
@@ -5,6 +5,7 @@ export { copilotAdapter } from './copilot.js';
5
5
  export { codexAdapter } from './codex.js';
6
6
  export { opencodeAdapter } from './opencode.js';
7
7
  export { antigravityAdapter } from './antigravity.js';
8
+ export { grokAdapter } from './grok.js';
8
9
  export { isAgentCallCommand, parseAgentCall } from './agent-call.util.js';
9
10
  export declare const BUILTIN_ADAPTERS: Record<string, CliProviderAdapter>;
10
11
  export declare function parseStdoutEvent(timestamp: string, message: string, providerId?: string): TaskLogEntry[];
@@ -1,3 +1,3 @@
1
- export { BUILTIN_ADAPTERS, parseStdoutEvent, claudeAdapter, copilotAdapter, codexAdapter, opencodeAdapter, antigravityAdapter, isAgentCallCommand, parseAgentCall, } from './adapters/index.js';
1
+ export { BUILTIN_ADAPTERS, parseStdoutEvent, claudeAdapter, copilotAdapter, codexAdapter, opencodeAdapter, antigravityAdapter, grokAdapter, isAgentCallCommand, parseAgentCall, } from './adapters/index.js';
2
2
  export type { CliProviderAdapter } from './adapter.types.js';
3
3
  export { RateLimitError } from './adapter.types.js';
@@ -1,4 +1,5 @@
1
1
  import type { AcpProviderMetaResult } from '../acp/meta.js';
2
+ import type { ModelTier } from '../../config/models.generated.js';
2
3
  import type { CliProviderAdapter } from './adapter.types.js';
3
4
  export declare function queryOpencodeModels(): Promise<Array<{
4
5
  id: string;
@@ -6,6 +7,10 @@ export declare function queryOpencodeModels(): Promise<Array<{
6
7
  export declare function cliAdapterMetaToProviderMeta(key: string, adapter: CliProviderAdapter, overrideModels?: Array<{
7
8
  id: string;
8
9
  name?: string;
10
+ description?: string;
11
+ contextWindowTokens?: number;
12
+ tier?: ModelTier;
13
+ recommended?: boolean;
9
14
  }>): AcpProviderMetaResult | null;
10
15
  export declare function queryAllCliProviderMetas(options?: {
11
16
  includeOpencodeRuntimeModels?: boolean;
@@ -10,6 +10,7 @@ export declare class ProviderError extends Error {
10
10
  readonly code: ProviderErrorCode;
11
11
  readonly kind?: ProviderErrorKind;
12
12
  readonly retryAfterMs?: number;
13
+ stdout?: string;
13
14
  constructor(message: string, providerStr: string, options?: ProviderErrorOptions);
14
15
  }
15
16
  export declare class IdleTimeoutError extends ProviderError {
@@ -0,0 +1,19 @@
1
+ export interface IdleWatchdogOptions {
2
+ timeoutMs: number;
3
+ onIdle: () => void;
4
+ now?: () => number;
5
+ }
6
+ export declare class IdleWatchdog {
7
+ private readonly timeoutMs;
8
+ private readonly onIdleCb;
9
+ private readonly now;
10
+ private timer;
11
+ private lastActivity;
12
+ private settled;
13
+ constructor(options: IdleWatchdogOptions);
14
+ start(): void;
15
+ refresh(): void;
16
+ stop(): void;
17
+ private scheduleCheck;
18
+ private fireIdle;
19
+ }
@@ -1,9 +1,22 @@
1
- import { type ModelCatalogEntry, type ProviderCatalogEntry, type ProviderModeEntry, type ProviderModelOverride } from '../config/models.generated.js';
2
- export type { ModelCatalogEntry, ProviderCatalogEntry, ProviderModeEntry, ProviderModelOverride, } from '../config/models.generated.js';
1
+ import { type ModelCatalogEntry, type ModelTier, type ProviderCatalogEntry, type ProviderDefaultProfile, type ProviderModeEntry, type ProviderModelOverride } from '../config/models.generated.js';
2
+ import type { ModelApiPricing } from '../config/pricing.types.js';
3
+ export type { ModelTier, ModelCatalogEntry, ProviderCatalogEntry, ProviderDefaultProfile, ProviderDefaults, ProviderModeEntry, ProviderOptionSpec, ProviderModelOverride, } from '../config/models.generated.js';
4
+ export type ModelMergeEntry = {
5
+ id: string;
6
+ name?: string;
7
+ description?: string;
8
+ contextWindowTokens?: number;
9
+ tier?: ModelTier;
10
+ recommended?: boolean;
11
+ apiPricing?: ModelApiPricing;
12
+ };
3
13
  export declare function setModelsOverride(providers: Record<string, ProviderCatalogEntry | ModelCatalogEntry[]>): void;
4
14
  export declare function clearModelsOverride(): void;
15
+ export declare function setModelsDefaultsOverride(providers: Record<string, ProviderDefaultProfile>): void;
16
+ export declare function clearModelsDefaultsOverride(): void;
5
17
  export declare function getProviderModels(provider: string): ModelCatalogEntry[];
6
18
  export declare function getProviderCatalog(provider: string): ProviderCatalogEntry;
19
+ export declare function getProviderDefaultProfile(provider: string): ProviderDefaultProfile | undefined;
7
20
  export declare function getProviderModes(provider: string): ProviderModeEntry[];
8
21
  export declare function getProviderEffort(provider: string, model?: string): string[];
9
22
  export declare function getProviderModelOverrides(provider: string): Record<string, ProviderModelOverride>;
@@ -11,13 +24,5 @@ export declare function getClaudeModels(): ModelCatalogEntry[];
11
24
  export declare function getCodexModels(): ModelCatalogEntry[];
12
25
  export declare function getCopilotModels(): ModelCatalogEntry[];
13
26
  export declare function getAntigravityModels(): ModelCatalogEntry[];
14
- export declare function mergeModels(a: Array<{
15
- id: string;
16
- name?: string;
17
- }>, b: Array<{
18
- id: string;
19
- name?: string;
20
- }>): Array<{
21
- id: string;
22
- name?: string;
23
- }>;
27
+ export declare function mergeModels(a: ModelMergeEntry[], b: ModelMergeEntry[]): ModelMergeEntry[];
28
+ export declare function withApiPricing(models: ModelMergeEntry[]): ModelMergeEntry[];
@@ -1,4 +1,4 @@
1
- export declare const PROVIDER_ORDER: readonly ["codex", "claude", "opencode", "antigravity", "copilot"];
1
+ export declare const PROVIDER_ORDER: readonly ["codex", "claude", "grok", "opencode", "antigravity", "copilot"];
2
2
  export declare function providerRank(id: string): number;
3
3
  export declare function compareProviders(a: string, b: string): number;
4
4
  export declare function normalizeProviderId(provider?: string): string;
@@ -3,4 +3,10 @@ export interface ParsedUsage {
3
3
  outputTokens: number;
4
4
  cachedInputTokens: number;
5
5
  }
6
+ export interface ClaudePartialUsage {
7
+ inputTokens: number;
8
+ cachedInputTokens: number;
9
+ model?: string;
10
+ }
11
+ export declare function parseClaudePartialUsage(stdout: string): ClaudePartialUsage | undefined;
6
12
  export declare function parseUsage(stdout: string): ParsedUsage | undefined;
@@ -0,0 +1,8 @@
1
+ import type { CliProviderAdapter } from './cli/adapter.types.js';
2
+ export declare function lookupCliAdapter(providerStr: string): CliProviderAdapter | undefined;
3
+ export type ProviderAvailabilityDeps = {
4
+ lookupAdapter?: (providerStr: string) => CliProviderAdapter | undefined;
5
+ env?: NodeJS.ProcessEnv;
6
+ };
7
+ export declare function isProviderAvailable(providerStr: string, deps?: ProviderAvailabilityDeps): boolean;
8
+ export declare function selectAvailableProvider(providers: string | string[], deps?: ProviderAvailabilityDeps): string;
@@ -0,0 +1 @@
1
+ export declare function redactTechnicalMessage(value: unknown): string | undefined;
@@ -0,0 +1,16 @@
1
+ export type TaskErrorCode = 'USAGE_LIMITED' | 'CONTEXT_WINDOW_EXCEEDED' | 'INPUT_TOO_LARGE' | 'MODEL_NOT_SUPPORTED' | 'MODEL_AT_CAPACITY' | 'AUTH_REQUIRED' | 'CLI_NOT_AVAILABLE' | 'CLI_UPDATE_REQUIRED' | 'AGENT_NOT_FOUND' | 'PERMISSION_OR_TRUST' | 'TIMEOUT_OR_STUCK' | 'NETWORK_OR_PROVIDER_TRANSIENT' | 'PROVIDER_CONFIGURATION' | 'PROCESS_FAILED';
2
+ export interface TaskErrorMeta {
3
+ resetAt?: string | number;
4
+ model?: string;
5
+ cliName?: string;
6
+ envKey?: string;
7
+ upstreamType?: string;
8
+ upstreamCode?: string | number;
9
+ referenceId?: string;
10
+ technicalMessage?: string;
11
+ }
12
+ export interface TaskErrorProjection {
13
+ errorCode: TaskErrorCode | null;
14
+ errorProvider: string | null;
15
+ errorMeta?: TaskErrorMeta;
16
+ }
@@ -0,0 +1,22 @@
1
+ export type AccountAuthBoundaryErrorCode = 'ACCOUNT_USER_PAIR_MISSING' | 'ACCOUNT_USER_ISSUER_MISSING' | 'ACCOUNT_USER_ANON_KEY_MISSING' | 'ACCOUNT_ACCESS_TOKEN_INVALID' | 'ACCOUNT_TOKEN_ISSUER_MISMATCH' | 'ACCOUNT_TOKEN_SUB_MISMATCH' | 'ACCOUNT_AUTH_JSON_ISSUER_MISMATCH' | 'ACCOUNT_AUTH_JSON_SUB_MISMATCH';
2
+ export declare class AccountAuthBoundaryError extends Error {
3
+ readonly code: AccountAuthBoundaryErrorCode;
4
+ constructor(code: AccountAuthBoundaryErrorCode, message: string);
5
+ }
6
+ export interface UserAccountConfig {
7
+ issuer: string;
8
+ anonKey: string;
9
+ }
10
+ export declare function resolveUserAccountConfig(env?: Readonly<Record<string, string | undefined>>): UserAccountConfig;
11
+ export interface AccessTokenIdentity {
12
+ issuer: string;
13
+ sub: string;
14
+ }
15
+ export declare function decodeAccessTokenIdentity(accessToken: string): AccessTokenIdentity;
16
+ export declare function assertUserRealmAccessToken(accessToken: string, config: Pick<UserAccountConfig, 'issuer'>, expectedSub?: string): AccessTokenIdentity;
17
+ export interface AuthJsonIdentity {
18
+ issuer: string;
19
+ sub: string;
20
+ access_token: string;
21
+ }
22
+ export declare function assertAuthJsonUserRealm(auth: AuthJsonIdentity, config: Pick<UserAccountConfig, 'issuer'>): AccessTokenIdentity;
@@ -0,0 +1,11 @@
1
+ export interface AuthJson {
2
+ version: 1;
3
+ issuer: string;
4
+ sub: string;
5
+ email: string;
6
+ access_token: string;
7
+ refresh_token: string;
8
+ expires_at: number;
9
+ updated_at: string;
10
+ }
11
+ export declare function readAuthJson(): AuthJson;
@@ -0,0 +1,6 @@
1
+ export interface ExcludeRuleDef {
2
+ label: string;
3
+ test(basename: string, relPath: string, isDir: boolean): boolean;
4
+ }
5
+ export declare const EXCLUDE_RULES: ExcludeRuleDef[];
6
+ export declare function matchExclude(basename: string, relPath: string, isDir: boolean): string | null;
@@ -0,0 +1,30 @@
1
+ import type { ExcludedEntry } from './scan';
2
+ import type { SecretFinding } from './secrets';
3
+ import type { PublishManifest } from './manifest';
4
+ import { uploadToMarketplace } from './upload';
5
+ import type { PublishUploadOptions, PublishUploadResult } from './upload';
6
+ export interface PublishOptions {
7
+ version?: string;
8
+ }
9
+ export interface PublishPlan {
10
+ manifest: PublishManifest;
11
+ included: string[];
12
+ excluded: ExcludedEntry[];
13
+ secretFindings: SecretFinding[];
14
+ }
15
+ export declare function planPublish(dir: string, opts?: PublishOptions): Promise<PublishPlan>;
16
+ export declare function packTemplate(dir: string, opts?: PublishOptions): Promise<{
17
+ manifest: PublishManifest;
18
+ tgzPath: string;
19
+ }>;
20
+ export type { PublishManifest, ManifestFile, BuildManifestOptions } from './manifest';
21
+ export type { ExcludedEntry, ScanResult } from './scan';
22
+ export type { SecretFinding } from './secrets';
23
+ export { EXCLUDE_RULES } from './constants';
24
+ export { uploadToMarketplace };
25
+ export type { PublishUploadOptions, PublishUploadResult };
26
+ export { readAuthJson } from './auth-json';
27
+ export type { AuthJson } from './auth-json';
28
+ export { AccountAuthBoundaryError, assertAuthJsonUserRealm, assertUserRealmAccessToken, decodeAccessTokenIdentity, resolveUserAccountConfig, } from './auth-boundary';
29
+ export type { AccessTokenIdentity, AccountAuthBoundaryErrorCode, AuthJsonIdentity, UserAccountConfig, } from './auth-boundary';
30
+ export { MARKETPLACE_API_PREFIX } from './marketplace-api.constants';
@@ -0,0 +1 @@
1
+ 'use strict';var y=require('path'),h=require('fs'),X=require('crypto'),W=require('js-yaml'),I=require('os'),Y=require('tar'),zlib=require('zlib');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 y__namespace=/*#__PURE__*/_interopNamespace(y);var h__namespace=/*#__PURE__*/_interopNamespace(h);var X__namespace=/*#__PURE__*/_interopNamespace(X);var W__namespace=/*#__PURE__*/_interopNamespace(W);var I__namespace=/*#__PURE__*/_interopNamespace(I);var Y__namespace=/*#__PURE__*/_interopNamespace(Y);function ae(e){let t=n=>n.replace(/[.+^${}()|[\]\\]/g,"\\$&"),s=e.split("/").map(n=>n==="**"?".*":n.split("*").map(t).join("[^/]*"));return new RegExp(`^${s.join("\\/")}$`)}function w(e,t){try{return ae(t).test(e)}catch{return false}}function C(e,...t){let r=e.split("/");if(r.length<t.length)return false;let s=r.length-t.length;return t.every((n,i)=>w(r[s+i],n))}function ce(e,t){return e.split("/").some(r=>w(r,t))}var D=[{label:".env*",test:e=>w(e,".env*")},{label:".git/",test:(e,t,r)=>r&&e===".git"},{label:"memory/",test:(e,t,r)=>r&&e==="memory"},{label:"*.key",test:e=>w(e,"*.key")},{label:"*.pem",test:e=>w(e,"*.pem")},{label:"auth.json",test:e=>e==="auth.json"},{label:"node_modules/",test:(e,t,r)=>r&&e==="node_modules"},{label:"conversations/",test:(e,t,r)=>r&&e==="conversations"},{label:".crewx/threads/",test:(e,t,r)=>r&&C(t,".crewx","threads")},{label:".crewx/crewx.db",test:(e,t,r)=>!r&&C(t,".crewx","crewx.db")},{label:".crewx/*.log",test:(e,t,r)=>!r&&C(t,".crewx","*.log")},{label:".crewx/publish/",test:(e,t,r)=>r&&C(t,".crewx","publish")},{label:".crewx/",test:(e,t)=>ce(t,".crewx")}];function v(e,t,r){for(let s of D)if(s.test(e,t,r))return s.label;return null}function J(e){let t=[],r=[];function s(n,i,a){let d;try{d=h__namespace.readdirSync(n,{withFileTypes:!0});}catch{return}d.sort((c,u)=>c.name.localeCompare(u.name));for(let c of d){let u=i?`${i}/${c.name}`:c.name,l=y__namespace.join(n,c.name);if(c.isSymbolicLink()){let p;try{p=h__namespace.statSync(l);}catch{continue}if(p.isDirectory()){r.push({path:u,rule:a??"symlink-dir"});continue}let U=a??v(c.name,u,false);U?r.push({path:u,rule:U}):t.push(u);continue}if(c.isDirectory()){let p=a??v(c.name,u,true);s(l,u,p);continue}if(c.isFile()){let p=a??v(c.name,u,false);p?r.push({path:u,rule:p}):t.push(u);}}}return s(e,"",null),t.sort(),r.sort((n,i)=>n.path<i.path?-1:n.path>i.path?1:0),{included:t,excluded:r}}var ue=[{rule:"token-prefix",regex:/\b(?:sk-|ghp_|xoxb-)[A-Za-z0-9_-]{10,}/},{rule:"private-key",regex:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{rule:"aws-access-key",regex:/\bAKIA[0-9A-Z]{16}\b/}];function le(e){return e.includes(0)}function L(e,t){let r=[];for(let s of t){let n=y__namespace.join(e,s),i;try{i=h__namespace.readFileSync(n);}catch{continue}if(le(i))continue;i.toString("utf8").split(/\r\n|\r|\n/).forEach((d,c)=>{for(let{rule:u,regex:l}of ue)l.test(d)&&r.push({path:s,line:c+1,rule:u});});}return r}var V=/^[a-z0-9-]+$/,pe=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,fe=/^[A-Za-z_][A-Za-z0-9_]*$/;function de(e){let t=y__namespace.join(e,"crewx.yaml");if(!h__namespace.existsSync(t))return {};let r;try{r=W__namespace.load(h__namespace.readFileSync(t,"utf8"));}catch{return {}}if(!r||typeof r!="object")return {};let s=r.metadata;if(!s||typeof s!="object")return {};let n=s;return {name:typeof n.name=="string"?n.name:void 0,version:typeof n.version=="string"?n.version:void 0,description:typeof n.description=="string"?n.description:void 0,requiredEnv:n.requiredEnv,crewxMinVersion:typeof n.crewxMinVersion=="string"?n.crewxMinVersion:void 0}}function me(e){return X__namespace.createHash("sha256").update(new Uint8Array(h__namespace.readFileSync(e))).digest("hex")}function G(e,t,r={}){let s=de(e),n=s.name??y__namespace.basename(e);if(!V.test(n))throw new Error(`publish: invalid name "${n}" \u2014 must match ${V} (lowercase letters, numbers, hyphen only)`);let i=r.version??s.version;if(!i)throw new Error("publish: version is required \u2014 set crewx.yaml metadata.version or pass opts.version");if(!pe.test(i))throw new Error(`publish: invalid version "${i}" \u2014 must be semver (e.g. 1.0.0)`);let a=Array.isArray(s.requiredEnv)?s.requiredEnv:[],d=[];for(let l of a){if(typeof l!="string"||!fe.test(l))throw new Error(`publish: requiredEnv must contain names only (no values), got "${String(l)}"`);d.push(l);}let c=t.map(l=>({path:l,sha256:me(y__namespace.join(e,l))})).sort((l,p)=>l.path<p.path?-1:l.path>p.path?1:0),u={name:n,version:i,type:"template",description:s.description??"",files:c,requiredEnv:d};return s.crewxMinVersion&&(u.crewxMinVersion=s.crewxMinVersion),u}async function Q(e,t){let r=y__namespace.join(e,".crewx","publish");h__namespace.mkdirSync(r,{recursive:true});let s=y__namespace.join(r,`${t.name}-${t.version}.tgz`),n=h__namespace.mkdtempSync(y__namespace.join(I__namespace.tmpdir(),"crewx-publish-"));try{h__namespace.writeFileSync(y__namespace.join(n,"manifest.json"),JSON.stringify(t,null,2));for(let i of t.files){let a=y__namespace.join(n,i.path);h__namespace.mkdirSync(y__namespace.dirname(a),{recursive:!0}),h__namespace.copyFileSync(y__namespace.join(e,i.path),a);}await Y__namespace.create({gzip:!0,file:s,cwd:n,portable:!0,noMtime:!0},["manifest.json",...t.files.map(i=>i.path)]);}finally{h__namespace.rmSync(n,{recursive:true,force:true});}return s}var A="/api/v1";var ye=201,Ee=409,$=401;function be(){return process.env.WI013_FAKE_UPLOAD==="1"}function we(e){let t=zlib.gunzipSync(new Uint8Array(e)),r=zlib.gzipSync(new Uint8Array(t),{level:1});if(Buffer.compare(new Uint8Array(r),new Uint8Array(e))===0)throw new Error("publish: [E_MALFORMED] Re-gzipped upload bytes are identical to the original \u2014 tamper is a no-op");return r}function Ae(e){return e.replace(/\/+$/,"")}async function P(e){try{return await e.json()}catch{return null}}function E(e){let t=e?.message;return typeof t=="string"?t:void 0}function ee(e,t,r){let s=e;if(!s||s.success!==true||s.data===void 0)throw new Error(`publish: [E_MALFORMED] ${t} response envelope is malformed (expected { success: true, data }) \u2014 HTTP ${r}`);return s.data}async function _e(e){let t=Ae(e.baseUrl),r=e.accessPolicy??"private",s=e.manifest.name,n;try{n=await fetch(`${t}${A}/publisher/items`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({slug:s,displayName:s,description:e.manifest.description,type:"template",version:e.manifest.version,accessPolicy:r})});}catch(o){throw new Error(`publish: [E_NETWORK] Submit request failed (network) \u2014 ${o instanceof Error?o.message:String(o)}`)}let i;if(n.status===ye)i="created";else if(n.status===Ee)i="existing";else {if(n.status===$)throw new Error("publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP 401)");{let o=await P(n);throw new Error(`publish: [E_HTTP] Submit request failed \u2014 HTTP ${n.status}${E(o)?` ${E(o)}`:""}`)}}let a="not-needed",d=null;if(i==="existing"){let o;try{o=await fetch(`${t}${A}/publisher/items`,{method:"GET",headers:{Authorization:`Bearer ${e.accessToken}`}});}catch(f){throw new Error(`publish: [E_NETWORK] Publisher items request failed (network) \u2014 ${f instanceof Error?f.message:String(f)}`)}let M=await P(o);if(o.status!==200)throw new Error(`publish: [E_HTTP] Publisher items request failed \u2014 HTTP ${o.status}${E(M)?` ${E(M)}`:""}`);let B=ee(M,"publisher items",o.status)?.items;if(!Array.isArray(B))throw new Error(`publish: [E_MALFORMED] Publisher items response is malformed (expected data.items[]) \u2014 HTTP ${o.status}`);let O=B.find(f=>!f||typeof f!="object"?false:f.slug===s);if(!O||typeof O.version!="string")throw new Error(`publish: [E_MALFORMED] Publisher items response does not contain slug "${s}" \u2014 HTTP ${o.status}`);if(d=O.version,d!==e.manifest.version){let f;try{f=await fetch(`${t}${A}/publisher/items/${encodeURIComponent(s)}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({version:e.manifest.version})});}catch(T){throw new Error(`publish: [E_NETWORK] Version update request failed (network) \u2014 ${T instanceof Error?T.message:String(T)}`)}if(!f.ok){let T=await P(f),b=E(T);throw f.status===$?new Error(`publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP ${f.status})${b?` ${b}`:""}`):f.status===403?new Error(`publish: [E_FORBIDDEN] Version update is forbidden; only the item owner can update an existing item (HTTP ${f.status})${b?` ${b}`:""}`):new Error(`publish: [E_HTTP] Version update failed \u2014 HTTP ${f.status}${b?` ${b}`:""}`)}a="applied";}}let c=h__namespace.readFileSync(e.tgzPath),u=be()?we(c):c,l=new FormData;l.set("archive",new Blob([new Uint8Array(u)],{type:"application/gzip"}),`${s}-${e.manifest.version}.tgz`);let p;try{p=await fetch(`${t}${A}/publisher/items/${encodeURIComponent(s)}/upload`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:l});}catch(o){throw new Error(`publish: [E_NETWORK] Upload request failed (network) \u2014 ${o instanceof Error?o.message:String(o)}`)}if(p.status===$)throw new Error("publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP 401)");if(!p.ok){let o=await P(p);throw new Error(`publish: [E_HTTP] Upload request failed \u2014 HTTP ${p.status}${E(o)?` ${E(o)}`:""}`)}let U=await P(p),j=ee(U,"upload",p.status);return {slug:s,version:e.manifest.version,artifactChecksum:j.artifactChecksum,artifactSizeBytes:j.artifactSizeBytes,submitOutcome:i,versionUpdate:a,serverVersionBefore:d}}function ne(){if(process.env.CREWX_HOME)try{return h__namespace.realpathSync(process.env.CREWX_HOME)}catch{return y__namespace.join(I__namespace.homedir(),".crewx")}return process.platform!=="win32"&&process.env.XDG_CONFIG_HOME?y__namespace.join(process.env.XDG_CONFIG_HOME,"crewx"):y__namespace.join(I__namespace.homedir(),".crewx")}var g=class extends Error{code;constructor(t,r){super(r),this.name="AccountAuthBoundaryError",this.code=t;}};function N(e=process.env){let t=e.CREWX_ACCOUNT_ISSUER?.trim(),r=e.CREWX_ACCOUNT_ANON_KEY?.trim();if(!t&&!r)throw new g("ACCOUNT_USER_PAIR_MISSING","CrewX user-realm issuer and anon/publishable key pair are not configured");if(!t)throw new g("ACCOUNT_USER_ISSUER_MISSING","CrewX user-realm issuer is not configured");if(!r)throw new g("ACCOUNT_USER_ANON_KEY_MISSING","CrewX user-realm anon/publishable key is not configured");return {issuer:t,anonKey:r}}function _(){throw new g("ACCOUNT_ACCESS_TOKEN_INVALID","Account access token could not be verified")}function se(e){try{return JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{return _()}}function ie(e){if(typeof e!="string")return _();let t=e.split(".");if(t.length!==3||t.some(i=>i.length===0))return _();let r=se(t[0]),s=se(t[1]);if(!r||typeof r!="object"||!s||typeof s!="object")return _();let n=s;return typeof n.iss!="string"||n.iss.length===0||typeof n.sub!="string"||n.sub.length===0?_():{issuer:n.iss,sub:n.sub}}function oe(e,t,r){let s=ie(e);if(s.issuer!==t.issuer)throw new g("ACCOUNT_TOKEN_ISSUER_MISMATCH","Account access token does not match the configured user realm");if(r!==void 0&&s.sub!==r)throw new g("ACCOUNT_TOKEN_SUB_MISMATCH","Account access token subject does not match the expected identity");return s}function H(e,t){if(e.issuer!==t.issuer)throw new g("ACCOUNT_AUTH_JSON_ISSUER_MISMATCH","auth.json does not match the configured user realm");let r=oe(e.access_token,t);if(r.sub!==e.sub)throw new g("ACCOUNT_AUTH_JSON_SUB_MISMATCH","auth.json subject does not match the access token identity");return r}function Pe(e){if(!e||typeof e!="object")return false;let t=e;return t.version===1&&typeof t.sub=="string"&&typeof t.email=="string"&&typeof t.access_token=="string"&&typeof t.refresh_token=="string"&&typeof t.expires_at=="number"&&typeof t.issuer=="string"&&typeof t.updated_at=="string"}function Ue(){let e=y.join(ne(),"auth.json");if(!h.existsSync(e))throw new Error(`Login required \u2014 ${e} was not found (please log in first)`);let t;try{t=h.readFileSync(e,"utf8");}catch(n){throw new Error(`Could not read auth.json (${e}): ${n instanceof Error?n.message:String(n)}`)}let r;try{r=JSON.parse(t);}catch(n){throw new Error(`Failed to parse auth.json (${e}): ${n instanceof Error?n.message:String(n)}`)}if(!Pe(r))throw new Error(`auth.json is malformed (${e}) \u2014 please log in again`);let s=N();return H(r,s),r}async function Ce(e,t={}){let r=y__namespace.resolve(e),{included:s,excluded:n}=J(r),i=G(r,s,{version:t.version}),a=L(r,s);return {manifest:i,included:s,excluded:n,secretFindings:a}}async function pt(e,t={}){let r=await Ce(e,t);if(r.secretFindings.length>0){let i=r.secretFindings.map(a=>`${a.path}:${a.line} (${a.rule})`).join(", ");throw new Error(`publish: aborted \u2014 secret findings must be resolved before packing: ${i}`)}let s=y__namespace.resolve(e),n=await Q(s,r.manifest);return {manifest:r.manifest,tgzPath:n}}exports.AccountAuthBoundaryError=g;exports.EXCLUDE_RULES=D;exports.MARKETPLACE_API_PREFIX=A;exports.assertAuthJsonUserRealm=H;exports.assertUserRealmAccessToken=oe;exports.decodeAccessTokenIdentity=ie;exports.packTemplate=pt;exports.planPublish=Ce;exports.readAuthJson=Ue;exports.resolveUserAccountConfig=N;exports.uploadToMarketplace=_e;
@@ -0,0 +1,17 @@
1
+ export interface ManifestFile {
2
+ path: string;
3
+ sha256: string;
4
+ }
5
+ export interface PublishManifest {
6
+ name: string;
7
+ version: string;
8
+ type: 'template';
9
+ description: string;
10
+ files: ManifestFile[];
11
+ requiredEnv: string[];
12
+ crewxMinVersion?: string;
13
+ }
14
+ export interface BuildManifestOptions {
15
+ version?: string;
16
+ }
17
+ export declare function buildManifest(rootDir: string, includedFiles: string[], opts?: BuildManifestOptions): PublishManifest;
@@ -0,0 +1 @@
1
+ export declare const MARKETPLACE_API_PREFIX = "/api/v1";
@@ -0,0 +1,2 @@
1
+ import type { PublishManifest } from './manifest';
2
+ export declare function createArchive(rootDir: string, manifest: PublishManifest): Promise<string>;
@@ -0,0 +1,9 @@
1
+ export interface ExcludedEntry {
2
+ path: string;
3
+ rule: string;
4
+ }
5
+ export interface ScanResult {
6
+ included: string[];
7
+ excluded: ExcludedEntry[];
8
+ }
9
+ export declare function scanWorkspace(rootDir: string): ScanResult;
@@ -0,0 +1,6 @@
1
+ export interface SecretFinding {
2
+ path: string;
3
+ line: number;
4
+ rule: string;
5
+ }
6
+ export declare function scanForSecrets(rootDir: string, includedFiles: string[]): SecretFinding[];
@@ -0,0 +1,18 @@
1
+ import type { PublishManifest } from './manifest';
2
+ export interface PublishUploadOptions {
3
+ tgzPath: string;
4
+ manifest: PublishManifest;
5
+ baseUrl: string;
6
+ accessToken: string;
7
+ accessPolicy?: 'private';
8
+ }
9
+ export interface PublishUploadResult {
10
+ slug: string;
11
+ version: string;
12
+ artifactChecksum: string;
13
+ artifactSizeBytes: number;
14
+ submitOutcome: 'created' | 'existing';
15
+ versionUpdate: 'not-needed' | 'applied';
16
+ serverVersionBefore: string | null;
17
+ }
18
+ export declare function uploadToMarketplace(opts: PublishUploadOptions): Promise<PublishUploadResult>;
@@ -0,0 +1,34 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { agent_suggestions } from '../schema/index.js';
3
+ export type AgentSuggestionRow = typeof agent_suggestions.$inferSelect;
4
+ export type NewAgentSuggestion = typeof agent_suggestions.$inferInsert;
5
+ export type SuggestionType = 'H1' | 'H3';
6
+ export type SuggestionStatus = 'pending' | 'applied' | 'dismissed';
7
+ export interface CreateAgentSuggestionInput {
8
+ workspaceId: string;
9
+ agentId: string;
10
+ taskId?: string | null;
11
+ type: SuggestionType;
12
+ status?: SuggestionStatus;
13
+ payload: string;
14
+ appliedCommitSha?: string | null;
15
+ }
16
+ export declare const DEFAULT_LIST_LIMIT = 50;
17
+ export declare class AgentSuggestionRepository extends BaseSqliteRepository {
18
+ private readonly dbPath?;
19
+ constructor(opts?: {
20
+ dbPath?: string;
21
+ dbRoot?: string;
22
+ });
23
+ resolveDbPath(): string;
24
+ private openHandle;
25
+ create(rows: CreateAgentSuggestionInput[]): {
26
+ ids: string[];
27
+ };
28
+ findLatestSet(workspaceId: string, agentId: string): AgentSuggestionRow[];
29
+ findSetByTaskId(workspaceId: string, agentId: string, taskId: string): AgentSuggestionRow[];
30
+ findById(workspaceId: string, agentId: string, suggestionId: string): AgentSuggestionRow | null;
31
+ updateStatus(id: string, status: SuggestionStatus, appliedCommitSha?: string | null): boolean;
32
+ listByAgent(workspaceId: string, agentId: string, limit?: number): AgentSuggestionRow[];
33
+ findDismissed(workspaceId: string, agentId: string, limit?: number): AgentSuggestionRow[];
34
+ }
@@ -6,4 +6,12 @@ export interface DrizzleHandle {
6
6
  runRaw(sqlStr: string, params?: unknown[]): void;
7
7
  close(): void;
8
8
  }
9
+ export declare const CREWX_JOURNAL_SIZE_LIMIT_BYTES: number;
10
+ export type ReclaimJournalMode = 'PASSIVE' | 'TRUNCATE';
11
+ export interface ReclaimJournalResult {
12
+ busy: boolean;
13
+ walBytesBefore: number;
14
+ walBytesAfter: number;
15
+ }
9
16
  export declare function openDrizzleDb(dbPath: string): DrizzleHandle;
17
+ export declare function reclaimTemporaryJournal(dbPath: string, mode?: ReclaimJournalMode): ReclaimJournalResult;
@@ -3,15 +3,22 @@ export { RepositoryError } from './errors.js';
3
3
  export type { RepositoryErrorCode } from './errors.js';
4
4
  export { WorkspaceRepository } from './workspace.repository.js';
5
5
  export type { ProjectRow, ThreadRow as WorkspaceThreadRow, ThreadWithAgentRow } from './workspace.repository.js';
6
- export { openDrizzleDb } from './db.js';
7
- export type { DrizzleDb, DrizzleHandle } from './db.js';
6
+ export { DEFAULT_PROJECT_STAGE_KEYS, DEFAULT_PROJECT_STAGES, ProjectRepository, } from './project.repository.js';
7
+ export type { AcceptProjectInput, AppendProjectEventInput, CreateProjectInput, CriterionVerifyStatus, ListProjectEventsOptions, ListProjectsOptions, ProjectActorInput, ProjectActorType, ProjectDetail, ProjectEvidence, ProjectEvidenceKind, ProjectEventType, ProjectScene, ProjectStage, SetCriterionEvidenceInput, SetCriterionVerifyInput, } from './project.repository.js';
8
+ export { CREWX_JOURNAL_SIZE_LIMIT_BYTES, openDrizzleDb, reclaimTemporaryJournal } from './db.js';
9
+ export type { DrizzleDb, DrizzleHandle, ReclaimJournalMode, ReclaimJournalResult } from './db.js';
8
10
  export { runMigrations, runMigrationsOnce } from './migrate.js';
9
11
  export { pushSchema } from './push.js';
10
12
  export type { PushResult } from './push.js';
11
13
  export type { Workspace, NewWorkspace } from '../schema/index.js';
12
14
  export { tasks } from '../schema/index.js';
13
15
  export { TaskRepository } from './task.repository.js';
14
- export type { TaskRow, NewTask, AgentUsageRow, TrendRow, ProviderUsageRow } from './task.repository.js';
16
+ export type { TaskRow, TaskListRow, NewTask, AgentUsageRow, TrendRow, ProviderUsageRow, ModelUsageRow, ReportTaskRow, DelegationEdge, DelegationMatrixResult, WorkflowCardRow, WorkflowParentTaskRow, } from './task.repository.js';
17
+ export { TaskLogRepository } from './task-log.repository.js';
18
+ export type { TaskLogEntry, RawTaskLogEntry, TaskLogRawEntry, TaskLogStorage, TaskLogState, TaskLogReadResult, TaskLogRepositoryContract, } from './task-log.repository.js';
19
+ export { runTaskLogMigration, resolveTaskLogMigrationDbPath, taskLogBackupName, tryCheckpointTaskLogWal, hasSufficientTaskLogMigrationFreeSpace, } from './task-log-migration.js';
20
+ export { TASK_LOG_MIGRATION_EVENT_ROW_BYTES, TASK_LOG_MIGRATION_MIN_FREE_SPACE_BYTES, TASK_LOG_MIGRATION_TERMINAL_STATUSES, } from './task-log-migration.js';
21
+ export type { TaskLogMigrationFailure, TaskLogMigrationFailureKind, TaskLogMigrationMode, TaskLogMigrationOptions, TaskLogMigrationReport, TaskLogWalCheckpointConnection, TaskLogVerificationIssue, TaskLogVerificationIssueKind, TaskLogVerificationReport, } from './task-log-migration.js';
15
22
  export { ThreadRepository } from './thread.repository.js';
16
23
  export type { ThreadRow, NewThread } from './thread.repository.js';
17
24
  export { SpanRepository } from './span.repository.js';
@@ -24,3 +31,9 @@ export { RequestLogRepository } from './request-log.repository.js';
24
31
  export type { RequestLogRow, NewRequestLog, RequestLogEntry } from './request-log.repository.js';
25
32
  export { UsageLimitSnapshotRepository, calcBucketStart } from './usage-limit-snapshot.repository.js';
26
33
  export type { UsageLimitSnapshotRow, NewUsageLimitSnapshot, UpsertSnapshotInput, LimitTrendPoint, LimitTrendProvider, } from './usage-limit-snapshot.repository.js';
34
+ export { UsageReportRepository } from './usage-report.repository.js';
35
+ export type { UsageReportRow, NewUsageReport, PublishReportInput } from './usage-report.repository.js';
36
+ export { NotificationRepository, DEFAULT_NOTIFICATION_CAP, DEFAULT_LIST_LIMIT as DEFAULT_NOTIFICATION_LIST_LIMIT, } from './notification.repository.js';
37
+ export type { NotificationRow, NewNotification, NotificationReadRow, NotificationLevel, NotificationSource, CreateNotificationInput, NotificationListItem, ListNotificationsParams, UserScope as NotificationUserScope, MarkReadParams as NotificationMarkReadParams, } from './notification.repository.js';
38
+ export { AgentSuggestionRepository, DEFAULT_LIST_LIMIT as DEFAULT_AGENT_SUGGESTION_LIST_LIMIT, } from './agent-suggestion.repository.js';
39
+ export type { AgentSuggestionRow, NewAgentSuggestion, SuggestionType, SuggestionStatus, CreateAgentSuggestionInput, } from './agent-suggestion.repository.js';