@keystrokehq/cli 0.0.123 → 0.0.125
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/{discovery-XqwkB9H_-CQLSzR72.mjs → discovery-XqwkB9H_-C2XdYbG2.mjs} +5 -2
- package/dist/{discovery-XqwkB9H_-CQLSzR72.mjs.map → discovery-XqwkB9H_-C2XdYbG2.mjs.map} +1 -1
- package/dist/{dist-IKyaKHgU.mjs → dist-uZuvgIVp.mjs} +2 -2
- package/dist/{dist-IKyaKHgU.mjs.map → dist-uZuvgIVp.mjs.map} +1 -1
- package/dist/index.mjs +78 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as array, d as object, p as string, t as entryIdFromFile } from "./discovery-XqwkB9H_-
|
|
2
|
+
import { a as array, d as object, p as string, t as entryIdFromFile } from "./discovery-XqwkB9H_-C2XdYbG2.mjs";
|
|
3
3
|
import { isBuiltin } from "node:module";
|
|
4
4
|
import { basename, join, relative } from "node:path";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -294,4 +294,4 @@ async function watchApp(options = {}) {
|
|
|
294
294
|
//#endregion
|
|
295
295
|
export { buildApp, resolveRuntimeBuildArtifact, watchApp };
|
|
296
296
|
|
|
297
|
-
//# sourceMappingURL=dist-
|
|
297
|
+
//# sourceMappingURL=dist-uZuvgIVp.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist-IKyaKHgU.mjs","names":["z.object","z.string","z.array"],"sources":["../../../packages/sandbox/dist/files-B0H9_dP4.mjs","../../../packages/tsdown-config/deps.js","../../../packages/tsdown-config/index.js","../../../packages/build/dist/index.mjs"],"sourcesContent":["import { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { z } from \"zod\";\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/sandbox-dirs.ts\nfunction resolveSandboxRoot(workspacesRoot, scope) {\n\tif (scope.type === \"agent\") return join(workspacesRoot, scope.agentId);\n\treturn join(workspacesRoot, \"runs\", scope.runId);\n}\nasync function ensureWorkspaceDir(workspaceRoot) {\n\tawait mkdir(workspaceRoot, { recursive: true });\n}\n//#endregion\n//#region src/files/schemas.ts\nconst SandboxFileContentSchema = z.object({\n\tpath: z.string(),\n\tfile: z.string()\n});\n/** Destination path under `/workspace`. For `dir`, used as a prefix. */\nconst SandboxFileSchema = z.object({\n\tpath: z.string(),\n\t/** Single file body — typically from a build-time import (`import doc from \"./doc.md\"`). */\n\tfile: z.string().optional(),\n\t/** Directory contents — each path is relative to `path`. */\n\tdir: z.array(SandboxFileContentSchema).optional()\n});\nconst SandboxDefinitionSchema = z.object({\n\tkey: z.string().optional(),\n\tfiles: z.array(SandboxFileSchema).optional()\n});\n//#endregion\n//#region src/files/define-sandbox.ts\n/** Define a reusable sandbox file layout. */\nfunction defineSandbox(def) {\n\treturn def;\n}\n//#endregion\n//#region src/files/flatten-sandbox-files.ts\n/** Expand directory entries into flat `{ path, file }` records under `/workspace`. */\nfunction flattenSandboxFiles(files) {\n\tif (!files?.length) return [];\n\tconst flattened = [];\n\tfor (const entry of files) {\n\t\tif (entry.dir !== void 0) {\n\t\t\tconst prefix = entry.path.replace(/\\/+$/, \"\");\n\t\t\tfor (const child of entry.dir) flattened.push({\n\t\t\t\tpath: prefix ? `${prefix}/${child.path}` : child.path,\n\t\t\t\tfile: child.file\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.file === void 0) continue;\n\t\tflattened.push({\n\t\t\tpath: entry.path,\n\t\t\tfile: entry.file\n\t\t});\n\t}\n\treturn flattened;\n}\n//#endregion\n//#region src/files/materialize-sandbox.ts\nasync function materializeSandbox(options) {\n\tconst root = resolveSandboxRoot(options.workspacesRoot, options.scope);\n\tawait ensureWorkspaceDir(root);\n\tconst files = flattenSandboxFiles(options.definition?.files);\n\tif (files.length) await applySandboxFiles(root, files, options.scope);\n\treturn {\n\t\troot,\n\t\tscope: options.scope,\n\t\t...options.definition !== void 0 ? { definition: options.definition } : {}\n\t};\n}\nasync function applySandboxFiles(root, files, scope) {\n\tfor (const entry of files) {\n\t\tconst hostPath = resolve(root, entry.path);\n\t\tif (scope.type === \"agent\") try {\n\t\t\tawait access(hostPath);\n\t\t\tcontinue;\n\t\t} catch {}\n\t\tawait mkdir(dirname(hostPath), { recursive: true });\n\t\tawait writeFile(hostPath, entry.file);\n\t}\n}\n//#endregion\n//#region src/files/pack-dir.ts\nconst SKIP_DIRS$1 = new Set([\".git\", \"node_modules\"]);\n/** Recursively read a host file or directory into sandbox-relative `{ path, file }` entries. */\nfunction packDirFromDisk(rootPath) {\n\tconst stat = statSync(rootPath);\n\tif (stat.isFile()) return [{\n\t\tpath: basename(rootPath),\n\t\tfile: readFileSync(rootPath, \"utf8\")\n\t}];\n\tif (!stat.isDirectory()) throw new Error(`Expected a file or directory at ${rootPath}`);\n\tconst files = [];\n\twalkDir(rootPath, rootPath, files);\n\treturn files;\n}\nfunction walkDir(rootPath, currentPath, files) {\n\tfor (const name of readdirSync(currentPath)) {\n\t\tif (SKIP_DIRS$1.has(name)) continue;\n\t\tconst entryPath = join(currentPath, name);\n\t\tconst stat = statSync(entryPath);\n\t\tif (stat.isDirectory()) {\n\t\t\twalkDir(rootPath, entryPath, files);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) continue;\n\t\tfiles.push({\n\t\t\tpath: relative(rootPath, entryPath),\n\t\t\tfile: readFileSync(entryPath, \"utf8\")\n\t\t});\n\t}\n}\n//#endregion\n//#region src/files/pack-asset-dirs.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\n/** Pack every subdir under `src/skills/` and `src/files/` into an asset manifest. */\nfunction packAssetDirs(appRoot, srcDir = \"src\") {\n\treturn {\n\t\tskills: packAssetRoot(join(appRoot, srcDir, \"skills\")),\n\t\tfiles: packAssetRoot(join(appRoot, srcDir, \"files\"))\n\t};\n}\nfunction packAssetRoot(rootPath) {\n\tif (!statSync(rootPath, { throwIfNoEntry: false })?.isDirectory()) return {};\n\tconst manifest = {};\n\tfor (const name of readdirSync(rootPath)) {\n\t\tif (SKIP_DIRS.has(name)) continue;\n\t\tconst entryPath = join(rootPath, name);\n\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\tmanifest[name] = packDirFromDisk(entryPath);\n\t}\n\treturn manifest;\n}\n//#endregion\n//#region src/files/resolve-app-root.ts\n/** Walk upward from a module file to find the user app root (`src/agents`, `src/skills`, etc.). */\nfunction resolveAppRoot(fromPath) {\n\tlet dir = statSync(fromPath).isDirectory() ? fromPath : dirname(fromPath);\n\twhile (dir !== dirname(dir)) {\n\t\tif (hasAppLayout(dir)) return dir;\n\t\tdir = dirname(dir);\n\t}\n\treturn process.env.KEYSTROKE_ROOT ?? process.cwd();\n}\n/** Resolve app root from an agent (or other) module URL. */\nfunction resolveAppRootFromModule(moduleUrl) {\n\treturn resolveAppRoot(fileURLToPath(moduleUrl));\n}\nfunction hasAppLayout(dir) {\n\tconst src = join(dir, \"src\");\n\tconst dist = join(dir, \"dist\");\n\treturn existsSync(join(src, \"agents\")) || existsSync(join(src, \"skills\")) || existsSync(join(src, \"files\")) || existsSync(join(dist, \"agents\")) || existsSync(join(dist, \".keystroke\", \"assets.mjs\"));\n}\n//#endregion\nexport { materializeSandbox as a, SandboxDefinitionSchema as c, ensureWorkspaceDir as d, resolveSandboxRoot as f, packDirFromDisk as i, SandboxFileContentSchema as l, resolveAppRootFromModule as n, flattenSandboxFiles as o, packAssetDirs as r, defineSandbox as s, resolveAppRoot as t, SandboxFileSchema as u };\n\n//# sourceMappingURL=files-B0H9_dP4.mjs.map","import { isBuiltin } from \"node:module\";\n\n/** Native addons kept external — resolved from the CLI runtime at app start. */\nexport const NATIVE_RUNTIME_DEPS = [\"pg\", \"better-sqlite3\", \"@parcel/watcher\"];\n\n/** Kept external so .d.ts emission does not inline internal/inferred types. */\nexport const LIBRARY_EXTERNAL_DEPS = [\"better-auth\", /^@better-auth\\//, /^better-auth\\//];\n\n/** Non-auth runtime deps kept external for published entry bundles (platform, etc.). */\nexport const BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS = [\n ...NATIVE_RUNTIME_DEPS,\n \"dockerode\",\n \"ssh2\",\n \"cpu-features\",\n \"microsandbox\",\n /^@aws-sdk\\//,\n /^@napi-rs\\//,\n \"hono\",\n /^@hono\\//,\n \"undici\",\n];\n\n/** Kept external when bundling published entry points (cli, keystroke, platform). */\nexport const BUNDLED_ENTRY_EXTERNAL_DEPS = [\n ...BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS,\n ...LIBRARY_EXTERNAL_DEPS,\n];\n\n/** Bundle into CLI — device login uses Better Auth client only. */\nexport const BETTER_AUTH_CLIENT_BUNDLE_PATTERNS = [\n /^better-auth\\/client$/,\n /^better-auth\\/client\\//,\n];\n\n/** Server adapters and root entry — must not ship in the CLI bundle. */\nexport const BETTER_AUTH_SERVER_EXTERNAL_PATTERNS = [\n /^better-auth$/,\n /^@better-auth\\//,\n /^better-auth\\/(?!client(\\/|$)).+/,\n];\n\nexport function isNativeRuntimeDep(id) {\n return NATIVE_RUNTIME_DEPS.some((dep) => id === dep || id.startsWith(`${dep}/`));\n}\n\nfunction packageName(id) {\n if (id.startsWith(\"@\")) {\n const [scope, name] = id.split(\"/\");\n return name ? `${scope}/${name}` : id;\n }\n\n return id.split(\"/\")[0] ?? id;\n}\n\nfunction isRuntimeExternal(id) {\n const name = packageName(id);\n if (isNativeRuntimeDep(name)) {\n return true;\n }\n\n if (name.startsWith(\"@keystrokehq/\")) {\n return true;\n }\n\n if (name === \"better-auth\" || name.startsWith(\"@better-auth/\")) {\n return true;\n }\n\n return false;\n}\n\n/** Library packages resolve npm deps from node_modules at runtime. */\nexport function libraryBuildDepsConfig() {\n return {\n alwaysBundle: (_id) => null,\n neverBundle: [...NATIVE_RUNTIME_DEPS, /^@keystrokehq\\//, ...LIBRARY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/** Bundle npm deps into dist; resolve @keystrokehq/* and natives from the runtime. */\nexport function userAppBuildDepsConfig() {\n return {\n alwaysBundle: (id, _importer) => {\n if (id.startsWith(\".\") || id.startsWith(\"/\") || isBuiltin(id)) {\n return null;\n }\n\n return isRuntimeExternal(id) ? null : true;\n },\n neverBundle: [...NATIVE_RUNTIME_DEPS, /^@keystrokehq\\//, ...LIBRARY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/**\n * Published entry packages (cli, keystroke, platform): declare bundled @keystrokehq/*\n * in dependencies (changesets release graph ignores devDependencies). Inlining is\n * driven by alwaysBundle below, not by dep kind. Runtime npm deps stay external.\n */\nexport function bundledEntryDepsConfig() {\n return {\n alwaysBundle: [/^@keystrokehq\\//],\n neverBundle: [...BUNDLED_ENTRY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/** Published CLI: inline better-auth client + @better-auth/*; keep server adapters external. */\nexport const BETTER_AUTH_CLI_BUNDLE_PATTERNS = [\n ...BETTER_AUTH_CLIENT_BUNDLE_PATTERNS,\n /^@better-auth\\//,\n];\n\nexport const BETTER_AUTH_CLI_EXTERNAL_PATTERNS = [\n /^better-auth$/,\n /^better-auth\\/(?!client(\\/|$)).+/,\n /^@better-auth\\/drizzle-adapter/,\n \"drizzle-orm\",\n];\n\n/** Rolldown/tsdown — native bindings; stay in CLI node_modules at runtime. */\nexport const CLI_BUILD_TOOL_EXTERNAL_PATTERNS = [\"tsdown\", \"rolldown\", /^@rolldown\\//, \"tsx\"];\n\n/** CLI: inline better-auth/client; keep server + drizzle adapters external. */\nexport function cliBundledEntryDepsConfig() {\n return {\n alwaysBundle: [/^@keystrokehq\\//, ...BETTER_AUTH_CLI_BUNDLE_PATTERNS],\n neverBundle: [\n ...BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS,\n ...BETTER_AUTH_CLI_EXTERNAL_PATTERNS,\n ...CLI_BUILD_TOOL_EXTERNAL_PATTERNS,\n ],\n onlyBundle: false,\n };\n}\n","import { bundledEntryDepsConfig, libraryBuildDepsConfig, userAppBuildDepsConfig } from \"./deps.js\";\n\nexport {\n isNativeRuntimeDep,\n NATIVE_RUNTIME_DEPS,\n bundledEntryDepsConfig,\n cliBundledEntryDepsConfig,\n libraryBuildDepsConfig,\n userAppBuildDepsConfig,\n} from \"./deps.js\";\n\nexport const baseTsdownConfig = {\n format: [\"esm\", \"cjs\"],\n dts: true,\n clean: true,\n sourcemap: true,\n target: \"node20\",\n deps: libraryBuildDepsConfig(),\n};\n\n/** tsdown config for published bundles (cli, keystroke, platform). */\nexport const bundledEntryTsdownConfig = {\n format: [\"esm\", \"cjs\"],\n dts: true,\n clean: true,\n sourcemap: true,\n target: \"node20\",\n deps: bundledEntryDepsConfig(),\n};\n","import { t as resolveModuleDirs } from \"./resolve-module-dirs-BPHQhRGy.mjs\";\nimport { existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { entryIdFromFile } from \"@keystrokehq/server/discovery\";\nimport { packAssetDirs } from \"@keystrokehq/sandbox/files\";\nimport { baseTsdownConfig, userAppBuildDepsConfig } from \"@keystrokehq/tsdown-config\";\nimport { build, mergeConfig } from \"tsdown\";\n//#region src/resolve-runtime-artifact.ts\nfunction packageRoot(nodeModules, scope, name) {\n\tconst direct = scope ? join(nodeModules, scope, name) : join(nodeModules, name);\n\tif (existsSync(join(direct, \"package.json\"))) return direct;\n\tconst pnpmDir = join(nodeModules, \".pnpm\");\n\tif (!existsSync(pnpmDir)) return null;\n\tfor (const entry of readdirSync(pnpmDir)) {\n\t\tconst candidate = scope ? join(pnpmDir, entry, \"node_modules\", scope, name) : join(pnpmDir, entry, \"node_modules\", name);\n\t\tif (existsSync(join(candidate, \"package.json\"))) return candidate;\n\t}\n\treturn null;\n}\n/** Resolve a file shipped with `@keystrokehq/build` inside the CLI runtime. */\nfunction resolveRuntimeBuildArtifact(runtimeNodeModules, relativePath) {\n\tconst pkgRoot = packageRoot(runtimeNodeModules, \"@keystrokehq\", \"build\");\n\tif (!pkgRoot) throw new Error(\"Keystroke runtime is missing @keystrokehq/build\");\n\tconst artifact = join(pkgRoot, relativePath);\n\tif (!existsSync(artifact)) throw new Error(`Keystroke runtime artifact not found: ${relativePath}`);\n\treturn artifact;\n}\n//#endregion\n//#region src/vitest-plugin.ts\nconst ASSETS_MODULE$1 = \"@keystrokehq/assets\";\nconst virtualPrefix = `\\0${ASSETS_MODULE$1}:`;\n/** Vitest plugin resolving `@keystrokehq/assets` from disk. */\nfunction agentAssetsVitestPlugin(appRoot = process.cwd()) {\n\tlet manifest = null;\n\treturn {\n\t\tname: \"keystroke-assets\",\n\t\tresolveId(source) {\n\t\t\tif (source !== ASSETS_MODULE$1) return null;\n\t\t\treturn `${virtualPrefix}manifest`;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== `${virtualPrefix}manifest`) return null;\n\t\t\tmanifest ??= packAssetDirs(appRoot);\n\t\t\treturn `export default ${JSON.stringify(manifest)};`;\n\t\t}\n\t};\n}\nfunction findAppRootFromConfig(configFile) {\n\tif (!configFile) return process.cwd();\n\treturn dirname(configFile);\n}\nfunction agentAssetsVitestPluginFromConfig(configFile) {\n\treturn agentAssetsVitestPlugin(findAppRootFromConfig(configFile));\n}\n//#endregion\n//#region src/index.ts\nconst ASSETS_MODULE = \"@keystrokehq/assets\";\nconst VIRTUAL_PREFIX = `\\0${ASSETS_MODULE}:`;\nfunction walkTypeScriptSources(dir) {\n\tif (!existsSync(dir)) return [];\n\tconst files = [];\n\tfor (const name of readdirSync(dir)) {\n\t\tconst path = join(dir, name);\n\t\tif (statSync(path).isDirectory()) files.push(...walkTypeScriptSources(path));\n\t\telse if (/\\.(ts|mts)$/.test(name) && !/\\.(int\\.)?test\\.(ts|mts)$/.test(name)) files.push(path);\n\t}\n\treturn files;\n}\nfunction discoveredEntries(dir, nestedEntry, prefix) {\n\tconst entries = {};\n\tfor (const filePath of walkTypeScriptSources(dir)) {\n\t\tconst id = entryIdFromFile(dir, filePath, { nestedEntry });\n\t\tif (!id) continue;\n\t\tentries[`${prefix}/${id}`] = filePath;\n\t}\n\treturn entries;\n}\nfunction renderAssetModule(manifest) {\n\treturn `export default ${JSON.stringify(manifest)};\\n`;\n}\n/** Rolldown plugin: pack src/skills + src/files and expose `@keystrokehq/assets`. */\nfunction agentAssetsPlugin(options) {\n\tconst srcDir = options.srcDir ?? \"src\";\n\tlet manifest = null;\n\treturn {\n\t\tname: \"keystroke-assets\",\n\t\tbuildStart() {\n\t\t\tmanifest = packAssetDirs(options.root, srcDir);\n\t\t},\n\t\tresolveId(source) {\n\t\t\tif (source !== ASSETS_MODULE) return null;\n\t\t\treturn `${VIRTUAL_PREFIX}manifest`;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== `${VIRTUAL_PREFIX}manifest` || !manifest) return null;\n\t\t\treturn renderAssetModule(manifest);\n\t\t},\n\t\tbuildEnd() {\n\t\t\tif (!manifest) return;\n\t\t\tconst outDir = join(options.root, options.outDir ?? \"dist\", \".keystroke\");\n\t\t\tmkdirSync(outDir, { recursive: true });\n\t\t\twriteFileSync(join(outDir, \"assets.mjs\"), renderAssetModule(manifest));\n\t\t}\n\t};\n}\n/** Full tsdown config for user keystroke apps (config + discovered modules only). */\nfunction createAppBuildConfig(options = {}) {\n\tconst root = options.root ?? process.cwd();\n\tconst srcDir = options.srcDir ?? \"src\";\n\tconst outDir = options.outDir ?? \"dist\";\n\tconst srcRoot = join(root, srcDir);\n\tconst configEntry = existsSync(join(root, \"keystroke.config.ts\")) ? join(root, \"keystroke.config.ts\") : void 0;\n\tconst entries = {\n\t\t...configEntry ? { config: configEntry } : {},\n\t\t...discoveredEntries(join(srcRoot, \"agents\"), \"agent\", \"agents\"),\n\t\t...discoveredEntries(join(srcRoot, \"workflows\"), \"workflow\", \"workflows\"),\n\t\t...discoveredEntries(join(srcRoot, \"triggers\"), \"trigger\", \"triggers\")\n\t};\n\tif (Object.keys(entries).length === 0) throw new Error(\"Nothing to build — add keystroke.config.ts or modules under src/\");\n\treturn mergeConfig(baseTsdownConfig, {\n\t\tentry: entries,\n\t\tformat: [\"esm\"],\n\t\toutDir: join(root, outDir),\n\t\tclean: options.clean ?? true,\n\t\tdts: false,\n\t\tloader: { \".md\": \"text\" },\n\t\tdeps: userAppBuildDepsConfig(),\n\t\tplugins: [agentAssetsPlugin({\n\t\t\troot,\n\t\t\tsrcDir,\n\t\t\toutDir\n\t\t})]\n\t});\n}\n/** Build user agents, workflows, triggers, and config to `dist/`. */\nasync function buildApp(options = {}) {\n\tconst root = options.root ?? process.cwd();\n\tconst previous = process.cwd();\n\ttry {\n\t\tprocess.chdir(root);\n\t\tawait build(createAppBuildConfig({\n\t\t\t...options,\n\t\t\troot\n\t\t}));\n\t} finally {\n\t\tprocess.chdir(previous);\n\t}\n}\n/**\n* Watch `src/` and rebuild `dist/` on change.\n*\n* NOT true hot reload — each change runs a full tsdown rebuild. Callers should\n* restart the API server in `onRebuild` so discovery picks up new/changed modules.\n*/\nasync function watchApp(options = {}) {\n\tconst { runWatchApp } = await import(\"./watch-app-DTIeKrbl.mjs\");\n\tawait runWatchApp(buildApp, options);\n}\n//#endregion\nexport { agentAssetsVitestPlugin, agentAssetsVitestPluginFromConfig, buildApp, createAppBuildConfig, resolveModuleDirs, resolveRuntimeBuildArtifact, watchApp };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;AAeA,MAAM,2BAA2BA,OAAS;CACzC,MAAMC,OAAS;CACf,MAAMA,OAAS;AAChB,CAAC;;AAED,MAAM,oBAAoBD,OAAS;CAClC,MAAMC,OAAS;;CAEf,MAAMA,OAAS,EAAE,SAAS;;CAE1B,KAAKC,MAAQ,wBAAwB,EAAE,SAAS;AACjD,CAAC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ACpC"}
|
|
1
|
+
{"version":3,"file":"dist-uZuvgIVp.mjs","names":["z.object","z.string","z.array"],"sources":["../../../packages/sandbox/dist/files-B0H9_dP4.mjs","../../../packages/tsdown-config/deps.js","../../../packages/tsdown-config/index.js","../../../packages/build/dist/index.mjs"],"sourcesContent":["import { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { z } from \"zod\";\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/sandbox-dirs.ts\nfunction resolveSandboxRoot(workspacesRoot, scope) {\n\tif (scope.type === \"agent\") return join(workspacesRoot, scope.agentId);\n\treturn join(workspacesRoot, \"runs\", scope.runId);\n}\nasync function ensureWorkspaceDir(workspaceRoot) {\n\tawait mkdir(workspaceRoot, { recursive: true });\n}\n//#endregion\n//#region src/files/schemas.ts\nconst SandboxFileContentSchema = z.object({\n\tpath: z.string(),\n\tfile: z.string()\n});\n/** Destination path under `/workspace`. For `dir`, used as a prefix. */\nconst SandboxFileSchema = z.object({\n\tpath: z.string(),\n\t/** Single file body — typically from a build-time import (`import doc from \"./doc.md\"`). */\n\tfile: z.string().optional(),\n\t/** Directory contents — each path is relative to `path`. */\n\tdir: z.array(SandboxFileContentSchema).optional()\n});\nconst SandboxDefinitionSchema = z.object({\n\tkey: z.string().optional(),\n\tfiles: z.array(SandboxFileSchema).optional()\n});\n//#endregion\n//#region src/files/define-sandbox.ts\n/** Define a reusable sandbox file layout. */\nfunction defineSandbox(def) {\n\treturn def;\n}\n//#endregion\n//#region src/files/flatten-sandbox-files.ts\n/** Expand directory entries into flat `{ path, file }` records under `/workspace`. */\nfunction flattenSandboxFiles(files) {\n\tif (!files?.length) return [];\n\tconst flattened = [];\n\tfor (const entry of files) {\n\t\tif (entry.dir !== void 0) {\n\t\t\tconst prefix = entry.path.replace(/\\/+$/, \"\");\n\t\t\tfor (const child of entry.dir) flattened.push({\n\t\t\t\tpath: prefix ? `${prefix}/${child.path}` : child.path,\n\t\t\t\tfile: child.file\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.file === void 0) continue;\n\t\tflattened.push({\n\t\t\tpath: entry.path,\n\t\t\tfile: entry.file\n\t\t});\n\t}\n\treturn flattened;\n}\n//#endregion\n//#region src/files/materialize-sandbox.ts\nasync function materializeSandbox(options) {\n\tconst root = resolveSandboxRoot(options.workspacesRoot, options.scope);\n\tawait ensureWorkspaceDir(root);\n\tconst files = flattenSandboxFiles(options.definition?.files);\n\tif (files.length) await applySandboxFiles(root, files, options.scope);\n\treturn {\n\t\troot,\n\t\tscope: options.scope,\n\t\t...options.definition !== void 0 ? { definition: options.definition } : {}\n\t};\n}\nasync function applySandboxFiles(root, files, scope) {\n\tfor (const entry of files) {\n\t\tconst hostPath = resolve(root, entry.path);\n\t\tif (scope.type === \"agent\") try {\n\t\t\tawait access(hostPath);\n\t\t\tcontinue;\n\t\t} catch {}\n\t\tawait mkdir(dirname(hostPath), { recursive: true });\n\t\tawait writeFile(hostPath, entry.file);\n\t}\n}\n//#endregion\n//#region src/files/pack-dir.ts\nconst SKIP_DIRS$1 = new Set([\".git\", \"node_modules\"]);\n/** Recursively read a host file or directory into sandbox-relative `{ path, file }` entries. */\nfunction packDirFromDisk(rootPath) {\n\tconst stat = statSync(rootPath);\n\tif (stat.isFile()) return [{\n\t\tpath: basename(rootPath),\n\t\tfile: readFileSync(rootPath, \"utf8\")\n\t}];\n\tif (!stat.isDirectory()) throw new Error(`Expected a file or directory at ${rootPath}`);\n\tconst files = [];\n\twalkDir(rootPath, rootPath, files);\n\treturn files;\n}\nfunction walkDir(rootPath, currentPath, files) {\n\tfor (const name of readdirSync(currentPath)) {\n\t\tif (SKIP_DIRS$1.has(name)) continue;\n\t\tconst entryPath = join(currentPath, name);\n\t\tconst stat = statSync(entryPath);\n\t\tif (stat.isDirectory()) {\n\t\t\twalkDir(rootPath, entryPath, files);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) continue;\n\t\tfiles.push({\n\t\t\tpath: relative(rootPath, entryPath),\n\t\t\tfile: readFileSync(entryPath, \"utf8\")\n\t\t});\n\t}\n}\n//#endregion\n//#region src/files/pack-asset-dirs.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\n/** Pack every subdir under `src/skills/` and `src/files/` into an asset manifest. */\nfunction packAssetDirs(appRoot, srcDir = \"src\") {\n\treturn {\n\t\tskills: packAssetRoot(join(appRoot, srcDir, \"skills\")),\n\t\tfiles: packAssetRoot(join(appRoot, srcDir, \"files\"))\n\t};\n}\nfunction packAssetRoot(rootPath) {\n\tif (!statSync(rootPath, { throwIfNoEntry: false })?.isDirectory()) return {};\n\tconst manifest = {};\n\tfor (const name of readdirSync(rootPath)) {\n\t\tif (SKIP_DIRS.has(name)) continue;\n\t\tconst entryPath = join(rootPath, name);\n\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\tmanifest[name] = packDirFromDisk(entryPath);\n\t}\n\treturn manifest;\n}\n//#endregion\n//#region src/files/resolve-app-root.ts\n/** Walk upward from a module file to find the user app root (`src/agents`, `src/skills`, etc.). */\nfunction resolveAppRoot(fromPath) {\n\tlet dir = statSync(fromPath).isDirectory() ? fromPath : dirname(fromPath);\n\twhile (dir !== dirname(dir)) {\n\t\tif (hasAppLayout(dir)) return dir;\n\t\tdir = dirname(dir);\n\t}\n\treturn process.env.KEYSTROKE_ROOT ?? process.cwd();\n}\n/** Resolve app root from an agent (or other) module URL. */\nfunction resolveAppRootFromModule(moduleUrl) {\n\treturn resolveAppRoot(fileURLToPath(moduleUrl));\n}\nfunction hasAppLayout(dir) {\n\tconst src = join(dir, \"src\");\n\tconst dist = join(dir, \"dist\");\n\treturn existsSync(join(src, \"agents\")) || existsSync(join(src, \"skills\")) || existsSync(join(src, \"files\")) || existsSync(join(dist, \"agents\")) || existsSync(join(dist, \".keystroke\", \"assets.mjs\"));\n}\n//#endregion\nexport { materializeSandbox as a, SandboxDefinitionSchema as c, ensureWorkspaceDir as d, resolveSandboxRoot as f, packDirFromDisk as i, SandboxFileContentSchema as l, resolveAppRootFromModule as n, flattenSandboxFiles as o, packAssetDirs as r, defineSandbox as s, resolveAppRoot as t, SandboxFileSchema as u };\n\n//# sourceMappingURL=files-B0H9_dP4.mjs.map","import { isBuiltin } from \"node:module\";\n\n/** Native addons kept external — resolved from the CLI runtime at app start. */\nexport const NATIVE_RUNTIME_DEPS = [\"pg\", \"better-sqlite3\", \"@parcel/watcher\"];\n\n/** Kept external so .d.ts emission does not inline internal/inferred types. */\nexport const LIBRARY_EXTERNAL_DEPS = [\"better-auth\", /^@better-auth\\//, /^better-auth\\//];\n\n/** Non-auth runtime deps kept external for published entry bundles (platform, etc.). */\nexport const BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS = [\n ...NATIVE_RUNTIME_DEPS,\n \"dockerode\",\n \"ssh2\",\n \"cpu-features\",\n \"microsandbox\",\n /^@aws-sdk\\//,\n /^@napi-rs\\//,\n \"hono\",\n /^@hono\\//,\n \"undici\",\n];\n\n/** Kept external when bundling published entry points (cli, keystroke, platform). */\nexport const BUNDLED_ENTRY_EXTERNAL_DEPS = [\n ...BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS,\n ...LIBRARY_EXTERNAL_DEPS,\n];\n\n/** Bundle into CLI — device login uses Better Auth client only. */\nexport const BETTER_AUTH_CLIENT_BUNDLE_PATTERNS = [\n /^better-auth\\/client$/,\n /^better-auth\\/client\\//,\n];\n\n/** Server adapters and root entry — must not ship in the CLI bundle. */\nexport const BETTER_AUTH_SERVER_EXTERNAL_PATTERNS = [\n /^better-auth$/,\n /^@better-auth\\//,\n /^better-auth\\/(?!client(\\/|$)).+/,\n];\n\nexport function isNativeRuntimeDep(id) {\n return NATIVE_RUNTIME_DEPS.some((dep) => id === dep || id.startsWith(`${dep}/`));\n}\n\nfunction packageName(id) {\n if (id.startsWith(\"@\")) {\n const [scope, name] = id.split(\"/\");\n return name ? `${scope}/${name}` : id;\n }\n\n return id.split(\"/\")[0] ?? id;\n}\n\nfunction isRuntimeExternal(id) {\n const name = packageName(id);\n if (isNativeRuntimeDep(name)) {\n return true;\n }\n\n if (name.startsWith(\"@keystrokehq/\")) {\n return true;\n }\n\n if (name === \"better-auth\" || name.startsWith(\"@better-auth/\")) {\n return true;\n }\n\n return false;\n}\n\n/** Library packages resolve npm deps from node_modules at runtime. */\nexport function libraryBuildDepsConfig() {\n return {\n alwaysBundle: (_id) => null,\n neverBundle: [...NATIVE_RUNTIME_DEPS, /^@keystrokehq\\//, ...LIBRARY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/** Bundle npm deps into dist; resolve @keystrokehq/* and natives from the runtime. */\nexport function userAppBuildDepsConfig() {\n return {\n alwaysBundle: (id, _importer) => {\n if (id.startsWith(\".\") || id.startsWith(\"/\") || isBuiltin(id)) {\n return null;\n }\n\n return isRuntimeExternal(id) ? null : true;\n },\n neverBundle: [...NATIVE_RUNTIME_DEPS, /^@keystrokehq\\//, ...LIBRARY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/**\n * Published entry packages (cli, keystroke, platform): declare bundled @keystrokehq/*\n * in dependencies (changesets release graph ignores devDependencies). Inlining is\n * driven by alwaysBundle below, not by dep kind. Runtime npm deps stay external.\n */\nexport function bundledEntryDepsConfig() {\n return {\n alwaysBundle: [/^@keystrokehq\\//],\n neverBundle: [...BUNDLED_ENTRY_EXTERNAL_DEPS],\n onlyBundle: false,\n };\n}\n\n/** Published CLI: inline better-auth client + @better-auth/*; keep server adapters external. */\nexport const BETTER_AUTH_CLI_BUNDLE_PATTERNS = [\n ...BETTER_AUTH_CLIENT_BUNDLE_PATTERNS,\n /^@better-auth\\//,\n];\n\nexport const BETTER_AUTH_CLI_EXTERNAL_PATTERNS = [\n /^better-auth$/,\n /^better-auth\\/(?!client(\\/|$)).+/,\n /^@better-auth\\/drizzle-adapter/,\n \"drizzle-orm\",\n];\n\n/** Rolldown/tsdown — native bindings; stay in CLI node_modules at runtime. */\nexport const CLI_BUILD_TOOL_EXTERNAL_PATTERNS = [\"tsdown\", \"rolldown\", /^@rolldown\\//, \"tsx\"];\n\n/** CLI: inline better-auth/client; keep server + drizzle adapters external. */\nexport function cliBundledEntryDepsConfig() {\n return {\n alwaysBundle: [/^@keystrokehq\\//, ...BETTER_AUTH_CLI_BUNDLE_PATTERNS],\n neverBundle: [\n ...BUNDLED_ENTRY_RUNTIME_EXTERNAL_DEPS,\n ...BETTER_AUTH_CLI_EXTERNAL_PATTERNS,\n ...CLI_BUILD_TOOL_EXTERNAL_PATTERNS,\n ],\n onlyBundle: false,\n };\n}\n","import { bundledEntryDepsConfig, libraryBuildDepsConfig, userAppBuildDepsConfig } from \"./deps.js\";\n\nexport {\n isNativeRuntimeDep,\n NATIVE_RUNTIME_DEPS,\n bundledEntryDepsConfig,\n cliBundledEntryDepsConfig,\n libraryBuildDepsConfig,\n userAppBuildDepsConfig,\n} from \"./deps.js\";\n\nexport const baseTsdownConfig = {\n format: [\"esm\", \"cjs\"],\n dts: true,\n clean: true,\n sourcemap: true,\n target: \"node20\",\n deps: libraryBuildDepsConfig(),\n};\n\n/** tsdown config for published bundles (cli, keystroke, platform). */\nexport const bundledEntryTsdownConfig = {\n format: [\"esm\", \"cjs\"],\n dts: true,\n clean: true,\n sourcemap: true,\n target: \"node20\",\n deps: bundledEntryDepsConfig(),\n};\n","import { t as resolveModuleDirs } from \"./resolve-module-dirs-BPHQhRGy.mjs\";\nimport { existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { entryIdFromFile } from \"@keystrokehq/server/discovery\";\nimport { packAssetDirs } from \"@keystrokehq/sandbox/files\";\nimport { baseTsdownConfig, userAppBuildDepsConfig } from \"@keystrokehq/tsdown-config\";\nimport { build, mergeConfig } from \"tsdown\";\n//#region src/resolve-runtime-artifact.ts\nfunction packageRoot(nodeModules, scope, name) {\n\tconst direct = scope ? join(nodeModules, scope, name) : join(nodeModules, name);\n\tif (existsSync(join(direct, \"package.json\"))) return direct;\n\tconst pnpmDir = join(nodeModules, \".pnpm\");\n\tif (!existsSync(pnpmDir)) return null;\n\tfor (const entry of readdirSync(pnpmDir)) {\n\t\tconst candidate = scope ? join(pnpmDir, entry, \"node_modules\", scope, name) : join(pnpmDir, entry, \"node_modules\", name);\n\t\tif (existsSync(join(candidate, \"package.json\"))) return candidate;\n\t}\n\treturn null;\n}\n/** Resolve a file shipped with `@keystrokehq/build` inside the CLI runtime. */\nfunction resolveRuntimeBuildArtifact(runtimeNodeModules, relativePath) {\n\tconst pkgRoot = packageRoot(runtimeNodeModules, \"@keystrokehq\", \"build\");\n\tif (!pkgRoot) throw new Error(\"Keystroke runtime is missing @keystrokehq/build\");\n\tconst artifact = join(pkgRoot, relativePath);\n\tif (!existsSync(artifact)) throw new Error(`Keystroke runtime artifact not found: ${relativePath}`);\n\treturn artifact;\n}\n//#endregion\n//#region src/vitest-plugin.ts\nconst ASSETS_MODULE$1 = \"@keystrokehq/assets\";\nconst virtualPrefix = `\\0${ASSETS_MODULE$1}:`;\n/** Vitest plugin resolving `@keystrokehq/assets` from disk. */\nfunction agentAssetsVitestPlugin(appRoot = process.cwd()) {\n\tlet manifest = null;\n\treturn {\n\t\tname: \"keystroke-assets\",\n\t\tresolveId(source) {\n\t\t\tif (source !== ASSETS_MODULE$1) return null;\n\t\t\treturn `${virtualPrefix}manifest`;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== `${virtualPrefix}manifest`) return null;\n\t\t\tmanifest ??= packAssetDirs(appRoot);\n\t\t\treturn `export default ${JSON.stringify(manifest)};`;\n\t\t}\n\t};\n}\nfunction findAppRootFromConfig(configFile) {\n\tif (!configFile) return process.cwd();\n\treturn dirname(configFile);\n}\nfunction agentAssetsVitestPluginFromConfig(configFile) {\n\treturn agentAssetsVitestPlugin(findAppRootFromConfig(configFile));\n}\n//#endregion\n//#region src/index.ts\nconst ASSETS_MODULE = \"@keystrokehq/assets\";\nconst VIRTUAL_PREFIX = `\\0${ASSETS_MODULE}:`;\nfunction walkTypeScriptSources(dir) {\n\tif (!existsSync(dir)) return [];\n\tconst files = [];\n\tfor (const name of readdirSync(dir)) {\n\t\tconst path = join(dir, name);\n\t\tif (statSync(path).isDirectory()) files.push(...walkTypeScriptSources(path));\n\t\telse if (/\\.(ts|mts)$/.test(name) && !/\\.(int\\.)?test\\.(ts|mts)$/.test(name)) files.push(path);\n\t}\n\treturn files;\n}\nfunction discoveredEntries(dir, nestedEntry, prefix) {\n\tconst entries = {};\n\tfor (const filePath of walkTypeScriptSources(dir)) {\n\t\tconst id = entryIdFromFile(dir, filePath, { nestedEntry });\n\t\tif (!id) continue;\n\t\tentries[`${prefix}/${id}`] = filePath;\n\t}\n\treturn entries;\n}\nfunction renderAssetModule(manifest) {\n\treturn `export default ${JSON.stringify(manifest)};\\n`;\n}\n/** Rolldown plugin: pack src/skills + src/files and expose `@keystrokehq/assets`. */\nfunction agentAssetsPlugin(options) {\n\tconst srcDir = options.srcDir ?? \"src\";\n\tlet manifest = null;\n\treturn {\n\t\tname: \"keystroke-assets\",\n\t\tbuildStart() {\n\t\t\tmanifest = packAssetDirs(options.root, srcDir);\n\t\t},\n\t\tresolveId(source) {\n\t\t\tif (source !== ASSETS_MODULE) return null;\n\t\t\treturn `${VIRTUAL_PREFIX}manifest`;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== `${VIRTUAL_PREFIX}manifest` || !manifest) return null;\n\t\t\treturn renderAssetModule(manifest);\n\t\t},\n\t\tbuildEnd() {\n\t\t\tif (!manifest) return;\n\t\t\tconst outDir = join(options.root, options.outDir ?? \"dist\", \".keystroke\");\n\t\t\tmkdirSync(outDir, { recursive: true });\n\t\t\twriteFileSync(join(outDir, \"assets.mjs\"), renderAssetModule(manifest));\n\t\t}\n\t};\n}\n/** Full tsdown config for user keystroke apps (config + discovered modules only). */\nfunction createAppBuildConfig(options = {}) {\n\tconst root = options.root ?? process.cwd();\n\tconst srcDir = options.srcDir ?? \"src\";\n\tconst outDir = options.outDir ?? \"dist\";\n\tconst srcRoot = join(root, srcDir);\n\tconst configEntry = existsSync(join(root, \"keystroke.config.ts\")) ? join(root, \"keystroke.config.ts\") : void 0;\n\tconst entries = {\n\t\t...configEntry ? { config: configEntry } : {},\n\t\t...discoveredEntries(join(srcRoot, \"agents\"), \"agent\", \"agents\"),\n\t\t...discoveredEntries(join(srcRoot, \"workflows\"), \"workflow\", \"workflows\"),\n\t\t...discoveredEntries(join(srcRoot, \"triggers\"), \"trigger\", \"triggers\")\n\t};\n\tif (Object.keys(entries).length === 0) throw new Error(\"Nothing to build — add keystroke.config.ts or modules under src/\");\n\treturn mergeConfig(baseTsdownConfig, {\n\t\tentry: entries,\n\t\tformat: [\"esm\"],\n\t\toutDir: join(root, outDir),\n\t\tclean: options.clean ?? true,\n\t\tdts: false,\n\t\tloader: { \".md\": \"text\" },\n\t\tdeps: userAppBuildDepsConfig(),\n\t\tplugins: [agentAssetsPlugin({\n\t\t\troot,\n\t\t\tsrcDir,\n\t\t\toutDir\n\t\t})]\n\t});\n}\n/** Build user agents, workflows, triggers, and config to `dist/`. */\nasync function buildApp(options = {}) {\n\tconst root = options.root ?? process.cwd();\n\tconst previous = process.cwd();\n\ttry {\n\t\tprocess.chdir(root);\n\t\tawait build(createAppBuildConfig({\n\t\t\t...options,\n\t\t\troot\n\t\t}));\n\t} finally {\n\t\tprocess.chdir(previous);\n\t}\n}\n/**\n* Watch `src/` and rebuild `dist/` on change.\n*\n* NOT true hot reload — each change runs a full tsdown rebuild. Callers should\n* restart the API server in `onRebuild` so discovery picks up new/changed modules.\n*/\nasync function watchApp(options = {}) {\n\tconst { runWatchApp } = await import(\"./watch-app-DTIeKrbl.mjs\");\n\tawait runWatchApp(buildApp, options);\n}\n//#endregion\nexport { agentAssetsVitestPlugin, agentAssetsVitestPluginFromConfig, buildApp, createAppBuildConfig, resolveModuleDirs, resolveRuntimeBuildArtifact, watchApp };\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C7B,IAAI;EACH,QAAQ,MAAM,IAAI;EAClB,MAAM,MAAM,qBAAqB;GAChC,GAAG;GACH;EACD,CAAC,CAAC;CACH,UAAU;EACT,QAAQ,MAAM,QAAQ;CACvB;AACD;;;;;;;AAOA,eAAe,SAAS,UAAU,CAAC,GAAG;CACrC,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,MAAM,YAAY,UAAU,OAAO;AACpC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as array, c as discriminatedUnion, d as object, f as record, g as
|
|
2
|
+
import { _ as _coercedNumber, a as array, c as discriminatedUnion, d as object, f as record, g as url, h as unknown, i as _enum, l as literal, m as union, n as ZodNumber, o as boolean, p as string, r as ZodType, s as custom, t as entryIdFromFile, u as number$1 } from "./discovery-XqwkB9H_-C2XdYbG2.mjs";
|
|
3
3
|
import { a as installPlaygroundDependencies, i as installDependencies, n as buildPlaygroundWorkspace, o as resolvePackageManager, s as resolveCliRoot, t as readCliVersion } from "./version-DESgLEkE.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
@@ -2603,6 +2603,16 @@ const ListOrganizationInvitationsResponseSchema = object({ invitations: array(ob
|
|
|
2603
2603
|
})) });
|
|
2604
2604
|
const AcceptOrganizationInvitationResponseSchema = object({ organization: UserOrganizationSchema });
|
|
2605
2605
|
const DeclineOrganizationInvitationResponseSchema = object({ success: literal(true) });
|
|
2606
|
+
/** Custom avatar override; null means fall back to OAuth `users.image`. */
|
|
2607
|
+
const UserAvatarSchema = object({ url: url().nullable() });
|
|
2608
|
+
const UserAvatarPatchSchema = object({
|
|
2609
|
+
/** Storage key returned from presign; null removes the custom override. */
|
|
2610
|
+
storageKey: string().min(1).nullable() });
|
|
2611
|
+
const PresignUserAvatarRequestSchema = object({ contentType: string().trim().min(1) });
|
|
2612
|
+
const PresignUserAvatarResponseSchema = object({
|
|
2613
|
+
uploadUrl: url(),
|
|
2614
|
+
storageKey: string().min(1)
|
|
2615
|
+
});
|
|
2606
2616
|
const ProjectArtifactStatusSchema = _enum(["pending", "ready"]);
|
|
2607
2617
|
const isoDateTime$1 = string().datetime();
|
|
2608
2618
|
const ProjectArtifactSchema = object({
|
|
@@ -5171,8 +5181,8 @@ const DEFAULT_PROJECT_SETTINGS = {
|
|
|
5171
5181
|
defaultRole: "editor",
|
|
5172
5182
|
invitePermission: "admin"
|
|
5173
5183
|
};
|
|
5174
|
-
const MOCK_STORAGE_KEY$
|
|
5175
|
-
function getBrowserLocalStorage$
|
|
5184
|
+
const MOCK_STORAGE_KEY$3 = "keystroke:mock-project-settings:v1";
|
|
5185
|
+
function getBrowserLocalStorage$3() {
|
|
5176
5186
|
if (typeof globalThis !== "object") return null;
|
|
5177
5187
|
return globalThis.localStorage ?? null;
|
|
5178
5188
|
}
|
|
@@ -5198,10 +5208,10 @@ function mergeProjectSettings(current, patch) {
|
|
|
5198
5208
|
});
|
|
5199
5209
|
}
|
|
5200
5210
|
function readSettingsStore() {
|
|
5201
|
-
const localStorage = getBrowserLocalStorage$
|
|
5211
|
+
const localStorage = getBrowserLocalStorage$3();
|
|
5202
5212
|
if (!localStorage) return {};
|
|
5203
5213
|
try {
|
|
5204
|
-
const raw = localStorage.getItem(MOCK_STORAGE_KEY$
|
|
5214
|
+
const raw = localStorage.getItem(MOCK_STORAGE_KEY$3);
|
|
5205
5215
|
if (!raw) return {};
|
|
5206
5216
|
const parsed = JSON.parse(raw);
|
|
5207
5217
|
if (!parsed || typeof parsed !== "object") return {};
|
|
@@ -5211,10 +5221,10 @@ function readSettingsStore() {
|
|
|
5211
5221
|
}
|
|
5212
5222
|
}
|
|
5213
5223
|
function writeSettingsStore(store) {
|
|
5214
|
-
const localStorage = getBrowserLocalStorage$
|
|
5224
|
+
const localStorage = getBrowserLocalStorage$3();
|
|
5215
5225
|
if (!localStorage) return;
|
|
5216
5226
|
try {
|
|
5217
|
-
localStorage.setItem(MOCK_STORAGE_KEY$
|
|
5227
|
+
localStorage.setItem(MOCK_STORAGE_KEY$3, JSON.stringify(store));
|
|
5218
5228
|
} catch {}
|
|
5219
5229
|
}
|
|
5220
5230
|
function requireProjectId(projectId) {
|
|
@@ -7717,8 +7727,8 @@ function createHistoryResource() {
|
|
|
7717
7727
|
}, async (runId) => cancelHistoryRun(runId))
|
|
7718
7728
|
};
|
|
7719
7729
|
}
|
|
7720
|
-
const MOCK_STORAGE_KEY$
|
|
7721
|
-
function getBrowserLocalStorage$
|
|
7730
|
+
const MOCK_STORAGE_KEY$2 = "keystroke:mock-organization-sidebar-branding:v1";
|
|
7731
|
+
function getBrowserLocalStorage$2() {
|
|
7722
7732
|
if (typeof globalThis !== "object") return null;
|
|
7723
7733
|
return globalThis.localStorage ?? null;
|
|
7724
7734
|
}
|
|
@@ -7761,10 +7771,10 @@ function mergeOrganizationSidebarBranding(current, patch) {
|
|
|
7761
7771
|
});
|
|
7762
7772
|
}
|
|
7763
7773
|
function readBrandingStore() {
|
|
7764
|
-
const localStorage = getBrowserLocalStorage$
|
|
7774
|
+
const localStorage = getBrowserLocalStorage$2();
|
|
7765
7775
|
if (!localStorage) return {};
|
|
7766
7776
|
try {
|
|
7767
|
-
const raw = localStorage.getItem(MOCK_STORAGE_KEY$
|
|
7777
|
+
const raw = localStorage.getItem(MOCK_STORAGE_KEY$2);
|
|
7768
7778
|
if (!raw) return {};
|
|
7769
7779
|
const parsed = JSON.parse(raw);
|
|
7770
7780
|
if (!parsed || typeof parsed !== "object") return {};
|
|
@@ -7774,10 +7784,10 @@ function readBrandingStore() {
|
|
|
7774
7784
|
}
|
|
7775
7785
|
}
|
|
7776
7786
|
function writeBrandingStore(store) {
|
|
7777
|
-
const localStorage = getBrowserLocalStorage$
|
|
7787
|
+
const localStorage = getBrowserLocalStorage$2();
|
|
7778
7788
|
if (!localStorage) return;
|
|
7779
7789
|
try {
|
|
7780
|
-
localStorage.setItem(MOCK_STORAGE_KEY$
|
|
7790
|
+
localStorage.setItem(MOCK_STORAGE_KEY$2, JSON.stringify(store));
|
|
7781
7791
|
} catch {}
|
|
7782
7792
|
}
|
|
7783
7793
|
function resolveOrganizationId(getActiveOrganizationId) {
|
|
@@ -7811,8 +7821,8 @@ function createOrganizationSidebarBrandingResource(options) {
|
|
|
7811
7821
|
})
|
|
7812
7822
|
};
|
|
7813
7823
|
}
|
|
7814
|
-
const MOCK_STORAGE_KEY$
|
|
7815
|
-
function getBrowserLocalStorage$
|
|
7824
|
+
const MOCK_STORAGE_KEY$1 = "keystroke:mock-user-preferences:v1";
|
|
7825
|
+
function getBrowserLocalStorage$1() {
|
|
7816
7826
|
if (typeof globalThis !== "object") return null;
|
|
7817
7827
|
return globalThis.localStorage ?? null;
|
|
7818
7828
|
}
|
|
@@ -7920,10 +7930,10 @@ function mergeUserPreferences(current, patch) {
|
|
|
7920
7930
|
});
|
|
7921
7931
|
}
|
|
7922
7932
|
function readPreferencesStore() {
|
|
7923
|
-
const localStorage = getBrowserLocalStorage$
|
|
7933
|
+
const localStorage = getBrowserLocalStorage$1();
|
|
7924
7934
|
if (!localStorage) return {};
|
|
7925
7935
|
try {
|
|
7926
|
-
const raw = localStorage.getItem(MOCK_STORAGE_KEY$
|
|
7936
|
+
const raw = localStorage.getItem(MOCK_STORAGE_KEY$1);
|
|
7927
7937
|
if (!raw) return {};
|
|
7928
7938
|
const parsed = JSON.parse(raw);
|
|
7929
7939
|
if (!parsed || typeof parsed !== "object") return {};
|
|
@@ -7934,13 +7944,13 @@ function readPreferencesStore() {
|
|
|
7934
7944
|
}
|
|
7935
7945
|
}
|
|
7936
7946
|
function writePreferencesStore(store) {
|
|
7937
|
-
const localStorage = getBrowserLocalStorage$
|
|
7947
|
+
const localStorage = getBrowserLocalStorage$1();
|
|
7938
7948
|
if (!localStorage) return;
|
|
7939
7949
|
try {
|
|
7940
|
-
localStorage.setItem(MOCK_STORAGE_KEY$
|
|
7950
|
+
localStorage.setItem(MOCK_STORAGE_KEY$1, JSON.stringify(store));
|
|
7941
7951
|
} catch {}
|
|
7942
7952
|
}
|
|
7943
|
-
function resolveUserId
|
|
7953
|
+
function resolveUserId(getCurrentUserId) {
|
|
7944
7954
|
const userId = getCurrentUserId()?.trim();
|
|
7945
7955
|
if (!userId) throw new Error("User preferences require an authenticated user");
|
|
7946
7956
|
return userId;
|
|
@@ -7952,7 +7962,7 @@ function createUserPreferencesResource(options) {
|
|
|
7952
7962
|
method: "get",
|
|
7953
7963
|
plannedEndpoint: "GET /api/account/preferences"
|
|
7954
7964
|
}, async () => {
|
|
7955
|
-
const userId = resolveUserId
|
|
7965
|
+
const userId = resolveUserId(options.getCurrentUserId ?? (() => null));
|
|
7956
7966
|
return readPreferencesStore()[userId] ?? DEFAULT_USER_PREFERENCES;
|
|
7957
7967
|
}),
|
|
7958
7968
|
update: mock({
|
|
@@ -7960,7 +7970,7 @@ function createUserPreferencesResource(options) {
|
|
|
7960
7970
|
method: "update",
|
|
7961
7971
|
plannedEndpoint: "PATCH /api/account/preferences"
|
|
7962
7972
|
}, async (patch) => {
|
|
7963
|
-
const userId = resolveUserId
|
|
7973
|
+
const userId = resolveUserId(options.getCurrentUserId ?? (() => null));
|
|
7964
7974
|
const store = readPreferencesStore();
|
|
7965
7975
|
const next = mergeUserPreferences(store[userId] ?? DEFAULT_USER_PREFERENCES, patch);
|
|
7966
7976
|
writePreferencesStore({
|
|
@@ -7971,66 +7981,48 @@ function createUserPreferencesResource(options) {
|
|
|
7971
7981
|
})
|
|
7972
7982
|
};
|
|
7973
7983
|
}
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
}
|
|
7980
|
-
function normalizeUserAvatar(value) {
|
|
7981
|
-
if (!value || typeof value !== "object") return DEFAULT_USER_AVATAR;
|
|
7982
|
-
const dataUrl = value.dataUrl;
|
|
7983
|
-
return { dataUrl: typeof dataUrl === "string" && dataUrl.length > 0 ? dataUrl : null };
|
|
7984
|
-
}
|
|
7985
|
-
function readAvatarStore() {
|
|
7986
|
-
const localStorage = getBrowserLocalStorage$1();
|
|
7987
|
-
if (!localStorage) return {};
|
|
7988
|
-
try {
|
|
7989
|
-
const raw = localStorage.getItem(MOCK_STORAGE_KEY$1);
|
|
7990
|
-
if (!raw) return {};
|
|
7991
|
-
const parsed = JSON.parse(raw);
|
|
7992
|
-
if (!parsed || typeof parsed !== "object") return {};
|
|
7993
|
-
return Object.fromEntries(Object.entries(parsed).map(([userId, value]) => [userId, normalizeUserAvatar(value)]));
|
|
7994
|
-
} catch {
|
|
7995
|
-
return {};
|
|
7984
|
+
function createUserAvatarResource(http) {
|
|
7985
|
+
async function presignUpload(contentType) {
|
|
7986
|
+
const body = PresignUserAvatarRequestSchema.parse({ contentType });
|
|
7987
|
+
const data = await http.post("/api/avatar/presign", { json: body }).json();
|
|
7988
|
+
return PresignUserAvatarResponseSchema.parse(data);
|
|
7996
7989
|
}
|
|
7997
|
-
}
|
|
7998
|
-
function writeAvatarStore(store) {
|
|
7999
|
-
const localStorage = getBrowserLocalStorage$1();
|
|
8000
|
-
if (!localStorage) return;
|
|
8001
|
-
try {
|
|
8002
|
-
localStorage.setItem(MOCK_STORAGE_KEY$1, JSON.stringify(store));
|
|
8003
|
-
} catch {}
|
|
8004
|
-
}
|
|
8005
|
-
function resolveUserId(getCurrentUserId) {
|
|
8006
|
-
const userId = getCurrentUserId()?.trim();
|
|
8007
|
-
if (!userId) throw new Error("User avatar requires an authenticated user");
|
|
8008
|
-
return userId;
|
|
8009
|
-
}
|
|
8010
|
-
function createUserAvatarResource(options) {
|
|
8011
7990
|
return {
|
|
8012
|
-
get
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
}
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
7991
|
+
async get() {
|
|
7992
|
+
try {
|
|
7993
|
+
const data = await http.get("/api/avatar").json();
|
|
7994
|
+
return UserAvatarSchema.parse(data);
|
|
7995
|
+
} catch (error) {
|
|
7996
|
+
throw await toPlatformError(error);
|
|
7997
|
+
}
|
|
7998
|
+
},
|
|
7999
|
+
async upload(file) {
|
|
8000
|
+
const contentType = file.type?.trim() || "application/octet-stream";
|
|
8001
|
+
try {
|
|
8002
|
+
const { uploadUrl, storageKey } = await presignUpload(contentType);
|
|
8003
|
+
if (!(await fetch(uploadUrl, {
|
|
8004
|
+
method: "PUT",
|
|
8005
|
+
body: file,
|
|
8006
|
+
headers: { "Content-Type": contentType }
|
|
8007
|
+
})).ok) throw new Error("Avatar upload failed");
|
|
8008
|
+
return await this.update({ storageKey });
|
|
8009
|
+
} catch (error) {
|
|
8010
|
+
if (error instanceof Error && error.message === "Avatar upload failed") throw error;
|
|
8011
|
+
throw await toPlatformError(error);
|
|
8012
|
+
}
|
|
8013
|
+
},
|
|
8014
|
+
async remove() {
|
|
8015
|
+
return this.update({ storageKey: null });
|
|
8016
|
+
},
|
|
8017
|
+
async update(patch) {
|
|
8018
|
+
const body = UserAvatarPatchSchema.parse(patch);
|
|
8019
|
+
try {
|
|
8020
|
+
const data = await http.patch("/api/avatar", { json: body }).json();
|
|
8021
|
+
return UserAvatarSchema.parse(data);
|
|
8022
|
+
} catch (error) {
|
|
8023
|
+
throw await toPlatformError(error);
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
8034
8026
|
};
|
|
8035
8027
|
}
|
|
8036
8028
|
const CHANNEL_PLATFORMS = [
|
|
@@ -8643,7 +8635,7 @@ function createPlatformClient(options) {
|
|
|
8643
8635
|
apiKeys: createApiKeysResource(),
|
|
8644
8636
|
recents: createRecentsResource(),
|
|
8645
8637
|
userPreferences: createUserPreferencesResource({ getCurrentUserId: options.getCurrentUserId }),
|
|
8646
|
-
userAvatar: createUserAvatarResource(
|
|
8638
|
+
userAvatar: createUserAvatarResource(http),
|
|
8647
8639
|
organizationSidebarBranding: createOrganizationSidebarBrandingResource({ getActiveOrganizationId: () => activeOrganizationId }),
|
|
8648
8640
|
getActiveOrganizationId: () => activeOrganizationId,
|
|
8649
8641
|
setActiveOrganizationId
|
|
@@ -9407,7 +9399,7 @@ function registerBuildCommand(program) {
|
|
|
9407
9399
|
program.command("build").description("Build the keystroke project for production").option("--dir <path>", "Project directory", process.cwd()).action(async (options) => {
|
|
9408
9400
|
try {
|
|
9409
9401
|
const root = resolveProjectRoot(options.dir);
|
|
9410
|
-
const { buildApp } = await import("./dist-
|
|
9402
|
+
const { buildApp } = await import("./dist-uZuvgIVp.mjs");
|
|
9411
9403
|
await buildApp({ root });
|
|
9412
9404
|
process.stdout.write(`Built ${root}\n`);
|
|
9413
9405
|
} catch (error) {
|
|
@@ -9599,7 +9591,7 @@ async function runDeploy(options) {
|
|
|
9599
9591
|
const config = createCliConfig();
|
|
9600
9592
|
const client = createCliPlatformClient(config);
|
|
9601
9593
|
if (!options.skipBuild) {
|
|
9602
|
-
const { buildApp } = await import("./dist-
|
|
9594
|
+
const { buildApp } = await import("./dist-uZuvgIVp.mjs");
|
|
9603
9595
|
await buildApp({ root });
|
|
9604
9596
|
}
|
|
9605
9597
|
const archive = packProjectArtifact(root);
|
|
@@ -9697,7 +9689,7 @@ function runtimeChildEnv(parentEnv, overrides) {
|
|
|
9697
9689
|
//#region src/project/bootstrap-run.ts
|
|
9698
9690
|
/** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
|
|
9699
9691
|
async function resolveBootstrapRun(options) {
|
|
9700
|
-
const { resolveRuntimeBuildArtifact } = await import("./dist-
|
|
9692
|
+
const { resolveRuntimeBuildArtifact } = await import("./dist-uZuvgIVp.mjs");
|
|
9701
9693
|
const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
|
|
9702
9694
|
const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/bootstrap.mjs");
|
|
9703
9695
|
const args = [`--import=${loader}`];
|
|
@@ -9847,7 +9839,7 @@ async function runDev(options) {
|
|
|
9847
9839
|
process.on("SIGINT", shutdown);
|
|
9848
9840
|
process.on("SIGTERM", shutdown);
|
|
9849
9841
|
try {
|
|
9850
|
-
const { watchApp } = await import("./dist-
|
|
9842
|
+
const { watchApp } = await import("./dist-uZuvgIVp.mjs");
|
|
9851
9843
|
await watchApp({
|
|
9852
9844
|
root,
|
|
9853
9845
|
clean: false,
|
|
@@ -10269,7 +10261,7 @@ async function runStart(options) {
|
|
|
10269
10261
|
const apiPort = Number(new URL(serverUrl).port || 80);
|
|
10270
10262
|
const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
|
|
10271
10263
|
ensureNativeDeps(runtimeNodeModules);
|
|
10272
|
-
const { buildApp } = await import("./dist-
|
|
10264
|
+
const { buildApp } = await import("./dist-uZuvgIVp.mjs");
|
|
10273
10265
|
await buildApp({
|
|
10274
10266
|
root,
|
|
10275
10267
|
clean: false
|