@exagone313/dsh-podman 1.4.0 → 1.5.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.
Files changed (47) hide show
  1. package/dist/card-route.d.ts +2 -1
  2. package/dist/card-route.js +89 -6
  3. package/dist/client/ContainerCard.js +1 -1
  4. package/dist/client/card-protocol.d.ts +12 -1
  5. package/dist/client/card-protocol.js +20 -0
  6. package/dist/client/container-card-controller.d.ts +5 -1
  7. package/dist/client/container-card-controller.js +12 -1
  8. package/dist/client/container-card-create-modal.js +14 -12
  9. package/dist/client/container-card-images.d.ts +9 -0
  10. package/dist/client/container-card-images.js +25 -3
  11. package/dist/client/container-card-ptc-section.d.ts +11 -0
  12. package/dist/client/container-card-ptc-section.js +36 -0
  13. package/dist/client/container-card-ptc.d.ts +69 -0
  14. package/dist/client/container-card-ptc.js +148 -0
  15. package/dist/client/container-card-resources.d.ts +1 -0
  16. package/dist/client/container-card-resources.js +13 -8
  17. package/dist/client/container-card-row.js +4 -2
  18. package/dist/client/container-card-shared.d.ts +1 -0
  19. package/dist/client/container-card-shared.js +4 -3
  20. package/dist/client/container-card-status.d.ts +6 -0
  21. package/dist/client/container-card-status.js +18 -14
  22. package/dist/client/index.js +832 -511
  23. package/dist/client/locales.d.ts +1 -1
  24. package/dist/client/locales.js +20 -0
  25. package/dist/client/relative-time.d.ts +2 -2
  26. package/dist/client/relative-time.js +8 -7
  27. package/dist/container-kind.d.ts +10 -0
  28. package/dist/container-kind.js +38 -0
  29. package/dist/dsh-version.d.ts +2 -0
  30. package/dist/dsh-version.js +33 -0
  31. package/dist/generated/version.d.ts +2 -2
  32. package/dist/generated/version.js +2 -2
  33. package/dist/grpc/proto/dshctl/v1/control.proto +35 -7
  34. package/dist/grpc/proto/dshguest/v1/guest.proto +17 -1
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.js +1 -1
  37. package/dist/public.d.ts +2 -0
  38. package/dist/public.js +19 -0
  39. package/dist/subprocess.js +271 -105
  40. package/dist/tool-handlers.js +12 -13
  41. package/dist/workspace-binding.d.ts +2 -0
  42. package/dist/workspace-binding.js +54 -11
  43. package/docs/configuration.md +6 -5
  44. package/docs/configuration.zh.md +6 -5
  45. package/docs/usage.md +37 -1
  46. package/docs/usage.zh.md +31 -1
  47. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { type CardSnapshot } from "./client/card-protocol.js";
1
+ import { type CardSnapshot, type PtcView } from "./client/card-protocol.js";
2
2
  import { type ReasonLocale } from "./approval-reasons.js";
3
3
  import { type WorkspaceResolver } from "./workspace-binding.js";
4
4
  export declare function containerMountView(mount: any, projectsRoot: string): {
@@ -9,6 +9,7 @@ export declare function containerMountView(mount: any, projectsRoot: string): {
9
9
  volume: string;
10
10
  secret: string;
11
11
  };
12
+ export declare function ptcView(row: any | undefined): PtcView;
12
13
  /** Build the live snapshot the card renders. */
13
14
  export declare function cardSnapshot(resolver: WorkspaceResolver, workspaceRegistry: any, harnessVersion?: string): Promise<CardSnapshot>;
14
15
  /**
@@ -5,9 +5,10 @@
5
5
  // path. It serves the live orchestrator snapshot and runs one command per
6
6
  // request, so neither the snapshot nor the commands touch the persisted
7
7
  // settings document.
8
- import { CARD_PATH, } from "./client/card-protocol.js";
8
+ import { absentPtcView, CARD_PATH, PTC_CONTAINER_NAME, PTC_IMAGE_ID, } from "./client/card-protocol.js";
9
9
  import { renderCacheCleanNotice, renderDefaultEnvSyncNotice, renderPublishNotice, resolveReasonLocale, } from "./approval-reasons.js";
10
10
  import { mergeDefaultEnv, missingDefaultEnv } from "./container-env.js";
11
+ import { isPtcContainer } from "./container-kind.js";
11
12
  import { portProtocolFromProto, portProtocolToProto } from "./publish-port.js";
12
13
  import { defaultMountMode, mountKindToProto, mountModeToProto, normalizeMountKind, normalizeMountMode, } from "./mount-enums.js";
13
14
  import { mountInputToProto, projectMountMirror, validateMountInput, } from "./mount-input.js";
@@ -15,7 +16,7 @@ import { unaryGuest } from "./guest-rpc.js";
15
16
  import { workspaceSlug } from "./workspace-binding.js";
16
17
  import { GIT_COMMIT, VERSION } from "./generated/version.js";
17
18
  import { versionState as pluginVersionState } from "./version-compat.js";
18
- import { dshVersion } from "./dsh-version.js";
19
+ import { dshVersion, pinnedDshVersion } from "./dsh-version.js";
19
20
  // readOrchestratorVersion asks the orchestrator for its version and commit, or
20
21
  // returns empty strings when the call fails (an orchestrator predating the
21
22
  // handshake).
@@ -110,6 +111,28 @@ function publishedPortView(port) {
110
111
  endpoint: stringField(port?.endpoint),
111
112
  };
112
113
  }
114
+ // ptcView projects the one shared PTC container from its listing row, or the
115
+ // absent state when the orchestrator holds no record for it. The row belongs to
116
+ // no workspace, and a missing row is a normal state: the container is created
117
+ // lazily on its first use, not by the card.
118
+ export function ptcView(row) {
119
+ if (row === undefined)
120
+ return absentPtcView();
121
+ const status = stringField(row.status);
122
+ const state = status === "running" || status === "stopped"
123
+ ? status
124
+ : "absent";
125
+ return {
126
+ containerName: stringField(row.containerName) || PTC_CONTAINER_NAME,
127
+ kind: "ptc",
128
+ state,
129
+ // A row the orchestrator still holds may predate the image field: an absent
130
+ // container names the image it would be built from instead of reading empty.
131
+ imageId: stringField(row.imageId) ||
132
+ (state === "absent" ? PTC_IMAGE_ID : ""),
133
+ createdAt: stringField(row.createdAt),
134
+ };
135
+ }
113
136
  function imageView(image) {
114
137
  return {
115
138
  imageId: stringField(image?.imageId),
@@ -222,6 +245,7 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
222
245
  gatewayVersionState: "ok",
223
246
  projectsRoot: resolver.getConfig().projectsRoot,
224
247
  workspaces: [],
248
+ ptc: absentPtcView(),
225
249
  containers: [],
226
250
  images: [],
227
251
  volumes: [],
@@ -230,6 +254,11 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
230
254
  };
231
255
  }
232
256
  const [containers, images, workspaces, volumes, secrets, caches] = listings;
257
+ // The shared PTC container comes from its own row, which carries an empty
258
+ // workspace slug, and is never mixed into a workspace card. The orchestrator
259
+ // lists it even when no workspace exists.
260
+ const containerRows = (containers.containers ?? []);
261
+ const ptcRow = containerRows.find((container) => isPtcContainer(container));
233
262
  return {
234
263
  version: VERSION,
235
264
  commit: GIT_COMMIT,
@@ -244,7 +273,10 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
244
273
  : pluginVersionState(gateway.gatewayVersion, orchestratorVersion || VERSION),
245
274
  projectsRoot: resolver.getConfig().projectsRoot,
246
275
  workspaces: mergeWorkspaceViews(dshWorkspaceViews(workspaceRegistry, resolver.getConfig().projectsRoot), orchestratorWorkspaceViews(workspaces.workspaces)),
247
- containers: (containers.containers ?? []).map((container) => ({
276
+ ptc: ptcView(ptcRow),
277
+ containers: containerRows
278
+ .filter((container) => !isPtcContainer(container))
279
+ .map((container) => ({
248
280
  containerName: container.containerName ?? "",
249
281
  workspaceSlug: container.workspaceSlug ?? "",
250
282
  imageId: container.imageId ?? "",
@@ -254,7 +286,7 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
254
286
  paths: container.paths ?? [],
255
287
  env: container.env ?? {},
256
288
  secretEnv: container.secretEnv ?? {},
257
- publishedPorts: (container.publishedPorts ?? []).map(publishedPortView),
289
+ publishedPorts: (container.publishedPorts ?? []).map((port) => publishedPortView(port)),
258
290
  })),
259
291
  images: (images.images ?? []).map(imageView),
260
292
  volumes: (volumes.volumes ?? []).map((volume) => ({
@@ -450,6 +482,27 @@ readLocale) {
450
482
  ...(command.container !== "" ? { container: command.container } : {}),
451
483
  });
452
484
  break;
485
+ case "ptc_remove":
486
+ // The shared PTC container belongs to no workspace: the orchestrator's
487
+ // explicit workspace-less remove is the empty slug with its reserved
488
+ // name. Every user-addressed mutation on that name stays refused.
489
+ await resolver.control("removeContainer", {
490
+ container: PTC_CONTAINER_NAME,
491
+ });
492
+ break;
493
+ case "ptc_recreate":
494
+ // The container carries no editable field, so a recreate is its
495
+ // workspace-less remove followed by the orchestrator's own ensure: the
496
+ // PTC image is built on demand for the harness release the plugin pins,
497
+ // exactly as the agent's PTC attach path asks for it.
498
+ await resolver.control("removeContainer", {
499
+ container: PTC_CONTAINER_NAME,
500
+ });
501
+ await resolver.control("ensureContainer", {
502
+ container: PTC_CONTAINER_NAME,
503
+ dshVersion: pinnedDshVersion(),
504
+ });
505
+ break;
453
506
  case "workspace_remove":
454
507
  await resolver.control("removeWorkspace", {
455
508
  workspaceSlug: command.workspace,
@@ -488,11 +541,37 @@ readLocale) {
488
541
  value: command.value,
489
542
  });
490
543
  break;
544
+ case "ptc_build":
545
+ // Building a missing PTC image also has to create its container: an
546
+ // image alone has nothing to run. The ensure builds the image and makes
547
+ // the shared container usable in one step.
548
+ await resolver.control("ensureContainer", {
549
+ container: PTC_CONTAINER_NAME,
550
+ dshVersion: pinnedDshVersion(),
551
+ });
552
+ break;
491
553
  case "image_rebuild":
492
- await resolver.control("rebuildImage", { imageId: command.workspace });
554
+ // The PTC image has no stored description: the orchestrator rebuilds its
555
+ // single image for the harness release the plugin pins, unconditionally
556
+ // and without touching the container record. Every other row rebuilds
557
+ // its stored image.
558
+ if (command.workspace === PTC_IMAGE_ID) {
559
+ await resolver.control("rebuildImage", {
560
+ imageId: PTC_IMAGE_ID,
561
+ dshVersion: pinnedDshVersion(),
562
+ });
563
+ }
564
+ else {
565
+ await resolver.control("rebuildImage", { imageId: command.workspace });
566
+ }
493
567
  break;
494
568
  case "image_rebuild_all":
495
- await resolver.control("rebuildAllImages", {});
569
+ // The pinned release covers the reserved PTC image too, so rebuilding
570
+ // everything builds it when missing and refreshes it when present,
571
+ // without touching the PTC container.
572
+ await resolver.control("rebuildAllImages", {
573
+ dshVersion: pinnedDshVersion(),
574
+ });
496
575
  break;
497
576
  case "container_secret_add":
498
577
  await resolver.control("addContainerSecret", {
@@ -534,6 +613,10 @@ readLocale) {
534
613
  let applied = 0;
535
614
  let skipped = 0;
536
615
  for (const row of listings.containers ?? []) {
616
+ // The PTC container is orchestrator-owned and user-addressed mutations
617
+ // on it are refused, so it never receives the default environment.
618
+ if (isPtcContainer(row))
619
+ continue;
537
620
  if (command.workspace !== "" && row.workspaceSlug !== command.workspace) {
538
621
  continue;
539
622
  }
@@ -166,5 +166,5 @@ export function ContainerCard(props) {
166
166
  panelId: panelId("status"),
167
167
  },
168
168
  ] }), _jsx("div", { id: panelId("workspaces"), role: "tabpanel", "aria-labelledby": tabId("workspaces"), hidden: tab !== "workspaces", style: tab === "workspaces" ? tabPanel : undefined, children: noWorkspace ? _jsx("p", { style: hint, children: t("noWorkspaces") }) : (workspaceRows.map(({ workspace, containers }) => (_jsx(WorkspaceSection, { t: t, workspace: workspace, containers: containers, images: state.images, volumes: state.volumes, secrets: state.secrets, busy: state.busy, writable: state.writable, locale: state.locale, pendingActions: state.pendingActions, defaultImage: state.defaultImage, defaultEnv: state.containerEnv, projectsRoot: state.projectsRoot, directoryPicker: state.directoryPicker, onRemove: props.remove, onRecreate: props.recreate, onRemoveWorkspace: props.removeWorkspace, onCreate: props.createContainer, onCreateSecret: props.createSecret, onStartContainer: props.startContainer, onApplyContainerConfig: props.applyContainerConfig, gatewayUnavailable: state.gatewayState === "absent" ||
169
- state.gatewayState === "incompatible" }, workspace.workspaceSlug)))) }), _jsx("div", { id: panelId("images"), role: "tabpanel", "aria-labelledby": tabId("images"), hidden: tab !== "images", style: tab === "images" ? tabPanel : undefined, children: _jsx(ImagesSection, { t: t, images: state.images, busy: state.busy, pendingActions: state.pendingActions, defaultImage: state.defaultImage, locale: state.locale, onBuildImage: props.buildImage, onRebuildAllImages: props.rebuildAllImages, onRebuildBaseImage: props.rebuildBaseImage, onPullBaseImage: props.pullBaseImage, onRemoveImage: props.removeImage, onRebuildImage: props.rebuildImage, onSetDefaultImage: props.setDefaultImage }) }), _jsx("div", { id: panelId("storage"), role: "tabpanel", "aria-labelledby": tabId("storage"), hidden: tab !== "storage", style: tab === "storage" ? tabPanel : undefined, children: _jsx(StorageSection, { t: t, volumes: state.volumes, secrets: state.secrets, caches: state.caches, busy: state.busy, writable: state.writable, pendingActions: state.pendingActions, onCleanCaches: props.cleanCaches, onCreateVolume: props.createVolume, onRemoveVolume: props.removeVolume, onCreateSecret: props.createSecret, onRemoveSecret: props.removeSecret, onSetSecret: props.setSecret }) }), _jsx("div", { id: panelId("defaults"), role: "tabpanel", "aria-labelledby": tabId("defaults"), hidden: tab !== "defaults", style: tab === "defaults" ? tabPanel : undefined, children: _jsx(DefaultsSection, { t: t, images: state.images, defaultImage: state.defaultImage, env: state.containerEnv, workspaces: state.workspaces, containers: state.containers, busy: state.busy, writable: state.writable, onSetDefaultImage: props.setDefaultImage, onSaveEnv: props.saveContainerEnv, onApplyDefaultEnv: props.applyDefaultEnv }) }), _jsx("div", { id: panelId("status"), role: "tabpanel", "aria-labelledby": tabId("status"), hidden: tab !== "status", style: tab === "status" ? tabPanel : undefined, children: _jsx(StatusSection, { t: t, dshVersion: state.dshVersion, version: state.version, commit: state.commit, versionState: state.versionState, orchestratorVersion: state.orchestratorVersion, orchestratorCommit: state.orchestratorCommit, orchestratorReady: state.orchestratorReady, orchestratorKnown: state.orchestratorKnown, gatewayState: state.gatewayState, gatewayVersion: state.gatewayVersion, gatewayCommit: state.gatewayCommit, gatewayVersionState: state.gatewayVersionState }) }), _jsx("div", { style: actionRow, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
169
+ state.gatewayState === "incompatible" }, workspace.workspaceSlug)))) }), _jsx("div", { id: panelId("images"), role: "tabpanel", "aria-labelledby": tabId("images"), hidden: tab !== "images", style: tab === "images" ? tabPanel : undefined, children: _jsx(ImagesSection, { t: t, images: state.images, busy: state.busy, pendingActions: state.pendingActions, defaultImage: state.defaultImage, locale: state.locale, onBuildImage: props.buildImage, onRebuildAllImages: props.rebuildAllImages, onRebuildBaseImage: props.rebuildBaseImage, onPullBaseImage: props.pullBaseImage, onRemoveImage: props.removeImage, onRebuildImage: props.rebuildImage, onBuildPtcImage: props.buildPtcImage, onSetDefaultImage: props.setDefaultImage }) }), _jsx("div", { id: panelId("storage"), role: "tabpanel", "aria-labelledby": tabId("storage"), hidden: tab !== "storage", style: tab === "storage" ? tabPanel : undefined, children: _jsx(StorageSection, { t: t, volumes: state.volumes, secrets: state.secrets, caches: state.caches, busy: state.busy, writable: state.writable, pendingActions: state.pendingActions, onCleanCaches: props.cleanCaches, onCreateVolume: props.createVolume, onRemoveVolume: props.removeVolume, onCreateSecret: props.createSecret, onRemoveSecret: props.removeSecret, onSetSecret: props.setSecret }) }), _jsx("div", { id: panelId("defaults"), role: "tabpanel", "aria-labelledby": tabId("defaults"), hidden: tab !== "defaults", style: tab === "defaults" ? tabPanel : undefined, children: _jsx(DefaultsSection, { t: t, images: state.images, defaultImage: state.defaultImage, env: state.containerEnv, workspaces: state.workspaces, containers: state.containers, busy: state.busy, writable: state.writable, onSetDefaultImage: props.setDefaultImage, onSaveEnv: props.saveContainerEnv, onApplyDefaultEnv: props.applyDefaultEnv }) }), _jsx("div", { id: panelId("status"), role: "tabpanel", "aria-labelledby": tabId("status"), hidden: tab !== "status", style: tab === "status" ? tabPanel : undefined, children: _jsx(StatusSection, { t: t, dshVersion: state.dshVersion, version: state.version, commit: state.commit, versionState: state.versionState, orchestratorVersion: state.orchestratorVersion, orchestratorCommit: state.orchestratorCommit, orchestratorReady: state.orchestratorReady, orchestratorKnown: state.orchestratorKnown, gatewayState: state.gatewayState, gatewayVersion: state.gatewayVersion, gatewayCommit: state.gatewayCommit, gatewayVersionState: state.gatewayVersionState, ptc: state.ptc, locale: state.locale, pendingActions: state.pendingActions, onRecreatePtc: props.recreatePtc, onRemovePtc: props.removePtc }) }), _jsx("div", { style: actionRow, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
170
170
  }
@@ -1,4 +1,6 @@
1
1
  export declare const CARD_PATH = "/api/podman/card";
2
+ export declare const PTC_CONTAINER_NAME = "ptc";
3
+ export declare const PTC_IMAGE_ID = "ptc";
2
4
  export interface MountInput {
3
5
  kind: string;
4
6
  project: string;
@@ -7,7 +9,7 @@ export interface MountInput {
7
9
  volume: string;
8
10
  secret: string;
9
11
  }
10
- export type CommandOp = "remove" | "workspace_remove" | "recreate" | "create" | "volume_create" | "volume_remove" | "image_remove" | "secret_create" | "secret_remove" | "secret_set" | "image_rebuild" | "image_rebuild_all" | "image_build" | "image_base_rebuild" | "image_base_pull" | "container_secret_add" | "container_secret_remove" | "container_mount_add" | "container_mount_remove" | "container_mount_update" | "container_publish_port" | "container_unpublish_port" | "container_path_set" | "default_env_sync" | "cache_clean";
12
+ export type CommandOp = "remove" | "ptc_remove" | "ptc_recreate" | "ptc_build" | "workspace_remove" | "recreate" | "create" | "volume_create" | "volume_remove" | "image_remove" | "secret_create" | "secret_remove" | "secret_set" | "image_rebuild" | "image_rebuild_all" | "image_build" | "image_base_rebuild" | "image_base_pull" | "container_secret_add" | "container_secret_remove" | "container_mount_add" | "container_mount_remove" | "container_mount_update" | "container_publish_port" | "container_unpublish_port" | "container_path_set" | "default_env_sync" | "cache_clean";
11
13
  export declare function containerActionKey(op: CommandOp, workspace: string, container: string): string;
12
14
  export declare function scopedActionKey(op: CommandOp, scope: string): string;
13
15
  export declare function bareActionKey(op: CommandOp): string;
@@ -60,6 +62,14 @@ export interface ContainerView {
60
62
  secretEnv: Record<string, string>;
61
63
  publishedPorts: readonly PublishedPortView[];
62
64
  }
65
+ export interface PtcView {
66
+ containerName: string;
67
+ kind: "ptc";
68
+ state: "running" | "stopped" | "absent";
69
+ imageId: string;
70
+ createdAt: string;
71
+ }
72
+ export declare function absentPtcView(): PtcView;
63
73
  export interface ImageView {
64
74
  imageId: string;
65
75
  parent: string;
@@ -110,6 +120,7 @@ export interface CardSnapshot {
110
120
  gatewayVersionState: "ok" | "minor-mismatch" | "major-mismatch";
111
121
  projectsRoot: string;
112
122
  workspaces: readonly WorkspaceView[];
123
+ ptc: PtcView;
113
124
  containers: readonly ContainerView[];
114
125
  images: readonly ImageView[];
115
126
  volumes: readonly VolumeView[];
@@ -8,6 +8,15 @@
8
8
  // registers and matches the whole pathname (a path outside `/api/` is refused
9
9
  // at registration).
10
10
  export const CARD_PATH = "/api/podman/card";
11
+ // The reserved logical name of the one shared, orchestrator-owned PTC
12
+ // container. It belongs to no workspace, so it is rendered from its own
13
+ // snapshot entry rather than among a workspace's containers.
14
+ export const PTC_CONTAINER_NAME = "ptc";
15
+ // The one image id the orchestrator reserves for the shared PTC image. It is
16
+ // not stored among the images, and the container names it even before it
17
+ // exists: the card reads the expected image from the snapshot rather than
18
+ // guessing it.
19
+ export const PTC_IMAGE_ID = "ptc";
11
20
  // The stable identity of one in-flight command: its operation plus the
12
21
  // identifiers it acts on, e.g. "remove:team:default" or "volume_create:data".
13
22
  // The controller keys its in-flight set with these builders and every control
@@ -42,3 +51,14 @@ const CONTAINER_OPS = [
42
51
  export function containerActionPending(pendingActions, workspace, container) {
43
52
  return CONTAINER_OPS.some((op) => pendingActions.includes(containerActionKey(op, workspace, container)));
44
53
  }
54
+ export function absentPtcView() {
55
+ return {
56
+ containerName: PTC_CONTAINER_NAME,
57
+ kind: "ptc",
58
+ state: "absent",
59
+ // The container does not exist yet, but its image does: naming it keeps the
60
+ // card's image field filled instead of requiring the client to guess.
61
+ imageId: PTC_IMAGE_ID,
62
+ createdAt: "",
63
+ };
64
+ }
@@ -1,6 +1,6 @@
1
1
  import { type SnapshotStore } from "@deepseek-ai/dsh-client-store";
2
2
  import type { ConfigForm, ConfigFormSnapshot } from "@deepseek-ai/dsh-client-ui-settings/client";
3
- import { type CacheView, type ContainerView, type ImageView, type MountInput, type PublishedPortView, type SecretView, type VolumeView, type WorkspaceView } from "./card-protocol.js";
3
+ import { type CacheView, type ContainerView, type ImageView, type MountInput, type PtcView, type PublishedPortView, type SecretView, type VolumeView, type WorkspaceView } from "./card-protocol.js";
4
4
  import { type CardClient } from "./card-client.js";
5
5
  import { type ContainerConfig, type PortConfig } from "./container-card-config.js";
6
6
  import { type DirectoryPickerFace } from "./directory-picker.js";
@@ -59,6 +59,7 @@ export interface CardState {
59
59
  projectsRoot: string;
60
60
  directoryPicker?: DirectoryPickerFace;
61
61
  workspaces: readonly WorkspaceView[];
62
+ ptc: PtcView;
62
63
  containers: readonly ContainerView[];
63
64
  images: readonly ImageView[];
64
65
  volumes: readonly VolumeView[];
@@ -72,6 +73,9 @@ export interface ContainerCardFace {
72
73
  reload: () => void;
73
74
  dismissToast: () => void;
74
75
  remove: (workspace: string, container: string) => void;
76
+ removePtc: () => void;
77
+ recreatePtc: () => void;
78
+ buildPtcImage: () => void;
75
79
  cleanCaches: (mode: string) => void;
76
80
  removeWorkspace: (workspace: string) => void;
77
81
  recreate: (workspace: string, container: string, image: string, env?: Record<string, string>) => void;
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // SPDX-License-Identifier: MIT
4
4
  import { createSnapshotStore, } from "@deepseek-ai/dsh-client-store";
5
- import { bareActionKey, containerActionKey, scopedActionKey, } from "./card-protocol.js";
5
+ import { absentPtcView, bareActionKey, containerActionKey, scopedActionKey, } from "./card-protocol.js";
6
6
  import { createCardClient } from "./card-client.js";
7
7
  import { configNeedsRecreate, envDiff, mountDiff, pathsEqual, portDiff, } from "./container-card-config.js";
8
8
  import { versionState as pluginVersionState } from "../version-compat.js";
@@ -20,6 +20,7 @@ const EMPTY_SNAPSHOT = {
20
20
  gatewayVersionState: "ok",
21
21
  projectsRoot: "",
22
22
  workspaces: [],
23
+ ptc: absentPtcView(),
23
24
  containers: [],
24
25
  images: [],
25
26
  volumes: [],
@@ -48,6 +49,12 @@ function commandKey(request) {
48
49
  return scopedActionKey(request.op, request.cacheMode);
49
50
  case "image_rebuild_all":
50
51
  return bareActionKey(request.op);
52
+ case "ptc_remove":
53
+ case "ptc_recreate":
54
+ case "ptc_build":
55
+ // The shared PTC container is a singleton, so each of its commands has
56
+ // one key.
57
+ return bareActionKey(request.op);
51
58
  case "default_env_sync":
52
59
  // A sync names the workspace it targets, and an empty workspace means
53
60
  // every container; keying the two apart keeps the in-flight set stable
@@ -150,6 +157,7 @@ export class ContainerCardController {
150
157
  ? {}
151
158
  : { directoryPicker: this.directoryPicker }),
152
159
  workspaces: this.snapshot.workspaces,
160
+ ptc: this.snapshot.ptc,
153
161
  containers: this.snapshot.containers,
154
162
  images: this.snapshot.images,
155
163
  volumes: this.snapshot.volumes,
@@ -431,6 +439,9 @@ export class ContainerCardController {
431
439
  this.publish();
432
440
  },
433
441
  remove: (workspace, container) => this.command("remove", workspace, "", { container }),
442
+ removePtc: () => this.command("ptc_remove", "", ""),
443
+ recreatePtc: () => this.command("ptc_recreate", "", ""),
444
+ buildPtcImage: () => this.command("ptc_build", "", ""),
434
445
  cleanCaches: (mode) => this.command("cache_clean", "", "", { cacheMode: mode }),
435
446
  removeWorkspace: (workspace) => this.command("workspace_remove", workspace, ""),
436
447
  recreate: (workspace, container, image, env) => this.command("recreate", workspace, image, {
@@ -3,12 +3,11 @@ import { configsEqual } from "./container-card-config.js";
3
3
  import { ContainerDialog } from "./container-card-dialog.js";
4
4
  import { ContainerForm } from "./container-card-form.js";
5
5
  import { DiscardChangesModal, namePattern } from "./container-card-shared.js";
6
+ import { DEFAULT_CONTAINER_NAME, PTC_CONTAINER_NAME, reservedContainerName, } from "./container-card-ptc.js";
6
7
  import { mergeDefaultEnv } from "../container-env.js";
7
8
  import { orderedEnvRecord } from "../env-rows.js";
8
9
  import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
9
10
  import { useEffect, useRef, useState } from "react";
10
- // The one name the orchestrator reserves for a workspace's default container.
11
- const DEFAULT_CONTAINER_NAME = "default";
12
11
  // The project mount every new container starts with; it is the pristine mount
13
12
  // the draft is compared against for its dirty state.
14
13
  function initialMounts(workspace) {
@@ -67,21 +66,24 @@ export function CreateContainerModal(props) {
67
66
  setConfirmClose(false);
68
67
  }, [open, workspace, defaultImage, defaultEnv]);
69
68
  const pristine = initialConfig(workspace, defaultImage, defaultEnv);
70
- const reservedName = name === DEFAULT_CONTAINER_NAME;
69
+ const reservedName = reservedContainerName(name);
71
70
  const nameTaken = existing.includes(name);
72
71
  const namePatternOk = namePattern.test(name);
73
- const nameValid = namePatternOk && !reservedName && !nameTaken;
74
- // The name it already refuses: reserved, taken, or outside the allowed
75
- // character set. Naming the rule is what lets the user fix it in place.
72
+ const nameValid = namePatternOk && reservedName === undefined && !nameTaken;
73
+ // The name it already refuses: reserved (the default container's name or the
74
+ // PTC container's), taken, or outside the allowed character set. Naming the
75
+ // rule is what lets the user fix it in place.
76
76
  const nameError = name === ""
77
77
  ? ""
78
- : reservedName
78
+ : reservedName === DEFAULT_CONTAINER_NAME
79
79
  ? t("containerNameReserved")
80
- : nameTaken
81
- ? t("containerNameTaken")
82
- : namePatternOk
83
- ? ""
84
- : t("invalidContainerName");
80
+ : reservedName === PTC_CONTAINER_NAME
81
+ ? t("containerNamePtcReserved")
82
+ : nameTaken
83
+ ? t("containerNameTaken")
84
+ : namePatternOk
85
+ ? ""
86
+ : t("invalidContainerName");
85
87
  const canCreate = !named || nameValid;
86
88
  // Anything typed or picked since the dialog opened makes closing lose the
87
89
  // draft, so the close is routed through the discard confirmation.
@@ -23,6 +23,15 @@ export declare function BaseImageRow(props: {
23
23
  onPull: (name: string) => void;
24
24
  onSetDefault: (imageId: string) => void;
25
25
  }): ReactNode;
26
+ export declare function PtcImageRow(props: {
27
+ t: Translate;
28
+ image: ImageView;
29
+ locale: string;
30
+ last: boolean;
31
+ pendingActions: readonly string[];
32
+ onRebuild: (imageId: string) => void;
33
+ onBuild: () => void;
34
+ }): ReactNode;
26
35
  export declare function ImageBuildModal(props: {
27
36
  t: Translate;
28
37
  images: readonly {
@@ -3,7 +3,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
3
3
  //
4
4
  // SPDX-License-Identifier: MIT
5
5
  import { Chip, ConfirmButton, Field, imageIdPattern, imageStatusLabel, imageStatusTone, StatusChip, TagInput, } from "./container-card-shared.js";
6
- import { scopedActionKey } from "./card-protocol.js";
6
+ import { bareActionKey, scopedActionKey } from "./card-protocol.js";
7
+ import { buildParentImages, ptcImageRow } from "./container-card-ptc.js";
7
8
  import { FIELD_ROW_CLASS } from "./container-card-table-styles.js";
8
9
  import { actionRow, cardBlockRow, containerNameHeading, hint, imageFieldLabel, imageFieldOwnLine, imageFields, imageFieldValue, imageSelect, rowActions, rowDivider, rowMain, } from "./container-card-styles.js";
9
10
  import { relativeTimeLabel } from "./relative-time.js";
@@ -70,14 +71,35 @@ export function BaseImageRow(props) {
70
71
  ? (_jsx(Button, { variant: "outline", size: "sm", disabled: rebuildPending, onClick: () => onRebuild(image.imageId), children: rebuildPending ? t("busy") : t("rebuildImage") }))
71
72
  : null, _jsx(Button, { variant: "outline", size: "sm", disabled: image.imageId === defaultImage, onClick: () => onSetDefault(image.imageId), children: t("setDefaultImage") })] }) }) }));
72
73
  }
74
+ // The one reserved PTC image row: the image's name, its status chip and the
75
+ // violet PTC marker, its build date and parent line, then its Build/Rebuild
76
+ // action beside the disabled Set default. The PTC image is never a workspace's
77
+ // default, so that button stays disabled and its tooltip says why; the row has
78
+ // no Remove and is not a parent candidate, because the orchestrator owns its
79
+ // single image.
80
+ export function PtcImageRow(props) {
81
+ const { t, image, locale, last, pendingActions, onRebuild, onBuild, } = props;
82
+ const row = ptcImageRow(t, image);
83
+ const built = image.status === "built";
84
+ const pending = pendingActions.includes(built
85
+ ? scopedActionKey("image_rebuild", image.imageId)
86
+ : bareActionKey("ptc_build"));
87
+ return (_jsxs("div", { style: last ? cardBlockRow : { ...cardBlockRow, ...rowDivider }, children: [_jsxs("div", { style: actionRow, children: [_jsxs("div", { style: rowMain, children: [_jsx("span", { style: containerNameHeading, children: row.imageId }), row.chips.map((chip) => (_jsx(StatusChip, { tone: chip.tone, label: chip.label, title: chip.title }, chip.key)))] }), _jsxs("div", { style: rowActions, children: [_jsx(Button, { variant: "outline", size: "sm", disabled: pending, onClick: () => (built ? onRebuild(image.imageId) : onBuild()), children: pending ? t("busy") : row.build.label }), _jsx(Button, { variant: "outline", size: "sm", disabled: row.setDefault.disabled, title: row.setDefault.tooltip, children: row.setDefault.label })] })] }), _jsxs("div", { style: imageFields, children: [row.builtAt === "" ? null : (_jsx(ImageField, { label: t("built"), children: _jsx("span", { title: row.builtAt, children: relativeTimeLabel(row.builtAt, locale) }) })), row.parent === ""
88
+ ? null
89
+ : _jsx(ImageField, { label: t("parentImage"), children: row.parent })] })] }));
90
+ }
73
91
  export function ImageBuildModal(props) {
74
92
  const { t, images, open, imageId, parent, packages, onImageId, onParent, onPackages, onClose, onBuild, } = props;
75
93
  const canBuild = imageIdPattern.test(imageId) && parent.trim() !== "";
76
94
  const imageIdLabel = useId();
77
95
  const parentLabel = useId();
78
96
  const packagesLabel = useId();
79
- const baseImages = images.filter((image) => image.isBase);
80
- const customImages = images.filter((image) => !image.isBase);
97
+ // The parent choices exclude the reserved PTC image even if the caller hands
98
+ // in the whole snapshot: the PTC image is listed in the base card but built
99
+ // only by the orchestrator, never as a custom image's parent.
100
+ const parentImages = buildParentImages(images);
101
+ const baseImages = parentImages.filter((image) => image.isBase);
102
+ const customImages = parentImages.filter((image) => !image.isBase);
81
103
  return (_jsx(Modal, { open: open, onClose: onClose, title: t("buildImageTitle"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: onClose, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", disabled: !canBuild, onClick: onBuild, children: t("buildImage") })] }), children: _jsxs("div", { style: {
82
104
  display: "flex",
83
105
  flexDirection: "column",
@@ -0,0 +1,11 @@
1
+ import { type PtcView } from "./card-protocol.js";
2
+ import type { Translate } from "./locales.js";
3
+ import { type ReactNode } from "react";
4
+ export declare function PtcSection(props: {
5
+ t: Translate;
6
+ ptc: PtcView;
7
+ locale: string;
8
+ pendingActions: readonly string[];
9
+ onRecreate: () => void;
10
+ onRemove: () => void;
11
+ }): ReactNode;
@@ -0,0 +1,36 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
+ //
4
+ // SPDX-License-Identifier: MIT
5
+ // The one shared PTC container, as the Status tab renders it below the
6
+ // component card. It belongs to no workspace, so it is not listed among the
7
+ // workspace cards: it is a card of its own, without a heading for now — its
8
+ // identity line carries the container's name, its state chip, the violet PTC
9
+ // marker and its creation date, and its body is the read-only image the
10
+ // orchestrator builds on demand. A missing container is the normal state before
11
+ // its first use, so its status chip reads Missing in the muted tone rather than
12
+ // as an error.
13
+ import { bareActionKey } from "./card-protocol.js";
14
+ import { ptcActionViews, ptcChips, } from "./container-card-ptc.js";
15
+ import { ConfirmButton, CopyButton, ImageRow, StatusChip, } from "./container-card-shared.js";
16
+ import { actionRow, blockWrapper, card, cardTitle, containerNameHeading, headerRule, rowActions, rowMain, rowMeta, } from "./container-card-styles.js";
17
+ import { relativeTimeLabel } from "./relative-time.js";
18
+ export function PtcSection(props) {
19
+ const { t, ptc, locale, pendingActions, onRecreate, onRemove } = props;
20
+ const absent = ptc.state === "absent";
21
+ const actions = ptcActionViews(t, ptc.containerName);
22
+ const pending = (action) => pendingActions.includes(bareActionKey(action.op));
23
+ return (_jsxs("section", { style: card, children: [_jsxs("div", { style: { ...actionRow, ...headerRule }, children: [_jsxs("div", { style: rowMain, children: [_jsx("span", { style: {
24
+ ...cardTitle,
25
+ ...containerNameHeading,
26
+ overflowWrap: "anywhere",
27
+ }, children: ptc.containerName }), ptcChips(t, ptc.state).map((chip) => (_jsx(StatusChip, { tone: chip.tone, label: chip.label, title: chip.title }, chip.key))), absent || ptc.createdAt === "" ? null : (_jsxs(_Fragment, { children: [_jsx("span", { style: rowMeta, title: ptc.createdAt, children: relativeTimeLabel(ptc.createdAt, locale) }), _jsx(CopyButton, { t: t, value: ptc.createdAt, label: t("copyCreated") })] }))] }), _jsx("div", { style: rowActions, children: actions.map((action) => (_jsx(ConfirmButton, { t: t,
28
+ // The shared container carries no editable field, so both actions
29
+ // confirm before they touch its fixed identity. Recreate is a
30
+ // deliberate rebuild rather than a removal; Remove keeps the
31
+ // error colour of every removal.
32
+ emphasis: action.destructive ? undefined : "business", destructive: action.destructive, label: action.label, title: action.title, description: action.description, confirmLabel: action.title,
33
+ // Nothing is there to recreate or remove before the container
34
+ // exists.
35
+ disabled: absent, pending: pending(action), onConfirm: action.key === "recreate" ? onRecreate : onRemove }, action.key))) })] }), _jsx("div", { style: blockWrapper, children: _jsx(ImageRow, { t: t, mode: "view", image: ptc.imageId }) })] }));
36
+ }
@@ -0,0 +1,69 @@
1
+ import { PTC_CONTAINER_NAME, PTC_IMAGE_ID, type PtcView } from "./card-protocol.js";
2
+ import type { ContainerPluginKey, Translate } from "./locales.js";
3
+ export { PTC_CONTAINER_NAME, PTC_IMAGE_ID };
4
+ export declare const DEFAULT_CONTAINER_NAME = "default";
5
+ declare const RESERVED_CONTAINER_NAMES: readonly ["default", "ptc"];
6
+ export type ReservedContainerName = typeof RESERVED_CONTAINER_NAMES[number];
7
+ export declare function reservedContainerName(name: string): ReservedContainerName | undefined;
8
+ export declare const PTC_CHIP_KEY: ContainerPluginKey;
9
+ export declare const PTC_CHIP_TONE = "violet";
10
+ export type PtcChipTone = "ok" | "muted" | "error" | "violet";
11
+ export interface PtcChipView {
12
+ key: "state" | "ptc";
13
+ tone: PtcChipTone;
14
+ label: string;
15
+ title?: string;
16
+ }
17
+ export declare function ptcStateLabel(t: Translate, state: PtcView["state"]): string;
18
+ export declare function ptcStatusChip(t: Translate, state: PtcView["state"]): PtcChipView;
19
+ export declare function ptcChip(t: Translate, titleKey: "ptcContainerTooltip" | "ptcImageTooltip"): PtcChipView;
20
+ export declare function ptcChips(t: Translate, state: PtcView["state"]): readonly PtcChipView[];
21
+ export interface PtcActionView {
22
+ key: "recreate" | "remove";
23
+ op: "ptc_recreate" | "ptc_remove";
24
+ label: string;
25
+ title: string;
26
+ description: string;
27
+ destructive: boolean;
28
+ }
29
+ export declare function ptcActionViews(t: Translate, containerName: string): readonly PtcActionView[];
30
+ export declare function isPtcImage(imageId: string): boolean;
31
+ export declare function buildParentImages<T extends {
32
+ imageId: string;
33
+ }>(images: readonly T[]): readonly T[];
34
+ export declare function orderedImages<T extends {
35
+ imageId: string;
36
+ }>(images: readonly T[]): readonly T[];
37
+ export interface ImageCardRows<T> {
38
+ editable: readonly T[];
39
+ base: readonly T[];
40
+ ptc: T | undefined;
41
+ custom: readonly T[];
42
+ baseCount: number;
43
+ customCount: number;
44
+ }
45
+ export declare function imageCardRows<T extends {
46
+ imageId: string;
47
+ isBase: boolean;
48
+ }>(images: readonly T[]): ImageCardRows<T>;
49
+ export interface PtcImageRowView {
50
+ imageId: string;
51
+ builtAt: string;
52
+ parent: string;
53
+ chips: readonly PtcChipView[];
54
+ build: {
55
+ label: string;
56
+ };
57
+ setDefault: {
58
+ disabled: boolean;
59
+ label: string;
60
+ tooltip: string;
61
+ };
62
+ }
63
+ export declare function ptcImageRow(t: Translate, image: {
64
+ imageId: string;
65
+ status: string;
66
+ parent?: string;
67
+ primitive?: string;
68
+ builtAt?: string;
69
+ }): PtcImageRowView;