@klarkxy/dsh-magpie 0.0.0-stage → 0.1.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/LICENSE +42 -0
- package/README.md +35 -2
- package/cordis.patch.yml +5 -0
- package/docs/README.zh-CN.md +36 -0
- package/icon.svg +17 -0
- package/lib/client.inner.cjs +967 -0
- package/lib/client.inner.cjs.map +1 -0
- package/lib/client.js +976 -0
- package/lib/contracts.d.ts +104 -0
- package/lib/contracts.js +38 -0
- package/lib/contracts.js.map +1 -0
- package/lib/index.d.ts +191 -0
- package/lib/index.js +806 -0
- package/lib/index.js.map +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +137 -4
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/address.ts","../src/gateway.ts","../src/mapping.ts","../src/plan.ts","../src/service.ts","../src/index.ts"],"sourcesContent":["/**\n * Gateway address normalization. The result is the gateway root every\n * endpoint path is appended to, e.g. `http://192.168.1.5:3425`.\n */\n\nexport class AddressError extends Error {\n override name = 'AddressError'\n}\n\nexport interface GatewayAddress {\n /** Normalized gateway root without a trailing slash or `/v1` suffix. */\n root: string\n /** Whether the address points at this computer. */\n loopback: boolean\n}\n\nconst SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\//\n\nexport function isLoopbackHost(hostname: string): boolean {\n const host = hostname.replace(/^\\[|\\]$/g, '').toLowerCase()\n if (host === 'localhost' || host === '::1' || host === '0:0:0:0:0:0:0:1') return true\n return /^127(?:\\.\\d{1,3}){3}$/.test(host)\n}\n\n/** Normalize user input into a gateway root. Throws {@link AddressError}. */\nexport function normalizeGatewayAddress(input: string): GatewayAddress {\n const trimmed = input.trim()\n if (!trimmed) throw new AddressError('Gateway address is required')\n let url: URL\n try {\n url = new URL(SCHEME.test(trimmed) ? trimmed : `http://${trimmed}`)\n } catch {\n throw new AddressError(`Gateway address \"${trimmed}\" is not a valid URL`)\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new AddressError('Gateway address must use http or https')\n }\n if (url.username || url.password) throw new AddressError('Gateway address must not contain credentials')\n if (url.search) throw new AddressError('Gateway address must not contain a query')\n if (url.hash) throw new AddressError('Gateway address must not contain a fragment')\n let path = url.pathname.replace(/\\/+$/, '')\n if (path.endsWith('/v1')) path = path.slice(0, -3)\n const root = `${url.origin}${path}`\n return { root, loopback: isLoopbackHost(url.hostname) }\n}\n","/**\n * Thin read-only client for the magpie gateway. The gateway filters its model\n * listing per agent by User-Agent, so requests identify as deepseek-harness\n * and only ever issue GETs; no model inference endpoint is touched.\n */\nimport { GATEWAY_TIMEOUT_MS } from './contracts.ts'\n\nexport class GatewayError extends Error {\n readonly code: string\n readonly status?: number\n constructor(code: string, message: string, status?: number) {\n super(message)\n this.name = 'GatewayError'\n this.code = code\n this.status = status\n }\n}\n\nexport interface GatewayClientDeps {\n fetchImpl?: typeof fetch\n userAgent: string\n /** Bearer token; omit when the gateway needs none. */\n key?: string\n}\n\nasync function get(\n url: string,\n deps: GatewayClientDeps,\n signal?: AbortSignal,\n): Promise<unknown> {\n const fetcher = deps.fetchImpl ?? fetch\n const timeout = AbortSignal.timeout(GATEWAY_TIMEOUT_MS)\n const combined = signal ? AbortSignal.any([timeout, signal]) : timeout\n let response: Response\n try {\n response = await fetcher(url, {\n headers: {\n 'user-agent': deps.userAgent,\n ...(deps.key ? { authorization: `Bearer ${deps.key}` } : {}),\n },\n signal: combined,\n })\n } catch (error) {\n if ((error as Error).name === 'AbortError' && signal?.aborted) throw error\n if ((error as Error).name === 'TimeoutError' || (error as Error).name === 'AbortError') {\n throw new GatewayError('timeout', `magpie gateway at ${url} did not answer within ${GATEWAY_TIMEOUT_MS / 1000}s`)\n }\n throw new GatewayError('unreachable', `magpie gateway at ${url} is not reachable: ${(error as Error).message}`)\n }\n if (response.status === 401 || response.status === 403) {\n throw new GatewayError('key-required', 'the gateway requires a key; create one with `magpie gateway-key add` and save it here', response.status)\n }\n if (!response.ok) throw new GatewayError('http', `magpie gateway answered HTTP ${response.status} for ${url}`, response.status)\n try {\n return await response.json()\n } catch {\n throw new GatewayError('bad-reply', `magpie gateway returned an unreadable reply for ${url}`)\n }\n}\n\n/** GET `/` and verify the service identifies as magpie; keeps the version. */\nexport async function fetchGatewayInfo(\n root: string,\n deps: GatewayClientDeps,\n signal?: AbortSignal,\n): Promise<{ name: string; version?: string }> {\n const body = await get(`${root}/`, deps, signal) as { name?: unknown; version?: unknown }\n if (body?.name !== 'magpie') {\n throw new GatewayError('not-magpie', `${root} is not a magpie gateway (it answered \"${String(body?.name ?? 'unknown')}\")`)\n }\n return { name: 'magpie', version: typeof body.version === 'string' ? body.version : undefined }\n}\n\n/** GET `/v1/models`; returns the raw data array. Pagination is ignored. */\nexport async function fetchModels(\n root: string,\n deps: GatewayClientDeps,\n signal?: AbortSignal,\n): Promise<unknown[]> {\n const body = await get(`${root}/v1/models`, deps, signal) as { data?: unknown }\n return Array.isArray(body?.data) ? body.data : []\n}\n","/**\n * Map a magpie `/v1/models` listing onto the three llm-pi-ai provider routes\n * `magpie dsh <model>` writes (`magpie`, `magpie-responses`,\n * `magpie-anthropic`), so either tool can replace the other.\n */\nimport type { PiAiModelProfile, PiAiProviderProfile, PiAiReasoningEfforts } from '@deepseek-ai/dsh-llm-pi-ai'\nimport { ROUTES, STREAM_IDLE_TIMEOUT_MS, type RouteKind, type RouteName } from './contracts.ts'\n\n/** One entry of the magpie `/v1/models` reply, fields beyond this shape ignored. */\nexport interface MagpieModelEntry {\n id?: unknown\n type?: unknown\n owned_by?: unknown\n magpie_label?: unknown\n display_name?: unknown\n context_length?: unknown\n context_window?: unknown\n max_output_tokens?: unknown\n modalities?: unknown\n reasoning_levels?: unknown\n supported_reasoning_levels?: unknown\n native_endpoints?: unknown\n}\n\ntype Protocol = RouteKind\n\nconst REASONING_EFFORTS: Record<string, [key: string, value: string]> = {\n none: ['off', 'none'],\n minimal: ['minimal', 'minimal'],\n low: ['low', 'low'],\n medium: ['medium', 'medium'],\n high: ['high', 'high'],\n xhigh: ['xhigh', 'xhigh'],\n max: ['max', 'max'],\n}\n\nfunction strings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : []\n}\n\nfunction number(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n}\n\n/** Text models only: typed non-models and output modality lists without 'text' are skipped. */\nexport function isSelectableModel(entry: MagpieModelEntry): boolean {\n if (typeof entry.id !== 'string' || !entry.id) return false\n if (entry.type !== undefined && entry.type !== 'model') return false\n const output = (entry.modalities as { output?: unknown } | undefined)?.output\n if (output !== undefined && !strings(output).includes('text')) return false\n return true\n}\n\n/** Which wire protocol this model prefers, from its declared native endpoints. */\nexport function endpointProtocol(entry: MagpieModelEntry): Protocol | undefined {\n const endpoints = strings(entry.native_endpoints)\n if (endpoints.includes('/v1/chat/completions')) return 'completions'\n if (endpoints.includes('/v1/responses')) return 'responses'\n if (endpoints.includes('/v1/messages')) return 'anthropic'\n return undefined\n}\n\n/**\n * Models that declare no native endpoints inherit the unanimous protocol of\n * same-owner models that do declare one; a split owner falls back to\n * completions, matching `magpie dsh`.\n */\nexport function modelProtocol(entry: MagpieModelEntry, siblings: readonly MagpieModelEntry[]): Protocol {\n const own = endpointProtocol(entry)\n if (own) return own\n const protocols = new Set(\n siblings\n .filter(item => item !== entry && item.owned_by === entry.owned_by)\n .map(item => endpointProtocol(item))\n .filter((protocol): protocol is Protocol => protocol !== undefined),\n )\n return protocols.size === 1 ? [...protocols][0] : 'completions'\n}\n\nfunction reasoningEfforts(entry: MagpieModelEntry): PiAiReasoningEfforts | undefined {\n const levels = entry.reasoning_levels !== undefined\n ? strings(entry.reasoning_levels)\n : (entry.supported_reasoning_levels as readonly { effort?: unknown }[] | undefined)\n ?.map(item => item?.effort).filter((item): item is string => typeof item === 'string')\n if (!levels) return undefined\n const efforts: Record<string, string> = {}\n for (const level of levels) {\n const mapped = REASONING_EFFORTS[level]\n if (mapped && efforts[mapped[0]] === undefined) efforts[mapped[0]] = mapped[1]\n }\n return Object.keys(efforts).length ? efforts : undefined\n}\n\nfunction modelProfile(entry: MagpieModelEntry, protocol: Protocol): PiAiModelProfile {\n const id = entry.id as string\n const contextWindow = number(entry.context_length) ?? number(entry.context_window)\n let maxTokens = number(entry.max_output_tokens)\n if (maxTokens !== undefined && contextWindow !== undefined) {\n // Output cap at 7/16 of the window, matching what magpie writes for most models.\n maxTokens = Math.min(maxTokens, Math.floor(contextWindow * 7 / 16))\n }\n const declared = strings((entry.modalities as { input?: unknown } | undefined)?.input)\n .filter((item): item is 'text' | 'image' => item === 'text' || item === 'image')\n const profile: PiAiModelProfile = {\n id,\n name: typeof entry.magpie_label === 'string' ? entry.magpie_label\n : typeof entry.display_name === 'string' ? entry.display_name : id,\n input: declared.length ? declared : ['text'],\n }\n if (contextWindow !== undefined) profile.contextWindow = contextWindow\n if (maxTokens !== undefined) profile.maxTokens = maxTokens\n const efforts = reasoningEfforts(entry)\n if (efforts) profile.reasoningEfforts = efforts\n if (protocol === 'responses') profile.compat = { supportsStrictMode: true }\n else if (protocol === 'anthropic' && /claude/i.test(id)) profile.compat = { forceAdaptiveThinking: true }\n return profile\n}\n\nconst ROUTE_PROFILE: Record<Protocol, (root: string, apiKeyEnv: string, models: PiAiModelProfile[]) => PiAiProviderProfile> = {\n completions: (root, apiKeyEnv, models) => ({\n displayName: 'Magpie', apiKeyEnv, api: 'openai-completions', baseURL: `${root}/v1`, models,\n }),\n responses: (root, apiKeyEnv, models) => ({\n displayName: 'Magpie · Responses', apiKeyEnv, api: 'openai-responses', baseURL: `${root}/v1`, models,\n }),\n anthropic: (root, apiKeyEnv, models) => ({\n displayName: 'Magpie · Anthropic', apiKeyEnv, api: 'anthropic-messages', baseURL: root, models,\n }),\n}\n\n/**\n * Build the `llm-pi-ai` providers dict for one gateway listing. Listing order\n * is kept; a duplicated id keeps its first entry; an empty route is omitted.\n */\nexport function buildRoutes(\n listing: { data?: readonly MagpieModelEntry[] } | readonly MagpieModelEntry[],\n root: string,\n apiKeyEnv: string,\n): Partial<Record<RouteName, PiAiProviderProfile>> {\n const entries = Array.isArray(listing) ? listing : ((listing as { data?: readonly MagpieModelEntry[] }).data ?? [])\n const seen = new Set<string>()\n const grouped: Record<Protocol, PiAiModelProfile[]> = { completions: [], responses: [], anthropic: [] }\n for (const entry of entries) {\n if (!isSelectableModel(entry) || seen.has(entry.id as string)) continue\n seen.add(entry.id as string)\n const protocol = modelProtocol(entry, entries)\n grouped[protocol].push(modelProfile(entry, protocol))\n }\n const routes: Partial<Record<RouteName, PiAiProviderProfile>> = {}\n for (const protocol of ['completions', 'responses', 'anthropic'] as const) {\n const models = grouped[protocol]\n if (!models.length) continue\n routes[ROUTES[protocol]] = { ...ROUTE_PROFILE[protocol](root, apiKeyEnv, models), streamIdleTimeoutMs: STREAM_IDLE_TIMEOUT_MS }\n }\n return routes\n}\n","/**\n * Settings write planning. Given the live `ctx.settings` descriptors and the\n * state a gateway listing implies, produce the `mutate` ops per namespace.\n * The comparison layer is `descriptor.user` when present — the profile-patch\n * section `mutate` edits — otherwise `descriptor.value`; a namespace whose\n * user layer already matches is skipped entirely so a repeat sync never\n * churns the patch.\n */\nimport {\n NS_DEFAULT_MODEL, NS_LLM, NS_WEB_SEARCH, ROUTE_NAMES, type RouteName,\n} from './contracts.ts'\n\nexport interface SettingsDescriptorLike {\n ns: string\n value?: unknown\n base?: unknown\n user?: unknown\n revision: number\n}\n\nexport type PlanOp =\n | { op: 'set'; path: string[]; value: unknown }\n | { op: 'unset'; path: string[] }\n\nexport interface NamespacePlan {\n ns: string\n revision: number\n ops: PlanOp[]\n}\n\nexport interface SyncPlan {\n namespaces: NamespacePlan[]\n warnings: string[]\n}\n\nexport interface DesiredSync {\n /** Produced provider profiles; absent keys mean \"no such route\". */\n routes: Partial<Record<RouteName, unknown>>\n /** Credential reference shared by the routes and web search. */\n apiKeyEnv: string\n /** Requested default model id; empty means leave `agent-default-model` alone. */\n defaultModel?: string\n webSearch: boolean\n /** Web-search model id; falls back to defaultModel when empty. */\n webSearchModel?: string\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction layer(descriptor: SettingsDescriptorLike | undefined): unknown {\n return descriptor?.user !== undefined ? descriptor.user : descriptor?.value\n}\n\nfunction getPath(value: unknown, path: readonly string[]): unknown {\n let node = value\n for (const key of path) {\n if (!isRecord(node) && !Array.isArray(node)) return undefined\n node = (node as Record<string, unknown>)[key]\n }\n return node\n}\n\nexport function deepEqual(left: unknown, right: unknown): boolean {\n if (Object.is(left, right)) return true\n if (Array.isArray(left) && Array.isArray(right)) {\n return left.length === right.length && left.every((item, index) => deepEqual(item, right[index]))\n }\n if (isRecord(left) && isRecord(right)) {\n const keys = new Set([...Object.keys(left), ...Object.keys(right)])\n return [...keys].every(key => deepEqual(left[key], right[key]))\n }\n return false\n}\n\nfunction setIfChanged(ops: PlanOp[], current: unknown, path: readonly string[], value: unknown): void {\n if (!deepEqual(getPath(current, path), value)) ops.push({ op: 'set', path: [...path], value })\n}\n\nfunction unsetIfPresent(ops: PlanOp[], current: unknown, path: readonly string[]): void {\n if (getPath(current, path) !== undefined) ops.push({ op: 'unset', path: [...path] })\n}\n\nfunction routeForModel(routes: DesiredSync['routes'], model: string): RouteName | undefined {\n for (const name of ROUTE_NAMES) {\n const models = (routes[name] as { models?: { id?: unknown }[] } | undefined)?.models\n if (Array.isArray(models) && models.some(entry => entry?.id === model)) return name\n }\n return undefined\n}\n\nfunction llmPiAiOps(desired: DesiredSync, current: unknown): PlanOp[] {\n const ops: PlanOp[] = []\n for (const name of ROUTE_NAMES) {\n const profile = desired.routes[name]\n if (profile !== undefined) setIfChanged(ops, current, ['providers', name], profile)\n else unsetIfPresent(ops, current, ['providers', name])\n }\n return ops\n}\n\nfunction webSearchOffOps(current: unknown, root: string): PlanOp[] {\n if (getPath(current, ['baseURL']) !== `${root}/v1`) return []\n const ops: PlanOp[] = []\n unsetIfPresent(ops, current, ['apiKeyEnv'])\n unsetIfPresent(ops, current, ['baseURL'])\n unsetIfPresent(ops, current, ['model'])\n return ops\n}\n\n/**\n * Plan the ops writing one gateway state into llm-pi-ai routes, the default\n * model, and web search. Missing namespaces become warnings, not ops.\n */\nexport function planSync(\n descriptors: readonly SettingsDescriptorLike[],\n desired: DesiredSync,\n root: string,\n): SyncPlan {\n const warnings: string[] = []\n const namespaces: NamespacePlan[] = []\n const byNs = new Map(descriptors.map(entry => [entry.ns, entry]))\n const find = (ns: string): SettingsDescriptorLike | undefined => {\n const descriptor = byNs.get(ns)\n if (!descriptor) warnings.push(`settings namespace \"${ns}\" is not available; skipped`)\n return descriptor\n }\n\n const llm = find(NS_LLM)\n if (llm) {\n const ops = llmPiAiOps(desired, layer(llm))\n if (ops.length) namespaces.push({ ns: NS_LLM, revision: llm.revision, ops })\n }\n\n if (desired.defaultModel) {\n const model = desired.defaultModel\n const route = routeForModel(desired.routes, model)\n if (!route) warnings.push(`default model \"${model}\" is not offered by this gateway; default model unchanged`)\n else {\n const descriptor = find(NS_DEFAULT_MODEL)\n if (descriptor) {\n const current = layer(descriptor)\n const ops: PlanOp[] = []\n setIfChanged(ops, current, ['provider'], route)\n setIfChanged(ops, current, ['model'], model)\n if (ops.length) namespaces.push({ ns: NS_DEFAULT_MODEL, revision: descriptor.revision, ops })\n }\n }\n }\n\n const search = byNs.get(NS_WEB_SEARCH)\n if (desired.webSearch) {\n const model = desired.webSearchModel || desired.defaultModel\n if (!model) warnings.push('web search is enabled but no model is selected; web search unchanged')\n else if (!search) warnings.push(`settings namespace \"${NS_WEB_SEARCH}\" is not available; skipped`)\n else {\n const current = layer(search)\n const ops: PlanOp[] = []\n setIfChanged(ops, current, ['apiKeyEnv'], desired.apiKeyEnv)\n setIfChanged(ops, current, ['baseURL'], `${root}/v1`)\n setIfChanged(ops, current, ['model'], model)\n if (ops.length) namespaces.push({ ns: NS_WEB_SEARCH, revision: search.revision, ops })\n }\n } else if (search) {\n const ops = webSearchOffOps(layer(search), root)\n if (ops.length) namespaces.push({ ns: NS_WEB_SEARCH, revision: search.revision, ops })\n }\n\n return { namespaces, warnings }\n}\n\n/** Remove the three routes and revert the defaults they may own; the stored credential is kept. */\nexport function planDisconnect(descriptors: readonly SettingsDescriptorLike[], root: string): SyncPlan {\n const warnings: string[] = []\n const namespaces: NamespacePlan[] = []\n const byNs = new Map(descriptors.map(entry => [entry.ns, entry]))\n\n const llm = byNs.get(NS_LLM)\n if (llm) {\n const current = layer(llm)\n const ops: PlanOp[] = []\n for (const name of ROUTE_NAMES) unsetIfPresent(ops, current, ['providers', name])\n if (ops.length) namespaces.push({ ns: NS_LLM, revision: llm.revision, ops })\n } else {\n warnings.push(`settings namespace \"${NS_LLM}\" is not available; skipped`)\n }\n\n const fallback = byNs.get(NS_DEFAULT_MODEL)\n if (fallback) {\n const current = layer(fallback)\n if (ROUTE_NAMES.includes(getPath(current, ['provider']) as RouteName)) {\n const ops: PlanOp[] = []\n unsetIfPresent(ops, current, ['provider'])\n unsetIfPresent(ops, current, ['model'])\n if (ops.length) namespaces.push({ ns: NS_DEFAULT_MODEL, revision: fallback.revision, ops })\n }\n }\n\n const search = byNs.get(NS_WEB_SEARCH)\n if (search) {\n const ops = webSearchOffOps(layer(search), root)\n if (ops.length) namespaces.push({ ns: NS_WEB_SEARCH, revision: search.revision, ops })\n }\n\n return { namespaces, warnings }\n}\n","/**\n * Host-side controller: gateway reads, serialized syncs, and the RPC surface\n * the settings page calls. Every failure lands in `lastError`; the plugin\n * itself never crashes on a bad gateway or a read-only profile.\n */\nimport { normalizeGatewayAddress, AddressError } from './address.ts'\nimport { GatewayError, fetchGatewayInfo, fetchModels } from './gateway.ts'\nimport { buildRoutes } from './mapping.ts'\nimport { planDisconnect, planSync, type PlanOp, type SettingsDescriptorLike } from './plan.ts'\nimport {\n LOOPBACK_PLACEHOLDER_KEY, NS_LLM, ROUTE_NAMES, RPC_ENDPOINTS,\n type GatewayInfo, type MagpieOptions, type MagpieStatus, type RouteModel,\n type RpcResult, type SaveConnectionInput, type SetOptionsInput, type TestResult,\n} from './contracts.ts'\n\nexport class MagpieError extends Error {\n readonly code: string\n constructor(code: string, message: string) {\n super(message)\n this.name = 'MagpieError'\n this.code = code\n }\n}\n\nexport interface CredentialsLike {\n resolve(ref: string): Promise<{ value: string } | undefined>\n describe(ref: string): Promise<{ configured: boolean; writable: boolean }>\n set(ref: string, value: string): Promise<void>\n unset(ref: string): Promise<void>\n}\n\nexport interface MagpieServiceDeps {\n describe(): SettingsDescriptorLike[]\n mutate(ns: string, ops: readonly PlanOp[], expectedRevision?: number): Promise<void>\n /** Whether the active profile accepts settings writes. */\n writable(): boolean\n /** The host credential store; absent on hosts that ship none (e.g. headless). */\n credentials(): CredentialsLike | undefined\n /** Own settings namespace (the profile entry id of this plugin). */\n ownNamespace: string\n options(): MagpieOptions\n fetchImpl?: typeof fetch\n userAgent: string\n logger?: { warn(message: string, ...args: unknown[]): void }\n now?: () => Date\n}\n\nconst REF_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/\n\nfunction fail(error: unknown): RpcResult<never> {\n if (error instanceof MagpieError) return { ok: false, error: { code: error.code, message: error.message } }\n if (error instanceof GatewayError) return { ok: false, error: { code: error.code, message: error.message } }\n if (error instanceof AddressError) return { ok: false, error: { code: 'invalid-address', message: error.message } }\n const message = error instanceof Error ? error.message : String(error)\n return { ok: false, error: { code: 'internal', message } }\n}\n\nfunction isConflict(error: unknown): boolean {\n return (error as { code?: string })?.code === 'SETTINGS_CONFLICT'\n}\n\nexport function createMagpieService(deps: MagpieServiceDeps) {\n const now = () => (deps.now?.() ?? new Date()).toISOString()\n let queue: Promise<unknown> = Promise.resolve()\n let syncing = false\n let gateway: GatewayInfo | undefined\n let lastSync: MagpieStatus['lastSync']\n let lastError: MagpieStatus['lastError']\n\n const enqueue = <T>(task: () => Promise<T>): Promise<T> => {\n const result = queue.then(task)\n queue = result.catch(() => {})\n return result\n }\n\n const ownDescriptor = (): SettingsDescriptorLike => {\n const descriptor = deps.describe().find(entry => entry.ns === deps.ownNamespace)\n if (!descriptor) throw new MagpieError('unavailable', 'this profile cannot edit the magpie settings entry')\n return descriptor\n }\n\n /** CAS writes on any namespace with one describe-and-replan retry. */\n const applyPlan = async (plan: (descriptors: SettingsDescriptorLike[]) => { namespaces: { ns: string; revision: number; ops: PlanOp[] }[]; warnings: string[] }) => {\n let warnings: string[] = []\n for (let attempt = 0; attempt < 2; attempt += 1) {\n const current = plan(deps.describe())\n try {\n for (const item of current.namespaces) await deps.mutate(item.ns, item.ops, item.revision)\n warnings = current.warnings\n break\n } catch (error) {\n if (attempt === 0 && isConflict(error)) continue\n throw error instanceof MagpieError ? error : new MagpieError('write-failed', `settings write failed: ${(error as Error).message}`)\n }\n }\n return warnings\n }\n\n const writeOwn = async (ops: PlanOp[]): Promise<void> => {\n for (let attempt = 0; attempt < 2; attempt += 1) {\n const descriptor = ownDescriptor()\n try {\n await deps.mutate(deps.ownNamespace, ops, descriptor.revision)\n return\n } catch (error) {\n if (attempt === 0 && isConflict(error)) continue\n throw error instanceof MagpieError ? error : new MagpieError('write-failed', `settings write failed: ${(error as Error).message}`)\n }\n }\n }\n\n /** Stored credential, ambient env, or the loopback placeholder — persisted only during sync. */\n const resolveKey = async (options: MagpieOptions, loopback: boolean, store: boolean): Promise<string | undefined> => {\n if (!REF_NAME.test(options.apiKeyEnv)) {\n throw new MagpieError('invalid-ref', `credential reference \"${options.apiKeyEnv}\" is not a valid environment-variable name`)\n }\n const credentials = deps.credentials()\n if (!credentials) {\n const ambient = process.env[options.apiKeyEnv]?.trim()\n if (ambient) return ambient\n return loopback ? LOOPBACK_PLACEHOLDER_KEY : undefined\n }\n const existing = await credentials.resolve(options.apiKeyEnv)\n if (existing?.value) return existing.value\n if (!loopback) return undefined\n if (store) await credentials.set(options.apiKeyEnv, LOOPBACK_PLACEHOLDER_KEY)\n return LOOPBACK_PLACEHOLDER_KEY\n }\n\n const gatewayDeps = (key: string | undefined) => ({ fetchImpl: deps.fetchImpl, userAgent: deps.userAgent, key })\n\n const readGateway = async (signal?: AbortSignal): Promise<{ root: string; loopback: boolean; info: GatewayInfo; models: unknown[]; key?: string }> => {\n const options = deps.options()\n const { root, loopback } = normalizeGatewayAddress(options.address)\n const key = await resolveKey(options, loopback, false)\n const client = gatewayDeps(key)\n const info = await fetchGatewayInfo(root, client, signal)\n const models = await fetchModels(root, client, signal)\n return { root, loopback, info, models, key }\n }\n\n const routeModels = (): RouteModel[] => {\n const descriptor = deps.describe().find(entry => entry.ns === NS_LLM)\n const providers = (descriptor?.value as { providers?: Record<string, { models?: { id?: unknown; name?: unknown }[] }> } | undefined)?.providers\n if (!providers) return []\n return ROUTE_NAMES.flatMap(route =>\n (providers[route]?.models ?? [])\n .filter(model => typeof model?.id === 'string')\n .map(model => ({ id: model.id as string, name: typeof model.name === 'string' ? model.name : undefined, route })))\n }\n\n const status = async (): Promise<MagpieStatus> => {\n const options = deps.options()\n let keyConfigured = false\n let keyWritable = false\n const credentials = deps.credentials()\n if (!credentials) {\n keyConfigured = Boolean(process.env[options.apiKeyEnv]?.trim())\n } else {\n try {\n const info = await credentials.describe(options.apiKeyEnv)\n keyConfigured = info.configured\n keyWritable = info.writable\n } catch { /* an invalid ref reports as unconfigured */ }\n }\n return {\n address: options.address,\n apiKeyEnv: options.apiKeyEnv,\n keyConfigured,\n keyWritable,\n options: {\n syncOnStart: options.syncOnStart,\n defaultModel: options.defaultModel,\n webSearch: options.webSearch,\n webSearchModel: options.webSearchModel,\n },\n writable: deps.writable(),\n gateway,\n syncing,\n lastSync,\n lastError,\n models: routeModels(),\n }\n }\n\n const performSync = async (signal?: AbortSignal): Promise<void> => {\n if (!deps.writable()) throw new MagpieError('read-only', 'profile settings are read-only here; save connection details but sync cannot write them')\n const options = deps.options()\n const { root, loopback } = normalizeGatewayAddress(options.address)\n const key = await resolveKey(options, loopback, true)\n const client = gatewayDeps(key)\n const info = await fetchGatewayInfo(root, client, signal)\n const entries = await fetchModels(root, client, signal)\n const routes = buildRoutes({ data: entries as { id?: unknown }[] }, root, options.apiKeyEnv)\n const desired = {\n routes,\n apiKeyEnv: options.apiKeyEnv,\n defaultModel: options.defaultModel?.trim() || undefined,\n webSearch: options.webSearch,\n webSearchModel: options.webSearchModel?.trim() || undefined,\n }\n if (!Object.keys(routes).length) {\n throw new MagpieError('empty-listing', 'the gateway returned no usable models; nothing was changed')\n }\n const warnings = await applyPlan(descriptors => planSync(descriptors, desired, root))\n gateway = info\n lastSync = {\n at: now(),\n routes: Object.fromEntries(Object.entries(routes).map(([name, profile]) => [name, (profile as { models?: unknown[] }).models?.length ?? 0])),\n warnings,\n }\n lastError = undefined\n }\n\n const sync = (signal?: AbortSignal): Promise<MagpieStatus> => enqueue(async () => {\n syncing = true\n try {\n await performSync(signal)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n lastError = { at: now(), message }\n deps.logger?.warn('magpie: sync failed: %s', message)\n } finally {\n syncing = false\n }\n return status()\n })\n\n const saveConnection = async (input: SaveConnectionInput, signal?: AbortSignal): Promise<MagpieStatus> => {\n signal?.throwIfAborted()\n const wantsKey = input.clearKey === true || (typeof input.apiKey === 'string' && Boolean(input.apiKey.trim()))\n const credentials = deps.credentials()\n if (wantsKey && !credentials) {\n throw new MagpieError('no-credential-store',\n `this host has no credential store; set ${deps.options().apiKeyEnv} in the environment`)\n }\n const ops: PlanOp[] = []\n if (input.address !== undefined) {\n const { root } = normalizeGatewayAddress(input.address)\n ops.push({ op: 'set', path: ['address'], value: root })\n }\n if (ops.length) await writeOwn(ops)\n if (input.clearKey) await credentials!.unset(deps.options().apiKeyEnv)\n if (typeof input.apiKey === 'string' && input.apiKey.trim()) {\n await credentials!.set(deps.options().apiKeyEnv, input.apiKey.trim())\n }\n return status()\n }\n\n const setOptions = async (input: SetOptionsInput, signal?: AbortSignal): Promise<MagpieStatus> => {\n signal?.throwIfAborted()\n const ops: PlanOp[] = []\n if (input.syncOnStart !== undefined) {\n if (typeof input.syncOnStart !== 'boolean') throw new MagpieError('bad-request', 'syncOnStart must be a boolean')\n ops.push({ op: 'set', path: ['syncOnStart'], value: input.syncOnStart })\n }\n for (const key of ['defaultModel', 'webSearchModel'] as const) {\n const value = input[key]\n if (value === undefined) continue\n if (value === null || value === '') ops.push({ op: 'unset', path: [key] })\n else if (typeof value === 'string') ops.push({ op: 'set', path: [key], value })\n else throw new MagpieError('bad-request', `${key} must be a string`)\n }\n if (input.webSearch !== undefined) {\n if (typeof input.webSearch !== 'boolean') throw new MagpieError('bad-request', 'webSearch must be a boolean')\n ops.push({ op: 'set', path: ['webSearch'], value: input.webSearch })\n }\n if (ops.length) await writeOwn(ops)\n // Options affect only what sync writes; rerun it against the same gateway.\n return sync(signal)\n }\n\n const disconnect = async (signal?: AbortSignal): Promise<MagpieStatus> => enqueue(async () => {\n signal?.throwIfAborted()\n const options = deps.options()\n const { root } = normalizeGatewayAddress(options.address)\n if (!deps.writable()) throw new MagpieError('read-only', 'profile settings are read-only here; routes cannot be removed')\n await applyPlan(descriptors => planDisconnect(descriptors, root))\n gateway = undefined\n lastSync = undefined\n return status()\n })\n\n const test = async (signal?: AbortSignal): Promise<TestResult> => {\n const { info, models } = await readGateway(signal)\n gateway = info\n return { gateway: info, models: models.length }\n }\n\n const handleRpc = (endpoint: string, payload: unknown, signal: AbortSignal): Promise<RpcResult> => (async () => {\n try {\n const body = (payload ?? {}) as Record<string, unknown>\n switch (endpoint) {\n case RPC_ENDPOINTS.status: return { ok: true, value: await status() }\n case RPC_ENDPOINTS.saveConnection: return { ok: true, value: await saveConnection(body as SaveConnectionInput, signal) }\n case RPC_ENDPOINTS.test: return { ok: true, value: await test(signal) }\n case RPC_ENDPOINTS.sync: return { ok: true, value: await sync(signal) }\n case RPC_ENDPOINTS.setOptions: return { ok: true, value: await setOptions(body as SetOptionsInput, signal) }\n case RPC_ENDPOINTS.disconnect: return { ok: true, value: await disconnect(signal) }\n default: return { ok: false, error: { code: 'not-found', message: `unknown endpoint: ${endpoint}` } }\n }\n } catch (error) {\n return fail(error)\n }\n })()\n\n return { status, sync, saveConnection, setOptions, disconnect, test, handleRpc }\n}\n\nexport type MagpieService = ReturnType<typeof createMagpieService>\n","/**\n * dsh-magpie — connect this profile to a magpie gateway.\n *\n * Host half: fetches the gateway's model listing and writes the same three\n * llm-pi-ai provider routes `magpie dsh` writes (`magpie`,\n * `magpie-responses`, `magpie-anthropic`), plus the default model and web\n * search selection, through `ctx.settings.mutate` — the official profile-patch\n * path. The gateway key lives in the credential store under the same\n * `MAGPIE_GATEWAY_KEY` reference magpie uses, so either tool can replace the\n * other. Syncs are serialized; one runs on the button and once at startup\n * after the Loader has settled.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport Schema from '@deepseek-ai/schemastery'\nimport type {} from '@deepseek-ai/dsh-credentials'\nimport type {} from '@deepseek-ai/dsh-settings'\nimport { registerHostRpc, type HostRpcContext } from '@klarkxy/dsh-plugin-kit/host-rpc'\nimport { createMagpieService, type CredentialsLike } from './service.ts'\nimport type { SettingsDescriptorLike } from './plan.ts'\nimport {\n DEFAULT_ADDRESS, DEFAULT_KEY_REF, PLUGIN_NAME, PLUGIN_VERSION, RPC_CHANNEL,\n type MagpieOptions, type RpcResult,\n} from './contracts.ts'\n\nexport const name = PLUGIN_NAME\nexport const inject = ['settings', 'loader'] as const\n\nexport const Config = Schema.object({\n /** magpie gateway root; `http://` is assumed and a trailing `/v1` is stripped. */\n address: Schema.string().default(DEFAULT_ADDRESS).volatile(),\n /** Credential reference (`env`-style name) holding the gateway key. */\n apiKeyEnv: Schema.string().role('credential-ref').default(DEFAULT_KEY_REF).volatile(),\n /** Run one sync when the profile starts. */\n syncOnStart: Schema.boolean().default(true).volatile(),\n /** magpie model id promoted to the default model; empty keeps the current one. */\n defaultModel: Schema.string().volatile(),\n /** Route the DeepSeek web-search provider through this gateway. */\n webSearch: Schema.boolean().default(false).volatile(),\n /** Web-search model; empty uses the default model. */\n webSearchModel: Schema.string().volatile(),\n})\n\ntype Cell<T> = { get(): T } | T\n\ninterface ResolvedConfig {\n address: Cell<string>\n apiKeyEnv: Cell<string>\n syncOnStart: Cell<boolean>\n defaultModel: Cell<string | undefined>\n webSearch: Cell<boolean>\n webSearchModel: Cell<string | undefined>\n}\n\ntype Host = Context & HostRpcContext & {\n loader: { await(): Promise<void> }\n settings: {\n describe(): unknown[]\n mutate(ns: string, ops: readonly { op: string; path: readonly string[]; value?: unknown }[], expectedRevision?: number): Promise<void>\n writable: boolean\n configure(presentation: { auto?: boolean }): () => void\n }\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context { magpie: ReturnType<typeof createMagpieService> }\n}\n\n/** Volatile Config fields surface as cells with a live `get()`. */\nfunction cell<T>(value: Cell<T>): T {\n const get = (value as { get?: () => T })?.get\n return typeof get === 'function' ? get.call(value) : value as T\n}\n\nexport function apply(ctx: Context, config: ResolvedConfig): void {\n const host = ctx as Host\n const ownNamespace = (ctx.fiber as unknown as { entry?: { options?: { id?: string } } } | undefined)?.entry?.options?.id ?? 'magpie'\n const options = (): MagpieOptions => ({\n address: (cell(config.address) || DEFAULT_ADDRESS).trim() || DEFAULT_ADDRESS,\n apiKeyEnv: (cell(config.apiKeyEnv) || DEFAULT_KEY_REF).trim() || DEFAULT_KEY_REF,\n syncOnStart: cell(config.syncOnStart) ?? true,\n defaultModel: cell(config.defaultModel) || undefined,\n webSearch: cell(config.webSearch) ?? false,\n webSearchModel: cell(config.webSearchModel) || undefined,\n })\n // The credential store is optional: headless hosts ship none; the service\n // then reads the key ref from the environment at call time.\n const credentialHolder: { current?: CredentialsLike } = {}\n const service = createMagpieService({\n describe: () => host.settings.describe() as SettingsDescriptorLike[],\n mutate: (ns, ops, revision) => host.settings.mutate(ns, ops, revision),\n writable: () => host.settings.writable,\n credentials: () => credentialHolder.current,\n ownNamespace,\n options,\n userAgent: `deepseek-harness dsh-magpie/${PLUGIN_VERSION}`,\n logger: ctx.logger,\n })\n ctx.provide('magpie', service)\n ctx.inject(['credentials'], child => {\n credentialHolder.current = (child as Context & { credentials: CredentialsLike }).credentials\n child.effect(() => () => { credentialHolder.current = undefined }, 'magpie.credentials')\n })\n ctx.effect(() => host.settings.configure({ auto: false }), 'magpie.settings-page')\n // The settings page RPC needs the optional web host; headless/ACP hosts skip it.\n ctx.inject(['connection', 'webServer'], child => {\n child.effect(() => registerHostRpc(child as Context & HostRpcContext, RPC_CHANNEL,\n (endpoint, payload, signal): Promise<RpcResult> => service.handleRpc(endpoint, payload, signal)),\n 'magpie.rpc')\n })\n ctx.effect(() => {\n let settled = true\n void host.loader.await()\n .then(() => {\n if (!settled || !options().syncOnStart) return\n // One startup sync per process; failures land in status, not a crash.\n void service.sync().then(result => {\n if (result.lastError) ctx.logger.warn('magpie: startup sync failed: %s', result.lastError.message)\n })\n })\n .catch((error: unknown) => ctx.logger.warn('magpie: loader wait failed: %s', (error as Error).message))\n return () => { settled = false }\n }, 'magpie.startup-sync')\n}\n\nexport { createMagpieService } from './service.ts'\nexport { normalizeGatewayAddress, isLoopbackHost, AddressError } from './address.ts'\nexport { buildRoutes, isSelectableModel, modelProtocol, endpointProtocol } from './mapping.ts'\nexport { planSync, planDisconnect, deepEqual } from './plan.ts'\nexport type { MagpieStatus, MagpieOptions, RouteModel, RpcResult, TestResult } from './contracts.ts'\n"],"mappings":";;;;;;;;AAKA,IAAa,eAAb,cAAkC,MAAM;CACtC,OAAgB;AAClB;AASA,MAAM,SAAS;AAEf,SAAgB,eAAe,UAA2B;CACxD,MAAM,OAAO,SAAS,QAAQ,YAAY,EAAE,CAAC,CAAC,YAAY;CAC1D,IAAI,SAAS,eAAe,SAAS,SAAS,SAAS,mBAAmB,OAAO;CACjF,OAAO,wBAAwB,KAAK,IAAI;AAC1C;;AAGA,SAAgB,wBAAwB,OAA+B;CACrE,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,CAAC,SAAS,MAA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ACrE,gBAAgB,KAAK,SAAS;EAC9B,mBAAmB,iBAAiB;EACpC;EACA;EACA,WAAW,+BAA+B;EAC1C,QAAQ,IAAI;CACd,CAAC;CACD,IAAI,QAAQ,UAAU,OAAO;CAC7B,IAAI,OAAO,CAAC,aAAa,IAAG,UAAS;EACnC,iBAAiB,UAAW,MAAqD;EACjF,MAAM,mBAAmB;GAAE,iBAAiB,UAAU,KAAA;EAAU,GAAG,oBAAoB;CACzF,CAAC;CACD,IAAI,aAAa,KAAK,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC,GAAG,sBAAsB;CAEjF,IAAI,OAAO,CAAC,cAAc,WAAW,IAAG,UAAS;EAC/C,MAAM,aAAa,gBAAgB,OAAmC,cACnE,UAAU,SAAS,WAA+B,QAAQ,UAAU,UAAU,SAAS,MAAM,CAAC,GACjG,YAAY;CACd,CAAC;CACD,IAAI,aAAa;EACf,IAAI,UAAU;EACd,KAAU,OAAO,MAAM,CAAC,CACrB,WAAW;GACV,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,aAAa;GAExC,QAAa,KAAK,CAAC,CAAC,MAAK,WAAU;IACjC,IAAI,OAAO,WAAW,IAAI,OAAO,KAAK,mCAAmC,OAAO,UAAU,OAAO;GACnG,CAAC;EACH,CAAC,CAAC,CACD,OAAO,UAAmB,IAAI,OAAO,KAAK,kCAAmC,MAAgB,OAAO,CAAC;EACxG,aAAa;GAAE,UAAU;EAAM;CACjC,GAAG,qBAAqB;AAC1B"}
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,139 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarkxy/dsh-magpie",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Connect DSH to a magpie gateway on this computer, your local network or elsewhere, and sync its models, default model and web search.",
|
|
5
|
+
"icon": "./icon.svg",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22",
|
|
10
|
+
"dsh": ">=0.2.1-rc.1"
|
|
11
|
+
},
|
|
12
|
+
"main": "./lib/index.js",
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
17
|
+
"import": "./lib/index.js",
|
|
18
|
+
"default": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./contracts": {
|
|
21
|
+
"types": "./lib/contracts.d.ts",
|
|
22
|
+
"import": "./lib/contracts.js",
|
|
23
|
+
"default": "./lib/contracts.js"
|
|
24
|
+
},
|
|
25
|
+
"./client": {
|
|
26
|
+
"default": "./lib/client.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./locale/*.json": "./locale/*.json"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"icon.svg",
|
|
33
|
+
"locale/*.json",
|
|
34
|
+
"lib",
|
|
35
|
+
"cordis.patch.yml",
|
|
36
|
+
"README.md",
|
|
37
|
+
"docs/README.zh-CN.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"dsh": {
|
|
41
|
+
"bundle": {
|
|
42
|
+
"patch": "./cordis.patch.yml"
|
|
43
|
+
},
|
|
44
|
+
"client": {
|
|
45
|
+
"platform": "web",
|
|
46
|
+
"inject": [
|
|
47
|
+
"@deepseek-ai/dsh-client-connection",
|
|
48
|
+
"@deepseek-ai/dsh-client-locale",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"dshEditor": {
|
|
55
|
+
"role": "feature",
|
|
56
|
+
"visibility": "public",
|
|
57
|
+
"wrapClient": true,
|
|
58
|
+
"entries": [
|
|
59
|
+
{
|
|
60
|
+
"id": "magpie",
|
|
61
|
+
"title": "Magpie",
|
|
62
|
+
"description": "把 DSH 连接到本机、局域网或其他位置的 magpie 网关,同步模型、默认模型和网络搜索。",
|
|
63
|
+
"feature": "magpie",
|
|
64
|
+
"service": "magpie"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsdown && node ../../scripts/editor-plugins/wrap-client.mjs @klarkxy/dsh-magpie",
|
|
70
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
71
|
+
"test": "vitest run --root ../.. --config vitest.editor-plugins.config.ts --maxWorkers=2 plugins/dsh-magpie"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@klarkxy/dsh-plugin-kit": "0.5.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@deepseek-ai/cordis": ">=4.0.4",
|
|
78
|
+
"@deepseek-ai/schemastery": ">=3.18.4",
|
|
79
|
+
"@deepseek-ai/dsh-credentials": ">=0.2.1-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-llm-pi-ai": ">=0.2.1-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-settings": ">=0.2.1-rc.1"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"@deepseek-ai/cordis": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"@deepseek-ai/schemastery": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"@deepseek-ai/dsh-credentials": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@deepseek-ai/dsh-llm-pi-ai": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@deepseek-ai/dsh-settings": {
|
|
97
|
+
"optional": true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"devDependencies": {
|
|
101
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
102
|
+
"@deepseek-ai/schemastery": "3.18.5",
|
|
103
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-rc.1",
|
|
104
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.1",
|
|
105
|
+
"@deepseek-ai/dsh-settings": "0.2.1-rc.1",
|
|
106
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.1",
|
|
107
|
+
"react": "^18.2.0",
|
|
108
|
+
"react-dom": "^18.2.0",
|
|
109
|
+
"@types/react": "18.3.31",
|
|
110
|
+
"@types/react-dom": "^18.3.0",
|
|
111
|
+
"jsdom": "29.1.1",
|
|
112
|
+
"@types/jsdom": "28.0.3",
|
|
113
|
+
"yaml": "2.9.1"
|
|
114
|
+
},
|
|
115
|
+
"keywords": [
|
|
116
|
+
"dsh",
|
|
117
|
+
"dsh-plugin",
|
|
118
|
+
"dsh-plugins",
|
|
119
|
+
"deepseek-harness",
|
|
120
|
+
"magpie",
|
|
121
|
+
"llm"
|
|
122
|
+
],
|
|
123
|
+
"repository": {
|
|
124
|
+
"type": "git",
|
|
125
|
+
"url": "git+https://github.com/klarkxy/dsh-plugins.git",
|
|
126
|
+
"directory": "plugins/dsh-magpie"
|
|
127
|
+
},
|
|
128
|
+
"homepage": "https://klarkxy.github.io/dsh-plugins/plugins/magpie/",
|
|
129
|
+
"bugs": {
|
|
130
|
+
"url": "https://github.com/klarkxy/dsh-plugins/issues"
|
|
131
|
+
},
|
|
132
|
+
"publishConfig": {
|
|
133
|
+
"access": "public",
|
|
134
|
+
"registry": "https://registry.npmjs.org/"
|
|
135
|
+
},
|
|
136
|
+
"dshRelease": {
|
|
137
|
+
"contentHash": "eb8250cc4d6d4b0883e6c34bb82a7df4a8654cc3657c7037fb6a001e45e3f7d8"
|
|
138
|
+
}
|
|
139
|
+
}
|