@crewx/sdk 0.9.0-rc.11 → 0.9.0-rc.111

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 (247) 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 +37 -0
  6. package/dist/account/env-bootstrap.d.ts +5 -0
  7. package/dist/account/errors.d.ts +24 -0
  8. package/dist/account/index.d.ts +12 -0
  9. package/dist/account/index.js +2 -0
  10. package/dist/account/session-manager.d.ts +47 -0
  11. package/dist/activity-log/builder.d.ts +56 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/boxing/box.types.d.ts +4 -0
  14. package/dist/config/canonicalize-agent-options.d.ts +17 -0
  15. package/dist/config/default-agent-models.d.ts +11 -0
  16. package/dist/config/global-settings.d.ts +33 -0
  17. package/dist/config/migrate-grok-mode.d.ts +6 -0
  18. package/dist/config/model-compat.d.ts +31 -0
  19. package/dist/config/models.generated.d.ts +37 -0
  20. package/dist/config/models.remote.d.ts +1 -0
  21. package/dist/config/overdrive.d.ts +7 -0
  22. package/dist/config/pricing.d.ts +7 -3
  23. package/dist/config/pricing.generated.d.ts +4 -0
  24. package/dist/config/pricing.types.d.ts +4 -10
  25. package/dist/config/timeout.config.d.ts +4 -0
  26. package/dist/config/wi-boards.d.ts +19 -0
  27. package/dist/context-budget/continuity.d.ts +61 -0
  28. package/dist/context-budget/index.d.ts +141 -0
  29. package/dist/conversation/index.d.ts +1 -1
  30. package/dist/conversation/sqlite-provider.d.ts +6 -2
  31. package/dist/conversation/to-template-messages.d.ts +9 -0
  32. package/dist/conversation/types.d.ts +47 -1
  33. package/dist/desktop/command-runner.d.ts +4 -0
  34. package/dist/desktop/default-adapters.d.ts +4 -0
  35. package/dist/desktop/global-install.d.ts +19 -0
  36. package/dist/desktop/index.d.ts +3 -0
  37. package/dist/desktop/index.js +3 -0
  38. package/dist/desktop/install.d.ts +5 -0
  39. package/dist/desktop/lnk.d.ts +22 -0
  40. package/dist/desktop/manifest.d.ts +21 -0
  41. package/dist/desktop/types.d.ts +67 -0
  42. package/dist/desktop/version.d.ts +1 -0
  43. package/dist/desktop/windows-paths.d.ts +21 -0
  44. package/dist/desktop/wrapper.d.ts +18 -0
  45. package/dist/esm/account/index.js +2 -0
  46. package/dist/esm/desktop/index.js +3 -0
  47. package/dist/esm/index.js +700 -183
  48. package/dist/esm/plugins/index.js +302 -180
  49. package/dist/esm/process/index.js +1 -0
  50. package/dist/esm/publish/index.js +2 -0
  51. package/dist/esm/repository/index.js +370 -170
  52. package/dist/esm/skills/index.js +1 -0
  53. package/dist/esm/testing/index.js +1 -1
  54. package/dist/events/types.d.ts +9 -0
  55. package/dist/facade/Crewx.d.ts +54 -4
  56. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  57. package/dist/highlight/thread-highlighter.d.ts +326 -0
  58. package/dist/index.browser.d.ts +14 -1
  59. package/dist/index.browser.js +6 -2
  60. package/dist/index.d.ts +108 -15
  61. package/dist/index.js +700 -183
  62. package/dist/internal/console-decoder.d.ts +38 -0
  63. package/dist/internal/windows-spawn.d.ts +10 -0
  64. package/dist/layout/types.d.ts +18 -1
  65. package/dist/lifecycle/process-lease.d.ts +80 -0
  66. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  67. package/dist/lifecycle/task-stop.d.ts +82 -0
  68. package/dist/lifecycle/update-admission.d.ts +44 -0
  69. package/dist/local-server/base-url.d.ts +18 -0
  70. package/dist/local-server/index.d.ts +8 -0
  71. package/dist/local-server/opencode.d.ts +8 -0
  72. package/dist/local-server/probe.d.ts +3 -0
  73. package/dist/local-server/runtime.d.ts +26 -0
  74. package/dist/local-server/types.d.ts +43 -0
  75. package/dist/mcp-app/apps-context.d.ts +5 -0
  76. package/dist/mcp-app/catalog.d.ts +7 -0
  77. package/dist/mcp-app/discovery.d.ts +105 -0
  78. package/dist/mcp-app/errors.d.ts +7 -0
  79. package/dist/mcp-app/index.d.ts +18 -0
  80. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  81. package/dist/mcp-app/node-app-discovery-fs.d.ts +20 -0
  82. package/dist/mcp-app/projection.d.ts +13 -0
  83. package/dist/mcp-app/registry.d.ts +19 -0
  84. package/dist/mcp-app/state-set.d.ts +9 -0
  85. package/dist/mcp-app/types.d.ts +362 -0
  86. package/dist/mcp-app/workspace-snapshot.d.ts +53 -0
  87. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  88. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  89. package/dist/migrations/0010_analyze_stats.sql +6 -0
  90. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  91. package/dist/migrations/0012_blue_turbo.sql +23 -0
  92. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  93. package/dist/migrations/0014_organic_mongu.sql +73 -0
  94. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  95. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  96. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  97. package/dist/migrations/0018_bored_jackal.sql +33 -0
  98. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  99. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  100. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  101. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  102. package/dist/migrations/0023_red_payback.sql +1 -0
  103. package/dist/migrations/0024_storage_metadata.sql +262 -0
  104. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  105. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  106. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  107. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  108. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  109. package/dist/migrations/0029_nice_rhino.sql +1 -0
  110. package/dist/migrations/0031_petite_arclight.sql +6 -0
  111. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  112. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  113. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  114. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  115. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  116. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  117. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  118. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  119. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  120. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  121. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  122. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  123. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  124. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  125. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  126. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  127. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  128. package/dist/migrations/meta/_journal.json +168 -0
  129. package/dist/paths.d.ts +1 -0
  130. package/dist/plugin/types.d.ts +1 -0
  131. package/dist/plugins/index.d.ts +1 -1
  132. package/dist/plugins/index.js +302 -180
  133. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  134. package/dist/process/index.d.ts +2 -0
  135. package/dist/process/index.js +1 -0
  136. package/dist/process/process-control.d.ts +41 -0
  137. package/dist/prompt/tag-names.d.ts +20 -0
  138. package/dist/provider/acp/connection.d.ts +6 -0
  139. package/dist/provider/acp/meta.d.ts +11 -0
  140. package/dist/provider/bridge.d.ts +7 -1
  141. package/dist/provider/classify-task-error.d.ts +2 -0
  142. package/dist/provider/cli/adapter.types.d.ts +9 -1
  143. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  144. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  145. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  146. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  147. package/dist/provider/cli/adapters/index.d.ts +1 -0
  148. package/dist/provider/cli/index.d.ts +1 -1
  149. package/dist/provider/cli/meta.d.ts +5 -0
  150. package/dist/provider/cli/protocol-envelope.d.ts +2 -0
  151. package/dist/provider/errors.d.ts +5 -1
  152. package/dist/provider/idle-watchdog.d.ts +19 -0
  153. package/dist/provider/models.d.ts +17 -12
  154. package/dist/provider/order.d.ts +1 -1
  155. package/dist/provider/parse-usage.d.ts +6 -0
  156. package/dist/provider/provider-selection.d.ts +8 -0
  157. package/dist/provider/redact-technical-message.d.ts +1 -0
  158. package/dist/provider/task-error.types.d.ts +17 -0
  159. package/dist/publish/constants.d.ts +6 -0
  160. package/dist/publish/errors.d.ts +7 -0
  161. package/dist/publish/index.d.ts +50 -0
  162. package/dist/publish/index.js +2 -0
  163. package/dist/publish/manifest.d.ts +47 -0
  164. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  165. package/dist/publish/pack.d.ts +6 -0
  166. package/dist/publish/scan.d.ts +9 -0
  167. package/dist/publish/secrets.d.ts +6 -0
  168. package/dist/publish/upload.d.ts +19 -0
  169. package/dist/remote/execution-profile.d.ts +9 -0
  170. package/dist/remote/index.d.ts +1 -0
  171. package/dist/remote/types.d.ts +28 -0
  172. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  173. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  174. package/dist/repository/common-code.repository.d.ts +45 -0
  175. package/dist/repository/db.d.ts +12 -1
  176. package/dist/repository/index.d.ts +38 -5
  177. package/dist/repository/index.js +370 -170
  178. package/dist/repository/notification.repository.d.ts +58 -0
  179. package/dist/repository/project.repository.d.ts +90 -0
  180. package/dist/repository/request-log.repository.d.ts +1 -0
  181. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  182. package/dist/repository/task-log-migration.d.ts +74 -0
  183. package/dist/repository/task-log.repository.d.ts +44 -0
  184. package/dist/repository/task-status.d.ts +14 -0
  185. package/dist/repository/task.repository.d.ts +246 -7
  186. package/dist/repository/thread-history.repository.d.ts +193 -0
  187. package/dist/repository/thread-title.types.d.ts +29 -0
  188. package/dist/repository/thread.repository.d.ts +47 -5
  189. package/dist/repository/usage-backfill.d.ts +62 -0
  190. package/dist/repository/usage-from-logs.d.ts +21 -0
  191. package/dist/repository/usage-report.repository.d.ts +27 -0
  192. package/dist/repository/workspace.repository.d.ts +3 -0
  193. package/dist/schema/agent-suggestions.d.ts +199 -0
  194. package/dist/schema/common-codes.d.ts +216 -0
  195. package/dist/schema/index.d.ts +10 -0
  196. package/dist/schema/notifications.d.ts +303 -0
  197. package/dist/schema/projects.d.ts +610 -0
  198. package/dist/schema/storage-metadata.d.ts +181 -0
  199. package/dist/schema/task-log-events.d.ts +119 -0
  200. package/dist/schema/tasks.d.ts +165 -0
  201. package/dist/schema/thread-history.d.ts +734 -0
  202. package/dist/schema/threads.d.ts +59 -0
  203. package/dist/schema/ui-action-receipts.d.ts +303 -0
  204. package/dist/schema/ui-instances.d.ts +286 -0
  205. package/dist/schema/usage-reports.d.ts +252 -0
  206. package/dist/schema/workspaces.d.ts +17 -0
  207. package/dist/skills/index.d.ts +7 -0
  208. package/dist/skills/index.js +1 -0
  209. package/dist/skills/types.d.ts +18 -0
  210. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  211. package/dist/task-log/delegation-trailer.d.ts +34 -0
  212. package/dist/template/engine.d.ts +2 -2
  213. package/dist/template/helpers/exec.browser.d.ts +4 -3
  214. package/dist/template/helpers/exec.d.ts +4 -3
  215. package/dist/template/types.d.ts +20 -0
  216. package/dist/testing/index.js +1 -1
  217. package/dist/types/index.d.ts +1569 -3
  218. package/dist/types/task-log.types.d.ts +2 -0
  219. package/dist/ui-card/index.d.ts +2 -0
  220. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  221. package/dist/ui-instance/definition.d.ts +6 -0
  222. package/dist/ui-instance/errors.d.ts +17 -0
  223. package/dist/ui-instance/index.d.ts +9 -0
  224. package/dist/ui-instance/json.d.ts +5 -0
  225. package/dist/ui-instance/runtime.d.ts +18 -0
  226. package/dist/ui-instance/store.d.ts +99 -0
  227. package/dist/ui-instance/types.d.ts +213 -0
  228. package/dist/ui-plugin/index.d.ts +4 -0
  229. package/dist/ui-plugin/limits.d.ts +27 -0
  230. package/dist/ui-plugin/manifest.d.ts +3 -0
  231. package/dist/ui-plugin/types.d.ts +174 -0
  232. package/dist/ui-plugin/validator.d.ts +15 -0
  233. package/dist/utils/crewx-executable.d.ts +54 -0
  234. package/dist/utils/crewx-home.d.ts +1 -0
  235. package/dist/utils/env-defaults.d.ts +2 -0
  236. package/dist/utils/id.d.ts +1 -1
  237. package/dist/utils/runner-env.d.ts +3 -0
  238. package/dist/utils/timestamp.d.ts +1 -0
  239. package/dist/utils/workspace.d.ts +1 -0
  240. package/dist/wi/create.d.ts +48 -0
  241. package/dist/wi/select.d.ts +20 -0
  242. package/package.json +40 -2
  243. package/templates/agents/default.yaml +269 -127
  244. package/templates/documents/crewx-manual.md +138 -138
  245. package/templates/documents/crewx-quick-guide.md +1 -1
  246. package/templates/workflows/wi-default-flow.yaml +65 -0
  247. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -0,0 +1,58 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { notifications, notification_reads } from '../schema/index.js';
3
+ export declare const DEFAULT_NOTIFICATION_CAP = 500;
4
+ export type NotificationRow = typeof notifications.$inferSelect;
5
+ export type NewNotification = typeof notifications.$inferInsert;
6
+ export type NotificationReadRow = typeof notification_reads.$inferSelect;
7
+ export type NotificationLevel = 'info' | 'warning' | 'critical';
8
+ export type NotificationSource = 'agent' | 'system';
9
+ export interface CreateNotificationInput {
10
+ workspaceId: string;
11
+ agentId?: string | null;
12
+ taskId?: string | null;
13
+ threadId?: string | null;
14
+ source?: NotificationSource;
15
+ level?: NotificationLevel;
16
+ title: string;
17
+ body?: string | null;
18
+ targetUserId?: string | null;
19
+ metadata?: string | null;
20
+ }
21
+ export interface NotificationListItem extends NotificationRow {
22
+ read: boolean;
23
+ read_at: string | null;
24
+ }
25
+ export interface ListNotificationsParams {
26
+ workspaceId: string;
27
+ userId: string;
28
+ limit?: number;
29
+ }
30
+ export interface UserScope {
31
+ workspaceId: string;
32
+ userId: string;
33
+ }
34
+ export interface MarkReadParams {
35
+ notificationId: string;
36
+ workspaceId: string;
37
+ userId: string;
38
+ }
39
+ export declare const DEFAULT_LIST_LIMIT = 50;
40
+ export declare class NotificationRepository extends BaseSqliteRepository {
41
+ private readonly dbPath?;
42
+ private readonly cap;
43
+ constructor(opts?: {
44
+ dbPath?: string;
45
+ dbRoot?: string;
46
+ cap?: number;
47
+ });
48
+ resolveDbPath(): string;
49
+ private openHandle;
50
+ create(input: CreateNotificationInput): {
51
+ id: string;
52
+ };
53
+ private enforceCap;
54
+ list(params: ListNotificationsParams): NotificationListItem[];
55
+ unreadCount(params: UserScope): number;
56
+ markRead(params: MarkReadParams): boolean;
57
+ markAllRead(params: UserScope): number;
58
+ }
@@ -0,0 +1,90 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import type { Project as ProjectLedgerRow, ProjectCriterion as ProjectCriterionRow, ProjectEvent as ProjectEventRow } from '../schema/index.js';
3
+ export type ProjectScene = 'planning' | 'plan_review' | 'running' | 'human_wait' | 'limit_wait' | 'failed_stop' | 'analyzing_feedback' | 'replanned' | 'awaiting_review' | 'accepted';
4
+ export type CriterionVerifyStatus = 'pending' | 'verifying' | 'passed' | 'failed';
5
+ export type ProjectActorType = 'user' | 'project_manager' | 'system';
6
+ export type ProjectEventType = 'created' | 'plan_proposed' | 'plan_approved' | 'decision_requested' | 'decision_answered' | 'replanned' | 'stage_advanced' | 'criterion_verified' | 'scene_changed' | 'result_submitted' | 'accepted';
7
+ export type ProjectEvidenceKind = 'task' | 'wi' | 'url';
8
+ export interface ProjectStage {
9
+ key: string;
10
+ labelOverride: string | null;
11
+ }
12
+ export declare const DEFAULT_PROJECT_STAGE_KEYS: readonly ["outcome_plan", "contract_check", "feature_link", "use_verify", "result_review"];
13
+ export declare const DEFAULT_PROJECT_STAGES: readonly ProjectStage[];
14
+ export interface ProjectEvidence {
15
+ kind: ProjectEvidenceKind;
16
+ ref: string;
17
+ label?: string;
18
+ }
19
+ export interface ProjectActorInput {
20
+ actorType?: ProjectActorType;
21
+ actorId?: string | null;
22
+ }
23
+ export interface CreateProjectInput {
24
+ workspaceId: string;
25
+ name: string;
26
+ outcome: string;
27
+ dueDate?: string | null;
28
+ stages?: readonly ProjectStage[];
29
+ criteria: readonly string[];
30
+ }
31
+ export interface ListProjectsOptions {
32
+ includeArchived?: boolean;
33
+ }
34
+ export interface ListProjectEventsOptions {
35
+ afterSeq?: number;
36
+ limit?: number;
37
+ }
38
+ export interface AppendProjectEventInput extends ProjectActorInput {
39
+ projectId: string;
40
+ type: ProjectEventType;
41
+ title: string;
42
+ summary?: string | null;
43
+ payload?: Record<string, unknown>;
44
+ }
45
+ export interface SetCriterionVerifyInput extends ProjectActorInput {
46
+ projectId?: string;
47
+ criterionId: string;
48
+ verifyStatus?: CriterionVerifyStatus;
49
+ status?: CriterionVerifyStatus;
50
+ }
51
+ export interface SetCriterionEvidenceInput extends ProjectActorInput {
52
+ projectId?: string;
53
+ criterionId: string;
54
+ evidence: readonly ProjectEvidence[];
55
+ }
56
+ export interface AcceptProjectInput extends ProjectActorInput {
57
+ remainingRisks: unknown;
58
+ nextPlan: unknown;
59
+ lessons: unknown;
60
+ evidenceRefs: unknown;
61
+ }
62
+ export interface ProjectDetail extends ProjectLedgerRow {
63
+ stages: ProjectStage[];
64
+ criteria: ProjectCriterionRow[];
65
+ }
66
+ export declare class ProjectRepository extends BaseSqliteRepository {
67
+ private readonly dbPath?;
68
+ constructor(opts?: {
69
+ dbPath?: string;
70
+ dbRoot?: string;
71
+ });
72
+ resolveDbPath(): string;
73
+ private openHandle;
74
+ private getDetailFromHandle;
75
+ private getDetailOrThrow;
76
+ createProject(input: CreateProjectInput): ProjectDetail;
77
+ getProject(id: string): ProjectDetail | undefined;
78
+ listProjectsByWorkspace(workspaceId: string, options?: ListProjectsOptions): ProjectDetail[];
79
+ archiveProject(id: string): ProjectDetail;
80
+ setScene(id: string, scene: ProjectScene, actor?: ProjectActorInput): ProjectDetail;
81
+ setStageIndex(id: string, index: number, actor?: ProjectActorInput): ProjectDetail;
82
+ setCriterionVerify(input: SetCriterionVerifyInput): ProjectCriterionRow;
83
+ setCriterionVerify(projectId: string, criterionId: string, status: CriterionVerifyStatus, actor?: ProjectActorInput): ProjectCriterionRow;
84
+ setCriterionEvidence(input: SetCriterionEvidenceInput): ProjectCriterionRow;
85
+ setCriterionEvidence(projectId: string, criterionId: string, evidence: readonly ProjectEvidence[], actor?: ProjectActorInput): ProjectCriterionRow;
86
+ appendEvent(input: AppendProjectEventInput): ProjectEventRow;
87
+ appendEvent(projectId: string, input: Omit<AppendProjectEventInput, 'projectId'>): ProjectEventRow;
88
+ listEvents(projectId: string, options?: ListProjectEventsOptions): ProjectEventRow[];
89
+ acceptProject(id: string, input: AcceptProjectInput): ProjectDetail;
90
+ }
@@ -16,6 +16,7 @@ export interface RequestLogEntry {
16
16
  userId?: string;
17
17
  projectId?: string;
18
18
  partitionKey?: string;
19
+ timestamp?: string;
19
20
  metadata?: string;
20
21
  }
21
22
  export declare class RequestLogRepository extends BaseSqliteRepository {
@@ -0,0 +1,64 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ export declare const STORAGE_METADATA_KINDS: readonly ["taskLogs", "requestLogs", "prompts", "threadsLedger", "tasksLedger"];
3
+ export declare const STORAGE_METADATA_UNITS: readonly ["task_log_events", "request_logs", "tasks", "threads"];
4
+ export type StorageMetadataKind = (typeof STORAGE_METADATA_KINDS)[number];
5
+ export type StorageMetadataUnit = (typeof STORAGE_METADATA_UNITS)[number];
6
+ export type StorageMetadataAge = 'over6m' | 'm3to6' | 'm1to3' | 'recent1m';
7
+ export interface StorageMetadataAggregateRow {
8
+ sourceKind: StorageMetadataKind;
9
+ age: StorageMetadataAge;
10
+ count: number;
11
+ bytes: number;
12
+ }
13
+ export interface StorageMetadataCutoffs {
14
+ cutoff6: string;
15
+ cutoff3: string;
16
+ cutoff1: string;
17
+ }
18
+ export interface StorageMetadataUnitReadiness {
19
+ cursorRowid: number;
20
+ endRowid: number | null;
21
+ complete: boolean;
22
+ }
23
+ export interface StorageMetadataReadiness {
24
+ ready: boolean;
25
+ units: Record<StorageMetadataUnit, StorageMetadataUnitReadiness>;
26
+ }
27
+ export interface StorageMetadataSnapshot {
28
+ readiness: StorageMetadataReadiness;
29
+ rows: StorageMetadataAggregateRow[];
30
+ }
31
+ export interface StorageMetadataBatchResult {
32
+ unit: StorageMetadataUnit | null;
33
+ rowsScanned: number;
34
+ rowsWritten: number;
35
+ cursorRowid: number;
36
+ complete: boolean;
37
+ ready: boolean;
38
+ elapsedMs: number;
39
+ }
40
+ export interface StorageMetadataVerificationMismatch {
41
+ sourceId: string;
42
+ metaBytes: number;
43
+ sourceBytes: number;
44
+ }
45
+ export declare class StorageMetadataRepository extends BaseSqliteRepository {
46
+ private readonly dbPath?;
47
+ constructor(opts?: {
48
+ dbPath?: string;
49
+ dbRoot?: string;
50
+ });
51
+ resolveDbPath(): string;
52
+ private hasReadableDatabase;
53
+ private openWritableDatabase;
54
+ private readReadiness;
55
+ private readAggregate;
56
+ getReadiness(): StorageMetadataReadiness;
57
+ aggregate(cutoffs: StorageMetadataCutoffs): StorageMetadataAggregateRow[];
58
+ readSnapshot(cutoffs: StorageMetadataCutoffs): StorageMetadataSnapshot;
59
+ runBackfillBatch(opts?: {
60
+ batchSize?: number;
61
+ unit?: StorageMetadataUnit;
62
+ }): StorageMetadataBatchResult;
63
+ verifySample(kind: StorageMetadataKind, limit: number): StorageMetadataVerificationMismatch[];
64
+ }
@@ -0,0 +1,74 @@
1
+ export type TaskLogMigrationMode = 'dry-run' | 'apply' | 'verify';
2
+ export declare const TASK_LOG_MIGRATION_TERMINAL_STATUSES: readonly ["success", "failed", "completed"];
3
+ export declare const TASK_LOG_MIGRATION_MIN_FREE_SPACE_BYTES: number;
4
+ export declare const TASK_LOG_MIGRATION_EVENT_ROW_BYTES = 256;
5
+ export type TaskLogVerificationIssueKind = 'malformed-blob' | 'mixed-source' | 'seq-gap' | 'duplicate-seq' | 'orphan-event' | 'count-mismatch' | 'source-invariant' | 'invalid-event';
6
+ export type TaskLogMigrationFailureKind = 'malformed' | 'mixed-source' | 'metadata' | 'invalid-source';
7
+ export interface TaskLogMigrationOptions {
8
+ mode: TaskLogMigrationMode;
9
+ dbPath?: string;
10
+ batchTasks?: number;
11
+ backupPath?: string;
12
+ }
13
+ export interface TaskLogMigrationFailure {
14
+ taskId: string;
15
+ reason: string;
16
+ kind?: TaskLogMigrationFailureKind;
17
+ }
18
+ export interface TaskLogVerificationIssue {
19
+ taskId: string | null;
20
+ kind: TaskLogVerificationIssueKind;
21
+ reason: string;
22
+ expected?: number;
23
+ actual?: number;
24
+ seq?: number;
25
+ }
26
+ export interface TaskLogVerificationReport {
27
+ checkedTasks: number;
28
+ eventSourceTasks: number;
29
+ blobSourceTasks: number;
30
+ eventCount: number;
31
+ orphanEventCount: number;
32
+ failedTasks: number;
33
+ issues: TaskLogVerificationIssue[];
34
+ }
35
+ export interface TaskLogMigrationReport {
36
+ mode: TaskLogMigrationMode;
37
+ ok: boolean;
38
+ dbPath: string;
39
+ backupPath?: string;
40
+ backupMethod?: 'sqlite-online-backup';
41
+ blockedReason?: string;
42
+ activeTaskCount: number;
43
+ taskCount: number;
44
+ candidateTaskCount: number;
45
+ eligibleTaskCount: number;
46
+ statusCounts: Record<string, number>;
47
+ deferredTaskCount: number;
48
+ deferredStatusCounts: Record<string, number>;
49
+ entryCount: number;
50
+ sourceBytes: number;
51
+ estimatedFreeSpaceBytes: number;
52
+ requiredFreeSpaceBytes: number;
53
+ availableFreeSpaceBytes: number;
54
+ minimumFreeSpaceReserveBytes: number;
55
+ freeSpaceGatePassed: boolean;
56
+ migratedTasks: number;
57
+ migratedEntries: number;
58
+ skippedTasks: number;
59
+ failedTasks: number;
60
+ malformedRows: TaskLogMigrationFailure[];
61
+ failures: TaskLogMigrationFailure[];
62
+ logicalSourceBytesRemoved: number;
63
+ warnings: string[];
64
+ remainingTaskCount: number;
65
+ verification?: TaskLogVerificationReport;
66
+ }
67
+ export declare function resolveTaskLogMigrationDbPath(dbPath?: string): string;
68
+ export declare function hasSufficientTaskLogMigrationFreeSpace(availableFreeSpaceBytes: number, estimatedFreeSpaceBytes: number): boolean;
69
+ export interface TaskLogWalCheckpointConnection {
70
+ pragma(pragma: string): unknown;
71
+ }
72
+ export declare function tryCheckpointTaskLogWal(db: TaskLogWalCheckpointConnection): string | undefined;
73
+ export declare function runTaskLogMigration(options: TaskLogMigrationOptions): Promise<TaskLogMigrationReport>;
74
+ export declare function taskLogBackupName(backupPath: string): string;
@@ -0,0 +1,44 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ export type TaskLogStorage = 'blob' | 'events';
3
+ export interface TaskLogEntry {
4
+ timestamp: string;
5
+ level: string;
6
+ message: string;
7
+ }
8
+ export type RawTaskLogEntry = TaskLogEntry;
9
+ export type TaskLogRawEntry = TaskLogEntry;
10
+ export interface TaskLogState {
11
+ taskId: string;
12
+ source: TaskLogStorage;
13
+ revision: number;
14
+ lastSeq: number;
15
+ }
16
+ export interface TaskLogReadResult extends TaskLogState {
17
+ entries: TaskLogEntry[];
18
+ }
19
+ export interface TaskLogRepositoryContract {
20
+ appendLog(taskId: string, entry: TaskLogEntry): TaskLogState;
21
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): TaskLogState;
22
+ readLogs(taskId: string): TaskLogReadResult | undefined;
23
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
24
+ getLogState(taskId: string): TaskLogState | undefined;
25
+ }
26
+ export declare class TaskLogRepository extends BaseSqliteRepository implements TaskLogRepositoryContract {
27
+ private readonly dbPath?;
28
+ constructor(opts?: {
29
+ dbPath?: string;
30
+ dbRoot?: string;
31
+ });
32
+ resolveDbPath(): string;
33
+ private openHandle;
34
+ private findStateRow;
35
+ private findStateRowInTransaction;
36
+ private requireStateRowInTransaction;
37
+ appendLog(taskId: string, entry: TaskLogEntry): TaskLogState;
38
+ appendLogs(taskId: string, entries: readonly TaskLogEntry[]): TaskLogState;
39
+ getLogState(taskId: string): TaskLogState | undefined;
40
+ readLogs(taskId: string): TaskLogReadResult | undefined;
41
+ readLogsTail(taskId: string, limit: number): TaskLogReadResult | undefined;
42
+ readTail(taskId: string, limit: number): TaskLogReadResult | undefined;
43
+ private readLogsInternal;
44
+ }
@@ -0,0 +1,14 @@
1
+ export type TaskStatus = 'pending' | 'running' | 'paused' | 'success' | 'failed' | 'stopped' | 'runner_lost';
2
+ export declare const TASK_TERMINAL_STATUSES: readonly ["success", "failed", "stopped", "runner_lost"];
3
+ export type TaskTerminalStatus = (typeof TASK_TERMINAL_STATUSES)[number];
4
+ export type TaskTerminalReason = 'user_stop' | 'runner_lost' | 'launch_failed';
5
+ export declare const LEGACY_TASK_TERMINAL_ERROR_PATTERNS: {
6
+ readonly stopped: RegExp;
7
+ readonly runnerLost: RegExp;
8
+ };
9
+ export interface TaskStatusInput {
10
+ status: string;
11
+ error?: string | null;
12
+ metadata?: string | null;
13
+ }
14
+ export declare function normalizeTaskStatus(row: TaskStatusInput): TaskStatus;