diff --git a/packages/core/schema.json b/packages/core/schema.json index 14572de197d..9b774734a7a 100644 --- a/packages/core/schema.json +++ b/packages/core/schema.json @@ -2,9 +2,7 @@ "version": "7", "dialect": "sqlite", "id": "15060ec5-05f7-4b86-b2a5-9108609432b3", - "prevIds": [ - "1551a157-8959-4ba9-a52b-4ea3b7b28cae" - ], + "prevIds": ["1551a157-8959-4ba9-a52b-4ea3b7b28cae"], "ddl": [ { "name": "account_state", @@ -1355,13 +1353,9 @@ "table": "workspace" }, { - "columns": [ - "active_account_id" - ], + "columns": ["active_account_id"], "tableTo": "account", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "SET NULL", "nameExplicit": false, @@ -1370,13 +1364,9 @@ "table": "account_state" }, { - "columns": [ - "aggregate_id" - ], + "columns": ["aggregate_id"], "tableTo": "event_sequence", - "columnsTo": [ - "aggregate_id" - ], + "columnsTo": ["aggregate_id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1385,13 +1375,9 @@ "table": "event" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1400,13 +1386,9 @@ "table": "permission" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1415,13 +1397,9 @@ "table": "project_directory" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session_v2", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1430,13 +1408,9 @@ "table": "instruction_entry" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session_v2", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1445,13 +1419,9 @@ "table": "instruction_state" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session_v2", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1460,13 +1430,9 @@ "table": "session_message" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "tableTo": "session_v2", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1475,13 +1441,9 @@ "table": "session_pending" }, { - "columns": [ - "project_id" - ], + "columns": ["project_id"], "tableTo": "project", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "NO ACTION", "onDelete": "CASCADE", "nameExplicit": false, @@ -1490,156 +1452,119 @@ "table": "session_v2" }, { - "columns": [ - "email", - "url" - ], + "columns": ["email", "url"], "nameExplicit": false, "name": "control_account_pk", "entityType": "pks", "table": "control_account" }, { - "columns": [ - "project_id", - "directory" - ], + "columns": ["project_id", "directory"], "nameExplicit": false, "name": "project_directory_pk", "entityType": "pks", "table": "project_directory" }, { - "columns": [ - "session_id", - "key" - ], + "columns": ["session_id", "key"], "nameExplicit": false, "name": "instruction_entry_pk", "entityType": "pks", "table": "instruction_entry" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "account_state_pk", "table": "account_state", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "account_pk", "table": "account", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "credential_pk", "table": "credential", "entityType": "pks" }, { - "columns": [ - "aggregate_id" - ], + "columns": ["aggregate_id"], "nameExplicit": false, "name": "event_sequence_pk", "table": "event_sequence", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "event_pk", "table": "event", "entityType": "pks" }, { - "columns": [ - "key" - ], + "columns": ["key"], "nameExplicit": false, "name": "kv_pk", "table": "kv", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "permission_pk", "table": "permission", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "project_pk", "table": "project", "entityType": "pks" }, { - "columns": [ - "hash" - ], + "columns": ["hash"], "nameExplicit": false, "name": "instruction_blob_pk", "table": "instruction_blob", "entityType": "pks" }, { - "columns": [ - "session_id" - ], + "columns": ["session_id"], "nameExplicit": false, "name": "instruction_state_pk", "table": "instruction_state", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "session_message_pk", "table": "session_message", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "session_pending_pk", "table": "session_pending", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "session_v2_pk", "table": "session_v2", "entityType": "pks" }, { - "columns": [ - "id" - ], + "columns": ["id"], "nameExplicit": false, "name": "workspace_pk", "table": "workspace", @@ -1895,4 +1820,4 @@ } ], "renames": [] -} \ No newline at end of file +} diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index 5ba92344588..fb49b19cb86 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -352,9 +352,7 @@ const layer = Layer.effect( Effect.gen(function* () { yield* mutation(bus, { sessionID: input.sessionID, id: input.inputID }).pipe( Effect.catchDefect((defect) => - defect instanceof SessionPending.LifecycleConflict - ? pendingConflict(input) - : Effect.die(defect), + defect instanceof SessionPending.LifecycleConflict ? pendingConflict(input) : Effect.die(defect), ), ) if (wake) yield* execution.wake(input.sessionID) diff --git a/packages/protocol/openapi.json b/packages/protocol/openapi.json index 5778fa30a9f..00bc061b8cb 100644 --- a/packages/protocol/openapi.json +++ b/packages/protocol/openapi.json @@ -1809,6 +1809,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "metadata": { "type": "object" }, @@ -2017,6 +2023,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "delivery": { "anyOf": [ { @@ -12841,6 +12853,25 @@ "required": ["name"], "additionalProperties": false }, + "Prompt.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "text": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id", "name", "text"], + "additionalProperties": false + }, "Session.Message.User": { "type": "object", "properties": { @@ -12880,6 +12911,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "type": { "type": "string", "enum": ["user"] @@ -13837,6 +13874,19 @@ "required": ["uri"], "additionalProperties": false }, + "PromptInput.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id"], + "additionalProperties": false + }, "SessionPending.UserData": { "type": "object", "properties": { @@ -13855,6 +13905,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" } @@ -14764,6 +14820,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" } diff --git a/packages/tui/src/prompt/mention.ts b/packages/tui/src/prompt/mention.ts index 803df334468..224e9439419 100644 --- a/packages/tui/src/prompt/mention.ts +++ b/packages/tui/src/prompt/mention.ts @@ -35,9 +35,7 @@ export function realignPromptMentions( ([left], [right]) => right.length - left.length || left.localeCompare(right), )) { const candidates = mentionRanges(content, text) - const available = candidates.filter( - (candidate) => !protectedRanges.some((range) => overlaps(candidate, range)), - ) + const available = candidates.filter((candidate) => !protectedRanges.some((range) => overlaps(candidate, range))) for (const [item, candidate] of assignMentions(items, available)) { aligned[item.index] = { text, @@ -113,7 +111,10 @@ function assignMentions(items: MentionItem[], candidates: CandidateRange[]) { const ordered = items.toSorted((left, right) => left.mention.start - right.mention.start || left.index - right.index) const memo = new Map }>() - function solve(item: number, candidate: number): { matches: number; cost: number; pairs: Array<[MentionItem, CandidateRange]> } { + function solve( + item: number, + candidate: number, + ): { matches: number; cost: number; pairs: Array<[MentionItem, CandidateRange]> } { if (item >= ordered.length || candidate >= candidates.length) return { matches: 0, cost: 0, pairs: [] } const key = `${item}:${candidate}` const cached = memo.get(key) diff --git a/packages/www/openapi.json b/packages/www/openapi.json index 5778fa30a9f..00bc061b8cb 100644 --- a/packages/www/openapi.json +++ b/packages/www/openapi.json @@ -1809,6 +1809,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "metadata": { "type": "object" }, @@ -2017,6 +2023,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "delivery": { "anyOf": [ { @@ -12841,6 +12853,25 @@ "required": ["name"], "additionalProperties": false }, + "Prompt.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "text": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id", "name", "text"], + "additionalProperties": false + }, "Session.Message.User": { "type": "object", "properties": { @@ -12880,6 +12911,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "type": { "type": "string", "enum": ["user"] @@ -13837,6 +13874,19 @@ "required": ["uri"], "additionalProperties": false }, + "PromptInput.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id"], + "additionalProperties": false + }, "SessionPending.UserData": { "type": "object", "properties": { @@ -13855,6 +13905,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" } @@ -14764,6 +14820,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" } diff --git a/packages/www/public/openapi.json b/packages/www/public/openapi.json index 5778fa30a9f..00bc061b8cb 100644 --- a/packages/www/public/openapi.json +++ b/packages/www/public/openapi.json @@ -1809,6 +1809,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "metadata": { "type": "object" }, @@ -2017,6 +2023,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PromptInput.SkillAttachment" + } + }, "delivery": { "anyOf": [ { @@ -12841,6 +12853,25 @@ "required": ["name"], "additionalProperties": false }, + "Prompt.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "text": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id", "name", "text"], + "additionalProperties": false + }, "Session.Message.User": { "type": "object", "properties": { @@ -12880,6 +12911,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "type": { "type": "string", "enum": ["user"] @@ -13837,6 +13874,19 @@ "required": ["uri"], "additionalProperties": false }, + "PromptInput.SkillAttachment": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "mention": { + "$ref": "#/components/schemas/Prompt.Mention" + } + }, + "required": ["id"], + "additionalProperties": false + }, "SessionPending.UserData": { "type": "object", "properties": { @@ -13855,6 +13905,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" } @@ -14764,6 +14820,12 @@ "$ref": "#/components/schemas/Prompt.AgentAttachment" } }, + "skills": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Prompt.SkillAttachment" + } + }, "metadata": { "type": "object" }