Explorar el Código

chore: generate

opencode-agent[bot] hace 3 meses
padre
commit
8dc2ffd48f

+ 34 - 102
packages/core/migration/20260601202201_amazing_prowler/snapshot.json

@@ -2,9 +2,7 @@
   "version": "7",
   "version": "7",
   "dialect": "sqlite",
   "dialect": "sqlite",
   "id": "226375f1-a19f-4c7b-8aa2-ccc5513d3b0d",
   "id": "226375f1-a19f-4c7b-8aa2-ccc5513d3b0d",
-  "prevIds": [
-    "bf93c73b-5a48-4d63-9909-3c36a79b9788"
-  ],
+  "prevIds": ["bf93c73b-5a48-4d63-9909-3c36a79b9788"],
   "ddl": [
   "ddl": [
     {
     {
       "name": "workspace",
       "name": "workspace",
@@ -1143,13 +1141,9 @@
       "table": "session_share"
       "table": "session_share"
     },
     },
     {
     {
-      "columns": [
-        "project_id"
-      ],
+      "columns": ["project_id"],
       "tableTo": "project",
       "tableTo": "project",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1158,13 +1152,9 @@
       "table": "workspace"
       "table": "workspace"
     },
     },
     {
     {
-      "columns": [
-        "active_account_id"
-      ],
+      "columns": ["active_account_id"],
       "tableTo": "account",
       "tableTo": "account",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "SET NULL",
       "onDelete": "SET NULL",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1173,13 +1163,9 @@
       "table": "account_state"
       "table": "account_state"
     },
     },
     {
     {
-      "columns": [
-        "aggregate_id"
-      ],
+      "columns": ["aggregate_id"],
       "tableTo": "event_sequence",
       "tableTo": "event_sequence",
-      "columnsTo": [
-        "aggregate_id"
-      ],
+      "columnsTo": ["aggregate_id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1188,13 +1174,9 @@
       "table": "event"
       "table": "event"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1203,13 +1185,9 @@
       "table": "message"
       "table": "message"
     },
     },
     {
     {
-      "columns": [
-        "message_id"
-      ],
+      "columns": ["message_id"],
       "tableTo": "message",
       "tableTo": "message",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1218,13 +1196,9 @@
       "table": "part"
       "table": "part"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1233,13 +1207,9 @@
       "table": "session_message"
       "table": "session_message"
     },
     },
     {
     {
-      "columns": [
-        "project_id"
-      ],
+      "columns": ["project_id"],
       "tableTo": "project",
       "tableTo": "project",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1248,13 +1218,9 @@
       "table": "session"
       "table": "session"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1263,13 +1229,9 @@
       "table": "todo"
       "table": "todo"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1278,128 +1240,98 @@
       "table": "session_share"
       "table": "session_share"
     },
     },
     {
     {
-      "columns": [
-        "email",
-        "url"
-      ],
+      "columns": ["email", "url"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "control_account_pk",
       "name": "control_account_pk",
       "entityType": "pks",
       "entityType": "pks",
       "table": "control_account"
       "table": "control_account"
     },
     },
     {
     {
-      "columns": [
-        "session_id",
-        "position"
-      ],
+      "columns": ["session_id", "position"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "todo_pk",
       "name": "todo_pk",
       "entityType": "pks",
       "entityType": "pks",
       "table": "todo"
       "table": "todo"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "workspace_pk",
       "name": "workspace_pk",
       "table": "workspace",
       "table": "workspace",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "name"
-      ],
+      "columns": ["name"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "data_migration_pk",
       "name": "data_migration_pk",
       "table": "data_migration",
       "table": "data_migration",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "account_state_pk",
       "name": "account_state_pk",
       "table": "account_state",
       "table": "account_state",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "account_pk",
       "name": "account_pk",
       "table": "account",
       "table": "account",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "aggregate_id"
-      ],
+      "columns": ["aggregate_id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "event_sequence_pk",
       "name": "event_sequence_pk",
       "table": "event_sequence",
       "table": "event_sequence",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "event_pk",
       "name": "event_pk",
       "table": "event",
       "table": "event",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "project_pk",
       "name": "project_pk",
       "table": "project",
       "table": "project",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "message_pk",
       "name": "message_pk",
       "table": "message",
       "table": "message",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "part_pk",
       "name": "part_pk",
       "table": "part",
       "table": "part",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_message_pk",
       "name": "session_message_pk",
       "table": "session_message",
       "table": "session_message",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_pk",
       "name": "session_pk",
       "table": "session",
       "table": "session",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_share_pk",
       "name": "session_share_pk",
       "table": "session_share",
       "table": "session_share",
@@ -1563,4 +1495,4 @@
     }
     }
   ],
   ],
   "renames": []
   "renames": []
-}
+}

+ 37 - 111
packages/core/migration/20260602002951_lowly_union_jack/snapshot.json

@@ -2,9 +2,7 @@
   "version": "7",
   "version": "7",
   "dialect": "sqlite",
   "dialect": "sqlite",
   "id": "80d6efb8-93fd-4ce5-b320-45a05aaebdd7",
   "id": "80d6efb8-93fd-4ce5-b320-45a05aaebdd7",
-  "prevIds": [
-    "226375f1-a19f-4c7b-8aa2-ccc5513d3b0d"
-  ],
+  "prevIds": ["226375f1-a19f-4c7b-8aa2-ccc5513d3b0d"],
   "ddl": [
   "ddl": [
     {
     {
       "name": "workspace",
       "name": "workspace",
@@ -1207,13 +1205,9 @@
       "table": "session_share"
       "table": "session_share"
     },
     },
     {
     {
-      "columns": [
-        "project_id"
-      ],
+      "columns": ["project_id"],
       "tableTo": "project",
       "tableTo": "project",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1222,13 +1216,9 @@
       "table": "workspace"
       "table": "workspace"
     },
     },
     {
     {
-      "columns": [
-        "active_account_id"
-      ],
+      "columns": ["active_account_id"],
       "tableTo": "account",
       "tableTo": "account",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "SET NULL",
       "onDelete": "SET NULL",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1237,13 +1227,9 @@
       "table": "account_state"
       "table": "account_state"
     },
     },
     {
     {
-      "columns": [
-        "aggregate_id"
-      ],
+      "columns": ["aggregate_id"],
       "tableTo": "event_sequence",
       "tableTo": "event_sequence",
-      "columnsTo": [
-        "aggregate_id"
-      ],
+      "columnsTo": ["aggregate_id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1252,13 +1238,9 @@
       "table": "event"
       "table": "event"
     },
     },
     {
     {
-      "columns": [
-        "project_id"
-      ],
+      "columns": ["project_id"],
       "tableTo": "project",
       "tableTo": "project",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1267,13 +1249,9 @@
       "table": "permission"
       "table": "permission"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1282,13 +1260,9 @@
       "table": "message"
       "table": "message"
     },
     },
     {
     {
-      "columns": [
-        "message_id"
-      ],
+      "columns": ["message_id"],
       "tableTo": "message",
       "tableTo": "message",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1297,13 +1271,9 @@
       "table": "part"
       "table": "part"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1312,13 +1282,9 @@
       "table": "session_message"
       "table": "session_message"
     },
     },
     {
     {
-      "columns": [
-        "project_id"
-      ],
+      "columns": ["project_id"],
       "tableTo": "project",
       "tableTo": "project",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1327,13 +1293,9 @@
       "table": "session"
       "table": "session"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1342,13 +1304,9 @@
       "table": "todo"
       "table": "todo"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "tableTo": "session",
       "tableTo": "session",
-      "columnsTo": [
-        "id"
-      ],
+      "columnsTo": ["id"],
       "onUpdate": "NO ACTION",
       "onUpdate": "NO ACTION",
       "onDelete": "CASCADE",
       "onDelete": "CASCADE",
       "nameExplicit": false,
       "nameExplicit": false,
@@ -1357,137 +1315,105 @@
       "table": "session_share"
       "table": "session_share"
     },
     },
     {
     {
-      "columns": [
-        "email",
-        "url"
-      ],
+      "columns": ["email", "url"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "control_account_pk",
       "name": "control_account_pk",
       "entityType": "pks",
       "entityType": "pks",
       "table": "control_account"
       "table": "control_account"
     },
     },
     {
     {
-      "columns": [
-        "session_id",
-        "position"
-      ],
+      "columns": ["session_id", "position"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "todo_pk",
       "name": "todo_pk",
       "entityType": "pks",
       "entityType": "pks",
       "table": "todo"
       "table": "todo"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "workspace_pk",
       "name": "workspace_pk",
       "table": "workspace",
       "table": "workspace",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "name"
-      ],
+      "columns": ["name"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "data_migration_pk",
       "name": "data_migration_pk",
       "table": "data_migration",
       "table": "data_migration",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "account_state_pk",
       "name": "account_state_pk",
       "table": "account_state",
       "table": "account_state",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "account_pk",
       "name": "account_pk",
       "table": "account",
       "table": "account",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "aggregate_id"
-      ],
+      "columns": ["aggregate_id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "event_sequence_pk",
       "name": "event_sequence_pk",
       "table": "event_sequence",
       "table": "event_sequence",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "event_pk",
       "name": "event_pk",
       "table": "event",
       "table": "event",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "permission_pk",
       "name": "permission_pk",
       "table": "permission",
       "table": "permission",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "project_pk",
       "name": "project_pk",
       "table": "project",
       "table": "project",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "message_pk",
       "name": "message_pk",
       "table": "message",
       "table": "message",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "part_pk",
       "name": "part_pk",
       "table": "part",
       "table": "part",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_message_pk",
       "name": "session_message_pk",
       "table": "session_message",
       "table": "session_message",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "id"
-      ],
+      "columns": ["id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_pk",
       "name": "session_pk",
       "table": "session",
       "table": "session",
       "entityType": "pks"
       "entityType": "pks"
     },
     },
     {
     {
-      "columns": [
-        "session_id"
-      ],
+      "columns": ["session_id"],
       "nameExplicit": false,
       "nameExplicit": false,
       "name": "session_share_pk",
       "name": "session_share_pk",
       "table": "session_share",
       "table": "session_share",
@@ -1673,4 +1599,4 @@
     }
     }
   ],
   ],
   "renames": []
   "renames": []
-}
+}

+ 3 - 1
packages/core/src/database/migration/20260602002951_lowly_union_jack.ts

@@ -16,7 +16,9 @@ export default {
           CONSTRAINT \`fk_permission_project_id_project_id_fk\` FOREIGN KEY (\`project_id\`) REFERENCES \`project\`(\`id\`) ON DELETE CASCADE
           CONSTRAINT \`fk_permission_project_id_project_id_fk\` FOREIGN KEY (\`project_id\`) REFERENCES \`project\`(\`id\`) ON DELETE CASCADE
         );
         );
       `)
       `)
-      yield* tx.run(`CREATE UNIQUE INDEX \`permission_project_action_resource_idx\` ON \`permission\` (\`project_id\`,\`action\`,\`resource\`);`)
+      yield* tx.run(
+        `CREATE UNIQUE INDEX \`permission_project_action_resource_idx\` ON \`permission\` (\`project_id\`,\`action\`,\`resource\`);`,
+      )
     })
     })
   },
   },
 } satisfies DatabaseMigration.Migration
 } satisfies DatabaseMigration.Migration

+ 8 - 2
packages/core/src/permission.ts

@@ -254,7 +254,11 @@ export const layer = Layer.effect(
       }
       }
 
 
       if (input.reply === "always" && existing.request.save?.length) {
       if (input.reply === "always" && existing.request.save?.length) {
-        yield* saved.add({ projectID: location.project.id, action: existing.request.action, resources: existing.request.save })
+        yield* saved.add({
+          projectID: location.project.id,
+          action: existing.request.action,
+          resources: existing.request.save,
+        })
       }
       }
       yield* Deferred.succeed(existing.deferred, undefined)
       yield* Deferred.succeed(existing.deferred, undefined)
       if (input.reply !== "always" || !existing.request.save?.length) return
       if (input.reply !== "always" || !existing.request.save?.length) return
@@ -269,7 +273,9 @@ export const layer = Layer.effect(
         if (denied(input, rules)) continue
         if (denied(input, rules)) continue
         const effective = [...rules, ...rememberedRules]
         const effective = [...rules, ...rememberedRules]
         if (
         if (
-          !item.request.resources.every((resource) => evaluate(item.request.action, resource, effective).effect === "allow")
+          !item.request.resources.every(
+            (resource) => evaluate(item.request.action, resource, effective).effect === "allow",
+          )
         )
         )
           continue
           continue
         pending.delete(id)
         pending.delete(id)

+ 11 - 2
packages/core/src/permission/saved.ts

@@ -54,14 +54,23 @@ export const layer = Layer.effect(
         .where(input?.projectID ? eq(PermissionTable.project_id, input.projectID) : undefined)
         .where(input?.projectID ? eq(PermissionTable.project_id, input.projectID) : undefined)
         .all()
         .all()
         .pipe(Effect.orDie)
         .pipe(Effect.orDie)
-      return rows.map((row): Info => ({ id: row.id, projectID: row.project_id, action: row.action, resource: row.resource }))
+      return rows.map(
+        (row): Info => ({ id: row.id, projectID: row.project_id, action: row.action, resource: row.resource }),
+      )
     })
     })
 
 
     const add = Effect.fn("PermissionSaved.add")(function* (input: AddInput) {
     const add = Effect.fn("PermissionSaved.add")(function* (input: AddInput) {
       if (!input.resources.length) return
       if (!input.resources.length) return
       yield* db
       yield* db
         .insert(PermissionTable)
         .insert(PermissionTable)
-        .values(input.resources.map((resource) => ({ id: ID.create(), project_id: input.projectID, action: input.action, resource })))
+        .values(
+          input.resources.map((resource) => ({
+            id: ID.create(),
+            project_id: input.projectID,
+            action: input.action,
+            resource,
+          })),
+        )
         .onConflictDoNothing()
         .onConflictDoNothing()
         .run()
         .run()
         .pipe(Effect.orDie)
         .pipe(Effect.orDie)

+ 1 - 3
packages/core/src/plugin/agent.ts

@@ -158,9 +158,7 @@ export const Plugin = PluginV2.define({
         item.description =
         item.description =
           "General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel."
           "General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel."
         item.mode = "subagent"
         item.mode = "subagent"
-        item.permissions.push(
-          ...PermissionV2.merge(defaults, [{ action: "todowrite", resource: "*", effect: "deny" }]),
-        )
+        item.permissions.push(...PermissionV2.merge(defaults, [{ action: "todowrite", resource: "*", effect: "deny" }]))
       })
       })
 
 
       editor.update(AgentV2.ID.make("explore"), (item) => {
       editor.update(AgentV2.ID.make("explore"), (item) => {

+ 4 - 6
packages/core/test/permission.test.ts

@@ -160,14 +160,12 @@ describe("PermissionV2", () => {
       yield* Fiber.join(fiber)
       yield* Fiber.join(fiber)
 
 
       const { db } = yield* Database.Service
       const { db } = yield* Database.Service
-      expect(yield* db.select().from(PermissionTable).where(eq(PermissionTable.project_id, Project.ID.global)).all()).toMatchObject([
-        { action: "read", resource: "src/*" },
-      ])
+      expect(
+        yield* db.select().from(PermissionTable).where(eq(PermissionTable.project_id, Project.ID.global)).all(),
+      ).toMatchObject([{ action: "read", resource: "src/*" }])
       const saved = yield* PermissionSaved.Service
       const saved = yield* PermissionSaved.Service
       const id = (yield* saved.list())[0]!.id
       const id = (yield* saved.list())[0]!.id
-      expect(yield* saved.list()).toEqual([
-        { id, projectID: Project.ID.global, action: "read", resource: "src/*" },
-      ])
+      expect(yield* saved.list()).toEqual([{ id, projectID: Project.ID.global, action: "read", resource: "src/*" }])
       yield* service.assert(assertion({ id: PermissionV2.ID.create("per_next"), resources: ["src/next.ts"] }))
       yield* service.assert(assertion({ id: PermissionV2.ID.create("per_next"), resources: ["src/next.ts"] }))
       yield* saved.remove(id)
       yield* saved.remove(id)
       expect(yield* saved.list()).toEqual([])
       expect(yield* saved.list()).toEqual([])

+ 8 - 2
packages/opencode/src/permission/index.ts

@@ -38,7 +38,11 @@ interface State {
   approved: PermissionLegacy.Rule[]
   approved: PermissionLegacy.Rule[]
 }
 }
 
 
-export function evaluate(permission: string, pattern: string, ...rulesets: PermissionLegacy.Ruleset[]): PermissionLegacy.Rule {
+export function evaluate(
+  permission: string,
+  pattern: string,
+  ...rulesets: PermissionLegacy.Ruleset[]
+): PermissionLegacy.Rule {
   return (
   return (
     rulesets
     rulesets
       .flat()
       .flat()
@@ -134,7 +138,9 @@ export const layer = Layer.effect(
       if (input.reply === "reject") {
       if (input.reply === "reject") {
         yield* Deferred.fail(
         yield* Deferred.fail(
           existing.deferred,
           existing.deferred,
-          input.message ? new PermissionLegacy.CorrectedError({ feedback: input.message }) : new PermissionLegacy.RejectedError(),
+          input.message
+            ? new PermissionLegacy.CorrectedError({ feedback: input.message })
+            : new PermissionLegacy.RejectedError(),
         )
         )
 
 
         for (const [id, item] of pending.entries()) {
         for (const [id, item] of pending.entries()) {

+ 6 - 2
packages/opencode/src/server/routes/instance/httpapi/groups/v2/permission.ts

@@ -58,7 +58,9 @@ export const SessionPermissionGroup = HttpApiGroup.make("v2.session.permission")
       }),
       }),
     ),
     ),
   )
   )
-  .annotateMerge(OpenApi.annotations({ title: "v2 session permissions", description: "Experimental v2 session permission routes." }))
+  .annotateMerge(
+    OpenApi.annotations({ title: "v2 session permissions", description: "Experimental v2 session permission routes." }),
+  )
   .middleware(V2Authorization)
   .middleware(V2Authorization)
 
 
 export const PermissionSavedGroup = HttpApiGroup.make("v2.permission.saved")
 export const PermissionSavedGroup = HttpApiGroup.make("v2.permission.saved")
@@ -86,5 +88,7 @@ export const PermissionSavedGroup = HttpApiGroup.make("v2.permission.saved")
       }),
       }),
     ),
     ),
   )
   )
-  .annotateMerge(OpenApi.annotations({ title: "v2 saved permissions", description: "Experimental v2 saved permission routes." }))
+  .annotateMerge(
+    OpenApi.annotations({ title: "v2 saved permissions", description: "Experimental v2 saved permission routes." }),
+  )
   .middleware(V2Authorization)
   .middleware(V2Authorization)

+ 8 - 2
packages/opencode/test/permission/next.test.ts

@@ -917,7 +917,11 @@ it.instance(
   () =>
   () =>
     Effect.gen(function* () {
     Effect.gen(function* () {
       const events = yield* EventV2Bridge.Service
       const events = yield* EventV2Bridge.Service
-      const seen = yield* Deferred.make<{ sessionID: SessionID; requestID: PermissionLegacy.ID; reply: PermissionLegacy.Reply }>()
+      const seen = yield* Deferred.make<{
+        sessionID: SessionID
+        requestID: PermissionLegacy.ID
+        reply: PermissionLegacy.Reply
+      }>()
 
 
       const fiber = yield* ask({
       const fiber = yield* ask({
         id: PermissionLegacy.ID.make("per_test7"),
         id: PermissionLegacy.ID.make("per_test7"),
@@ -935,7 +939,9 @@ it.instance(
         if (event.type === Permission.Event.Replied.type)
         if (event.type === Permission.Event.Replied.type)
           Deferred.doneUnsafe(
           Deferred.doneUnsafe(
             seen,
             seen,
-            Effect.succeed(event.data as { sessionID: SessionID; requestID: PermissionLegacy.ID; reply: PermissionLegacy.Reply }),
+            Effect.succeed(
+              event.data as { sessionID: SessionID; requestID: PermissionLegacy.ID; reply: PermissionLegacy.Reply },
+            ),
           )
           )
         return Effect.void
         return Effect.void
       })
       })

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 683 - 187
packages/sdk/openapi.json


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio