@telepath-computer/television 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -48730,6 +48730,8 @@ var ArtifactClient = class {
48730
48730
  break;
48731
48731
  }
48732
48732
  body2.channelID = input.channelID;
48733
+ if (input.before !== void 0) body2.before = input.before;
48734
+ if (input.after !== void 0) body2.after = input.after;
48733
48735
  return this.#http.requestJSON("POST", "/artifacts", body2);
48734
48736
  }
48735
48737
  /**
@@ -48772,6 +48774,18 @@ var ArtifactClient = class {
48772
48774
  `/artifacts/${encodeURIComponent(input.artifactID)}`
48773
48775
  );
48774
48776
  }
48777
+ /** Move an artifact to another channel (specs/arch/layout/index.md#^ly-move). */
48778
+ move(input) {
48779
+ return this.#http.requestJSON(
48780
+ "POST",
48781
+ `/artifacts/${encodeURIComponent(input.artifactID)}/move`,
48782
+ {
48783
+ channelID: input.channelID,
48784
+ ...input.before !== void 0 ? { before: input.before } : {},
48785
+ ...input.after !== void 0 ? { after: input.after } : {}
48786
+ }
48787
+ );
48788
+ }
48775
48789
  };
48776
48790
  var ThemeClient = class {
48777
48791
  #http;
@@ -52450,10 +52464,13 @@ var createURLArtifactSchema = external_exports.object({
52450
52464
  title: external_exports.string(),
52451
52465
  url: external_exports.string()
52452
52466
  }).strict();
52467
+ var placementFields = { before: external_exports.string().optional(), after: external_exports.string().optional() };
52468
+ var ONE_PLACEMENT_MESSAGE = "Give at most one of before or after";
52453
52469
  var createArtifactBodySchema = external_exports.discriminatedUnion("kind", [
52454
- createPathArtifactSchema.extend({ channelID: external_exports.string() }).strict(),
52455
- createURLArtifactSchema.extend({ channelID: external_exports.string() }).strict()
52456
- ]);
52470
+ createPathArtifactSchema.extend({ channelID: external_exports.string(), ...placementFields }).strict(),
52471
+ createURLArtifactSchema.extend({ channelID: external_exports.string(), ...placementFields }).strict()
52472
+ ]).refine((value) => value.before === void 0 || value.after === void 0, { message: ONE_PLACEMENT_MESSAGE });
52473
+ var moveArtifactBodySchema = external_exports.object({ channelID: external_exports.string({ error: "channelID is required" }).min(1, "channelID is required"), ...placementFields }).refine((value) => value.before === void 0 || value.after === void 0, { message: ONE_PLACEMENT_MESSAGE });
52457
52474
  var patchArtifactSchema = external_exports.object({
52458
52475
  title: external_exports.string().optional(),
52459
52476
  path: external_exports.string().optional(),
@@ -52655,6 +52672,18 @@ function registerRoutes(app, store, options) {
52655
52672
  handleStoreError(res, error48, "Failed to update artifact");
52656
52673
  }
52657
52674
  });
52675
+ app.post("/artifacts/:id/move", ...auth, (req, res) => {
52676
+ const parsed = moveArtifactBodySchema.safeParse(req.body ?? {});
52677
+ if (!parsed.success) {
52678
+ sendError(res, HTTP_BAD_REQUEST, parsed.error.issues[0]?.message ?? "Invalid request body");
52679
+ return;
52680
+ }
52681
+ try {
52682
+ res.json(store.moveArtifact({ artifactID: req.params.id, ...parsed.data }, telemetryContext(req)));
52683
+ } catch (error48) {
52684
+ handleStoreError(res, error48, "Failed to move artifact");
52685
+ }
52686
+ });
52658
52687
  app.get("/artifacts/:id", ...auth, (req, res) => {
52659
52688
  const artifact = store.getArtifact(req.params.id);
52660
52689
  if (!artifact) {
@@ -54259,7 +54288,7 @@ function disabledTelemetryRuntime() {
54259
54288
 
54260
54289
  // ../server/src/updates/version.ts
54261
54290
  function readVersionStamp() {
54262
- if ("1.5.3".length > 0) return "1.5.3";
54291
+ if ("1.5.4".length > 0) return "1.5.4";
54263
54292
  return void 0;
54264
54293
  }
54265
54294
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -56683,8 +56712,8 @@ var Server = class {
56683
56712
  };
56684
56713
  };
56685
56714
  function readServerPackageVersion() {
56686
- if ("1.5.3".length > 0) {
56687
- return telemetryVersion("1.5.3");
56715
+ if ("1.5.4".length > 0) {
56716
+ return telemetryVersion("1.5.4");
56688
56717
  }
56689
56718
  const packageJsonPath = import_node_path17.default.resolve(import_node_path17.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
56690
56719
  if (!(0, import_node_fs13.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
@@ -57990,19 +58019,18 @@ var ServerStore = class extends EventTarget {
57990
58019
  /** Create a new artifact and append its default page to the owning channel. */
57991
58020
  /** Creates an artifact with a generated ID; nothing that creates an artifact supplies its ID (specs/product/artifacts.md#^af-artifact-id). */
57992
58021
  createArtifact(input, telemetryContext) {
57993
- const channel = this.requireChannel(input.channelID);
57994
- const created = this.createKindArtifact({ ...input, id: this.newID() });
58022
+ const { before, after, ...fields } = input;
58023
+ const channel = this.requireChannel(fields.channelID);
58024
+ const created = this.createKindArtifact({ ...fields, id: this.newID() });
57995
58025
  const previousLayout = channel.layout;
58026
+ const nextLayout = placePage(
58027
+ channel,
58028
+ { artifactIds: [created.id], geometry: { ...DEFAULT_PAGE_GEOMETRY }, size: { ...DEFAULT_PAGE_SIZE } },
58029
+ { before, after }
58030
+ );
57996
58031
  const saved = this.saveArtifactRecord(created, `creating artifact ${created.id}`);
57997
58032
  const artifact = saved.artifact;
57998
- channel.layout = [
57999
- ...channel.layout,
58000
- {
58001
- artifactIds: [artifact.id],
58002
- geometry: { ...DEFAULT_PAGE_GEOMETRY },
58003
- size: { ...DEFAULT_PAGE_SIZE }
58004
- }
58005
- ];
58033
+ channel.layout = nextLayout;
58006
58034
  try {
58007
58035
  this.persistChannel(channel);
58008
58036
  } catch (error48) {
@@ -58014,6 +58042,9 @@ var ServerStore = class extends EventTarget {
58014
58042
  this.artifactChannels.set(artifact.id, channel.id);
58015
58043
  this.startWatchingArtifactContent(artifact);
58016
58044
  this.dispatchEvent(new ArtifactCreatedEvent("artifact-created", { channelID: channel.id, artifact }));
58045
+ if (before !== void 0 || after !== void 0) {
58046
+ this.dispatchEvent(new ChannelUpdatedEvent("channel-updated", { channel }));
58047
+ }
58017
58048
  this.emitTelemetry((hooks) => hooks.artifactCreated(artifact, telemetryContext));
58018
58049
  if (saved.uncertain !== null) throw saved.uncertain;
58019
58050
  return artifact;
@@ -58342,6 +58373,66 @@ var ServerStore = class extends EventTarget {
58342
58373
  );
58343
58374
  }
58344
58375
  }
58376
+ /**
58377
+ * Move an artifact to another channel as two ordinary channel saves
58378
+ * (specs/arch/layout/index.md#^ly-move): off the source, then onto the
58379
+ * target. A failed target save, like a stop between the two, leaves the
58380
+ * artifact on no channel; that risk is accepted to keep a move simple.
58381
+ */
58382
+ moveArtifact(input, telemetryContext) {
58383
+ const { artifactID } = input;
58384
+ if (!this._artifacts.has(artifactID)) {
58385
+ throw new NotFoundError(`Artifact not found: ${artifactID}`, { entityType: "artifact", entityID: artifactID });
58386
+ }
58387
+ const target = this.requireChannel(input.channelID);
58388
+ const sourceID = this.artifactChannels.get(artifactID);
58389
+ if (sourceID === target.id) return this.repositionByMove(artifactID, target, input, telemetryContext);
58390
+ if (sourceID === void 0) {
58391
+ throw new NotFoundError(`Artifact not found: ${artifactID}`, { entityType: "artifact", entityID: artifactID });
58392
+ }
58393
+ const source = this.requireChannel(sourceID);
58394
+ const page = source.layout.find((candidate) => candidate.artifactIds.includes(artifactID));
58395
+ const nextTargetLayout = placePage(
58396
+ target,
58397
+ { artifactIds: [artifactID], geometry: structuredClone(page.geometry), size: { ...page.size } },
58398
+ input
58399
+ );
58400
+ const previousSourceLayout = source.layout;
58401
+ source.layout = removeArtifactFromPages(source.layout, artifactID);
58402
+ try {
58403
+ this.persistChannel(source, { atomically: true });
58404
+ } catch (error48) {
58405
+ source.layout = previousSourceLayout;
58406
+ throw error48;
58407
+ }
58408
+ this.artifactChannels.delete(artifactID);
58409
+ this.dispatchEvent(new ChannelUpdatedEvent("channel-updated", { channel: source }));
58410
+ const previousTargetLayout = target.layout;
58411
+ target.layout = nextTargetLayout;
58412
+ try {
58413
+ this.persistChannel(target, { atomically: true });
58414
+ } catch (error48) {
58415
+ target.layout = previousTargetLayout;
58416
+ throw error48;
58417
+ }
58418
+ this.artifactChannels.set(artifactID, target.id);
58419
+ this.dispatchEvent(new ArtifactCreatedEvent("artifact-created", { channelID: target.id, artifact: this._artifacts.get(artifactID) }));
58420
+ this.dispatchEvent(new ChannelUpdatedEvent("channel-updated", { channel: target }));
58421
+ return { outcome: "moved", artifactID, channelID: target.id };
58422
+ }
58423
+ /** A move to the channel already holding the artifact applies its placement as one layout update. */
58424
+ repositionByMove(artifactID, channel, placement, telemetryContext) {
58425
+ const unchanged = { outcome: "unchanged", artifactID, channelID: channel.id };
58426
+ if (placement.before === void 0 && placement.after === void 0) return unchanged;
58427
+ if (placement.before === artifactID || placement.after === artifactID) {
58428
+ throw new InvalidRequestError(`Cannot place artifact ${artifactID} before or after itself.`);
58429
+ }
58430
+ const page = channel.layout.find((candidate) => candidate.artifactIds.includes(artifactID));
58431
+ const layout = placePage({ ...channel, layout: channel.layout.filter((candidate) => candidate !== page) }, page, placement);
58432
+ if (layout.every((candidate, index) => candidate === channel.layout[index])) return unchanged;
58433
+ this.updateChannel({ channelID: channel.id, fields: { layout } }, telemetryContext);
58434
+ return { outcome: "repositioned", artifactID, channelID: channel.id };
58435
+ }
58345
58436
  /**
58346
58437
  * Resolve the owning channel for `artifactID`, flip the active channel if
58347
58438
  * necessary, then broadcast an `artifact-focus` event for clients to
@@ -58867,7 +58958,13 @@ var ServerStore = class extends EventTarget {
58867
58958
  `);
58868
58959
  return token;
58869
58960
  }
58870
- persistChannel(channel) {
58961
+ /**
58962
+ * Save a channel's record. `atomically` replaces the file through the same
58963
+ * writer as the artifact records, so a stop mid-save leaves the old record or
58964
+ * the new one; a move saves its two channels this way
58965
+ * (specs/arch/layout/index.md#^ly-move).
58966
+ */
58967
+ persistChannel(channel, { atomically = false } = {}) {
58871
58968
  if (!this.channels.has(channel.id)) {
58872
58969
  throw new Error(`Cannot persist channel ${channel.id}: not in live map`);
58873
58970
  }
@@ -58878,10 +58975,17 @@ var ServerStore = class extends EventTarget {
58878
58975
  layout: channel.layout,
58879
58976
  ...channel.onboarding ? { onboarding: channel.onboarding } : {}
58880
58977
  };
58881
- (0, import_node_fs19.writeFileSync)(
58882
- import_node_path23.default.join(this.channelsDir, `${channel.id}.json`),
58883
- JSON.stringify(stored, null, JSON_INDENT_SPACES5)
58884
- );
58978
+ const filePath = import_node_path23.default.join(this.channelsDir, `${channel.id}.json`);
58979
+ const text = JSON.stringify(stored, null, JSON_INDENT_SPACES5);
58980
+ if (!atomically) {
58981
+ (0, import_node_fs19.writeFileSync)(filePath, text);
58982
+ return;
58983
+ }
58984
+ try {
58985
+ rewriteFile(this.recordStorage, filePath, text);
58986
+ } catch (error48) {
58987
+ if (!(error48 instanceof UncertainWriteError)) throw error48;
58988
+ }
58885
58989
  }
58886
58990
  readArtifactFile(filePath, expectedID) {
58887
58991
  let raw;
@@ -59089,6 +59193,18 @@ function storeOf(artifact) {
59089
59193
  function shareOf(artifact) {
59090
59194
  return artifact?.kind === "path" ? artifact.share : void 0;
59091
59195
  }
59196
+ function placePage(channel, page, placement) {
59197
+ const { before, after } = placement;
59198
+ if (before !== void 0 && after !== void 0) {
59199
+ throw new InvalidRequestError("Give at most one of before or after");
59200
+ }
59201
+ const named = before ?? after;
59202
+ if (named === void 0) return [...channel.layout, page];
59203
+ const index = channel.layout.findIndex((candidate) => candidate.artifactIds.includes(named));
59204
+ if (index === -1) throw new InvalidRequestError(`Artifact ${named} is not on channel ${channel.id}.`);
59205
+ const at = before !== void 0 ? index : index + 1;
59206
+ return [...channel.layout.slice(0, at), page, ...channel.layout.slice(at)];
59207
+ }
59092
59208
 
59093
59209
  // src/index.ts
59094
59210
  var import_meta2 = {};
@@ -59104,6 +59220,7 @@ var MAX_PROCESS_EXIT_STATUS = 255;
59104
59220
  var LOOPBACK_IPV4 = "127.0.0.1";
59105
59221
  var CONFIG_KEYS2 = ["port", "listen", "auth", "installedByAgent"];
59106
59222
  var HTTP_UNAUTHORIZED_STATUS2 = 401;
59223
+ var HTTP_CONFLICT_STATUS = 409;
59107
59224
  var HELP_POINTER = "Television ships bundled skills. The main skill is `television` \u2014 keep its guidance available for channels, lifecycle, the `tv` CLI, artifact workflow, and theming. Re-read it only if it is not already in context or you know the installed skill changed. Additional `tv-*` skills cover specialized artifact types. Install all bundled skills with `tv skills install <path>` (e.g. ~/.openclaw/skills) or `tv skills install -i`.";
59108
59225
  var PORT_ZERO_WARNING = "WARNING: config port 0 lets the operating system choose this server's port. Commands that contact this server must pass --port <port>, using the port in the startup output.";
59109
59226
  var TELEMETRY_NOTICE = "Fully anonymized telemetry is enabled by default. Opt out: tv telemetry disable.";
@@ -59227,8 +59344,8 @@ function resolveVercelSkillsInstallerBin() {
59227
59344
  return localRequire.resolve("skills/bin/cli.mjs");
59228
59345
  }
59229
59346
  function readCLIVersion() {
59230
- if ("1.5.3".length > 0) {
59231
- return "1.5.3";
59347
+ if ("1.5.4".length > 0) {
59348
+ return "1.5.4";
59232
59349
  }
59233
59350
  const devPackageJsonPath = import_node_path24.default.join(getDevPackageDir(), "package.json");
59234
59351
  if (!(0, import_node_fs20.existsSync)(devPackageJsonPath)) {
@@ -59512,6 +59629,29 @@ function copyBundledSkillsToDestination(bundledSkillsRoot, destinationRoot) {
59512
59629
  }
59513
59630
  return copied;
59514
59631
  }
59632
+ function parseArtifactDimension(option, value) {
59633
+ const parsed = value.trim() === "" ? Number.NaN : Number(value);
59634
+ if (!Number.isFinite(parsed) || parsed <= 0) {
59635
+ throw createDirectiveError(`tv reposition-artifact ${option} must be a finite, positive number of reference pixels; got ${value}.`);
59636
+ }
59637
+ return parsed;
59638
+ }
59639
+ function parseArtifactPosition(value) {
59640
+ if (!/^\d+$/.test(value.trim()) || Number(value) < 1) {
59641
+ throw createDirectiveError(`tv reposition-artifact --position must be a whole number from 1; got ${value}.`);
59642
+ }
59643
+ return Number(value);
59644
+ }
59645
+ var PLACE_BEFORE_HELP = "Place the artifact immediately before (left of) this artifact on the channel; otherwise it goes at the end";
59646
+ var PLACE_AFTER_HELP = "Place the artifact immediately after (right of) this artifact on the channel; otherwise it goes at the end";
59647
+ function resolvePlacement(commandName, opts) {
59648
+ if (opts.before !== void 0 && opts.after !== void 0) {
59649
+ throw createDirectiveError(`tv ${commandName} accepts --before or --after, not both.`);
59650
+ }
59651
+ if (opts.before !== void 0) return { before: opts.before };
59652
+ if (opts.after !== void 0) return { after: opts.after };
59653
+ return {};
59654
+ }
59515
59655
  function resolveFocusDirective(argv, commandName, focusFlag) {
59516
59656
  const shouldFocus = argv.includes(focusFlag);
59517
59657
  const shouldNotFocus = argv.includes("--no-focus");
@@ -59974,15 +60114,17 @@ function createProgram(env, invocation = { argv: [] }) {
59974
60114
  });
59975
60115
  program2.command("create-path-artifact").description(
59976
60116
  "Create a path artifact that points at an existing absolute markdown or HTML file, or at a directory with a root index.html/index.htm (trailing separator optional; the server detects file vs directory on disk). Television records the pointer only; HTML and directory targets are read-only, and markdown targets are written through only by in-UI editor saves via PUT /markdown/<id>."
59977
- ).requiredOption("--channel <id>", "Target channel ID").requiredOption("--title <title>", "Artifact title").requiredOption("--path <path>", "Absolute path to an existing markdown/HTML file or indexed directory (trailing separator optional)").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
60117
+ ).requiredOption("--channel <id>", "Target channel ID").requiredOption("--title <title>", "Artifact title").requiredOption("--path <path>", "Absolute path to an existing markdown/HTML file or indexed directory (trailing separator optional)").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--before <artifact-id>", PLACE_BEFORE_HELP).option("--after <artifact-id>", PLACE_AFTER_HELP).option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
59978
60118
  const shouldFocus = resolveFocusDirective(argv, "create-path-artifact", "--focus-artifact");
60119
+ const placement = resolvePlacement("create-path-artifact", opts);
59979
60120
  const artifactPath = opts.path.trim();
59980
60121
  const client = createAuthenticatedClient(opts);
59981
60122
  const { artifact } = await client.artifacts.create({
59982
60123
  kind: "path",
59983
60124
  path: artifactPath,
59984
60125
  title: opts.title,
59985
- channelID: opts.channel
60126
+ channelID: opts.channel,
60127
+ ...placement
59986
60128
  });
59987
60129
  if (shouldFocus) {
59988
60130
  await client.display.focus({ artifactID: artifact.id });
@@ -59992,15 +60134,17 @@ function createProgram(env, invocation = { argv: [] }) {
59992
60134
  });
59993
60135
  program2.command("create-url-artifact").description(
59994
60136
  "Create a URL artifact that points at an absolute http(s) URL. Television records the pointer only and does not own or modify the remote page."
59995
- ).requiredOption("--channel <id>", "Target channel ID").requiredOption("--title <title>", "Artifact title").requiredOption("--url <url>", "http(s) URL").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
60137
+ ).requiredOption("--channel <id>", "Target channel ID").requiredOption("--title <title>", "Artifact title").requiredOption("--url <url>", "http(s) URL").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--before <artifact-id>", PLACE_BEFORE_HELP).option("--after <artifact-id>", PLACE_AFTER_HELP).option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
59996
60138
  const shouldFocus = resolveFocusDirective(argv, "create-url-artifact", "--focus-artifact");
60139
+ const placement = resolvePlacement("create-url-artifact", opts);
59997
60140
  const artifactURL = opts.url.trim();
59998
60141
  const client = createAuthenticatedClient(opts);
59999
60142
  const { artifact } = await client.artifacts.create({
60000
60143
  kind: "url",
60001
60144
  url: artifactURL,
60002
60145
  title: opts.title,
60003
- channelID: opts.channel
60146
+ channelID: opts.channel,
60147
+ ...placement
60004
60148
  });
60005
60149
  if (shouldFocus) {
60006
60150
  await client.display.focus({ artifactID: artifact.id });
@@ -60035,6 +60179,83 @@ function createProgram(env, invocation = { argv: [] }) {
60035
60179
  writeLine(env.stdout, line);
60036
60180
  }
60037
60181
  });
60182
+ program2.command("reposition-artifact").description(
60183
+ "Change an artifact's size in reference pixels (the size it shows at on a 1280x800 stage), its full-screen state, or its position in its channel's left-to-right order, on whatever channel holds it. The changes apply together as one shared layout update, as if made in the app. Read a channel's arrangement with `tv get-channel`."
60184
+ ).requiredOption("--id <id>", "Artifact ID").option("--width <px>", "Width in reference pixels; finite and positive").option("--height <px>", "Height in reference pixels; finite and positive").option("--full-screen", "Make the artifact full-screen").option("--no-full-screen", "Take the artifact out of full-screen; its size is unchanged").option("--position <n>", "Position in the channel's order, counting from 1 at the left").option("--before <artifact-id>", "Place the artifact immediately before (left of) this artifact on its channel").option("--after <artifact-id>", "Place the artifact immediately after (right of) this artifact on its channel").option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).action(async (opts) => {
60185
+ const fullScreenFlags = argv.filter((token) => token === "--full-screen" || token === "--no-full-screen");
60186
+ if (new Set(fullScreenFlags).size > 1) {
60187
+ throw createDirectiveError("tv reposition-artifact accepts --full-screen or --no-full-screen, not both.");
60188
+ }
60189
+ const fullScreen = fullScreenFlags.length === 0 ? void 0 : fullScreenFlags[0] === "--full-screen";
60190
+ const width = opts.width === void 0 ? void 0 : parseArtifactDimension("--width", opts.width);
60191
+ const height = opts.height === void 0 ? void 0 : parseArtifactDimension("--height", opts.height);
60192
+ const position = opts.position === void 0 ? void 0 : parseArtifactPosition(opts.position);
60193
+ if ([opts.position, opts.before, opts.after].filter((value) => value !== void 0).length > 1) {
60194
+ throw createDirectiveError("tv reposition-artifact accepts only one of --position, --before, or --after.");
60195
+ }
60196
+ const named = opts.before ?? opts.after;
60197
+ if (named === opts.id) {
60198
+ throw createDirectiveError(`tv reposition-artifact cannot place artifact ${opts.id} before or after itself; name another artifact.`);
60199
+ }
60200
+ if (width === void 0 && height === void 0 && fullScreen === void 0 && position === void 0 && named === void 0) {
60201
+ throw createDirectiveError("tv reposition-artifact requires at least one of --width, --height, --full-screen, --no-full-screen, --position, --before, or --after.");
60202
+ }
60203
+ const client = createAuthenticatedClient(opts);
60204
+ const { channels } = await client.channels.list();
60205
+ const channel = channels.find((candidate) => candidate.layout.some((page) => page.artifactIds.includes(opts.id)));
60206
+ if (channel === void 0) throw new ValidationError(`Artifact not found: ${opts.id}`);
60207
+ if (position !== void 0 && position > channel.layout.length) {
60208
+ throw new ValidationError(
60209
+ `--position must be from 1 to ${channel.layout.length} on channel ${channel.id}; got ${position}.`
60210
+ );
60211
+ }
60212
+ const index = channel.layout.findIndex((page) => page.artifactIds.includes(opts.id));
60213
+ const current = channel.layout[index];
60214
+ const changed = {
60215
+ ...current,
60216
+ geometry: fullScreen === void 0 ? current.geometry : { ...current.geometry, full_screen: fullScreen },
60217
+ size: { width: width ?? current.size.width, height: height ?? current.size.height }
60218
+ };
60219
+ const layout = channel.layout.filter((_page, pageIndex) => pageIndex !== index);
60220
+ let insertAt = position === void 0 ? index : position - 1;
60221
+ if (named !== void 0) {
60222
+ const namedIndex = layout.findIndex((page) => page.artifactIds.includes(named));
60223
+ if (namedIndex === -1) throw new ValidationError(`Artifact ${named} is not on channel ${channel.id}.`);
60224
+ insertAt = opts.before !== void 0 ? namedIndex : namedIndex + 1;
60225
+ }
60226
+ layout.splice(insertAt, 0, changed);
60227
+ try {
60228
+ await client.channels.update({ channelID: channel.id, layout });
60229
+ } catch (error48) {
60230
+ if (error48.status === HTTP_CONFLICT_STATUS) {
60231
+ throw new ValidationError(
60232
+ `Channel ${channel.id} changed before artifact ${opts.id} could be repositioned, so nothing changed. Run the command again.`
60233
+ );
60234
+ }
60235
+ throw error48;
60236
+ }
60237
+ writeLine(env.stdout, `Artifact ${opts.id} repositioned.`);
60238
+ });
60239
+ program2.command("move-artifact").description(
60240
+ "Move an artifact to another channel. It stays the same artifact, keeping its ID, store, and share link, and goes at the end of that channel's order, or beside the artifact --before or --after names, at the size and full-screen state it had. If it is already on that channel, --before or --after still moves it beside the artifact named, and without them nothing changes. To show the same path or URL on two channels at once, create a second artifact instead."
60241
+ ).requiredOption("--id <id>", "Artifact ID").requiredOption("--channel <id>", "Target channel ID").option("--focus-artifact", "Focus the artifact on its new channel after the move").option("--no-focus", "Move the artifact without changing focus").option("--before <artifact-id>", PLACE_BEFORE_HELP).option("--after <artifact-id>", PLACE_AFTER_HELP).option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).action(async (opts) => {
60242
+ const shouldFocus = resolveFocusDirective(argv, "move-artifact", "--focus-artifact");
60243
+ const placement = resolvePlacement("move-artifact", opts);
60244
+ if (opts.before === opts.id || opts.after === opts.id) {
60245
+ throw createDirectiveError(`tv move-artifact cannot place artifact ${opts.id} before or after itself; name another artifact.`);
60246
+ }
60247
+ const client = createAuthenticatedClient(opts);
60248
+ const result = await client.artifacts.move({ artifactID: opts.id, channelID: opts.channel, ...placement });
60249
+ if (shouldFocus) {
60250
+ await client.display.focus({ artifactID: opts.id });
60251
+ }
60252
+ const messages = {
60253
+ moved: `Artifact ${opts.id} moved to channel ${result.channelID}.`,
60254
+ repositioned: `Artifact ${opts.id} repositioned on channel ${result.channelID}.`,
60255
+ unchanged: `Artifact ${opts.id} is already on channel ${result.channelID}.`
60256
+ };
60257
+ writeLine(env.stdout, messages[result.outcome]);
60258
+ });
60038
60259
  program2.command("get-artifact").description("Fetch an artifact's metadata as JSON").requiredOption("--id <id>", "Artifact ID").option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).action(async (opts) => {
60039
60260
  const client = createAuthenticatedClient(opts);
60040
60261
  writeJSON(env.stdout, await client.artifacts.get({ artifactID: opts.id }));
@@ -60157,7 +60378,7 @@ function createProgram(env, invocation = { argv: [] }) {
60157
60378
  writeJSON(env.stdout, { themesPath: import_node_path24.default.join(resolveHome(), "themes") });
60158
60379
  });
60159
60380
  program2.command("focus-artifact").description(
60160
- "Send a transient focus nudge for a specific artifact. Connected clients select the artifact's tab page and switch to its channel when needed. This is NOT persisted as state \u2014 there is no concept of a 'focused artifact' that survives reconnects (the focused channel is persistent, but artifact focus is a one-shot event)."
60381
+ "Send a transient focus nudge for a specific artifact. Connected clients select the artifact and switch to its channel when needed. This is NOT persisted as state \u2014 there is no concept of a 'focused artifact' that survives reconnects (the focused channel is persistent, but artifact focus is a one-shot event)."
60161
60382
  ).requiredOption("--id <id>", "Artifact ID").option("--port <number>", "Server port; required when the config file sets port 0", parseClientPortOption).action(async (opts) => {
60162
60383
  const client = createAuthenticatedClient(opts);
60163
60384
  const result = await client.display.focus({ artifactID: opts.id });
@@ -45,9 +45,9 @@ When the artifact is the real answer, keep the final reply short. Tell the user
45
45
  That relationship matters:
46
46
 
47
47
  - creating an artifact places it on a channel immediately
48
- - reordering an artifact's tab page is a browser UI tab-drag gesture; the CLI does not expose layout mutation today
49
- - deleting an artifact removes its registry record and its tab page from the channel
50
- - moving the same underlying path or URL to another channel means deleting the old artifact and creating a new artifact with the same path or URL on the target channel
48
+ - `tv reposition-artifact` changes an artifact's size, full-screen state, and position in its channel's order, and `tv get-channel` shows the current arrangement
49
+ - `tv move-artifact` moves an artifact to another channel, keeping its ID, store, and share link
50
+ - deleting an artifact removes its registry record and removes the artifact from its channel
51
51
 
52
52
  ### Onboarding channels
53
53
 
@@ -139,7 +139,7 @@ Commands group into four intents:
139
139
 
140
140
  - **Channel and display commands** — create, inspect, rename, remove, or switch channels, or change the active display theme (`create-channel`, `list-channels`, `get-channel`, `update-channel`, `remove-channel`, `focus-channel`, `focus-status`, `set-theme`).
141
141
  - **Artifact creation commands** — register path or URL artifacts (`create-path-artifact`, `create-url-artifact`).
142
- - **Artifact management commands** — inspect, retitle, repoint, focus, list, or delete existing artifacts (`delete-artifact`, `get-artifact`, `list-artifacts`, `update-artifact`, `focus-artifact`).
142
+ - **Artifact management commands** — inspect, retitle, repoint, focus, list, arrange, move, or delete existing artifacts (`delete-artifact`, `get-artifact`, `list-artifacts`, `update-artifact`, `reposition-artifact`, `move-artifact`, `focus-artifact`).
143
143
  - **Server and environment commands** — operate on the Television server and its home (`serve`, `status`, `stop`, `config`, `themes-path`, `telemetry`, `skills install`).
144
144
 
145
145
  When the CLI rejects a command, follow the directive it prints rather than guessing flags.
@@ -171,7 +171,7 @@ Use read commands when you need authoritative state for planning or verification
171
171
  Television separates state changes from focus. Choosing where an artifact lives is one decision; choosing whether the user's attention moves there is a separate one.
172
172
 
173
173
  - **channel focus** is persistent: which channel the user is currently looking at
174
- - **artifact focus** is transient: clients select the artifact's tab page, switching channels first when needed
174
+ - **artifact focus** is transient: clients select the artifact, switching channels first when needed
175
175
 
176
176
  There is a persisted focused channel.
177
177
  There is not a persisted focused artifact.
@@ -220,17 +220,37 @@ These are illustrative, not exhaustive. When the language is ambiguous or unusua
220
220
 
221
221
  ## Channel placement
222
222
 
223
- Artifact creation commands require `--channel` because new artifacts need immediate channel membership. Reordering an artifact's tab page on its current channel is a browser UI tab-drag gesture; the CLI does not expose layout mutation today. To move the same underlying path or URL to a different channel, delete the old artifact and create a new artifact on the target channel with the same path or URL.
223
+ Artifact creation commands require `--channel` because new artifacts need immediate channel membership. `tv move-artifact --id <id> --channel <target> (--focus-artifact|--no-focus)` moves an existing artifact to another channel. It stays the same artifact, so its ID, its store, and its share link keep working, and it keeps the size and full-screen state it had. Creating a second artifact with the same `--path` or `--url` on the other channel instead shows the content in both places, as two artifacts with separate stores.
224
+
225
+ A created or moved artifact goes at the end of the channel's order unless you name a neighbour: `--before <artifact-id>` puts it immediately to the left of that artifact, and `--after <artifact-id>` immediately to its right. Use at most one of the two. The named artifact must already be on that channel; otherwise nothing changes and the command reports an error. Moving an artifact to the channel it is already on changes nothing unless you give `--before` or `--after`; then it moves beside the artifact you name.
224
226
 
225
227
  Think carefully about whether the user means:
226
228
 
227
229
  - create something new on a channel
228
- - reorder an artifact's tab page on its current channel in the browser UI
230
+ - reorder, resize, or full-screen an artifact on its current channel
231
+ - move an existing artifact to another channel
232
+ - show the same path or URL on a second channel as well
229
233
  - delete an artifact from its channel
230
- - recreate the same path or URL on a different channel
231
234
 
232
235
  Those are different operations with different consequences. The per-command help text spells out which is which.
233
236
 
237
+ ### Arranging artifacts
238
+
239
+ A channel shows its artifacts left to right, in the order of its tabs. `tv get-channel --channel <id>` prints the channel's `layout`: one entry per artifact in that order, each with the artifact's ID in `artifactIds`, its `geometry.full_screen` flag, and its `size`.
240
+
241
+ `tv reposition-artifact --id <artifact-id>` changes that artifact's arrangement, with any of:
242
+
243
+ - `--width <px>` and `--height <px>` — the artifact's size
244
+ - `--full-screen` or `--no-full-screen` — whether the artifact fills the stage; leaving full-screen returns the artifact to its size
245
+ - `--position <n>` — where the artifact sits in the order, counting from 1 at the left
246
+ - `--before <artifact-id>` or `--after <artifact-id>` — put the artifact immediately left or right of another artifact on its channel. To move it one step, use `--before` with the artifact now on its left, or `--after` with the artifact now on its right; `tv get-channel` shows the order.
247
+
248
+ Use at most one of `--position`, `--before`, and `--after`.
249
+
250
+ Sizes are reference pixels, not screen pixels: the size the artifact shows at when the stage is 1280 by 800. On a larger or smaller window, every artifact grows or shrinks by the same partial factor, never in full proportion, and an artifact is never shown larger than the stage. A new artifact starts at 760 by 770. To make artifacts bigger or smaller relative to each other, change their sizes by the same ratio you want them to appear in; to fill the stage, use `--full-screen` rather than a large size.
251
+
252
+ These are the same changes a person makes by dragging and double-clicking in the app, and everyone viewing the channel sees them at once. When the user cannot see the result from where they are, tell them what you changed.
253
+
234
254
  ### Choosing the right channel
235
255
 
236
256
  When deciding where an artifact should go:
@@ -253,7 +273,7 @@ Default to placing things on an existing channel unless one of those conditions
253
273
 
254
274
  # Artifact workflow
255
275
 
256
- Read this document for Television artifact work: creating files, registering path or URL artifacts, browser-only tab-page reordering, deleting, and updating titles.
276
+ Read this document for Television artifact work: creating files, registering path or URL artifacts, arranging and moving artifacts, deleting, and updating titles.
257
277
 
258
278
  If you need bundled Television authoring skills installed first, copy them into the agent harness skills folder with `tv skills install <path>` (for example `~/.openclaw/skills`, `~/.hermes/skills`, or `~/.agents/skills`) or use `tv skills install -i`.
259
279
 
@@ -448,11 +468,15 @@ tv update-artifact --id "<artifact-id>" --url "https://example.com/next"
448
468
 
449
469
  The new path follows the same rules as creation (file or indexed directory, trailing separator optional). Rendering follows the new pointer immediately, and for path artifacts the content watcher retargets with it. Prefer repointing over delete-and-recreate when the artifact should keep its identity and channel placement.
450
470
 
451
- Reordering an artifact's tab page on its current channel is a browser UI tab-drag gesture; the CLI does not expose layout mutation today.
471
+ To change an artifact's size, full-screen state, or position in its channel's order, use `tv reposition-artifact`, described under Arranging artifacts above.
472
+
473
+ To move an artifact to another channel, keeping its identity, store, and share link:
452
474
 
453
- To move the same underlying path or URL to another channel, delete the existing artifact and create a new one on the target channel with the same `--path` or `--url`.
475
+ ```bash
476
+ tv move-artifact --id "<artifact-id>" --channel "<target-channel-id>" --no-focus
477
+ ```
454
478
 
455
- To delete the registry record and remove its tab page from the channel:
479
+ To delete the registry record and remove the artifact from its channel:
456
480
 
457
481
  ```bash
458
482
  tv delete-artifact --id "<artifact-id>"