@foothill/agent-move 1.0.8 → 1.0.10
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/README.md +46 -9
- package/package.json +2 -1
- package/packages/client/dist/assets/{BufferResource-Ddjob236.js → BufferResource-Dfd5uHKt.js} +1 -1
- package/packages/client/dist/assets/{CanvasRenderer-B0w6SYyW.js → CanvasRenderer-7Cv6xZVP.js} +1 -1
- package/packages/client/dist/assets/{Filter-NcMGuiK-.js → Filter-CBX7EB7j.js} +1 -1
- package/packages/client/dist/assets/{RenderTargetSystem-DgAzY5_U.js → RenderTargetSystem-ko-v73NG.js} +1 -1
- package/packages/client/dist/assets/{WebGLRenderer-DUWXDPIX.js → WebGLRenderer-vhPQEPUG.js} +1 -1
- package/packages/client/dist/assets/{WebGPURenderer-C1HbrllR.js → WebGPURenderer-Dwywvwqe.js} +1 -1
- package/packages/client/dist/assets/{browserAll-CaF1Fl0O.js → browserAll-QyCAT8_K.js} +1 -1
- package/packages/client/dist/assets/index-BPJtz4FL.js +722 -0
- package/packages/client/dist/assets/{webworkerAll-BJ6UhC7r.js → webworkerAll-hM-gNP7L.js} +1 -1
- package/packages/client/dist/index.html +1 -1
- package/packages/server/dist/config.d.ts +4 -0
- package/packages/server/dist/config.d.ts.map +1 -1
- package/packages/server/dist/config.js +5 -5
- package/packages/server/dist/config.js.map +1 -1
- package/packages/server/dist/hooks/hook-event-manager.js +0 -4
- package/packages/server/dist/hooks/hook-installer.js +0 -4
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +792 -856
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/routes/api.js +0 -4
- package/packages/server/dist/state/activity-processor.d.ts +1 -1
- package/packages/server/dist/state/activity-processor.d.ts.map +1 -1
- package/packages/server/dist/state/activity-processor.js +1 -5
- package/packages/server/dist/state/activity-processor.js.map +1 -1
- package/packages/server/dist/state/agent-state-manager.d.ts +1 -2
- package/packages/server/dist/state/agent-state-manager.d.ts.map +1 -1
- package/packages/server/dist/state/agent-state-manager.js +87 -6
- package/packages/server/dist/state/agent-state-manager.js.map +1 -1
- package/packages/server/dist/state/anomaly-detector.js +0 -4
- package/packages/server/dist/state/identity-manager.js +0 -4
- package/packages/server/dist/state/role-resolver.d.ts +1 -2
- package/packages/server/dist/state/role-resolver.d.ts.map +1 -1
- package/packages/server/dist/state/role-resolver.js +0 -4
- package/packages/server/dist/state/role-resolver.js.map +1 -1
- package/packages/server/dist/state/task-graph-manager.d.ts +12 -0
- package/packages/server/dist/state/task-graph-manager.d.ts.map +1 -1
- package/packages/server/dist/state/task-graph-manager.js +80 -4
- package/packages/server/dist/state/task-graph-manager.js.map +1 -1
- package/packages/server/dist/state/tool-chain-tracker.js +0 -4
- package/packages/server/dist/watcher/agent-watcher.js +0 -5
- package/packages/server/dist/watcher/claude/claude-paths.d.ts +18 -0
- package/packages/server/dist/watcher/claude/claude-paths.d.ts.map +1 -0
- package/packages/server/dist/watcher/{claude-paths.js → claude/claude-paths.js} +47 -59
- package/packages/server/dist/watcher/claude/claude-paths.js.map +1 -0
- package/packages/server/dist/watcher/{file-watcher.d.ts → claude/claude-watcher.d.ts} +3 -3
- package/packages/server/dist/watcher/claude/claude-watcher.d.ts.map +1 -0
- package/packages/server/dist/watcher/{file-watcher.js → claude/claude-watcher.js} +59 -69
- package/packages/server/dist/watcher/claude/claude-watcher.js.map +1 -0
- package/packages/server/dist/watcher/claude/jsonl-parser.d.ts +6 -0
- package/packages/server/dist/watcher/claude/jsonl-parser.d.ts.map +1 -0
- package/packages/server/dist/watcher/{jsonl-parser.js → claude/jsonl-parser.js} +1 -5
- package/packages/server/dist/watcher/claude/jsonl-parser.js.map +1 -0
- package/packages/server/dist/watcher/codex/codex-parser.d.ts +30 -0
- package/packages/server/dist/watcher/codex/codex-parser.d.ts.map +1 -0
- package/packages/server/dist/watcher/codex/codex-parser.js +326 -0
- package/packages/server/dist/watcher/codex/codex-parser.js.map +1 -0
- package/packages/server/dist/watcher/codex/codex-paths.d.ts +35 -0
- package/packages/server/dist/watcher/codex/codex-paths.d.ts.map +1 -0
- package/packages/server/dist/watcher/codex/codex-paths.js +46 -0
- package/packages/server/dist/watcher/codex/codex-paths.js.map +1 -0
- package/packages/server/dist/watcher/codex/codex-watcher.d.ts +42 -0
- package/packages/server/dist/watcher/codex/codex-watcher.d.ts.map +1 -0
- package/packages/server/dist/watcher/codex/codex-watcher.js +577 -0
- package/packages/server/dist/watcher/codex/codex-watcher.js.map +1 -0
- package/packages/server/dist/watcher/git-info.js +0 -4
- package/packages/server/dist/watcher/opencode/opencode-parser.d.ts +1 -1
- package/packages/server/dist/watcher/opencode/opencode-parser.d.ts.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-parser.js +31 -6
- package/packages/server/dist/watcher/opencode/opencode-paths.d.ts +1 -1
- package/packages/server/dist/watcher/opencode/opencode-paths.d.ts.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-paths.js +1 -4
- package/packages/server/dist/watcher/opencode/opencode-paths.js.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-watcher.js +50 -789
- package/packages/server/dist/watcher/opencode/opencode-watcher.js.map +1 -1
- package/packages/server/dist/watcher/path-utils.d.ts +10 -0
- package/packages/server/dist/watcher/path-utils.d.ts.map +1 -0
- package/packages/server/dist/watcher/path-utils.js +38 -0
- package/packages/server/dist/watcher/path-utils.js.map +1 -0
- package/packages/server/dist/watcher/pi/pi-parser.d.ts +19 -0
- package/packages/server/dist/watcher/pi/pi-parser.d.ts.map +1 -0
- package/packages/server/dist/watcher/pi/pi-parser.js +307 -0
- package/packages/server/dist/watcher/pi/pi-parser.js.map +1 -0
- package/packages/server/dist/watcher/pi/pi-paths.d.ts +28 -0
- package/packages/server/dist/watcher/pi/pi-paths.d.ts.map +1 -0
- package/packages/server/dist/watcher/pi/pi-paths.js +86 -0
- package/packages/server/dist/watcher/pi/pi-paths.js.map +1 -0
- package/packages/server/dist/watcher/pi/pi-watcher.d.ts +36 -0
- package/packages/server/dist/watcher/pi/pi-watcher.d.ts.map +1 -0
- package/packages/server/dist/watcher/pi/pi-watcher.js +593 -0
- package/packages/server/dist/watcher/pi/pi-watcher.js.map +1 -0
- package/packages/server/dist/watcher/session-scanner.d.ts +9 -3
- package/packages/server/dist/watcher/session-scanner.d.ts.map +1 -1
- package/packages/server/dist/watcher/session-scanner.js +11 -13
- package/packages/server/dist/watcher/session-scanner.js.map +1 -1
- package/packages/server/dist/watcher/types.d.ts +30 -0
- package/packages/server/dist/watcher/types.d.ts.map +1 -0
- package/packages/server/dist/watcher/types.js +14 -0
- package/packages/server/dist/watcher/types.js.map +1 -0
- package/packages/server/dist/ws/broadcaster.js +0 -4
- package/packages/server/dist/ws/ws-handler.js +0 -4
- package/packages/shared/dist/constants/colors.d.ts +1 -1
- package/packages/shared/dist/constants/colors.js +1 -1
- package/packages/shared/dist/constants/colors.js.map +1 -1
- package/packages/shared/dist/constants/tools.d.ts.map +1 -1
- package/packages/shared/dist/constants/tools.js +30 -1
- package/packages/shared/dist/constants/tools.js.map +1 -1
- package/packages/shared/dist/index.d.ts +1 -1
- package/packages/shared/dist/index.d.ts.map +1 -1
- package/packages/shared/dist/types/agent.d.ts +3 -0
- package/packages/shared/dist/types/agent.d.ts.map +1 -1
- package/packages/client/dist/assets/index-Dh8yWoLP.js +0 -711
- package/packages/server/dist/watcher/claude-paths.d.ts +0 -32
- package/packages/server/dist/watcher/claude-paths.d.ts.map +0 -1
- package/packages/server/dist/watcher/claude-paths.js.map +0 -1
- package/packages/server/dist/watcher/file-watcher.d.ts.map +0 -1
- package/packages/server/dist/watcher/file-watcher.js.map +0 -1
- package/packages/server/dist/watcher/jsonl-parser.d.ts +0 -21
- package/packages/server/dist/watcher/jsonl-parser.d.ts.map +0 -1
- package/packages/server/dist/watcher/jsonl-parser.js.map +0 -1
|
@@ -1,788 +1,21 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
1
|
// dist/watcher/opencode/opencode-watcher.js
|
|
4
|
-
import { createRequire } from "module";
|
|
5
2
|
import chokidar from "chokidar";
|
|
3
|
+
import Database from "better-sqlite3";
|
|
6
4
|
import { homedir } from "os";
|
|
7
5
|
import { join } from "path";
|
|
8
6
|
import { homedir as homedir2 } from "os";
|
|
9
7
|
import { join as join2 } from "path";
|
|
10
8
|
import { existsSync } from "fs";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
if (typeof require2 !== "undefined") return require2.apply(this, arguments);
|
|
22
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
23
|
-
});
|
|
24
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
25
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
36
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
41
|
-
mod
|
|
42
|
-
));
|
|
43
|
-
var require_util = __commonJS({
|
|
44
|
-
"../../node_modules/better-sqlite3/lib/util.js"(exports) {
|
|
45
|
-
"use strict";
|
|
46
|
-
exports.getBooleanOption = (options, key) => {
|
|
47
|
-
let value = false;
|
|
48
|
-
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
49
|
-
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
};
|
|
53
|
-
exports.cppdb = /* @__PURE__ */ Symbol();
|
|
54
|
-
exports.inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
var require_sqlite_error = __commonJS({
|
|
58
|
-
"../../node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
|
|
59
|
-
"use strict";
|
|
60
|
-
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
61
|
-
function SqliteError(message, code) {
|
|
62
|
-
if (new.target !== SqliteError) {
|
|
63
|
-
return new SqliteError(message, code);
|
|
64
|
-
}
|
|
65
|
-
if (typeof code !== "string") {
|
|
66
|
-
throw new TypeError("Expected second argument to be a string");
|
|
67
|
-
}
|
|
68
|
-
Error.call(this, message);
|
|
69
|
-
descriptor.value = "" + message;
|
|
70
|
-
Object.defineProperty(this, "message", descriptor);
|
|
71
|
-
Error.captureStackTrace(this, SqliteError);
|
|
72
|
-
this.code = code;
|
|
73
|
-
}
|
|
74
|
-
Object.setPrototypeOf(SqliteError, Error);
|
|
75
|
-
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
76
|
-
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
77
|
-
module.exports = SqliteError;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
var require_file_uri_to_path = __commonJS({
|
|
81
|
-
"../../node_modules/file-uri-to-path/index.js"(exports, module) {
|
|
82
|
-
var sep = __require("path").sep || "/";
|
|
83
|
-
module.exports = fileUriToPath;
|
|
84
|
-
function fileUriToPath(uri) {
|
|
85
|
-
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
86
|
-
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
87
|
-
}
|
|
88
|
-
var rest = decodeURI(uri.substring(7));
|
|
89
|
-
var firstSlash = rest.indexOf("/");
|
|
90
|
-
var host = rest.substring(0, firstSlash);
|
|
91
|
-
var path = rest.substring(firstSlash + 1);
|
|
92
|
-
if ("localhost" == host) host = "";
|
|
93
|
-
if (host) {
|
|
94
|
-
host = sep + sep + host;
|
|
95
|
-
}
|
|
96
|
-
path = path.replace(/^(.+)\|/, "$1:");
|
|
97
|
-
if (sep == "\\") {
|
|
98
|
-
path = path.replace(/\//g, "\\");
|
|
99
|
-
}
|
|
100
|
-
if (/^.+\:/.test(path)) {
|
|
101
|
-
} else {
|
|
102
|
-
path = sep + path;
|
|
103
|
-
}
|
|
104
|
-
return host + path;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
var require_bindings = __commonJS({
|
|
109
|
-
"../../node_modules/bindings/bindings.js"(exports, module) {
|
|
110
|
-
var fs = __require("fs");
|
|
111
|
-
var path = __require("path");
|
|
112
|
-
var fileURLToPath = require_file_uri_to_path();
|
|
113
|
-
var join3 = path.join;
|
|
114
|
-
var dirname = path.dirname;
|
|
115
|
-
var exists = fs.accessSync && function(path2) {
|
|
116
|
-
try {
|
|
117
|
-
fs.accessSync(path2);
|
|
118
|
-
} catch (e) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
} || fs.existsSync || path.existsSync;
|
|
123
|
-
var defaults = {
|
|
124
|
-
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
125
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
126
|
-
platform: process.platform,
|
|
127
|
-
arch: process.arch,
|
|
128
|
-
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
129
|
-
version: process.versions.node,
|
|
130
|
-
bindings: "bindings.node",
|
|
131
|
-
try: [
|
|
132
|
-
// node-gyp's linked version in the "build" dir
|
|
133
|
-
["module_root", "build", "bindings"],
|
|
134
|
-
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
135
|
-
["module_root", "build", "Debug", "bindings"],
|
|
136
|
-
["module_root", "build", "Release", "bindings"],
|
|
137
|
-
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
138
|
-
["module_root", "out", "Debug", "bindings"],
|
|
139
|
-
["module_root", "Debug", "bindings"],
|
|
140
|
-
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
141
|
-
["module_root", "out", "Release", "bindings"],
|
|
142
|
-
["module_root", "Release", "bindings"],
|
|
143
|
-
// Legacy from node-waf, node <= 0.4.x
|
|
144
|
-
["module_root", "build", "default", "bindings"],
|
|
145
|
-
// Production "Release" buildtype binary (meh...)
|
|
146
|
-
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
147
|
-
// node-qbs builds
|
|
148
|
-
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
149
|
-
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
150
|
-
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
151
|
-
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
152
|
-
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
153
|
-
]
|
|
154
|
-
};
|
|
155
|
-
function bindings(opts) {
|
|
156
|
-
if (typeof opts == "string") {
|
|
157
|
-
opts = { bindings: opts };
|
|
158
|
-
} else if (!opts) {
|
|
159
|
-
opts = {};
|
|
160
|
-
}
|
|
161
|
-
Object.keys(defaults).map(function(i2) {
|
|
162
|
-
if (!(i2 in opts)) opts[i2] = defaults[i2];
|
|
163
|
-
});
|
|
164
|
-
if (!opts.module_root) {
|
|
165
|
-
opts.module_root = exports.getRoot(exports.getFileName());
|
|
166
|
-
}
|
|
167
|
-
if (path.extname(opts.bindings) != ".node") {
|
|
168
|
-
opts.bindings += ".node";
|
|
169
|
-
}
|
|
170
|
-
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
171
|
-
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
172
|
-
for (; i < l; i++) {
|
|
173
|
-
n = join3.apply(
|
|
174
|
-
null,
|
|
175
|
-
opts.try[i].map(function(p) {
|
|
176
|
-
return opts[p] || p;
|
|
177
|
-
})
|
|
178
|
-
);
|
|
179
|
-
tries.push(n);
|
|
180
|
-
try {
|
|
181
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
182
|
-
if (!opts.path) {
|
|
183
|
-
b.path = n;
|
|
184
|
-
}
|
|
185
|
-
return b;
|
|
186
|
-
} catch (e) {
|
|
187
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
188
|
-
throw e;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
err = new Error(
|
|
193
|
-
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
194
|
-
return opts.arrow + a;
|
|
195
|
-
}).join("\n")
|
|
196
|
-
);
|
|
197
|
-
err.tries = tries;
|
|
198
|
-
throw err;
|
|
199
|
-
}
|
|
200
|
-
module.exports = exports = bindings;
|
|
201
|
-
exports.getFileName = function getFileName(calling_file) {
|
|
202
|
-
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
203
|
-
Error.stackTraceLimit = 10;
|
|
204
|
-
Error.prepareStackTrace = function(e, st) {
|
|
205
|
-
for (var i = 0, l = st.length; i < l; i++) {
|
|
206
|
-
fileName = st[i].getFileName();
|
|
207
|
-
if (fileName !== __filename) {
|
|
208
|
-
if (calling_file) {
|
|
209
|
-
if (fileName !== calling_file) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
Error.captureStackTrace(dummy);
|
|
219
|
-
dummy.stack;
|
|
220
|
-
Error.prepareStackTrace = origPST;
|
|
221
|
-
Error.stackTraceLimit = origSTL;
|
|
222
|
-
var fileSchema = "file://";
|
|
223
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
224
|
-
fileName = fileURLToPath(fileName);
|
|
225
|
-
}
|
|
226
|
-
return fileName;
|
|
227
|
-
};
|
|
228
|
-
exports.getRoot = function getRoot(file) {
|
|
229
|
-
var dir = dirname(file), prev;
|
|
230
|
-
while (true) {
|
|
231
|
-
if (dir === ".") {
|
|
232
|
-
dir = process.cwd();
|
|
233
|
-
}
|
|
234
|
-
if (exists(join3(dir, "package.json")) || exists(join3(dir, "node_modules"))) {
|
|
235
|
-
return dir;
|
|
236
|
-
}
|
|
237
|
-
if (prev === dir) {
|
|
238
|
-
throw new Error(
|
|
239
|
-
'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
prev = dir;
|
|
243
|
-
dir = join3(dir, "..");
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
var require_wrappers = __commonJS({
|
|
249
|
-
"../../node_modules/better-sqlite3/lib/methods/wrappers.js"(exports) {
|
|
250
|
-
"use strict";
|
|
251
|
-
var { cppdb } = require_util();
|
|
252
|
-
exports.prepare = function prepare(sql) {
|
|
253
|
-
return this[cppdb].prepare(sql, this, false);
|
|
254
|
-
};
|
|
255
|
-
exports.exec = function exec(sql) {
|
|
256
|
-
this[cppdb].exec(sql);
|
|
257
|
-
return this;
|
|
258
|
-
};
|
|
259
|
-
exports.close = function close() {
|
|
260
|
-
this[cppdb].close();
|
|
261
|
-
return this;
|
|
262
|
-
};
|
|
263
|
-
exports.loadExtension = function loadExtension(...args) {
|
|
264
|
-
this[cppdb].loadExtension(...args);
|
|
265
|
-
return this;
|
|
266
|
-
};
|
|
267
|
-
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
268
|
-
this[cppdb].defaultSafeIntegers(...args);
|
|
269
|
-
return this;
|
|
270
|
-
};
|
|
271
|
-
exports.unsafeMode = function unsafeMode(...args) {
|
|
272
|
-
this[cppdb].unsafeMode(...args);
|
|
273
|
-
return this;
|
|
274
|
-
};
|
|
275
|
-
exports.getters = {
|
|
276
|
-
name: {
|
|
277
|
-
get: function name() {
|
|
278
|
-
return this[cppdb].name;
|
|
279
|
-
},
|
|
280
|
-
enumerable: true
|
|
281
|
-
},
|
|
282
|
-
open: {
|
|
283
|
-
get: function open() {
|
|
284
|
-
return this[cppdb].open;
|
|
285
|
-
},
|
|
286
|
-
enumerable: true
|
|
287
|
-
},
|
|
288
|
-
inTransaction: {
|
|
289
|
-
get: function inTransaction() {
|
|
290
|
-
return this[cppdb].inTransaction;
|
|
291
|
-
},
|
|
292
|
-
enumerable: true
|
|
293
|
-
},
|
|
294
|
-
readonly: {
|
|
295
|
-
get: function readonly() {
|
|
296
|
-
return this[cppdb].readonly;
|
|
297
|
-
},
|
|
298
|
-
enumerable: true
|
|
299
|
-
},
|
|
300
|
-
memory: {
|
|
301
|
-
get: function memory() {
|
|
302
|
-
return this[cppdb].memory;
|
|
303
|
-
},
|
|
304
|
-
enumerable: true
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
var require_transaction = __commonJS({
|
|
310
|
-
"../../node_modules/better-sqlite3/lib/methods/transaction.js"(exports, module) {
|
|
311
|
-
"use strict";
|
|
312
|
-
var { cppdb } = require_util();
|
|
313
|
-
var controllers = /* @__PURE__ */ new WeakMap();
|
|
314
|
-
module.exports = function transaction(fn) {
|
|
315
|
-
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
316
|
-
const db = this[cppdb];
|
|
317
|
-
const controller = getController(db, this);
|
|
318
|
-
const { apply } = Function.prototype;
|
|
319
|
-
const properties = {
|
|
320
|
-
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
321
|
-
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
322
|
-
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
323
|
-
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
324
|
-
database: { value: this, enumerable: true }
|
|
325
|
-
};
|
|
326
|
-
Object.defineProperties(properties.default.value, properties);
|
|
327
|
-
Object.defineProperties(properties.deferred.value, properties);
|
|
328
|
-
Object.defineProperties(properties.immediate.value, properties);
|
|
329
|
-
Object.defineProperties(properties.exclusive.value, properties);
|
|
330
|
-
return properties.default.value;
|
|
331
|
-
};
|
|
332
|
-
var getController = (db, self) => {
|
|
333
|
-
let controller = controllers.get(db);
|
|
334
|
-
if (!controller) {
|
|
335
|
-
const shared = {
|
|
336
|
-
commit: db.prepare("COMMIT", self, false),
|
|
337
|
-
rollback: db.prepare("ROLLBACK", self, false),
|
|
338
|
-
savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
339
|
-
release: db.prepare("RELEASE ` _bs3. `", self, false),
|
|
340
|
-
rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
341
|
-
};
|
|
342
|
-
controllers.set(db, controller = {
|
|
343
|
-
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
344
|
-
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
345
|
-
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
346
|
-
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
return controller;
|
|
350
|
-
};
|
|
351
|
-
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
352
|
-
let before, after, undo;
|
|
353
|
-
if (db.inTransaction) {
|
|
354
|
-
before = savepoint;
|
|
355
|
-
after = release;
|
|
356
|
-
undo = rollbackTo;
|
|
357
|
-
} else {
|
|
358
|
-
before = begin;
|
|
359
|
-
after = commit;
|
|
360
|
-
undo = rollback;
|
|
361
|
-
}
|
|
362
|
-
before.run();
|
|
363
|
-
try {
|
|
364
|
-
const result = apply.call(fn, this, arguments);
|
|
365
|
-
if (result && typeof result.then === "function") {
|
|
366
|
-
throw new TypeError("Transaction function cannot return a promise");
|
|
367
|
-
}
|
|
368
|
-
after.run();
|
|
369
|
-
return result;
|
|
370
|
-
} catch (ex) {
|
|
371
|
-
if (db.inTransaction) {
|
|
372
|
-
undo.run();
|
|
373
|
-
if (undo !== rollback) after.run();
|
|
374
|
-
}
|
|
375
|
-
throw ex;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
var require_pragma = __commonJS({
|
|
381
|
-
"../../node_modules/better-sqlite3/lib/methods/pragma.js"(exports, module) {
|
|
382
|
-
"use strict";
|
|
383
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
384
|
-
module.exports = function pragma(source, options) {
|
|
385
|
-
if (options == null) options = {};
|
|
386
|
-
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
387
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
388
|
-
const simple = getBooleanOption(options, "simple");
|
|
389
|
-
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
390
|
-
return simple ? stmt.pluck().get() : stmt.all();
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
var require_backup = __commonJS({
|
|
395
|
-
"../../node_modules/better-sqlite3/lib/methods/backup.js"(exports, module) {
|
|
396
|
-
"use strict";
|
|
397
|
-
var fs = __require("fs");
|
|
398
|
-
var path = __require("path");
|
|
399
|
-
var { promisify } = __require("util");
|
|
400
|
-
var { cppdb } = require_util();
|
|
401
|
-
var fsAccess = promisify(fs.access);
|
|
402
|
-
module.exports = async function backup(filename, options) {
|
|
403
|
-
if (options == null) options = {};
|
|
404
|
-
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
405
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
406
|
-
filename = filename.trim();
|
|
407
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
408
|
-
const handler = "progress" in options ? options.progress : null;
|
|
409
|
-
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
410
|
-
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
411
|
-
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
412
|
-
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
413
|
-
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
414
|
-
await fsAccess(path.dirname(filename)).catch(() => {
|
|
415
|
-
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
416
|
-
});
|
|
417
|
-
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
418
|
-
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
419
|
-
};
|
|
420
|
-
var runBackup = (backup, handler) => {
|
|
421
|
-
let rate = 0;
|
|
422
|
-
let useDefault = true;
|
|
423
|
-
return new Promise((resolve, reject) => {
|
|
424
|
-
setImmediate(function step() {
|
|
425
|
-
try {
|
|
426
|
-
const progress = backup.transfer(rate);
|
|
427
|
-
if (!progress.remainingPages) {
|
|
428
|
-
backup.close();
|
|
429
|
-
resolve(progress);
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
if (useDefault) {
|
|
433
|
-
useDefault = false;
|
|
434
|
-
rate = 100;
|
|
435
|
-
}
|
|
436
|
-
if (handler) {
|
|
437
|
-
const ret = handler(progress);
|
|
438
|
-
if (ret !== void 0) {
|
|
439
|
-
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
440
|
-
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
setImmediate(step);
|
|
444
|
-
} catch (err) {
|
|
445
|
-
backup.close();
|
|
446
|
-
reject(err);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
var require_serialize = __commonJS({
|
|
454
|
-
"../../node_modules/better-sqlite3/lib/methods/serialize.js"(exports, module) {
|
|
455
|
-
"use strict";
|
|
456
|
-
var { cppdb } = require_util();
|
|
457
|
-
module.exports = function serialize(options) {
|
|
458
|
-
if (options == null) options = {};
|
|
459
|
-
if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
|
|
460
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
461
|
-
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
462
|
-
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
463
|
-
return this[cppdb].serialize(attachedName);
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
var require_function = __commonJS({
|
|
468
|
-
"../../node_modules/better-sqlite3/lib/methods/function.js"(exports, module) {
|
|
469
|
-
"use strict";
|
|
470
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
471
|
-
module.exports = function defineFunction(name, options, fn) {
|
|
472
|
-
if (options == null) options = {};
|
|
473
|
-
if (typeof options === "function") {
|
|
474
|
-
fn = options;
|
|
475
|
-
options = {};
|
|
476
|
-
}
|
|
477
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
478
|
-
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
479
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
480
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
481
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
482
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
483
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
484
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
485
|
-
let argCount = -1;
|
|
486
|
-
if (!varargs) {
|
|
487
|
-
argCount = fn.length;
|
|
488
|
-
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
489
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
490
|
-
}
|
|
491
|
-
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
492
|
-
return this;
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
var require_aggregate = __commonJS({
|
|
497
|
-
"../../node_modules/better-sqlite3/lib/methods/aggregate.js"(exports, module) {
|
|
498
|
-
"use strict";
|
|
499
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
500
|
-
module.exports = function defineAggregate(name, options) {
|
|
501
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
502
|
-
if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
|
|
503
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
504
|
-
const start = "start" in options ? options.start : null;
|
|
505
|
-
const step = getFunctionOption(options, "step", true);
|
|
506
|
-
const inverse = getFunctionOption(options, "inverse", false);
|
|
507
|
-
const result = getFunctionOption(options, "result", false);
|
|
508
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
509
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
510
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
511
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
512
|
-
let argCount = -1;
|
|
513
|
-
if (!varargs) {
|
|
514
|
-
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
515
|
-
if (argCount > 0) argCount -= 1;
|
|
516
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
517
|
-
}
|
|
518
|
-
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
519
|
-
return this;
|
|
520
|
-
};
|
|
521
|
-
var getFunctionOption = (options, key, required) => {
|
|
522
|
-
const value = key in options ? options[key] : null;
|
|
523
|
-
if (typeof value === "function") return value;
|
|
524
|
-
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
525
|
-
if (required) throw new TypeError(`Missing required option "${key}"`);
|
|
526
|
-
return null;
|
|
527
|
-
};
|
|
528
|
-
var getLength = ({ length }) => {
|
|
529
|
-
if (Number.isInteger(length) && length >= 0) return length;
|
|
530
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
var require_table = __commonJS({
|
|
535
|
-
"../../node_modules/better-sqlite3/lib/methods/table.js"(exports, module) {
|
|
536
|
-
"use strict";
|
|
537
|
-
var { cppdb } = require_util();
|
|
538
|
-
module.exports = function defineTable(name, factory) {
|
|
539
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
540
|
-
if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
|
|
541
|
-
let eponymous = false;
|
|
542
|
-
if (typeof factory === "object" && factory !== null) {
|
|
543
|
-
eponymous = true;
|
|
544
|
-
factory = defer(parseTableDefinition(factory, "used", name));
|
|
545
|
-
} else {
|
|
546
|
-
if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
547
|
-
factory = wrapFactory(factory);
|
|
548
|
-
}
|
|
549
|
-
this[cppdb].table(factory, name, eponymous);
|
|
550
|
-
return this;
|
|
551
|
-
};
|
|
552
|
-
function wrapFactory(factory) {
|
|
553
|
-
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
554
|
-
const thisObject = {
|
|
555
|
-
module: moduleName,
|
|
556
|
-
database: databaseName,
|
|
557
|
-
table: tableName
|
|
558
|
-
};
|
|
559
|
-
const def = apply.call(factory, thisObject, args);
|
|
560
|
-
if (typeof def !== "object" || def === null) {
|
|
561
|
-
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
562
|
-
}
|
|
563
|
-
return parseTableDefinition(def, "returned", moduleName);
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function parseTableDefinition(def, verb, moduleName) {
|
|
567
|
-
if (!hasOwnProperty.call(def, "rows")) {
|
|
568
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
569
|
-
}
|
|
570
|
-
if (!hasOwnProperty.call(def, "columns")) {
|
|
571
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
572
|
-
}
|
|
573
|
-
const rows = def.rows;
|
|
574
|
-
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
575
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
576
|
-
}
|
|
577
|
-
let columns = def.columns;
|
|
578
|
-
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
579
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
580
|
-
}
|
|
581
|
-
if (columns.length !== new Set(columns).size) {
|
|
582
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
583
|
-
}
|
|
584
|
-
if (!columns.length) {
|
|
585
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
586
|
-
}
|
|
587
|
-
let parameters;
|
|
588
|
-
if (hasOwnProperty.call(def, "parameters")) {
|
|
589
|
-
parameters = def.parameters;
|
|
590
|
-
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
591
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
592
|
-
}
|
|
593
|
-
} else {
|
|
594
|
-
parameters = inferParameters(rows);
|
|
595
|
-
}
|
|
596
|
-
if (parameters.length !== new Set(parameters).size) {
|
|
597
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
598
|
-
}
|
|
599
|
-
if (parameters.length > 32) {
|
|
600
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
601
|
-
}
|
|
602
|
-
for (const parameter of parameters) {
|
|
603
|
-
if (columns.includes(parameter)) {
|
|
604
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
let safeIntegers = 2;
|
|
608
|
-
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
609
|
-
const bool = def.safeIntegers;
|
|
610
|
-
if (typeof bool !== "boolean") {
|
|
611
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
612
|
-
}
|
|
613
|
-
safeIntegers = +bool;
|
|
614
|
-
}
|
|
615
|
-
let directOnly = false;
|
|
616
|
-
if (hasOwnProperty.call(def, "directOnly")) {
|
|
617
|
-
directOnly = def.directOnly;
|
|
618
|
-
if (typeof directOnly !== "boolean") {
|
|
619
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
const columnDefinitions = [
|
|
623
|
-
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
624
|
-
...columns.map(identifier)
|
|
625
|
-
];
|
|
626
|
-
return [
|
|
627
|
-
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
628
|
-
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
629
|
-
parameters,
|
|
630
|
-
safeIntegers,
|
|
631
|
-
directOnly
|
|
632
|
-
];
|
|
633
|
-
}
|
|
634
|
-
function wrapGenerator(generator, columnMap, moduleName) {
|
|
635
|
-
return function* virtualTable(...args) {
|
|
636
|
-
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
637
|
-
for (let i = 0; i < columnMap.size; ++i) {
|
|
638
|
-
output.push(null);
|
|
639
|
-
}
|
|
640
|
-
for (const row of generator(...args)) {
|
|
641
|
-
if (Array.isArray(row)) {
|
|
642
|
-
extractRowArray(row, output, columnMap.size, moduleName);
|
|
643
|
-
yield output;
|
|
644
|
-
} else if (typeof row === "object" && row !== null) {
|
|
645
|
-
extractRowObject(row, output, columnMap, moduleName);
|
|
646
|
-
yield output;
|
|
647
|
-
} else {
|
|
648
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
function extractRowArray(row, output, columnCount, moduleName) {
|
|
654
|
-
if (row.length !== columnCount) {
|
|
655
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
656
|
-
}
|
|
657
|
-
const offset = output.length - columnCount;
|
|
658
|
-
for (let i = 0; i < columnCount; ++i) {
|
|
659
|
-
output[i + offset] = row[i];
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
function extractRowObject(row, output, columnMap, moduleName) {
|
|
663
|
-
let count = 0;
|
|
664
|
-
for (const key of Object.keys(row)) {
|
|
665
|
-
const index = columnMap.get(key);
|
|
666
|
-
if (index === void 0) {
|
|
667
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
668
|
-
}
|
|
669
|
-
output[index] = row[key];
|
|
670
|
-
count += 1;
|
|
671
|
-
}
|
|
672
|
-
if (count !== columnMap.size) {
|
|
673
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
function inferParameters({ length }) {
|
|
677
|
-
if (!Number.isInteger(length) || length < 0) {
|
|
678
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
679
|
-
}
|
|
680
|
-
const params = [];
|
|
681
|
-
for (let i = 0; i < length; ++i) {
|
|
682
|
-
params.push(`$${i + 1}`);
|
|
683
|
-
}
|
|
684
|
-
return params;
|
|
685
|
-
}
|
|
686
|
-
var { hasOwnProperty } = Object.prototype;
|
|
687
|
-
var { apply } = Function.prototype;
|
|
688
|
-
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
689
|
-
});
|
|
690
|
-
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
691
|
-
var defer = (x) => () => x;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
var require_inspect = __commonJS({
|
|
695
|
-
"../../node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
|
|
696
|
-
"use strict";
|
|
697
|
-
var DatabaseInspection = function Database2() {
|
|
698
|
-
};
|
|
699
|
-
module.exports = function inspect(depth, opts) {
|
|
700
|
-
return Object.assign(new DatabaseInspection(), this);
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
var require_database = __commonJS({
|
|
705
|
-
"../../node_modules/better-sqlite3/lib/database.js"(exports, module) {
|
|
706
|
-
"use strict";
|
|
707
|
-
var fs = __require("fs");
|
|
708
|
-
var path = __require("path");
|
|
709
|
-
var util = require_util();
|
|
710
|
-
var SqliteError = require_sqlite_error();
|
|
711
|
-
var DEFAULT_ADDON;
|
|
712
|
-
function Database2(filenameGiven, options) {
|
|
713
|
-
if (new.target == null) {
|
|
714
|
-
return new Database2(filenameGiven, options);
|
|
715
|
-
}
|
|
716
|
-
let buffer;
|
|
717
|
-
if (Buffer.isBuffer(filenameGiven)) {
|
|
718
|
-
buffer = filenameGiven;
|
|
719
|
-
filenameGiven = ":memory:";
|
|
720
|
-
}
|
|
721
|
-
if (filenameGiven == null) filenameGiven = "";
|
|
722
|
-
if (options == null) options = {};
|
|
723
|
-
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
724
|
-
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
725
|
-
if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
726
|
-
if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
727
|
-
const filename = filenameGiven.trim();
|
|
728
|
-
const anonymous = filename === "" || filename === ":memory:";
|
|
729
|
-
const readonly = util.getBooleanOption(options, "readonly");
|
|
730
|
-
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
731
|
-
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
732
|
-
const verbose = "verbose" in options ? options.verbose : null;
|
|
733
|
-
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
734
|
-
if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
735
|
-
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
736
|
-
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
737
|
-
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
738
|
-
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
739
|
-
let addon;
|
|
740
|
-
if (nativeBinding == null) {
|
|
741
|
-
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
742
|
-
} else if (typeof nativeBinding === "string") {
|
|
743
|
-
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
744
|
-
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
745
|
-
} else {
|
|
746
|
-
addon = nativeBinding;
|
|
747
|
-
}
|
|
748
|
-
if (!addon.isInitialized) {
|
|
749
|
-
addon.setErrorConstructor(SqliteError);
|
|
750
|
-
addon.isInitialized = true;
|
|
751
|
-
}
|
|
752
|
-
if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
|
|
753
|
-
throw new TypeError("Cannot open database because the directory does not exist");
|
|
754
|
-
}
|
|
755
|
-
Object.defineProperties(this, {
|
|
756
|
-
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
757
|
-
...wrappers.getters
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
var wrappers = require_wrappers();
|
|
761
|
-
Database2.prototype.prepare = wrappers.prepare;
|
|
762
|
-
Database2.prototype.transaction = require_transaction();
|
|
763
|
-
Database2.prototype.pragma = require_pragma();
|
|
764
|
-
Database2.prototype.backup = require_backup();
|
|
765
|
-
Database2.prototype.serialize = require_serialize();
|
|
766
|
-
Database2.prototype.function = require_function();
|
|
767
|
-
Database2.prototype.aggregate = require_aggregate();
|
|
768
|
-
Database2.prototype.table = require_table();
|
|
769
|
-
Database2.prototype.loadExtension = wrappers.loadExtension;
|
|
770
|
-
Database2.prototype.exec = wrappers.exec;
|
|
771
|
-
Database2.prototype.close = wrappers.close;
|
|
772
|
-
Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
773
|
-
Database2.prototype.unsafeMode = wrappers.unsafeMode;
|
|
774
|
-
Database2.prototype[util.inspect] = require_inspect();
|
|
775
|
-
module.exports = Database2;
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
var require_lib = __commonJS({
|
|
779
|
-
"../../node_modules/better-sqlite3/lib/index.js"(exports, module) {
|
|
780
|
-
"use strict";
|
|
781
|
-
module.exports = require_database();
|
|
782
|
-
module.exports.SqliteError = require_sqlite_error();
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
var import_better_sqlite3 = __toESM(require_lib(), 1);
|
|
9
|
+
function createFallbackSession(agentType, name) {
|
|
10
|
+
return {
|
|
11
|
+
agentType,
|
|
12
|
+
projectPath: name,
|
|
13
|
+
projectName: name,
|
|
14
|
+
isSubagent: false,
|
|
15
|
+
projectDir: name,
|
|
16
|
+
parentSessionId: null
|
|
17
|
+
};
|
|
18
|
+
}
|
|
786
19
|
var config = {
|
|
787
20
|
port: parseInt(process.env.AGENT_MOVE_PORT || "3333", 10),
|
|
788
21
|
claudeHome: join(homedir(), ".claude"),
|
|
@@ -794,7 +27,11 @@ var config = {
|
|
|
794
27
|
activeThresholdMs: 10 * 60 * 1e3,
|
|
795
28
|
// 10 minutes
|
|
796
29
|
/** Enable OpenCode session watching (auto-detected if storage dir exists) */
|
|
797
|
-
enableOpenCode: process.env.AGENT_MOVE_OPENCODE !== "false"
|
|
30
|
+
enableOpenCode: process.env.AGENT_MOVE_OPENCODE !== "false",
|
|
31
|
+
/** Enable pi coding agent session watching (auto-detected if sessions dir exists) */
|
|
32
|
+
enablePi: process.env.AGENT_MOVE_PI !== "false",
|
|
33
|
+
/** Enable Codex CLI session watching (auto-detected if sessions dir exists) */
|
|
34
|
+
enableCodex: process.env.AGENT_MOVE_CODEX !== "false"
|
|
798
35
|
};
|
|
799
36
|
function getOpenCodeDbPath() {
|
|
800
37
|
const home = homedir2();
|
|
@@ -814,6 +51,7 @@ function parseOpenCodeSession(row) {
|
|
|
814
51
|
const segments = row.directory.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
815
52
|
const projectName = segments[segments.length - 1] || "opencode";
|
|
816
53
|
return {
|
|
54
|
+
agentType: "opencode",
|
|
817
55
|
// Use the actual directory as projectPath so getGitBranch() gets a valid cwd.
|
|
818
56
|
// projectDir uses the project_id hash to group agents belonging to the same project.
|
|
819
57
|
projectPath: row.directory || row.project_id,
|
|
@@ -824,7 +62,7 @@ function parseOpenCodeSession(row) {
|
|
|
824
62
|
};
|
|
825
63
|
}
|
|
826
64
|
var TOOL_NAME_MAP = {
|
|
827
|
-
// OpenCode lowercase → canonical PascalCase
|
|
65
|
+
// OpenCode / pi lowercase → canonical PascalCase
|
|
828
66
|
read: "Read",
|
|
829
67
|
write: "Write",
|
|
830
68
|
edit: "Edit",
|
|
@@ -835,7 +73,36 @@ var TOOL_NAME_MAP = {
|
|
|
835
73
|
websearch: "WebSearch",
|
|
836
74
|
webfetch: "WebFetch",
|
|
837
75
|
todoread: "TodoRead",
|
|
838
|
-
todowrite: "TodoWrite"
|
|
76
|
+
todowrite: "TodoWrite",
|
|
77
|
+
// pi-specific tool names
|
|
78
|
+
"edit-diff": "Patch",
|
|
79
|
+
find: "Glob",
|
|
80
|
+
ls: "Bash",
|
|
81
|
+
truncate: "Write",
|
|
82
|
+
// Codex CLI tool names
|
|
83
|
+
shell_command: "Bash",
|
|
84
|
+
exec_command: "Bash",
|
|
85
|
+
read_file: "Read",
|
|
86
|
+
apply_patch: "Patch",
|
|
87
|
+
list_dir: "Bash",
|
|
88
|
+
grep_files: "Grep",
|
|
89
|
+
web_search: "WebSearch",
|
|
90
|
+
js_repl: "Bash",
|
|
91
|
+
js_repl_reset: "Bash",
|
|
92
|
+
spawn_agent: "Agent",
|
|
93
|
+
send_input: "Agent",
|
|
94
|
+
wait: "Agent",
|
|
95
|
+
close_agent: "Agent",
|
|
96
|
+
resume_agent: "Agent",
|
|
97
|
+
spawn_agents_on_csv: "Agent",
|
|
98
|
+
report_agent_job_result: "Agent",
|
|
99
|
+
request_user_input: "AskUserQuestion",
|
|
100
|
+
request_permissions: "AskUserQuestion",
|
|
101
|
+
update_plan: "TodoWrite",
|
|
102
|
+
view_image: "Read",
|
|
103
|
+
image_generation: "Write",
|
|
104
|
+
write_stdin: "Bash",
|
|
105
|
+
search_apps: "WebSearch"
|
|
839
106
|
};
|
|
840
107
|
function normalizeToolName(name) {
|
|
841
108
|
return TOOL_NAME_MAP[name] ?? name;
|
|
@@ -1111,7 +378,7 @@ var OpenCodeWatcher = class {
|
|
|
1111
378
|
}
|
|
1112
379
|
console.log(`[opencode] Database found at ${dbPath}`);
|
|
1113
380
|
try {
|
|
1114
|
-
this.db = new
|
|
381
|
+
this.db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
1115
382
|
this.prepareStatements();
|
|
1116
383
|
} catch (err) {
|
|
1117
384
|
console.error("[opencode] Failed to open database:", err);
|
|
@@ -1275,13 +542,7 @@ var OpenCodeWatcher = class {
|
|
|
1275
542
|
return id.startsWith("oc:") ? id : `oc:${id}`;
|
|
1276
543
|
}
|
|
1277
544
|
fallbackSession() {
|
|
1278
|
-
return
|
|
1279
|
-
projectPath: "opencode",
|
|
1280
|
-
projectName: "opencode",
|
|
1281
|
-
isSubagent: false,
|
|
1282
|
-
projectDir: "opencode",
|
|
1283
|
-
parentSessionId: null
|
|
1284
|
-
};
|
|
545
|
+
return createFallbackSession("opencode", "opencode");
|
|
1285
546
|
}
|
|
1286
547
|
};
|
|
1287
548
|
export {
|