@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
@@ -25,6 +25,13 @@ export interface LayoutDefinition {
25
25
  template: string;
26
26
  propsSchema: Record<string, PropSchema>;
27
27
  defaultProps: Record<string, any>;
28
+ capabilities?: LayoutCapabilities;
29
+ }
30
+ export interface LayoutCapabilities {
31
+ semanticContinuity?: boolean;
32
+ continuity?: boolean;
33
+ continuitySlot?: string;
34
+ slot?: string;
28
35
  }
29
36
  export interface CustomLayoutDefinition {
30
37
  template: string;
@@ -32,10 +39,15 @@ export interface CustomLayoutDefinition {
32
39
  version?: string;
33
40
  propsSchema?: Record<string, any>;
34
41
  defaultProps?: Record<string, any>;
42
+ capabilities?: LayoutCapabilities;
35
43
  }
36
44
  export type InlineLayoutSpec = string | {
37
45
  id: string;
38
46
  props?: Record<string, any>;
47
+ capabilities?: LayoutCapabilities;
48
+ } | {
49
+ template: string;
50
+ capabilities?: LayoutCapabilities;
39
51
  };
40
52
  export interface ValidationResult {
41
53
  valid: boolean;
@@ -97,6 +109,7 @@ export interface RenderContext {
97
109
  [key: string]: any;
98
110
  };
99
111
  context?: Record<string, any>;
112
+ semanticContinuity?: import('../conversation/types.js').SemanticContinuityContext;
100
113
  contextOptions?: {
101
114
  goals: boolean | string | string[];
102
115
  daily: boolean;
@@ -109,7 +122,8 @@ export interface RawLayoutYaml {
109
122
  description?: string;
110
123
  propsSchema?: Record<string, any>;
111
124
  template?: string;
112
- layouts?: Record<string, string>;
125
+ layouts?: Record<string, any>;
126
+ capabilities?: LayoutCapabilities;
113
127
  }
114
128
  export declare class LayoutLoadError extends Error {
115
129
  readonly layoutId?: string | undefined;
@@ -0,0 +1,33 @@
1
+ CREATE TABLE IF NOT EXISTS `common_codes` (
2
+ `code_group` text NOT NULL,
3
+ `code` text NOT NULL,
4
+ `code_name` text,
5
+ `color` text DEFAULT 'gray' NOT NULL,
6
+ `sort_order` integer NOT NULL,
7
+ `workspace_id` text,
8
+ `is_builtin` integer DEFAULT 0 NOT NULL,
9
+ `is_archived` integer DEFAULT 0 NOT NULL,
10
+ `metadata` text,
11
+ `created_at` text NOT NULL,
12
+ `updated_at` text NOT NULL,
13
+ PRIMARY KEY(`code_group`, `code`),
14
+ CONSTRAINT "common_codes_metadata_ck" CHECK("common_codes"."metadata" IS NULL OR (json_valid("common_codes"."metadata") AND json_type("common_codes"."metadata") = 'object')),
15
+ CONSTRAINT "common_codes_builtin_ck" CHECK("common_codes"."is_builtin" IN (0, 1)),
16
+ CONSTRAINT "common_codes_archived_ck" CHECK("common_codes"."is_archived" IN (0, 1))
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE INDEX IF NOT EXISTS `idx_common_codes_group_archived_order` ON `common_codes` (`code_group`,`is_archived`,`sort_order`);--> statement-breakpoint
20
+ INSERT OR IGNORE INTO `common_codes`
21
+ (`code_group`, `code`, `code_name`, `color`, `sort_order`, `workspace_id`, `is_builtin`, `is_archived`, `metadata`, `created_at`, `updated_at`)
22
+ VALUES
23
+ ('THREAD_PRIORITY', 'urgent', NULL, 'red', 0, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
24
+ ('THREAD_PRIORITY', 'high', NULL, 'orange', 1, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
25
+ ('THREAD_PRIORITY', 'medium', NULL, 'blue', 2, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
26
+ ('THREAD_PRIORITY', 'low', NULL, 'gray', 3, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
27
+ ('THREAD_STATE', 'investigating', NULL, 'violet', 0, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
28
+ ('THREAD_STATE', 'in-progress', NULL, 'blue', 1, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
29
+ ('THREAD_STATE', 'in-review', NULL, 'amber', 2, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
30
+ ('THREAD_STATE', 'on-hold', NULL, 'gray', 3, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
31
+ ('THREAD_STATE', 'done', NULL, 'green', 4, NULL, 1, 0, NULL, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), strftime('%Y-%m-%dT%H:%M:%fZ', 'now'));--> statement-breakpoint
32
+ CREATE INDEX IF NOT EXISTS `idx_threads_workspace_thread_state` ON `threads` (`workspace_id`, json_extract(metadata, '$.threadTitle.state'));--> statement-breakpoint
33
+ CREATE INDEX IF NOT EXISTS `idx_threads_workspace_thread_priority` ON `threads` (`workspace_id`, json_extract(metadata, '$.threadTitle.priority'));
@@ -0,0 +1,74 @@
1
+ -- Backfill the indexed thread_id before command-based legacy lookups are removed.
2
+ -- The command format stores a thread id as the next whitespace-delimited value
3
+ -- after --thread=. Quoted values are normalized because some older launchers
4
+ -- persisted argv strings with quotes. A prompt can also contain a documented
5
+ -- --thread= example, so the final marker is the actual CLI option appended by
6
+ -- the launcher.
7
+ WITH RECURSIVE thread_markers(id, command, marker_pos) AS (
8
+ SELECT
9
+ id,
10
+ command,
11
+ instr(command, '--thread=') AS marker_pos
12
+ FROM tasks
13
+ WHERE thread_id IS NULL
14
+ AND command IS NOT NULL
15
+ AND instr(command, '--thread=') > 0
16
+
17
+ UNION ALL
18
+
19
+ SELECT
20
+ id,
21
+ command,
22
+ marker_pos
23
+ + length('--thread=')
24
+ - 1
25
+ + instr(substr(command, marker_pos + length('--thread=')), '--thread=')
26
+ FROM thread_markers
27
+ WHERE instr(substr(command, marker_pos + length('--thread=')), '--thread=') > 0
28
+ ), last_markers AS (
29
+ SELECT id, command, MAX(marker_pos) AS marker_pos
30
+ FROM thread_markers
31
+ GROUP BY id, command
32
+ ), legacy_threads AS (
33
+ SELECT
34
+ id,
35
+ substr(command, marker_pos + length('--thread=')) AS tail
36
+ FROM last_markers
37
+ ), extracted AS (
38
+ SELECT
39
+ id,
40
+ trim(
41
+ CASE
42
+ WHEN instr(replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '), ' ') > 0
43
+ THEN substr(
44
+ replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '),
45
+ 1,
46
+ instr(replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' '), ' ') - 1
47
+ )
48
+ ELSE replace(replace(replace(tail, char(9), ' '), char(10), ' '), char(13), ' ')
49
+ END
50
+ ) AS raw_thread_id
51
+ FROM legacy_threads
52
+ ), normalized AS (
53
+ SELECT
54
+ id,
55
+ CASE
56
+ WHEN substr(raw_thread_id, 1, 1) IN ('"', char(39))
57
+ AND substr(raw_thread_id, -1, 1) = substr(raw_thread_id, 1, 1)
58
+ THEN substr(raw_thread_id, 2, length(raw_thread_id) - 2)
59
+ ELSE raw_thread_id
60
+ END AS thread_id
61
+ FROM extracted
62
+ )
63
+ UPDATE tasks
64
+ SET thread_id = (
65
+ SELECT normalized.thread_id
66
+ FROM normalized
67
+ WHERE normalized.id = tasks.id
68
+ )
69
+ WHERE tasks.thread_id IS NULL
70
+ AND tasks.id IN (
71
+ SELECT id
72
+ FROM normalized
73
+ WHERE length(thread_id) > 0
74
+ );
@@ -0,0 +1,55 @@
1
+ CREATE TABLE IF NOT EXISTS `thread_events` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `thread_id` text NOT NULL,
4
+ `seq` integer NOT NULL,
5
+ `type` text NOT NULL,
6
+ `actor_type` text NOT NULL,
7
+ `payload_json` text NOT NULL,
8
+ `created_at` text NOT NULL,
9
+ `actor_id` text,
10
+ `task_id` text,
11
+ `highlight_id` text,
12
+ FOREIGN KEY (`thread_id`) REFERENCES `threads`(`id`) ON UPDATE no action ON DELETE cascade,
13
+ CONSTRAINT "thread_events_type_ck" CHECK("thread_events"."type" IN ('thread.snapshot.imported', 'thread.title.changed', 'thread.priority.changed', 'thread.state.changed', 'thread.highlight.created', 'thread.highlight.updated', 'thread.highlight.deleted')),
14
+ CONSTRAINT "thread_events_actor_type_ck" CHECK("thread_events"."actor_type" IN ('user', 'agent', 'system')),
15
+ CONSTRAINT "thread_events_payload_json_ck" CHECK(json_valid("thread_events"."payload_json") AND json_type("thread_events"."payload_json") = 'object')
16
+ );
17
+ --> statement-breakpoint
18
+ CREATE INDEX IF NOT EXISTS `idx_thread_events_thread_seq` ON `thread_events` (`thread_id`,`seq`);--> statement-breakpoint
19
+ CREATE INDEX IF NOT EXISTS `idx_thread_events_thread_created` ON `thread_events` (`thread_id`,`created_at`);--> statement-breakpoint
20
+ CREATE UNIQUE INDEX IF NOT EXISTS `thread_events_thread_seq_uq` ON `thread_events` (`thread_id`,`seq`);--> statement-breakpoint
21
+ CREATE TABLE IF NOT EXISTS `thread_highlights` (
22
+ `id` text PRIMARY KEY NOT NULL,
23
+ `thread_id` text NOT NULL,
24
+ `source` text NOT NULL,
25
+ `kind` text NOT NULL,
26
+ `status` text DEFAULT 'active' NOT NULL,
27
+ `text` text,
28
+ `covers_from_task_id` text NOT NULL,
29
+ `covers_to_task_id` text NOT NULL,
30
+ `revision` integer DEFAULT 0 NOT NULL,
31
+ `created_at` text NOT NULL,
32
+ `updated_at` text NOT NULL,
33
+ `agent_id` text,
34
+ `source_task_id` text,
35
+ `detector_version` text,
36
+ `content_fingerprint` text,
37
+ `dismissed_at` text,
38
+ FOREIGN KEY (`thread_id`) REFERENCES `threads`(`id`) ON UPDATE no action ON DELETE cascade,
39
+ CONSTRAINT "thread_highlights_source_ck" CHECK("thread_highlights"."source" IN ('auto', 'manual')),
40
+ CONSTRAINT "thread_highlights_kind_ck" CHECK("thread_highlights"."kind" IN ('decision', 'judgment', 'issue', 'result', 'pivot')),
41
+ CONSTRAINT "thread_highlights_status_ck" CHECK("thread_highlights"."status" IN ('active', 'dismissed')),
42
+ CONSTRAINT "thread_highlights_active_text_ck" CHECK("thread_highlights"."status" = 'dismissed' OR ("thread_highlights"."text" IS NOT NULL AND length("thread_highlights"."text") > 0)),
43
+ CONSTRAINT "thread_highlights_covers_ck" CHECK(length("thread_highlights"."covers_from_task_id") > 0 AND length("thread_highlights"."covers_to_task_id") > 0),
44
+ CONSTRAINT "thread_highlights_auto_key_ck" CHECK("thread_highlights"."source" = 'manual' OR ("thread_highlights"."source" = 'auto' AND "thread_highlights"."source_task_id" IS NOT NULL AND "thread_highlights"."detector_version" IS NOT NULL AND "thread_highlights"."content_fingerprint" IS NOT NULL AND length("thread_highlights"."source_task_id") > 0 AND length("thread_highlights"."detector_version") > 0 AND length("thread_highlights"."content_fingerprint") > 0))
45
+ );
46
+ --> statement-breakpoint
47
+ CREATE INDEX IF NOT EXISTS `idx_thread_highlights_thread_status_created` ON `thread_highlights` (`thread_id`,`status`,`created_at`);--> statement-breakpoint
48
+ CREATE INDEX IF NOT EXISTS `idx_thread_highlights_thread_covers` ON `thread_highlights` (`thread_id`,`covers_from_task_id`,`covers_to_task_id`);--> statement-breakpoint
49
+ CREATE UNIQUE INDEX IF NOT EXISTS `thread_highlights_auto_idempotency_uq` ON `thread_highlights` (`thread_id`,`source_task_id`,`detector_version`,`content_fingerprint`) WHERE "thread_highlights"."source" = 'auto';
50
+ --> statement-breakpoint
51
+ CREATE TRIGGER IF NOT EXISTS thread_events_no_update
52
+ BEFORE UPDATE ON thread_events
53
+ BEGIN
54
+ SELECT RAISE(ABORT, 'thread_events is append-only');
55
+ END;