@sudocode-ai/types 0.1.5 → 0.1.7

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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Database migration utilities for sudocode
3
+ */
4
+ import type Database from "better-sqlite3";
5
+ export interface Migration {
6
+ version: number;
7
+ name: string;
8
+ up: (db: Database.Database) => void;
9
+ down?: (db: Database.Database) => void;
10
+ }
11
+ /**
12
+ * Get the current migration version from the database
13
+ */
14
+ export declare function getCurrentMigrationVersion(db: Database.Database): number;
15
+ /**
16
+ * Record a migration as applied
17
+ */
18
+ export declare function recordMigration(db: Database.Database, migration: Migration): void;
19
+ /**
20
+ * Run all pending migrations
21
+ */
22
+ export declare function runMigrations(db: Database.Database): void;
23
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;IACpC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC;CACxC;AA8GD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAaxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,SAAS,EAAE,SAAS,GACnB,IAAI,CAMN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAwBzD"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Database migration utilities for sudocode
3
+ */
4
+ /**
5
+ * All migrations in order
6
+ */
7
+ const MIGRATIONS = [
8
+ {
9
+ version: 1,
10
+ name: "generalize-feedback-table",
11
+ up: (db) => {
12
+ // Check if old columns exist
13
+ const tableInfo = db.pragma("table_info(issue_feedback)");
14
+ const hasOldColumns = tableInfo.some((col) => col.name === "issue_id");
15
+ if (!hasOldColumns) {
16
+ // Already migrated or new database
17
+ return;
18
+ }
19
+ // Create new table with updated schema
20
+ db.exec(`
21
+ CREATE TABLE IF NOT EXISTS issue_feedback_new (
22
+ id TEXT PRIMARY KEY,
23
+ from_id TEXT NOT NULL,
24
+ from_uuid TEXT NOT NULL,
25
+ to_id TEXT NOT NULL,
26
+ to_uuid TEXT NOT NULL,
27
+ feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),
28
+ content TEXT NOT NULL,
29
+ agent TEXT,
30
+ anchor TEXT,
31
+ dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),
32
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
33
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
34
+ FOREIGN KEY (from_id) REFERENCES issues(id) ON DELETE CASCADE,
35
+ FOREIGN KEY (from_uuid) REFERENCES issues(uuid) ON DELETE CASCADE
36
+ );
37
+ `);
38
+ // Copy data from old table to new table
39
+ db.exec(`
40
+ INSERT INTO issue_feedback_new (
41
+ id, from_id, from_uuid, to_id, to_uuid, feedback_type,
42
+ content, agent, anchor, dismissed, created_at, updated_at
43
+ )
44
+ SELECT
45
+ id, issue_id, issue_uuid, spec_id, spec_uuid, feedback_type,
46
+ content, agent, anchor, dismissed, created_at, updated_at
47
+ FROM issue_feedback;
48
+ `);
49
+ // Drop old table
50
+ db.exec(`DROP TABLE issue_feedback;`);
51
+ // Rename new table to original name
52
+ db.exec(`ALTER TABLE issue_feedback_new RENAME TO issue_feedback;`);
53
+ // Recreate indexes
54
+ db.exec(`
55
+ CREATE INDEX IF NOT EXISTS idx_feedback_from_id ON issue_feedback(from_id);
56
+ CREATE INDEX IF NOT EXISTS idx_feedback_from_uuid ON issue_feedback(from_uuid);
57
+ CREATE INDEX IF NOT EXISTS idx_feedback_to_id ON issue_feedback(to_id);
58
+ CREATE INDEX IF NOT EXISTS idx_feedback_to_uuid ON issue_feedback(to_uuid);
59
+ CREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);
60
+ CREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);
61
+ CREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);
62
+ `);
63
+ },
64
+ down: (db) => {
65
+ // Rollback: rename columns back
66
+ db.exec(`
67
+ CREATE TABLE IF NOT EXISTS issue_feedback_old (
68
+ id TEXT PRIMARY KEY,
69
+ issue_id TEXT NOT NULL,
70
+ issue_uuid TEXT NOT NULL,
71
+ spec_id TEXT NOT NULL,
72
+ spec_uuid TEXT NOT NULL,
73
+ feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),
74
+ content TEXT NOT NULL,
75
+ agent TEXT,
76
+ anchor TEXT,
77
+ dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),
78
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
79
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
80
+ FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,
81
+ FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE CASCADE,
82
+ FOREIGN KEY (spec_id) REFERENCES specs(id) ON DELETE CASCADE,
83
+ FOREIGN KEY (spec_uuid) REFERENCES specs(uuid) ON DELETE CASCADE
84
+ );
85
+ `);
86
+ db.exec(`
87
+ INSERT INTO issue_feedback_old (
88
+ id, issue_id, issue_uuid, spec_id, spec_uuid, feedback_type,
89
+ content, agent, anchor, dismissed, created_at, updated_at
90
+ )
91
+ SELECT
92
+ id, from_id, from_uuid, to_id, to_uuid, feedback_type,
93
+ content, agent, anchor, dismissed, created_at, updated_at
94
+ FROM issue_feedback;
95
+ `);
96
+ db.exec(`DROP TABLE issue_feedback;`);
97
+ db.exec(`ALTER TABLE issue_feedback_old RENAME TO issue_feedback;`);
98
+ },
99
+ },
100
+ ];
101
+ /**
102
+ * Get the current migration version from the database
103
+ */
104
+ export function getCurrentMigrationVersion(db) {
105
+ // Create migrations table if it doesn't exist
106
+ db.exec(`
107
+ CREATE TABLE IF NOT EXISTS migrations (
108
+ version INTEGER PRIMARY KEY,
109
+ name TEXT NOT NULL,
110
+ applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
111
+ )
112
+ `);
113
+ const stmt = db.prepare("SELECT MAX(version) as version FROM migrations");
114
+ const result = stmt.get();
115
+ return result.version ?? 0;
116
+ }
117
+ /**
118
+ * Record a migration as applied
119
+ */
120
+ export function recordMigration(db, migration) {
121
+ const stmt = db.prepare(`
122
+ INSERT OR REPLACE INTO migrations (version, name)
123
+ VALUES (?, ?)
124
+ `);
125
+ stmt.run(migration.version, migration.name);
126
+ }
127
+ /**
128
+ * Run all pending migrations
129
+ */
130
+ export function runMigrations(db) {
131
+ const currentVersion = getCurrentMigrationVersion(db);
132
+ const pendingMigrations = MIGRATIONS.filter((m) => m.version > currentVersion);
133
+ if (pendingMigrations.length === 0) {
134
+ return;
135
+ }
136
+ console.log(`Running ${pendingMigrations.length} pending migration(s)...`);
137
+ for (const migration of pendingMigrations) {
138
+ console.log(` Applying migration ${migration.version}: ${migration.name}`);
139
+ try {
140
+ migration.up(db);
141
+ recordMigration(db, migration);
142
+ console.log(` ✓ Migration ${migration.version} applied successfully`);
143
+ }
144
+ catch (error) {
145
+ console.error(` ✗ Migration ${migration.version} failed:`, error);
146
+ throw error;
147
+ }
148
+ }
149
+ }
150
+ //# sourceMappingURL=migrations.js.map
@@ -0,0 +1 @@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,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,iBAAiB,SAAS,CAAC,OAAO,UAAU,EAAE,KAAK,CAAC,CAAC;YACnE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC"}
package/dist/schema.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare const ISSUES_TABLE = "\nCREATE TABLE IF NOT EXISTS issues (\n
15
15
  export declare const RELATIONSHIPS_TABLE = "\nCREATE TABLE IF NOT EXISTS relationships (\n from_id TEXT NOT NULL,\n from_uuid TEXT NOT NULL,\n from_type TEXT NOT NULL,\n to_id TEXT NOT NULL,\n to_uuid TEXT NOT NULL,\n to_type TEXT NOT NULL,\n relationship_type TEXT NOT NULL,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n metadata TEXT,\n PRIMARY KEY (from_id, from_type, to_id, to_type, relationship_type)\n);\n";
16
16
  export declare const TAGS_TABLE = "\nCREATE TABLE IF NOT EXISTS tags (\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n tag TEXT NOT NULL,\n PRIMARY KEY (entity_id, entity_type, tag)\n);\n";
17
17
  export declare const EVENTS_TABLE = "\nCREATE TABLE IF NOT EXISTS events (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n entity_id TEXT NOT NULL,\n entity_uuid TEXT NOT NULL,\n entity_type TEXT NOT NULL,\n event_type TEXT NOT NULL,\n actor TEXT NOT NULL,\n old_value TEXT,\n new_value TEXT,\n comment TEXT,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n git_commit_sha TEXT,\n source TEXT\n);\n";
18
- export declare const ISSUE_FEEDBACK_TABLE = "\nCREATE TABLE IF NOT EXISTS issue_feedback (\n id TEXT PRIMARY KEY,\n issue_id TEXT NOT NULL,\n issue_uuid TEXT NOT NULL,\n spec_id TEXT NOT NULL,\n spec_uuid TEXT NOT NULL,\n feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),\n content TEXT NOT NULL,\n agent TEXT,\n anchor TEXT,\n dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,\n FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE CASCADE,\n FOREIGN KEY (spec_id) REFERENCES specs(id) ON DELETE CASCADE,\n FOREIGN KEY (spec_uuid) REFERENCES specs(uuid) ON DELETE CASCADE\n);\n";
18
+ export declare const ISSUE_FEEDBACK_TABLE = "\nCREATE TABLE IF NOT EXISTS issue_feedback (\n id TEXT PRIMARY KEY,\n from_id TEXT NOT NULL,\n from_uuid TEXT NOT NULL,\n to_id TEXT NOT NULL,\n to_uuid TEXT NOT NULL,\n feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),\n content TEXT NOT NULL,\n agent TEXT,\n anchor TEXT,\n dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (from_id) REFERENCES issues(id) ON DELETE CASCADE,\n FOREIGN KEY (from_uuid) REFERENCES issues(uuid) ON DELETE CASCADE\n);\n";
19
19
  export declare const EXECUTIONS_TABLE = "\nCREATE TABLE IF NOT EXISTS executions (\n id TEXT PRIMARY KEY,\n issue_id TEXT,\n issue_uuid TEXT,\n\n -- Execution mode and configuration\n mode TEXT CHECK(mode IN ('worktree', 'local')),\n prompt TEXT,\n config TEXT,\n\n -- Process information (legacy + new)\n agent_type TEXT CHECK(agent_type IN ('claude-code', 'codex')),\n session_id TEXT,\n workflow_execution_id TEXT,\n\n -- Git/branch information\n target_branch TEXT NOT NULL,\n branch_name TEXT NOT NULL,\n before_commit TEXT,\n after_commit TEXT,\n worktree_path TEXT,\n\n -- Status (unified - supports both old and new statuses)\n status TEXT NOT NULL CHECK(status IN (\n 'preparing', 'pending', 'running', 'paused',\n 'completed', 'failed', 'cancelled', 'stopped'\n )),\n\n -- Timing (consistent with other tables)\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n started_at DATETIME,\n completed_at DATETIME,\n cancelled_at DATETIME,\n\n -- Results and metadata\n exit_code INTEGER,\n error_message TEXT,\n error TEXT,\n model TEXT,\n summary TEXT,\n files_changed TEXT,\n\n -- Relationships\n parent_execution_id TEXT,\n\n -- Multi-step workflow support (future extension)\n step_type TEXT,\n step_index INTEGER,\n step_config TEXT,\n\n FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL,\n FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE SET NULL,\n FOREIGN KEY (parent_execution_id) REFERENCES executions(id) ON DELETE SET NULL\n);\n";
20
20
  export declare const PROMPT_TEMPLATES_TABLE = "\nCREATE TABLE IF NOT EXISTS prompt_templates (\n id TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n description TEXT,\n type TEXT NOT NULL CHECK(type IN ('issue', 'spec', 'custom')),\n template TEXT NOT NULL,\n variables TEXT NOT NULL,\n is_default INTEGER NOT NULL DEFAULT 0 CHECK(is_default IN (0, 1)),\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n";
21
21
  export declare const EXECUTION_LOGS_TABLE = "\nCREATE TABLE IF NOT EXISTS execution_logs (\n execution_id TEXT PRIMARY KEY,\n raw_logs TEXT NOT NULL DEFAULT '',\n byte_size INTEGER NOT NULL DEFAULT 0,\n line_count INTEGER NOT NULL DEFAULT 0,\n created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\n FOREIGN KEY (execution_id) REFERENCES executions(id) ON DELETE CASCADE\n);\n";
@@ -27,15 +27,15 @@ export declare const ISSUES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_issues_u
27
27
  export declare const RELATIONSHIPS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_rel_from_id ON relationships(from_id, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_from_uuid ON relationships(from_uuid, from_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_id ON relationships(to_id, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_to_uuid ON relationships(to_uuid, to_type);\nCREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relationship_type);\nCREATE INDEX IF NOT EXISTS idx_rel_created_at ON relationships(created_at);\n";
28
28
  export declare const TAGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_tags_entity_id ON tags(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_entity_uuid ON tags(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_tags_tag ON tags(tag);\n";
29
29
  export declare const EVENTS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_events_entity_id ON events(entity_id, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_entity_uuid ON events(entity_uuid, entity_type);\nCREATE INDEX IF NOT EXISTS idx_events_type ON events(event_type);\nCREATE INDEX IF NOT EXISTS idx_events_actor ON events(actor);\nCREATE INDEX IF NOT EXISTS idx_events_created_at ON events(created_at);\nCREATE INDEX IF NOT EXISTS idx_events_git_commit ON events(git_commit_sha);\n";
30
- export declare const ISSUE_FEEDBACK_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_feedback_issue_id ON issue_feedback(issue_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_issue_uuid ON issue_feedback(issue_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_spec_id ON issue_feedback(spec_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_spec_uuid ON issue_feedback(spec_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);\nCREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);\nCREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);\n";
30
+ export declare const ISSUE_FEEDBACK_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_feedback_from_id ON issue_feedback(from_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_from_uuid ON issue_feedback(from_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_to_id ON issue_feedback(to_id);\nCREATE INDEX IF NOT EXISTS idx_feedback_to_uuid ON issue_feedback(to_uuid);\nCREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);\nCREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);\nCREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);\n";
31
31
  export declare const EXECUTIONS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_executions_issue_id ON executions(issue_id);\nCREATE INDEX IF NOT EXISTS idx_executions_issue_uuid ON executions(issue_uuid);\nCREATE INDEX IF NOT EXISTS idx_executions_status ON executions(status);\nCREATE INDEX IF NOT EXISTS idx_executions_session_id ON executions(session_id);\nCREATE INDEX IF NOT EXISTS idx_executions_parent ON executions(parent_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_created_at ON executions(created_at);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow ON executions(workflow_execution_id);\nCREATE INDEX IF NOT EXISTS idx_executions_workflow_step ON executions(workflow_execution_id, step_index);\nCREATE INDEX IF NOT EXISTS idx_executions_step_type ON executions(step_type);\n";
32
32
  export declare const PROMPT_TEMPLATES_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_templates_type ON prompt_templates(type);\nCREATE INDEX IF NOT EXISTS idx_templates_default ON prompt_templates(is_default);\n";
33
33
  export declare const EXECUTION_LOGS_INDEXES = "\nCREATE INDEX IF NOT EXISTS idx_execution_logs_updated_at ON execution_logs(updated_at);\nCREATE INDEX IF NOT EXISTS idx_execution_logs_byte_size ON execution_logs(byte_size);\nCREATE INDEX IF NOT EXISTS idx_execution_logs_line_count ON execution_logs(line_count);\n";
34
34
  /**
35
35
  * View definitions
36
36
  */
37
- export declare const READY_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS ready_issues AS\nSELECT i.*\nFROM issues i\nWHERE i.status = 'open'\n AND i.archived = 0\n AND NOT EXISTS (\n SELECT 1 FROM relationships r\n JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'\n WHERE r.from_id = i.id\n AND r.from_type = 'issue'\n AND r.relationship_type = 'blocks'\n AND blocker.status IN ('open', 'in_progress', 'blocked')\n );\n";
38
- export declare const BLOCKED_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS blocked_issues AS\nSELECT\n i.*,\n COUNT(r.to_id) as blocked_by_count,\n GROUP_CONCAT(r.to_id) as blocked_by_ids\nFROM issues i\nJOIN relationships r ON i.id = r.from_id AND r.from_type = 'issue'\nJOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'\nWHERE i.status IN ('open', 'in_progress', 'blocked')\n AND i.archived = 0\n AND r.relationship_type = 'blocks'\n AND blocker.status IN ('open', 'in_progress', 'blocked')\nGROUP BY i.id;\n";
37
+ export declare const READY_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS ready_issues AS\nSELECT i.*\nFROM issues i\nWHERE i.status = 'open'\n AND i.archived = 0\n AND NOT EXISTS (\n SELECT 1 FROM relationships r\n JOIN issues blocker ON (\n (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')\n )\n WHERE (\n (r.relationship_type = 'blocks' AND r.to_id = i.id AND r.to_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.from_id = i.id AND r.from_type = 'issue')\n )\n AND blocker.status IN ('open', 'in_progress', 'blocked')\n );\n";
38
+ export declare const BLOCKED_ISSUES_VIEW = "\nCREATE VIEW IF NOT EXISTS blocked_issues AS\nSELECT\n i.*,\n COUNT(DISTINCT blocker.id) as blocked_by_count,\n GROUP_CONCAT(DISTINCT blocker.id) as blocked_by_ids\nFROM issues i\nJOIN relationships r ON (\n (r.relationship_type = 'blocks' AND i.id = r.to_id AND r.to_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND i.id = r.from_id AND r.from_type = 'issue')\n)\nJOIN issues blocker ON (\n (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR\n (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')\n)\nWHERE i.status IN ('open', 'in_progress', 'blocked')\n AND i.archived = 0\n AND blocker.status IN ('open', 'in_progress', 'blocked')\nGROUP BY i.id;\n";
39
39
  /**
40
40
  * Combined schema initialization
41
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,SAAS,uSAarB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,WAAW,ysBAiBvB,CAAC;AAEF,eAAO,MAAM,YAAY,qwBAmBxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,iaAa/B,CAAC;AAEF,eAAO,MAAM,UAAU,mNAQtB,CAAC;AAEF,eAAO,MAAM,YAAY,uZAexB,CAAC;AAEF,eAAO,MAAM,oBAAoB,6zBAmBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,wmDAwD5B,CAAC;AAGF,eAAO,MAAM,sBAAsB,ocAYlC,CAAC;AAIF,eAAO,MAAM,oBAAoB,iaAUhC,CAAC;AAEF;;GAEG;AAEH,eAAO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BAAqB,seAOjC,CAAC;AAEF,eAAO,MAAM,YAAY,kOAIxB,CAAC;AAEF,eAAO,MAAM,cAAc,2cAO1B,CAAC;AAEF,eAAO,MAAM,sBAAsB,+iBAQlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,0vBAU9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,oKAGpC,CAAC;AAEF,eAAO,MAAM,sBAAsB,gRAIlC,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,iBAAiB,gqBAkB7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,ovBAmB/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,UAUtB,CAAC;AAEF,eAAO,MAAM,WAAW,UAUvB,CAAC;AAEF,eAAO,MAAM,SAAS,UAA2C,CAAC"}
package/dist/schema.js CHANGED
@@ -103,10 +103,10 @@ CREATE TABLE IF NOT EXISTS events (
103
103
  export const ISSUE_FEEDBACK_TABLE = `
104
104
  CREATE TABLE IF NOT EXISTS issue_feedback (
105
105
  id TEXT PRIMARY KEY,
106
- issue_id TEXT NOT NULL,
107
- issue_uuid TEXT NOT NULL,
108
- spec_id TEXT NOT NULL,
109
- spec_uuid TEXT NOT NULL,
106
+ from_id TEXT NOT NULL,
107
+ from_uuid TEXT NOT NULL,
108
+ to_id TEXT NOT NULL,
109
+ to_uuid TEXT NOT NULL,
110
110
  feedback_type TEXT NOT NULL CHECK(feedback_type IN ('comment', 'suggestion', 'request')),
111
111
  content TEXT NOT NULL,
112
112
  agent TEXT,
@@ -114,10 +114,8 @@ CREATE TABLE IF NOT EXISTS issue_feedback (
114
114
  dismissed INTEGER NOT NULL DEFAULT 0 CHECK(dismissed IN (0, 1)),
115
115
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
116
116
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
117
- FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE,
118
- FOREIGN KEY (issue_uuid) REFERENCES issues(uuid) ON DELETE CASCADE,
119
- FOREIGN KEY (spec_id) REFERENCES specs(id) ON DELETE CASCADE,
120
- FOREIGN KEY (spec_uuid) REFERENCES specs(uuid) ON DELETE CASCADE
117
+ FOREIGN KEY (from_id) REFERENCES issues(id) ON DELETE CASCADE,
118
+ FOREIGN KEY (from_uuid) REFERENCES issues(uuid) ON DELETE CASCADE
121
119
  );
122
120
  `;
123
121
  export const EXECUTIONS_TABLE = `
@@ -250,10 +248,10 @@ CREATE INDEX IF NOT EXISTS idx_events_created_at ON events(created_at);
250
248
  CREATE INDEX IF NOT EXISTS idx_events_git_commit ON events(git_commit_sha);
251
249
  `;
252
250
  export const ISSUE_FEEDBACK_INDEXES = `
253
- CREATE INDEX IF NOT EXISTS idx_feedback_issue_id ON issue_feedback(issue_id);
254
- CREATE INDEX IF NOT EXISTS idx_feedback_issue_uuid ON issue_feedback(issue_uuid);
255
- CREATE INDEX IF NOT EXISTS idx_feedback_spec_id ON issue_feedback(spec_id);
256
- CREATE INDEX IF NOT EXISTS idx_feedback_spec_uuid ON issue_feedback(spec_uuid);
251
+ CREATE INDEX IF NOT EXISTS idx_feedback_from_id ON issue_feedback(from_id);
252
+ CREATE INDEX IF NOT EXISTS idx_feedback_from_uuid ON issue_feedback(from_uuid);
253
+ CREATE INDEX IF NOT EXISTS idx_feedback_to_id ON issue_feedback(to_id);
254
+ CREATE INDEX IF NOT EXISTS idx_feedback_to_uuid ON issue_feedback(to_uuid);
257
255
  CREATE INDEX IF NOT EXISTS idx_feedback_dismissed ON issue_feedback(dismissed);
258
256
  CREATE INDEX IF NOT EXISTS idx_feedback_type ON issue_feedback(feedback_type);
259
257
  CREATE INDEX IF NOT EXISTS idx_feedback_created_at ON issue_feedback(created_at);
@@ -289,10 +287,14 @@ WHERE i.status = 'open'
289
287
  AND i.archived = 0
290
288
  AND NOT EXISTS (
291
289
  SELECT 1 FROM relationships r
292
- JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'
293
- WHERE r.from_id = i.id
294
- AND r.from_type = 'issue'
295
- AND r.relationship_type = 'blocks'
290
+ JOIN issues blocker ON (
291
+ (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR
292
+ (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')
293
+ )
294
+ WHERE (
295
+ (r.relationship_type = 'blocks' AND r.to_id = i.id AND r.to_type = 'issue') OR
296
+ (r.relationship_type = 'depends-on' AND r.from_id = i.id AND r.from_type = 'issue')
297
+ )
296
298
  AND blocker.status IN ('open', 'in_progress', 'blocked')
297
299
  );
298
300
  `;
@@ -300,14 +302,19 @@ export const BLOCKED_ISSUES_VIEW = `
300
302
  CREATE VIEW IF NOT EXISTS blocked_issues AS
301
303
  SELECT
302
304
  i.*,
303
- COUNT(r.to_id) as blocked_by_count,
304
- GROUP_CONCAT(r.to_id) as blocked_by_ids
305
+ COUNT(DISTINCT blocker.id) as blocked_by_count,
306
+ GROUP_CONCAT(DISTINCT blocker.id) as blocked_by_ids
305
307
  FROM issues i
306
- JOIN relationships r ON i.id = r.from_id AND r.from_type = 'issue'
307
- JOIN issues blocker ON r.to_id = blocker.id AND r.to_type = 'issue'
308
+ JOIN relationships r ON (
309
+ (r.relationship_type = 'blocks' AND i.id = r.to_id AND r.to_type = 'issue') OR
310
+ (r.relationship_type = 'depends-on' AND i.id = r.from_id AND r.from_type = 'issue')
311
+ )
312
+ JOIN issues blocker ON (
313
+ (r.relationship_type = 'blocks' AND r.from_id = blocker.id AND r.from_type = 'issue') OR
314
+ (r.relationship_type = 'depends-on' AND r.to_id = blocker.id AND r.to_type = 'issue')
315
+ )
308
316
  WHERE i.status IN ('open', 'in_progress', 'blocked')
309
317
  AND i.archived = 0
310
- AND r.relationship_type = 'blocks'
311
318
  AND blocker.status IN ('open', 'in_progress', 'blocked')
312
319
  GROUP BY i.id;
313
320
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":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B,gBAAgB;IAChB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,YAAY;IACZ,cAAc;IACd,sBAAsB;IACtB,kBAAkB;IAClB,wBAAwB;IACxB,sBAAsB;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudocode-ai/types",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "TypeScript type definitions for sudocode",
5
5
  "types": "src/index.d.ts",
6
6
  "type": "module",
@@ -12,6 +12,10 @@
12
12
  "./schema": {
13
13
  "types": "./dist/schema.d.ts",
14
14
  "default": "./dist/schema.js"
15
+ },
16
+ "./migrations": {
17
+ "types": "./dist/migrations.d.ts",
18
+ "default": "./dist/migrations.js"
15
19
  }
16
20
  },
17
21
  "scripts": {
package/src/index.d.ts CHANGED
@@ -94,14 +94,15 @@ export type EventType =
94
94
  | "tag_removed";
95
95
 
96
96
  /**
97
- * Issue-based spec feedback types
97
+ * Issue-based feedback types
98
+ * Feedback can target either a spec or another issue (type inferred from ID prefix)
98
99
  */
99
100
  export interface IssueFeedback {
100
101
  id: string;
101
- issue_id: string;
102
- issue_uuid: string;
103
- spec_id: string;
104
- spec_uuid: string;
102
+ from_id: string;
103
+ from_uuid: string;
104
+ to_id: string;
105
+ to_uuid: string;
105
106
  feedback_type: FeedbackType;
106
107
  content: string;
107
108
  agent?: string;
@@ -155,8 +156,8 @@ export interface IssueJSONL extends Issue {
155
156
 
156
157
  export interface FeedbackJSONL {
157
158
  id: string;
158
- issue_id: string;
159
- spec_id: string;
159
+ from_id: string;
160
+ to_id: string;
160
161
  feedback_type: FeedbackType;
161
162
  content: string;
162
163
  agent?: string;
@@ -1,90 +0,0 @@
1
- /**
2
- * Claude to AG-UI Transformation Logic
3
- *
4
- * Shared transformation functions for converting raw Claude stream-json messages
5
- * to AG-UI events. Used by both:
6
- * - Backend: Real-time transformation for SSE streaming
7
- * - Frontend: Historical transformation for log replay
8
- *
9
- * @module claude-to-ag-ui
10
- */
11
- /**
12
- * Claude stream-json message format
13
- * Based on Claude Code CLI output structure
14
- */
15
- export interface ClaudeStreamMessage {
16
- type: "assistant" | "tool_result" | "result" | "error";
17
- message?: {
18
- id?: string;
19
- model?: string;
20
- role?: string;
21
- content?: Array<{
22
- type: "text" | "tool_use";
23
- text?: string;
24
- id?: string;
25
- name?: string;
26
- input?: any;
27
- }>;
28
- stop_reason?: string;
29
- stop_sequence?: string | null;
30
- };
31
- result?: {
32
- tool_use_id?: string;
33
- content?: Array<{
34
- type: string;
35
- text?: string;
36
- }>;
37
- };
38
- usage?: {
39
- input_tokens?: number;
40
- output_tokens?: number;
41
- cache_read_input_tokens?: number;
42
- cache_creation_input_tokens?: number;
43
- };
44
- error?: {
45
- message: string;
46
- type?: string;
47
- };
48
- }
49
- /**
50
- * AG-UI Event types
51
- * Minimal interface needed for transformation
52
- */
53
- export interface AgUiEvent {
54
- type: string;
55
- timestamp: number;
56
- [key: string]: any;
57
- }
58
- /**
59
- * Transform a single Claude stream-json message to AG-UI events
60
- *
61
- * @param message - Raw Claude message from stream-json output
62
- * @param startSequence - Starting sequence number for events
63
- * @returns Array of AG-UI events (may be empty for unhandled message types)
64
- *
65
- * @example
66
- * ```typescript
67
- * const message = JSON.parse(line);
68
- * const events = transformClaudeMessageToAgUi(message, 0);
69
- * events.forEach(event => console.log(event));
70
- * ```
71
- */
72
- export declare function transformClaudeMessageToAgUi(message: ClaudeStreamMessage, startSequence: number): AgUiEvent[];
73
- /**
74
- * Parse array of raw execution logs (NDJSON format) to AG-UI events
75
- *
76
- * Processes each line as a separate Claude message and transforms to AG-UI events.
77
- * Handles parse errors gracefully by logging warnings and continuing.
78
- *
79
- * @param rawLogs - Array of NDJSON log lines
80
- * @returns Promise resolving to array of AG-UI events
81
- *
82
- * @example
83
- * ```typescript
84
- * const logs = await fetch('/api/executions/123/logs').then(r => r.json());
85
- * const events = await parseExecutionLogs(logs.logs);
86
- * console.log(`Parsed ${events.length} events`);
87
- * ```
88
- */
89
- export declare function parseExecutionLogs(rawLogs: string[]): Promise<AgUiEvent[]>;
90
- //# sourceMappingURL=claude-to-ag-ui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-to-ag-ui.d.ts","sourceRoot":"","sources":["../src/claude-to-ag-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvD,OAAO,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;YAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,EAAE,CAAC,EAAE,MAAM,CAAC;YACZ,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,GAAG,CAAC;SACb,CAAC,CAAC;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;IACF,MAAM,CAAC,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClD,CAAC;IACF,KAAK,CAAC,EAAE;QACN,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,2BAA2B,CAAC,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,mBAAmB,EAC5B,aAAa,EAAE,MAAM,GACpB,SAAS,EAAE,CAoGb;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,SAAS,EAAE,CAAC,CAiCtB"}
@@ -1,153 +0,0 @@
1
- /**
2
- * Claude to AG-UI Transformation Logic
3
- *
4
- * Shared transformation functions for converting raw Claude stream-json messages
5
- * to AG-UI events. Used by both:
6
- * - Backend: Real-time transformation for SSE streaming
7
- * - Frontend: Historical transformation for log replay
8
- *
9
- * @module claude-to-ag-ui
10
- */
11
- /**
12
- * Transform a single Claude stream-json message to AG-UI events
13
- *
14
- * @param message - Raw Claude message from stream-json output
15
- * @param startSequence - Starting sequence number for events
16
- * @returns Array of AG-UI events (may be empty for unhandled message types)
17
- *
18
- * @example
19
- * ```typescript
20
- * const message = JSON.parse(line);
21
- * const events = transformClaudeMessageToAgUi(message, 0);
22
- * events.forEach(event => console.log(event));
23
- * ```
24
- */
25
- export function transformClaudeMessageToAgUi(message, startSequence) {
26
- const events = [];
27
- const timestamp = Date.now();
28
- switch (message.type) {
29
- case "assistant": {
30
- // Extract content blocks from assistant message
31
- const content = message.message?.content || [];
32
- for (const block of content) {
33
- if (block.type === "text" && block.text) {
34
- // Text message → TEXT_MESSAGE_CONTENT event
35
- events.push({
36
- type: "CUSTOM",
37
- timestamp,
38
- name: "TEXT_MESSAGE_CONTENT",
39
- value: {
40
- content: block.text,
41
- },
42
- });
43
- }
44
- else if (block.type === "tool_use") {
45
- // Tool use → TOOL_CALL_START + TOOL_CALL_ARGS events
46
- const toolId = block.id || `tool-${Date.now()}`;
47
- events.push({
48
- type: "TOOL_CALL_START",
49
- timestamp,
50
- toolCallId: toolId,
51
- toolCallName: block.name || "unknown",
52
- }, {
53
- type: "TOOL_CALL_ARGS",
54
- timestamp,
55
- toolCallId: toolId,
56
- delta: JSON.stringify(block.input || {}),
57
- });
58
- }
59
- }
60
- break;
61
- }
62
- case "tool_result": {
63
- // Tool result → TOOL_CALL_END + TOOL_CALL_RESULT events
64
- const toolUseId = message.result?.tool_use_id || "unknown";
65
- const resultContent = message.result?.content || [];
66
- const resultText = resultContent.find((c) => c.type === "text")?.text || "";
67
- events.push({
68
- type: "TOOL_CALL_END",
69
- timestamp,
70
- toolCallId: toolUseId,
71
- }, {
72
- type: "TOOL_CALL_RESULT",
73
- timestamp,
74
- messageId: `msg-${toolUseId}`,
75
- toolCallId: toolUseId,
76
- content: resultText,
77
- });
78
- break;
79
- }
80
- case "result": {
81
- // Result message with usage → USAGE_UPDATE event
82
- if (message.usage) {
83
- const usage = message.usage;
84
- events.push({
85
- type: "CUSTOM",
86
- timestamp,
87
- name: "USAGE_UPDATE",
88
- value: {
89
- inputTokens: usage.input_tokens || 0,
90
- outputTokens: usage.output_tokens || 0,
91
- cacheTokens: usage.cache_read_input_tokens || 0,
92
- totalTokens: (usage.input_tokens || 0) + (usage.output_tokens || 0),
93
- },
94
- });
95
- }
96
- break;
97
- }
98
- case "error": {
99
- // Error message → RUN_ERROR event
100
- events.push({
101
- type: "RUN_ERROR",
102
- timestamp,
103
- message: message.error?.message || "Unknown error",
104
- errorType: message.error?.type,
105
- });
106
- break;
107
- }
108
- }
109
- return events;
110
- }
111
- /**
112
- * Parse array of raw execution logs (NDJSON format) to AG-UI events
113
- *
114
- * Processes each line as a separate Claude message and transforms to AG-UI events.
115
- * Handles parse errors gracefully by logging warnings and continuing.
116
- *
117
- * @param rawLogs - Array of NDJSON log lines
118
- * @returns Promise resolving to array of AG-UI events
119
- *
120
- * @example
121
- * ```typescript
122
- * const logs = await fetch('/api/executions/123/logs').then(r => r.json());
123
- * const events = await parseExecutionLogs(logs.logs);
124
- * console.log(`Parsed ${events.length} events`);
125
- * ```
126
- */
127
- export async function parseExecutionLogs(rawLogs) {
128
- const events = [];
129
- let sequence = 0;
130
- for (let i = 0; i < rawLogs.length; i++) {
131
- const line = rawLogs[i].trim();
132
- // Skip empty lines
133
- if (!line) {
134
- continue;
135
- }
136
- try {
137
- // Parse JSON line
138
- const message = JSON.parse(line);
139
- // Transform to AG-UI events
140
- const agUiEvents = transformClaudeMessageToAgUi(message, sequence);
141
- // Accumulate events
142
- events.push(...agUiEvents);
143
- sequence += agUiEvents.length;
144
- }
145
- catch (error) {
146
- // Log warning but continue processing
147
- console.warn(`[parseExecutionLogs] Failed to parse log line ${i + 1}:`, error instanceof Error ? error.message : String(error));
148
- // Don't throw - continue with remaining logs
149
- }
150
- }
151
- return events;
152
- }
153
- //# sourceMappingURL=claude-to-ag-ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claude-to-ag-ui.js","sourceRoot":"","sources":["../src/claude-to-ag-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgDH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA4B,EAC5B,aAAqB;IAErB,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,gDAAgD;YAChD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;YAE/C,K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