@banzhe/dsh-devcontainer 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -2
- package/README.zh-CN.md +80 -0
- package/cordis.patch.yml +71 -0
- package/lib/client.js +789 -0
- package/lib/client.js.map +1 -0
- package/lib/exec-CKAAz2zz.js +241 -0
- package/lib/exec-CKAAz2zz.js.map +1 -0
- package/lib/exec-_8g5fdSx.d.ts +26 -0
- package/lib/exec-_8g5fdSx.d.ts.map +1 -0
- package/lib/fs.d.ts +530 -0
- package/lib/fs.d.ts.map +1 -0
- package/lib/fs.js +1737 -0
- package/lib/fs.js.map +1 -0
- package/lib/helper/main.mjs +1008 -0
- package/lib/index.d.ts +88 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +927 -0
- package/lib/index.js.map +1 -0
- package/lib/sbx-1GsFjQBk.js +1489 -0
- package/lib/sbx-1GsFjQBk.js.map +1 -0
- package/lib/shell.d.ts +175 -0
- package/lib/shell.d.ts.map +1 -0
- package/lib/shell.js +454 -0
- package/lib/shell.js.map +1 -0
- package/lib/types-DsF9Hz5P.d.ts +33 -0
- package/lib/types-DsF9Hz5P.d.ts.map +1 -0
- package/package.json +116 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["createSnapshotStore","Button","Checkbox","Tag","styles"],"sources":["../src/ids.ts","../src/client/variants.ts","../src/client/controller.ts","../src/client/VariantsSection.tsx","../src/client/locales.ts","../src/client/index.ts"],"sourcesContent":["/**\n * The suffixes and display labels that mark a derived preset, shared by both\n * halves of the Bundle.\n *\n * Two independent tracks exist: a `… (devContainer)` variant for repositories\n * that declare a Dev Container, and a `… (sbx)` variant for Docker Sandbox\n * (`sbx`) sessions. They differ only in the suffix, the label, and the\n * `DSH_*` marker the shell row injects; everything else about a derived preset\n * is identical, so one module owns the naming for both.\n *\n * The browser half needs these to keep derived presets out of its own picker\n * list, and must not import the Host modules to get them: this file has no\n * imports.\n */\n\n/** Appended to a source preset id to name its Dev Container variant. */\nexport const DEVCONTAINER_VARIANT_SUFFIX = '-devcontainer'\n\n/** Appended to a source preset id to name its Docker Sandbox variant. */\nexport const SBX_VARIANT_SUFFIX = '-sbx'\n\n/** Appended to a source preset's display name for the Dev Container variant. */\nexport const DEVCONTAINER_NAME_SUFFIX = ' (devContainer)'\n\n/** Appended to a source preset's display name for the Docker Sandbox variant. */\nexport const SBX_NAME_SUFFIX = ' (sbx)'\n\n/** Which runtime a derived preset targets. */\nexport type VariantKind = 'devcontainer' | 'sbx'\n\n/** Every kind, in the order the planner emits them. */\nexport const VARIANT_KINDS: readonly VariantKind[] = ['devcontainer', 'sbx']\n\n/**\n * The id suffix of one track.\n * @param kind - the track.\n * @returns `-devcontainer` or `-sbx`.\n */\nexport function variantSuffixOf(kind: VariantKind): string {\n return kind === 'sbx' ? SBX_VARIANT_SUFFIX : DEVCONTAINER_VARIANT_SUFFIX\n}\n\n/**\n * The display-name suffix of one track.\n * @param kind - the track.\n * @returns ` (devContainer)` or ` (sbx)`.\n */\nexport function variantNameSuffixOf(kind: VariantKind): string {\n return kind === 'sbx' ? SBX_NAME_SUFFIX : DEVCONTAINER_NAME_SUFFIX\n}\n\n/**\n * The derived id of one source preset on one track.\n * @param source - the source preset id.\n * @param kind - the track the variant belongs to.\n * @returns the variant id.\n */\nexport function variantIdOf(source: string, kind: VariantKind): string {\n return `${source}${variantSuffixOf(kind)}`\n}\n\n/**\n * The track one variant id belongs to.\n * @param id - any preset id.\n * @returns the track, or undefined when the id names no derived preset.\n */\nexport function variantKindOf(id: string): VariantKind | undefined {\n // The Dev Container suffix is checked first: it is the older of the two, and\n // no id can carry both.\n if (id.endsWith(DEVCONTAINER_VARIANT_SUFFIX)) return 'devcontainer'\n if (id.endsWith(SBX_VARIANT_SUFFIX)) return 'sbx'\n return undefined\n}\n\n/**\n * Whether an id names a `… (devContainer)` preset.\n * @param id - any preset id.\n * @returns true when the id carries the Dev Container suffix.\n */\nexport function isDevcontainerVariantId(id: string): boolean {\n return id.endsWith(DEVCONTAINER_VARIANT_SUFFIX)\n}\n\n/**\n * Whether an id names a `… (sbx)` preset.\n * @param id - any preset id.\n * @returns true when the id carries the Docker Sandbox suffix.\n */\nexport function isSbxVariantId(id: string): boolean {\n return id.endsWith(SBX_VARIANT_SUFFIX)\n}\n\n/**\n * Whether an id names a preset this Bundle derived, on either track.\n * @param id - any preset id.\n * @returns true when the id carries either variant suffix.\n */\nexport function isAnyVariantId(id: string): boolean {\n return variantKindOf(id) !== undefined\n}\n","/**\n * The settings page's data rules, as pure functions.\n *\n * Each derivative track has its own stored list and its own derived ids:\n * `sources` is the `(devContainer)` track and `sbxSources` the `(sbx)` track, so a\n * row's \"derived\" answer is always relative to the track that asked.\n *\n * The page lists the presets a person can derive from, which is the roster\n * MINUS every variant this Bundle already registered: offering\n * `standard-devcontainer` as a source would derive `standard-devcontainer-devcontainer`.\n */\nimport type { AgentPresetRow, AgentPresetRoster } from '@deepseek-ai/dsh-agent-preset-registry/types'\nimport { isAnyVariantId, variantIdOf, type VariantKind } from '../ids.ts'\n\n/**\n * The two stored source lists, one per derivative track.\n *\n * These are field names of the `devcontainer` settings namespace, and the Host\n * row reads exactly the same pair.\n */\nexport const SOURCE_FIELDS = {\n devcontainer: 'sources',\n sbx: 'sbxSources',\n} as const satisfies Record<VariantKind, string>\n\n/** One selectable source row. */\nexport interface SelectablePreset {\n /** Stable preset id: what the checkbox writes. */\n readonly id: string\n /** The preset's published name, or the id when it published none. */\n readonly name: string\n /** The preset's own one-line description, when it published one. */\n readonly description: string\n /** Whether THIS track's variant is registered right now. */\n readonly derived: boolean\n /**\n * The registry's diagnostic for this track's variant, when it registered but\n * could not mount. A variant the picker hides must never read as \"available\".\n */\n readonly variantBroken?: string\n /** Whether this track's stored list asks for its variant. */\n readonly checked: boolean\n /** The registry's activation diagnostic, when this preset could not be mounted. */\n readonly broken?: string\n}\n\n/**\n * The stored ids of one track.\n * @param section - the namespace value as the Host published it, possibly before the first read.\n * @param field - the settings field holding that track's list.\n * @returns every non-empty string id it lists, in written order.\n */\nfunction idsOf(section: unknown, field: string): string[] {\n if (typeof section !== 'object' || section === null) return []\n const raw: unknown = Reflect.get(section, field)\n if (!Array.isArray(raw)) return []\n return raw.filter((id): id is string => typeof id === 'string' && id.length > 0)\n}\n\n/**\n * The stored `(devContainer)` source list of one form value.\n * @param section - the namespace value as the Host published it, possibly before the first read.\n * @returns every non-empty string id it lists, in written order.\n */\nexport function sourcesOf(section: unknown): string[] {\n return idsOf(section, SOURCE_FIELDS.devcontainer)\n}\n\n/**\n * The stored `(sbx)` source list of one form value.\n * @param section - the namespace value as the Host published it, possibly before the first read.\n * @returns every non-empty string id it lists, in written order.\n */\nexport function sbxSourcesOf(section: unknown): string[] {\n return idsOf(section, SOURCE_FIELDS.sbx)\n}\n\n/**\n * The variant ids the roster currently carries.\n * @param roster - the roster the Host answered with.\n * @returns the derived preset ids it contains.\n */\nfunction rowsOf(roster: unknown): readonly AgentPresetRow[] {\n if (roster === null || typeof roster !== 'object') return []\n const presets: unknown = (roster as { presets?: unknown }).presets\n return Array.isArray(presets) ? presets as readonly AgentPresetRow[] : []\n}\n\n/**\n * The rows one track offers.\n *\n * Source presets keep the Host's roster order; a variant of either track never\n * appears as a source. `checked` follows the STORED list rather than the roster,\n * because a registration that failed still needs a row a person can uncheck.\n * @param roster - the full roster from the Host.\n * @param sources - the stored list of source ids on this track.\n * @param kind - the derivative track whose variants the rows report.\n * @returns one row per selectable preset.\n */\nexport function selectablePresets(\n roster: AgentPresetRoster,\n sources: readonly string[],\n kind: VariantKind = 'devcontainer',\n): SelectablePreset[] {\n const wanted = new Set(sources)\n const rows = rowsOf(roster)\n const byId = new Map(rows.map(preset => [preset.id, preset]))\n return rows\n .filter(preset => !isAnyVariantId(preset.id))\n .map((preset) => {\n const variant = byId.get(variantIdOf(preset.id, kind))\n return {\n id: preset.id,\n name: preset.name ?? preset.id,\n description: preset.description ?? '',\n derived: variant !== undefined,\n checked: wanted.has(preset.id),\n ...preset.broken === undefined ? {} : { broken: preset.broken },\n ...variant?.broken === undefined ? {} : { variantBroken: variant.broken },\n }\n })\n}\n\n/**\n * Whether one row may be checked: a preset the registry could not mount derives\n * a variant that cannot mount either, so offering it would only strand the page.\n * @param row - the row to test.\n * @returns false when the row is broken and not already stored.\n */\nexport function selectable(row: SelectablePreset): boolean {\n return row.broken === undefined || row.checked\n}\n\n/**\n * The stored list one checkbox produces.\n * @param sources - the ids currently stored, in written order.\n * @param id - the preset the row owns.\n * @param checked - whether that preset's variant is now wanted.\n * @returns the next stored order: existing ids keep their place, an added id goes last.\n */\nexport function nextSources(sources: readonly string[], id: string, checked: boolean): string[] {\n if (!checked) return sources.filter(held => held !== id)\n return sources.includes(id) ? [...sources] : [...sources, id]\n}\n","/**\n * Staged state for the Dev Container variants page.\n *\n * Reads the roster through `ctx.remote.agentPresets.list` — the same listing\n * every picker reads — and writes BOTH stored source lists (`sources` for the\n * `(devContainer)` track, `sbxSources` for the `(sbx)` track) through the shared\n * `ConfigForm` of the `devcontainer` settings namespace. A write lands in the\n * profile patch and in the Host's live reference, and the Host re-derives the\n * variant set while the same event is still settling, so checking a box is felt\n * before the next render.\n *\n * Toggles are queued rather than dropped: each write carries the WHOLE pair of\n * lists, and a person clearing two rows in a row must not lose the second click.\n */\nimport { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'\nimport type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-preset-registry/types'\nimport type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'\nimport type { SettingsPathOpView } from '@deepseek-ai/dsh-api-remotes/client'\nimport {\n nextSources, selectable, selectablePresets, SOURCE_FIELDS, sbxSourcesOf, sourcesOf, type SelectablePreset,\n} from './variants.ts'\n\n/** The settings namespace this page edits: also the Host Loader row id. */\nexport const DEVCONTAINER_NS = 'devcontainer'\n\n/** The namespace section as the Host publishes it. */\nexport interface DevcontainerVariantsSettings {\n /** Source preset ids whose `(devContainer)` variants are wanted; absent before the first Host read. */\n sources?: readonly string[]\n /** Source preset ids whose `(sbx)` variants are wanted; absent before the first Host read. */\n sbxSources?: readonly string[]\n}\n\n/** One row as the page renders it. */\nexport type VariantRow = SelectablePreset\n\n/** What a failed read or write means for the page's own copy. */\nexport type VariantsFailure = 'load' | 'write'\n\n/** Page snapshot the renderer subscribes to. */\nexport interface VariantsState {\n /** `loading` until the roster arrives, `unavailable` when the Host serves no such namespace. */\n readonly status: 'loading' | 'ready' | 'error' | 'unavailable'\n /** The failure the page must explain, if any. */\n readonly failure: VariantsFailure | null\n /** Whether the Host accepts writes to this namespace. */\n readonly writable: boolean\n /** Whether a toggle is crossing the wire or still queued. */\n readonly saving: boolean\n /** Every selectable source preset, in Host roster order, with its `(devContainer)` state. */\n readonly rows: readonly VariantRow[]\n /** The same presets, with their `(sbx)` state. */\n readonly sbxRows: readonly VariantRow[]\n /** How many rows have a `(devContainer)` variant derived right now. */\n readonly checkedCount: number\n /** How many rows have an `(sbx)` variant derived right now. */\n readonly sbxCheckedCount: number\n}\n\n/** Business face the page receives (the framework binds `hooks` to a selector hook). */\nexport interface VariantsFace {\n hooks: { devcontainerVariants: SnapshotStore<VariantsState> }\n /** Read the roster from the Host. */\n load: () => Promise<void>\n /** Derive or drop one preset's `(devContainer)` variant; queues behind a write already in flight. */\n setChecked: (id: string, checked: boolean) => void\n /** Flip one preset's `(sbx)` variant; queues behind a write already in flight. */\n toggleSbxSource: (sourceId: string) => void\n}\n\n/** The pair of stored lists one write carries. */\ninterface SourcesIntent {\n readonly sources: string[]\n readonly sbxSources: string[]\n}\n\nconst INITIAL: VariantsState = {\n status: 'loading',\n failure: null,\n writable: false,\n saving: false,\n rows: [],\n sbxRows: [],\n checkedCount: 0,\n sbxCheckedCount: 0,\n}\n\n/**\n * Delays between roster re-reads after a write lands.\n *\n * A landed write reaches the Host before the variants it asks for are\n * registered: the settings event is emitted first, the sync then walks the\n * presets. One immediate re-read therefore sees the old roster, and without a\n * retry the page would show every freshly checked row as pending forever.\n */\nconst VERIFY_DELAYS: readonly number[] = [80, 150, 300, 600]\n\n/**\n * The rows of one roster answer.\n *\n * A listing that reports success without a body (a namespace whose method is not\n * what this build serves) must leave the page empty rather than throw inside the\n * plugin: this page is a preference, not a critical surface.\n * @param value - the roster the Remote answered with.\n * @returns its preset rows, or none when the answer carries no roster.\n */\nexport function rosterRows(value: unknown): AgentPresetRoster['presets'] {\n if (value === null || typeof value !== 'object') return []\n const presets: unknown = (value as { presets?: unknown }).presets\n return Array.isArray(presets) ? presets as AgentPresetRoster['presets'] : []\n}\n\n/** Resolve after one delay, so a test can drive the clock. */\nfunction wait(ms: number): Promise<void> {\n return new Promise((resolve) => { setTimeout(resolve, ms) })\n}\n\n/**\n * One roster read.\n *\n * Structural rather than `RemoteResult` so a build that serves no such namespace\n * can answer \"not readable\" without fabricating a carrier error: success carries\n * the roster, anything else is a failed read.\n */\nexport type RosterListing = () => Promise<{ readonly ok: boolean, readonly value?: unknown }>\n\n/** Reads the roster and writes the two source lists for one page instance. */\nexport class VariantsController {\n private declared: AgentPresetRoster['presets'] = []\n private failure: VariantsFailure | null = null\n private loading = true\n /** The lists the queue will send next; undefined when every toggle has landed. */\n private intent: SourcesIntent | undefined\n private writing = false\n /** Invalidates every read that a newer load, or a dispose, supersedes. */\n private generation = 0\n private disposed = false\n private readonly store: SnapshotStore<VariantsState> = createSnapshotStore(INITIAL)\n private readonly unsubscribe: () => void\n\n /**\n * @param form - the shared form of the `devcontainer` settings namespace.\n * @param listing - the roster listing the pickers read.\n */\n constructor(\n private readonly form: ConfigForm<DevcontainerVariantsSettings>,\n private readonly listing: RosterListing,\n ) {\n // Another editor of the same namespace (a second tab, an SSH session) moves\n // the stored lists under this page, so the rows follow the form, not a copy.\n this.unsubscribe = form.subscribe(() => { this.publish() })\n }\n\n dispose(): void {\n this.disposed = true\n this.generation += 1\n this.unsubscribe()\n }\n\n inject(): VariantsFace {\n return {\n hooks: { devcontainerVariants: this.store },\n load: () => this.load(),\n setChecked: (id, checked) => { this.setChecked(id, checked) },\n toggleSbxSource: (sourceId) => { this.toggleSbxSource(sourceId) },\n }\n }\n\n /** Read the roster the pickers read. */\n async load(): Promise<void> {\n await this.refresh(false)\n void this.settle()\n }\n\n /**\n * Re-read the roster without flipping the page back to `loading`.\n * @param quiet - true when a previous render must stay on screen while it refreshes.\n */\n private async refresh(quiet: boolean): Promise<void> {\n if (this.disposed) return\n const generation = ++this.generation\n if (!quiet) {\n this.loading = true\n this.publish()\n }\n const result = await this.listing()\n if (generation !== this.generation) return\n this.loading = false\n if (result.ok) {\n this.declared = rosterRows(result.value)\n this.failure = null\n } else {\n this.declared = []\n this.failure = 'load'\n }\n this.publish()\n }\n\n /**\n * Re-read the roster a few times while a write's registrations settle.\n *\n * The first re-read after a landed write races the Host's own sync, so the\n * variants it asks for may still be missing. Retrying with backoff turns the\n * \"waiting to be registered\" badge into the real state within a second, and\n * stops as soon as nothing is outstanding.\n */\n private async settle(): Promise<void> {\n for (const delay of VERIFY_DELAYS) {\n if (!this.polling()) return\n await wait(delay)\n if (!this.polling()) return\n await this.refresh(true)\n }\n }\n\n /** Whether another retry is still both wanted and possible. */\n private polling(): boolean {\n return !this.disposed && this.outstanding()\n }\n\n /** Whether a stored row of either track is still waiting for its variant to register. */\n private outstanding(): boolean {\n const stored = this.effective(this.form.getSnapshot().value)\n const roster = { presets: this.declared }\n return selectablePresets(roster, stored.sources, 'devcontainer').some(pending)\n || selectablePresets(roster, stored.sbxSources, 'sbx').some(pending)\n }\n\n /** Derive or drop one preset's `(devContainer)` variant, without losing a toggle that arrives mid-write. */\n setChecked(id: string, checked: boolean): void {\n const stored = this.stage()\n if (stored === undefined) return\n this.commit({ ...stored, sources: nextSources(stored.sources, id, checked) })\n }\n\n /**\n * Flip one preset's `(sbx)` variant.\n *\n * A toggle rather than a target state because the checkbox renders the\n * effective list: whatever the person saw checked is what flips, including a\n * toggle that is still queued behind a write in flight.\n * @param sourceId - the source preset whose `(sbx)` variant flips.\n */\n toggleSbxSource(sourceId: string): void {\n const stored = this.stage()\n if (stored === undefined) return\n const checked = !stored.sbxSources.includes(sourceId)\n this.commit({ ...stored, sbxSources: nextSources(stored.sbxSources, sourceId, checked) })\n }\n\n /**\n * The lists a toggle starts from, or undefined when this page must ignore it.\n * @returns the queued lists when a write is still pending, otherwise the stored ones.\n */\n private stage(): SourcesIntent | undefined {\n if (this.disposed) return undefined\n const snapshot = this.form.getSnapshot()\n if (!snapshot.writable) return undefined\n return this.effective(snapshot.value)\n }\n\n /** Queue one toggle and start the write that carries it. */\n private commit(next: SourcesIntent): void {\n this.intent = next\n this.publish()\n void this.flush()\n }\n\n /**\n * The lists to render: the queued ones while a write is in flight, otherwise\n * the ones the Host stored.\n */\n private effective(section: unknown): SourcesIntent {\n if (this.intent !== undefined) return this.intent\n return { sources: sourcesOf(section), sbxSources: sbxSourcesOf(section) }\n }\n\n /**\n * Send the queued lists until nothing is queued.\n *\n * Both fields travel in ONE mutation, so a single revision fence accepts or\n * refuses the pair together: a deployment can never store one track's toggle\n * and drop the other's.\n *\n * A refusal drops the queue: those intents were derived from lists the Host\n * never stored, so replaying them would toggle a different set than the one the\n * person was looking at. After a landed write the roster is re-read, because\n * the Host may have just registered or disposed a variant.\n */\n private async flush(): Promise<void> {\n if (this.writing) return\n this.writing = true\n this.publish()\n let landed = false\n try {\n while (this.intent !== undefined) {\n const next = this.intent\n const accepted = await this.form.mutate(opsFor(next))\n this.failure = accepted ? null : 'write'\n if (!accepted) break\n landed = true\n if (this.intent === next) this.intent = undefined\n this.publish()\n }\n } catch {\n this.failure = 'write'\n } finally {\n this.intent = undefined\n this.writing = false\n this.publish()\n }\n if (landed && !this.disposed) {\n await this.refresh(true)\n await this.settle()\n }\n }\n\n private publish(): void {\n if (this.disposed) return\n const snapshot = this.form.getSnapshot()\n const stored = this.effective(snapshot.value)\n const roster = { presets: this.declared }\n const rows = selectablePresets(roster, stored.sources, 'devcontainer')\n const sbxRows = selectablePresets(roster, stored.sbxSources, 'sbx')\n this.store.set({\n status: snapshot.status === 'unavailable'\n ? 'unavailable'\n : this.failure === 'load' ? 'error'\n : this.loading || snapshot.status === 'loading' ? 'loading' : 'ready',\n failure: this.failure,\n writable: snapshot.writable,\n saving: this.writing || this.intent !== undefined,\n rows,\n sbxRows,\n checkedCount: rows.filter(row => row.checked).length,\n sbxCheckedCount: sbxRows.filter(row => row.checked).length,\n })\n }\n}\n\n/** Whether one row is stored but its variant is not registered yet. */\nfunction pending(row: SelectablePreset): boolean {\n return row.checked && !row.derived && selectable(row)\n}\n\n/**\n * One mutation carrying both stored lists.\n * @param intent - the lists to store.\n * @returns the settings operations, in track order.\n */\nfunction opsFor(intent: SourcesIntent): SettingsPathOpView[] {\n return [\n { op: 'set', path: [SOURCE_FIELDS.devcontainer], value: intent.sources },\n { op: 'set', path: [SOURCE_FIELDS.sbx], value: intent.sbxSources },\n ]\n}\n","/**\n * The Dev Container variants page: two independent tracks, one checkbox per\n * source preset on each.\n *\n * A checkbox, not a dropdown, because each track is a SET rather than one\n * choice, and `Checkbox` is the primitive the shipped settings rows already use\n * for the same shape. Checked means \"derive my copy on this track\".\n *\n * The row's tail carries the truth from the Host: a checked box whose variant is\n * not in the roster yet says so (`pendingBadge`), and a preset the registry could\n * not mount says so too (`brokenBadge`) — its variant could not mount either, so\n * it is offered read-only rather than stranding the person with a pending row.\n */\nimport { useEffect, type ReactNode } from 'react'\nimport { Button, Checkbox, Tag } from '@deepseek-ai/dsh-client-ui-primitives'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport { variantNameSuffixOf, type VariantKind } from '../ids.ts'\nimport type { VariantRow, VariantsFace, VariantsState } from './controller.ts'\nimport { selectable } from './variants.ts'\nimport type { DevcontainerVariantsKey } from './locales.ts'\n\nexport type DevcontainerVariantsSectionProps =\n PropsRuntime<'settings.section'>\n & PropsLocale<'devcontainer'>\n & InjectFace<VariantsFace>\n\n/** The translating seat the section and its track groups receive. */\ntype Translate = DevcontainerVariantsSectionProps['t']\n\n/** The dictionary keys one track reads for its own copy. */\ninterface TrackCopy {\n readonly title: DevcontainerVariantsKey\n readonly description: DevcontainerVariantsKey\n readonly empty: DevcontainerVariantsKey\n readonly none: DevcontainerVariantsKey\n readonly count: DevcontainerVariantsKey\n}\n\n/** Copy per track: the two groups differ only in their words and their suffix. */\nconst COPY: Record<VariantKind, TrackCopy> = {\n devcontainer: {\n title: 'devcontainerTitle',\n description: 'devcontainerDescription',\n empty: 'empty',\n none: 'noneChecked',\n count: 'checkedCount',\n },\n sbx: {\n title: 'sbxTitle',\n description: 'sbxDescription',\n empty: 'sbxEmpty',\n none: 'sbxNoneChecked',\n count: 'sbxCheckedCount',\n },\n}\n\n/** One track's rendered rows and the toggle they call. */\ninterface TrackInput {\n readonly kind: VariantKind\n readonly rows: VariantsState['rows']\n readonly checkedCount: number\n readonly disabled: boolean\n readonly onToggle: (id: string, checked: boolean) => void\n}\n\n/**\n * Render the selectable presets on both tracks, each with one derivation toggle\n * per row.\n * @param props - settings actions, the page snapshot hook, and localized copy.\n * @returns The Dev Container variants settings section.\n */\nexport function DevcontainerVariantsSection(props: DevcontainerVariantsSectionProps): ReactNode {\n const { t, load } = props\n const state = props.useDevcontainerVariants(snapshot => snapshot)\n useEffect(() => { void load() }, [load])\n // A write in flight does not lock the rows: the controller queues a toggle that\n // lands mid-write, so a person checking several rows keeps every click.\n const disabled = !state.writable\n return (\n <section className=\"dcv-section\">\n <h2 className=\"dcv-title\">{t('nav')}</h2>\n <p className=\"dcv-intro\">{t('intro')}</p>\n {state.failure === 'load'\n ? (\n <p className=\"dcv-notice\" data-failed=\"true\" role=\"alert\">\n {t('failed')}{' '}\n <Button variant=\"ghost\" disabled={disabled} onClick={() => { void load() }}>{t('retry')}</Button>\n </p>\n )\n : null}\n {state.failure === 'write'\n ? <p className=\"dcv-notice\" data-failed=\"true\" role=\"alert\">{t('writeFailed')}</p>\n : null}\n {state.status === 'unavailable' ? <p className=\"dcv-notice\">{t('unavailable')}</p> : null}\n {state.status === 'loading' ? <p className=\"dcv-notice\" role=\"status\">{t('loading')}</p> : null}\n {state.status === 'ready' && !state.writable ? <p className=\"dcv-notice\">{t('readOnly')}</p> : null}\n {state.status === 'ready'\n ? (\n <>\n {renderTrack(t, {\n kind: 'devcontainer',\n rows: state.rows,\n checkedCount: state.checkedCount,\n disabled,\n onToggle: (id, checked) => { props.setChecked(id, checked) },\n })}\n {renderTrack(t, {\n kind: 'sbx',\n rows: state.sbxRows,\n checkedCount: state.sbxCheckedCount,\n disabled,\n // The sbx box renders the effective list, so flipping it is the\n // whole intent: the controller derives the target state itself.\n onToggle: (id) => { props.toggleSbxSource(id) },\n })}\n <p className=\"dcv-notice\">{t('refreshHint')}</p>\n </>\n )\n : null}\n </section>\n )\n}\n\n/**\n * One track's card: its heading with the preset-name suffix, what the track is,\n * how much of it is derived, and the rows themselves.\n * @param t - the localized copy seat.\n * @param input - the track, its rows, and its toggle.\n * @returns The rendered group.\n */\nfunction renderTrack(t: Translate, input: TrackInput): ReactNode {\n const copy = COPY[input.kind]\n return (\n <div className=\"dcv-group\" data-track={input.kind}>\n <h3 className=\"dcv-group-title\">\n {t(copy.title)}\n <code className=\"dcv-suffix\">{variantNameSuffixOf(input.kind).trim()}</code>\n </h3>\n <p className=\"dcv-group-description\">{t(copy.description)}</p>\n <p className=\"dcv-count\">\n {input.rows.length === 0\n ? t(copy.empty)\n : input.checkedCount === 0 ? t(copy.none) : t(copy.count, { count: input.checkedCount })}\n </p>\n {input.rows.length === 0 ? null : (\n <ul className=\"dcv-rows\">\n {input.rows.map(row => renderRow(t, input.kind, row, input.disabled, input.onToggle))}\n </ul>\n )}\n </div>\n )\n}\n\n/**\n * One preset row: the checkbox, the preset's own description, and the Host's\n * verdict on this track's variant.\n * @param t - the localized copy seat.\n * @param kind - the derivative track this row belongs to.\n * @param row - the row to render.\n * @param disabled - whether the deployment refuses writes.\n * @param onToggle - the toggle for this row.\n * @returns The rendered row.\n */\nfunction renderRow(\n t: Translate,\n kind: VariantKind,\n row: VariantRow,\n disabled: boolean,\n onToggle: (id: string, checked: boolean) => void,\n): ReactNode {\n const broken = row.broken !== undefined\n return (\n <li\n key={row.id}\n className=\"dcv-row\"\n data-checked={row.checked ? 'true' : undefined}\n data-broken={broken ? 'true' : undefined}\n >\n <span className=\"dcv-main\">\n <Checkbox\n checked={row.checked}\n disabled={disabled || !selectable(row)}\n label={row.name}\n title={broken\n ? `${t('brokenBadge')}: ${row.broken ?? ''}`\n : row.variantBroken === undefined\n ? t(row.checked ? 'checked' : 'unchecked')\n : `${t('variantBrokenBadge')}: ${row.variantBroken}`}\n onChange={(next) => { onToggle(row.id, next) }}\n />\n {row.description === '' ? null : (\n // Both tracks list the same preset ids, so the anchor carries the track.\n <span className=\"dcv-description\" id={`dcv-description-${kind}-${row.id}`}>{row.description}</span>\n )}\n </span>\n <span className=\"dcv-tail\">\n {row.name === row.id ? null : <code className=\"dcv-id\">{row.id}</code>}\n {broken ? <Tag tone=\"danger\">{t('brokenBadge')}</Tag> : null}\n {row.checked\n ? row.variantBroken === undefined\n ? <Tag tone={row.derived ? 'success' : 'warning'}>{t(row.derived ? 'derivedBadge' : 'pendingBadge')}</Tag>\n : <Tag tone=\"danger\">{t('variantBrokenBadge')}</Tag>\n : null}\n <span className=\"dcv-state\" data-checked={row.checked ? 'true' : undefined}>\n {t(row.checked ? 'checked' : 'unchecked')}\n </span>\n </span>\n </li>\n )\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n devcontainer: DevcontainerVariantsKey\n }\n}\n","/** Locale bundles for the Dev Container variants page (namespace `devcontainer`). */\n\nexport type DevcontainerVariantsKey =\n | 'nav' | 'intro'\n | 'devcontainerTitle' | 'devcontainerDescription' | 'sbxTitle' | 'sbxDescription'\n | 'checked' | 'unchecked' | 'derivedBadge' | 'pendingBadge' | 'brokenBadge' | 'variantBrokenBadge'\n | 'noneChecked' | 'checkedCount' | 'sbxNoneChecked' | 'sbxCheckedCount'\n | 'loading' | 'failed' | 'retry' | 'unavailable' | 'readOnly'\n | 'writeFailed' | 'refreshHint' | 'empty' | 'sbxEmpty'\n\nexport const en: Record<DevcontainerVariantsKey, string> = {\n nav: 'Dev Container presets',\n intro: 'Check a preset to derive copies of it. A “(devContainer)” copy sends every command into the repository\\'s Linux Dev Container; an “(sbx)” copy runs in a Docker Sandbox. The two tracks are independent, nothing is derived until you check something, and a copy disappears again as soon as you clear its box.',\n devcontainerTitle: 'Dev Container runtime',\n devcontainerDescription: 'The regular container environment built from the repository\\'s .devcontainer declaration: every command runs inside the Linux container the Dev Container CLI builds and starts.',\n sbxTitle: 'Docker Sandbox runtime',\n sbxDescription: 'Hardware-isolated execution in a Docker Sandbox (MicroVM): each session gets its own micro VM with Docker ready to build out of the box, and no repository declaration is needed.',\n checked: 'derived',\n unchecked: 'not derived',\n derivedBadge: 'Available',\n pendingBadge: 'Wait for it',\n brokenBadge: 'Cannot load',\n variantBrokenBadge: 'Variant cannot mount',\n noneChecked: 'No preset is derived.',\n checkedCount: '{count} derived',\n sbxNoneChecked: 'No Docker Sandbox copy is derived.',\n sbxCheckedCount: '{count} derived as (sbx)',\n loading: 'Loading presets…',\n failed: 'Presets could not be loaded.',\n retry: 'Retry',\n unavailable: 'This plugin is not loaded, so there is nothing to configure.',\n readOnly: 'This deployment stores settings read-only.',\n writeFailed: 'The deployment did not accept this change.',\n refreshHint: 'Preset pickers re-read the roster the next time one opens.',\n empty: 'This deployment declares no preset to derive from.',\n sbxEmpty: 'This deployment declares no preset to derive a Docker Sandbox copy from.',\n}\n\nexport const zh: Record<DevcontainerVariantsKey, string> = {\n nav: 'Dev Container 预设',\n intro: '勾选一个预设即可派生它的副本:「(devContainer)」副本把每条命令送进仓库指定的 Linux Dev Container,「(sbx)」副本在 Docker Sandbox 中执行。两组互相独立,默认都不派生;取消勾选后副本立即注销。',\n devcontainerTitle: 'Dev Container 运行环境',\n devcontainerDescription: '基于仓库 .devcontainer 声明的常规容器运行环境:命令在 Dev Container CLI 构建并启动的 Linux 容器里执行。',\n sbxTitle: 'Docker Sandbox 运行环境',\n sbxDescription: '基于 Docker Sandbox (MicroVM) 的硬件级隔离执行环境:每个会话独占一台微虚拟机,开箱即用支持 Docker 构建,不依赖仓库声明。',\n checked: '已派生',\n unchecked: '未派生',\n derivedBadge: '已可用',\n pendingBadge: '等待注册',\n brokenBadge: '无法加载',\n variantBrokenBadge: '派生副本不可用',\n noneChecked: '当前没有派生任何预设。',\n checkedCount: '已派生 {count} 项',\n sbxNoneChecked: '当前没有派生任何 Docker Sandbox 副本。',\n sbxCheckedCount: '已派生 {count} 项 (sbx)',\n loading: '正在加载预设…',\n failed: '无法加载预设。',\n retry: '重试',\n unavailable: '该插件当前未加载,无需配置。',\n readOnly: '本部署的设置为只读。',\n writeFailed: '本部署没有接受这次修改。',\n refreshHint: '预设选择器下次打开时会重新读取清单。',\n empty: '本部署没有可派生的预设。',\n sbxEmpty: '本部署没有可派生 Docker Sandbox 副本的预设。',\n}\n","/**\n * Browser half: the Dev Container variants page.\n *\n * The page is a `settings.section` of its own rather than a `plugins.row.config`\n * card: this preference decides which `(devContainer)` presets exist, not how\n * this Loader row is configured, and it has to stay reachable while the row is\n * what is being configured.\n *\n * Writes go through `configForms`, so the stored list lands in the profile patch\n * and in the Host's live reference in one step; the Host row follows the same\n * namespace and re-derives its variant set on the resulting\n * `settings/document-updated` event.\n */\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\n// Type-only: the ctx.remote merge and the agentPresets namespace it carries.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms merge, the ConfigForm type, and the\n// `settings.section` SlotMap entry.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport { DEVCONTAINER_NS, VariantsController, type DevcontainerVariantsSettings } from './controller.ts'\nimport { DevcontainerVariantsSection } from './VariantsSection.tsx'\nimport { en, zh } from './locales.ts'\n// Text, not a stylesheet link: the ModuleLoader fetches one artifact, so the\n// sheet is inlined at build time. See `tsdown.config.ts`.\nimport styles from './styles.css?inline'\n\nexport type {\n DevcontainerVariantsSettings, VariantRow, VariantsFace, VariantsFailure, VariantsState,\n} from './controller.ts'\nexport type { DevcontainerVariantsKey } from './locales.ts'\nexport type { SelectablePreset } from './variants.ts'\n\n/** Plugin id, stamped onto the injected stylesheet for teardown bookkeeping. */\nconst PLUGIN_ID = '@banzhe/dsh-devcontainer'\n\nconst NS = DEVCONTAINER_NS\n\nexport const inject = ['configForms', 'locale', 'remote', 'remote.agentPresets', 'slots']\n\n// Type-only: the roster read this page performs.\nimport type { RosterListing } from './controller.ts'\n\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'devcontainer: dictionaries')\n // The page's stylesheet rides the plugin's own fiber: unload removes it. It\n // carries the shell's `--dsw-*` token values, which only resolve inside a\n // themed document, so it is a `<style>` tag installed here — not inline\n // declarations on the elements, which beat every stylesheet in the cascade.\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const tag = document.createElement('style')\n tag.dataset.plugin = PLUGIN_ID\n tag.dataset.pluginCss = `${PLUGIN_ID}/styles.css`\n tag.textContent = styles\n document.head.appendChild(tag)\n return () => { tag.remove() }\n }, 'devcontainer: stylesheet')\n\n const form = ctx.configForms.get<DevcontainerVariantsSettings>(NS)\n ctx.effect(() => ctx.configForms.whileServed([NS], () => ctx.slots.inject('settings.section', () => {\n // The shared form is owned by configForms: repeated `get` returns the same\n // controller, so this page and any other editor of the entry share one write\n // queue and one revision fence.\n const controller = new VariantsController(form, async () => {\n // A build that serves no `agentPresets` namespace reports the page as\n // unreadable instead of throwing during plugin activation.\n const namespace = ctx.remote.agentPresets as { list?: RosterListing }\n if (typeof namespace.list !== 'function') return { ok: false }\n return namespace.list()\n })\n const offSlot = ctx.slots.register({\n name: 'settings.section',\n id: NS,\n // After the visibility page (order 30): this one decides what exists at all.\n order: 31,\n label: () => ctx.locale.bind(NS)('nav'),\n locale: NS,\n inject: () => controller.inject(),\n }, DevcontainerVariantsSection)\n // Reverse order: drop the registration before releasing what renders it.\n return [offSlot, () => { controller.dispose() }]\n })), 'devcontainer: variants page')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAgBA,MAAa,8BAA8B;;EAG3C,MAAa,qBAAqB;;EAGlC,MAAa,2BAA2B;;EAGxC,MAAa,kBAAkB;;;;;;EAa/B,SAAgB,gBAAgB,MAA2B;GACzD,OAAO,SAAS,QAAQ,qBAAqB;EAC/C;;;;;;EAOA,SAAgB,oBAAoB,MAA2B;GAC7D,OAAO,SAAS,QAAQ,kBAAkB;EAC5C;;;;;;;EAQA,SAAgB,YAAY,QAAgB,MAA2B;GACrE,OAAO,GAAG,SAAS,gBAAgB,IAAI;EACzC;;;;;;EAOA,SAAgB,cAAc,IAAqC;GAGjE,IAAI,GAAG,SAAA,eAAoC,GAAG,OAAO;GACrD,IAAI,GAAG,SAAA,MAA2B,GAAG,OAAO;EAE9C;;;;;;EAyBA,SAAgB,eAAe,IAAqB;GAClD,OAAO,cAAc,EAAE,MAAM,KAAA;EAC/B;;;;;;;;;EC/EA,MAAa,gBAAgB;GAC3B,cAAc;GACd,KAAK;EACP;;;;;;;EA6BA,SAAS,MAAM,SAAkB,OAAyB;GACxD,IAAI,OAAO,YAAY,YAAY,YAAY,MAAM,OAAO,CAAC;GAC7D,MAAM,MAAe,QAAQ,IAAI,SAAS,KAAK;GAC/C,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC;GACjC,OAAO,IAAI,QAAQ,OAAqB,OAAO,OAAO,YAAY,GAAG,SAAS,CAAC;EACjF;;;;;;EAOA,SAAgB,UAAU,SAA4B;GACpD,OAAO,MAAM,SAAS,cAAc,YAAY;EAClD;;;;;;E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,SAAS;IACrB,IAAI,QAAQ,YAAY,GAAG,UAAU;IACrC,IAAI,cAAcC;IAClB,SAAS,KAAK,YAAY,GAAG;IAC7B,aAAa;KAAE,IAAI,OAAO;IAAE;GAC9B,GAAG,0BAA0B;GAE7B,MAAM,OAAO,IAAI,YAAY,IAAkC,EAAE;GACjE,IAAI,aAAa,IAAI,YAAY,YAAY,CAAC,EAAE,SAAS,IAAI,MAAM,OAAO,0BAA0B;IAIlG,MAAM,aAAa,IAAI,mBAAmB,MAAM,YAAY;KAG1D,MAAM,YAAY,IAAI,OAAO;KAC7B,IAAI,OAAO,UAAU,SAAS,YAAY,OAAO,EAAE,IAAI,MAAM;KAC7D,OAAO,UAAU,KAAK;IACxB,CAAC;IAWD,OAAO,CAVS,IAAI,MAAM,SAAS;KACjC,MAAM;KACN,IAAI;KAEJ,OAAO;KACP,aAAa,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,KAAK;KACtC,QAAQ;KACR,cAAc,WAAW,OAAO;IAClC,GAAG,2BAEW,SAAS;KAAE,WAAW,QAAQ;IAAE,CAAC;GACjD,CAAC,CAAC,GAAG,6BAA6B;EACpC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { B as toPosixSlashes, r as resolveSbxTarget } from "./sbx-1GsFjQBk.js";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { SENSITIVE_ENV_PATTERN } from "@deepseek-ai/dsh-subprocess";
|
|
4
|
+
//#region src/container.ts
|
|
5
|
+
/** Label the Dev Container CLI stamps on every container it creates. */
|
|
6
|
+
const CONTAINER_FOLDER_LABEL = "devcontainer.local_folder";
|
|
7
|
+
const PS_FORMAT = "{{.ID}} {{.Label \"devcontainer.local_folder\"}}";
|
|
8
|
+
/** Compare two host folders as one repository, folding separators and win32 case. */
|
|
9
|
+
function sameFolder(left, right) {
|
|
10
|
+
return toPosixSlashes(left).replace(/\/+$/, "").toLowerCase() === toPosixSlashes(right).replace(/\/+$/, "").toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Find the running container the Dev Container CLI started for this repository.
|
|
14
|
+
* @param spec - the repository container specification.
|
|
15
|
+
* @param run - the CLI runner.
|
|
16
|
+
* @param signal - cancellation of the probe.
|
|
17
|
+
* @returns the container id, or undefined when none is running (or Docker is absent).
|
|
18
|
+
*/
|
|
19
|
+
async function findRunningContainer(spec, run, signal) {
|
|
20
|
+
const result = await run([
|
|
21
|
+
"docker",
|
|
22
|
+
"ps",
|
|
23
|
+
"--filter",
|
|
24
|
+
`label=${CONTAINER_FOLDER_LABEL}`,
|
|
25
|
+
"--format",
|
|
26
|
+
PS_FORMAT
|
|
27
|
+
], {
|
|
28
|
+
...signal === void 0 ? {} : { signal },
|
|
29
|
+
timeoutMs: spec.containerTimeoutMs
|
|
30
|
+
});
|
|
31
|
+
if (result.exitCode !== 0) return void 0;
|
|
32
|
+
for (const line of result.stdout.split("\n")) {
|
|
33
|
+
const [id, folder] = line.split(" ");
|
|
34
|
+
if (id === void 0 || folder === void 0) continue;
|
|
35
|
+
if (id.trim() === "" || folder.trim() === "") continue;
|
|
36
|
+
if (sameFolder(folder.trim(), spec.hostWorkspaceRoot)) return id.trim();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read the container id out of `devcontainer up` output (its last JSON line).
|
|
41
|
+
* @param stdout - the CLI's standard output.
|
|
42
|
+
* @returns the container id, or undefined when the output carries none.
|
|
43
|
+
*/
|
|
44
|
+
function parseUpOutput(stdout) {
|
|
45
|
+
const lines = stdout.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("{"));
|
|
46
|
+
for (const line of lines.reverse()) try {
|
|
47
|
+
const parsed = JSON.parse(line);
|
|
48
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
49
|
+
const { containerId } = parsed;
|
|
50
|
+
if (typeof containerId === "string" && containerId !== "") return containerId;
|
|
51
|
+
}
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build and start the repository's container through the Dev Container CLI.
|
|
56
|
+
* @param spec - the repository container specification.
|
|
57
|
+
* @param run - the CLI runner.
|
|
58
|
+
* @param signal - cancellation of the CLI call.
|
|
59
|
+
* @returns the produced container id when the CLI reported one.
|
|
60
|
+
* @throws Error when the CLI failed and reported no container.
|
|
61
|
+
*/
|
|
62
|
+
async function startContainer(spec, run, signal) {
|
|
63
|
+
const result = await run([
|
|
64
|
+
"devcontainer",
|
|
65
|
+
"up",
|
|
66
|
+
"--workspace-folder",
|
|
67
|
+
spec.hostWorkspaceRoot
|
|
68
|
+
], {
|
|
69
|
+
...signal === void 0 ? {} : { signal },
|
|
70
|
+
timeoutMs: spec.containerTimeoutMs
|
|
71
|
+
});
|
|
72
|
+
const containerId = parseUpOutput(result.stdout);
|
|
73
|
+
if (result.exitCode !== 0 && containerId === void 0) {
|
|
74
|
+
const detail = (result.stderr.trim() || result.stdout.trim() || "no output").split("\n").slice(-3).join(" ");
|
|
75
|
+
throw new Error(`devcontainer: "${spec.configPath}": devcontainer up failed for ${spec.hostWorkspaceRoot}: ${detail}`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...containerId === void 0 ? {} : { containerId },
|
|
79
|
+
workspaceFolder: spec.hostWorkspaceRoot
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the container agent commands run in.
|
|
84
|
+
*
|
|
85
|
+
* `cli: 'sbx'` is not a container at all: a Docker Sandbox mounts the host
|
|
86
|
+
* workspace at its own absolute path, so it is discovered and started by
|
|
87
|
+
* {@link resolveSbxTarget} instead of by the Dev Container drivers below.
|
|
88
|
+
* @param spec - the repository container specification.
|
|
89
|
+
* @param run - the CLI runner.
|
|
90
|
+
* @param signal - cancellation of the probe / start sequence.
|
|
91
|
+
* @returns the docker target when a container id is known, else the CLI or sandbox target.
|
|
92
|
+
* @throws Error when `cli: 'docker'` was demanded and no container is running, or `sbx` cannot be prepared.
|
|
93
|
+
*/
|
|
94
|
+
async function resolveContainerTarget(spec, run, signal) {
|
|
95
|
+
if (spec.cli === "sbx") return await resolveSbxTarget(spec, run, signal);
|
|
96
|
+
if (spec.container !== void 0) return {
|
|
97
|
+
kind: "docker",
|
|
98
|
+
containerId: spec.container,
|
|
99
|
+
workspaceFolder: spec.containerWorkspaceFolder
|
|
100
|
+
};
|
|
101
|
+
if (spec.cli !== "devcontainer") {
|
|
102
|
+
const running = await findRunningContainer(spec, run, signal);
|
|
103
|
+
if (running !== void 0) return {
|
|
104
|
+
kind: "docker",
|
|
105
|
+
containerId: running,
|
|
106
|
+
workspaceFolder: spec.containerWorkspaceFolder
|
|
107
|
+
};
|
|
108
|
+
if (spec.cli === "docker") throw new Error("devcontainer: \"" + spec.configPath + `": cli is "docker" but no running container carries ${CONTAINER_FOLDER_LABEL}=${spec.hostWorkspaceRoot}; start it or set cli: "auto"`);
|
|
109
|
+
}
|
|
110
|
+
if (spec.ensureUp) {
|
|
111
|
+
const started = await startContainer(spec, run, signal);
|
|
112
|
+
if (started.containerId !== void 0) return {
|
|
113
|
+
kind: "docker",
|
|
114
|
+
containerId: started.containerId,
|
|
115
|
+
workspaceFolder: spec.containerWorkspaceFolder
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
kind: "devcontainer-cli",
|
|
119
|
+
workspaceFolder: started.workspaceFolder
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
kind: "devcontainer-cli",
|
|
124
|
+
workspaceFolder: spec.hostWorkspaceRoot
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/exec.ts
|
|
129
|
+
/**
|
|
130
|
+
* The one place this Bundle starts a host process: the Docker / Dev Container
|
|
131
|
+
* CLI probes that find or start the container, and the `docker exec` that runs
|
|
132
|
+
* the agent's command. Kept behind an interface so the container argv logic is
|
|
133
|
+
* testable without a Docker daemon.
|
|
134
|
+
* @module @banzhe/dsh-devcontainer/exec
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* Cap for one probe's captured output. The agent's own commands do not come
|
|
138
|
+
* through here — they run through the subprocess seam, which streams and caps
|
|
139
|
+
* them — so this only has to hold `devcontainer up`'s build log.
|
|
140
|
+
*/
|
|
141
|
+
const MAX_CLI_OUTPUT_BYTES = 33554432;
|
|
142
|
+
/**
|
|
143
|
+
* The parent variables a Docker / Dev Container CLI is started with.
|
|
144
|
+
*
|
|
145
|
+
* The CLI is a host program the harness runs on the user's behalf, not a proxy
|
|
146
|
+
* for the session: starting it with the ambient environment would hand the
|
|
147
|
+
* harness's own credentials, the session's `DSH_*` facts, and every unrelated
|
|
148
|
+
* host-only variable to a build that the container's `Dockerfile` can read.
|
|
149
|
+
* Only the names below survive, because the CLI itself needs each one:
|
|
150
|
+
* executable lookup and the platform runtime, the per-user Docker configuration
|
|
151
|
+
* under `HOME`/`APPDATA` (where the credential helper is named), scratch space,
|
|
152
|
+
* locale, and proxy routing.
|
|
153
|
+
*/
|
|
154
|
+
const CONTAINER_CLI_ENV_NAMES = [
|
|
155
|
+
"PATH",
|
|
156
|
+
"PATHEXT",
|
|
157
|
+
"SYSTEMROOT",
|
|
158
|
+
"SYSTEMDRIVE",
|
|
159
|
+
"WINDIR",
|
|
160
|
+
"COMSPEC",
|
|
161
|
+
"HOME",
|
|
162
|
+
"USERPROFILE",
|
|
163
|
+
"HOMEDRIVE",
|
|
164
|
+
"HOMEPATH",
|
|
165
|
+
"APPDATA",
|
|
166
|
+
"LOCALAPPDATA",
|
|
167
|
+
"PROGRAMDATA",
|
|
168
|
+
"PROGRAMFILES",
|
|
169
|
+
"PROGRAMFILES(X86)",
|
|
170
|
+
"PROGRAMW6432",
|
|
171
|
+
"TEMP",
|
|
172
|
+
"TMP",
|
|
173
|
+
"TMPDIR",
|
|
174
|
+
"LANG",
|
|
175
|
+
"LANGUAGE",
|
|
176
|
+
"LC_ALL",
|
|
177
|
+
"LC_CTYPE",
|
|
178
|
+
"TZ",
|
|
179
|
+
"HTTP_PROXY",
|
|
180
|
+
"HTTPS_PROXY",
|
|
181
|
+
"NO_PROXY",
|
|
182
|
+
"ALL_PROXY"
|
|
183
|
+
];
|
|
184
|
+
/** Families the CLIs own end to end; a user's Docker/XDG settings belong to them. */
|
|
185
|
+
const CONTAINER_CLI_ENV_PREFIXES = ["DOCKER_", "XDG_"];
|
|
186
|
+
/**
|
|
187
|
+
* The environment one Docker / Dev Container CLI call is started with.
|
|
188
|
+
*
|
|
189
|
+
* Names are matched case-insensitively because Windows environment names are,
|
|
190
|
+
* and a credential-shaped name is dropped even when it is otherwise listed (see
|
|
191
|
+
* `SENSITIVE_ENV_PATTERN`, the one heuristic every in-repo spawner shares).
|
|
192
|
+
* @param parent - the environment to filter; the host process environment by default.
|
|
193
|
+
* @returns a fresh environment object, safe to hand to `execFile`.
|
|
194
|
+
*/
|
|
195
|
+
function containerCliEnv(parent = process.env) {
|
|
196
|
+
const allowed = new Set(CONTAINER_CLI_ENV_NAMES);
|
|
197
|
+
const env = {};
|
|
198
|
+
for (const [name, value] of Object.entries(parent)) {
|
|
199
|
+
if (value === void 0 || SENSITIVE_ENV_PATTERN.test(name)) continue;
|
|
200
|
+
const folded = name.toUpperCase();
|
|
201
|
+
if (!allowed.has(folded) && !CONTAINER_CLI_ENV_PREFIXES.some((prefix) => folded.startsWith(prefix))) continue;
|
|
202
|
+
env[name] = value;
|
|
203
|
+
}
|
|
204
|
+
return env;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Run one CLI command without a shell, capturing bounded output.
|
|
208
|
+
* @param argv - program and arguments, never shell-interpreted.
|
|
209
|
+
* @param options - cancellation, timeout, and working directory.
|
|
210
|
+
* @returns the captured result; a missing program is reported as `exitCode: null`.
|
|
211
|
+
*/
|
|
212
|
+
const runContainerCommand = (argv, options = {}) => {
|
|
213
|
+
const [program, ...args] = argv;
|
|
214
|
+
if (program === void 0) return Promise.reject(/* @__PURE__ */ new Error("devcontainer: empty command"));
|
|
215
|
+
return new Promise((resolvePromise, reject) => {
|
|
216
|
+
execFile(program, args, {
|
|
217
|
+
encoding: "utf8",
|
|
218
|
+
maxBuffer: MAX_CLI_OUTPUT_BYTES,
|
|
219
|
+
windowsHide: true,
|
|
220
|
+
env: containerCliEnv(),
|
|
221
|
+
killSignal: "SIGTERM",
|
|
222
|
+
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
223
|
+
...options.timeoutMs === void 0 ? {} : { timeout: options.timeoutMs },
|
|
224
|
+
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
225
|
+
}, (error, stdout, stderr) => {
|
|
226
|
+
if (error !== null && options.signal?.aborted === true) {
|
|
227
|
+
reject(options.signal.reason instanceof Error ? options.signal.reason : /* @__PURE__ */ new Error("devcontainer: command aborted"));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
resolvePromise({
|
|
231
|
+
stdout,
|
|
232
|
+
stderr,
|
|
233
|
+
exitCode: error === null ? 0 : typeof error.code === "number" ? error.code : null
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
export { runContainerCommand as n, resolveContainerTarget as r, containerCliEnv as t };
|
|
240
|
+
|
|
241
|
+
//# sourceMappingURL=exec-CKAAz2zz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-CKAAz2zz.js","names":[],"sources":["../src/container.ts","../src/exec.ts"],"sourcesContent":["/**\n * Finding or starting the repository's container.\n *\n * Three drivers, in the order `cli: 'auto'` tries them:\n *\n * 1. an explicit `container` / `containerName` from the configuration;\n * 2. a running container the Dev Container CLI labelled with\n * `devcontainer.local_folder=<host root>`, which needs no CLI of our own;\n * 3. `devcontainer up`, which builds and starts the container from the\n * configuration and reports the container id it produced.\n *\n * @module @banzhe/dsh-devcontainer/container\n */\n\nimport type { ContainerRun } from './exec.ts'\nimport { toPosixSlashes } from './paths.ts'\nimport { resolveSbxTarget } from './sbx.ts'\nimport type { RepoContainerSpec } from './types.ts'\n\n/** Where agent commands run. */\nexport type ContainerTarget =\n | { readonly kind: 'docker'; readonly containerId: string; readonly workspaceFolder: string }\n | { readonly kind: 'devcontainer-cli'; readonly workspaceFolder: string }\n | { readonly kind: 'sbx'; readonly sandboxName: string; readonly workspaceFolder: string }\n\n/** Label the Dev Container CLI stamps on every container it creates. */\nexport const CONTAINER_FOLDER_LABEL = 'devcontainer.local_folder'\n\nconst PS_FORMAT = '{{.ID}}\\t{{.Label \"devcontainer.local_folder\"}}'\n\n/** Compare two host folders as one repository, folding separators and win32 case. */\nfunction sameFolder(left: string, right: string): boolean {\n return toPosixSlashes(left).replace(/\\/+$/, '').toLowerCase()\n === toPosixSlashes(right).replace(/\\/+$/, '').toLowerCase()\n}\n\n/**\n * Find the running container the Dev Container CLI started for this repository.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe.\n * @returns the container id, or undefined when none is running (or Docker is absent).\n */\nexport async function findRunningContainer(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<string | undefined> {\n const result = await run(\n ['docker', 'ps', '--filter', `label=${CONTAINER_FOLDER_LABEL}`, '--format', PS_FORMAT],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n if (result.exitCode !== 0) return undefined\n for (const line of result.stdout.split('\\n')) {\n const [id, folder] = line.split('\\t')\n if (id === undefined || folder === undefined) continue\n if (id.trim() === '' || folder.trim() === '') continue\n if (sameFolder(folder.trim(), spec.hostWorkspaceRoot)) return id.trim()\n }\n return undefined\n}\n\n/**\n * Read the container id out of `devcontainer up` output (its last JSON line).\n * @param stdout - the CLI's standard output.\n * @returns the container id, or undefined when the output carries none.\n */\nexport function parseUpOutput(stdout: string): string | undefined {\n const lines = stdout.split('\\n').map(line => line.trim()).filter(line => line.startsWith('{'))\n for (const line of lines.reverse()) {\n try {\n const parsed: unknown = JSON.parse(line)\n if (typeof parsed === 'object' && parsed !== null) {\n const { containerId } = parsed as { containerId?: unknown }\n if (typeof containerId === 'string' && containerId !== '') return containerId\n }\n } catch {\n // A non-JSON line is progress output, not the result envelope.\n }\n }\n return undefined\n}\n\n/**\n * Build and start the repository's container through the Dev Container CLI.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the CLI call.\n * @returns the produced container id when the CLI reported one.\n * @throws Error when the CLI failed and reported no container.\n */\nexport async function startContainer(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<{ containerId?: string; workspaceFolder: string }> {\n const result = await run(\n ['devcontainer', 'up', '--workspace-folder', spec.hostWorkspaceRoot],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n const containerId = parseUpOutput(result.stdout)\n if (result.exitCode !== 0 && containerId === undefined) {\n const detail = (result.stderr.trim() || result.stdout.trim() || 'no output').split('\\n').slice(-3).join(' ')\n throw new Error(`devcontainer: \"${spec.configPath}\": devcontainer up failed for ${spec.hostWorkspaceRoot}: ${detail}`)\n }\n return {\n ...containerId === undefined ? {} : { containerId },\n workspaceFolder: spec.hostWorkspaceRoot,\n }\n}\n\n/**\n * Resolve the container agent commands run in.\n *\n * `cli: 'sbx'` is not a container at all: a Docker Sandbox mounts the host\n * workspace at its own absolute path, so it is discovered and started by\n * {@link resolveSbxTarget} instead of by the Dev Container drivers below.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe / start sequence.\n * @returns the docker target when a container id is known, else the CLI or sandbox target.\n * @throws Error when `cli: 'docker'` was demanded and no container is running, or `sbx` cannot be prepared.\n */\nexport async function resolveContainerTarget(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<ContainerTarget> {\n if (spec.cli === 'sbx') return await resolveSbxTarget(spec, run, signal)\n if (spec.container !== undefined) {\n return { kind: 'docker', containerId: spec.container, workspaceFolder: spec.containerWorkspaceFolder }\n }\n if (spec.cli !== 'devcontainer') {\n const running = await findRunningContainer(spec, run, signal)\n if (running !== undefined) {\n return { kind: 'docker', containerId: running, workspaceFolder: spec.containerWorkspaceFolder }\n }\n if (spec.cli === 'docker') {\n throw new Error('devcontainer: \"' + spec.configPath + '\": cli is \"docker\" but no running container carries '\n + `${CONTAINER_FOLDER_LABEL}=${spec.hostWorkspaceRoot}; start it or set cli: \"auto\"`)\n }\n }\n if (spec.ensureUp) {\n const started = await startContainer(spec, run, signal)\n if (started.containerId !== undefined) {\n return {\n kind: 'docker',\n containerId: started.containerId,\n workspaceFolder: spec.containerWorkspaceFolder,\n }\n }\n return { kind: 'devcontainer-cli', workspaceFolder: started.workspaceFolder }\n }\n return { kind: 'devcontainer-cli', workspaceFolder: spec.hostWorkspaceRoot }\n}\n","/**\n * The one place this Bundle starts a host process: the Docker / Dev Container\n * CLI probes that find or start the container, and the `docker exec` that runs\n * the agent's command. Kept behind an interface so the container argv logic is\n * testable without a Docker daemon.\n * @module @banzhe/dsh-devcontainer/exec\n */\n\nimport { execFile } from 'node:child_process'\nimport { SENSITIVE_ENV_PATTERN } from '@deepseek-ai/dsh-subprocess'\n\n/** One finished CLI call. */\nexport interface ContainerCommandResult {\n readonly stdout: string\n readonly stderr: string\n /** Exit code, or null when the CLI could not be started at all. */\n readonly exitCode: number | null\n}\n\n/** Options for one CLI call. */\nexport interface ContainerCommandOptions {\n readonly signal?: AbortSignal | undefined\n readonly timeoutMs?: number | undefined\n readonly cwd?: string | undefined\n}\n\n/** Runs one host CLI command and resolves with its output. */\nexport type ContainerRun = (argv: readonly string[], options?: ContainerCommandOptions) => Promise<ContainerCommandResult>\n\n/**\n * Cap for one probe's captured output. The agent's own commands do not come\n * through here — they run through the subprocess seam, which streams and caps\n * them — so this only has to hold `devcontainer up`'s build log.\n */\nconst MAX_CLI_OUTPUT_BYTES = 32 * 1024 * 1024\n\n/**\n * The parent variables a Docker / Dev Container CLI is started with.\n *\n * The CLI is a host program the harness runs on the user's behalf, not a proxy\n * for the session: starting it with the ambient environment would hand the\n * harness's own credentials, the session's `DSH_*` facts, and every unrelated\n * host-only variable to a build that the container's `Dockerfile` can read.\n * Only the names below survive, because the CLI itself needs each one:\n * executable lookup and the platform runtime, the per-user Docker configuration\n * under `HOME`/`APPDATA` (where the credential helper is named), scratch space,\n * locale, and proxy routing.\n */\nconst CONTAINER_CLI_ENV_NAMES: readonly string[] = [\n 'PATH', 'PATHEXT', 'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC',\n 'HOME', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH', 'APPDATA', 'LOCALAPPDATA',\n 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES(X86)', 'PROGRAMW6432',\n 'TEMP', 'TMP', 'TMPDIR',\n 'LANG', 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'TZ',\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY',\n]\n\n/** Families the CLIs own end to end; a user's Docker/XDG settings belong to them. */\nconst CONTAINER_CLI_ENV_PREFIXES: readonly string[] = ['DOCKER_', 'XDG_']\n\n/**\n * The environment one Docker / Dev Container CLI call is started with.\n *\n * Names are matched case-insensitively because Windows environment names are,\n * and a credential-shaped name is dropped even when it is otherwise listed (see\n * `SENSITIVE_ENV_PATTERN`, the one heuristic every in-repo spawner shares).\n * @param parent - the environment to filter; the host process environment by default.\n * @returns a fresh environment object, safe to hand to `execFile`.\n */\nexport function containerCliEnv(parent: NodeJS.ProcessEnv = process.env): Record<string, string> {\n const allowed = new Set(CONTAINER_CLI_ENV_NAMES)\n const env: Record<string, string> = {}\n for (const [name, value] of Object.entries(parent)) {\n if (value === undefined || SENSITIVE_ENV_PATTERN.test(name)) continue\n const folded = name.toUpperCase()\n if (!allowed.has(folded) && !CONTAINER_CLI_ENV_PREFIXES.some(prefix => folded.startsWith(prefix))) continue\n env[name] = value\n }\n return env\n}\n\n/**\n * Run one CLI command without a shell, capturing bounded output.\n * @param argv - program and arguments, never shell-interpreted.\n * @param options - cancellation, timeout, and working directory.\n * @returns the captured result; a missing program is reported as `exitCode: null`.\n */\nexport const runContainerCommand: ContainerRun = (argv, options = {}) => {\n const [program, ...args] = argv\n if (program === undefined) return Promise.reject(new Error('devcontainer: empty command'))\n return new Promise((resolvePromise, reject) => {\n execFile(program, args, {\n encoding: 'utf8',\n maxBuffer: MAX_CLI_OUTPUT_BYTES,\n windowsHide: true,\n env: containerCliEnv(),\n // `signal` kills the child on abort; naming the signal keeps the kill\n // deterministic instead of relying on the platform default.\n killSignal: 'SIGTERM',\n ...options.signal === undefined ? {} : { signal: options.signal },\n ...options.timeoutMs === undefined ? {} : { timeout: options.timeoutMs },\n ...options.cwd === undefined ? {} : { cwd: options.cwd },\n }, (error, stdout, stderr) => {\n if (error !== null && options.signal?.aborted === true) {\n reject(options.signal.reason instanceof Error ? options.signal.reason : new Error('devcontainer: command aborted'))\n return\n }\n const exitCode = error === null\n ? 0\n : typeof error.code === 'number' ? error.code : null\n resolvePromise({ stdout, stderr, exitCode })\n })\n })\n}\n"],"mappings":";;;;;AA0BA,MAAa,yBAAyB;AAEtC,MAAM,YAAY;;AAGlB,SAAS,WAAW,MAAc,OAAwB;CACxD,OAAO,eAAe,IAAI,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC,YAAY,MACtD,eAAe,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC,YAAY;AAC9D;;;;;;;;AASA,eAAsB,qBACpB,MACA,KACA,QAC6B;CAC7B,MAAM,SAAS,MAAM,IACnB;EAAC;EAAU;EAAM;EAAY,SAAS;EAA0B;EAAY;CAAS,GACrF;EAAE,GAAG,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EAAG,WAAW,KAAK;CAAmB,CAClF;CACA,IAAI,OAAO,aAAa,GAAG,OAAO,KAAA;CAClC,KAAK,MAAM,QAAQ,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|
+
//#region src/exec.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The one place this Bundle starts a host process: the Docker / Dev Container
|
|
4
|
+
* CLI probes that find or start the container, and the `docker exec` that runs
|
|
5
|
+
* the agent's command. Kept behind an interface so the container argv logic is
|
|
6
|
+
* testable without a Docker daemon.
|
|
7
|
+
* @module @banzhe/dsh-devcontainer/exec
|
|
8
|
+
*/
|
|
9
|
+
/** One finished CLI call. */
|
|
10
|
+
interface ContainerCommandResult {
|
|
11
|
+
readonly stdout: string;
|
|
12
|
+
readonly stderr: string;
|
|
13
|
+
/** Exit code, or null when the CLI could not be started at all. */
|
|
14
|
+
readonly exitCode: number | null;
|
|
15
|
+
}
|
|
16
|
+
/** Options for one CLI call. */
|
|
17
|
+
interface ContainerCommandOptions {
|
|
18
|
+
readonly signal?: AbortSignal | undefined;
|
|
19
|
+
readonly timeoutMs?: number | undefined;
|
|
20
|
+
readonly cwd?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Runs one host CLI command and resolves with its output. */
|
|
23
|
+
type ContainerRun = (argv: readonly string[], options?: ContainerCommandOptions) => Promise<ContainerCommandResult>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ContainerRun as t };
|
|
26
|
+
//# sourceMappingURL=exec-_8g5fdSx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-_8g5fdSx.d.ts","names":[],"sources":["../src/exec.ts"],"mappings":";;;;;;;;;UAYiB;WACN;WACA;;WAEA;;;UAIM;WACN,SAAS;WACT;WACA;;;KAIC,gBAAgB,yBAAyB,UAAU,4BAA4B,QAAQ"}
|