arkflow-magpie-plugins 0.0.0-stage → 2.0.19
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/LICENSE +21 -0
- package/NOTICE +17 -0
- package/README.en.md +29 -0
- package/README.md +28 -2
- package/bundled/meeting-actions/SKILL.md +11 -0
- package/docs/MAGPIE-LICENSE +21 -0
- package/index.mjs +9 -0
- package/package.json +79 -4
- package/page/app.css +275 -0
- package/page/app.js +784 -0
- package/page/bootstrap.js +59 -0
- package/page/connection.js +24 -0
- package/page/icon.svg +3 -0
- package/page/index.html +28 -0
- package/page/logo.png +0 -0
- package/page/magpie-components.css +131 -0
- package/page/request.js +101 -0
- package/page/service.html +3 -0
- package/page/store-model.mjs +107 -0
- package/page/theme.js +51 -0
- package/src/accounts.mjs +124 -0
- package/src/api-client.mjs +292 -0
- package/src/bundled-skills.mjs +13 -0
- package/src/config.mjs +71 -0
- package/src/credentials.mjs +90 -0
- package/src/host-adapter.mjs +707 -0
- package/src/install-defaults.mjs +92 -0
- package/src/install-identity.mjs +32 -0
- package/src/manual-initialization.mjs +225 -0
- package/src/native-auth.mjs +62 -0
- package/src/native-control.mjs +236 -0
- package/src/native-providers.mjs +422 -0
- package/src/page-service.mjs +358 -0
- package/src/provider.mjs +44 -0
- package/src/runtime.mjs +302 -0
- package/src/session.mjs +366 -0
- package/src/skill-metadata.mjs +32 -0
- package/src/skill-packages.mjs +226 -0
- package/src/skills.mjs +454 -0
- package/src/state-store.mjs +89 -0
- package/src/sync-engine.mjs +392 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import { execFile } from "node:child_process"
|
|
2
|
+
import { access, chmod, constants as fsConstants, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises"
|
|
3
|
+
import { homedir } from "node:os"
|
|
4
|
+
import { fileURLToPath } from "node:url"
|
|
5
|
+
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path"
|
|
6
|
+
import { PRODUCTION_ORIGIN } from "./config.mjs"
|
|
7
|
+
import { skillDescription } from "./skill-metadata.mjs"
|
|
8
|
+
import { manifestFor, hashSkillManifest } from "./skill-packages.mjs"
|
|
9
|
+
|
|
10
|
+
const ALIAS_RE = /^[a-z0-9][a-z0-9_-]{0,79}$/
|
|
11
|
+
const LIBRARY_SKILL_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,159}$/
|
|
12
|
+
const AGENT_RE = /^[a-z0-9][a-z0-9_.-]{0,79}$/
|
|
13
|
+
const AGENT_MODEL_DEFAULTS = [
|
|
14
|
+
{ id: "codex", name: "Codex" },
|
|
15
|
+
{ id: "claude", name: "Claude Code" },
|
|
16
|
+
{ id: "dsh", name: "DeepSeek Harness" },
|
|
17
|
+
]
|
|
18
|
+
const NOVAFLOW_MODEL = /^novaflow-key-[a-f0-9]{20}\/\S+$/
|
|
19
|
+
const GPT_SOL = /^gpt-\d+(?:\.\d+)*-sol(?:$|[-_])/i
|
|
20
|
+
const MODEL_ORDER = new Intl.Collator("en", { numeric: true, sensitivity: "base" })
|
|
21
|
+
const AGENT_CLI = { env: { NO_COLOR: "1" }, timeout: 30_000 }
|
|
22
|
+
|
|
23
|
+
function catalogModelRef(value) {
|
|
24
|
+
return value.replace(/^magpie\//, "")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function oldNovaFlowModel(ref) {
|
|
28
|
+
const direct = /^(?:novaflow-key-[a-f0-9]{20}|novaflow)\/([^\s,]+)$/.exec(ref)
|
|
29
|
+
if (direct) return direct[1]
|
|
30
|
+
const legacy = /^nf:[^:\s]+:([A-Za-z0-9_-]+)$/.exec(ref)
|
|
31
|
+
return legacy ? Buffer.from(legacy[1], "base64url").toString() : ""
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function detectedAgentRows(listing) {
|
|
35
|
+
return [...listing.matchAll(/^ {2,}(\S[^\r\n]*?) {2,}(\S[^\r\n]*)/gm)].map(([, label, summary]) => ({
|
|
36
|
+
name: label.replace(/ hidden$/, ""), summary,
|
|
37
|
+
})).filter(({ summary }) => !/^(?:CLI not found|magpie added|magpie .+ add|not detected)\b/.test(summary))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function runChild(exec, command, args, options = {}) {
|
|
41
|
+
return new Promise((resolvePromise, reject) => {
|
|
42
|
+
exec(command, args, {
|
|
43
|
+
encoding: "utf8",
|
|
44
|
+
maxBuffer: 4 << 20,
|
|
45
|
+
timeout: options.timeout ?? 15_000,
|
|
46
|
+
env: options.env ?? process.env,
|
|
47
|
+
signal: options.signal,
|
|
48
|
+
}, (error, stdout, stderr) => {
|
|
49
|
+
if (error) {
|
|
50
|
+
error.stdout = String(stdout ?? "")
|
|
51
|
+
error.stderr = String(stderr ?? "")
|
|
52
|
+
reject(error)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
resolvePromise({ stdout: String(stdout ?? ""), stderr: String(stderr ?? "") })
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isInside(root, candidate) {
|
|
61
|
+
const relation = relative(resolve(root), resolve(candidate))
|
|
62
|
+
return relation === "" || (!!relation && !relation.startsWith("..") && !relation.includes(sep + ".."))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parseLibraryView(text) {
|
|
66
|
+
const lines = String(text ?? "").split(/\r?\n/)
|
|
67
|
+
const skills = []
|
|
68
|
+
let insideSkills = false
|
|
69
|
+
let libraryDir = ""
|
|
70
|
+
for (const line of lines) {
|
|
71
|
+
const kept = /^\s*kept in\s+(.+?)\s*$/.exec(line)
|
|
72
|
+
if (kept) {
|
|
73
|
+
// Magpie appends its help hint after the real path, for example:
|
|
74
|
+
// kept in /Users/example/.config/magpie/library · magpie library help
|
|
75
|
+
// Keep only the directory before treating this as a filesystem path.
|
|
76
|
+
libraryDir = kept[1].split(/\s+·\s+/, 1)[0].trim()
|
|
77
|
+
insideSkills = false
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
80
|
+
if (/^Skills\s*$/.test(line)) {
|
|
81
|
+
insideSkills = true
|
|
82
|
+
continue
|
|
83
|
+
}
|
|
84
|
+
if (/^(?:MCP servers|Instructions|RTK)\b/.test(line)) insideSkills = false
|
|
85
|
+
if (!insideSkills) continue
|
|
86
|
+
const match = /^\s{2,}([A-Za-z0-9][A-Za-z0-9_.-]*)(?:\s*(?:→|->)\s*(.+))?$/.exec(line)
|
|
87
|
+
if (!match) continue
|
|
88
|
+
const agents = match[2] && match[2].trim() !== "no agent"
|
|
89
|
+
? match[2].split(/[,,]\s*/).map((item) => item.trim()).filter(Boolean)
|
|
90
|
+
: []
|
|
91
|
+
skills.push({ name: match[1], agents })
|
|
92
|
+
}
|
|
93
|
+
return { skills, libraryDir }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function normalizeAgentList(value) {
|
|
97
|
+
if (value === "all") return "all"
|
|
98
|
+
if (!Array.isArray(value)) return []
|
|
99
|
+
const out = []
|
|
100
|
+
for (const item of value) {
|
|
101
|
+
const agent = String(item ?? "").trim()
|
|
102
|
+
if (agent && !AGENT_RE.test(agent)) throw new Error("Invalid Magpie agent identifier")
|
|
103
|
+
if (agent && !out.includes(agent)) out.push(agent)
|
|
104
|
+
}
|
|
105
|
+
return out.slice(0, 32)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class MagpieHostAdapter {
|
|
109
|
+
constructor({
|
|
110
|
+
magpiePath = "",
|
|
111
|
+
execImpl = execFile,
|
|
112
|
+
env = process.env,
|
|
113
|
+
platform = process.platform,
|
|
114
|
+
directory = "",
|
|
115
|
+
sharedSkillsDir,
|
|
116
|
+
home = homedir(),
|
|
117
|
+
now = () => new Date(),
|
|
118
|
+
} = {}) {
|
|
119
|
+
this.magpiePath = magpiePath
|
|
120
|
+
this.execImpl = execImpl
|
|
121
|
+
this.env = env
|
|
122
|
+
this.platform = platform
|
|
123
|
+
this.directory = directory
|
|
124
|
+
this.home = home
|
|
125
|
+
this.sharedSkillsDir = sharedSkillsDir || join(home, ".agents", "skills")
|
|
126
|
+
this.now = now
|
|
127
|
+
this.available = false
|
|
128
|
+
this.version = ""
|
|
129
|
+
this.lastError = ""
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static async detect({ platform = process.platform, env = process.env, paths = [], directory = "" } = {}) {
|
|
133
|
+
// Even `magpie --version` loads provider plugins. Discover files only;
|
|
134
|
+
// executing Magpie here would recursively initialize this plugin.
|
|
135
|
+
const configured = [
|
|
136
|
+
env.MAGPIE_CLI_PATH,
|
|
137
|
+
env.MAGPIE_BIN,
|
|
138
|
+
...paths,
|
|
139
|
+
platform === "darwin" ? "/Applications/magpie.app/Contents/MacOS/magpie" : "",
|
|
140
|
+
platform === "win32" ? join(env.LOCALAPPDATA ?? "", "Programs", "magpie", "magpie.exe") : "",
|
|
141
|
+
].filter(Boolean)
|
|
142
|
+
const searchPaths = String(env.PATH || "").split(platform === "win32" ? ";" : delimiter).filter(Boolean)
|
|
143
|
+
const executable = platform === "win32" ? "magpie.exe" : "magpie"
|
|
144
|
+
const candidates = configured.flatMap((candidate) => isAbsolute(candidate)
|
|
145
|
+
? [candidate]
|
|
146
|
+
: searchPaths.map((path) => join(path, candidate)))
|
|
147
|
+
candidates.push(...searchPaths.map((path) => join(path, executable)))
|
|
148
|
+
for (const candidate of new Set(candidates)) {
|
|
149
|
+
try {
|
|
150
|
+
await access(candidate, platform === "win32" ? fsConstants.F_OK : fsConstants.X_OK)
|
|
151
|
+
if (!(await stat(candidate)).isFile()) continue
|
|
152
|
+
let version = ""
|
|
153
|
+
if (platform === "darwin") {
|
|
154
|
+
// Magpie's app bundle ships an XML plist. Unsupported metadata
|
|
155
|
+
// formats leave the version unknown, never trigger a CLI fallback.
|
|
156
|
+
const plist = await readFile(join(dirname(candidate), "..", "Info.plist"), "utf8").catch(() => "")
|
|
157
|
+
version = /<key>CFBundleShortVersionString<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(plist)?.[1] || ""
|
|
158
|
+
}
|
|
159
|
+
if (!version && directory) {
|
|
160
|
+
const saved = await readFile(join(directory, "last-version"), "utf8").catch(() => "")
|
|
161
|
+
version = /^(?:magpie\s+)?(\d+\.\d+\.\d+)\s*$/.exec(saved)?.[1] || ""
|
|
162
|
+
}
|
|
163
|
+
return { magpiePath: candidate, version }
|
|
164
|
+
} catch {}
|
|
165
|
+
}
|
|
166
|
+
return { magpiePath: "", version: "" }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async run(args, options = {}) {
|
|
170
|
+
if (this.env.NOVAFLOW_PLUGIN_CLI_CHILD === "1") throw new Error("Nested ArkFlow CLI calls are disabled")
|
|
171
|
+
if (!this.magpiePath) throw new Error("Magpie CLI is unavailable")
|
|
172
|
+
return runChild(this.execImpl, this.magpiePath, args, {
|
|
173
|
+
...options,
|
|
174
|
+
// Magpie loads providers for Library commands too. The entry point
|
|
175
|
+
// returns no hooks in this child, so no service or sync can start.
|
|
176
|
+
env: { ...this.env, ...options.env, NOVAFLOW_PLUGIN_CLI_CHILD: "1" },
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async initialize() {
|
|
181
|
+
const detected = await MagpieHostAdapter.detect({
|
|
182
|
+
platform: this.platform,
|
|
183
|
+
env: this.env,
|
|
184
|
+
paths: this.magpiePath ? [this.magpiePath] : [],
|
|
185
|
+
directory: this.directory,
|
|
186
|
+
})
|
|
187
|
+
this.magpiePath = detected.magpiePath
|
|
188
|
+
this.version = detected.version
|
|
189
|
+
this.available = !!this.magpiePath
|
|
190
|
+
this.lastError = this.available ? "" : "Magpie CLI is unavailable"
|
|
191
|
+
return this.available
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async openWebsite() {
|
|
195
|
+
// Sandboxed plugin pages cannot open popups. This command has no caller
|
|
196
|
+
// URL: it can only open the build's fixed ArkFlow website.
|
|
197
|
+
const command = this.platform === "darwin" ? "/usr/bin/open" : this.platform === "win32" ? "rundll32.exe" : "xdg-open"
|
|
198
|
+
const args = this.platform === "win32" ? ["url.dll,FileProtocolHandler", PRODUCTION_ORIGIN] : [PRODUCTION_ORIGIN]
|
|
199
|
+
await runChild(this.execImpl, command, args, { env: this.env, timeout: 5_000 })
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async openEnterpriseGuide() {
|
|
203
|
+
await this.openBrowser(PRODUCTION_ORIGIN + "/profile")
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async openAuthorization(target) {
|
|
207
|
+
if (!target.startsWith(PRODUCTION_ORIGIN + "/desktop/authorize?request=") || !/^nfda_[\w-]{43}$/.test(target.slice((PRODUCTION_ORIGIN + "/desktop/authorize?request=").length))) throw new Error("Invalid ArkFlow authorization URL")
|
|
208
|
+
await this.openBrowser(target)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async openBrowser(target) {
|
|
212
|
+
const command = this.platform === "darwin" ? "/usr/bin/open" : this.platform === "win32" ? "rundll32.exe" : "xdg-open"
|
|
213
|
+
const args = this.platform === "win32" ? ["url.dll,FileProtocolHandler", target] : [target]
|
|
214
|
+
await runChild(this.execImpl, command, args, { env: this.env, timeout: 5_000 })
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async refreshProvider(id, signal) {
|
|
218
|
+
if (!/^novaflow-key-[a-f0-9]{20}$/.test(id)) throw new Error("Invalid managed provider identifier")
|
|
219
|
+
if (!this.available) await this.initialize()
|
|
220
|
+
if (!this.available) throw new Error("Magpie CLI is unavailable")
|
|
221
|
+
try {
|
|
222
|
+
await this.run(["provider", "refresh", id], { timeout: 45_000, signal })
|
|
223
|
+
} catch (error) {
|
|
224
|
+
const empty = /^magpie: no model list: (https?:\/\/[^\s;]+): no models listed(?: — type its model ids in by hand, or give the URL its list is at)?$/m.exec(String(error.stderr || "").trim())
|
|
225
|
+
if (error.code === 1 && empty) {
|
|
226
|
+
throw Object.assign(new Error("Magpie returned no models"), { code: "PLUGIN_NATIVE_EMPTY_LIST", listURL: empty[1] })
|
|
227
|
+
}
|
|
228
|
+
throw error
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async syncProviderIcon(id, signal) {
|
|
233
|
+
if (!/^novaflow-key-[a-f0-9]{20}$/.test(id)) throw new Error("Invalid managed provider identifier")
|
|
234
|
+
if (!this.available) await this.initialize()
|
|
235
|
+
if (!this.available) throw new Error("Magpie CLI is unavailable")
|
|
236
|
+
const asset = fileURLToPath(new URL("../page/icon.svg", import.meta.url))
|
|
237
|
+
await this.run(["provider", "icon", id, asset], { timeout: 15_000, signal })
|
|
238
|
+
const config = JSON.parse(await readFile(join(this.directory, "providers.json"), "utf8"))
|
|
239
|
+
const icon = config.providers?.find(item => item.id === id)?.icon
|
|
240
|
+
if (!/^file:[a-f0-9]{16}\.svg$/.test(icon || "")) throw new Error("Magpie did not register the provider icon")
|
|
241
|
+
const path = join(this.directory, "icons", icon.slice(5))
|
|
242
|
+
const info = await lstat(path)
|
|
243
|
+
if (!info.isFile() || info.isSymbolicLink() || info.size > (1 << 20)) throw new Error("Magpie provider icon is unavailable")
|
|
244
|
+
if (!(await readFile(path)).equals(await readFile(asset))) throw new Error("Magpie provider icon verification failed")
|
|
245
|
+
return icon
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
providerCacheDirectory() {
|
|
249
|
+
const configBase = isAbsolute(this.env.XDG_CONFIG_HOME || "") ? this.env.XDG_CONFIG_HOME : join(this.home, ".config")
|
|
250
|
+
// A portable Magpie puts both configuration and cache beneath its data folder.
|
|
251
|
+
if (resolve(this.directory) !== resolve(join(configBase, "magpie"))) return join(this.directory, "cache", "models")
|
|
252
|
+
const cacheBase = isAbsolute(this.env.XDG_CACHE_HOME || "") ? this.env.XDG_CACHE_HOME : join(this.home, ".cache")
|
|
253
|
+
return join(cacheBase, "magpie", "models")
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async readProviderCatalog(id, { includeUnmanaged = false } = {}) {
|
|
257
|
+
if (!(includeUnmanaged ? /^[a-z0-9][a-z0-9_.-]{0,79}$/.test(id) : /^novaflow-key-[a-f0-9]{20}$/.test(id))) throw new Error("Invalid managed provider identifier")
|
|
258
|
+
const path = join(this.providerCacheDirectory(), id + ".json")
|
|
259
|
+
let cached
|
|
260
|
+
try {
|
|
261
|
+
const info = await lstat(path)
|
|
262
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Invalid model cache")
|
|
263
|
+
cached = JSON.parse(await readFile(path, "utf8"))
|
|
264
|
+
if (!Array.isArray(cached.models)) throw new Error("Invalid model cache")
|
|
265
|
+
} catch (error) {
|
|
266
|
+
if (error.code === "ENOENT") return { models: [] }
|
|
267
|
+
throw new Error("Magpie model cache is unavailable")
|
|
268
|
+
}
|
|
269
|
+
return { models: cached.models.filter(model => typeof model.ID === "string").map(model => ({
|
|
270
|
+
id: model.ID, name: String(model.Name || model.ID), draws: model.Draws === true, films: model.Films === true,
|
|
271
|
+
})) }
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async library() {
|
|
275
|
+
if (!this.available) await this.initialize()
|
|
276
|
+
if (!this.available) throw new Error(this.lastError || "Magpie Library is unavailable")
|
|
277
|
+
const result = await this.run(["library"])
|
|
278
|
+
const parsed = parseLibraryView(result.stdout)
|
|
279
|
+
if (!parsed.libraryDir) throw new Error("Magpie Library did not report its directory")
|
|
280
|
+
return parsed
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async ensureLibraryDirectory(reportedDirectory) {
|
|
284
|
+
const configDirectory = this.directory || join(
|
|
285
|
+
isAbsolute(this.env.XDG_CONFIG_HOME || "") ? this.env.XDG_CONFIG_HOME : join(this.home, ".config"),
|
|
286
|
+
"magpie",
|
|
287
|
+
)
|
|
288
|
+
const libraryDirectory = join(resolve(configDirectory), "library")
|
|
289
|
+
if (!isAbsolute(reportedDirectory) || resolve(reportedDirectory) !== libraryDirectory) {
|
|
290
|
+
throw new Error("Magpie reported an unexpected Library directory")
|
|
291
|
+
}
|
|
292
|
+
const checkDirectory = async (path) => {
|
|
293
|
+
const info = await lstat(path)
|
|
294
|
+
if (!info.isDirectory() || info.isSymbolicLink() || (process.getuid && info.uid !== process.getuid())) {
|
|
295
|
+
throw new Error("Magpie Library directory ownership is invalid")
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Only create the fixed child of the host's existing configuration root.
|
|
299
|
+
// A fresh `magpie library` reports this directory before creating it.
|
|
300
|
+
await checkDirectory(configDirectory)
|
|
301
|
+
try {
|
|
302
|
+
await mkdir(libraryDirectory, { mode: 0o700 })
|
|
303
|
+
} catch (error) {
|
|
304
|
+
if (error?.code !== "EEXIST") throw error
|
|
305
|
+
}
|
|
306
|
+
await checkDirectory(libraryDirectory)
|
|
307
|
+
try {
|
|
308
|
+
await checkDirectory(join(libraryDirectory, "skills"))
|
|
309
|
+
} catch (error) {
|
|
310
|
+
if (error?.code !== "ENOENT") throw error
|
|
311
|
+
}
|
|
312
|
+
return realpath(libraryDirectory)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async listSkills() {
|
|
316
|
+
const view = await this.library()
|
|
317
|
+
const libraryDir = await this.ensureLibraryDirectory(view.libraryDir)
|
|
318
|
+
const skillsRoot = join(libraryDir, "skills")
|
|
319
|
+
const rootInfo = await lstat(skillsRoot).catch(() => null)
|
|
320
|
+
if (!rootInfo?.isDirectory() || rootInfo.isSymbolicLink()) {
|
|
321
|
+
return { skills: [], libraryAvailable: true, source: "magpie-cli" }
|
|
322
|
+
}
|
|
323
|
+
const skills = []
|
|
324
|
+
for (const item of view.skills) {
|
|
325
|
+
if (!LIBRARY_SKILL_RE.test(item.name)) continue
|
|
326
|
+
const path = join(skillsRoot, item.name)
|
|
327
|
+
let info
|
|
328
|
+
try {
|
|
329
|
+
const [link, directory] = await Promise.all([lstat(path), stat(path)])
|
|
330
|
+
if (!directory.isDirectory() || link.isSymbolicLink() || !isInside(skillsRoot, path)) continue
|
|
331
|
+
info = directory
|
|
332
|
+
} catch {
|
|
333
|
+
continue
|
|
334
|
+
}
|
|
335
|
+
let description = ""
|
|
336
|
+
let entry
|
|
337
|
+
try {
|
|
338
|
+
entry = await open(join(path, "SKILL.md"), fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW || 0))
|
|
339
|
+
const meta = await entry.stat()
|
|
340
|
+
if (meta.isFile() && meta.size <= (2 << 20)) description = skillDescription(await entry.readFile())
|
|
341
|
+
} catch {} finally { await entry?.close() }
|
|
342
|
+
skills.push({
|
|
343
|
+
name: item.name,
|
|
344
|
+
description,
|
|
345
|
+
agents: item.agents,
|
|
346
|
+
source: "magpie-library",
|
|
347
|
+
status: "registered",
|
|
348
|
+
modifiedAt: info.mtime.toISOString(),
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
return { skills, libraryAvailable: true, source: "magpie-cli" }
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async listAgents() {
|
|
355
|
+
if (!this.available) await this.initialize()
|
|
356
|
+
if (!this.available) throw new Error(this.lastError || "Magpie CLI is unavailable")
|
|
357
|
+
const result = await this.run(["agents"], { timeout: 20_000 })
|
|
358
|
+
return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && AGENT_RE.test(line)).slice(0, 64)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async enableAutostart(assertCurrent) {
|
|
362
|
+
const cli = { env: { NO_COLOR: "1" } }
|
|
363
|
+
const enabled = /(?:magpie opens at login, in the tray|magpie starts the gateway at boot \(requires Termux:Boot\))\s*$/m
|
|
364
|
+
const blocked = "macOS 阻止了 Magpie 开机自启,请在系统设置的「通用 → 登录项与扩展」中允许 Magpie 在后台运行,再重试。"
|
|
365
|
+
const failed = "无法启用 Magpie 开机自启,请在 Magpie 设置中检查后重试。"
|
|
366
|
+
const readStatus = async args => {
|
|
367
|
+
let stdout
|
|
368
|
+
try { ({ stdout } = await this.run(args, cli)) } catch { throw new Error(failed) }
|
|
369
|
+
if (stdout.includes("it is switched off in System Settings")) throw new Error(blocked)
|
|
370
|
+
return stdout
|
|
371
|
+
}
|
|
372
|
+
const current = await readStatus(["autostart"])
|
|
373
|
+
if (enabled.test(current)) return
|
|
374
|
+
if (!current.includes("magpie doesn't open at login")) throw new Error(failed)
|
|
375
|
+
assertCurrent()
|
|
376
|
+
if (!enabled.test(await readStatus(["autostart", "on"]))) throw new Error(failed)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async disableAutomaticRoutingGroups(assertCurrent) {
|
|
380
|
+
const args = ["group", "auto"]
|
|
381
|
+
const options = { env: { NO_COLOR: "1" } }
|
|
382
|
+
const failed = "无法关闭自动创建路由组,请在 Magpie 的路由页面检查后重试。"
|
|
383
|
+
const readStatus = async () => {
|
|
384
|
+
const { stdout } = await this.run(args, options).catch(() => { throw new Error(failed) })
|
|
385
|
+
return /^found groups are (on|off)\b/m.exec(stdout)?.[1]
|
|
386
|
+
}
|
|
387
|
+
const current = await readStatus()
|
|
388
|
+
if (current === "off") return
|
|
389
|
+
if (current !== "on") throw new Error(failed)
|
|
390
|
+
assertCurrent()
|
|
391
|
+
try {
|
|
392
|
+
await this.run([...args, "off"], options)
|
|
393
|
+
} catch (error) {
|
|
394
|
+
if (error.stderr?.includes("take it out, or change it to make it yours, first")) {
|
|
395
|
+
throw new Error("自定义路由组正在引用自动创建的组。请在 Magpie 的路由页面移除该引用,或将引用的组改为自定义组后重试。")
|
|
396
|
+
}
|
|
397
|
+
throw new Error(failed)
|
|
398
|
+
}
|
|
399
|
+
if (await readStatus() !== "off") throw new Error(failed)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
async detectedAgents() {
|
|
403
|
+
try {
|
|
404
|
+
return detectedAgentRows((await this.run(["ls"], AGENT_CLI)).stdout)
|
|
405
|
+
} catch (error) {
|
|
406
|
+
if (error.code === 1 && /^magpie: no supported agents found on this machine\s*$/.test(error.stderr)) return []
|
|
407
|
+
throw new Error("暂时无法读取 Magpie 的 Agent 列表")
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async configureAgentModels(providers, { repairOnly = false, disconnected = {}, assertCurrent }) {
|
|
412
|
+
const candidates = []
|
|
413
|
+
for (const provider of providers) {
|
|
414
|
+
if (provider.off || provider.emptyCatalog) continue
|
|
415
|
+
for (const model of provider.models || []) {
|
|
416
|
+
const ref = `${provider.id}/${model.id}`
|
|
417
|
+
if (GPT_SOL.test(model.id) && NOVAFLOW_MODEL.test(ref) && !model.draws && !model.films) {
|
|
418
|
+
candidates.push({ ref, model: model.id, stable: /稳定|\bstable\b/i.test(provider.groupName || "") })
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (!candidates.length) return 0
|
|
423
|
+
candidates.sort((a, b) => Number(b.stable) - Number(a.stable) || MODEL_ORDER.compare(b.model, a.model))
|
|
424
|
+
const detected = new Set((await this.detectedAgents()).map(agent => agent.name))
|
|
425
|
+
let configured = 0
|
|
426
|
+
const failed = []
|
|
427
|
+
for (const { id, name } of AGENT_MODEL_DEFAULTS) {
|
|
428
|
+
if (!detected.has(name) || disconnected[id + ".disconnected"] === "1") continue
|
|
429
|
+
assertCurrent()
|
|
430
|
+
const readModel = async () => {
|
|
431
|
+
const { stdout } = await this.run([id, "model"], AGENT_CLI)
|
|
432
|
+
const value = stdout.trim().split(/\r?\n/).find(line => line.startsWith(name + " model "))?.slice(name.length + 7)
|
|
433
|
+
if (!value) throw new Error("Unexpected Magpie model state")
|
|
434
|
+
return catalogModelRef(value.trim())
|
|
435
|
+
}
|
|
436
|
+
try {
|
|
437
|
+
const current = await readModel()
|
|
438
|
+
const currentRef = current.replace(/\[1m\]$/, "")
|
|
439
|
+
const previousModel = oldNovaFlowModel(currentRef)
|
|
440
|
+
if (!previousModel && (repairOnly || current !== "default")) continue
|
|
441
|
+
const { stdout } = await this.run(["models", id], AGENT_CLI)
|
|
442
|
+
const visible = new Set(stdout.split(/\r?\n/).map(line => /^ {2}(\S+)/.exec(line)?.[1]))
|
|
443
|
+
if (visible.has(current) || visible.has(currentRef)) continue
|
|
444
|
+
const available = candidates.filter(item => visible.has(item.ref))
|
|
445
|
+
const pick = (available.find(item => item.model === previousModel) || available[0])?.ref
|
|
446
|
+
if (!pick || await readModel() !== current) continue
|
|
447
|
+
assertCurrent()
|
|
448
|
+
// A prefixed ref makes Magpie reject a model that disappeared after listing.
|
|
449
|
+
await this.run([id, "model", "magpie/" + pick], AGENT_CLI)
|
|
450
|
+
const saved = await readModel()
|
|
451
|
+
if (saved !== pick && saved !== pick + "[1m]") throw new Error("Magpie did not retain the model choice")
|
|
452
|
+
configured++
|
|
453
|
+
} catch {
|
|
454
|
+
assertCurrent()
|
|
455
|
+
failed.push(name)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (failed.length) throw new Error(`未能为以下 Agent 设置 ArkFlow 模型:${failed.join("、")}。请重试或在 Magpie 的 Agent 页面检查。`)
|
|
459
|
+
return configured
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
async setNewSessionEffortHigh(assertCurrent) {
|
|
463
|
+
let configured = 0
|
|
464
|
+
const failed = new Set()
|
|
465
|
+
const seen = new Set()
|
|
466
|
+
for (const { name, summary } of await this.detectedAgents()) {
|
|
467
|
+
if (!/^[\p{L}\p{N}][\p{L}\p{N} ._()#@+-]{0,119}$/u.test(name) || seen.has(name)) continue
|
|
468
|
+
seen.add(name)
|
|
469
|
+
if (/(?:^| · )(?:effort|thinking) high(?:\s|$)/.test(summary)) { configured++; continue }
|
|
470
|
+
assertCurrent()
|
|
471
|
+
try {
|
|
472
|
+
// Agent names resolve case-insensitively. Uppercase keeps them distinct
|
|
473
|
+
// from Magpie's lowercase top-level commands, even for custom agents.
|
|
474
|
+
const { stdout } = await this.run([name.toUpperCase(), "effort", "high"], AGENT_CLI)
|
|
475
|
+
if (/ (?:effort|thinking) high(?: \(unchanged\))?\s*$/m.test(stdout)) configured++
|
|
476
|
+
else failed.add(name)
|
|
477
|
+
} catch (error) {
|
|
478
|
+
const unavailable = /^(?:magpie: )?(?:pick a model through magpie for .+ first;|.+(?:has no field "effort" \(fields:|takes an effort of .+not "high"|sends .+ no effort|runs .+, not high \(it would send))/m
|
|
479
|
+
if (error.code === 1 && unavailable.test(error.stderr)) continue
|
|
480
|
+
failed.add(name)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (failed.size) throw new Error(`以下 Agent 的新会话思考强度未能设为高:${[...failed].join("、")}`)
|
|
484
|
+
return configured
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
async readSkillFiles(name) {
|
|
488
|
+
const view = await this.library()
|
|
489
|
+
if (!LIBRARY_SKILL_RE.test(name)) throw new Error("Invalid skill name")
|
|
490
|
+
if (!view.skills.some((item) => item.name === name)) throw new Error("Skill is not registered in Magpie Library")
|
|
491
|
+
const libraryDir = await realpath(view.libraryDir)
|
|
492
|
+
const skillsRoot = join(libraryDir, "skills")
|
|
493
|
+
const skillsInfo = await lstat(skillsRoot)
|
|
494
|
+
if (!skillsInfo.isDirectory() || skillsInfo.isSymbolicLink()) throw new Error("Magpie Library skills folder is not a regular directory")
|
|
495
|
+
const root = join(skillsRoot, name)
|
|
496
|
+
const link = await lstat(root)
|
|
497
|
+
if (link.isSymbolicLink() || !isInside(skillsRoot, root)) throw new Error("Skill is not a regular library folder")
|
|
498
|
+
const found = []
|
|
499
|
+
const seen = new Map()
|
|
500
|
+
const excluded = []
|
|
501
|
+
const EXCLUDE = /(^|[/\\])(?:\.git|node_modules|__pycache__|\.DS_Store|\.env(?:\.[^/\\]+)?|id_rsa|credentials(?:\.json)?|secrets\.ya?ml)$/i
|
|
502
|
+
|
|
503
|
+
async function walk(directory, prefix) {
|
|
504
|
+
const entries = await readdir(directory, { withFileTypes: true })
|
|
505
|
+
entries.sort((a, b) => a.name.localeCompare(b.name))
|
|
506
|
+
for (const entry of entries) {
|
|
507
|
+
const absolute = join(directory, entry.name)
|
|
508
|
+
const path = prefix ? `${prefix}/${entry.name}` : entry.name
|
|
509
|
+
if (entry.isSymbolicLink()) {
|
|
510
|
+
excluded.push({ path, reason: "symlink" })
|
|
511
|
+
continue
|
|
512
|
+
}
|
|
513
|
+
if (EXCLUDE.test(path)) {
|
|
514
|
+
excluded.push({ path, reason: "secret-or-cache" })
|
|
515
|
+
continue
|
|
516
|
+
}
|
|
517
|
+
if (entry.isDirectory()) {
|
|
518
|
+
await walk(absolute, path)
|
|
519
|
+
continue
|
|
520
|
+
}
|
|
521
|
+
if (!entry.isFile()) continue
|
|
522
|
+
if (found.length >= 2_000) throw new Error("Skill contains too many files")
|
|
523
|
+
const bytes = await readFile(absolute)
|
|
524
|
+
if (bytes.byteLength > 64 << 20) throw new Error("Skill file is too large")
|
|
525
|
+
const lowered = path.toLowerCase()
|
|
526
|
+
if (seen.has(lowered)) throw new Error("Skill contains a case-insensitive path collision")
|
|
527
|
+
seen.set(lowered, path)
|
|
528
|
+
found.push({ path, bytes })
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
await walk(root, "")
|
|
532
|
+
found.sort((a, b) => {
|
|
533
|
+
if (a.path === "SKILL.md") return -1
|
|
534
|
+
if (b.path === "SKILL.md") return 1
|
|
535
|
+
return a.path.localeCompare(b.path)
|
|
536
|
+
})
|
|
537
|
+
return { files: found, excluded }
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
async registeredHash(name) {
|
|
541
|
+
if (!ALIAS_RE.test(name)) throw new Error("Invalid skill name")
|
|
542
|
+
const view = await this.library()
|
|
543
|
+
if (!view.skills.some(item => item.name === name)) return null
|
|
544
|
+
const path = join(await this.ensureLibraryDirectory(view.libraryDir), "skills", name)
|
|
545
|
+
if (!(await lstat(path)).isDirectory()) throw new Error("资料库技能目录已变化")
|
|
546
|
+
return hashPackageFiles(await packageFilesFromDirectory(path))
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
async registerSkill({ name, sourceDir, agents = [], packageFiles = [], manifestHash = "", replaceExisting = false, previousHash, check = () => {} }) {
|
|
550
|
+
if (!ALIAS_RE.test(name)) throw new Error("Invalid managed skill alias")
|
|
551
|
+
const targetAgents = normalizeAgentList(agents)
|
|
552
|
+
await mkdir(this.sharedSkillsDir, { recursive: true, mode: 0o700 })
|
|
553
|
+
let staged = join(this.sharedSkillsDir, `.novaflow-${name}-${process.pid}-${Date.now()}`)
|
|
554
|
+
let destination = join(this.sharedSkillsDir, name)
|
|
555
|
+
let inLibrary = false
|
|
556
|
+
let moved = false
|
|
557
|
+
let previous = null
|
|
558
|
+
let phase = "stage"
|
|
559
|
+
try {
|
|
560
|
+
await copyTree(sourceDir, staged)
|
|
561
|
+
phase = "verify"
|
|
562
|
+
const verified = await packageFilesFromDirectory(staged)
|
|
563
|
+
if (manifestHash && await hashPackageFiles(verified) !== manifestHash) throw new Error("Staged skill does not match the verified package")
|
|
564
|
+
phase = "host"
|
|
565
|
+
if (!this.available) await this.initialize()
|
|
566
|
+
if (!this.available) throw new Error(this.lastError || "Magpie CLI is unavailable")
|
|
567
|
+
phase = "library"
|
|
568
|
+
const view = await this.library()
|
|
569
|
+
const libraryPath = join(await this.ensureLibraryDirectory(view.libraryDir), "skills", name)
|
|
570
|
+
phase = "conflict"
|
|
571
|
+
const exists = async path => {
|
|
572
|
+
try { await lstat(path); return true } catch (error) { if (error?.code === "ENOENT") return false; throw error }
|
|
573
|
+
}
|
|
574
|
+
if (!replaceExisting && (view.skills.some(item => item.name.toLowerCase() === name.toLowerCase()) || await exists(libraryPath) || await exists(destination))) {
|
|
575
|
+
throw new Error("Skill name is already in use")
|
|
576
|
+
}
|
|
577
|
+
// A handed-over skill lives in Library, not the shared staging
|
|
578
|
+
// directory. Update its files atomically without replacing its Library
|
|
579
|
+
// registration (agents, routed/direct and off-here choices belong to users).
|
|
580
|
+
if (replaceExisting && await exists(libraryPath)) {
|
|
581
|
+
const info = await lstat(libraryPath)
|
|
582
|
+
if (!info.isSymbolicLink()) {
|
|
583
|
+
if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid())) throw new Error("Invalid owned Library skill directory")
|
|
584
|
+
const next = join(dirname(libraryPath), `.novaflow-${name}-${process.pid}-${Date.now()}`)
|
|
585
|
+
await copyTree(staged, next)
|
|
586
|
+
await rm(staged, { recursive: true, force: true })
|
|
587
|
+
staged = next
|
|
588
|
+
destination = libraryPath
|
|
589
|
+
inLibrary = true
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
phase = "stage"
|
|
593
|
+
check()
|
|
594
|
+
try {
|
|
595
|
+
await stat(destination)
|
|
596
|
+
if (previousHash && await hashPackageFiles(await packageFilesFromDirectory(destination)) !== previousHash) throw new Error("技能有本地修改,已保留")
|
|
597
|
+
check()
|
|
598
|
+
previous = destination + `.novaflow-previous-${this.now().toISOString().replace(/[:.]/g, "-")}`
|
|
599
|
+
await rename(destination, previous)
|
|
600
|
+
} catch (error) {
|
|
601
|
+
if (error?.code !== "ENOENT") throw error
|
|
602
|
+
}
|
|
603
|
+
await rename(staged, destination)
|
|
604
|
+
moved = true
|
|
605
|
+
phase = "handover"
|
|
606
|
+
if (!inLibrary) await this.run(["library", "skill", "hand-over", name], { timeout: 60_000 })
|
|
607
|
+
if (targetAgents.length) {
|
|
608
|
+
await this.run(["library", "skill", "agents", name, targetAgents.join(",")], { timeout: 60_000 })
|
|
609
|
+
}
|
|
610
|
+
phase = "sync"
|
|
611
|
+
await this.run(["library", "sync"], { timeout: 60_000 })
|
|
612
|
+
phase = "confirm"
|
|
613
|
+
const listed = await this.listSkills()
|
|
614
|
+
const registered = listed.skills.some((item) => item.name === name)
|
|
615
|
+
if (!registered) throw new Error("Magpie Library did not report the registered alias")
|
|
616
|
+
if (await hashPackageFiles(await packageFilesFromDirectory(libraryPath)) !== await hashPackageFiles(verified)) throw new Error("Magpie Library skill files do not match the verified package")
|
|
617
|
+
if (previous) await rm(previous, { recursive: true, force: true })
|
|
618
|
+
return { downloaded: true, registered, agents: registered ? targetAgents : [], available: false }
|
|
619
|
+
} catch (error) {
|
|
620
|
+
if (moved && !previous) await rm(destination, { recursive: true, force: true })
|
|
621
|
+
if (previous) {
|
|
622
|
+
if (moved) await rm(destination, { recursive: true, force: true }).catch(() => {})
|
|
623
|
+
await rename(previous, destination).catch(() => {})
|
|
624
|
+
}
|
|
625
|
+
const messages = {
|
|
626
|
+
stage: "无法准备技能文件,请检查本机技能目录的写入权限和磁盘空间",
|
|
627
|
+
verify: "技能复制后校验未通过,请重新下载安装",
|
|
628
|
+
host: "Magpie 资料库命令不可用,请确认客户端安装完整",
|
|
629
|
+
library: "Magpie 资料库目录不可用,请检查目录位置、权限和磁盘空间后重试",
|
|
630
|
+
conflict: "本机已有同名技能,请先在 Magpie 资料库处理同名项后重试;原技能未被覆盖",
|
|
631
|
+
handover: "Magpie 接管技能失败,请检查资料库状态后重试",
|
|
632
|
+
sync: "技能已接管,但 Magpie 资料库同步失败,请重试安装",
|
|
633
|
+
confirm: "Magpie 资料库尚未返回该技能的登记记录,请刷新后重试",
|
|
634
|
+
}
|
|
635
|
+
throw Object.assign(new Error(messages[phase], { cause: error }), { code: `HOST_SKILL_${phase.toUpperCase()}_FAILED`, libraryNameOwned: moved })
|
|
636
|
+
} finally {
|
|
637
|
+
await rm(staged, { recursive: true, force: true }).catch(() => {})
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
async removeSkill(name) {
|
|
642
|
+
if (!ALIAS_RE.test(name)) throw new Error("Invalid managed skill alias")
|
|
643
|
+
const listed = await this.listSkills()
|
|
644
|
+
if (!listed.skills.some((item) => item.name === name)) return { registered: false }
|
|
645
|
+
if (!this.available) await this.initialize()
|
|
646
|
+
if (!this.available) throw new Error(this.lastError || "Magpie CLI is unavailable")
|
|
647
|
+
await this.run(["library", "skill", "rm", name], { timeout: 60_000 })
|
|
648
|
+
const after = await this.listSkills()
|
|
649
|
+
return { registered: after.skills.some((item) => item.name === name) }
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export class UnsupportedHostSettingsAdapter {
|
|
654
|
+
constructor() {
|
|
655
|
+
this.name = "unsupported"
|
|
656
|
+
this.capability = "global-settings"
|
|
657
|
+
this.available = false
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
async read() {
|
|
661
|
+
throw Object.assign(new Error("Magpie does not expose a supported global settings field to plugins"), { code: "HOST_SETTINGS_UNSUPPORTED" })
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async write() {
|
|
665
|
+
throw Object.assign(new Error("Magpie does not expose a supported global settings field to plugins"), { code: "HOST_SETTINGS_UNSUPPORTED" })
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async function packageFilesFromDirectory(root) {
|
|
670
|
+
const out = []
|
|
671
|
+
async function walk(directory, prefix) {
|
|
672
|
+
const entries = await readdir(directory, { withFileTypes: true })
|
|
673
|
+
entries.sort((a, b) => a.name.localeCompare(b.name))
|
|
674
|
+
for (const entry of entries) {
|
|
675
|
+
const path = prefix ? `${prefix}/${entry.name}` : entry.name
|
|
676
|
+
const absolute = join(directory, entry.name)
|
|
677
|
+
if (entry.isSymbolicLink()) throw new Error("Package contains a symbolic link")
|
|
678
|
+
if (entry.isDirectory()) await walk(absolute, path)
|
|
679
|
+
else if (entry.isFile()) out.push({ path, bytes: await readFile(absolute) })
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
await walk(root, "")
|
|
683
|
+
return out.sort((a, b) => a.path.localeCompare(b.path))
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
async function copyTree(source, target) {
|
|
687
|
+
await mkdir(target, { recursive: true, mode: 0o700 })
|
|
688
|
+
await chmod(target, 0o700)
|
|
689
|
+
const entries = await readdir(source, { withFileTypes: true })
|
|
690
|
+
entries.sort((a, b) => a.name.localeCompare(b.name))
|
|
691
|
+
for (const entry of entries) {
|
|
692
|
+
const from = join(source, entry.name)
|
|
693
|
+
const to = join(target, entry.name)
|
|
694
|
+
const info = await lstat(from)
|
|
695
|
+
if (info.isSymbolicLink()) throw new Error("Package contains a symbolic link")
|
|
696
|
+
if (info.isDirectory()) await copyTree(from, to)
|
|
697
|
+
else if (info.isFile()) {
|
|
698
|
+
await writeFile(to, await readFile(from), { mode: 0o600 })
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
async function hashPackageFiles(files) {
|
|
704
|
+
return hashSkillManifest(manifestFor(files))
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export { ALIAS_RE, LIBRARY_SKILL_RE, parseLibraryView, runChild }
|