opencode-supertask 0.1.0 → 0.1.1
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.
- package/dist/cli/index.js +74 -58
- package/dist/cli/index.js.map +1 -1
- package/dist/gateway/index.js +53 -0
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +79 -0
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +53 -0
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.js +53 -0
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin/supertask.js
CHANGED
|
@@ -26678,6 +26678,44 @@ function drizzle(...params) {
|
|
|
26678
26678
|
drizzle2.mock = mock;
|
|
26679
26679
|
})(drizzle || (drizzle = {}));
|
|
26680
26680
|
|
|
26681
|
+
// node_modules/drizzle-orm/migrator.js
|
|
26682
|
+
import crypto from "crypto";
|
|
26683
|
+
import fs from "fs";
|
|
26684
|
+
function readMigrationFiles(config2) {
|
|
26685
|
+
const migrationFolderTo = config2.migrationsFolder;
|
|
26686
|
+
const migrationQueries = [];
|
|
26687
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
26688
|
+
if (!fs.existsSync(journalPath)) {
|
|
26689
|
+
throw new Error(`Can't find meta/_journal.json file`);
|
|
26690
|
+
}
|
|
26691
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
26692
|
+
const journal = JSON.parse(journalAsString);
|
|
26693
|
+
for (const journalEntry of journal.entries) {
|
|
26694
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
26695
|
+
try {
|
|
26696
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
26697
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
26698
|
+
return it;
|
|
26699
|
+
});
|
|
26700
|
+
migrationQueries.push({
|
|
26701
|
+
sql: result,
|
|
26702
|
+
bps: journalEntry.breakpoints,
|
|
26703
|
+
folderMillis: journalEntry.when,
|
|
26704
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
26705
|
+
});
|
|
26706
|
+
} catch {
|
|
26707
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
26708
|
+
}
|
|
26709
|
+
}
|
|
26710
|
+
return migrationQueries;
|
|
26711
|
+
}
|
|
26712
|
+
|
|
26713
|
+
// node_modules/drizzle-orm/bun-sqlite/migrator.js
|
|
26714
|
+
function migrate(db2, config2) {
|
|
26715
|
+
const migrations = readMigrationFiles(config2);
|
|
26716
|
+
db2.dialect.migrate(migrations, db2.session, config2);
|
|
26717
|
+
}
|
|
26718
|
+
|
|
26681
26719
|
// src/core/db/schema.ts
|
|
26682
26720
|
var schema_exports = {};
|
|
26683
26721
|
__export(schema_exports, {
|
|
@@ -26768,11 +26806,18 @@ var taskTemplates = sqliteTable("task_templates", {
|
|
|
26768
26806
|
import { existsSync, mkdirSync } from "fs";
|
|
26769
26807
|
import { homedir } from "os";
|
|
26770
26808
|
import { join, dirname } from "path";
|
|
26809
|
+
import { fileURLToPath } from "url";
|
|
26771
26810
|
var DB_FILE_PATH = join(homedir(), ".local/share/opencode/tasks.db");
|
|
26772
26811
|
var _sqlite = null;
|
|
26773
26812
|
var _db = null;
|
|
26813
|
+
var _migrationRan = false;
|
|
26814
|
+
function getMigrationsFolder() {
|
|
26815
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
26816
|
+
return join(__dirname, "../../drizzle");
|
|
26817
|
+
}
|
|
26774
26818
|
function initDb() {
|
|
26775
26819
|
const dataDir = dirname(DB_FILE_PATH);
|
|
26820
|
+
const dbExisted = existsSync(DB_FILE_PATH);
|
|
26776
26821
|
if (!existsSync(dataDir)) {
|
|
26777
26822
|
mkdirSync(dataDir, { recursive: true });
|
|
26778
26823
|
}
|
|
@@ -26788,6 +26833,14 @@ function initDb() {
|
|
|
26788
26833
|
);
|
|
26789
26834
|
`);
|
|
26790
26835
|
_db = drizzle(_sqlite, { schema: schema_exports });
|
|
26836
|
+
if (!_migrationRan) {
|
|
26837
|
+
_migrationRan = true;
|
|
26838
|
+
try {
|
|
26839
|
+
migrate(_db, { migrationsFolder: getMigrationsFolder() });
|
|
26840
|
+
} catch (err) {
|
|
26841
|
+
console.error("[supertask] migration failed:", err instanceof Error ? err.message : String(err));
|
|
26842
|
+
}
|
|
26843
|
+
}
|
|
26791
26844
|
return _db;
|
|
26792
26845
|
}
|
|
26793
26846
|
function getDb() {
|
|
@@ -27149,6 +27202,31 @@ var TaskTemplateService = class {
|
|
|
27149
27202
|
};
|
|
27150
27203
|
|
|
27151
27204
|
// plugin/supertask.ts
|
|
27205
|
+
import { spawn } from "child_process";
|
|
27206
|
+
var _gatewaySpawned = false;
|
|
27207
|
+
function ensureGateway() {
|
|
27208
|
+
if (_gatewaySpawned) return;
|
|
27209
|
+
_gatewaySpawned = true;
|
|
27210
|
+
try {
|
|
27211
|
+
getDb();
|
|
27212
|
+
} catch (err) {
|
|
27213
|
+
console.error("[supertask] DB init failed:", err instanceof Error ? err.message : String(err));
|
|
27214
|
+
return;
|
|
27215
|
+
}
|
|
27216
|
+
try {
|
|
27217
|
+
const lockRow = sqlite.prepare("SELECT pid, heartbeat_at FROM gateway_lock WHERE id = 1").get();
|
|
27218
|
+
if (lockRow && Date.now() - lockRow.heartbeat_at < 3e4) {
|
|
27219
|
+
return;
|
|
27220
|
+
}
|
|
27221
|
+
const child = spawn("supertask", ["gateway"], {
|
|
27222
|
+
detached: true,
|
|
27223
|
+
stdio: "ignore"
|
|
27224
|
+
});
|
|
27225
|
+
child.unref();
|
|
27226
|
+
} catch (err) {
|
|
27227
|
+
console.error("[supertask] gateway spawn failed:", err instanceof Error ? err.message : String(err));
|
|
27228
|
+
}
|
|
27229
|
+
}
|
|
27152
27230
|
var RUNNER_PROMPT = `\u4F60\u662F **SuperTask \u4EFB\u52A1\u6267\u884C\u5668**\u3002
|
|
27153
27231
|
|
|
27154
27232
|
## \u5DE5\u4F5C\u6D41\u7A0B
|
|
@@ -27235,6 +27313,7 @@ var SuperTaskPlugin = async () => {
|
|
|
27235
27313
|
bash: "allow"
|
|
27236
27314
|
}
|
|
27237
27315
|
};
|
|
27316
|
+
ensureGateway();
|
|
27238
27317
|
},
|
|
27239
27318
|
async "experimental.chat.system.transform"(input, output) {
|
|
27240
27319
|
output.system.push(SYSTEM_INSTRUCTION);
|