@crewx/sdk 0.9.0-rc.73 → 0.9.0-rc.75

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 (37) hide show
  1. package/dist/context-budget/continuity.d.ts +53 -0
  2. package/dist/context-budget/index.d.ts +35 -1
  3. package/dist/conversation/sqlite-provider.d.ts +4 -1
  4. package/dist/conversation/types.d.ts +28 -0
  5. package/dist/esm/index.js +219 -155
  6. package/dist/esm/plugins/index.js +129 -126
  7. package/dist/esm/repository/index.js +123 -120
  8. package/dist/facade/Crewx.d.ts +6 -2
  9. package/dist/highlight/thread-highlighter.d.ts +155 -0
  10. package/dist/index.browser.d.ts +2 -0
  11. package/dist/index.browser.js +4 -4
  12. package/dist/index.d.ts +20 -2
  13. package/dist/index.js +220 -156
  14. package/dist/layout/types.d.ts +15 -1
  15. package/dist/migrations/0018_bored_jackal.sql +33 -0
  16. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  17. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  18. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  19. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  20. package/dist/migrations/meta/_journal.json +22 -1
  21. package/dist/plugins/index.js +129 -126
  22. package/dist/repository/common-code.repository.d.ts +39 -0
  23. package/dist/repository/index.d.ts +12 -2
  24. package/dist/repository/index.js +123 -120
  25. package/dist/repository/task.repository.d.ts +5 -0
  26. package/dist/repository/thread-history.repository.d.ts +117 -0
  27. package/dist/repository/thread-title-common-code-migration.d.ts +13 -0
  28. package/dist/repository/thread-title.types.d.ts +29 -0
  29. package/dist/repository/thread.repository.d.ts +16 -0
  30. package/dist/schema/common-codes.d.ts +216 -0
  31. package/dist/schema/index.d.ts +2 -0
  32. package/dist/schema/thread-history.d.ts +518 -0
  33. package/dist/schema/threads.d.ts +2 -0
  34. package/dist/types/index.d.ts +1092 -0
  35. package/dist/utils/id.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/templates/agents/default.yaml +33 -0
@@ -4,6 +4,10 @@ import type { TaskLogEntry, TaskLogReadResult, TaskLogState } from './task-log.r
4
4
  export type TaskRow = typeof tasks.$inferSelect;
5
5
  export type NewTask = typeof tasks.$inferInsert;
6
6
  export type TaskListRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'status' | 'parent_task_id' | 'started_at' | 'completed_at' | 'duration_ms' | 'input_tokens' | 'output_tokens' | 'cost_usd' | 'error'>;
7
+ export type TaskActivityLogRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'parent_task_id' | 'started_at' | 'completed_at'>;
8
+ export type FindTasksByThreadOptions = {
9
+ projection: 'activity-log';
10
+ };
7
11
  export interface WorkflowCardRow {
8
12
  taskId: string;
9
13
  workflowRunId?: string;
@@ -178,6 +182,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
178
182
  outputTokens: number;
179
183
  costUsd: number;
180
184
  };
185
+ findTasksByThread(threadId: string, workspaceId: string | undefined, options: FindTasksByThreadOptions): TaskActivityLogRow[];
181
186
  findTasksByThread(threadId: string, workspaceId?: string): TaskRow[];
182
187
  private parseWorkflowCardMetadata;
183
188
  private extractThreadIdFromCommand;
@@ -0,0 +1,117 @@
1
+ import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { RepositoryError } from './errors.js';
3
+ import type { ThreadActorType, ThreadEvent, ThreadHighlight, ThreadHighlightKind, ThreadHighlightSource } from '../schema/index.js';
4
+ import type { ThreadPriority, ThreadState } from './thread-title.types.js';
5
+ export interface ThreadActorInput {
6
+ actorType?: ThreadActorType;
7
+ actorId?: string | null;
8
+ actor?: {
9
+ actorType?: ThreadActorType;
10
+ actorId?: string | null;
11
+ };
12
+ }
13
+ export interface ThreadSnapshotMutationInput extends ThreadActorInput {
14
+ threadId: string;
15
+ workspaceId?: string | null;
16
+ title?: string | null;
17
+ priority?: ThreadPriority | null;
18
+ state?: ThreadState | null;
19
+ taskId?: string | null;
20
+ }
21
+ export interface ThreadSnapshot {
22
+ threadId: string;
23
+ workspaceId: string | null;
24
+ title: string | null;
25
+ priority: ThreadPriority | null;
26
+ state: ThreadState | null;
27
+ metadata: string | null;
28
+ titleLocked: boolean;
29
+ updatedAt: string;
30
+ }
31
+ export interface ThreadTimelineOptions {
32
+ beforeSeq?: number;
33
+ afterSeq?: number;
34
+ limit?: number;
35
+ }
36
+ export interface ThreadTimelineQuery extends ThreadTimelineOptions {
37
+ threadId: string;
38
+ workspaceId: string;
39
+ }
40
+ export interface ThreadTimeline {
41
+ items: ThreadEvent[];
42
+ latestSeq: number;
43
+ hasMoreOlder: boolean;
44
+ }
45
+ export interface CreateThreadHighlightInput extends ThreadActorInput {
46
+ threadId: string;
47
+ workspaceId: string;
48
+ source?: ThreadHighlightSource;
49
+ kind: ThreadHighlightKind;
50
+ text: string;
51
+ taskId?: string;
52
+ coversFromTaskId?: string;
53
+ coversToTaskId?: string;
54
+ fromTaskId?: string;
55
+ toTaskId?: string;
56
+ agentId?: string | null;
57
+ sourceTaskId?: string | null;
58
+ detectorVersion?: string | null;
59
+ contentFingerprint?: string | null;
60
+ idempotencyKey?: string;
61
+ id?: string;
62
+ }
63
+ export interface UpdateThreadHighlightInput extends ThreadActorInput {
64
+ threadId: string;
65
+ workspaceId: string;
66
+ highlightId: string;
67
+ expectedRevision: number;
68
+ text?: string;
69
+ kind?: ThreadHighlightKind;
70
+ coversFromTaskId?: string;
71
+ coversToTaskId?: string;
72
+ }
73
+ export interface DismissThreadHighlightInput extends ThreadActorInput {
74
+ threadId: string;
75
+ workspaceId: string;
76
+ highlightId: string;
77
+ expectedRevision: number;
78
+ }
79
+ export interface ListActiveHighlightsOptions {
80
+ taskId?: string;
81
+ coversFromTaskId?: string;
82
+ coversToTaskId?: string;
83
+ }
84
+ export declare class ThreadHistoryConflictError extends RepositoryError {
85
+ readonly threadId: string;
86
+ readonly highlightId: string;
87
+ readonly expectedRevision: number;
88
+ readonly currentRevision: number;
89
+ constructor(threadId: string, highlightId: string, expectedRevision: number, currentRevision: number);
90
+ }
91
+ export declare class ThreadHighlightConflictError extends ThreadHistoryConflictError {
92
+ }
93
+ export declare class ThreadHistoryRepository extends BaseSqliteRepository {
94
+ private readonly dbPath?;
95
+ constructor(opts?: {
96
+ dbPath?: string;
97
+ dbRoot?: string;
98
+ });
99
+ resolveDbPath(): string;
100
+ private openHandle;
101
+ private findThread;
102
+ resolveWorkspaceId(threadId: string): string | null;
103
+ updateSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
104
+ mutateSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
105
+ updateThreadSnapshot(input: ThreadSnapshotMutationInput): ThreadSnapshot;
106
+ getLatestSeq(threadId: string, workspaceId?: string | null): number | null;
107
+ listTimeline(query: ThreadTimelineQuery): ThreadTimeline | null;
108
+ listTimeline(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
109
+ listEvents(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
110
+ getTimeline(threadId: string, workspaceId: string, options?: ThreadTimelineOptions): ThreadTimeline | null;
111
+ createHighlight(input: CreateThreadHighlightInput): ThreadHighlight;
112
+ updateHighlight(input: UpdateThreadHighlightInput): ThreadHighlight;
113
+ dismissHighlight(input: DismissThreadHighlightInput): ThreadHighlight;
114
+ listActiveHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
115
+ listHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
116
+ getActiveHighlights(threadId: string, workspaceId: string, options?: ListActiveHighlightsOptions): ThreadHighlight[] | null;
117
+ }
@@ -0,0 +1,13 @@
1
+ export interface ThreadTitleCommonCodeMigrationOptions {
2
+ dbPath?: string;
3
+ dbRoot?: string;
4
+ configuredLabels?: readonly string[];
5
+ }
6
+ export interface ThreadTitleCommonCodeMigrationResult {
7
+ migratedRows: number;
8
+ createdCodes: number;
9
+ remainingCustomReferences: number;
10
+ orphanReferences: number;
11
+ }
12
+ export declare function migrateLegacyThreadTitleCommonCodes(options?: ThreadTitleCommonCodeMigrationOptions): ThreadTitleCommonCodeMigrationResult;
13
+ export declare const migrateThreadTitleCommonCodes: typeof migrateLegacyThreadTitleCommonCodes;
@@ -0,0 +1,29 @@
1
+ export declare const THREAD_PRIORITIES: readonly ["urgent", "high", "medium", "low"];
2
+ export type ThreadPriority = (typeof THREAD_PRIORITIES)[number];
3
+ export declare const BUILTIN_THREAD_STATES: readonly ["investigating", "in-progress", "in-review", "on-hold", "done"];
4
+ export type BuiltinThreadState = (typeof BUILTIN_THREAD_STATES)[number];
5
+ export type StableThreadState = BuiltinThreadState | `c_${string}`;
6
+ export type LegacyThreadState = `custom:${string}`;
7
+ export type ThreadState = StableThreadState | LegacyThreadState;
8
+ export interface ThreadTitleMeta {
9
+ priority?: ThreadPriority;
10
+ state?: ThreadState;
11
+ }
12
+ export interface ThreadTitlePatch {
13
+ priority?: ThreadPriority | null;
14
+ state?: ThreadState | null;
15
+ }
16
+ export declare function isThreadPriority(value: unknown): value is ThreadPriority;
17
+ export declare function isThreadState(value: unknown): value is ThreadState;
18
+ export declare function customStateLabel(state: ThreadState): string | undefined;
19
+ export declare function hasThreadTitleKey(metadataJson: string | null | undefined): boolean;
20
+ export declare function readThreadTitleMeta(metadataJson: string | null | undefined): ThreadTitleMeta;
21
+ export declare function mergeThreadTitleMeta(metadataJson: string | null | undefined, patch: ThreadTitlePatch): string | null;
22
+ export declare function threadTitleSearchHaystack(meta: ThreadTitleMeta, labelNames?: ReadonlyMap<string, string>): string;
23
+ export interface ThreadTitleFilter {
24
+ values: Set<string>;
25
+ includeNone: boolean;
26
+ }
27
+ export declare function parseThreadPriorityFilter(raw: string | undefined): ThreadTitleFilter | undefined;
28
+ export declare function parseThreadStateFilter(raw: string | undefined): ThreadTitleFilter | undefined;
29
+ export declare function matchesThreadTitleFilter(current: string | undefined, filter: ThreadTitleFilter | undefined): boolean;
@@ -1,8 +1,23 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
+ import { RepositoryError } from './errors.js';
2
3
  import { threads } from '../schema/index.js';
3
4
  import type { TaskRow, TaskListRow } from './task.repository.js';
4
5
  export type ThreadRow = typeof threads.$inferSelect;
5
6
  export type NewThread = typeof threads.$inferInsert;
7
+ export interface ThreadTitleMetadataPatch {
8
+ priority?: string | null;
9
+ state?: string | null;
10
+ }
11
+ export interface ThreadTitleMetadataPatchResult {
12
+ threadId: string;
13
+ priority: string | null;
14
+ state: string | null;
15
+ }
16
+ export type ThreadTitleMetadataPatchErrorReason = 'THREAD_TITLE_PATCH_EMPTY' | 'THREAD_TITLE_PATCH_INVALID';
17
+ export declare class ThreadTitleMetadataPatchError extends RepositoryError {
18
+ readonly reason: ThreadTitleMetadataPatchErrorReason;
19
+ constructor(reason: ThreadTitleMetadataPatchErrorReason, message?: string);
20
+ }
6
21
  export declare class ThreadRepository extends BaseSqliteRepository {
7
22
  private readonly dbPath?;
8
23
  constructor(opts?: {
@@ -59,6 +74,7 @@ export declare class ThreadRepository extends BaseSqliteRepository {
59
74
  title?: string;
60
75
  titleLocked?: boolean;
61
76
  }): void;
77
+ patchThreadTitleMetadata(threadId: string, patch: ThreadTitleMetadataPatch, workspaceId?: string): ThreadTitleMetadataPatchResult | ThreadTitleMetadataPatchError | null;
62
78
  togglePin(threadId: string, workspaceId?: string): {
63
79
  pinned: boolean;
64
80
  } | null;
@@ -0,0 +1,216 @@
1
+ export declare const COMMON_CODE_GROUPS: readonly ["THREAD_STATE", "THREAD_PRIORITY"];
2
+ export type CommonCodeGroup = (typeof COMMON_CODE_GROUPS)[number];
3
+ export declare const COMMON_CODE_COLORS: readonly ["gray", "blue", "violet", "green", "amber", "orange", "red", "pink"];
4
+ export type CommonCodeColor = (typeof COMMON_CODE_COLORS)[number];
5
+ export declare const common_codes: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
6
+ name: "common_codes";
7
+ schema: undefined;
8
+ columns: {
9
+ code_group: import("drizzle-orm/sqlite-core").SQLiteColumn<{
10
+ name: "code_group";
11
+ tableName: "common_codes";
12
+ dataType: "string";
13
+ columnType: "SQLiteText";
14
+ data: string;
15
+ driverParam: string;
16
+ notNull: true;
17
+ hasDefault: false;
18
+ isPrimaryKey: false;
19
+ isAutoincrement: false;
20
+ hasRuntimeDefault: false;
21
+ enumValues: [string, ...string[]];
22
+ baseColumn: never;
23
+ identity: undefined;
24
+ generated: undefined;
25
+ }, {}, {
26
+ length: number | undefined;
27
+ }>;
28
+ code: import("drizzle-orm/sqlite-core").SQLiteColumn<{
29
+ name: "code";
30
+ tableName: "common_codes";
31
+ dataType: "string";
32
+ columnType: "SQLiteText";
33
+ data: string;
34
+ driverParam: string;
35
+ notNull: true;
36
+ hasDefault: false;
37
+ isPrimaryKey: false;
38
+ isAutoincrement: false;
39
+ hasRuntimeDefault: false;
40
+ enumValues: [string, ...string[]];
41
+ baseColumn: never;
42
+ identity: undefined;
43
+ generated: undefined;
44
+ }, {}, {
45
+ length: number | undefined;
46
+ }>;
47
+ code_name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
48
+ name: "code_name";
49
+ tableName: "common_codes";
50
+ dataType: "string";
51
+ columnType: "SQLiteText";
52
+ data: string;
53
+ driverParam: string;
54
+ notNull: false;
55
+ hasDefault: false;
56
+ isPrimaryKey: false;
57
+ isAutoincrement: false;
58
+ hasRuntimeDefault: false;
59
+ enumValues: [string, ...string[]];
60
+ baseColumn: never;
61
+ identity: undefined;
62
+ generated: undefined;
63
+ }, {}, {
64
+ length: number | undefined;
65
+ }>;
66
+ color: import("drizzle-orm/sqlite-core").SQLiteColumn<{
67
+ name: "color";
68
+ tableName: "common_codes";
69
+ dataType: "string";
70
+ columnType: "SQLiteText";
71
+ data: string;
72
+ driverParam: string;
73
+ notNull: true;
74
+ hasDefault: true;
75
+ isPrimaryKey: false;
76
+ isAutoincrement: false;
77
+ hasRuntimeDefault: false;
78
+ enumValues: [string, ...string[]];
79
+ baseColumn: never;
80
+ identity: undefined;
81
+ generated: undefined;
82
+ }, {}, {
83
+ length: number | undefined;
84
+ }>;
85
+ sort_order: import("drizzle-orm/sqlite-core").SQLiteColumn<{
86
+ name: "sort_order";
87
+ tableName: "common_codes";
88
+ dataType: "number";
89
+ columnType: "SQLiteInteger";
90
+ data: number;
91
+ driverParam: number;
92
+ notNull: true;
93
+ hasDefault: false;
94
+ isPrimaryKey: false;
95
+ isAutoincrement: false;
96
+ hasRuntimeDefault: false;
97
+ enumValues: undefined;
98
+ baseColumn: never;
99
+ identity: undefined;
100
+ generated: undefined;
101
+ }, {}, {}>;
102
+ workspace_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
103
+ name: "workspace_id";
104
+ tableName: "common_codes";
105
+ dataType: "string";
106
+ columnType: "SQLiteText";
107
+ data: string;
108
+ driverParam: string;
109
+ notNull: false;
110
+ hasDefault: false;
111
+ isPrimaryKey: false;
112
+ isAutoincrement: false;
113
+ hasRuntimeDefault: false;
114
+ enumValues: [string, ...string[]];
115
+ baseColumn: never;
116
+ identity: undefined;
117
+ generated: undefined;
118
+ }, {}, {
119
+ length: number | undefined;
120
+ }>;
121
+ is_builtin: import("drizzle-orm/sqlite-core").SQLiteColumn<{
122
+ name: "is_builtin";
123
+ tableName: "common_codes";
124
+ dataType: "number";
125
+ columnType: "SQLiteInteger";
126
+ data: number;
127
+ driverParam: number;
128
+ notNull: true;
129
+ hasDefault: true;
130
+ isPrimaryKey: false;
131
+ isAutoincrement: false;
132
+ hasRuntimeDefault: false;
133
+ enumValues: undefined;
134
+ baseColumn: never;
135
+ identity: undefined;
136
+ generated: undefined;
137
+ }, {}, {}>;
138
+ is_archived: import("drizzle-orm/sqlite-core").SQLiteColumn<{
139
+ name: "is_archived";
140
+ tableName: "common_codes";
141
+ dataType: "number";
142
+ columnType: "SQLiteInteger";
143
+ data: number;
144
+ driverParam: number;
145
+ notNull: true;
146
+ hasDefault: true;
147
+ isPrimaryKey: false;
148
+ isAutoincrement: false;
149
+ hasRuntimeDefault: false;
150
+ enumValues: undefined;
151
+ baseColumn: never;
152
+ identity: undefined;
153
+ generated: undefined;
154
+ }, {}, {}>;
155
+ metadata: import("drizzle-orm/sqlite-core").SQLiteColumn<{
156
+ name: "metadata";
157
+ tableName: "common_codes";
158
+ dataType: "string";
159
+ columnType: "SQLiteText";
160
+ data: string;
161
+ driverParam: string;
162
+ notNull: false;
163
+ hasDefault: false;
164
+ isPrimaryKey: false;
165
+ isAutoincrement: false;
166
+ hasRuntimeDefault: false;
167
+ enumValues: [string, ...string[]];
168
+ baseColumn: never;
169
+ identity: undefined;
170
+ generated: undefined;
171
+ }, {}, {
172
+ length: number | undefined;
173
+ }>;
174
+ created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
175
+ name: "created_at";
176
+ tableName: "common_codes";
177
+ dataType: "string";
178
+ columnType: "SQLiteText";
179
+ data: string;
180
+ driverParam: string;
181
+ notNull: true;
182
+ hasDefault: false;
183
+ isPrimaryKey: false;
184
+ isAutoincrement: false;
185
+ hasRuntimeDefault: false;
186
+ enumValues: [string, ...string[]];
187
+ baseColumn: never;
188
+ identity: undefined;
189
+ generated: undefined;
190
+ }, {}, {
191
+ length: number | undefined;
192
+ }>;
193
+ updated_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
194
+ name: "updated_at";
195
+ tableName: "common_codes";
196
+ dataType: "string";
197
+ columnType: "SQLiteText";
198
+ data: string;
199
+ driverParam: string;
200
+ notNull: true;
201
+ hasDefault: false;
202
+ isPrimaryKey: false;
203
+ isAutoincrement: false;
204
+ hasRuntimeDefault: false;
205
+ enumValues: [string, ...string[]];
206
+ baseColumn: never;
207
+ identity: undefined;
208
+ generated: undefined;
209
+ }, {}, {
210
+ length: number | undefined;
211
+ }>;
212
+ };
213
+ dialect: "sqlite";
214
+ }>;
215
+ export type CommonCode = typeof common_codes.$inferSelect;
216
+ export type NewCommonCode = typeof common_codes.$inferInsert;
@@ -13,3 +13,5 @@ export * from './agent-suggestions.js';
13
13
  export * from './ui-instances.js';
14
14
  export * from './ui-action-receipts.js';
15
15
  export * from './projects.js';
16
+ export * from './common-codes.js';
17
+ export * from './thread-history.js';