pi2dsh 0.17.1 → 0.18.0
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/host.d.mts +6 -0
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +1 -1
- package/dist/host.mjs.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +23 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/host.d.mts
CHANGED
|
@@ -8,6 +8,12 @@ interface PiHostPackageSpec {
|
|
|
8
8
|
name: string;
|
|
9
9
|
/** Optional per-package config forwarded to the runtime. */
|
|
10
10
|
config?: UnknownRecord;
|
|
11
|
+
/**
|
|
12
|
+
* Resolution anchor for THIS package (a package.json path). A suite's
|
|
13
|
+
* members are its own dependencies, so under pnpm's isolated layout they
|
|
14
|
+
* resolve from the suite package, not from the profile root.
|
|
15
|
+
*/
|
|
16
|
+
anchor?: string;
|
|
11
17
|
}
|
|
12
18
|
interface PiHostConfig {
|
|
13
19
|
packages: Array<string | PiHostPackageSpec>;
|
package/dist/host.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.mts","names":[],"sources":["../src/host.ts"],"mappings":";;;;KAkBK,gBAAgB;UAEJ;;EAEf;;EAEA,SAAS;;
|
|
1
|
+
{"version":3,"file":"host.d.mts","names":[],"sources":["../src/host.ts"],"mappings":";;;;KAkBK,gBAAgB;UAEJ;;EAEf;;EAEA,SAAS;;;;;;EAMT;;UAGe;EACf,UAAU,eAAe;;EAEzB,2BAA2B;;UAGZ;WACN;WACA,SAAS;WACT,UAAU;WACV,SAAS;;;iBAuBE,qBAAqB,KAAK,oBAAoB,QAAQ;;;;;;iBA8DtD,YAAY,KAAK,SAAS,QAAQ,cAAc,kBAAkB;;iBAOlE,cAAc,QAAQ,cAAc,kBAAkB,QAAQ;;iBAsC9D,oBACpB,KAAK,SACL,mBAAmB,yBACnB,aAAa,eACb;EAAQ;IACP"}
|
package/dist/host.mjs
CHANGED
|
@@ -90,7 +90,7 @@ async function preparePiHost(config, anchor) {
|
|
|
90
90
|
const errors = [];
|
|
91
91
|
const prepared = [];
|
|
92
92
|
for (const spec of normalizeSpecs(config)) try {
|
|
93
|
-
const dir = resolveInstalledDir(anchorPath, spec.name);
|
|
93
|
+
const dir = resolveInstalledDir(spec.anchor ?? anchorPath, spec.name);
|
|
94
94
|
const pkg = await resolvePiPackage(dir);
|
|
95
95
|
try {
|
|
96
96
|
const manifest = await manifestForInstalled(pkg);
|
package/dist/host.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.mjs","names":[],"sources":["../src/host.ts"],"sourcesContent":["// PiHostOnDSH: one DSH plugin that hosts unmodified Pi packages.\n//\n// Pi packages are ordinary npm dependencies of the profile; DSH's plugin\n// manager (pnpm) installs them, and at load time this module resolves each\n// installed package, discovers its Pi entry points, and mounts it through\n// the same package-agnostic runtime. One host, any package — there is\n// deliberately no per-package branching here.\n\nimport { existsSync, readFileSync } from 'node:fs'\nimport { readFile, stat, writeFile, mkdir, cp } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join, relative } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPiPackage, registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\nimport type { GeneratedRuntimeManifest, ResolvedPiPackage } from './types.js'\n\ntype UnknownRecord = Record<string, unknown>\n\nexport interface PiHostPackageSpec {\n /** npm package name as installed in the host bundle's node_modules. */\n name: string\n /** Optional per-package config forwarded to the runtime. */\n config?: UnknownRecord\n}\n\nexport interface PiHostConfig {\n packages: Array<string | PiHostPackageSpec>\n /** Image-admission companions: default automatic; `false` off; explicit map narrows. */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\nexport interface PreparedPiHostPackage {\n readonly name: string\n readonly rootUrl: URL\n readonly manifest: GeneratedRuntimeManifest\n readonly config?: UnknownRecord\n}\n\nfunction parseFrontmatter(text: string): { attributes: Record<string, string>; body: string } {\n const normalized = text.replace(/\\r\\n?/gu, '\\n')\n if (!normalized.startsWith('---')) return { attributes: {}, body: normalized }\n const endIndex = normalized.indexOf('\\n---', 3)\n if (endIndex === -1) return { attributes: {}, body: normalized }\n const attributes: Record<string, string> = {}\n for (const line of normalized.slice(4, endIndex).split('\\n')) {\n const separator = line.indexOf(':')\n if (separator === -1) continue\n const key = line.slice(0, separator).trim()\n let value = line.slice(separator + 1).trim()\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith(\"'\") && value.endsWith(\"'\"))) {\n value = value.slice(1, -1)\n }\n if (key.length > 0) attributes[key] = value\n }\n return { attributes, body: normalized.slice(endIndex + 4).trim() }\n}\n\n/** Build a runtime manifest in place over an installed Pi package directory. */\nexport async function manifestForInstalled(pkg: ResolvedPiPackage): Promise<GeneratedRuntimeManifest> {\n const relativeTo = (file: string): string => relative(pkg.rootDir, file).replaceAll('\\\\', '/')\n\n const skillDirs = new Set<string>()\n for (const file of pkg.resources.skills) {\n // <dir>/<name>/SKILL.md contributes <dir>; a flat <dir>/<name>.md contributes <dir>.\n skillDirs.add(relativeTo(basename(file) === 'SKILL.md' ? dirname(dirname(file)) : dirname(file)))\n }\n\n const prompts: GeneratedRuntimeManifest['prompts'] = []\n const promptNames = new Set<string>()\n for (const source of pkg.resources.prompts) {\n const name = basename(source, '.md').toLowerCase().replace(/[^a-z0-9_-]+/gu, '-')\n if (promptNames.has(name)) throw new Error(`prompt command name collision in ${pkg.identity.name}: ${name}`)\n promptNames.add(name)\n const { attributes, body } = parseFrontmatter(await readFile(source, 'utf8'))\n const firstLine = body.split(/\\r?\\n/u).map(line => line.trim()).find(Boolean)\n prompts.push({\n name,\n description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,\n ...(attributes['argument-hint'] !== undefined ? { argumentHint: attributes['argument-hint'] } : {}),\n path: relativeTo(source),\n })\n }\n\n return {\n schemaVersion: 1,\n package: pkg.identity,\n extensions: pkg.resources.extensions.map(relativeTo),\n skillDirs: [...skillDirs].sort(),\n prompts,\n }\n}\n\nfunction normalizeSpecs(config: PiHostConfig): PiHostPackageSpec[] {\n const packages = Array.isArray(config?.packages) ? config.packages : []\n return packages.map(spec => (typeof spec === 'string' ? { name: spec } : spec))\n .filter(spec => typeof spec?.name === 'string' && spec.name.length > 0)\n}\n\nfunction resolveInstalledDir(anchor: string, packageName: string): string {\n const require = createRequire(anchor)\n try {\n return dirname(require.resolve(`${packageName}/package.json`))\n } catch {\n // Modern strict `exports` maps refuse the package.json subpath, and pure\n // ESM packages (no \"require\" condition) refuse CJS entry resolution too.\n // Locate the installed directory on the filesystem instead: probe every\n // node_modules candidate on the resolution path — no exports involved.\n for (const candidate of require.resolve.paths(packageName) ?? []) {\n const dir = join(candidate, packageName)\n if (existsSync(join(dir, 'package.json'))) return dir\n }\n throw new Error(`cannot locate the installed package directory for ${JSON.stringify(packageName)} near ${JSON.stringify(anchor)}`)\n }\n}\n\n/**\n * Mount every configured Pi package from the host bundle's own node_modules.\n * Packages that fail to mount report their error and do not take down the\n * host or their siblings — matching Pi's own per-extension error isolation.\n */\nexport async function applyPiHost(ctx: Context, config: PiHostConfig, anchor?: string): Promise<void> {\n registerVisionCompanions(ctx, config.visionCompanions)\n const prepared = await preparePiHost(config, anchor)\n await applyPreparedPiHost(ctx, prepared)\n}\n\n/** Resolve installed Pi packages and build immutable manifests without mounting their runtimes. */\nexport async function preparePiHost(config: PiHostConfig, anchor?: string): Promise<PreparedPiHostPackage[]> {\n const anchorPath = anchor ?? fileURLToPath(import.meta.url)\n const errors: Array<{ name: string; error: string }> = []\n const prepared: PreparedPiHostPackage[] = []\n for (const spec of normalizeSpecs(config)) {\n try {\n const dir = resolveInstalledDir(anchorPath, spec.name)\n const pkg = await resolvePiPackage(dir)\n try {\n const manifest = await manifestForInstalled(pkg)\n prepared.push({\n name: spec.name,\n rootUrl: pathToFileURL(`${pkg.rootDir}/`),\n manifest,\n ...(spec.config === undefined ? {} : { config: spec.config }),\n })\n } finally {\n await pkg.dispose()\n }\n } catch (error) {\n errors.push({ name: spec.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n // Console AND logger, the same rule the engine states for its own mount\n // line: a profile's logger level must never be able to hide which packages\n // did not mount. It could, and it did — a package failed to mount and the\n // only symptom was its absence from a list nobody was diffing.\n const message = `[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`\n console.warn(message)\n }\n if (errors.length > 0 && errors.length === normalizeSpecs(config).length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error}`)\n }\n return prepared\n}\n\n/** Mount prepared Pi package runtimes into one exact DSH context. */\nexport async function applyPreparedPiHost(\n ctx: Context,\n prepared: readonly PreparedPiHostPackage[],\n ownerAgent?: UnknownRecord,\n mode: { hostAnchor?: boolean } = {},\n): Promise<void> {\n const errors: Array<{ name: string; error: string }> = []\n for (const pkg of prepared) {\n try {\n // One real Cordis activation per Pi package, owned by this Agent scope.\n // Besides giving teardown the correct owner, dsh-TUI's contribution\n // services bind registration and later use to this activation identity;\n // calling applyPiPackage() naked from the setup event has no live plugin\n // caller and cannot register or open a scene correctly.\n await ctx.plugin(Object.assign(\n async (packageCtx: Context) => {\n await applyPiPackage(packageCtx, {\n rootUrl: pkg.rootUrl,\n manifest: pkg.manifest,\n // The engine/host registers companion routes once on the host\n // before mounting prepared packages. Suppress applyPiPackage's\n // standalone default here so one package cannot undo an explicit\n // host-level `visionCompanions: false` or duplicate the catalog.\n config: { ...(pkg.config ?? {}), visionCompanions: false },\n ...(ownerAgent === undefined ? {} : { ownerAgent }),\n ...(mode.hostAnchor === true ? { hostAnchor: true } : {}),\n })\n },\n { inject: ['tools', 'systemPrompt', 'commands'] },\n ))\n } catch (error) {\n errors.push({ name: pkg.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n const log = (ctx as unknown as { logger?: { warn?(message: string): void } }).logger\n const message = `[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`\n log?.warn?.(message)\n console.warn(message)\n }\n if (errors.length > 0 && errors.length === prepared.length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error}`)\n }\n}\n"],"mappings":";;;;;;;;;AAwCA,SAAS,iBAAiB,MAAoE;CAC5F,MAAM,aAAa,KAAK,QAAQ,WAAW,IAAI;CAC/C,IAAI,CAAC,WAAW,WAAW,KAAK,GAAG,OAAO;EAAE,YAAY,CAAC;EAAG,MAAM;CAAW;CAC7E,MAAM,WAAW,WAAW,QAAQ,SAAS,CAAC;CAC9C,IAAI,aAAa,IAAI,OAAO;EAAE,YAAY,CAAC;EAAG,MAAM;CAAW;CAC/D,MAAM,aAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,WAAW,MAAM,GAAG,QAAQ,CAAC,CAAC,MAAM,IAAI,GAAG;EAC5D,MAAM,YAAY,KAAK,QAAQ,GAAG;EAClC,IAAI,cAAc,IAAI;EACtB,MAAM,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC,KAAK;EAC1C,IAAI,QAAQ,KAAK,MAAM,YAAY,CAAC,CAAC,CAAC,KAAK;EAC3C,IAAK,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG,KAAO,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,GAChG,QAAQ,MAAM,MAAM,GAAG,EAAE;EAE3B,IAAI,IAAI,SAAS,GAAG,WAAW,OAAO;CACxC;CACA,OAAO;EAAE;EAAY,MAAM,WAAW,MAAM,WAAW,CAAC,CAAC,CAAC,KAAK;CAAE;AACnE;;AAGA,eAAsB,qBAAqB,KAA2D;CACpG,MAAM,cAAc,SAAyB,SAAS,IAAI,SAAS,IAAI,CAAC,CAAC,WAAW,MAAM,GAAG;CAE7F,MAAM,4BAAY,IAAI,IAAY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odified Pi packages.\n//\n// Pi packages are ordinary npm dependencies of the profile; DSH's plugin\n// manager (pnpm) installs them, and at load time this module resolves each\n// installed package, discovers its Pi entry points, and mounts it through\n// the same package-agnostic runtime. One host, any package — there is\n// deliberately no per-package branching here.\n\nimport { existsSync, readFileSync } from 'node:fs'\nimport { readFile, stat, writeFile, mkdir, cp } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join, relative } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPiPackage, registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\nimport type { GeneratedRuntimeManifest, ResolvedPiPackage } from './types.js'\n\ntype UnknownRecord = Record<string, unknown>\n\nexport interface PiHostPackageSpec {\n /** npm package name as installed in the host bundle's node_modules. */\n name: string\n /** Optional per-package config forwarded to the runtime. */\n config?: UnknownRecord\n /**\n * Resolution anchor for THIS package (a package.json path). A suite's\n * members are its own dependencies, so under pnpm's isolated layout they\n * resolve from the suite package, not from the profile root.\n */\n anchor?: string\n}\n\nexport interface PiHostConfig {\n packages: Array<string | PiHostPackageSpec>\n /** Image-admission companions: default automatic; `false` off; explicit map narrows. */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\nexport interface PreparedPiHostPackage {\n readonly name: string\n readonly rootUrl: URL\n readonly manifest: GeneratedRuntimeManifest\n readonly config?: UnknownRecord\n}\n\nfunction parseFrontmatter(text: string): { attributes: Record<string, string>; body: string } {\n const normalized = text.replace(/\\r\\n?/gu, '\\n')\n if (!normalized.startsWith('---')) return { attributes: {}, body: normalized }\n const endIndex = normalized.indexOf('\\n---', 3)\n if (endIndex === -1) return { attributes: {}, body: normalized }\n const attributes: Record<string, string> = {}\n for (const line of normalized.slice(4, endIndex).split('\\n')) {\n const separator = line.indexOf(':')\n if (separator === -1) continue\n const key = line.slice(0, separator).trim()\n let value = line.slice(separator + 1).trim()\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith(\"'\") && value.endsWith(\"'\"))) {\n value = value.slice(1, -1)\n }\n if (key.length > 0) attributes[key] = value\n }\n return { attributes, body: normalized.slice(endIndex + 4).trim() }\n}\n\n/** Build a runtime manifest in place over an installed Pi package directory. */\nexport async function manifestForInstalled(pkg: ResolvedPiPackage): Promise<GeneratedRuntimeManifest> {\n const relativeTo = (file: string): string => relative(pkg.rootDir, file).replaceAll('\\\\', '/')\n\n const skillDirs = new Set<string>()\n for (const file of pkg.resources.skills) {\n // <dir>/<name>/SKILL.md contributes <dir>; a flat <dir>/<name>.md contributes <dir>.\n skillDirs.add(relativeTo(basename(file) === 'SKILL.md' ? dirname(dirname(file)) : dirname(file)))\n }\n\n const prompts: GeneratedRuntimeManifest['prompts'] = []\n const promptNames = new Set<string>()\n for (const source of pkg.resources.prompts) {\n const name = basename(source, '.md').toLowerCase().replace(/[^a-z0-9_-]+/gu, '-')\n if (promptNames.has(name)) throw new Error(`prompt command name collision in ${pkg.identity.name}: ${name}`)\n promptNames.add(name)\n const { attributes, body } = parseFrontmatter(await readFile(source, 'utf8'))\n const firstLine = body.split(/\\r?\\n/u).map(line => line.trim()).find(Boolean)\n prompts.push({\n name,\n description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,\n ...(attributes['argument-hint'] !== undefined ? { argumentHint: attributes['argument-hint'] } : {}),\n path: relativeTo(source),\n })\n }\n\n return {\n schemaVersion: 1,\n package: pkg.identity,\n extensions: pkg.resources.extensions.map(relativeTo),\n skillDirs: [...skillDirs].sort(),\n prompts,\n }\n}\n\nfunction normalizeSpecs(config: PiHostConfig): PiHostPackageSpec[] {\n const packages = Array.isArray(config?.packages) ? config.packages : []\n return packages.map(spec => (typeof spec === 'string' ? { name: spec } : spec))\n .filter(spec => typeof spec?.name === 'string' && spec.name.length > 0)\n}\n\nfunction resolveInstalledDir(anchor: string, packageName: string): string {\n const require = createRequire(anchor)\n try {\n return dirname(require.resolve(`${packageName}/package.json`))\n } catch {\n // Modern strict `exports` maps refuse the package.json subpath, and pure\n // ESM packages (no \"require\" condition) refuse CJS entry resolution too.\n // Locate the installed directory on the filesystem instead: probe every\n // node_modules candidate on the resolution path — no exports involved.\n for (const candidate of require.resolve.paths(packageName) ?? []) {\n const dir = join(candidate, packageName)\n if (existsSync(join(dir, 'package.json'))) return dir\n }\n throw new Error(`cannot locate the installed package directory for ${JSON.stringify(packageName)} near ${JSON.stringify(anchor)}`)\n }\n}\n\n/**\n * Mount every configured Pi package from the host bundle's own node_modules.\n * Packages that fail to mount report their error and do not take down the\n * host or their siblings — matching Pi's own per-extension error isolation.\n */\nexport async function applyPiHost(ctx: Context, config: PiHostConfig, anchor?: string): Promise<void> {\n registerVisionCompanions(ctx, config.visionCompanions)\n const prepared = await preparePiHost(config, anchor)\n await applyPreparedPiHost(ctx, prepared)\n}\n\n/** Resolve installed Pi packages and build immutable manifests without mounting their runtimes. */\nexport async function preparePiHost(config: PiHostConfig, anchor?: string): Promise<PreparedPiHostPackage[]> {\n const anchorPath = anchor ?? fileURLToPath(import.meta.url)\n const errors: Array<{ name: string; error: string }> = []\n const prepared: PreparedPiHostPackage[] = []\n for (const spec of normalizeSpecs(config)) {\n try {\n const dir = resolveInstalledDir(spec.anchor ?? anchorPath, spec.name)\n const pkg = await resolvePiPackage(dir)\n try {\n const manifest = await manifestForInstalled(pkg)\n prepared.push({\n name: spec.name,\n rootUrl: pathToFileURL(`${pkg.rootDir}/`),\n manifest,\n ...(spec.config === undefined ? {} : { config: spec.config }),\n })\n } finally {\n await pkg.dispose()\n }\n } catch (error) {\n errors.push({ name: spec.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n // Console AND logger, the same rule the engine states for its own mount\n // line: a profile's logger level must never be able to hide which packages\n // did not mount. It could, and it did — a package failed to mount and the\n // only symptom was its absence from a list nobody was diffing.\n const message = `[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`\n console.warn(message)\n }\n if (errors.length > 0 && errors.length === normalizeSpecs(config).length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error}`)\n }\n return prepared\n}\n\n/** Mount prepared Pi package runtimes into one exact DSH context. */\nexport async function applyPreparedPiHost(\n ctx: Context,\n prepared: readonly PreparedPiHostPackage[],\n ownerAgent?: UnknownRecord,\n mode: { hostAnchor?: boolean } = {},\n): Promise<void> {\n const errors: Array<{ name: string; error: string }> = []\n for (const pkg of prepared) {\n try {\n // One real Cordis activation per Pi package, owned by this Agent scope.\n // Besides giving teardown the correct owner, dsh-TUI's contribution\n // services bind registration and later use to this activation identity;\n // calling applyPiPackage() naked from the setup event has no live plugin\n // caller and cannot register or open a scene correctly.\n await ctx.plugin(Object.assign(\n async (packageCtx: Context) => {\n await applyPiPackage(packageCtx, {\n rootUrl: pkg.rootUrl,\n manifest: pkg.manifest,\n // The engine/host registers companion routes once on the host\n // before mounting prepared packages. Suppress applyPiPackage's\n // standalone default here so one package cannot undo an explicit\n // host-level `visionCompanions: false` or duplicate the catalog.\n config: { ...(pkg.config ?? {}), visionCompanions: false },\n ...(ownerAgent === undefined ? {} : { ownerAgent }),\n ...(mode.hostAnchor === true ? { hostAnchor: true } : {}),\n })\n },\n { inject: ['tools', 'systemPrompt', 'commands'] },\n ))\n } catch (error) {\n errors.push({ name: pkg.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n const log = (ctx as unknown as { logger?: { warn?(message: string): void } }).logger\n const message = `[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`\n log?.warn?.(message)\n console.warn(message)\n }\n if (errors.length > 0 && errors.length === prepared.length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error}`)\n }\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAS,iBAAiB,MAAoE;CAC5F,MAAM,aAAa,KAAK,QAAQ,WAAW,IAAI;CAC/C,IAAI,CAAC,WAAW,WAAW,KAAK,GAAG,OAAO;EAAE,YAAY,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AO,eAAwB;GAC7B,MAAM,eAAe,YAAY;IAC/B,SAAS,IAAI;IACb,UAAU,IAAI;IAKd,QAAQ;KAAE,GAAI,IAAI,UAAU,CAAC;KAAI,kBAAkB;IAAM;IACzD,GAAI,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW;IACjD,GAAI,KAAK,eAAe,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;GACzD,CAAC;EACH,GACA,EAAE,QAAQ;GAAC;GAAS;GAAgB;EAAU,EAAE,CAClD,CAAC;CACH,SAAS,OAAO;EACd,OAAO,KAAK;GAAE,MAAM,IAAI;GAAM,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAAE,CAAC;CAC/F;CAEF,KAAK,MAAM,WAAW,QAAQ;EAC5B,MAAM,MAAO,IAAiE;EAC9E,MAAM,UAAU,iCAAiC,QAAQ,KAAK,IAAI,QAAQ;EAC1E,KAAK,OAAO,OAAO;EACnB,QAAQ,KAAK,OAAO;CACtB;CACA,IAAI,OAAO,SAAS,KAAK,OAAO,WAAW,SAAS,QAClD,MAAM,IAAI,MAAM,mDAAmD,OAAO,EAAE,CAAE,KAAK,IAAI,OAAO,EAAE,CAAE,OAAO;AAE7G"}
|
package/dist/index.d.mts
CHANGED
|
@@ -22,6 +22,10 @@ declare function findProfileRoot(start: string): string | undefined;
|
|
|
22
22
|
interface DiscoveredPackage {
|
|
23
23
|
name: string;
|
|
24
24
|
dir: string;
|
|
25
|
+
/** Resolution anchor when the package is carried by a suite (its members
|
|
26
|
+
* are the suite's dependencies, unreachable from the profile root under
|
|
27
|
+
* pnpm's isolated layout). */
|
|
28
|
+
anchor?: string;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* The profile's direct dependencies that identify as Pi packages: not the
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/engine.ts","../src/compatibility.ts","../src/mcp-config.ts","../src/source.ts","../src/index.ts"],"mappings":";;;;;UA6BiB;;EAEf;;EAEA;;;;;;;;EAQA,2BAA2B;;;iBAIb,gBAAgB;UAUtB;EACR;EACA;;;;;;;;iBAyBoB,0BACpB,qBACA;EAAW;EAAoB,QAAQ;IACtC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/engine.ts","../src/compatibility.ts","../src/mcp-config.ts","../src/source.ts","../src/index.ts"],"mappings":";;;;;UA6BiB;;EAEf;;EAEA;;;;;;;;EAQA,2BAA2B;;;iBAIb,gBAAgB;UAUtB;EACR;EACA;;;;EAIA;;;;;;;;iBAyBoB,0BACpB,qBACA;EAAW;EAAoB,QAAQ;IACtC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsHK,yBACd,KAAK,SACL,kBAAkB,iBAAiB,0BACnC;EAAU,KAAK;;;cAmGJ;cACA;iBAES,MAAM,KAAK,SAAS,SAAQ,eAAoB;;;UCtT5D;EACR,OAAO;EACP;;EAEA;;;;;;;;;UAUQ,oBAAoB;EAC5B;;cAQW;cAKA;cAKA;cAYA,mBAAmB,SAAS,eAAe,SAAS,eAAe;cA+NnE,eAAe,SAAS,eAAe;cA4BvC,kBAAkB,SAAS,eAAe;cA+B1C,WAAW,SAAS,eAAe;cA8InC,aAAa,SAAS,eAAe;iBAgHlC,WAAW,iBAAiB;iBAI5B,aAAa,gBAAgB;iBAO7B,kBAAkB,qBAAqB,uBAAuB;iBAS9D,uBAAuB,mBAAmB;iBAI1C,yBAAyB,mBAAmB;;;KCllBvD,gBAAgB;UAEJ;EACf;EACA;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA,UAAU;EACV;;UAGe;EACf;EACA;;UAGe;EACf,SAAS;EACT,SAAS;EACT,UAAU;EACV;;iBA6Cc,oBAAoB,aAAa;EAA8B,SAAS,YAAY;EAAc;;iBAoElG,mBAAmB,aAAa,wBAA4B;;iBAsD5D,eAAe,QAAQ;;;iBC5EjB,iBAAiB,gBAAgB,eAAsB,QAAQ;;;;;;;;iBChH/D,eAAe,KAAK,oBAAoB,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,19 @@ async function discoverProfilePiPackages(profileRoot, options = {}) {
|
|
|
50
50
|
warn(`[pi2dsh engine] cannot read ${name}/package.json (${error instanceof Error ? error.message : String(error)}); skipping`);
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
+
const suite = packageJson.pi2dsh?.suite;
|
|
54
|
+
if (Array.isArray(suite)) {
|
|
55
|
+
for (const member of suite) {
|
|
56
|
+
if (typeof member !== "string" || member.length === 0) continue;
|
|
57
|
+
if (member === "pi2dsh" || excluded.has(member)) continue;
|
|
58
|
+
discovered.push({
|
|
59
|
+
name: member,
|
|
60
|
+
dir,
|
|
61
|
+
anchor: join(dir, "package.json")
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
53
66
|
if (packageJson.dsh?.bundle !== void 0) continue;
|
|
54
67
|
if (packageJson.pi !== void 0 && typeof packageJson.pi === "object") {
|
|
55
68
|
discovered.push({
|
|
@@ -70,7 +83,12 @@ async function discoverProfilePiPackages(profileRoot, options = {}) {
|
|
|
70
83
|
}
|
|
71
84
|
} catch {}
|
|
72
85
|
}
|
|
73
|
-
|
|
86
|
+
const byName = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const pkg of discovered) {
|
|
88
|
+
const existing = byName.get(pkg.name);
|
|
89
|
+
if (existing === void 0 || existing.anchor !== void 0 && pkg.anchor === void 0) byName.set(pkg.name, pkg);
|
|
90
|
+
}
|
|
91
|
+
return [...byName.values()];
|
|
74
92
|
}
|
|
75
93
|
/**
|
|
76
94
|
* The single mount path on every DSH surface: one Pi runtime per root Agent.
|
|
@@ -217,7 +235,10 @@ async function apply(ctx, config = {}) {
|
|
|
217
235
|
return;
|
|
218
236
|
}
|
|
219
237
|
info(`[pi2dsh engine] preparing ${packages.length} Pi package(s): ${packages.map((pkg) => pkg.name).join(", ")}`);
|
|
220
|
-
const prepared = await preparePiHost({ packages: packages.map((pkg) =>
|
|
238
|
+
const prepared = await preparePiHost({ packages: packages.map((pkg) => pkg.anchor === void 0 ? { name: pkg.name } : {
|
|
239
|
+
name: pkg.name,
|
|
240
|
+
anchor: pkg.anchor
|
|
241
|
+
}) }, join(profileRoot, "package.json"));
|
|
221
242
|
await applyPreparedPiHost(ctx, prepared, void 0, { hostAnchor: true });
|
|
222
243
|
resolvePrepared(prepared);
|
|
223
244
|
} catch (error) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/engine.ts","../src/index.ts"],"sourcesContent":["// The pi2dsh engine: ONE installed copy of the bridge that mounts every Pi\n// package the user has added to their DSH profile.\n//\n// dsh plugin --profile p add pi2dsh ← the engine (this plugin)\n// dsh plugin --profile p add @kassing/pi-vision ← plain npm dependency\n// dsh plugin --profile p add pi-vision-tool ← plain npm dependency\n//\n// DSH's plugin manager records only packages that declare `dsh.bundle` as\n// profile layers; everything else stays an ordinary dependency (\"a plain\n// library is fine\"). The engine reads the profile manifest's DIRECT\n// dependencies — every entry there was an explicit `dsh plugin add` — and\n// mounts each package that identifies as a Pi package, all through one\n// bridge instance: one model ledger, one command space, one upgrade unit.\n//\n// Discovery is manifest-driven, never a node_modules scan (the lesson from\n// Prettier 3 dropping directory-based plugin discovery): the dependency list\n// is the user's explicit intent, and package identification uses the same\n// Pi markers `resolvePiPackage` has always used (the `pi` manifest field,\n// with Pi's directory conventions as fallback).\n\nimport { readFile } from 'node:fs/promises'\nimport { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPreparedPiHost, preparePiHost, type PreparedPiHostPackage } from './host.js'\nimport { registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\n\nexport interface EngineConfig {\n /** Mount exactly these packages (skips discovery). */\n packages?: string[]\n /** Never mount these packages even when discovered. */\n exclude?: string[]\n /**\n * Image-admission companion routes. Default: AUTOMATIC — every text-only\n * llm route gets a \\`<route>-vision\\` companion that admits pasted images\n * (a mounted vision extension analyzes them; without one the image is\n * materialized to a file any image-capable tool can read). \\`false\\`\n * turns companions off; an explicit \\`{ <route>: [modelIds] }\\` narrows.\n */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\n/** Locate the DSH profile root: the nearest ancestor holding cordis.yml. */\nexport function findProfileRoot(start: string): string | undefined {\n let dir = start\n for (;;) {\n if (existsSync(join(dir, 'cordis.yml')) && existsSync(join(dir, 'package.json'))) return dir\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\ninterface DiscoveredPackage {\n name: string\n dir: string\n}\n\ninterface ProfileManifest {\n dependencies?: Record<string, string>\n dsh?: { profile?: { bundles?: string[] } }\n}\n\nasync function readProfileManifest(profileRoot: string): Promise<ProfileManifest> {\n return JSON.parse(await readFile(join(profileRoot, 'package.json'), 'utf8')) as ProfileManifest\n}\n\nfunction resolveDependencyDir(profileRoot: string, name: string): string | undefined {\n // Direct dependencies of the profile live under its node_modules by name\n // (pnpm links them there); resolving by path needs no exports gymnastics.\n const dir = join(profileRoot, 'node_modules', name)\n return existsSync(join(dir, 'package.json')) ? dir : undefined\n}\n\n/**\n * The profile's direct dependencies that identify as Pi packages: not the\n * engine itself, not a `dsh.bundle` (those are DSH plugins, not Pi\n * packages), carrying either Pi's `pi` manifest field or extension sources\n * under Pi's directory conventions.\n */\nexport async function discoverProfilePiPackages(\n profileRoot: string,\n options: { exclude?: string[], warn?: (message: string) => void } = {},\n): Promise<DiscoveredPackage[]> {\n const warn = options.warn ?? (() => {})\n const excluded = new Set(options.exclude ?? [])\n const manifest = await readProfileManifest(profileRoot)\n const discovered: DiscoveredPackage[] = []\n for (const name of Object.keys(manifest.dependencies ?? {})) {\n if (name === 'pi2dsh' || excluded.has(name)) continue\n const dir = resolveDependencyDir(profileRoot, name)\n if (dir === undefined) {\n warn(`[pi2dsh engine] dependency ${JSON.stringify(name)} is not installed under the profile; skipping`)\n continue\n }\n let packageJson: Record<string, unknown>\n try {\n packageJson = JSON.parse(await readFile(join(dir, 'package.json'), 'utf8')) as Record<string, unknown>\n } catch (error) {\n warn(`[pi2dsh engine] cannot read ${name}/package.json (${error instanceof Error ? error.message : String(error)}); skipping`)\n continue\n }\n // A dsh.bundle-declaring package is a DSH plugin layer, never a Pi package.\n if ((packageJson.dsh as { bundle?: unknown } | undefined)?.bundle !== undefined) continue\n if (packageJson.pi !== undefined && typeof packageJson.pi === 'object') {\n discovered.push({ name, dir })\n continue\n }\n // No `pi` field: fall back to Pi's directory conventions via the same\n // resolver every other mount path uses (a package with zero extension\n // sources is a plain library and stays unmounted).\n try {\n const pkg = await resolvePiPackage(dir)\n try {\n if (pkg.resources.extensions.length > 0) discovered.push({ name, dir })\n } finally {\n await pkg.dispose()\n }\n } catch {\n // Not resolvable as a Pi package — a plain library.\n }\n }\n return discovered\n}\n\ninterface AgentScopedMount {\n ready: Promise<void>\n /** Set when the mount failed; the agent then runs as a plain DSH agent. */\n failure?: string\n}\n\n/** The loose shapes of the official DSH seams this file consumes. */\ninterface AgentLike {\n ctx: Context\n}\ninterface EngineHostContext {\n /** Un-injected reflection access (the ctx.get('loader') idiom): the engine\n * must not hard-depend on the agent registry — compositions without one\n * (bare test hosts) simply have no agents to mount for. */\n get?(name: string): unknown\n tools?: { schemas?(scope: unknown): Array<{ name: string }> }\n on(name: string, listener: (...args: never[]) => unknown): () => void\n}\ninterface AgentRegistryLike {\n roots?(): AgentLike[]\n}\n\n/**\n * The single mount path on every DSH surface: one Pi runtime per root Agent.\n *\n * Pi instantiates its extensions once per session; DSH's twin of that scope is\n * the Agent with its public `agent.ctx` (\"contributions are agent-local,\n * unwind on disposal\"). Mounting is driven purely by official core seams, so\n * the same semantics hold on the TUI, web, headless, ACP and config-declared\n * agents alike:\n *\n * - `agent/created` fires on every publication path before the loop can run\n * a first turn; it eagerly starts that agent's mount.\n * - `system-prompt/assemble` (awaited waterfall, runs in every step's\n * preStep) gates the assembly on the mount and patches the pre-waterfall\n * tools snapshot from the official scoped projection `tools.schemas()` —\n * stock DSH collects `assembly.tools` before dispatching the waterfall,\n * so a mount that lands during the wait would otherwise miss turn one.\n * - `tools/pre-execute` (awaited waterfall) closes the same window for\n * direct executions that bypass assembly.\n *\n * `agent/session-start` deliberately is NOT the trigger: DSH documents it as a\n * veto-less notification that cannot gate startup. The waterfalls above are\n * the officially awaited seams, and the exact pattern of registering onto a\n * foreign agent's ctx from a lifecycle event is what DSH's own schedule\n * plugin ships.\n *\n * A mount failure never takes the Agent down: the agent keeps running as a\n * plain DSH agent, the failure is reported loudly once, and only the Pi\n * packages are missing — the capability-gap discipline, not a rollback.\n */\nexport function installAgentScopedMounts(\n ctx: Context,\n preparedPackages: Promise<readonly PreparedPiHostPackage[]>,\n report: { warn(message: string): void },\n): void {\n const host = ctx as unknown as EngineHostContext\n const mounts = new WeakMap<object, AgentScopedMount>()\n\n const registry = (): AgentRegistryLike | undefined => {\n try {\n return host.get?.('agents') as AgentRegistryLike | undefined\n } catch {\n return undefined\n }\n }\n\n const isRootAgent = (agent: object): boolean => {\n // Subagents keep Pi's own sub-session semantics through the session\n // bridge; only runtime roots receive a Pi runtime (the same distinction\n // DSH's schedule plugin draws via agents.roots()).\n const agents = registry()\n const roots = agents?.roots\n if (typeof roots !== 'function') return true\n try {\n return (roots.call(agents) as unknown[]).includes(agent)\n } catch {\n return true\n }\n }\n\n const ensureMount = (agent: AgentLike): AgentScopedMount => {\n let mount = mounts.get(agent)\n if (mount === undefined) {\n const started: AgentScopedMount = { ready: Promise.resolve() }\n started.ready = preparedPackages.then(async prepared => {\n if (prepared.length === 0) return\n try {\n await applyPreparedPiHost(agent.ctx, prepared, agent as unknown as Record<string, unknown>)\n } catch (error) {\n // Loud, once per agent; the gates resolve so the plain DSH agent\n // keeps working. Faking success is forbidden — the message names\n // what is missing.\n started.failure = error instanceof Error ? error.message : String(error)\n report.warn(`[pi2dsh engine] Pi packages failed to mount for this agent; it continues without them: ${started.failure}`)\n }\n })\n mounts.set(agent, started)\n mount = started\n }\n return mount\n }\n\n // Eager start on publication. `agent/created` reaches host-level listeners\n // on every create/resume/config path, before the loop can open a turn.\n host.on('agent/created', ((payload: { agent: AgentLike }) => {\n if (isRootAgent(payload.agent)) ensureMount(payload.agent)\n }) as never)\n\n // Correctness boundary #1: no prompt assembly for a root agent proceeds\n // before its Pi runtime is mounted, and the tools snapshot taken before\n // this waterfall is reconciled against the official scoped projection.\n host.on('system-prompt/assemble', (async (\n assembly: { tools: Array<{ name: string }> },\n context: { agent?: AgentLike },\n next: () => Promise<unknown>,\n ) => {\n const agent = context.agent\n if (agent !== undefined && isRootAgent(agent)) {\n await ensureMount(agent).ready\n const schemas = host.tools?.schemas\n if (typeof schemas === 'function') {\n const present = new Set(assembly.tools.map(tool => tool.name))\n for (const schema of schemas.call(host.tools, agent)) {\n if (!present.has(schema.name)) assembly.tools.push(schema)\n }\n }\n }\n return next()\n }) as never)\n\n // Correctness boundary #2: tool execution for a root agent waits for the\n // same mount (serially awaited by the tool runtime before dispatch).\n host.on('tools/pre-execute', (async (\n exec: { agent?: AgentLike },\n next: () => Promise<unknown>,\n ) => {\n if (exec.agent !== undefined && isRootAgent(exec.agent)) await ensureMount(exec.agent).ready\n return next()\n }) as never)\n\n // Backfill: agents published before this plugin finished loading (a surface\n // that skips the official await-the-loader pattern DSH's headless runner\n // uses). Their next assembly still passes the gates above.\n void preparedPackages.then(() => {\n const agents = registry()\n const roots = agents?.roots\n if (typeof roots !== 'function') return\n for (const agent of roots.call(agents)) ensureMount(agent)\n })\n}\n\n/** Cordis plugin surface: `dsh plugin add pi2dsh` mounts this. */\nexport const name = 'pi2dsh'\nexport const inject = ['tools', 'systemPrompt', 'commands', 'skills']\n\nexport async function apply(ctx: Context, config: EngineConfig = {}): Promise<void> {\n // Same emission as the runtime's logger helper: the cordis logger AND the\n // console — profile logger levels must never hide what the engine mounted.\n const log = (ctx as unknown as { logger?: { info?(m: string): void, warn?(m: string): void } }).logger\n const warn = (message: string): void => { log?.warn?.(message); console.warn(message) }\n const info = (message: string): void => { log?.info?.(message); console.log(message) }\n\n // The loader resolves plugins against the profile's baseUrl; that IS the\n // profile root. The ancestor walk from the installed engine is the\n // fallback for compositions without a loader (tests, hand-built hosts).\n const baseUrl = (ctx as unknown as { baseUrl?: string }).baseUrl\n const profileRoot = (baseUrl !== undefined ? findProfileRoot(fileURLToPath(new URL('.', baseUrl))) : undefined)\n ?? findProfileRoot(dirname(fileURLToPath(import.meta.url)))\n if (profileRoot === undefined) {\n throw new Error('pi2dsh engine: no DSH profile root (cordis.yml + package.json) above the installed engine — is pi2dsh installed via `dsh plugin add pi2dsh`?')\n }\n\n // The single mount path, before any await: gates and lifecycle listeners\n // must exist the moment a surface can publish its first Agent. Package\n // preparation resolves behind this promise; the gates hold each agent's\n // first assembly until its own mount lands.\n let resolvePrepared!: (prepared: readonly PreparedPiHostPackage[]) => void\n const preparedPackages = new Promise<readonly PreparedPiHostPackage[]>(resolve => {\n resolvePrepared = resolve\n })\n installAgentScopedMounts(ctx, preparedPackages, { warn })\n\n registerVisionCompanions(ctx, config.visionCompanions)\n\n try {\n // The host half, mounted exactly once regardless of packages or agents:\n // Pi's built-in provider directory, `/login`, and credential recovery.\n // Without it a fresh engine cannot run `/login openai-codex`: DSH treats\n // the unknown slash line as a model prompt and fails on the unrelated\n // default provider credential. Community packages join the same\n // SharedHostState (keyed on ctx.root), so host-level resources stay\n // single-instance no matter which agent scope mounts them.\n await applyPreparedPiHost(ctx, [{\n name: 'pi2dsh-builtins',\n rootUrl: new URL('.', import.meta.url),\n manifest: {\n schemaVersion: 1,\n package: { name: 'pi2dsh-builtins', version: '0.0.0', source: 'engine' },\n extensions: [],\n skillDirs: [],\n prompts: [],\n },\n }])\n\n const packages = Array.isArray(config.packages) && config.packages.length > 0\n ? config.packages.map(name => ({ name }))\n : await discoverProfilePiPackages(profileRoot, {\n ...(Array.isArray(config.exclude) ? { exclude: config.exclude } : {}),\n warn,\n })\n if (packages.length === 0) {\n info('[pi2dsh engine] no Pi packages installed in this profile yet — add one with: dsh plugin --profile <p> add <pi-package>')\n resolvePrepared([])\n return\n }\n info(`[pi2dsh engine] preparing ${packages.length} Pi package(s): ${packages.map(pkg => pkg.name).join(', ')}`)\n const prepared = await preparePiHost(\n { packages: packages.map(pkg => ({ name: pkg.name })) },\n join(profileRoot, 'package.json'),\n )\n // Host anchors, before the per-Agent gates open: every package's\n // HOST-level contributions (provider routes, OAuth accounts, /login,\n // credential recovery, companions, skills) exist from engine apply — a\n // surface with zero live Agents (web at boot) still advertises them, the\n // first Agent's model resolution finds its routes, and routes survive\n // Agent churn. Anchors serve no Agent; sessions belong to the per-Agent\n // instances the gates mount.\n await applyPreparedPiHost(ctx, prepared, undefined, { hostAnchor: true })\n resolvePrepared(prepared)\n } catch (error) {\n // The gates must never hang on a failed preparation; agents keep running\n // as plain DSH agents while the engine failure propagates loudly.\n resolvePrepared([])\n throw error\n }\n}\n","// Engine surface: `dsh plugin add pi2dsh` resolves this entry as a cordis\n// plugin (named exports, no default — a default export would make the\n// loader discard the function-plugin namespace).\nexport { apply, inject, name, discoverProfilePiPackages, findProfileRoot, installAgentScopedMounts, type EngineConfig } from './engine.js'\n\n// The CLI-only analysis surface loads lazily: its static-analysis dependency\n// (the 23 MB typescript compiler, an optional peer) must never be pulled\n// into a profile that installs the ENGINE. The dynamic import below keeps\n// the analyzer in its own chunk, off the engine's load path.\nimport type { CompatibilityReport, ResolvedPiPackage } from './types.js'\n\n/**\n * Static compatibility analysis of one resolved Pi package (CLI `inspect`).\n * @param pkg - the resolved package.\n * @returns the compatibility report.\n */\nexport async function analyzePackage(pkg: ResolvedPiPackage): Promise<CompatibilityReport> {\n const { analyzePackage: run } = await import('./analyzer.js')\n return run(pkg)\n}\n\nexport {\n API_RULES,\n CONTEXT_RULES,\n EVENT_RULES,\n HOST_IMPORT_RULES,\n PI_AI_PACKAGES,\n PI_CODING_AGENT_PACKAGES,\n PI_TUI_PACKAGES,\n UI_CONTEXT_RULES,\n ruleForApi,\n ruleForContextProperty,\n ruleForEvent,\n ruleForHostImport,\n ruleForUiContextProperty,\n} from './compatibility.js'\nexport { applyPiHost, applyPreparedPiHost, manifestForInstalled, preparePiHost } from './host.js'\nexport { collectPiMcpServers, convertPiMcpConfig, renderMcpPatch } from './mcp-config.js'\nexport { resolvePiPackage } from './source.js'\nexport type * from './types.js'\n"],"mappings":";;;;;;;;;;;AA6CA,SAAgB,gBAAgB,OAAmC;CACjE,IAAI,MAAM;CACV,SAAS;EACP,IAAI,WAAW,KAAK,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,KAAK,cAAc,CAAC,GAAG,OAAO;EACzF,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,KAAA;EAC3B,MAAM;CACR;AACF;AAYA,eAAe,oBAAoB,aAA+C;CAChF,OAAO,KAAK,MAAM,MAAM,SAAS,KAAK,aAAa,cAAc,GAAG,MAAM,CAAC;AAC7E;AAEA,SAAS,qBAAqB,aAAqB,MAAkC;CAGnF,MAAM,MAAM,KAAK,aAAa,gBAAgB,IAAI;CAClD,OAAO,WAAW,KAAK,KAAK,cAAc,CAAC,IAAI,MAAM,KAAA;AACvD;;;;;;;AAQA,eAAsB,0BACpB,aACA,UAAoE,CAAC,GACvC;CAC9B,MAAM,OAAO,QAAQ,eAAe,CAAC;CACrC,MAAM,WAAW,IAAI,IAAI,QAAQ,WAAW,CAAC,CAAC;CAC9C,MAAM,WAAW,MAAM,oBAAoB,WAAW;CACtD,MAAM,aAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,GAAG;EAC3D,IAAI,SAAS,YAAY,SAAS,IAAI,IAAI,GAAG;EAC7C,MAA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ACF,CAAC;EACL,IAAI,SAAS,WAAW,GAAG;GACzB,KAAK,wHAAwH;GAC7H,gBAAgB,CAAC,CAAC;GAClB;EACF;EACA,KAAK,6BAA6B,SAAS,OAAO,kBAAkB,SAAS,KAAI,QAAO,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG;EAC9G,MAAM,WAAW,MAAM,cACrB,EAAE,UAAU,SAAS,KAAI,SAAQ,EAAE,MAAM,IAAI,KAAK,EAAE,EAAE,GACtD,KAAK,aAAa,cAAc,CAClC;EAQA,MAAM,oBAAoB,KAAK,UAAU,KAAA,GAAW,EAAE,YAAY,KAAK,CAAC;EACxE,gBAAgB,QAAQ;CAC1B,SAAS,OAAO;EAGd,gBAAgB,CAAC,CAAC;EAClB,MAAM;CACR;AACF;;;;;;;;AC3VA,eAAsB,eAAe,KAAsD;CACzF,MAAM,EAAE,gBAAgB,QAAQ,MAAM,OAAO;CAC7C,OAAO,IAAI,GAAG;AAChB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/engine.ts","../src/index.ts"],"sourcesContent":["// The pi2dsh engine: ONE installed copy of the bridge that mounts every Pi\n// package the user has added to their DSH profile.\n//\n// dsh plugin --profile p add pi2dsh ← the engine (this plugin)\n// dsh plugin --profile p add @kassing/pi-vision ← plain npm dependency\n// dsh plugin --profile p add pi-vision-tool ← plain npm dependency\n//\n// DSH's plugin manager records only packages that declare `dsh.bundle` as\n// profile layers; everything else stays an ordinary dependency (\"a plain\n// library is fine\"). The engine reads the profile manifest's DIRECT\n// dependencies — every entry there was an explicit `dsh plugin add` — and\n// mounts each package that identifies as a Pi package, all through one\n// bridge instance: one model ledger, one command space, one upgrade unit.\n//\n// Discovery is manifest-driven, never a node_modules scan (the lesson from\n// Prettier 3 dropping directory-based plugin discovery): the dependency list\n// is the user's explicit intent, and package identification uses the same\n// Pi markers `resolvePiPackage` has always used (the `pi` manifest field,\n// with Pi's directory conventions as fallback).\n\nimport { readFile } from 'node:fs/promises'\nimport { existsSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPreparedPiHost, preparePiHost, type PreparedPiHostPackage } from './host.js'\nimport { registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\n\nexport interface EngineConfig {\n /** Mount exactly these packages (skips discovery). */\n packages?: string[]\n /** Never mount these packages even when discovered. */\n exclude?: string[]\n /**\n * Image-admission companion routes. Default: AUTOMATIC — every text-only\n * llm route gets a \\`<route>-vision\\` companion that admits pasted images\n * (a mounted vision extension analyzes them; without one the image is\n * materialized to a file any image-capable tool can read). \\`false\\`\n * turns companions off; an explicit \\`{ <route>: [modelIds] }\\` narrows.\n */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\n/** Locate the DSH profile root: the nearest ancestor holding cordis.yml. */\nexport function findProfileRoot(start: string): string | undefined {\n let dir = start\n for (;;) {\n if (existsSync(join(dir, 'cordis.yml')) && existsSync(join(dir, 'package.json'))) return dir\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\ninterface DiscoveredPackage {\n name: string\n dir: string\n /** Resolution anchor when the package is carried by a suite (its members\n * are the suite's dependencies, unreachable from the profile root under\n * pnpm's isolated layout). */\n anchor?: string\n}\n\ninterface ProfileManifest {\n dependencies?: Record<string, string>\n dsh?: { profile?: { bundles?: string[] } }\n}\n\nasync function readProfileManifest(profileRoot: string): Promise<ProfileManifest> {\n return JSON.parse(await readFile(join(profileRoot, 'package.json'), 'utf8')) as ProfileManifest\n}\n\nfunction resolveDependencyDir(profileRoot: string, name: string): string | undefined {\n // Direct dependencies of the profile live under its node_modules by name\n // (pnpm links them there); resolving by path needs no exports gymnastics.\n const dir = join(profileRoot, 'node_modules', name)\n return existsSync(join(dir, 'package.json')) ? dir : undefined\n}\n\n/**\n * The profile's direct dependencies that identify as Pi packages: not the\n * engine itself, not a `dsh.bundle` (those are DSH plugins, not Pi\n * packages), carrying either Pi's `pi` manifest field or extension sources\n * under Pi's directory conventions.\n */\nexport async function discoverProfilePiPackages(\n profileRoot: string,\n options: { exclude?: string[], warn?: (message: string) => void } = {},\n): Promise<DiscoveredPackage[]> {\n const warn = options.warn ?? (() => {})\n const excluded = new Set(options.exclude ?? [])\n const manifest = await readProfileManifest(profileRoot)\n const discovered: DiscoveredPackage[] = []\n for (const name of Object.keys(manifest.dependencies ?? {})) {\n if (name === 'pi2dsh' || excluded.has(name)) continue\n const dir = resolveDependencyDir(profileRoot, name)\n if (dir === undefined) {\n warn(`[pi2dsh engine] dependency ${JSON.stringify(name)} is not installed under the profile; skipping`)\n continue\n }\n let packageJson: Record<string, unknown>\n try {\n packageJson = JSON.parse(await readFile(join(dir, 'package.json'), 'utf8')) as Record<string, unknown>\n } catch (error) {\n warn(`[pi2dsh engine] cannot read ${name}/package.json (${error instanceof Error ? error.message : String(error)}); skipping`)\n continue\n }\n // A suite: `pi2dsh: { suite: [names...] }` mounts the listed Pi packages\n // as if the user had added each one. The list is an explicit manifest —\n // the same discovery covenant as the profile dependency list, one hop\n // deeper — and the members are the suite's own dependencies, so each\n // resolves anchored at the suite package (pnpm keeps transitive\n // dependencies out of the profile root). One level only, no recursion.\n const suite = (packageJson.pi2dsh as { suite?: unknown } | undefined)?.suite\n if (Array.isArray(suite)) {\n for (const member of suite) {\n if (typeof member !== 'string' || member.length === 0) continue\n if (member === 'pi2dsh' || excluded.has(member)) continue\n discovered.push({ name: member, dir, anchor: join(dir, 'package.json') })\n }\n continue\n }\n // A dsh.bundle-declaring package is a DSH plugin layer, never a Pi package.\n if ((packageJson.dsh as { bundle?: unknown } | undefined)?.bundle !== undefined) continue\n if (packageJson.pi !== undefined && typeof packageJson.pi === 'object') {\n discovered.push({ name, dir })\n continue\n }\n // No `pi` field: fall back to Pi's directory conventions via the same\n // resolver every other mount path uses (a package with zero extension\n // sources is a plain library and stays unmounted).\n try {\n const pkg = await resolvePiPackage(dir)\n try {\n if (pkg.resources.extensions.length > 0) discovered.push({ name, dir })\n } finally {\n await pkg.dispose()\n }\n } catch {\n // Not resolvable as a Pi package — a plain library.\n }\n }\n // One mount per name. A package that is both a direct dependency and a\n // suite member mounts as the DIRECT dependency (the user's own explicit\n // add, resolved from the profile root) — the suite copy yields.\n const byName = new Map<string, DiscoveredPackage>()\n for (const pkg of discovered) {\n const existing = byName.get(pkg.name)\n if (existing === undefined || (existing.anchor !== undefined && pkg.anchor === undefined)) {\n byName.set(pkg.name, pkg)\n }\n }\n return [...byName.values()]\n}\n\ninterface AgentScopedMount {\n ready: Promise<void>\n /** Set when the mount failed; the agent then runs as a plain DSH agent. */\n failure?: string\n}\n\n/** The loose shapes of the official DSH seams this file consumes. */\ninterface AgentLike {\n ctx: Context\n}\ninterface EngineHostContext {\n /** Un-injected reflection access (the ctx.get('loader') idiom): the engine\n * must not hard-depend on the agent registry — compositions without one\n * (bare test hosts) simply have no agents to mount for. */\n get?(name: string): unknown\n tools?: { schemas?(scope: unknown): Array<{ name: string }> }\n on(name: string, listener: (...args: never[]) => unknown): () => void\n}\ninterface AgentRegistryLike {\n roots?(): AgentLike[]\n}\n\n/**\n * The single mount path on every DSH surface: one Pi runtime per root Agent.\n *\n * Pi instantiates its extensions once per session; DSH's twin of that scope is\n * the Agent with its public `agent.ctx` (\"contributions are agent-local,\n * unwind on disposal\"). Mounting is driven purely by official core seams, so\n * the same semantics hold on the TUI, web, headless, ACP and config-declared\n * agents alike:\n *\n * - `agent/created` fires on every publication path before the loop can run\n * a first turn; it eagerly starts that agent's mount.\n * - `system-prompt/assemble` (awaited waterfall, runs in every step's\n * preStep) gates the assembly on the mount and patches the pre-waterfall\n * tools snapshot from the official scoped projection `tools.schemas()` —\n * stock DSH collects `assembly.tools` before dispatching the waterfall,\n * so a mount that lands during the wait would otherwise miss turn one.\n * - `tools/pre-execute` (awaited waterfall) closes the same window for\n * direct executions that bypass assembly.\n *\n * `agent/session-start` deliberately is NOT the trigger: DSH documents it as a\n * veto-less notification that cannot gate startup. The waterfalls above are\n * the officially awaited seams, and the exact pattern of registering onto a\n * foreign agent's ctx from a lifecycle event is what DSH's own schedule\n * plugin ships.\n *\n * A mount failure never takes the Agent down: the agent keeps running as a\n * plain DSH agent, the failure is reported loudly once, and only the Pi\n * packages are missing — the capability-gap discipline, not a rollback.\n */\nexport function installAgentScopedMounts(\n ctx: Context,\n preparedPackages: Promise<readonly PreparedPiHostPackage[]>,\n report: { warn(message: string): void },\n): void {\n const host = ctx as unknown as EngineHostContext\n const mounts = new WeakMap<object, AgentScopedMount>()\n\n const registry = (): AgentRegistryLike | undefined => {\n try {\n return host.get?.('agents') as AgentRegistryLike | undefined\n } catch {\n return undefined\n }\n }\n\n const isRootAgent = (agent: object): boolean => {\n // Subagents keep Pi's own sub-session semantics through the session\n // bridge; only runtime roots receive a Pi runtime (the same distinction\n // DSH's schedule plugin draws via agents.roots()).\n const agents = registry()\n const roots = agents?.roots\n if (typeof roots !== 'function') return true\n try {\n return (roots.call(agents) as unknown[]).includes(agent)\n } catch {\n return true\n }\n }\n\n const ensureMount = (agent: AgentLike): AgentScopedMount => {\n let mount = mounts.get(agent)\n if (mount === undefined) {\n const started: AgentScopedMount = { ready: Promise.resolve() }\n started.ready = preparedPackages.then(async prepared => {\n if (prepared.length === 0) return\n try {\n await applyPreparedPiHost(agent.ctx, prepared, agent as unknown as Record<string, unknown>)\n } catch (error) {\n // Loud, once per agent; the gates resolve so the plain DSH agent\n // keeps working. Faking success is forbidden — the message names\n // what is missing.\n started.failure = error instanceof Error ? error.message : String(error)\n report.warn(`[pi2dsh engine] Pi packages failed to mount for this agent; it continues without them: ${started.failure}`)\n }\n })\n mounts.set(agent, started)\n mount = started\n }\n return mount\n }\n\n // Eager start on publication. `agent/created` reaches host-level listeners\n // on every create/resume/config path, before the loop can open a turn.\n host.on('agent/created', ((payload: { agent: AgentLike }) => {\n if (isRootAgent(payload.agent)) ensureMount(payload.agent)\n }) as never)\n\n // Correctness boundary #1: no prompt assembly for a root agent proceeds\n // before its Pi runtime is mounted, and the tools snapshot taken before\n // this waterfall is reconciled against the official scoped projection.\n host.on('system-prompt/assemble', (async (\n assembly: { tools: Array<{ name: string }> },\n context: { agent?: AgentLike },\n next: () => Promise<unknown>,\n ) => {\n const agent = context.agent\n if (agent !== undefined && isRootAgent(agent)) {\n await ensureMount(agent).ready\n const schemas = host.tools?.schemas\n if (typeof schemas === 'function') {\n const present = new Set(assembly.tools.map(tool => tool.name))\n for (const schema of schemas.call(host.tools, agent)) {\n if (!present.has(schema.name)) assembly.tools.push(schema)\n }\n }\n }\n return next()\n }) as never)\n\n // Correctness boundary #2: tool execution for a root agent waits for the\n // same mount (serially awaited by the tool runtime before dispatch).\n host.on('tools/pre-execute', (async (\n exec: { agent?: AgentLike },\n next: () => Promise<unknown>,\n ) => {\n if (exec.agent !== undefined && isRootAgent(exec.agent)) await ensureMount(exec.agent).ready\n return next()\n }) as never)\n\n // Backfill: agents published before this plugin finished loading (a surface\n // that skips the official await-the-loader pattern DSH's headless runner\n // uses). Their next assembly still passes the gates above.\n void preparedPackages.then(() => {\n const agents = registry()\n const roots = agents?.roots\n if (typeof roots !== 'function') return\n for (const agent of roots.call(agents)) ensureMount(agent)\n })\n}\n\n/** Cordis plugin surface: `dsh plugin add pi2dsh` mounts this. */\nexport const name = 'pi2dsh'\nexport const inject = ['tools', 'systemPrompt', 'commands', 'skills']\n\nexport async function apply(ctx: Context, config: EngineConfig = {}): Promise<void> {\n // Same emission as the runtime's logger helper: the cordis logger AND the\n // console — profile logger levels must never hide what the engine mounted.\n const log = (ctx as unknown as { logger?: { info?(m: string): void, warn?(m: string): void } }).logger\n const warn = (message: string): void => { log?.warn?.(message); console.warn(message) }\n const info = (message: string): void => { log?.info?.(message); console.log(message) }\n\n // The loader resolves plugins against the profile's baseUrl; that IS the\n // profile root. The ancestor walk from the installed engine is the\n // fallback for compositions without a loader (tests, hand-built hosts).\n const baseUrl = (ctx as unknown as { baseUrl?: string }).baseUrl\n const profileRoot = (baseUrl !== undefined ? findProfileRoot(fileURLToPath(new URL('.', baseUrl))) : undefined)\n ?? findProfileRoot(dirname(fileURLToPath(import.meta.url)))\n if (profileRoot === undefined) {\n throw new Error('pi2dsh engine: no DSH profile root (cordis.yml + package.json) above the installed engine — is pi2dsh installed via `dsh plugin add pi2dsh`?')\n }\n\n // The single mount path, before any await: gates and lifecycle listeners\n // must exist the moment a surface can publish its first Agent. Package\n // preparation resolves behind this promise; the gates hold each agent's\n // first assembly until its own mount lands.\n let resolvePrepared!: (prepared: readonly PreparedPiHostPackage[]) => void\n const preparedPackages = new Promise<readonly PreparedPiHostPackage[]>(resolve => {\n resolvePrepared = resolve\n })\n installAgentScopedMounts(ctx, preparedPackages, { warn })\n\n registerVisionCompanions(ctx, config.visionCompanions)\n\n try {\n // The host half, mounted exactly once regardless of packages or agents:\n // Pi's built-in provider directory, `/login`, and credential recovery.\n // Without it a fresh engine cannot run `/login openai-codex`: DSH treats\n // the unknown slash line as a model prompt and fails on the unrelated\n // default provider credential. Community packages join the same\n // SharedHostState (keyed on ctx.root), so host-level resources stay\n // single-instance no matter which agent scope mounts them.\n await applyPreparedPiHost(ctx, [{\n name: 'pi2dsh-builtins',\n rootUrl: new URL('.', import.meta.url),\n manifest: {\n schemaVersion: 1,\n package: { name: 'pi2dsh-builtins', version: '0.0.0', source: 'engine' },\n extensions: [],\n skillDirs: [],\n prompts: [],\n },\n }])\n\n const packages: Array<{ name: string, anchor?: string }> = Array.isArray(config.packages) && config.packages.length > 0\n ? config.packages.map(name => ({ name }))\n : await discoverProfilePiPackages(profileRoot, {\n ...(Array.isArray(config.exclude) ? { exclude: config.exclude } : {}),\n warn,\n })\n if (packages.length === 0) {\n info('[pi2dsh engine] no Pi packages installed in this profile yet — add one with: dsh plugin --profile <p> add <pi-package>')\n resolvePrepared([])\n return\n }\n info(`[pi2dsh engine] preparing ${packages.length} Pi package(s): ${packages.map(pkg => pkg.name).join(', ')}`)\n const prepared = await preparePiHost(\n {\n packages: packages.map(pkg =>\n pkg.anchor === undefined ? { name: pkg.name } : { name: pkg.name, anchor: pkg.anchor }),\n },\n join(profileRoot, 'package.json'),\n )\n // Host anchors, before the per-Agent gates open: every package's\n // HOST-level contributions (provider routes, OAuth accounts, /login,\n // credential recovery, companions, skills) exist from engine apply — a\n // surface with zero live Agents (web at boot) still advertises them, the\n // first Agent's model resolution finds its routes, and routes survive\n // Agent churn. Anchors serve no Agent; sessions belong to the per-Agent\n // instances the gates mount.\n await applyPreparedPiHost(ctx, prepared, undefined, { hostAnchor: true })\n resolvePrepared(prepared)\n } catch (error) {\n // The gates must never hang on a failed preparation; agents keep running\n // as plain DSH agents while the engine failure propagates loudly.\n resolvePrepared([])\n throw error\n }\n}\n","// Engine surface: `dsh plugin add pi2dsh` resolves this entry as a cordis\n// plugin (named exports, no default — a default export would make the\n// loader discard the function-plugin namespace).\nexport { apply, inject, name, discoverProfilePiPackages, findProfileRoot, installAgentScopedMounts, type EngineConfig } from './engine.js'\n\n// The CLI-only analysis surface loads lazily: its static-analysis dependency\n// (the 23 MB typescript compiler, an optional peer) must never be pulled\n// into a profile that installs the ENGINE. The dynamic import below keeps\n// the analyzer in its own chunk, off the engine's load path.\nimport type { CompatibilityReport, ResolvedPiPackage } from './types.js'\n\n/**\n * Static compatibility analysis of one resolved Pi package (CLI `inspect`).\n * @param pkg - the resolved package.\n * @returns the compatibility report.\n */\nexport async function analyzePackage(pkg: ResolvedPiPackage): Promise<CompatibilityReport> {\n const { analyzePackage: run } = await import('./analyzer.js')\n return run(pkg)\n}\n\nexport {\n API_RULES,\n CONTEXT_RULES,\n EVENT_RULES,\n HOST_IMPORT_RULES,\n PI_AI_PACKAGES,\n PI_CODING_AGENT_PACKAGES,\n PI_TUI_PACKAGES,\n UI_CONTEXT_RULES,\n ruleForApi,\n ruleForContextProperty,\n ruleForEvent,\n ruleForHostImport,\n ruleForUiContextProperty,\n} from './compatibility.js'\nexport { applyPiHost, applyPreparedPiHost, manifestForInstalled, preparePiHost } from './host.js'\nexport { collectPiMcpServers, convertPiMcpConfig, renderMcpPatch } from './mcp-config.js'\nexport { resolvePiPackage } from './source.js'\nexport type * from './types.js'\n"],"mappings":";;;;;;;;;;;AA6CA,SAAgB,gBAAgB,OAAmC;CACjE,IAAI,MAAM;CACV,SAAS;EACP,IAAI,WAAW,KAAK,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,KAAK,cAAc,CAAC,GAAG,OAAO;EACzF,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK,OAAO,KAAA;EAC3B,MAAM;CACR;AACF;AAgBA,eAAe,oBAAoB,aAA+C;CAChF,OAAO,KAAK,MAAM,MAAM,SAAS,KAAK,aAAa,cAAc,GAAG,MAAM,CAAC;AAC7E;AAEA,SAAS,qBAAqB,aAAqB,MAAkC;CAGnF,MAAM,MAAM,KAAK,aAAa,gBAAgB,IAAI;CAClD,OAAO,WAAW,KAAK,KAAK,cAAc,CAAC,IAAI,MAAM,KAAA;AACvD;;;;;;;AAQA,eAAsB,0BACpB,aACA,UAAoE,CAAC,GACvC;CAC9B,MAAM,OAAO,QAAQ,eAAe,CAAC;CACrC,MAAM,WAAW,IAAI,IAAI,QAAQ,WAAW,CAAC,CAAC;CAC9C,MAAM,WAAW,MAAM,oBAAoB,WAAW;CACtD,MAAM,aAAkC,CAAC;CACzC,KAAK,MAAM,QAAQ,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,GAAG;EAC3D,IAAI,SAAS,YAAY,SAAS,IAAI,IAAI,GAAG;EAC7C,MAAM,MAAM,qBAAqB,aAAa,IAAI;EAClD,IAAI,QAAQ,KAAA,GAAW;GACrB,KAAK,8BAA8B,KAAK,UAAU,IAAI,EAAE,8CAA8C;GACtG;EACF;EACA,IAAI;EACJ,IAAI;GACF,cAAc,KAAK,MAAM,MAAM,SAAS,KAAK,KAAK,cAAc,GAAG,MAAM,CAAC;EAC5E,SAAS,OAAO;GACd,KAAK,+BAA+B,KAAK,iBAAiB,iBAAiB,QA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SAAS,CAAC;GACZ;EACF,CAAC,CAAC;EAEF,MAAM,WAAqD,MAAM,QAAQ,OAAO,QAAQ,KAAK,OAAO,SAAS,SAAS,IAClH,OAAO,SAAS,KAAI,UAAS,EAAE,KAAK,EAAE,IACtC,MAAM,0BAA0B,aAAa;GAC3C,GAAI,MAAM,QAAQ,OAAO,OAAO,IAAI,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;GACnE;EACF,CAAC;EACL,IAAI,SAAS,WAAW,GAAG;GACzB,KAAK,wHAAwH;GAC7H,gBAAgB,CAAC,CAAC;GAClB;EACF;EACA,KAAK,6BAA6B,SAAS,OAAO,kBAAkB,SAAS,KAAI,QAAO,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG;EAC9G,MAAM,WAAW,MAAM,cACrB,EACE,UAAU,SAAS,KAAI,QACrB,IAAI,WAAW,KAAA,IAAY,EAAE,MAAM,IAAI,KAAK,IAAI;GAAE,MAAM,IAAI;GAAM,QAAQ,IAAI;EAAO,CAAC,EAC1F,GACA,KAAK,aAAa,cAAc,CAClC;EAQA,MAAM,oBAAoB,KAAK,UAAU,KAAA,GAAW,EAAE,YAAY,KAAK,CAAC;EACxE,gBAAgB,QAAQ;CAC1B,SAAS,OAAO;EAGd,gBAAgB,CAAC,CAAC;EAClB,MAAM;CACR;AACF;;;;;;;;AC3XA,eAAsB,eAAe,KAAsD;CACzF,MAAM,EAAE,gBAAgB,QAAQ,MAAM,OAAO;CAC7C,OAAO,IAAI,GAAG;AAChB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi2dsh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Bridge the Pi and DeepSeek Harness ecosystems: a general Pi Host ABI that runs unmodified Pi extensions as native DSH plugins, with compatibility inspection and Pi-to-DSH MCP config translation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|