@clipy/cli 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +202 -0
- package/README.md +265 -12
- package/dist/chromeForClipy.js +1 -1
- package/dist/context/importCmd.js +4 -1
- package/dist/context/readCmd.js +33 -21
- package/dist/context/ytdlp.js +108 -28
- package/dist/context-core/arec.js +66 -6
- package/dist/index.js +1180 -98
- package/dist/library.js +7 -3
- package/dist/local/arec.js +186 -0
- package/dist/local/commands.js +1103 -0
- package/dist/local/deps.js +42 -0
- package/dist/local/media.js +154 -0
- package/dist/local/pipeline.js +530 -0
- package/dist/local/ports.js +1 -0
- package/dist/local/speechEngine.js +260 -0
- package/dist/local/transcriptFile.js +54 -0
- package/dist/local/vendor/capture/capture.js +442 -0
- package/dist/local/vendor/capture/check.js +103 -0
- package/dist/local/vendor/capture/children.js +69 -0
- package/dist/local/vendor/capture/ffmpegArgs.js +108 -0
- package/dist/local/vendor/capture/index.js +36 -0
- package/dist/local/vendor/capture/proc.js +71 -0
- package/dist/local/vendor/capture/scripts.js +107 -0
- package/dist/local/vendor/capture/sidecar.js +199 -0
- package/dist/local/vendor/capture/sources.js +272 -0
- package/dist/local/vendor/capture/types.js +1 -0
- package/dist/local/vendor/capture/virtualDisplay.js +170 -0
- package/dist/local/vendor/capture/xauth.js +68 -0
- package/dist/local/vendor/config/errors.js +12 -0
- package/dist/local/vendor/config/index.js +241 -0
- package/dist/local/vendor/config/paths.js +37 -0
- package/dist/local/vendor/config/presets.js +61 -0
- package/dist/local/vendor/config/schema.js +66 -0
- package/dist/local/vendor/moments/generated/drawStrokes.js +127 -0
- package/dist/local/vendor/moments/generated/keyMomentsCursorContext.js +568 -0
- package/dist/local/vendor/moments/generated/keyMomentsFusion.js +406 -0
- package/dist/local/vendor/moments/generated/localMomentPlan.js +178 -0
- package/dist/local/vendor/moments/generated/types.js +1 -0
- package/dist/local/vendor/moments/index.js +147 -0
- package/dist/local/vendor/moments/llm.js +158 -0
- package/dist/local/vendor/transcribe/audio.js +251 -0
- package/dist/local/vendor/transcribe/chunking.js +250 -0
- package/dist/local/vendor/transcribe/index.js +89 -0
- package/dist/local/vendor/transcribe/local.js +221 -0
- package/dist/local/vendor/transcribe/localWorker.js +79 -0
- package/dist/local/vendor/transcribe/models.js +369 -0
- package/dist/local/vendor/transcribe/providers/assemblyai.js +61 -0
- package/dist/local/vendor/transcribe/providers/common.js +105 -0
- package/dist/local/vendor/transcribe/providers/deepgram.js +59 -0
- package/dist/local/vendor/transcribe/providers/elevenlabs.js +43 -0
- package/dist/local/vendor/transcribe/providers/gemini.js +102 -0
- package/dist/local/vendor/transcribe/providers/http.js +214 -0
- package/dist/local/vendor/transcribe/providers/openai.js +48 -0
- package/dist/local/vendor/transcribe/tar.js +53 -0
- package/dist/local/vendor/transcribe/types.js +1 -0
- package/dist/macBridge.js +78 -9
- package/dist/recheck.js +934 -0
- package/dist/recheckCmd.js +279 -0
- package/dist/skill.js +94 -3
- package/package.json +22 -11
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* override the stored key. Read-only unless the key carries the "ingest" scope.
|
|
14
14
|
*/
|
|
15
15
|
import { parseArgs } from "node:util";
|
|
16
|
-
import { appendFileSync, closeSync, copyFileSync, cpSync, createWriteStream, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, chmodSync } from "node:fs";
|
|
16
|
+
import { appendFileSync, closeSync, copyFileSync, cpSync, createWriteStream, existsSync, mkdirSync, mkdtempSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, chmodSync } from "node:fs";
|
|
17
17
|
import { homedir, tmpdir } from "node:os";
|
|
18
18
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
19
19
|
import { createInterface } from "node:readline";
|
|
@@ -39,7 +39,9 @@ import { supportsWebp } from "./context/ffmpeg.js";
|
|
|
39
39
|
import { renderProofFrames } from "./proofFrames.js";
|
|
40
40
|
import { cmdAnalytics, cmdComment, cmdComments, cmdDelete, cmdDiagnostics, cmdFolders, cmdInteractions, cmdOrganize, cmdShare, cmdUpdate, failure, } from "./library.js";
|
|
41
41
|
import { waitForAgentContext } from "./agentReadiness.js";
|
|
42
|
-
import {
|
|
42
|
+
import { cmdRecheck } from "./recheckCmd.js";
|
|
43
|
+
import { RECHECK_MAX_STEPS } from "./recheck.js";
|
|
44
|
+
import { BridgeUnavailableError, bridgeRequest, inspectBridge, listSources, readBridgeInfo, resolveCaptureSource, windowLabel, probeSocketOpenable, probeBridgeHandshake, bridgeInfoFromFile, bridgeAppOutdated, MIN_BRIDGE_APP_VERSION, describeWindow, describeDisplay, bridgeApplicable, resolveFromSources, } from "./macBridge.js";
|
|
43
45
|
import { defaultDisplay, describeCaps, ffmpegCaps, isWaylandSession, listLinuxSources, orphanedCaptureProcesses, parseDisplaySize, realRunner, startScreenRecorder, startVirtualDisplay, } from "./linuxScreen.js";
|
|
44
46
|
// Exit quietly when stdout/stderr close early (e.g. `clipy list | head`).
|
|
45
47
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -73,6 +75,89 @@ function die(message, code = 1) {
|
|
|
73
75
|
process.stderr.write(`${c.red("error:")} ${message}\n`);
|
|
74
76
|
process.exit(code);
|
|
75
77
|
}
|
|
78
|
+
let localModuleCache = null;
|
|
79
|
+
let localEnvCache = null;
|
|
80
|
+
/** --yes: a local take may download the speech engine without asking. */
|
|
81
|
+
let localAssumeYes = false;
|
|
82
|
+
function localModule() {
|
|
83
|
+
return (localModuleCache ??= import("./local/commands.js"));
|
|
84
|
+
}
|
|
85
|
+
async function localMode() {
|
|
86
|
+
const mod = await localModule();
|
|
87
|
+
const env = await (localEnvCache ??= mod.realLocalEnv(VERSION, { assumeYes: localAssumeYes }));
|
|
88
|
+
return { mod, env };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Runs the local pipeline on a finished capture and prints the result: the
|
|
92
|
+
* AREC path last on stdout, or one JSON object with --json. Returns false (and
|
|
93
|
+
* sets the exit code) on failure, so the caller's own cleanup still runs.
|
|
94
|
+
*/
|
|
95
|
+
async function finishLocalTake(req, extra = {}) {
|
|
96
|
+
const { mod, env } = await localMode();
|
|
97
|
+
try {
|
|
98
|
+
const result = await mod.runLocalTake(req, env);
|
|
99
|
+
mod.printLocalResult(result, req.json, env.io, extra);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// A LocalTakeError says where the capture was kept; it is never deleted.
|
|
104
|
+
mod.printLocalError(error, req.json, env.io);
|
|
105
|
+
process.exitCode = error instanceof mod.UsageError ? 2 : 1;
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Settles everything a --local take needs before anything is recorded: the
|
|
111
|
+
* config file and model provider, ffmpeg, and the output folder (claimed
|
|
112
|
+
* here; a non-empty --out is refused unless --force). A mistake in any of them
|
|
113
|
+
* exits now, with exit code 2 for a usage error, instead of after a capture.
|
|
114
|
+
*/
|
|
115
|
+
async function prepareLocalOrExit(opts) {
|
|
116
|
+
const { mod, env } = await localMode();
|
|
117
|
+
try {
|
|
118
|
+
return await mod.prepareLocalTake({ out: opts.out, force: opts.force, inputs: opts.inputs, speech: opts.speech, speechFile: opts.speechFile, json: opts.json }, env);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
mod.printLocalError(error, opts.json, env.io);
|
|
122
|
+
process.exit(error instanceof mod.UsageError ? 2 : 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Removes a claimed --local folder that stayed empty because the capture never started. */
|
|
126
|
+
async function releaseLocalOut(dir) {
|
|
127
|
+
if (!dir)
|
|
128
|
+
return;
|
|
129
|
+
const { mod } = await localMode();
|
|
130
|
+
await mod.releaseOutDir(dir);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* While a --local capture runs (headless --url, Linux --source screen),
|
|
134
|
+
* Ctrl-C, SIGTERM and SIGHUP stop it early and the take is still built, instead
|
|
135
|
+
* of killing the CLI and leaving ffmpeg or Xvfb running. Returns a disposer.
|
|
136
|
+
*/
|
|
137
|
+
function onStopSignal(stop) {
|
|
138
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
139
|
+
const handler = () => stop();
|
|
140
|
+
for (const sig of signals)
|
|
141
|
+
process.on(sig, handler);
|
|
142
|
+
return () => {
|
|
143
|
+
for (const sig of signals)
|
|
144
|
+
process.off(sig, handler);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Narration notes in the local pipeline's shape. */
|
|
148
|
+
function localNarration(notes) {
|
|
149
|
+
return notes.map((n) => ({ startMs: n.startMs, ...(n.endMs !== undefined ? { endMs: n.endMs } : {}), text: n.text }));
|
|
150
|
+
}
|
|
151
|
+
/** --local real-screen takes on macOS go through Clipy Local, the local edition of the Mac app. */
|
|
152
|
+
const LOCAL_MAC_PLATFORM = "--source mac-screen with --local records through Clipy Local, which runs on macOS. " +
|
|
153
|
+
"Use clipy record --local (the CLI's own screen recorder), a web page with --url, or clipy proof --local.";
|
|
154
|
+
const LOCAL_MAC_OUT = "--out and --force do not apply to --source mac-screen with --local: Clipy Local keeps each take in its own folder, reported as out";
|
|
155
|
+
/** `--source mac-screen`, or `--source screen` on macOS, with --local. */
|
|
156
|
+
function isLocalMacSource(source, platform = process.platform) {
|
|
157
|
+
return source === "mac-screen" || (source === "screen" && platform === "darwin");
|
|
158
|
+
}
|
|
159
|
+
const LOCAL_EXTENSION_REFUSAL = "--source chrome-extension is not available with --local: the Clipy extension uploads its own recordings. " +
|
|
160
|
+
"Use --source chrome-for-clipy or --url with --local.";
|
|
76
161
|
function statusGlyph(status) {
|
|
77
162
|
switch (status) {
|
|
78
163
|
case "ready":
|
|
@@ -253,6 +338,62 @@ function libraryDeps(ctx, json) {
|
|
|
253
338
|
color: c,
|
|
254
339
|
};
|
|
255
340
|
}
|
|
341
|
+
/** `clipy recheck`: the library helpers plus Playwright and the proof upload. */
|
|
342
|
+
function recheckDeps(ctx, json) {
|
|
343
|
+
return {
|
|
344
|
+
...libraryDeps(ctx, json),
|
|
345
|
+
loadChromium: async () => (await loadChromium()),
|
|
346
|
+
uploadFrames: (frames, meta) => uploadRecheckFrames(ctx, frames, meta),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** The same path as `clipy proof --frame`: one held frame per step, the step
|
|
350
|
+
* result as its timed caption. */
|
|
351
|
+
async function uploadRecheckFrames(ctx, frames, meta) {
|
|
352
|
+
requireKey(ctx);
|
|
353
|
+
const holdSeconds = 3;
|
|
354
|
+
// Private (mkdtemp is 0700): the video is made of screenshots of a
|
|
355
|
+
// signed-in app. Removed on success, failure and Ctrl-C alike.
|
|
356
|
+
const tmpDir = mkdtempSync(join(tmpdir(), "clipy-recheck-upload-"));
|
|
357
|
+
const onSignal = (signal) => {
|
|
358
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
359
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
360
|
+
};
|
|
361
|
+
process.once("SIGINT", onSignal);
|
|
362
|
+
process.once("SIGTERM", onSignal);
|
|
363
|
+
try {
|
|
364
|
+
const videoPath = join(tmpDir, "recheck.mp4");
|
|
365
|
+
meta.log(`assembling ${frames.length} step frame${frames.length === 1 ? "" : "s"}…`);
|
|
366
|
+
await renderProofFrames({
|
|
367
|
+
framePaths: frames.map((f) => f.path),
|
|
368
|
+
outputPath: videoPath,
|
|
369
|
+
holdSeconds,
|
|
370
|
+
width: 1280,
|
|
371
|
+
height: 720,
|
|
372
|
+
notify: meta.log,
|
|
373
|
+
});
|
|
374
|
+
const notes = frames.map((f, i) => ({
|
|
375
|
+
startMs: Math.round(i * holdSeconds * 1000),
|
|
376
|
+
endMs: Math.round((i + 1) * holdSeconds * 1000),
|
|
377
|
+
text: f.caption,
|
|
378
|
+
}));
|
|
379
|
+
const uploaded = await uploadVideoToClipy(ctx, {
|
|
380
|
+
videoPath,
|
|
381
|
+
name: meta.name,
|
|
382
|
+
nameIsUserProvided: true,
|
|
383
|
+
description: meta.description,
|
|
384
|
+
narration: { notes },
|
|
385
|
+
// The server maps the cli-proof/ prefix to the CLI source platform.
|
|
386
|
+
sourceVersion: `cli-proof/${VERSION}`,
|
|
387
|
+
log: meta.log,
|
|
388
|
+
});
|
|
389
|
+
return { id: uploaded.publicId, shareUrl: uploaded.shareUrl, contextUrl: uploaded.contextUrl };
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
process.off("SIGINT", onSignal);
|
|
393
|
+
process.off("SIGTERM", onSignal);
|
|
394
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
395
|
+
}
|
|
396
|
+
}
|
|
256
397
|
function printJson(data) {
|
|
257
398
|
process.stdout.write(`${JSON.stringify(data, null, 2)}\n`);
|
|
258
399
|
}
|
|
@@ -365,7 +506,7 @@ ${c.bold("RECORDINGS")}
|
|
|
365
506
|
your library (needs "ingest"). --wait, --json
|
|
366
507
|
|
|
367
508
|
${c.bold("MANAGE")} ${c.dim("(needs recordings:write; comments needs comments:read, comment comments:write, analytics analytics:read)")}
|
|
368
|
-
update <id> [--title <t>] [--description <d> | --clear-description]
|
|
509
|
+
update <id> [--title <t>] [--description <d> | --clear-description] [--expected <text>]
|
|
369
510
|
Rename a recording or edit its description
|
|
370
511
|
share <id> [public|restricted|private]
|
|
371
512
|
Show or change who can open the share link
|
|
@@ -397,6 +538,14 @@ ${c.bold("BUG EVIDENCE")} ${c.dim("(captured by the Chrome extension's bug captu
|
|
|
397
538
|
Clicks, scrolls, typing and pauses with
|
|
398
539
|
the element labels and frame evidence;
|
|
399
540
|
page with --cursor <nextCursor>
|
|
541
|
+
recheck <id> --url <start-url> [--plan] [--no-upload] [--out <dir>]
|
|
542
|
+
Replay a recorded workflow in Chrome for
|
|
543
|
+
Clipy and report each step: matched,
|
|
544
|
+
control not found, different screen, error
|
|
545
|
+
or could not map. --plan lists the steps only.
|
|
546
|
+
Irreversible-looking controls (delete, pay,
|
|
547
|
+
send) are not clicked without
|
|
548
|
+
--allow-destructive
|
|
400
549
|
|
|
401
550
|
${c.bold("PROOF")} ${c.dim("(tool-neutral evidence; needs an ingest-scoped API key)")}
|
|
402
551
|
proof --frame <png|jpg|webp> [--frame <image> ...]
|
|
@@ -529,6 +678,59 @@ ${c.bold("SESSION")} ${c.dim("(agent works, Clipy records — one active session
|
|
|
529
678
|
session abort Discard the session — nothing is uploaded
|
|
530
679
|
session status Show the active session's state
|
|
531
680
|
|
|
681
|
+
${c.bold("LOCAL")} ${c.dim("(--local: no Clipy account, nothing uploaded)")}
|
|
682
|
+
${c.dim("Add --local to record, session, proof or context import and Clipy builds the")}
|
|
683
|
+
${c.dim("recording into an AREC folder on this machine instead of uploading it: video,")}
|
|
684
|
+
${c.dim("transcript, key moments with a screenshot each, and recording.arec for your AI")}
|
|
685
|
+
${c.dim("agent (Claude Code, Codex, Cursor and others). The last line printed is the")}
|
|
686
|
+
${c.dim("absolute path of recording.arec; --json prints one object with it.")}
|
|
687
|
+
${c.dim("Where data goes: with no provider, or a model or transcription running on this")}
|
|
688
|
+
${c.dim("machine (Ollama, LM Studio, the downloadable speech models), nothing leaves it.")}
|
|
689
|
+
${c.dim("With a model provider, the transcript text, click labels and a bounded sample")}
|
|
690
|
+
${c.dim("of pointer and key events go to it. With a transcription key, the audio goes")}
|
|
691
|
+
${c.dim("to that provider. The video and screenshots never leave this machine.")}
|
|
692
|
+
record --local [--max <sec>] [--mic] [--virtual-display] [--display|--window <id>]
|
|
693
|
+
Record the screen until Enter, Ctrl-C, SIGTERM or
|
|
694
|
+
--max. With no --max and stdin not a terminal, it
|
|
695
|
+
also stops when stdin closes. --virtual-display
|
|
696
|
+
(Linux) records a private Xvfb display. With
|
|
697
|
+
--url: the headless web capture. With --source
|
|
698
|
+
screen on Linux: the X11 recorder. With
|
|
699
|
+
--source screen (or mac-screen) on macOS:
|
|
700
|
+
Clipy Local, the open-source Mac app, records
|
|
701
|
+
for --for seconds (default 15)
|
|
702
|
+
session start ... --local Same session, marks and chapters; stop builds
|
|
703
|
+
the AREC (web, --source screen, chrome-for-clipy;
|
|
704
|
+
on macOS --source screen drives Clipy Local)
|
|
705
|
+
proof --frame <img>... --local Proof from screenshots or --video, built locally;
|
|
706
|
+
each frame and caption becomes a key moment
|
|
707
|
+
context import <file> --local Transcribe (unless --transcript), pick moments,
|
|
708
|
+
extract frames. URLs keep their transcript-only
|
|
709
|
+
bundle and never call Clipy; --sync is refused
|
|
710
|
+
--out <dir> Output folder (default ~/clipy/recordings/<date-time>/).
|
|
711
|
+
A folder that holds files is refused; --force replaces
|
|
712
|
+
the take in it. Checked, with the config, before recording
|
|
713
|
+
sources --local Screens and windows the local recorder can use
|
|
714
|
+
(add --source mac-screen for Clipy Local's ids)
|
|
715
|
+
local setup [flags] Choose who picks spoken moments and who transcribes
|
|
716
|
+
--model-provider openrouter|openai|gemini|groq|ollama|lmstudio|custom|none
|
|
717
|
+
--model-key - --model <name> --base-url <url>
|
|
718
|
+
--transcribe local-english|local-multilingual|openai|groq|deepgram|assemblyai|elevenlabs|gemini|none
|
|
719
|
+
--transcribe-key -
|
|
720
|
+
${c.dim("A key of - is read from stdin. Better still, set")}
|
|
721
|
+
${c.dim("CLIPY_MODEL_API_KEY or CLIPY_TRANSCRIBE_API_KEY in your")}
|
|
722
|
+
${c.dim("environment; a key typed on the command line can stay in")}
|
|
723
|
+
${c.dim("shell history and the process list.")}
|
|
724
|
+
local status [--json] Config file, provider, transcription, models, capture
|
|
725
|
+
models list | models download <english-fast|multilingual>
|
|
726
|
+
On-device speech models (one-time download, about
|
|
727
|
+
104 MB and 161 MB)
|
|
728
|
+
speech status | speech install The engine that runs them (sherpa-onnx-node, about
|
|
729
|
+
35 MB). Not installed with the CLI: a take that
|
|
730
|
+
needs it asks first. --yes or
|
|
731
|
+
CLIPY_INSTALL_SPEECH_ENGINE=1 accepts up front
|
|
732
|
+
${c.dim("Want a share link anyone can watch, with no signup to watch? clipy upload <file>.")}
|
|
733
|
+
|
|
532
734
|
${c.bold("AGENTS")}
|
|
533
735
|
setup [claude|codex|cursor|windsurf|opencode] [--with-browser]
|
|
534
736
|
Wire Clipy into a coding agent in ONE command:
|
|
@@ -554,8 +756,10 @@ ${c.bold("AGENTS")}
|
|
|
554
756
|
installing the Clipy extension and signing in
|
|
555
757
|
there, then waits until it is ready. install-app
|
|
556
758
|
saves a named macOS launcher in ~/Applications
|
|
557
|
-
doctor [--json]
|
|
558
|
-
Playwright, and install mode
|
|
759
|
+
doctor [--json] [--local] Health check: API key, Mac agent bridge,
|
|
760
|
+
Playwright, and install mode, with fix hints.
|
|
761
|
+
Also reports local mode (never a failure);
|
|
762
|
+
--local checks only local mode, no request to Clipy
|
|
559
763
|
guide --json Machine-readable manifest: every command,
|
|
560
764
|
flag, env var, and exit code
|
|
561
765
|
playwright-path [--json] Print the node_modules dir of the Playwright
|
|
@@ -1584,23 +1788,51 @@ function doctorLinuxScreenChecks() {
|
|
|
1584
1788
|
}
|
|
1585
1789
|
return out;
|
|
1586
1790
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1791
|
+
/**
|
|
1792
|
+
* Local mode (--local) in doctor: what it would use and whether it can run.
|
|
1793
|
+
* Informational until the user has a local config file; even then a missing
|
|
1794
|
+
* piece is a warning, never a failure, because local mode is optional.
|
|
1795
|
+
*/
|
|
1796
|
+
async function doctorLocalChecks() {
|
|
1797
|
+
let checks;
|
|
1798
|
+
try {
|
|
1799
|
+
const { mod, env } = await localMode();
|
|
1800
|
+
checks = await mod.localChecks(env);
|
|
1801
|
+
}
|
|
1802
|
+
catch (error) {
|
|
1803
|
+
return [{ name: "local mode", status: "info", detail: `unavailable: ${error.message}` }];
|
|
1804
|
+
}
|
|
1805
|
+
const configured = checks.some((chk) => chk.name === "local config" && chk.data?.exists);
|
|
1806
|
+
return checks.map((chk) => ({
|
|
1807
|
+
name: chk.name,
|
|
1808
|
+
status: chk.status === "pass" ? "pass" : chk.status === "warn" && configured ? "warn" : "info",
|
|
1809
|
+
detail: chk.detail,
|
|
1810
|
+
...(chk.hint ? { hint: chk.hint } : {}),
|
|
1811
|
+
...(chk.data ? { data: chk.data } : {}),
|
|
1812
|
+
}));
|
|
1813
|
+
}
|
|
1814
|
+
async function cmdDoctor(ctx, json, localOnly = false) {
|
|
1815
|
+
// --local: only what local mode uses. No API or sign-in check, so doctor
|
|
1816
|
+
// makes no request to Clipy.
|
|
1817
|
+
const checks = localOnly
|
|
1818
|
+
? await doctorLocalChecks()
|
|
1819
|
+
: [
|
|
1820
|
+
await doctorApiCheck(ctx),
|
|
1821
|
+
await doctorAuthCheck(ctx),
|
|
1822
|
+
...(await doctorBridgeChecks()),
|
|
1823
|
+
await doctorPlaywrightCheck(),
|
|
1824
|
+
doctorChromeCheck(),
|
|
1825
|
+
await doctorYtDlpCheck(),
|
|
1826
|
+
...(await doctorFfmpegChecks()),
|
|
1827
|
+
...doctorLinuxScreenChecks(),
|
|
1828
|
+
doctorInstallCheck(),
|
|
1829
|
+
...(await doctorLocalChecks()),
|
|
1830
|
+
];
|
|
1599
1831
|
const failed = checks.filter((chk) => chk.status === "fail").length;
|
|
1600
1832
|
if (json) {
|
|
1601
1833
|
printJson({
|
|
1602
1834
|
version: VERSION,
|
|
1603
|
-
apiUrl: ctx.apiUrl,
|
|
1835
|
+
...(localOnly ? { local: true } : { apiUrl: ctx.apiUrl }),
|
|
1604
1836
|
ok: failed === 0,
|
|
1605
1837
|
checks: checks.map((chk) => ({
|
|
1606
1838
|
name: chk.name,
|
|
@@ -1614,8 +1846,15 @@ async function cmdDoctor(ctx, json) {
|
|
|
1614
1846
|
process.exitCode = 1;
|
|
1615
1847
|
return;
|
|
1616
1848
|
}
|
|
1617
|
-
process.stdout.write(
|
|
1849
|
+
process.stdout.write(localOnly
|
|
1850
|
+
? `${c.bold("clipy doctor --local")} ${c.dim(`· v${VERSION} · no request to Clipy`)}\n\n`
|
|
1851
|
+
: `${c.bold("clipy doctor")} ${c.dim(`· v${VERSION} · ${ctx.apiUrl}`)}\n\n`);
|
|
1852
|
+
let localHeader = false;
|
|
1618
1853
|
for (const chk of checks) {
|
|
1854
|
+
if (!localHeader && chk.name.startsWith("local ")) {
|
|
1855
|
+
localHeader = true;
|
|
1856
|
+
process.stdout.write(`\n${c.bold("Local mode")} ${c.dim("(--local: no account, nothing uploaded; never a failure)")}\n`);
|
|
1857
|
+
}
|
|
1619
1858
|
// Pad to the longest check name ("bridge handshake") so details align.
|
|
1620
1859
|
process.stdout.write(`${doctorGlyph(chk.status)} ${chk.name.padEnd(16)} ${chk.detail}\n`);
|
|
1621
1860
|
if (chk.hint)
|
|
@@ -2147,6 +2386,7 @@ async function uploadVideoToClipy(ctx, opts) {
|
|
|
2147
2386
|
...(opts.accessMode ? { accessMode: opts.accessMode } : {}),
|
|
2148
2387
|
...(opts.nameIsUserProvided && opts.name ? { nameIsUserProvided: true } : {}),
|
|
2149
2388
|
...(opts.recordingKind ? { recordingKind: opts.recordingKind } : {}),
|
|
2389
|
+
...(opts.expectedResult ? { expectedResult: opts.expectedResult } : {}),
|
|
2150
2390
|
...(opts.narration && (opts.narration.text || opts.narration.notes?.length)
|
|
2151
2391
|
? { narration: opts.narration }
|
|
2152
2392
|
: {}),
|
|
@@ -2246,6 +2486,7 @@ async function cmdUpload(ctx, file, opts) {
|
|
|
2246
2486
|
nameIsUserProvided: opts.name !== undefined,
|
|
2247
2487
|
description: opts.description,
|
|
2248
2488
|
recordingKind: opts.recordingKind,
|
|
2489
|
+
expectedResult: opts.expectedResult,
|
|
2249
2490
|
narration: notes.length > 0 ? { notes } : undefined,
|
|
2250
2491
|
accessMode,
|
|
2251
2492
|
sourceVersion: `cli/${VERSION}`,
|
|
@@ -2328,13 +2569,31 @@ async function cmdProof(ctx, opts) {
|
|
|
2328
2569
|
if (maxPassRef(opts.notes) > 0) {
|
|
2329
2570
|
die('proof notes use absolute timestamps such as --note "3: saved state"; passN notes need record --viewports', 2);
|
|
2330
2571
|
}
|
|
2331
|
-
|
|
2572
|
+
if (opts.local && opts.verificationFor) {
|
|
2573
|
+
die("--for links a proof to a recording in your Clipy library; it does not apply with --local", 2);
|
|
2574
|
+
}
|
|
2575
|
+
if (!opts.local)
|
|
2576
|
+
requireKey(ctx);
|
|
2332
2577
|
const verificationFor = opts.verificationFor
|
|
2333
2578
|
? normalizeId(opts.verificationFor, ctx)
|
|
2334
2579
|
: null;
|
|
2335
2580
|
if (verificationFor) {
|
|
2336
2581
|
await apiJson(ctx, `/api/v1/recordings/${encodeURIComponent(verificationFor)}`);
|
|
2337
2582
|
}
|
|
2583
|
+
// --local: config, provider, ffmpeg and --out first, before frames are rendered.
|
|
2584
|
+
// The frames and video are inputs: an --out that holds them is refused.
|
|
2585
|
+
const prepared = opts.local
|
|
2586
|
+
? await prepareLocalOrExit({
|
|
2587
|
+
out: opts.local.out,
|
|
2588
|
+
force: opts.local.force,
|
|
2589
|
+
json: opts.json,
|
|
2590
|
+
inputs: [...opts.framePaths, ...(opts.videoPath ? [opts.videoPath] : [])],
|
|
2591
|
+
// Frames make a silent video; a supplied --video may have speech.
|
|
2592
|
+
speech: Boolean(opts.videoPath),
|
|
2593
|
+
speechFile: opts.videoPath,
|
|
2594
|
+
})
|
|
2595
|
+
: undefined;
|
|
2596
|
+
let localStarted = false;
|
|
2338
2597
|
const tmpDir = join(tmpdir(), `clipy-proof-${randomUUID()}`);
|
|
2339
2598
|
let generatedVideo = false;
|
|
2340
2599
|
let videoPath = opts.videoPath ? resolve(opts.videoPath) : "";
|
|
@@ -2378,12 +2637,49 @@ async function cmdProof(ctx, opts) {
|
|
|
2378
2637
|
if (narrationNotes.length > 200) {
|
|
2379
2638
|
throw new Error("proof supports at most 200 captions/notes");
|
|
2380
2639
|
}
|
|
2640
|
+
if (opts.local) {
|
|
2641
|
+
// Every frame gets a key moment (its caption, or its number), taken in
|
|
2642
|
+
// the middle of its hold so the screenshot is that frame.
|
|
2643
|
+
const local = narrationNotes.filter((n) => !/^\[proof frame \d+\/\d+\]/.test(n.text)).map((n) => ({ ...n }));
|
|
2644
|
+
const holdMs = Math.round(opts.holdSeconds * 1000);
|
|
2645
|
+
opts.framePaths.forEach((_frame, index) => {
|
|
2646
|
+
const caption = opts.captions[index]?.trim();
|
|
2647
|
+
local.push({
|
|
2648
|
+
startMs: index * holdMs,
|
|
2649
|
+
endMs: (index + 1) * holdMs,
|
|
2650
|
+
frameAtMs: index * holdMs + Math.floor(holdMs / 2),
|
|
2651
|
+
text: `[proof frame ${index + 1}/${opts.framePaths.length}]${caption ? ` ${caption}` : ""}`,
|
|
2652
|
+
});
|
|
2653
|
+
});
|
|
2654
|
+
local.sort((a, b) => a.startMs - b.startMs);
|
|
2655
|
+
localStarted = true;
|
|
2656
|
+
const ok = await finishLocalTake({
|
|
2657
|
+
videoPath,
|
|
2658
|
+
moveVideo: generatedVideo,
|
|
2659
|
+
prepared,
|
|
2660
|
+
title: opts.name ?? "Agent verification proof",
|
|
2661
|
+
description: opts.description,
|
|
2662
|
+
expectedResult: opts.expectedResult,
|
|
2663
|
+
recordingKind: opts.recordingKind,
|
|
2664
|
+
narration: local,
|
|
2665
|
+
origin: hasFrames ? { kind: "capture", sourceName: "proof frames" } : { kind: "import", fileName: basename(videoPath) },
|
|
2666
|
+
json: opts.json,
|
|
2667
|
+
}, {
|
|
2668
|
+
source: hasFrames
|
|
2669
|
+
? { kind: "proof-frames", frameCount: opts.framePaths.length, holdSeconds: opts.holdSeconds, durationSeconds }
|
|
2670
|
+
: { kind: "proof-video" },
|
|
2671
|
+
});
|
|
2672
|
+
if (!ok)
|
|
2673
|
+
process.exitCode = 1;
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2381
2676
|
const uploaded = await uploadVideoToClipy(ctx, {
|
|
2382
2677
|
videoPath,
|
|
2383
2678
|
name: opts.name ?? "Agent verification proof",
|
|
2384
2679
|
description: opts.description,
|
|
2385
2680
|
narration: narrationNotes.length > 0 ? { notes: narrationNotes } : undefined,
|
|
2386
2681
|
recordingKind: opts.recordingKind,
|
|
2682
|
+
expectedResult: opts.expectedResult,
|
|
2387
2683
|
sourceVersion: `cli-proof/${VERSION}`,
|
|
2388
2684
|
log,
|
|
2389
2685
|
});
|
|
@@ -2432,6 +2728,8 @@ async function cmdProof(ctx, opts) {
|
|
|
2432
2728
|
if (generatedVideo || existsSync(tmpDir)) {
|
|
2433
2729
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
2434
2730
|
}
|
|
2731
|
+
if (prepared && !localStarted)
|
|
2732
|
+
await releaseLocalOut(prepared.dir);
|
|
2435
2733
|
}
|
|
2436
2734
|
if (failure)
|
|
2437
2735
|
die(failure.message);
|
|
@@ -2825,16 +3123,18 @@ function sweepStaleProfileCopies() {
|
|
|
2825
3123
|
* context tears down that browser. */
|
|
2826
3124
|
async function launchRecordingContext(chromium, opts) {
|
|
2827
3125
|
const recordVideo = { dir: opts.recordVideoDir, size: opts.viewport };
|
|
3126
|
+
const signals = opts.callerHandlesSignals ? { handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false } : {};
|
|
2828
3127
|
if (opts.userDataDir) {
|
|
2829
3128
|
const context = await chromium.launchPersistentContext(opts.userDataDir, {
|
|
2830
3129
|
headless: true,
|
|
2831
3130
|
viewport: opts.viewport,
|
|
2832
3131
|
recordVideo,
|
|
2833
3132
|
args: opts.args,
|
|
3133
|
+
...signals,
|
|
2834
3134
|
});
|
|
2835
3135
|
return { context, browser: null };
|
|
2836
3136
|
}
|
|
2837
|
-
const browser = await chromium.launch({ headless: true, args: opts.args });
|
|
3137
|
+
const browser = await chromium.launch({ headless: true, args: opts.args, ...signals });
|
|
2838
3138
|
const context = await browser.newContext({
|
|
2839
3139
|
viewport: opts.viewport,
|
|
2840
3140
|
recordVideo,
|
|
@@ -2858,27 +3158,15 @@ async function cmdRecord(ctx, opts) {
|
|
|
2858
3158
|
validateAuthCapture(opts.auth, target.href); // usage errors (exit 2) before auth/browser
|
|
2859
3159
|
if (opts.userDataDir)
|
|
2860
3160
|
validateUserDataDir(opts.userDataDir, opts.profileDirectory);
|
|
2861
|
-
|
|
3161
|
+
if (!opts.local)
|
|
3162
|
+
requireKey(ctx); // fail fast before we spin up a browser
|
|
2862
3163
|
sweepStaleProfileCopies(); // clear any profile copy a prior SIGKILL stranded
|
|
2863
3164
|
const chromium = await loadChromium();
|
|
2864
3165
|
const tmpDir = join(tmpdir(), `clipy-record-${randomUUID()}`);
|
|
2865
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
2866
3166
|
const log = (m) => {
|
|
2867
3167
|
if (!opts.json)
|
|
2868
3168
|
process.stderr.write(`${m}\n`);
|
|
2869
3169
|
};
|
|
2870
|
-
// --profile-directory ⇒ copy the named profile into a scratch root's Default and
|
|
2871
|
-
// launch against THAT (Playwright can't select a named profile in-place). The
|
|
2872
|
-
// copy is disclosed loudly and cleaned up in the finally below. Always writes
|
|
2873
|
-
// the disclosure to stderr, even under --json (no silent profile substitution).
|
|
2874
|
-
let profileScratchRoot;
|
|
2875
|
-
const launchUserDataDir = (() => {
|
|
2876
|
-
if (opts.userDataDir && opts.profileDirectory) {
|
|
2877
|
-
profileScratchRoot = copyProfileToScratchRoot(opts.userDataDir, opts.profileDirectory, (m) => process.stderr.write(`${m}\n`));
|
|
2878
|
-
return profileScratchRoot;
|
|
2879
|
-
}
|
|
2880
|
-
return opts.userDataDir;
|
|
2881
|
-
})();
|
|
2882
3170
|
// Multi-viewport mode records every size sequentially into ONE video; the
|
|
2883
3171
|
// frame is sized to the largest viewport and smaller passes letterbox
|
|
2884
3172
|
// inside it. Each pass emits an auto note so the transcript chapters the
|
|
@@ -2897,11 +3185,43 @@ async function cmdRecord(ctx, opts) {
|
|
|
2897
3185
|
die(`--note "pass${maxRef}: …" refers to pass ${maxRef}, but this recording has ${passes.length} pass${passes.length === 1 ? "" : "es"}` +
|
|
2898
3186
|
`${opts.viewports ? "" : " (pass-scoped notes are for --viewports; use an absolute timestamp otherwise)"}`, 2);
|
|
2899
3187
|
}
|
|
2900
|
-
|
|
3188
|
+
// --local: config, provider, ffmpeg and --out are settled before the browser
|
|
3189
|
+
// records anything, so none of them can cost the take afterwards.
|
|
3190
|
+
const prepared = opts.local
|
|
3191
|
+
? await prepareLocalOrExit({ out: opts.local.out, force: opts.local.force, json: opts.json })
|
|
3192
|
+
: undefined;
|
|
3193
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
3194
|
+
// --profile-directory ⇒ copy the named profile into a scratch root's Default and
|
|
3195
|
+
// launch against THAT (Playwright can't select a named profile in-place). The
|
|
3196
|
+
// copy is disclosed loudly and cleaned up in the finally below. Always writes
|
|
3197
|
+
// the disclosure to stderr, even under --json (no silent profile substitution).
|
|
3198
|
+
let profileScratchRoot;
|
|
3199
|
+
const launchUserDataDir = (() => {
|
|
3200
|
+
if (opts.userDataDir && opts.profileDirectory) {
|
|
3201
|
+
profileScratchRoot = copyProfileToScratchRoot(opts.userDataDir, opts.profileDirectory, (m) => process.stderr.write(`${m}\n`));
|
|
3202
|
+
return profileScratchRoot;
|
|
3203
|
+
}
|
|
3204
|
+
return opts.userDataDir;
|
|
3205
|
+
})();
|
|
3206
|
+
// --local: Ctrl-C, SIGTERM or SIGHUP end the capture early and the take is
|
|
3207
|
+
// still built (Playwright is told not to kill the browser on them).
|
|
3208
|
+
let stopEarly = () => { };
|
|
3209
|
+
let stoppedEarly = false;
|
|
3210
|
+
const stopRequested = new Promise((resolveStop) => {
|
|
3211
|
+
stopEarly = () => {
|
|
3212
|
+
if (!stoppedEarly)
|
|
3213
|
+
log(c.dim("stopping early; building the take…"));
|
|
3214
|
+
stoppedEarly = true;
|
|
3215
|
+
resolveStop();
|
|
3216
|
+
};
|
|
3217
|
+
});
|
|
3218
|
+
const releaseSignals = opts.local ? onStopSignal(() => stopEarly()) : () => { };
|
|
3219
|
+
let uploaded = null;
|
|
2901
3220
|
const autoNotes = [];
|
|
2902
3221
|
// The real start of each pass, measured from the capture clock (index 0 =
|
|
2903
3222
|
// pass 1). Pass-scoped notes anchor to these actual times, not fixed guesses.
|
|
2904
3223
|
const passStartsMs = [];
|
|
3224
|
+
let capturedLocally = false;
|
|
2905
3225
|
try {
|
|
2906
3226
|
// --- Capture -----------------------------------------------------------
|
|
2907
3227
|
let videoPath;
|
|
@@ -2916,7 +3236,10 @@ async function cmdRecord(ctx, opts) {
|
|
|
2916
3236
|
recordVideoDir: tmpDir,
|
|
2917
3237
|
args: ["--no-sandbox", "--disable-dev-shm-usage"],
|
|
2918
3238
|
storageStatePath: opts.auth.storageStatePath,
|
|
3239
|
+
callerHandlesSignals: Boolean(opts.local),
|
|
2919
3240
|
});
|
|
3241
|
+
// A wait that a stop signal (--local only) cuts short.
|
|
3242
|
+
const hold = (page, ms) => Promise.race([page.waitForTimeout(ms), stopRequested]);
|
|
2920
3243
|
try {
|
|
2921
3244
|
// Seed cookies/localStorage/init-script before the first navigation. These
|
|
2922
3245
|
// compose with a persistent profile too; --storage-state does not (rejected
|
|
@@ -2927,6 +3250,8 @@ async function cmdRecord(ctx, opts) {
|
|
|
2927
3250
|
// and pass marks aren't anchored to the blank t=0 a compiling app shows.
|
|
2928
3251
|
let captureStart = 0;
|
|
2929
3252
|
for (const [i, vp] of passes.entries()) {
|
|
3253
|
+
if (stoppedEarly)
|
|
3254
|
+
break;
|
|
2930
3255
|
if (opts.viewports) {
|
|
2931
3256
|
await page.setViewportSize({ width: vp.width, height: vp.height }).catch(() => { });
|
|
2932
3257
|
log(`${c.dim(`viewport ${vp.label}…`)}`);
|
|
@@ -2961,13 +3286,13 @@ async function cmdRecord(ctx, opts) {
|
|
|
2961
3286
|
// just the fold. Scroll in ~6 steps across the pass duration.
|
|
2962
3287
|
const steps = 6;
|
|
2963
3288
|
const stepMs = (opts.forSec * 1000) / steps;
|
|
2964
|
-
for (let s = 0; s < steps; s++) {
|
|
2965
|
-
await page
|
|
3289
|
+
for (let s = 0; s < steps && !stoppedEarly; s++) {
|
|
3290
|
+
await hold(page, stepMs);
|
|
2966
3291
|
await page.mouse.wheel(0, Math.round(vp.height * 0.7)).catch(() => { });
|
|
2967
3292
|
}
|
|
2968
3293
|
}
|
|
2969
3294
|
else {
|
|
2970
|
-
await page
|
|
3295
|
+
await hold(page, opts.forSec * 1000);
|
|
2971
3296
|
}
|
|
2972
3297
|
}
|
|
2973
3298
|
const video = page.video();
|
|
@@ -2988,16 +3313,40 @@ async function cmdRecord(ctx, opts) {
|
|
|
2988
3313
|
}
|
|
2989
3314
|
// --- Upload ------------------------------------------------------------
|
|
2990
3315
|
const notes = [...autoNotes, ...resolveNarrationNotes(opts.notes, passStartsMs)].sort((a, b) => a.startMs - b.startMs);
|
|
3316
|
+
if (opts.local) {
|
|
3317
|
+
// --local: the same capture, built into an AREC here instead of uploaded.
|
|
3318
|
+
// A failure from here on keeps the video in the take folder.
|
|
3319
|
+
capturedLocally = true;
|
|
3320
|
+
releaseSignals();
|
|
3321
|
+
await finishLocalTake({
|
|
3322
|
+
videoPath,
|
|
3323
|
+
moveVideo: true,
|
|
3324
|
+
prepared,
|
|
3325
|
+
title: opts.name ?? `Recording of ${target.href}`,
|
|
3326
|
+
description: opts.description,
|
|
3327
|
+
expectedResult: opts.expectedResult,
|
|
3328
|
+
recordingKind: opts.recordingKind,
|
|
3329
|
+
narration: localNarration(notes),
|
|
3330
|
+
origin: { kind: "capture", sourceName: target.href },
|
|
3331
|
+
json: opts.json,
|
|
3332
|
+
}, { source: { kind: "web", url: target.href } });
|
|
3333
|
+
return;
|
|
3334
|
+
}
|
|
2991
3335
|
uploaded = await uploadVideoToClipy(ctx, {
|
|
2992
3336
|
videoPath,
|
|
2993
3337
|
name: opts.name,
|
|
2994
3338
|
description: opts.description,
|
|
2995
3339
|
recordingKind: opts.recordingKind,
|
|
3340
|
+
expectedResult: opts.expectedResult,
|
|
2996
3341
|
narration: notes.length ? { notes } : undefined,
|
|
2997
3342
|
log,
|
|
2998
3343
|
});
|
|
2999
3344
|
}
|
|
3000
3345
|
finally {
|
|
3346
|
+
releaseSignals();
|
|
3347
|
+
// A --local take that never captured anything leaves no empty folder.
|
|
3348
|
+
if (prepared && !capturedLocally)
|
|
3349
|
+
await releaseLocalOut(prepared.dir);
|
|
3001
3350
|
try {
|
|
3002
3351
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
3003
3352
|
}
|
|
@@ -3013,6 +3362,8 @@ async function cmdRecord(ctx, opts) {
|
|
|
3013
3362
|
}
|
|
3014
3363
|
}
|
|
3015
3364
|
}
|
|
3365
|
+
if (!uploaded)
|
|
3366
|
+
return; // --local printed its own result
|
|
3016
3367
|
if (opts.wait && uploaded.publicId) {
|
|
3017
3368
|
log(`${c.dim("waiting for transcript…")}`);
|
|
3018
3369
|
await waitForArtifacts(ctx, uploaded.publicId).catch(() => {
|
|
@@ -3566,7 +3917,8 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3566
3917
|
}
|
|
3567
3918
|
if (existing)
|
|
3568
3919
|
reportKeptCapture(cleanupSessionFiles(existing, file));
|
|
3569
|
-
const key = requireKey(ctx);
|
|
3920
|
+
const key = opts.local ? null : requireKey(ctx);
|
|
3921
|
+
const localOut = opts.local ? await localSessionOut(opts.local.out, opts.local.force, opts.json) : undefined;
|
|
3570
3922
|
const plan = planLinuxCapture(opts);
|
|
3571
3923
|
const maxSec = Math.min(Math.max(1, opts.maxSec), SESSION_HARD_CAP_SEC);
|
|
3572
3924
|
const id = randomUUID();
|
|
@@ -3585,9 +3937,11 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3585
3937
|
name: opts.name,
|
|
3586
3938
|
description: opts.description,
|
|
3587
3939
|
recordingKind: opts.recordingKind,
|
|
3940
|
+
expectedResult: opts.expectedResult,
|
|
3588
3941
|
maxSec,
|
|
3589
3942
|
width: opts.width,
|
|
3590
3943
|
height: opts.height,
|
|
3944
|
+
...(localOut ? { local: { out: localOut } } : {}),
|
|
3591
3945
|
state: "starting",
|
|
3592
3946
|
marksPath: join(dir, `marks-${id}.jsonl`),
|
|
3593
3947
|
controlPath: join(dir, `control-${id}.json`),
|
|
@@ -3598,7 +3952,7 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3598
3952
|
const child = spawn(process.execPath, [process.argv[1], "__session-daemon", file], {
|
|
3599
3953
|
detached: true,
|
|
3600
3954
|
stdio: ["ignore", logFd, logFd],
|
|
3601
|
-
env: { ...process.env, CLIPY_API_KEY: key, CLIPY_API_URL: ctx.apiUrl },
|
|
3955
|
+
env: { ...process.env, ...(key ? { CLIPY_API_KEY: key } : {}), CLIPY_API_URL: ctx.apiUrl },
|
|
3602
3956
|
});
|
|
3603
3957
|
closeSync(logFd);
|
|
3604
3958
|
if (!child.pid)
|
|
@@ -3636,10 +3990,13 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3636
3990
|
sessionFile: file,
|
|
3637
3991
|
source: captureSourceResult(plan.resolved),
|
|
3638
3992
|
...(plan.windowCapture ? { windowCapture: plan.windowCapture } : {}),
|
|
3993
|
+
...(localOut ? { local: true, out: localOut } : {}),
|
|
3639
3994
|
});
|
|
3640
3995
|
return;
|
|
3641
3996
|
}
|
|
3642
3997
|
process.stdout.write(`${c.green("✓")} recording ${plan.label} on ${xDisplay} (max ${maxSec}s)\n`);
|
|
3998
|
+
if (localOut)
|
|
3999
|
+
process.stdout.write(`${c.dim("local mode:")} nothing is uploaded; the AREC is written to ${localOut} at stop\n`);
|
|
3643
4000
|
if (plan.virtualDisplay) {
|
|
3644
4001
|
process.stdout.write(`${c.bold("virtual display:")} ${xDisplay}: only what you launch there is recorded, and it never touches the user's screen.\n` +
|
|
3645
4002
|
`${c.dim("launch apps on it with:")} DISPLAY=${xDisplay} <command> ${c.dim("(or use clipy session run, which sets DISPLAY)")}\n`);
|
|
@@ -3652,21 +4009,226 @@ async function cmdSessionStartLinux(ctx, opts) {
|
|
|
3652
4009
|
process.stdout.write(`${c.dim("while it runs:")} clipy mark "what just happened"\n` +
|
|
3653
4010
|
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
3654
4011
|
}
|
|
4012
|
+
/**
|
|
4013
|
+
* `clipy record --local`: the capture each flag combination uses today, with
|
|
4014
|
+
* the upload replaced by the local pipeline.
|
|
4015
|
+
*
|
|
4016
|
+
* - `--url <u>`: the headless browser capture (silent; notes become narration).
|
|
4017
|
+
* - `--source screen` on Linux: the CLI's X11 recorder, as without --local.
|
|
4018
|
+
* - no `--url` and no `--source`, or `--source screen` on macOS or Windows:
|
|
4019
|
+
* the local capture package (ffmpeg), until Enter, Ctrl-C or `--max`.
|
|
4020
|
+
*
|
|
4021
|
+
* Never needs `clipy login`.
|
|
4022
|
+
*/
|
|
4023
|
+
async function cmdRecordLocalDispatch(ctx, values, rest, h) {
|
|
4024
|
+
const str = (k) => typeof values[k] === "string" ? values[k].trim() || undefined : undefined;
|
|
4025
|
+
const out = str("out");
|
|
4026
|
+
const url = str("url") || rest[0]?.trim() || undefined;
|
|
4027
|
+
const rawSource = str("source");
|
|
4028
|
+
const name = str("title") ?? str("name");
|
|
4029
|
+
const description = str("description");
|
|
4030
|
+
const recordingKind = values.type ? requireRecordingKind(String(values.type)) : undefined;
|
|
4031
|
+
const notes = (values.note ?? []).map(parseNoteFlag);
|
|
4032
|
+
const window = str("window");
|
|
4033
|
+
const display = str("display");
|
|
4034
|
+
if (window && display)
|
|
4035
|
+
die("--window and --display are mutually exclusive: pick one capture source", 2);
|
|
4036
|
+
if (url) {
|
|
4037
|
+
if (rawSource && rawSource !== "web") {
|
|
4038
|
+
die("--url records a web page in a headless browser; drop --source, or record the screen without --url", 2);
|
|
4039
|
+
}
|
|
4040
|
+
if (h.audioFlagsPresent) {
|
|
4041
|
+
die("--mic/--no-system-audio: a headless web capture records no audio; drop the audio flag", 2);
|
|
4042
|
+
}
|
|
4043
|
+
if (values["virtual-display"] || values["x-display"] || window || display) {
|
|
4044
|
+
die("--virtual-display, --x-display, --window and --display record the screen; drop --url to use them", 2);
|
|
4045
|
+
}
|
|
4046
|
+
await cmdRecord(ctx, {
|
|
4047
|
+
url,
|
|
4048
|
+
forSec: h.num(values.for ?? values.max, 15),
|
|
4049
|
+
name,
|
|
4050
|
+
description,
|
|
4051
|
+
recordingKind,
|
|
4052
|
+
expectedResult: h.expectedResult,
|
|
4053
|
+
notes,
|
|
4054
|
+
viewports: values.viewports ? parseViewports(String(values.viewports)) : null,
|
|
4055
|
+
width: h.num(values.width, 1280),
|
|
4056
|
+
height: h.num(values.height, 720),
|
|
4057
|
+
wait: false,
|
|
4058
|
+
json: h.json,
|
|
4059
|
+
auth: h.authCapture(),
|
|
4060
|
+
userDataDir: h.userDataDir(),
|
|
4061
|
+
profileDirectory: h.profileDirectory(),
|
|
4062
|
+
local: { out, force: Boolean(values.force) },
|
|
4063
|
+
});
|
|
4064
|
+
return;
|
|
4065
|
+
}
|
|
4066
|
+
if (rawSource === "web")
|
|
4067
|
+
die("usage: clipy record --local --url <http(s) url> [--for <sec>] [--out <dir>]", 2);
|
|
4068
|
+
if (isLocalMacSource(rawSource)) {
|
|
4069
|
+
if (!bridgeApplicable("local"))
|
|
4070
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
4071
|
+
if (out || values.force)
|
|
4072
|
+
die(LOCAL_MAC_OUT, 2);
|
|
4073
|
+
if (h.authFlagsPresent) {
|
|
4074
|
+
die("auth state (--storage-state/--user-data-dir/--cookie/--local-storage/--init-script) applies to --url captures; --source mac-screen records the real, already signed-in screen", 2);
|
|
4075
|
+
}
|
|
4076
|
+
if (values.viewports)
|
|
4077
|
+
die("--viewports applies to --url captures", 2);
|
|
4078
|
+
if (values["x-display"] || values["virtual-display"])
|
|
4079
|
+
die("--x-display/--virtual-display apply to --source screen on Linux", 2);
|
|
4080
|
+
const forSec = h.num(values.for ?? values.max, 15);
|
|
4081
|
+
// Clipy Local's watchdog stops a bridge take at 1800 s.
|
|
4082
|
+
if (forSec > 1740)
|
|
4083
|
+
die("--for is capped at 1740s for --source mac-screen (the app stops at 1800s)", 2);
|
|
4084
|
+
await cmdRecordMacLocal({
|
|
4085
|
+
audio: h.audioChoice(),
|
|
4086
|
+
forSec,
|
|
4087
|
+
name,
|
|
4088
|
+
description,
|
|
4089
|
+
recordingKind,
|
|
4090
|
+
expectedResult: h.expectedResult,
|
|
4091
|
+
window,
|
|
4092
|
+
display,
|
|
4093
|
+
notes,
|
|
4094
|
+
json: h.json,
|
|
4095
|
+
});
|
|
4096
|
+
return;
|
|
4097
|
+
}
|
|
4098
|
+
if (rawSource && rawSource !== "screen" && rawSource !== "linux-screen") {
|
|
4099
|
+
die("with --local, --source is web (with --url) or screen", 2);
|
|
4100
|
+
}
|
|
4101
|
+
if (rawSource === "linux-screen" && process.platform !== "linux") {
|
|
4102
|
+
die("--source linux-screen records an X11 display and only runs on Linux", 2);
|
|
4103
|
+
}
|
|
4104
|
+
if (h.authFlagsPresent) {
|
|
4105
|
+
die("auth state (--storage-state/--user-data-dir/--cookie/--local-storage/--init-script) applies to --url captures", 2);
|
|
4106
|
+
}
|
|
4107
|
+
if (values.viewports)
|
|
4108
|
+
die("--viewports applies to --url captures", 2);
|
|
4109
|
+
if (maxPassRef(notes) > 0) {
|
|
4110
|
+
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
4111
|
+
}
|
|
4112
|
+
if (process.platform === "linux" && rawSource) {
|
|
4113
|
+
// --source screen on Linux: today's recorder, built locally.
|
|
4114
|
+
if (h.audioFlagsPresent) {
|
|
4115
|
+
die("--mic/--no-system-audio: Linux screen recordings are silent for now (narrate with --note); drop the audio flag, or record without --source to use --mic", 2);
|
|
4116
|
+
}
|
|
4117
|
+
const forSec = h.num(values.for ?? values.max, 15);
|
|
4118
|
+
if (forSec > SESSION_HARD_CAP_SEC)
|
|
4119
|
+
die(`--for is capped at ${SESSION_HARD_CAP_SEC}s`, 2);
|
|
4120
|
+
await cmdRecordLinux(ctx, {
|
|
4121
|
+
forSec,
|
|
4122
|
+
name,
|
|
4123
|
+
description,
|
|
4124
|
+
recordingKind,
|
|
4125
|
+
expectedResult: h.expectedResult,
|
|
4126
|
+
window,
|
|
4127
|
+
display,
|
|
4128
|
+
xDisplay: str("x-display"),
|
|
4129
|
+
virtualDisplay: Boolean(values["virtual-display"]),
|
|
4130
|
+
width: h.num(values.width, 1280),
|
|
4131
|
+
height: h.num(values.height, 720),
|
|
4132
|
+
notes,
|
|
4133
|
+
json: h.json,
|
|
4134
|
+
local: { out, force: Boolean(values.force) },
|
|
4135
|
+
}).catch((e) => die(e.message));
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
// The local capture package: any OS, until Enter, Ctrl-C or --max.
|
|
4139
|
+
if (values["x-display"])
|
|
4140
|
+
die("--x-display applies to --source screen on Linux", 2);
|
|
4141
|
+
if (values["virtual-display"] && process.platform !== "linux")
|
|
4142
|
+
die("--virtual-display needs Linux with Xvfb", 2);
|
|
4143
|
+
const maxRaw = values.max ?? values.for;
|
|
4144
|
+
let maxSeconds;
|
|
4145
|
+
if (maxRaw !== undefined) {
|
|
4146
|
+
maxSeconds = Number(maxRaw);
|
|
4147
|
+
if (!Number.isFinite(maxSeconds) || maxSeconds <= 0)
|
|
4148
|
+
die("--max must be a number of seconds above 0", 2);
|
|
4149
|
+
if (maxSeconds > SESSION_HARD_CAP_SEC * 4)
|
|
4150
|
+
die(`--max is capped at ${SESSION_HARD_CAP_SEC * 4}s`, 2);
|
|
4151
|
+
}
|
|
4152
|
+
const { mod, env } = await localMode();
|
|
4153
|
+
process.exitCode = await mod.localCaptureRecord({
|
|
4154
|
+
source: window ?? display,
|
|
4155
|
+
maxSeconds,
|
|
4156
|
+
mic: Boolean(values.mic),
|
|
4157
|
+
virtualDisplay: values["virtual-display"]
|
|
4158
|
+
? { width: h.num(values.width, 1280), height: h.num(values.height, 720) }
|
|
4159
|
+
: undefined,
|
|
4160
|
+
out,
|
|
4161
|
+
force: Boolean(values.force),
|
|
4162
|
+
title: name,
|
|
4163
|
+
description,
|
|
4164
|
+
expectedResult: h.expectedResult,
|
|
4165
|
+
recordingKind,
|
|
4166
|
+
narration: notes.map((n) => ({ startMs: n.startMs ?? 0, text: n.text })),
|
|
4167
|
+
json: h.json,
|
|
4168
|
+
}, env);
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* `clipy context import <file> --local`: transcribe on this machine (or with
|
|
4172
|
+
* the user's key) unless --transcript is given, pick moments, extract frames,
|
|
4173
|
+
* and write the full local AREC folder. Never calls Clipy.
|
|
4174
|
+
*/
|
|
4175
|
+
async function cmdContextImportLocal(target, opts) {
|
|
4176
|
+
const file = resolve(target);
|
|
4177
|
+
let transcript = null;
|
|
4178
|
+
if (opts.transcriptPath) {
|
|
4179
|
+
const { mod, env } = await localMode();
|
|
4180
|
+
try {
|
|
4181
|
+
const { readTranscriptFile } = await import("./local/transcriptFile.js");
|
|
4182
|
+
transcript = await readTranscriptFile(resolve(opts.transcriptPath));
|
|
4183
|
+
}
|
|
4184
|
+
catch (error) {
|
|
4185
|
+
mod.printLocalError(error, opts.json, env.io);
|
|
4186
|
+
process.exitCode = 1;
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
await finishLocalTake({
|
|
4191
|
+
videoPath: file,
|
|
4192
|
+
out: opts.out,
|
|
4193
|
+
force: opts.force,
|
|
4194
|
+
title: opts.title ?? basename(file),
|
|
4195
|
+
transcript,
|
|
4196
|
+
origin: { kind: "import", fileName: basename(file) },
|
|
4197
|
+
json: opts.json,
|
|
4198
|
+
}, { source: { kind: "local-file", fileName: basename(file) } });
|
|
4199
|
+
}
|
|
3655
4200
|
/** One-shot `clipy record --source screen --for N` on Linux. */
|
|
3656
4201
|
async function cmdRecordLinux(ctx, opts) {
|
|
3657
|
-
|
|
4202
|
+
if (!opts.local)
|
|
4203
|
+
requireKey(ctx);
|
|
3658
4204
|
if (maxPassRef(opts.notes) > 0) {
|
|
3659
4205
|
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
3660
4206
|
}
|
|
3661
4207
|
const plan = planLinuxCapture(opts);
|
|
3662
|
-
|
|
3663
|
-
const
|
|
4208
|
+
// --local: config, provider, ffmpeg and --out are settled before recording.
|
|
4209
|
+
const prepared = opts.local
|
|
4210
|
+
? await prepareLocalOrExit({ out: opts.local.out, force: opts.local.force, json: opts.json })
|
|
4211
|
+
: undefined;
|
|
4212
|
+
let localStarted = false;
|
|
4213
|
+
// --local: Ctrl-C, SIGTERM and SIGHUP end the take early and it is still
|
|
4214
|
+
// built, instead of killing the CLI and leaving ffmpeg and Xvfb running.
|
|
4215
|
+
let stopRequested = false;
|
|
4216
|
+
const releaseSignals = opts.local
|
|
4217
|
+
? onStopSignal(() => {
|
|
4218
|
+
if (!stopRequested && !opts.json)
|
|
4219
|
+
process.stderr.write(`${c.dim("stopping early; building the take…")}\n`);
|
|
4220
|
+
stopRequested = true;
|
|
4221
|
+
})
|
|
4222
|
+
: () => { };
|
|
4223
|
+
let vd = null;
|
|
3664
4224
|
const auto = [];
|
|
3665
4225
|
const workDir = join(tmpdir(), `clipy-record-${randomUUID()}`);
|
|
3666
4226
|
// Set when an upload fails: the finished video is kept for the user to
|
|
3667
4227
|
// retry, and only the intermediate segments are removed.
|
|
3668
4228
|
let keptVideo = null;
|
|
3669
4229
|
try {
|
|
4230
|
+
vd = plan.virtualDisplay ? await startVirtualDisplay(plan.virtualDisplay) : null;
|
|
4231
|
+
const xDisplay = vd?.display ?? plan.xDisplay;
|
|
3670
4232
|
if (vd) {
|
|
3671
4233
|
process.stderr.write(`${c.bold("virtual display:")} ${xDisplay}: launch apps there with DISPLAY=${xDisplay}; it closes when the recording ends.\n`);
|
|
3672
4234
|
}
|
|
@@ -3679,7 +4241,7 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3679
4241
|
if (!opts.json)
|
|
3680
4242
|
process.stderr.write(`${c.dim(`recording ${plan.label} for ${opts.forSec}s…`)}\n`);
|
|
3681
4243
|
const until = recorder.startedAt + opts.forSec * 1000;
|
|
3682
|
-
while (Date.now() < until) {
|
|
4244
|
+
while (Date.now() < until && !stopRequested) {
|
|
3683
4245
|
await new Promise((r) => setTimeout(r, 400));
|
|
3684
4246
|
let note = null;
|
|
3685
4247
|
try {
|
|
@@ -3694,11 +4256,39 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3694
4256
|
if (recorder.ended())
|
|
3695
4257
|
break;
|
|
3696
4258
|
}
|
|
3697
|
-
|
|
4259
|
+
let videoPath;
|
|
4260
|
+
try {
|
|
4261
|
+
videoPath = await recorder.finish();
|
|
4262
|
+
}
|
|
4263
|
+
catch (e) {
|
|
4264
|
+
if (!opts.local)
|
|
4265
|
+
throw e;
|
|
4266
|
+
// --local keeps what was recorded: the segments stay for the user.
|
|
4267
|
+
keptVideo = workDir;
|
|
4268
|
+
throw new Error(`${e.message}\nThe capture segments were kept at ${workDir}`);
|
|
4269
|
+
}
|
|
3698
4270
|
const notes = [
|
|
3699
4271
|
...opts.notes.map((n) => ({ startMs: n.startMs ?? 0, text: n.text })),
|
|
3700
4272
|
...auto,
|
|
3701
4273
|
].sort((a, b) => a.startMs - b.startMs);
|
|
4274
|
+
if (opts.local) {
|
|
4275
|
+
// A failure from here on keeps the video in the take folder.
|
|
4276
|
+
localStarted = true;
|
|
4277
|
+
releaseSignals();
|
|
4278
|
+
await finishLocalTake({
|
|
4279
|
+
videoPath,
|
|
4280
|
+
moveVideo: true,
|
|
4281
|
+
prepared,
|
|
4282
|
+
title: opts.name ?? `Screen recording of ${plan.label}`,
|
|
4283
|
+
description: opts.description,
|
|
4284
|
+
expectedResult: opts.expectedResult,
|
|
4285
|
+
recordingKind: opts.recordingKind,
|
|
4286
|
+
narration: localNarration(notes),
|
|
4287
|
+
origin: { kind: "capture", sourceName: plan.label },
|
|
4288
|
+
json: opts.json,
|
|
4289
|
+
}, { source: captureSourceResult(plan.resolved), ...(plan.windowCapture ? { windowCapture: plan.windowCapture } : {}) });
|
|
4290
|
+
return null;
|
|
4291
|
+
}
|
|
3702
4292
|
let uploaded;
|
|
3703
4293
|
try {
|
|
3704
4294
|
uploaded = await uploadVideoToClipy(ctx, {
|
|
@@ -3706,6 +4296,7 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3706
4296
|
name: opts.name,
|
|
3707
4297
|
description: opts.description,
|
|
3708
4298
|
recordingKind: opts.recordingKind,
|
|
4299
|
+
expectedResult: opts.expectedResult,
|
|
3709
4300
|
narration: notes.length ? { notes } : undefined,
|
|
3710
4301
|
log: (m) => {
|
|
3711
4302
|
if (!opts.json)
|
|
@@ -3727,8 +4318,14 @@ async function cmdRecordLinux(ctx, opts) {
|
|
|
3727
4318
|
};
|
|
3728
4319
|
}
|
|
3729
4320
|
finally {
|
|
4321
|
+
releaseSignals();
|
|
3730
4322
|
await vd?.stop();
|
|
3731
|
-
if (keptVideo)
|
|
4323
|
+
if (prepared && !localStarted && keptVideo !== workDir)
|
|
4324
|
+
await releaseLocalOut(prepared.dir);
|
|
4325
|
+
if (keptVideo === workDir) {
|
|
4326
|
+
// --local capture that could not be joined: everything stays.
|
|
4327
|
+
}
|
|
4328
|
+
else if (keptVideo) {
|
|
3732
4329
|
for (const name of readdirSync(workDir)) {
|
|
3733
4330
|
if (name.startsWith("segment-"))
|
|
3734
4331
|
rmSync(join(workDir, name), { force: true });
|
|
@@ -3914,6 +4511,9 @@ async function cmdRecordMac(opts) {
|
|
|
3914
4511
|
if (opts.recordingKind) {
|
|
3915
4512
|
log(c.yellow(`note: --type is not applied to --source mac-screen recordings yet (needs a Clipy app update)`));
|
|
3916
4513
|
}
|
|
4514
|
+
if (opts.expectedResult) {
|
|
4515
|
+
log(c.yellow(`note: --expected is not applied to --source mac-screen recordings yet; run clipy update <id> --expected "<text>" afterwards`));
|
|
4516
|
+
}
|
|
3917
4517
|
// Before the camera turns on, not after — see warnAudioUncontrollable().
|
|
3918
4518
|
// Deliberately NOT `log`: a "your mic may be live" warning must survive
|
|
3919
4519
|
// --json, and stderr never corrupts the JSON on stdout.
|
|
@@ -3951,12 +4551,200 @@ async function cmdRecordMac(opts) {
|
|
|
3951
4551
|
...(windowCapture ? { windowCapture } : {}),
|
|
3952
4552
|
};
|
|
3953
4553
|
}
|
|
4554
|
+
/** What a running app can capture, so --window/--display have ids. */
|
|
4555
|
+
function printBridgeSources(sources, json, hint) {
|
|
4556
|
+
if (json) {
|
|
4557
|
+
// Each entry carries the SAME `source` descriptor shape that
|
|
4558
|
+
// `session start --json` / `record --json` report for the resolved
|
|
4559
|
+
// capture, so a caller can compare "what I picked" against "what the
|
|
4560
|
+
// camera reports" with a direct object comparison — no transforming.
|
|
4561
|
+
printJson({
|
|
4562
|
+
displays: sources.displays.map((d) => ({ ...d, source: describeDisplay(d) })),
|
|
4563
|
+
windows: sources.windows.map((w) => ({ ...w, source: describeWindow(w) })),
|
|
4564
|
+
});
|
|
4565
|
+
return;
|
|
4566
|
+
}
|
|
4567
|
+
process.stdout.write(`${c.bold("DISPLAYS")}\n`);
|
|
4568
|
+
for (const d of sources.displays) {
|
|
4569
|
+
process.stdout.write(` ${d.id}\t${d.name || "display"}\t${c.dim(`${d.width}×${d.height}`)}\n`);
|
|
4570
|
+
}
|
|
4571
|
+
process.stdout.write(`${c.bold("WINDOWS")}\n`);
|
|
4572
|
+
for (const w of sources.windows) {
|
|
4573
|
+
process.stdout.write(` ${w.id}\t${windowLabel(w)}\t${c.dim(`${w.width}×${w.height}`)}\n`);
|
|
4574
|
+
}
|
|
4575
|
+
process.stdout.write(`${c.dim(hint)}\n`);
|
|
4576
|
+
}
|
|
4577
|
+
function appGoneMessage(state) {
|
|
4578
|
+
return state.bridge?.edition === "local"
|
|
4579
|
+
? "Clipy Local is no longer running, so the session was cleared. Start a new one."
|
|
4580
|
+
: "the Clipy app is no longer running — session cleared. Start a new one.";
|
|
4581
|
+
}
|
|
4582
|
+
/** Clipy Local through its bridge; a missing or wrong app is a clear error, never the official app. */
|
|
4583
|
+
function readLocalBridgeOrDie() {
|
|
4584
|
+
try {
|
|
4585
|
+
return readBridgeInfo("local");
|
|
4586
|
+
}
|
|
4587
|
+
catch (e) {
|
|
4588
|
+
die(e.message);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
/** Waits `seconds`, or less when Ctrl-C, SIGTERM or SIGHUP arrives (the take is still kept). */
|
|
4592
|
+
function waitOrStopSignal(seconds) {
|
|
4593
|
+
return new Promise((resolveWait) => {
|
|
4594
|
+
let dispose = () => { };
|
|
4595
|
+
const timer = setTimeout(() => {
|
|
4596
|
+
dispose();
|
|
4597
|
+
resolveWait();
|
|
4598
|
+
}, seconds * 1000);
|
|
4599
|
+
dispose = onStopSignal(() => {
|
|
4600
|
+
clearTimeout(timer);
|
|
4601
|
+
dispose();
|
|
4602
|
+
resolveWait();
|
|
4603
|
+
});
|
|
4604
|
+
});
|
|
4605
|
+
}
|
|
4606
|
+
/** Clipy Local's `stop` payload in the shape of the other --local results. */
|
|
4607
|
+
function localBridgeResultJson(result, extra = {}) {
|
|
4608
|
+
const arec = String(result.arecPath ?? "");
|
|
4609
|
+
const dir = typeof result.directory === "string" && result.directory ? result.directory : dirname(arec);
|
|
4610
|
+
const status = typeof result.status === "string" ? result.status : "processing";
|
|
4611
|
+
return {
|
|
4612
|
+
ok: status !== "failed",
|
|
4613
|
+
local: true,
|
|
4614
|
+
app: "Clipy Local",
|
|
4615
|
+
arec,
|
|
4616
|
+
arecPath: arec,
|
|
4617
|
+
dir,
|
|
4618
|
+
out: dir,
|
|
4619
|
+
video: join(dir, "recording.mp4"),
|
|
4620
|
+
status,
|
|
4621
|
+
message: typeof result.message === "string" ? result.message : "",
|
|
4622
|
+
recordingId: typeof result.recordingId === "string" ? result.recordingId : null,
|
|
4623
|
+
sizeBytes: Number(result.sizeBytes ?? 0),
|
|
4624
|
+
autoStopped: Boolean(result.autoStopped),
|
|
4625
|
+
...(result.timedOut ? { timedOut: true } : {}),
|
|
4626
|
+
...extra,
|
|
4627
|
+
};
|
|
4628
|
+
}
|
|
4629
|
+
/** The end of a Clipy Local take: the AREC path last on stdout, or one JSON object. */
|
|
4630
|
+
function reportLocalBridgeResult(result, json, extra = {}) {
|
|
4631
|
+
const out = localBridgeResultJson(result, extra);
|
|
4632
|
+
if (out.status === "failed")
|
|
4633
|
+
process.exitCode = 1;
|
|
4634
|
+
if (out.status !== "ready") {
|
|
4635
|
+
process.stderr.write(`Warning: Clipy Local reports ${out.status}${out.message ? `: ${out.message}` : ""}\n`);
|
|
4636
|
+
}
|
|
4637
|
+
if (json) {
|
|
4638
|
+
printJson(out);
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
process.stderr.write(`Done in Clipy Local (${out.status}). Nothing was uploaded. Give your AI agent the path below.\n` +
|
|
4642
|
+
`Want a share link anyone can watch, with no signup to watch? Run: clipy upload ${JSON.stringify(out.video)}\n`);
|
|
4643
|
+
process.stdout.write(`${out.arec}\n`);
|
|
4644
|
+
}
|
|
4645
|
+
/** `clipy record --local --source mac-screen`: one take through Clipy Local, kept on this computer. */
|
|
4646
|
+
async function cmdRecordMacLocal(opts) {
|
|
4647
|
+
if (maxPassRef(opts.notes) > 0) {
|
|
4648
|
+
die('pass-scoped --note values need --viewports; a screen recording is one take, so use "12: text"', 2);
|
|
4649
|
+
}
|
|
4650
|
+
const info = readLocalBridgeOrDie();
|
|
4651
|
+
const log = (m) => {
|
|
4652
|
+
if (!opts.json)
|
|
4653
|
+
process.stderr.write(`${m}\n`);
|
|
4654
|
+
};
|
|
4655
|
+
const target = await resolveBridgeTarget(info, opts);
|
|
4656
|
+
log(c.dim(`asking Clipy Local (v${info.appVersion || "?"}) to record ${target?.label ?? "the screen"}…`));
|
|
4657
|
+
if (target) {
|
|
4658
|
+
log(`${c.bold(`recording ${target.resolved.kind}:`)} "${target.resolved.title}" (id ${target.resolved.id})\n` +
|
|
4659
|
+
c.dim("confirm that is the surface you are driving; Clipy never brings it to the front for you."));
|
|
4660
|
+
}
|
|
4661
|
+
if (opts.recordingKind || opts.expectedResult) {
|
|
4662
|
+
log(c.yellow("note: --type and --expected are not applied to Clipy Local takes"));
|
|
4663
|
+
}
|
|
4664
|
+
const audioUncontrollable = warnAudioUncontrollable(info.protocolVersion, opts.audio, (m) => process.stderr.write(`${m}\n`));
|
|
4665
|
+
const windowWarned = warnWindowCaptureUnknown(info.protocolVersion, target, (m) => process.stderr.write(`${m}\n`));
|
|
4666
|
+
const startResult = await bridgeRequest(info, "start", {
|
|
4667
|
+
audio: { includeSystemAudio: opts.audio.includeSystemAudio, includeMic: opts.audio.includeMic },
|
|
4668
|
+
maxSec: Math.min(opts.forSec + 60, 1800),
|
|
4669
|
+
title: opts.name,
|
|
4670
|
+
description: opts.description,
|
|
4671
|
+
notes: resolveNarrationNotes(opts.notes, [0]).map((n) => ({ startMs: n.startMs, text: n.text })),
|
|
4672
|
+
...(target ? { source: target.source } : {}),
|
|
4673
|
+
}).catch((e) => die(e.message));
|
|
4674
|
+
const appliedAudio = reportAudio(opts.audio, echoedAudio(startResult), log, audioUncontrollable);
|
|
4675
|
+
const windowCapture = appliedWindowCapture(target, startResult, (m) => process.stderr.write(`${m}\n`), windowWarned);
|
|
4676
|
+
log(c.dim(`recording for ${opts.forSec}s (Ctrl-C stops early and keeps the take)…`));
|
|
4677
|
+
await waitOrStopSignal(opts.forSec);
|
|
4678
|
+
log(c.dim("stopping; Clipy Local is building the AREC on this computer…"));
|
|
4679
|
+
const result = await bridgeRequest(info, "stop").catch((e) => die(e.message));
|
|
4680
|
+
reportLocalBridgeResult(result, opts.json, {
|
|
4681
|
+
captureMode: "mac-screen",
|
|
4682
|
+
source: captureSourceResult(target?.resolved),
|
|
4683
|
+
audio: appliedAudio,
|
|
4684
|
+
...(windowCapture ? { windowCapture } : {}),
|
|
4685
|
+
});
|
|
4686
|
+
}
|
|
4687
|
+
/** `clipy session start --local --source mac-screen`: Clipy Local owns the take; stop returns its AREC. */
|
|
4688
|
+
async function cmdSessionStartMacLocal(opts) {
|
|
4689
|
+
const file = sessionFilePath(process.cwd());
|
|
4690
|
+
const existing = readSessionState(file);
|
|
4691
|
+
if (existing && sessionIsActive(existing)) {
|
|
4692
|
+
die("a recording session is already active here: finish it with `clipy session stop` or discard it with `clipy session abort`");
|
|
4693
|
+
}
|
|
4694
|
+
const info = readLocalBridgeOrDie();
|
|
4695
|
+
const maxSec = Math.min(Math.max(1, opts.maxSec), SESSION_HARD_CAP_SEC);
|
|
4696
|
+
const target = await resolveBridgeTarget(info, opts);
|
|
4697
|
+
if ((opts.recordingKind || opts.expectedResult) && !opts.json) {
|
|
4698
|
+
process.stderr.write(`${c.yellow("note: --type and --expected are not applied to Clipy Local takes")}\n`);
|
|
4699
|
+
}
|
|
4700
|
+
const audioUncontrollable = warnAudioUncontrollable(info.protocolVersion, opts.audio, (m) => process.stderr.write(`${m}\n`));
|
|
4701
|
+
const windowWarned = warnWindowCaptureUnknown(info.protocolVersion, target, (m) => process.stderr.write(`${m}\n`));
|
|
4702
|
+
const startResult = await bridgeRequest(info, "start", {
|
|
4703
|
+
audio: { includeSystemAudio: opts.audio.includeSystemAudio, includeMic: opts.audio.includeMic },
|
|
4704
|
+
maxSec,
|
|
4705
|
+
title: opts.name,
|
|
4706
|
+
description: opts.description,
|
|
4707
|
+
...(target ? { source: target.source } : {}),
|
|
4708
|
+
}).catch((e) => die(e.message));
|
|
4709
|
+
writeSessionState(file, macSessionState(info, maxSec));
|
|
4710
|
+
const appliedAudio = reportAudio(opts.audio, echoedAudio(startResult), (m) => process.stderr.write(`${m}\n`), audioUncontrollable);
|
|
4711
|
+
const windowCapture = appliedWindowCapture(target, startResult, (m) => process.stderr.write(`${m}\n`), windowWarned);
|
|
4712
|
+
if (opts.json) {
|
|
4713
|
+
printJson({
|
|
4714
|
+
state: "recording",
|
|
4715
|
+
local: true,
|
|
4716
|
+
app: "Clipy Local",
|
|
4717
|
+
captureMode: "mac-screen",
|
|
4718
|
+
maxSec,
|
|
4719
|
+
recordingId: typeof startResult.recordingId === "string" ? startResult.recordingId : null,
|
|
4720
|
+
arec: typeof startResult.arecPath === "string" ? startResult.arecPath : null,
|
|
4721
|
+
out: typeof startResult.directory === "string" ? startResult.directory : null,
|
|
4722
|
+
target: target?.label,
|
|
4723
|
+
source: captureSourceResult(target?.resolved),
|
|
4724
|
+
audio: appliedAudio,
|
|
4725
|
+
...(windowCapture ? { windowCapture } : {}),
|
|
4726
|
+
});
|
|
4727
|
+
return;
|
|
4728
|
+
}
|
|
4729
|
+
process.stdout.write(`${c.green("✓")} Clipy Local is recording ${target ? target.label : "your screen"} (max ${maxSec}s); nothing is uploaded\n`);
|
|
4730
|
+
if (target) {
|
|
4731
|
+
process.stdout.write(`${c.bold(`recording ${target.resolved.kind}:`)} "${target.resolved.title}" (id ${target.resolved.id})\n` +
|
|
4732
|
+
`${c.dim("confirm that is the surface you are driving; Clipy never brings it to the front for you.")}\n`);
|
|
4733
|
+
}
|
|
4734
|
+
process.stdout.write(`${c.dim("while it runs:")} clipy mark "what just happened"\n` +
|
|
4735
|
+
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
4736
|
+
}
|
|
3954
4737
|
function macSessionState(info, maxSec) {
|
|
3955
4738
|
const dir = sessionDir();
|
|
3956
4739
|
return {
|
|
3957
4740
|
version: 1,
|
|
3958
4741
|
kind: "mac",
|
|
3959
|
-
bridge: {
|
|
4742
|
+
bridge: {
|
|
4743
|
+
socketPath: info.socketPath,
|
|
4744
|
+
token: info.token,
|
|
4745
|
+
pid: info.pid,
|
|
4746
|
+
...(info.edition === "local" ? { edition: "local" } : {}),
|
|
4747
|
+
},
|
|
3960
4748
|
pid: info.pid,
|
|
3961
4749
|
cwd: process.cwd(),
|
|
3962
4750
|
url: "mac-screen",
|
|
@@ -3981,6 +4769,7 @@ function bridgeInfoFromSession(state) {
|
|
|
3981
4769
|
pid: state.bridge.pid,
|
|
3982
4770
|
appVersion: "",
|
|
3983
4771
|
protocolVersion: 1,
|
|
4772
|
+
edition: state.bridge.edition ?? "cloud",
|
|
3984
4773
|
};
|
|
3985
4774
|
}
|
|
3986
4775
|
/** The ready-to-run Playwright snippet printed after `session start --expose-cdp`.
|
|
@@ -4125,6 +4914,9 @@ async function cmdSessionStartExtension(opts) {
|
|
|
4125
4914
|
if (opts.recordingKind && !opts.json) {
|
|
4126
4915
|
process.stderr.write(`${c.yellow("note: --type is not applied to --source chrome-extension recordings yet")}\n`);
|
|
4127
4916
|
}
|
|
4917
|
+
if (opts.expectedResult && !opts.json) {
|
|
4918
|
+
process.stderr.write(`${c.yellow("note: --expected is not applied to --source chrome-extension recordings yet; after stop, run clipy update <id> --expected \"<text>\"")}\n`);
|
|
4919
|
+
}
|
|
4128
4920
|
const file = sessionFilePath(process.cwd());
|
|
4129
4921
|
const existing = readSessionState(file);
|
|
4130
4922
|
if (existing && sessionIsActive(existing)) {
|
|
@@ -4221,6 +5013,12 @@ async function cmdSessionStartExtension(opts) {
|
|
|
4221
5013
|
`${c.dim("when finished:")} clipy session stop ${c.dim("· discard:")} clipy session abort\n`);
|
|
4222
5014
|
}
|
|
4223
5015
|
async function cmdSessionStart(ctx, opts) {
|
|
5016
|
+
if (opts.local && opts.source === "chrome-extension")
|
|
5017
|
+
die(LOCAL_EXTENSION_REFUSAL, 2);
|
|
5018
|
+
if (opts.local && opts.source === "mac-screen") {
|
|
5019
|
+
await cmdSessionStartMacLocal(opts);
|
|
5020
|
+
return;
|
|
5021
|
+
}
|
|
4224
5022
|
if (opts.source === "chrome-extension") {
|
|
4225
5023
|
await cmdSessionStartExtension(opts);
|
|
4226
5024
|
return;
|
|
@@ -4243,6 +5041,9 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4243
5041
|
if (opts.recordingKind && !opts.json) {
|
|
4244
5042
|
process.stderr.write(`${c.yellow("note: --type is not applied to --source mac-screen recordings yet (needs a Clipy app update)")}\n`);
|
|
4245
5043
|
}
|
|
5044
|
+
if (opts.expectedResult && !opts.json) {
|
|
5045
|
+
process.stderr.write(`${c.yellow("note: --expected is not applied to --source mac-screen recordings yet; after stop, run clipy update <id> --expected \"<text>\"")}\n`);
|
|
5046
|
+
}
|
|
4246
5047
|
// Before the camera turns on, not after — see warnAudioUncontrollable().
|
|
4247
5048
|
const audioUncontrollable = warnAudioUncontrollable(info.protocolVersion, opts.audio, (m) => process.stderr.write(`${m}\n`));
|
|
4248
5049
|
const windowWarned = warnWindowCaptureUnknown(info.protocolVersion, target, (m) => process.stderr.write(`${m}\n`));
|
|
@@ -4304,7 +5105,9 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4304
5105
|
validateAuthCapture(opts.auth, target.href); // usage errors (exit 2) before auth/daemonizing
|
|
4305
5106
|
if (opts.userDataDir)
|
|
4306
5107
|
validateUserDataDir(opts.userDataDir, opts.profileDirectory);
|
|
4307
|
-
const key = requireKey(ctx);
|
|
5108
|
+
const key = opts.local ? null : requireKey(ctx);
|
|
5109
|
+
// Chrome for Clipy records the tab's audio; headless captures are silent.
|
|
5110
|
+
const localOut = opts.local ? await localSessionOut(opts.local.out, opts.local.force, opts.json, isChromeForClipy) : undefined;
|
|
4308
5111
|
await loadChromium(); // fail fast with install instructions before daemonizing
|
|
4309
5112
|
// Chrome for Clipy is started HERE, in the parent, so a missing Chrome or a
|
|
4310
5113
|
// dead CDP port is a loud immediate error rather than a daemon-log mystery.
|
|
@@ -4344,6 +5147,7 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4344
5147
|
name: opts.name,
|
|
4345
5148
|
description: opts.description,
|
|
4346
5149
|
recordingKind: opts.recordingKind,
|
|
5150
|
+
expectedResult: opts.expectedResult,
|
|
4347
5151
|
maxSec,
|
|
4348
5152
|
width: opts.width,
|
|
4349
5153
|
height: opts.height,
|
|
@@ -4356,6 +5160,7 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4356
5160
|
localStorageSpecs: opts.auth.localStorageSpecs.length ? opts.auth.localStorageSpecs : undefined,
|
|
4357
5161
|
userDataDir: launchUserDataDir,
|
|
4358
5162
|
profileScratchRoot,
|
|
5163
|
+
...(localOut ? { local: { out: localOut } } : {}),
|
|
4359
5164
|
state: "starting",
|
|
4360
5165
|
marksPath: join(dir, `marks-${id}.jsonl`),
|
|
4361
5166
|
controlPath: join(dir, `control-${id}.json`),
|
|
@@ -4368,7 +5173,7 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4368
5173
|
stdio: ["ignore", logFd, logFd],
|
|
4369
5174
|
env: {
|
|
4370
5175
|
...process.env,
|
|
4371
|
-
CLIPY_API_KEY: key,
|
|
5176
|
+
...(key ? { CLIPY_API_KEY: key } : {}),
|
|
4372
5177
|
CLIPY_API_URL: ctx.apiUrl,
|
|
4373
5178
|
},
|
|
4374
5179
|
});
|
|
@@ -4405,10 +5210,13 @@ async function cmdSessionStart(ctx, opts) {
|
|
|
4405
5210
|
sessionFile: file,
|
|
4406
5211
|
cdpUrl: started?.cdpUrl ?? null,
|
|
4407
5212
|
cdpHttpUrl: started?.cdpHttpUrl ?? null,
|
|
5213
|
+
...(localOut ? { local: true, out: localOut } : {}),
|
|
4408
5214
|
});
|
|
4409
5215
|
return;
|
|
4410
5216
|
}
|
|
4411
5217
|
process.stdout.write(`${c.green("✓")} recording ${c.bold(target.href)} (max ${maxSec}s)\n`);
|
|
5218
|
+
if (localOut)
|
|
5219
|
+
process.stdout.write(`${c.dim("local mode:")} nothing is uploaded; the AREC is written to ${localOut} at stop\n`);
|
|
4412
5220
|
if (started?.cdpHttpUrl) {
|
|
4413
5221
|
process.stdout.write(`${c.yellow("⚠ CDP exposed:")} any local process can attach to and control this browser while the session runs.\n`);
|
|
4414
5222
|
process.stdout.write(`${cdpDriverSnippet(started.cdpHttpUrl)}\n`);
|
|
@@ -4516,7 +5324,7 @@ async function cmdMark(text, json, opts) {
|
|
|
4516
5324
|
const result = await bridgeRequest(bridgeInfoFromSession(state), "mark", { text: macText }).catch((e) => {
|
|
4517
5325
|
if (e instanceof BridgeUnavailableError) {
|
|
4518
5326
|
cleanupSessionFiles(state, file);
|
|
4519
|
-
die(
|
|
5327
|
+
die(appGoneMessage(state));
|
|
4520
5328
|
}
|
|
4521
5329
|
die(e.message);
|
|
4522
5330
|
});
|
|
@@ -4641,7 +5449,7 @@ async function cmdChapter(label, json) {
|
|
|
4641
5449
|
const result = await bridgeRequest(bridgeInfoFromSession(state), "mark", { text: chapterText }).catch((e) => {
|
|
4642
5450
|
if (e instanceof BridgeUnavailableError) {
|
|
4643
5451
|
cleanupSessionFiles(state, file);
|
|
4644
|
-
die(
|
|
5452
|
+
die(appGoneMessage(state));
|
|
4645
5453
|
}
|
|
4646
5454
|
die(e.message);
|
|
4647
5455
|
});
|
|
@@ -4684,8 +5492,10 @@ async function cmdChapter(label, json) {
|
|
|
4684
5492
|
process.stdout.write(`${c.green("✓")} chapter @ ${(tMs / 1000).toFixed(1)}s — ${label}\n`);
|
|
4685
5493
|
}
|
|
4686
5494
|
}
|
|
4687
|
-
async function cmdSessionStop(json) {
|
|
5495
|
+
async function cmdSessionStop(json, local = false) {
|
|
4688
5496
|
const { file, state } = requireSession();
|
|
5497
|
+
if (local)
|
|
5498
|
+
refuseLocalFlagOnUploadSession(state);
|
|
4689
5499
|
if (state.kind === "chrome-extension") {
|
|
4690
5500
|
if (!json)
|
|
4691
5501
|
process.stderr.write(`${c.dim("stopping; the extension is uploading…")}\n`);
|
|
@@ -4723,8 +5533,10 @@ async function cmdSessionStop(json) {
|
|
|
4723
5533
|
return;
|
|
4724
5534
|
}
|
|
4725
5535
|
if (state.kind === "mac") {
|
|
4726
|
-
|
|
4727
|
-
|
|
5536
|
+
const localApp = state.bridge?.edition === "local";
|
|
5537
|
+
if (!json) {
|
|
5538
|
+
process.stderr.write(`${c.dim(localApp ? "stopping; Clipy Local is building the AREC on this computer…" : "stopping + uploading…")}\n`);
|
|
5539
|
+
}
|
|
4728
5540
|
// No daemon on the mac path to merge a tally, so emit the [verification]
|
|
4729
5541
|
// summary ourselves as a final bridge mark (stamped at stop) BEFORE stopping.
|
|
4730
5542
|
const macTally = verificationNote({
|
|
@@ -4744,6 +5556,10 @@ async function cmdSessionStop(json) {
|
|
|
4744
5556
|
die(e.message);
|
|
4745
5557
|
});
|
|
4746
5558
|
cleanupSessionFiles(state, file);
|
|
5559
|
+
if (localApp) {
|
|
5560
|
+
reportLocalBridgeResult(result, json);
|
|
5561
|
+
return;
|
|
5562
|
+
}
|
|
4747
5563
|
const publicId = String(result.publicId ?? "");
|
|
4748
5564
|
reportSessionResult({
|
|
4749
5565
|
publicId,
|
|
@@ -4756,8 +5572,8 @@ async function cmdSessionStop(json) {
|
|
|
4756
5572
|
if (!pidAlive(state.pid)) {
|
|
4757
5573
|
// Daemon already gone: it may have finished (auto-stop at max duration)
|
|
4758
5574
|
// or crashed. Report whatever terminal state it left behind.
|
|
4759
|
-
if (state.state === "done" && state.result) {
|
|
4760
|
-
|
|
5575
|
+
if (state.state === "done" && (state.result || state.localResult)) {
|
|
5576
|
+
reportSessionOutcome(state, json);
|
|
4761
5577
|
cleanupSessionFiles(state, file);
|
|
4762
5578
|
return;
|
|
4763
5579
|
}
|
|
@@ -4769,20 +5585,20 @@ async function cmdSessionStop(json) {
|
|
|
4769
5585
|
}
|
|
4770
5586
|
writeFileSync(state.controlPath, JSON.stringify({ action: "stop" }));
|
|
4771
5587
|
if (!json)
|
|
4772
|
-
process.stderr.write(`${c.dim("stopping + uploading…")}\n`);
|
|
5588
|
+
process.stderr.write(`${c.dim(state.local ? "stopping; building the AREC on this machine…" : "stopping + uploading…")}\n`);
|
|
4773
5589
|
// Stop = close browser + upload; give long recordings room to finish.
|
|
4774
5590
|
const deadline = Date.now() + 600_000;
|
|
4775
5591
|
for (;;) {
|
|
4776
5592
|
const s = readSessionState(file);
|
|
4777
|
-
if (s?.state === "done" && s.result) {
|
|
4778
|
-
|
|
5593
|
+
if (s?.state === "done" && (s.result || s.localResult)) {
|
|
5594
|
+
reportSessionOutcome(s, json);
|
|
4779
5595
|
cleanupSessionFiles(s, file);
|
|
4780
5596
|
return;
|
|
4781
5597
|
}
|
|
4782
5598
|
if (s?.state === "failed") {
|
|
4783
5599
|
const keptPath = cleanupSessionFiles(s, file);
|
|
4784
5600
|
const kept = keptPath ? `\nThe capture was kept at: ${keptPath}` : "";
|
|
4785
|
-
die(
|
|
5601
|
+
die(`${s.local ? "session failed" : "session upload failed"}: ${s.error ?? "unknown"}${kept}`);
|
|
4786
5602
|
}
|
|
4787
5603
|
if (s?.state === "aborted") {
|
|
4788
5604
|
cleanupSessionFiles(s, file);
|
|
@@ -4799,6 +5615,45 @@ async function cmdSessionStop(json) {
|
|
|
4799
5615
|
await new Promise((r) => setTimeout(r, 500));
|
|
4800
5616
|
}
|
|
4801
5617
|
}
|
|
5618
|
+
/**
|
|
5619
|
+
* `session stop|status --local` on a session that was started without
|
|
5620
|
+
* --local: stopping it would upload, which --local promises never happens,
|
|
5621
|
+
* so refuse instead of quietly uploading.
|
|
5622
|
+
*/
|
|
5623
|
+
function refuseLocalFlagOnUploadSession(state) {
|
|
5624
|
+
if (state.local || state.bridge?.edition === "local")
|
|
5625
|
+
return;
|
|
5626
|
+
die("this session was started without --local and uploads on stop; use clipy session abort to discard it", 2);
|
|
5627
|
+
}
|
|
5628
|
+
/** A finished daemon session: the share link, or with --local the AREC path. */
|
|
5629
|
+
function reportSessionOutcome(state, json) {
|
|
5630
|
+
if (state.localResult) {
|
|
5631
|
+
reportLocalSessionResult(state.localResult, json);
|
|
5632
|
+
return;
|
|
5633
|
+
}
|
|
5634
|
+
if (state.result)
|
|
5635
|
+
reportSessionResult(state.result, json);
|
|
5636
|
+
}
|
|
5637
|
+
function reportLocalSessionResult(result, json) {
|
|
5638
|
+
for (const warning of result.warnings)
|
|
5639
|
+
process.stderr.write(`Warning: ${warning}\n`);
|
|
5640
|
+
if (json) {
|
|
5641
|
+
printJson(result);
|
|
5642
|
+
return;
|
|
5643
|
+
}
|
|
5644
|
+
process.stderr.write(`Done: ${result.frames} screenshot${result.frames === 1 ? "" : "s"}, ${result.transcript.segments} transcript segment${result.transcript.segments === 1 ? "" : "s"}. Nothing was uploaded. Give your AI agent the path below.\n` +
|
|
5645
|
+
`Want a share link anyone can watch, with no signup to watch? Run: clipy upload ${JSON.stringify(result.video)}\n`);
|
|
5646
|
+
process.stdout.write(`${result.arec}\n`);
|
|
5647
|
+
}
|
|
5648
|
+
/**
|
|
5649
|
+
* The folder a --local session writes to, claimed when it starts (so two
|
|
5650
|
+
* sessions started in the same second never share one). The config file,
|
|
5651
|
+
* model provider and ffmpeg are checked here too, so a mistake in them is
|
|
5652
|
+
* reported now, not after the take at `session stop`.
|
|
5653
|
+
*/
|
|
5654
|
+
async function localSessionOut(out, force, json, speech = false) {
|
|
5655
|
+
return (await prepareLocalOrExit({ out, force, json, speech })).dir;
|
|
5656
|
+
}
|
|
4802
5657
|
function reportSessionResult(result, json) {
|
|
4803
5658
|
if (json) {
|
|
4804
5659
|
printJson({
|
|
@@ -4956,7 +5811,7 @@ async function cmdSessionAbort(json) {
|
|
|
4956
5811
|
else
|
|
4957
5812
|
process.stdout.write(`${c.green("✓")} session aborted — nothing was uploaded\n`);
|
|
4958
5813
|
}
|
|
4959
|
-
async function cmdSessionStatus(json) {
|
|
5814
|
+
async function cmdSessionStatus(json, local = false) {
|
|
4960
5815
|
const file = sessionFileToUse();
|
|
4961
5816
|
const state = readSessionState(file);
|
|
4962
5817
|
if (!state) {
|
|
@@ -4966,6 +5821,8 @@ async function cmdSessionStatus(json) {
|
|
|
4966
5821
|
process.stdout.write(`${c.dim("no session in this workspace")}\n`);
|
|
4967
5822
|
return;
|
|
4968
5823
|
}
|
|
5824
|
+
if (local)
|
|
5825
|
+
refuseLocalFlagOnUploadSession(state);
|
|
4969
5826
|
if (state.kind === "chrome-extension") {
|
|
4970
5827
|
const elapsedSec = state.recordStartEpochMs ? Math.round((Date.now() - state.recordStartEpochMs) / 1000) : null;
|
|
4971
5828
|
let live;
|
|
@@ -5880,12 +6737,66 @@ async function runSessionDaemon(file) {
|
|
|
5880
6737
|
log(`mark limit: merged ${notes.length} marks — keeping the first 200 (dropped ${notes.length - 200})`);
|
|
5881
6738
|
notes = notes.slice(0, 200);
|
|
5882
6739
|
}
|
|
6740
|
+
if (state.local) {
|
|
6741
|
+
// --local: the pipeline moves the capture into the output folder first,
|
|
6742
|
+
// so a failure after that still leaves the video there.
|
|
6743
|
+
save({ state: "uploading", videoPath });
|
|
6744
|
+
const { mod, env } = await localMode();
|
|
6745
|
+
const result = await mod
|
|
6746
|
+
.runLocalTake({
|
|
6747
|
+
videoPath,
|
|
6748
|
+
moveVideo: true,
|
|
6749
|
+
out: state.local.out,
|
|
6750
|
+
// Claimed (and checked) by `session start`.
|
|
6751
|
+
outClaimed: true,
|
|
6752
|
+
title: state.name ?? (state.kind === "linux-screen" ? `Screen recording (${state.url})` : `Recording of ${state.url}`),
|
|
6753
|
+
description: state.description,
|
|
6754
|
+
expectedResult: state.expectedResult,
|
|
6755
|
+
recordingKind: state.recordingKind,
|
|
6756
|
+
narration: localNarration(notes),
|
|
6757
|
+
origin: { kind: "capture", sourceName: state.url },
|
|
6758
|
+
json: true,
|
|
6759
|
+
}, { ...env, io: { ...env.io, stderr: (m) => log(m.trim()), onInterrupt: () => () => { } } })
|
|
6760
|
+
.catch((e) => {
|
|
6761
|
+
// runLocalTake keeps the capture in the take folder and says where;
|
|
6762
|
+
// `session stop` reports that path, so the error carries only the reason.
|
|
6763
|
+
if (e instanceof mod.LocalTakeError && e.keptPath && existsSync(e.keptPath)) {
|
|
6764
|
+
save({ keptVideoPath: e.keptPath });
|
|
6765
|
+
throw new Error(e.reason);
|
|
6766
|
+
}
|
|
6767
|
+
if (existsSync(videoPath)) {
|
|
6768
|
+
const kept = join(sessionDir(), `kept-${randomUUID()}${extname(videoPath) || ".webm"}`);
|
|
6769
|
+
try {
|
|
6770
|
+
moveFile(videoPath, kept);
|
|
6771
|
+
save({ keptVideoPath: kept });
|
|
6772
|
+
}
|
|
6773
|
+
catch {
|
|
6774
|
+
save({ keptVideoPath: videoPath });
|
|
6775
|
+
}
|
|
6776
|
+
}
|
|
6777
|
+
else if (existsSync(join(state.local.out, "recording.mp4"))) {
|
|
6778
|
+
save({ keptVideoPath: join(state.local.out, "recording.mp4") });
|
|
6779
|
+
}
|
|
6780
|
+
throw e;
|
|
6781
|
+
});
|
|
6782
|
+
const localJson = mod.resultJson(result, state.kind === "linux-screen" && state.screenSource ? { source: captureSourceResult(state.screenSource) } : {});
|
|
6783
|
+
save({ state: "done", localResult: localJson });
|
|
6784
|
+
log(`done (local): ${localJson.arec}`);
|
|
6785
|
+
try {
|
|
6786
|
+
rmSync(state.tmpDir, { recursive: true, force: true });
|
|
6787
|
+
}
|
|
6788
|
+
catch {
|
|
6789
|
+
// best-effort
|
|
6790
|
+
}
|
|
6791
|
+
return;
|
|
6792
|
+
}
|
|
5883
6793
|
save({ state: "uploading", videoPath });
|
|
5884
6794
|
const uploaded = await uploadVideoToClipy(ctx, {
|
|
5885
6795
|
videoPath,
|
|
5886
6796
|
name: state.name,
|
|
5887
6797
|
description: state.description,
|
|
5888
6798
|
recordingKind: state.recordingKind,
|
|
6799
|
+
expectedResult: state.expectedResult,
|
|
5889
6800
|
narration: notes.length ? { notes } : undefined,
|
|
5890
6801
|
browserDiagnostics: diagnosticsSidecar,
|
|
5891
6802
|
log: (m) => log(m.replace(/\x1b\[[0-9;]*m/g, "")),
|
|
@@ -6332,7 +7243,7 @@ async function cmdAgents(ctx, sub, targetRaw, json) {
|
|
|
6332
7243
|
// command's shape without trial-and-error. Bump GUIDE_SCHEMA_VERSION when the
|
|
6333
7244
|
// contract changes.
|
|
6334
7245
|
// ---------------------------------------------------------------------------
|
|
6335
|
-
const GUIDE_SCHEMA_VERSION =
|
|
7246
|
+
const GUIDE_SCHEMA_VERSION = 22;
|
|
6336
7247
|
/** The stable machine-readable failure taxonomy carried in `--json` error
|
|
6337
7248
|
* envelopes. Codes are the contract; messages are not. Published through the
|
|
6338
7249
|
* guide so an agent discovers the full recovery table without the skill. */
|
|
@@ -6359,6 +7270,12 @@ const GUIDE_ERROR_CODES = [
|
|
|
6359
7270
|
{ code: "confirmation_required", meaning: "a permanent action (clipy delete) was run without --yes (exit 2)", retryable: false, remediation: "only if the user asked for that exact recording to be deleted, re-run with --yes" },
|
|
6360
7271
|
{ code: "upload_unconfirmed", meaning: "the upload became a recording, but the server never confirmed its completion (still being committed or queued)", retryable: false, remediation: "do NOT upload again (that creates a duplicate); check the recording in partial.id with `clipy show <id>`" },
|
|
6361
7272
|
{ code: "sharing_not_applied", meaning: "the upload became a recording, but the requested public/restricted/private sharing could not be applied", retryable: false, remediation: "do NOT upload again (that creates a duplicate); run the `clipy share <id> <mode>` in the remediation, using partial.id" },
|
|
7273
|
+
{ code: "timeline_not_ready", meaning: "clipy recheck: the recording's interaction timeline is still being prepared", retryable: true, remediation: "wait a minute and re-run the same command" },
|
|
7274
|
+
{ code: "no_interactions", meaning: "clipy recheck: the recording has no clicks or page navigations to replay (for example a plain web-recorder take)", retryable: false, remediation: "only Chrome extension, Chrome for Clipy, Mac and Windows app takes can be re-checked; re-running cannot help" },
|
|
7275
|
+
{ code: "chrome_unavailable", meaning: "clipy recheck: Chrome for Clipy could not be started or driven", retryable: true, remediation: "run `clipy chrome status --json` and `clipy chrome start`, then re-run once" },
|
|
7276
|
+
{ code: "start_url_unreachable", meaning: "clipy recheck: the --url page could not be opened (connection refused, unknown host)", retryable: false, remediation: "check that --url loads (is the server running, is it the right host?), then re-run" },
|
|
7277
|
+
{ code: "recheck_upload_failed", meaning: "clipy recheck finished, but its step frames were not uploaded (a warning on an ok:true report, not a failure)", retryable: false, remediation: "the report and frames are saved locally (files.json); do not re-run the whole re-check just for the upload" },
|
|
7278
|
+
{ code: "speech_engine_required", meaning: "a --local take needs on-device transcription and the speech engine is not installed, and there was no terminal to ask in (or the user said no). Nothing was recorded", retryable: false, remediation: "with the user's consent run `clipy speech install` (downloads sherpa-onnx-node from npm, about 35 MB) or re-run with --yes; or choose another transcription option with `clipy local setup --transcribe`" },
|
|
6362
7279
|
{ code: "unknown", meaning: "an unclassified failure", retryable: true, remediation: "re-run once; if it repeats, hand the user the whole envelope as a bug report rather than improvising a workaround" },
|
|
6363
7280
|
];
|
|
6364
7281
|
function cmdGuide(json) {
|
|
@@ -6391,6 +7308,7 @@ function cmdGuide(json) {
|
|
|
6391
7308
|
{ name: "CLIPY_API_URL", description: "API base URL override (default https://clipy.online)" },
|
|
6392
7309
|
{ name: "CLIPY_DISABLE_CDP", description: "set to 1 to force session --expose-cdp off (a hard kill switch that wins over the flag)" },
|
|
6393
7310
|
{ name: "CLIPY_SESSION_FILE", description: "path to a session state file that mark/chapter/session stop|abort|status resolve FIRST (before the cwd hash). `session run` exports it to the child so a driver can mark from any cwd." },
|
|
7311
|
+
{ name: "CLIPY_LOCAL_BRIDGE_FILE", description: "path to Clipy Local's agent-bridge.json (default ~/Library/Application Support/Clipy Local/agent-bridge.json). Only --local commands read it; they never read the official app's file." },
|
|
6394
7312
|
{ name: "NO_COLOR", description: "disable ANSI color" },
|
|
6395
7313
|
],
|
|
6396
7314
|
exitCodes: [
|
|
@@ -6398,6 +7316,7 @@ function cmdGuide(json) {
|
|
|
6398
7316
|
{ code: 1, meaning: "error" },
|
|
6399
7317
|
{ code: 2, meaning: "usage error" },
|
|
6400
7318
|
{ code: 3, meaning: "artifact not ready yet (transcript/summary/wait)" },
|
|
7319
|
+
{ code: 4, meaning: "clipy recheck --fail-on-divergence: the re-check finished but its verdict is not matches" },
|
|
6401
7320
|
],
|
|
6402
7321
|
errorCodes: GUIDE_ERROR_CODES,
|
|
6403
7322
|
partialSuccess: {
|
|
@@ -6419,9 +7338,9 @@ function cmdGuide(json) {
|
|
|
6419
7338
|
cmdDoc("moments", "clipy moments <id> [--json]", "Key moments: timestamps, captions, click coords"),
|
|
6420
7339
|
cmdDoc("context", "clipy context <id>", "Full agent-context bundle as markdown"),
|
|
6421
7340
|
cmdDoc("context import", "clipy context import <youtube-url|loom-url|local-file> [--transcript <f>] [--output <dir>] [--language <code>] [--title <t>] [--tag <t>]… [--folder <name>] [--sync] [--json]", "Compile ANY video into a local Clipy context bundle — a directory holding recording.arec (the canonical agent-facing Markdown document), a byte-identical recording.md compatibility copy, manifest.json (provenance, versions, sufficiency report) and transcript.json. YouTube URLs resolve on YOUR machine via a Clipy-managed yt-dlp (auto-installed into ~/.clipy/bin on first use, with a disclosure); creator captions are preferred over auto-captions and NO media is downloaded. Loom share links (loom.com/share/<32-hex-id>) use Loom's own published transcript over plain HTTPS — no yt-dlp is needed and none is installed, so `clipy doctor`'s yt-dlp check does not gate a Loom import; roughly one Loom in six has no transcript recorded and fails with `no_captions` rather than emitting an empty bundle, and Loom's transcript is machine-generated so it is recorded as auto_captions. Local files need --transcript <.vtt|.srt|Clipy transcript JSON> and are probed with ffprobe. A deterministic classifier scores how well the transcript stands alone and lists the timestamps where it is blind — v1 emits the transcript profile only, so those gaps are the honest statement of what the bundle cannot show. Reruns over the same source are idempotent. --sync additionally uploads the DERIVED bundle (never source media) to your private library.", ["--transcript", "--output", "--language", "--title", "--tag", "--folder", "--sync", "--no-frames", "--json"]),
|
|
6422
|
-
cmdDoc("context read", "clipy context read <bundle-path>", "Print a local bundle's recording.arec to stdout
|
|
6423
|
-
cmdDoc("upload", "clipy upload <file> [--title t] [--description d] [--type kind] [--access public|restricted|private] [--note '12: text']… [--wait] [--json]", "Upload an existing WebM/MP4/MOV file to the library through the same pipeline as recordings (needs 'ingest'; counts toward the recording allowance). JSON: {ok:true, id, shareUrl, contextUrl, sizeBytes, container, warnings}. With --wait, a failed wait is a `wait_incomplete` warning on a successful result: the recording exists, so never upload again", ["--title", "--description", "--type", "--access", "--note", "--wait", "--json"]),
|
|
6424
|
-
cmdDoc("update", "clipy update <id> [--title t] [--description d | --clear-description] [--json]", "Rename a recording
|
|
7341
|
+
cmdDoc("context read", "clipy context read <bundle-path>", "Print a local bundle's recording.arec to stdout: plain, unpaged, uncoloured, for an agent to read directly. It opens with a self-describing header (source, duration, classification, sufficiency) before the [MM:SS] transcript sections, so the first screen tells you what the document is and where it is blind. For a SYNCED document read it over MCP instead: get_context_document for metadata+classification without the transcript, then read_context_document with startMs/endMs for just the span you need."),
|
|
7342
|
+
cmdDoc("upload", "clipy upload <file> [--title t] [--description d] [--type kind] [--expected text] [--access public|restricted|private] [--note '12: text']… [--wait] [--json]", "Upload an existing WebM/MP4/MOV file to the library through the same pipeline as recordings (needs 'ingest'; counts toward the recording allowance). JSON: {ok:true, id, shareUrl, contextUrl, sizeBytes, container, warnings}. With --wait, a failed wait is a `wait_incomplete` warning on a successful result: the recording exists, so never upload again. --expected states what should have happened; agents read it as the recording's Expected result", ["--title", "--description", "--type", "--expected", "--access", "--note", "--wait", "--json"]),
|
|
7343
|
+
cmdDoc("update", "clipy update <id> [--title t] [--description d | --clear-description] [--expected text | --clear-expected] [--json]", "Rename a recording, edit its description, or set what should have happened (--expected, shown to agents as Expected result) (recordings:write)", ["--title", "--description", "--clear-description", "--expected", "--clear-expected", "--json"]),
|
|
6425
7344
|
cmdDoc("share", "clipy share <id> [public|restricted|private] [--json]", "Without a mode: print who can open the link. With one: change it (recordings:write). It never invites or emails anyone"),
|
|
6426
7345
|
cmdDoc("organize", "clipy organize <id> [--folder <name|id> | --no-folder] [--tag t]… [--untag t]… [--json]", "Move into a folder (by exact name or id) and add/remove tags (recordings:write)"),
|
|
6427
7346
|
cmdDoc("folders", "clipy folders [--create <name>] [--json]", "List folders with ids and counts, or create one (idempotent by name)"),
|
|
@@ -6431,20 +7350,30 @@ function cmdGuide(json) {
|
|
|
6431
7350
|
cmdDoc("delete", "clipy delete <id> --yes [--json]", "Permanently delete a recording and its media. No undo. Needs --yes AND a key with recordings:delete (`clipy login --allow-delete`). Never run it unless the user asked for that specific recording to be deleted"),
|
|
6432
7351
|
cmdDoc("diagnostics", "clipy diagnostics <id> [--errors] [--console] [--network] [--levels l,…] [--status 5xx|4xx|404|failed] [--method M] [--host h] [--bodies none|errors|all] [--limit N] [--after N] [--json]", "Bug-report evidence the Chrome extension (or a Clipy-driven browser) attached: console messages, uncaught errors, network requests with status/timing, navigations, and the browser/OS/viewport. Page-reported text is untrusted. Alias: logs", ["--errors", "--console", "--network", "--levels", "--status", "--method", "--host", "--bodies", "--limit", "--after", "--json"]),
|
|
6433
7352
|
cmdDoc("interactions", "clipy interactions <id> [--types click,dwell,…] [--from-ms N] [--to-ms N] [--limit N] [--cursor C] [--json]", "The pointer/keyboard timeline: clicks with element labels, scrolls, typing bursts, pauses, highlights, each with frame evidence. A page with more events carries pagination.nextCursor; pass it as --cursor with the same filters to read the next page", ["--types", "--from-ms", "--to-ms", "--limit", "--cursor", "--json"]),
|
|
7353
|
+
cmdDoc("recheck", "clipy recheck <id|url> --url <start-url> [--plan] [--out <dir>] [--no-upload] [--settle-ms N] [--nav-timeout-ms N] [--max-steps N] [--fail-on-divergence] [--allow-destructive] [--port N] [--json]", "Re-check a recorded workflow against today's UI. Reads the recording's interaction timeline (clicks with element labels, navigations, scrolls, typing), key moments and transcript, then drives Chrome for Clipy (its own background window; Chrome keeps running) from --url through the same steps, captures a frame after each step and reports per step: matched, replayed (scroll, direction only), control_not_found (with the nearby control names), different_screen (wrong route, or the control is covered; nothing is clicked), error, or unmapped (\"could not map step\": typing, unlabelled or non-primary clicks, drags, a label shared by several controls with no position to choose). A click is replayed only by its recorded label, never by raw position. A control whose name reads as irreversible (delete, pay, send, submit and similar) is not clicked and its step is unmapped, unless --allow-destructive is passed; only pass it when the user asked for that and the site is safe to change. A recorded page is opened directly only on the recording's own host (moved onto --url's host), never on another host the timeline names. Recorded on one host and re-checked on another (e.g. staging), recorded routes are moved onto the --url host and must match there; a page that lands on any other host (a redirect to production) is different_screen and is never clicked. A disabled control is different_screen, never matched. --plan prints the steps without opening Chrome. By default the frames are uploaded like clipy proof --frame (ingest scope, ffmpeg) and the report carries the new recording's shareUrl and contextUrl; --no-upload keeps everything local. report.json and report.md are written to --out (default a private temp dir). Ctrl-C closes the re-check's window and exits 130. An unreachable --url fails with start_url_unreachable. An upload whose completion was not confirmed carries the recording plus an upload_unconfirmed warning: do not upload again. --json prints {ok:true, type:'clipy.recheck_report', original:{…, expectedResult}, summary:{verdict: matches|diverged|incomplete, firstDivergence, counts}, steps:[{status, reason, expected, observed}], recording, limitations, warnings, files}. original.expectedResult carries the recording's \"what should have happened\" when it has one; compare it with the last frame yourself. --fail-on-divergence exits 4 unless the verdict is matches. Needs Playwright (as session --source chrome-for-clipy does) and a Chrome for Clipy that is signed in where the workflow needs it.", ["--url <start-url>", "--plan", "--out <dir>", "--no-upload", "--settle-ms", "--nav-timeout-ms", "--max-steps", "--fail-on-divergence", "--allow-destructive", "--port", "--json"]),
|
|
6434
7354
|
cmdDoc("download", "clipy download <id> [-o path]", "Download the MP4"),
|
|
6435
7355
|
cmdDoc("open", "clipy open <id>", "Open the share page in a browser"),
|
|
6436
7356
|
cmdDoc("wait", "clipy wait <id> [--for transcript|summary|both] [--timeout sec]", "Block until artifacts are ready"),
|
|
6437
|
-
cmdDoc("proof", "clipy proof (--frame <png|jpg|webp>… | --video <webm|mp4>) [--for <recording>] [--caption <text>…] [--hold sec] [--title t] [--type kind] [--note '3: text']… [--wait] [--json]", "Tool-neutral proof upload. --frame may be repeated to turn screenshots produced by any browser, computer-use, simulator, or test tool into one high-quality silent MP4; --caption must be omitted or repeated exactly once per frame and becomes timestamped agent narration. --hold controls each frame's duration (default 3s, 0.25–30; total cap 300s); --width/--height must be even integers from 320–3840 and default to 1280x720. Frame inputs are bounded to 50 MiB each and 250 MiB total. Screenshot stitching needs ffmpeg but does not need Playwright or a browser integration. --video uploads an already-recorded WebM or MP4 without re-encoding and needs no recording dependency. Exactly one source mode is required. --for <recording id|url> links the uploaded proof back to the recording it verifies (validated before upload; the link appears in the owner-only receipt on that recording's watch page and needs a key with both ingest and recordings:read). --json prints {id, shareUrl, contextUrl, sizeBytes, source, verifies?}; proof-video source reports only the detected container and never discloses the local path. Captions and notes are driver-attested narration, not Clipy-verified assertions.", ["--frame", "--caption", "--video", "--for", "--hold", "--width", "--height", "--title", "--description", "--type", "--note", "--wait", "--json"]),
|
|
6438
|
-
cmdDoc("record", "clipy record --url <url> [--for sec] [--viewports list] [--title t] [--type kind] [--note '12: text']… [--storage-state f] [--cookie 'n=v']… [--local-storage 'k=v']… [--init-script f] [--wait] [--json]", "Headless one-shot capture of a web app; notes become the transcript. Notes are absolute ('12: text') or pass-scoped ('pass2: text' / 'pass2@5: text', anchored to a --viewports pass's real start; a malformed pass note is rejected). --type declares the recording kind (bug_report|feature_request|product_demo|walkthrough_tutorial|feedback_review|discussion_talk|other, plus aliases bug/feature/demo/walkthrough/feedback/discussion) so the AI summary reads it correctly. Auth (web capture only, applied before the first navigation so a logged-in SPA's route guard sees it): --storage-state <playwright storageState JSON path>, --cookie 'name=value[; Domain=d; Path=p; Secure; HttpOnly; SameSite=Lax]' (repeatable), --local-storage 'key=value' (repeatable, target origin only), --init-script <js file run before every page load>, --user-data-dir <dir> (launch from a persistent Chromium user-data ROOT with its whole logged-in identity; web only, mutually exclusive with --storage-state; refused if <dir> is a profile subdir — pass the root — or, in direct mode, a live-locked root via SingletonLock/Socket), --profile-directory <name> (with --user-data-dir: pick a NAMED profile like 'Profile 12' from chrome://version; Playwright can't select a profile in place, so Clipy COPIES it into a temp recording root and launches the copy — loudly disclosed, the real profile is never opened or written, and the copy is deleted after upload; no need to quit Chrome, though it warns if Chrome is running since in-use DBs may copy inconsistently). Auth boundary: --storage-state only seeds what the file contains; for cross-origin auth produce it with `npx playwright open --save-storage=auth.json <login-host>`, or use --user-data-dir + --profile-directory to record your real profile, or --source mac-screen --window Chrome. With --source screen (or mac-screen on macOS): records the real screen, via the Clipy Mac app on macOS (--type not yet applied on mac) and with the CLI's own X11 recorder on Linux (silent; needs ffmpeg with x11grab). Auth flags are rejected, since the screen is already logged in; --window '<title|app|id>' records that window by itself (windows on top of it stay out, and it follows the window if it moves, only when --json reports windowCapture \"window\"; \"area\", from a Clipy Mac app older than bridge protocol v3 or on ffmpeg older than 5.1, records whatever is on top, and on Linux covered parts are black without a compositor) and --display <id> records one display (ids from clipy sources). Linux only: --x-display :N picks the X display (default $DISPLAY) and --virtual-display records a private X display sized by --width/--height. --json prints {id, shareUrl, contextUrl, sizeBytes}", ["--for", "--viewports", "--title", "--description", "--type", "--note", "--storage-state", "--cookie", "--local-storage", "--init-script", "--user-data-dir", "--profile-directory", "--width", "--height", "--wait", "--source", "--window", "--display", "--x-display", "--virtual-display", "--json"]),
|
|
6439
|
-
cmdDoc("session", "clipy session <start|run|stop|abort|status> [--url <url>] [--max sec] [--type kind] [--source web|screen|chrome-for-clipy|chrome-extension] [--window w] [--display d] [--x-display :N] [--virtual-display] [--expose-cdp] [--diagnostics off|errors|all] [--network-detail] [--storage-state f] [--cookie 'n=v']… [--local-storage 'k=v']… [--init-script f] [--json]", "Background recording session; auto-stops + uploads at --max (default 600s, cap 1800s). --type sets the recording kind (see record). Web and chrome-for-clipy sessions attach browser evidence read from the browser itself (console output, uncaught errors, failed requests including GraphQL errors, WebSocket activity, environment) as the recording's browser diagnostics: --diagnostics errors (default) keeps warnings/errors and failures, all keeps every message and request, off keeps none; --network-detail also keeps request/response headers and text bodies (cookie and authorization headers never leave the machine; the server redacts the rest by field name and value pattern). With --source screen (mac-screen on macOS), --window records that window by itself (windows on top of it stay out only when --json reports windowCapture \"window\"; \"area\", from a Clipy Mac app older than bridge protocol v3 or on ffmpeg older than 5.1, records whatever is on top, and on Linux covered parts are black without a compositor) and --display records one display; on Linux --x-display :N picks the X display and --virtual-display records a private X display whose name is returned as xDisplay (session run exports it to the command as DISPLAY). --source chrome-extension records ONE TAB through the Clipy extension inside Chrome for Clipy (needs a one-time clipy chrome setup): no daemon, the extension records and uploads; start returns cdpHttpUrl and the recorded tab's url (opened in the background, never focused), --name titles the recording, the tab's sound is left out unless --tab-audio (detected speech would replace the marks as the transcript), mark/chapter (plain or --observed/--verdict, not --assert-*) are kept by the CLI and sent at stop as the transcript, stop waits for the upload and returns the link. --source chrome-for-clipy records ONE TAB (tab video + tab audio, no picker or gesture) inside the persistent Chrome for Clipy instance: the instance is started automatically (sign in once via clipy chrome start and the profile stays signed in), the recorded tab opens at --url, its CDP endpoint is always published as cdpUrl/cdpHttpUrl so drivers attach to the very browser being recorded, and stopping the session leaves Chrome for Clipy running; auth-capture flags and --user-data-dir are rejected for this source. --expose-cdp (web sessions) opens a CDP endpoint (cdpUrl/cdpHttpUrl in the state file + session start/status output) so your own tools can drive the page while it records; OFF by default (any local process could attach), and CLIPY_DISABLE_CDP=1 forces it off. `session run [start flags] -- <command…>` starts a session, runs the command with inherited stdio (env CLIPY_SESSION=1, plus CLIPY_CDP_URL when --expose-cdp, plus CLIPY_TARGET_ID/CLIPY_PAGE_WS_URL for the recorded tab with --source chrome-extension), then GUARANTEES cleanup: exit 0 uploads, any non-zero exit or signal discards (session abort) and propagates the child's code. It is the crash-safe wrapper, so a dead driver never records dead air. Accepts the same auth flags as record (--storage-state/--user-data-dir/--profile-directory/--cookie/--local-storage/--init-script; web only, rejected on --source mac-screen). `session run` exports CLIPY_SESSION_FILE to the child so mark/chapter resolve the session from any cwd. --json is supported on start/stop/status (start returns cdpUrl/cdpHttpUrl)", ["run", "--url", "--max", "--type", "--source", "--window", "--display", "--x-display", "--virtual-display", "--tab-audio", "--expose-cdp", "--diagnostics", "--network-detail", "--storage-state", "--user-data-dir", "--profile-directory", "--cookie", "--local-storage", "--init-script", "--json"]),
|
|
7357
|
+
cmdDoc("proof", "clipy proof (--frame <png|jpg|webp>… | --video <webm|mp4>) [--for <recording>] [--caption <text>…] [--hold sec] [--title t] [--type kind] [--expected text] [--note '3: text']… [--wait] [--json]", "Tool-neutral proof upload. --frame may be repeated to turn screenshots produced by any browser, computer-use, simulator, or test tool into one high-quality silent MP4; --caption must be omitted or repeated exactly once per frame and becomes timestamped agent narration. --hold controls each frame's duration (default 3s, 0.25–30; total cap 300s); --width/--height must be even integers from 320–3840 and default to 1280x720. Frame inputs are bounded to 50 MiB each and 250 MiB total. Screenshot stitching needs ffmpeg but does not need Playwright or a browser integration. --video uploads an already-recorded WebM or MP4 without re-encoding and needs no recording dependency. Exactly one source mode is required. --for <recording id|url> links the uploaded proof back to the recording it verifies (validated before upload; the link appears in the owner-only receipt on that recording's watch page and needs a key with both ingest and recordings:read). --json prints {id, shareUrl, contextUrl, sizeBytes, source, verifies?}; proof-video source reports only the detected container and never discloses the local path. Captions and notes are driver-attested narration, not Clipy-verified assertions.", ["--frame", "--caption", "--video", "--for", "--hold", "--width", "--height", "--title", "--description", "--type", "--expected", "--note", "--wait", "--json"]),
|
|
7358
|
+
cmdDoc("record", "clipy record --url <url> [--for sec] [--viewports list] [--title t] [--type kind] [--expected text] [--note '12: text']… [--storage-state f] [--cookie 'n=v']… [--local-storage 'k=v']… [--init-script f] [--wait] [--json]", "Headless one-shot capture of a web app; notes become the transcript. Notes are absolute ('12: text') or pass-scoped ('pass2: text' / 'pass2@5: text', anchored to a --viewports pass's real start; a malformed pass note is rejected). --type declares the recording kind (bug_report|feature_request|product_demo|walkthrough_tutorial|feedback_review|discussion_talk|other, plus aliases bug/feature/demo/walkthrough/feedback/discussion) so the AI summary reads it correctly. --expected states what should have happened (not yet applied on mac; use clipy update afterwards). Auth (web capture only, applied before the first navigation so a logged-in SPA's route guard sees it): --storage-state <playwright storageState JSON path>, --cookie 'name=value[; Domain=d; Path=p; Secure; HttpOnly; SameSite=Lax]' (repeatable), --local-storage 'key=value' (repeatable, target origin only), --init-script <js file run before every page load>, --user-data-dir <dir> (launch from a persistent Chromium user-data ROOT with its whole logged-in identity; web only, mutually exclusive with --storage-state; refused if <dir> is a profile subdir — pass the root — or, in direct mode, a live-locked root via SingletonLock/Socket), --profile-directory <name> (with --user-data-dir: pick a NAMED profile like 'Profile 12' from chrome://version; Playwright can't select a profile in place, so Clipy COPIES it into a temp recording root and launches the copy — loudly disclosed, the real profile is never opened or written, and the copy is deleted after upload; no need to quit Chrome, though it warns if Chrome is running since in-use DBs may copy inconsistently). Auth boundary: --storage-state only seeds what the file contains; for cross-origin auth produce it with `npx playwright open --save-storage=auth.json <login-host>`, or use --user-data-dir + --profile-directory to record your real profile, or --source mac-screen --window Chrome. With --source screen (or mac-screen on macOS): records the real screen, via the Clipy Mac app on macOS (--type not yet applied on mac) and with the CLI's own X11 recorder on Linux (silent; needs ffmpeg with x11grab). Auth flags are rejected, since the screen is already logged in; --window '<title|app|id>' records that window by itself (windows on top of it stay out, and it follows the window if it moves, only when --json reports windowCapture \"window\"; \"area\", from a Clipy Mac app older than bridge protocol v3 or on ffmpeg older than 5.1, records whatever is on top, and on Linux covered parts are black without a compositor) and --display <id> records one display (ids from clipy sources). Linux only: --x-display :N picks the X display (default $DISPLAY) and --virtual-display records a private X display sized by --width/--height. --json prints {id, shareUrl, contextUrl, sizeBytes}", ["--for", "--viewports", "--title", "--description", "--type", "--expected", "--note", "--storage-state", "--cookie", "--local-storage", "--init-script", "--user-data-dir", "--profile-directory", "--width", "--height", "--wait", "--source", "--window", "--display", "--x-display", "--virtual-display", "--json"]),
|
|
7359
|
+
cmdDoc("session", "clipy session <start|run|stop|abort|status> [--url <url>] [--max sec] [--type kind] [--expected text] [--source web|screen|chrome-for-clipy|chrome-extension] [--window w] [--display d] [--x-display :N] [--virtual-display] [--expose-cdp] [--diagnostics off|errors|all] [--network-detail] [--storage-state f] [--cookie 'n=v']… [--local-storage 'k=v']… [--init-script f] [--json]", "Background recording session; auto-stops + uploads at --max (default 600s, cap 1800s). --type sets the recording kind (see record). --expected states what should have happened, shown to agents as the recording's Expected result (web, chrome-for-clipy and Linux screen sessions; for the others run clipy update afterwards). Web and chrome-for-clipy sessions attach browser evidence read from the browser itself (console output, uncaught errors, failed requests including GraphQL errors, WebSocket activity, environment) as the recording's browser diagnostics: --diagnostics errors (default) keeps warnings/errors and failures, all keeps every message and request, off keeps none; --network-detail also keeps request/response headers and text bodies (cookie and authorization headers never leave the machine; the server redacts the rest by field name and value pattern). With --source screen (mac-screen on macOS), --window records that window by itself (windows on top of it stay out only when --json reports windowCapture \"window\"; \"area\", from a Clipy Mac app older than bridge protocol v3 or on ffmpeg older than 5.1, records whatever is on top, and on Linux covered parts are black without a compositor) and --display records one display; on Linux --x-display :N picks the X display and --virtual-display records a private X display whose name is returned as xDisplay (session run exports it to the command as DISPLAY). --source chrome-extension records ONE TAB through the Clipy extension inside Chrome for Clipy (needs a one-time clipy chrome setup): no daemon, the extension records and uploads; start returns cdpHttpUrl and the recorded tab's url (opened in the background, never focused), --name titles the recording, the tab's sound is left out unless --tab-audio (detected speech would replace the marks as the transcript), mark/chapter (plain or --observed/--verdict, not --assert-*) are kept by the CLI and sent at stop as the transcript, stop waits for the upload and returns the link. --source chrome-for-clipy records ONE TAB (tab video + tab audio, no picker or gesture) inside the persistent Chrome for Clipy instance: the instance is started automatically (sign in once via clipy chrome start and the profile stays signed in), the recorded tab opens at --url, its CDP endpoint is always published as cdpUrl/cdpHttpUrl so drivers attach to the very browser being recorded, and stopping the session leaves Chrome for Clipy running; auth-capture flags and --user-data-dir are rejected for this source. --expose-cdp (web sessions) opens a CDP endpoint (cdpUrl/cdpHttpUrl in the state file + session start/status output) so your own tools can drive the page while it records; OFF by default (any local process could attach), and CLIPY_DISABLE_CDP=1 forces it off. `session run [start flags] -- <command…>` starts a session, runs the command with inherited stdio (env CLIPY_SESSION=1, plus CLIPY_CDP_URL when --expose-cdp, plus CLIPY_TARGET_ID/CLIPY_PAGE_WS_URL for the recorded tab with --source chrome-extension), then GUARANTEES cleanup: exit 0 uploads, any non-zero exit or signal discards (session abort) and propagates the child's code. It is the crash-safe wrapper, so a dead driver never records dead air. Accepts the same auth flags as record (--storage-state/--user-data-dir/--profile-directory/--cookie/--local-storage/--init-script; web only, rejected on --source mac-screen). `session run` exports CLIPY_SESSION_FILE to the child so mark/chapter resolve the session from any cwd. --json is supported on start/stop/status (start returns cdpUrl/cdpHttpUrl)", ["run", "--url", "--max", "--type", "--expected", "--source", "--window", "--display", "--x-display", "--virtual-display", "--tab-audio", "--expose-cdp", "--diagnostics", "--network-detail", "--storage-state", "--user-data-dir", "--profile-directory", "--cookie", "--local-storage", "--init-script", "--json"]),
|
|
6440
7360
|
cmdDoc("mark", "clipy mark \"<text>\" [--observed \"<values>\" --verdict pass|fail] [--assert-selector <css> [--assert-text <substr>]] [--assert-url <glob>] [--fail-mode warn|abort] [--at <sec>|--ago <sec>] [--json]", "Drop a live-timestamped note into the active session. A mark carries at most ONE evidence provenance, and the two are labeled + tallied separately so they can never be pooled. DRIVER-ATTESTED (--observed '<values>' --verdict pass|fail, both required together): you drove the browser and report what YOU observed — renders '<text> [≈ ASSERT driver-attested; observed=<values>]' (pass) / '<text> [≈ FAILED driver-attested; observed=<values>]' (fail) — a HEDGE glyph, never ✓/✗, so a skim distinguishes provenance by shape alone and works in EVERY session type including --source mac-screen. Honesty rule: driver-attested means Clipy vouches the agent SAID it, not that Clipy verified it — put real observed values there. Combining --observed/--verdict with --assert-* is a usage error. CLIPY-VERIFIED assertion marks (Clipy-owned page only) make the note evidence Clipy itself checked: --assert-selector checks a CSS selector matches (its trimmed textContent is recorded as 'observed'); --assert-text requires that element's text to contain a substring (needs --assert-selector); --assert-url matches the page URL against a glob (** = any, * = any non-slash, no * = substring). The daemon evaluates against its live page and annotates the mark: pass ⇒ '<text> [assert ✓ verified-by-clipy; <observed>]', fail ⇒ '<text> [ASSERT ✗ verified-by-clipy; expected …; observed …]' — a false claim cannot read as fact. --fail-mode warn (default) records the ✗; --fail-mode abort DISCARDS the whole session on a failed assertion (no upload) and the CLI exits non-zero. If any assertion was attempted, a leading 0ms [verification] note is prepended, reporting the provenances as SEPARATE segments: '[verification] N clipy-verified: P passed, F failed, K unverified · M driver-attested: P passed, F failed' (a segment is omitted when empty; with only clipy-verified marks the legacy 'N assertion(s): …' rendering is byte-identical). --at <sec> stamps at an absolute recording time; --ago <sec> stamps N seconds before now (mutually exclusive). Assertions/backdating need a web session (rejected on --source mac-screen). Up to 200 marks per recording.", ["--observed", "--verdict", "--assert-selector", "--assert-text", "--assert-url", "--fail-mode", "--at", "--ago", "--json"]),
|
|
6441
7361
|
cmdDoc("chapter", "clipy chapter \"<label>\" [--json]", "Mark a BEFORE/AFTER section boundary in the active recording (stored as '=== CHAPTER: <label> ==='). The PR-review shape: demo the base branch, run `clipy chapter \"AFTER — fix applied\"`, swap branches + restart the dev server, demo the fix — one video carrying both states. Works on web + --source mac-screen sessions.", ["--json"]),
|
|
6442
|
-
cmdDoc("doctor", "clipy doctor [--json]", "One-shot health check: API reachability (GET /api/health, with latency), API key + whoami round-trip, Mac agent bridge (exists/parses/pid/appVersion>=" + MIN_BRIDGE_APP_VERSION + "), Playwright resolvability (and the resolved path/node_modules dir), context/proof prerequisites (yt-dlp presence/path/version, ffmpeg + ffprobe presence/version, and whether that ffmpeg has libwebp), and install mode (npx/global/local)
|
|
7362
|
+
cmdDoc("doctor", "clipy doctor [--json] [--local]", "One-shot health check: API reachability (GET /api/health, with latency), API key + whoami round-trip, Mac agent bridge (exists/parses/pid/appVersion>=" + MIN_BRIDGE_APP_VERSION + "), Playwright resolvability (and the resolved path/node_modules dir), context/proof prerequisites (yt-dlp presence/path/version, ffmpeg + ffprobe presence/version, and whether that ffmpeg has libwebp), and install mode (npx/global/local), each a pass/warn/fail with a fix hint; exits non-zero if any check fails. Read-only: it never installs anything, so a missing yt-dlp/ffmpeg reports WARN with the install command rather than silently downloading a binary. Run it first whenever an import, proof, or recording fails. With --local it checks only local mode (config, models, speech engine, capture) and makes no request to Clipy.", ["--json", "--local"]),
|
|
6443
7363
|
cmdDoc("playwright-path", "clipy playwright-path [--json]", "Print the node_modules directory of the Playwright this CLI resolves, so your own --expose-cdp driver scripts can load the same copy: NODE_PATH=$(clipy playwright-path) node driver.js. Exits 1 (empty stdout) if Playwright is unresolvable. --json prints {path, nodeModulesDir, source}", ["--json"]),
|
|
6444
7364
|
cmdDoc("sources", "clipy sources [--x-display :N] [--json]", "List displays + windows that --source screen can capture (the Clipy Mac app's on macOS; the X display's on Linux, where listing windows needs x11-utils) — ids feed --window/--display. --json gives each entry a `source` {kind,id,title} in the SAME shape session start/record report for the resolved capture, so a caller can compare what it picked against what the camera reports without transforming either."),
|
|
6445
7365
|
cmdDoc("setup", "clipy setup [claude|codex|cursor|windsurf|opencode] [--with-browser] [--json]", "Wire Clipy into one coding agent in a single command: sign in if needed, install the bundled skill, and register the MCP server in that agent's own config (`claude`/`codex` through their own `mcp add`; `cursor`/`windsurf`/`opencode` by merging their JSON config, never replacing other servers). Omit the agent to auto-detect from the environment — ambiguous or unknown exits 2 rather than guessing. Re-running is safe. Successful --json output is {ok:true, target, skill:{installed,path}, mcp:{method,path,changed,alreadyPresent}, authenticated:true, restartRequired:true}. Failures use {ok:false,code,error,remediation,partial}; partial.mcp.method 'manual' means the caller must run partial.mcp.command or paste partial.mcp.snippet before setup is complete. The MCP server is read at agent startup, so the calling session will not see the tools until it restarts. --with-browser additionally provisions Chrome for Clipy, the agent-owned automation browser (see chrome): on macOS it installs the launcher app once, then it starts the instance. Its outcome is reported under a `browser` key ({ok, chrome:{appInstalled, appPath?, running, error?}}) and a browser failure never fails core setup.", ["--with-browser", "--json"]),
|
|
6446
7366
|
cmdDoc("agents", "clipy agents <status|install|uninstall> <claude|codex|cursor|windsurf|opencode>", "Skill file only — does NOT register MCP. `clipy setup` is the one-command form; install triggers a browser login first when no key is configured (interactive terminals only)"),
|
|
6447
7367
|
cmdDoc("chrome", "clipy chrome <setup|start|stop|status|install-app> [--port <n>] [--foreground] [--json]", "setup (one time, for --source chrome-extension): starts Chrome for Clipy, opens the Clipy extension's Web Store page and then clipy.online in that window, and waits up to 15 minutes until the extension reports it is installed and signed in; returns {ok:true, extension:{version,email}, chrome} and is a quick check on a ready machine. The two steps it waits for are the user's: an agent relays them and never performs them. Chrome for Clipy also launches with --allowlisted-extension-id (CLIPY_EXTENSION_ID overrides the store id), and an instance found running without the current flags is relaunched. Launch and manage 'Chrome for Clipy', a dedicated persistent automation browser: its own profile (sign in once, identity persists across launches), CDP on --port (default 9333) for any driver, --auto-select-tab-capture-source-by-title so a page's getDisplayMedia captures the tab whose title starts with the 'clipy-rec' marker without any picker or gesture UI, and background-throttling disabled so hidden tabs keep rendering. start is idempotent (re-reports the running instance) and, on macOS, launches in the background without taking focus from the app the user is in (--foreground brings the window forward, e.g. to sign in; setup always does); status returns {running,pid,port,cdpUrl,cdpReady,profileDir,appInstalled,captureTitleMarker}; install-app writes a named 'Chrome for Clipy.app' launcher into ~/Applications (macOS only). Drivers attach over raw CDP; no extension is needed.", ["--port", "--foreground", "--json"]),
|
|
7368
|
+
cmdDoc("record --local", "clipy record --local [--max sec] [--mic] [--virtual-display] [--display <id>|--window <id>] [--url <u>] [--source screen] [--note '12: text']… [--title t] [--out dir] [--json]", "Local mode: no Clipy account and nothing uploaded. The capture is the same as without --local (with --url the headless browser capture, silent; with --source screen on Linux the X11 recorder, timed by --for or --max; with --source screen or mac-screen on macOS, Clipy Local, the open-source local edition of the Mac app, records through its agent bridge for --for or --max seconds (default 15, cap 1740; Ctrl-C stops early and keeps the take), never the official Clipy app, and fails with a clear message when Clipy Local is not running; --window and --display name a window or display Clipy Local can see; --out and --force do not apply because Clipy Local keeps each take in its own folder); with no --url and no --source, or --source screen on Windows, the CLI's local screen recorder (ffmpeg) runs until Enter, Ctrl-C, SIGTERM, SIGHUP or --max (with no --max and stdin not a terminal, also until stdin closes, with a warning), with the microphone only on --mic. The config file, model provider, ffmpeg and --out are checked before recording starts; a later failure keeps the capture and prints where. Then, on this machine: transcription (the configured engine; skipped when the capture has no audio track), key moments (rules for highlights, drawings, clicks and pointer rests, plus spoken references when a model provider is configured), one frame per moment, and an AREC 1.4 folder: recording.mp4, transcript.json, moments.json, frames/, recording.arec. Notes become narration in the transcript and a key moment each. Default folder ~/clipy/recordings/<YYYY-MM-DD-HHMMSS>/ (mode 0700), or --out; an --out that holds files is refused (exit 2) unless --force, which replaces the previous take's files there. The last stdout line is the absolute recording.arec path; --json prints {ok:true, local:true, arec, dir, video, durationMs, moments, frames, planner, transcript:{engine,segments}, warnings}; a failure prints {ok:false, local:true, error, keptVideo?}. A Clipy Local take prints {ok, local:true, app:\"Clipy Local\", arec, arecPath, dir, out, video, status (ready, failed, or the stage still running when the 300 s processing wait ran out, with timedOut:true), message, recordingId, sizeBytes, autoStopped, captureMode:\"mac-screen\", source, audio}; status failed exits 1 and still prints the Partial AREC path. Data boundary: with no provider (or Ollama/LM Studio) and on-device transcription, nothing leaves the machine; with a model provider, the transcript text, click labels and a bounded sample of pointer and key events go to it; with a transcription key, the audio goes to that provider. The video and screenshots never leave the machine. Share later with `clipy upload <dir>/recording.mp4` (needs an account; watching needs no signup).", ["--local", "--max", "--for", "--mic", "--virtual-display", "--display", "--window", "--url", "--source", "--note", "--title", "--description", "--type", "--expected", "--width", "--height", "--out", "--force", "--json"]),
|
|
7369
|
+
cmdDoc("session start --local", "clipy session start [--url <u>] [--source web|screen|chrome-for-clipy] --local [--out dir] [--force] [--max sec] [--json]", "Same lifecycle as session start (mark, chapter, stop, abort, run), but `session stop` builds the AREC on this machine instead of uploading; marks become narration and key moments. Works for headless web, --source screen on Linux, chrome-for-clipy, and --source screen or mac-screen on macOS, which drives Clipy Local (the open-source local edition of the Mac app) through its agent bridge: never the official Clipy app, no sign-in, marks and chapters become narration in its transcript and a key moment each, start --json returns {state, local:true, app:\"Clipy Local\", recordingId, arec, out, source, audio}, and stop waits up to 300 s for Clipy Local to finish processing and prints the Clipy Local result described under record --local (--out and --force do not apply). Refused for chrome-extension. Otherwise start checks the config, model provider and ffmpeg, and claims the output folder, so two sessions never share one. start --json adds {local:true, out}; stop prints the same result as record --local. `session stop --local` and `session status --local` exit 2 on a session started without --local (it would upload; discard it with session abort).", ["--local", "--out", "--force", "--url", "--source", "--max", "--json"]),
|
|
7370
|
+
cmdDoc("proof --local", "clipy proof (--frame <img>… [--caption t]… | --video <file>) --local [--out dir] [--force] [--json]", "Builds the proof video as usual and then the local AREC instead of uploading. Each frame (and its caption) becomes narration and a key moment framed mid-hold; --note values become narration. --for is refused (it links to a hosted recording).", ["--local", "--frame", "--caption", "--video", "--hold", "--note", "--title", "--out", "--force", "--json"]),
|
|
7371
|
+
cmdDoc("context import --local", "clipy context import <file|url> --local [--transcript <vtt|srt|json>] [--out dir] [--force] [--title t] [--json]", "A local video file: transcribes it on this machine (or with the configured key) unless --transcript is given, picks moments, extracts frames and writes the full local AREC folder; --language, --tag, --folder and --no-frames do not apply to a file and are refused. YouTube and Loom URLs with --local keep the usual transcript-only bundle in --out (fetched on this machine, nothing sent to Clipy); --sync is refused with --local.", ["--local", "--transcript", "--out", "--force", "--title", "--json"]),
|
|
7372
|
+
cmdDoc("local setup", "clipy local setup [--model-provider openrouter|openai|gemini|groq|ollama|lmstudio|custom|none] [--model-key -] [--model m] [--base-url u] [--transcribe local-english|local-multilingual|openai|groq|deepgram|assemblyai|elevenlabs|gemini|none] [--transcribe-key -] [--json]", "Saves local mode's settings (config file mode 0600; keys are never printed). The model provider reads the transcript to pick spoken references; no provider means rules only. Transcription defaults to the on-device english-fast model. Keys: prefer the CLIPY_MODEL_API_KEY and CLIPY_TRANSCRIBE_API_KEY env vars; `--model-key -` or `--transcribe-key -` reads the key from stdin (one line). A literal key still works but can stay in shell history and the process list, and a note says so. Env vars override the file: CLIPY_MODEL_PROVIDER, CLIPY_MODEL_BASE_URL, CLIPY_MODEL_API_KEY, CLIPY_MODEL, CLIPY_TRANSCRIBE, CLIPY_TRANSCRIBE_API_KEY, CLIPY_TRANSCRIBE_MODEL, CLIPY_TRANSCRIBE_BASE_URL, CLIPY_LOCAL_CONFIG.", ["--model-provider", "--model-key", "--model", "--base-url", "--transcribe", "--transcribe-key", "--json"]),
|
|
7373
|
+
cmdDoc("local status", "clipy local status [--json]", "Local mode at a glance: config file path, moment selection, transcription, which speech models are installed, whether the speech engine is installed, and whether screen capture is ready. Never fails.", ["--json"]),
|
|
7374
|
+
cmdDoc("models", "clipy models list | clipy models download <english-fast|multilingual> [--json]", "On-device speech models for local transcription: english-fast (NVIDIA Parakeet TDT-CTC 110M, CC-BY-4.0, about 104 MB) and multilingual (OpenAI Whisper base, MIT, about 161 MB), both run with sherpa-onnx (Apache-2.0). list shows each model's licence (--json: license, attribution). Downloaded only on request, checksum-verified, into the platform cache folder; Ctrl-C or SIGTERM cancels a download and removes the partial files. They run with the speech engine (clipy speech install); after a download it is offered, and installed with --yes.", ["--json"]),
|
|
7375
|
+
cmdDoc("speech", "clipy speech status | clipy speech install [--json]", "The on-device speech engine (sherpa-onnx-node 2.0.1, about 35 MB from npm) that runs the speech models. It is not installed with the CLI. The first local take that needs on-device transcription asks before downloading it into a Clipy folder in the user cache; with no terminal (agents, CI, --json) that take stops before recording with code speech_engine_required. Accept up front with clipy speech install, --yes on the take, or CLIPY_INSTALL_SPEECH_ENGINE=1. CLIPY_SPEECH_ENGINE_DIR moves the folder.", ["--json"]),
|
|
7376
|
+
cmdDoc("sources --local", "clipy sources --local [--source mac-screen] [--json]", "Screens and windows the local recorder (record --local) can capture, with ids for --display/--window. With --source mac-screen (or screen on macOS), the displays and windows Clipy Local can capture instead, in the same shape as clipy sources: the ids --window/--display take with --source mac-screen --local.", ["--local", "--source", "--json"]),
|
|
6448
7377
|
cmdDoc("guide", "clipy guide --json", "This manifest"),
|
|
6449
7378
|
cmdDoc("mcp", "clipy mcp", "Run the Clipy MCP server (wraps npx -y @clipy/mcp)"),
|
|
6450
7379
|
],
|
|
@@ -6573,6 +7502,15 @@ async function main() {
|
|
|
6573
7502
|
for: { type: "string" },
|
|
6574
7503
|
timeout: { type: "string" },
|
|
6575
7504
|
url: { type: "string" },
|
|
7505
|
+
// recheck
|
|
7506
|
+
out: { type: "string" },
|
|
7507
|
+
plan: { type: "boolean", default: false },
|
|
7508
|
+
"no-upload": { type: "boolean", default: false },
|
|
7509
|
+
"settle-ms": { type: "string" },
|
|
7510
|
+
"nav-timeout-ms": { type: "string" },
|
|
7511
|
+
"max-steps": { type: "string" },
|
|
7512
|
+
"fail-on-divergence": { type: "boolean", default: false },
|
|
7513
|
+
"allow-destructive": { type: "boolean", default: false },
|
|
6576
7514
|
name: { type: "string" },
|
|
6577
7515
|
title: { type: "string" },
|
|
6578
7516
|
description: { type: "string" },
|
|
@@ -6622,6 +7560,10 @@ async function main() {
|
|
|
6622
7560
|
yes: { type: "boolean", default: false },
|
|
6623
7561
|
"allow-delete": { type: "boolean", default: false },
|
|
6624
7562
|
"clear-description": { type: "boolean", default: false },
|
|
7563
|
+
// What the recorder expected to happen (issue #741). Optional; shown to
|
|
7564
|
+
// agents as "Expected result" in the recording's AREC.
|
|
7565
|
+
expected: { type: "string" },
|
|
7566
|
+
"clear-expected": { type: "boolean", default: false },
|
|
6625
7567
|
access: { type: "string" },
|
|
6626
7568
|
create: { type: "string" },
|
|
6627
7569
|
untag: { type: "string", multiple: true },
|
|
@@ -6642,8 +7584,18 @@ async function main() {
|
|
|
6642
7584
|
cursor: { type: "string" },
|
|
6643
7585
|
version: { type: "boolean", short: "v", default: false },
|
|
6644
7586
|
help: { type: "boolean", short: "h", default: false },
|
|
7587
|
+
// Local mode: build the AREC on this machine, upload nothing.
|
|
7588
|
+
local: { type: "boolean", default: false },
|
|
7589
|
+
force: { type: "boolean", default: false },
|
|
7590
|
+
"model-provider": { type: "string" },
|
|
7591
|
+
"model-key": { type: "string" },
|
|
7592
|
+
model: { type: "string" },
|
|
7593
|
+
"base-url": { type: "string" },
|
|
7594
|
+
transcribe: { type: "string" },
|
|
7595
|
+
"transcribe-key": { type: "string" },
|
|
6645
7596
|
},
|
|
6646
7597
|
});
|
|
7598
|
+
const expectedResult = values.expected?.trim() || undefined;
|
|
6647
7599
|
if (values.version) {
|
|
6648
7600
|
process.stdout.write(`${VERSION}\n`);
|
|
6649
7601
|
return;
|
|
@@ -6657,12 +7609,22 @@ async function main() {
|
|
|
6657
7609
|
apiKey: values.key || process.env.CLIPY_API_KEY || cfg.apiKey || null,
|
|
6658
7610
|
};
|
|
6659
7611
|
const [command, ...rest] = positionals;
|
|
7612
|
+
localAssumeYes = values.yes === true;
|
|
6660
7613
|
if (!command || values.help || command === "help") {
|
|
6661
7614
|
process.stdout.write(HELP);
|
|
6662
7615
|
if (!command && !values.help)
|
|
6663
7616
|
process.exitCode = 2;
|
|
6664
7617
|
return;
|
|
6665
7618
|
}
|
|
7619
|
+
// --local promises that nothing is uploaded, so a command that cannot keep
|
|
7620
|
+
// that promise refuses the flag instead of quietly ignoring it.
|
|
7621
|
+
if (values.local) {
|
|
7622
|
+
const localCapable = ["record", "session", "proof", "sources", "local", "models", "speech", "mark", "chapter", "guide", "doctor"].includes(command) ||
|
|
7623
|
+
(command === "context" && rest[0] === "import");
|
|
7624
|
+
if (!localCapable) {
|
|
7625
|
+
die(`--local does not apply to \`clipy ${command}${command === "context" && rest[0] ? ` ${rest[0]}` : ""}\`. It works with record, session, proof, context import and sources.`, 2);
|
|
7626
|
+
}
|
|
7627
|
+
}
|
|
6666
7628
|
const json = Boolean(values.json);
|
|
6667
7629
|
const num = (v, dflt) => {
|
|
6668
7630
|
const n = parseInt(String(v ?? ""), 10);
|
|
@@ -6809,14 +7771,42 @@ async function main() {
|
|
|
6809
7771
|
// by that name, which is why they can never be confused for one.
|
|
6810
7772
|
if (rest[0] === "import") {
|
|
6811
7773
|
if (!rest[1])
|
|
6812
|
-
die("usage: clipy context import <youtube-url|loom-url|local-file> [--transcript <f>] [--output <dir>] [--sync]", 2);
|
|
7774
|
+
die("usage: clipy context import <youtube-url|loom-url|local-file> [--transcript <f>] [--output <dir>] [--sync] [--local [--out <dir>]]", 2);
|
|
7775
|
+
if (values.local && values.sync) {
|
|
7776
|
+
die("--sync uploads to your Clipy library; it does not go with --local", 2);
|
|
7777
|
+
}
|
|
7778
|
+
const localOut = (values.out ?? values.output)?.trim() || undefined;
|
|
7779
|
+
if (values.local && existsSync(resolve(rest[1])) && statSync(resolve(rest[1])).isFile()) {
|
|
7780
|
+
// These shape a URL import or a library sync; a local file's take has
|
|
7781
|
+
// no use for them, so say so instead of dropping them silently.
|
|
7782
|
+
const ignored = [
|
|
7783
|
+
values.language !== undefined ? "--language" : null,
|
|
7784
|
+
values.tag !== undefined ? "--tag" : null,
|
|
7785
|
+
values.folder !== undefined ? "--folder" : null,
|
|
7786
|
+
values["no-frames"] ? "--no-frames" : null,
|
|
7787
|
+
].filter((flag) => flag !== null);
|
|
7788
|
+
if (ignored.length > 0) {
|
|
7789
|
+
die(`${ignored.join(", ")} ${ignored.length === 1 ? "does" : "do"} not apply to context import <file> --local: transcription follows clipy local setup, and every key moment gets a frame. Drop ${ignored.length === 1 ? "it" : "them"}.`, 2);
|
|
7790
|
+
}
|
|
7791
|
+
await cmdContextImportLocal(rest[1], {
|
|
7792
|
+
transcriptPath: values.transcript,
|
|
7793
|
+
out: localOut,
|
|
7794
|
+
force: Boolean(values.force),
|
|
7795
|
+
title: values.title?.trim() || undefined,
|
|
7796
|
+
json,
|
|
7797
|
+
});
|
|
7798
|
+
return;
|
|
7799
|
+
}
|
|
7800
|
+
// A YouTube or Loom URL with --local: the import already builds its
|
|
7801
|
+
// bundle on this machine and never calls Clipy without --sync.
|
|
6813
7802
|
try {
|
|
6814
7803
|
await cmdContextImport(rest[1], {
|
|
6815
7804
|
apiUrl: ctx.apiUrl,
|
|
6816
7805
|
apiKey: ctx.apiKey,
|
|
6817
7806
|
cliVersion: VERSION,
|
|
6818
7807
|
transcriptPath: values.transcript,
|
|
6819
|
-
|
|
7808
|
+
// --local takes --out like every local command; --output still works.
|
|
7809
|
+
outputDir: values.local ? localOut : values.output,
|
|
6820
7810
|
language: values.language,
|
|
6821
7811
|
title: values.title,
|
|
6822
7812
|
tags: values.tag ?? [],
|
|
@@ -6859,7 +7849,7 @@ async function main() {
|
|
|
6859
7849
|
case "upload": {
|
|
6860
7850
|
const file = rest[0] ?? values.video;
|
|
6861
7851
|
if (!file)
|
|
6862
|
-
usageFail('usage: clipy upload <file.mp4|webm|mov> [--title "<t>"] [--type kind] [--access public|restricted|private] [--wait] [--json]', 2);
|
|
7852
|
+
usageFail('usage: clipy upload <file.mp4|webm|mov> [--title "<t>"] [--type kind] [--expected "<text>"] [--access public|restricted|private] [--wait] [--json]', 2);
|
|
6863
7853
|
// Validated here, not by requireRecordingKind/parseNoteFlag, whose die()
|
|
6864
7854
|
// would print prose and break the one-object --json contract.
|
|
6865
7855
|
let uploadKind;
|
|
@@ -6878,6 +7868,7 @@ async function main() {
|
|
|
6878
7868
|
name: (values.title ?? values.name)?.trim() || undefined,
|
|
6879
7869
|
description: values.description?.trim() || undefined,
|
|
6880
7870
|
recordingKind: uploadKind,
|
|
7871
|
+
expectedResult,
|
|
6881
7872
|
notes: uploadNotes.map(parseNoteFlag),
|
|
6882
7873
|
accessMode: values.access,
|
|
6883
7874
|
wait: Boolean(values.wait),
|
|
@@ -6887,11 +7878,13 @@ async function main() {
|
|
|
6887
7878
|
}
|
|
6888
7879
|
case "update":
|
|
6889
7880
|
if (!rest[0])
|
|
6890
|
-
usageFail('usage: clipy update <id|url> [--title "<title>"] [--description "<text>" | --clear-description]', 2);
|
|
7881
|
+
usageFail('usage: clipy update <id|url> [--title "<title>"] [--description "<text>" | --clear-description] [--expected "<text>" | --clear-expected]', 2);
|
|
6891
7882
|
await cmdUpdate(libraryDeps(ctx, json), rest[0], {
|
|
6892
7883
|
title: values.title ?? values.name,
|
|
6893
7884
|
description: values.description,
|
|
6894
7885
|
clearDescription: Boolean(values["clear-description"]),
|
|
7886
|
+
expected: values.expected,
|
|
7887
|
+
clearExpected: Boolean(values["clear-expected"]),
|
|
6895
7888
|
});
|
|
6896
7889
|
return;
|
|
6897
7890
|
case "share":
|
|
@@ -6992,6 +7985,22 @@ async function main() {
|
|
|
6992
7985
|
});
|
|
6993
7986
|
return;
|
|
6994
7987
|
}
|
|
7988
|
+
case "recheck": {
|
|
7989
|
+
const numFlag = (v, fallback) => (v === undefined ? fallback : Number(v));
|
|
7990
|
+
await cmdRecheck(recheckDeps(ctx, json), rest[0], {
|
|
7991
|
+
startUrl: values.url?.trim() || undefined,
|
|
7992
|
+
outDir: values.out?.trim() || undefined,
|
|
7993
|
+
planOnly: Boolean(values.plan),
|
|
7994
|
+
upload: !values["no-upload"],
|
|
7995
|
+
settleMs: numFlag(values["settle-ms"], 800),
|
|
7996
|
+
navigationTimeoutMs: numFlag(values["nav-timeout-ms"], 5_000),
|
|
7997
|
+
maxSteps: numFlag(values["max-steps"], RECHECK_MAX_STEPS),
|
|
7998
|
+
failOnDivergence: Boolean(values["fail-on-divergence"]),
|
|
7999
|
+
allowDestructive: Boolean(values["allow-destructive"]),
|
|
8000
|
+
port: values.port === undefined ? undefined : Number(values.port),
|
|
8001
|
+
});
|
|
8002
|
+
return;
|
|
8003
|
+
}
|
|
6995
8004
|
case "download":
|
|
6996
8005
|
if (!rest[0])
|
|
6997
8006
|
die("usage: clipy download <id|url> [-o <path>]", 2);
|
|
@@ -7016,8 +8025,53 @@ async function main() {
|
|
|
7016
8025
|
cmdMcp();
|
|
7017
8026
|
return;
|
|
7018
8027
|
case "doctor":
|
|
7019
|
-
await cmdDoctor(ctx, json);
|
|
8028
|
+
await cmdDoctor(ctx, json, Boolean(values.local));
|
|
8029
|
+
return;
|
|
8030
|
+
case "local": {
|
|
8031
|
+
const sub = rest[0] ?? "status";
|
|
8032
|
+
const { mod, env } = await localMode();
|
|
8033
|
+
if (sub === "setup") {
|
|
8034
|
+
const str = (k) => (typeof values[k] === "string" ? values[k] : undefined);
|
|
8035
|
+
// `--model-key -` / `--transcribe-key -` read the key from stdin, so it
|
|
8036
|
+
// never sits in argv, shell history or an agent's command log.
|
|
8037
|
+
let keys;
|
|
8038
|
+
try {
|
|
8039
|
+
keys = await mod.resolveKeyFlags({ modelKey: str("model-key"), transcribeKey: str("transcribe-key") }, () => mod.readStdinLine());
|
|
8040
|
+
}
|
|
8041
|
+
catch (error) {
|
|
8042
|
+
mod.printLocalError(error, json, env.io);
|
|
8043
|
+
process.exitCode = error instanceof mod.UsageError ? 2 : 1;
|
|
8044
|
+
return;
|
|
8045
|
+
}
|
|
8046
|
+
process.exitCode = mod.cmdLocalSetup({
|
|
8047
|
+
modelProvider: str("model-provider"),
|
|
8048
|
+
modelKey: keys.modelKey,
|
|
8049
|
+
model: str("model"),
|
|
8050
|
+
baseUrl: str("base-url"),
|
|
8051
|
+
transcribe: str("transcribe"),
|
|
8052
|
+
transcribeKey: keys.transcribeKey,
|
|
8053
|
+
}, json, env);
|
|
8054
|
+
if (keys.literal.length > 0 && process.exitCode === 0)
|
|
8055
|
+
process.stderr.write(`${mod.LITERAL_KEY_NOTE}\n`);
|
|
8056
|
+
return;
|
|
8057
|
+
}
|
|
8058
|
+
if (sub === "status") {
|
|
8059
|
+
process.exitCode = await mod.cmdLocalStatus(json, env);
|
|
8060
|
+
return;
|
|
8061
|
+
}
|
|
8062
|
+
die("usage: clipy local setup [--model-provider <p> --model-key - --model <m> --base-url <u>] [--transcribe <engine> --transcribe-key -] | clipy local status", 2);
|
|
8063
|
+
return;
|
|
8064
|
+
}
|
|
8065
|
+
case "models": {
|
|
8066
|
+
const { mod, env } = await localMode();
|
|
8067
|
+
process.exitCode = await mod.cmdModels(rest, json, env);
|
|
7020
8068
|
return;
|
|
8069
|
+
}
|
|
8070
|
+
case "speech": {
|
|
8071
|
+
const { mod, env } = await localMode();
|
|
8072
|
+
process.exitCode = await mod.cmdSpeech(rest, json, env);
|
|
8073
|
+
return;
|
|
8074
|
+
}
|
|
7021
8075
|
case "playwright-path":
|
|
7022
8076
|
await cmdPlaywrightPath(json);
|
|
7023
8077
|
return;
|
|
@@ -7034,6 +8088,20 @@ async function main() {
|
|
|
7034
8088
|
cmdGuide(json);
|
|
7035
8089
|
return;
|
|
7036
8090
|
case "sources": {
|
|
8091
|
+
// Clipy Local's own ids: the ones --window/--display resolve against for
|
|
8092
|
+
// --source mac-screen --local (not the CLI recorder's ffmpeg ids).
|
|
8093
|
+
if (values.local && isLocalMacSource(values.source)) {
|
|
8094
|
+
if (!bridgeApplicable("local"))
|
|
8095
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
8096
|
+
const sources = await listSources(readLocalBridgeOrDie()).catch((e) => die(e.message));
|
|
8097
|
+
printBridgeSources(sources, json, 'record one with: clipy record --local --source mac-screen --window "<title or id>"');
|
|
8098
|
+
return;
|
|
8099
|
+
}
|
|
8100
|
+
if (values.local) {
|
|
8101
|
+
const { mod, env } = await localMode();
|
|
8102
|
+
process.exitCode = await mod.localSources(json, env);
|
|
8103
|
+
return;
|
|
8104
|
+
}
|
|
7037
8105
|
// An explicit CLIPY_BRIDGE_FILE means "ask that Clipy app", on any OS.
|
|
7038
8106
|
if (process.platform === "linux" && !process.env.CLIPY_BRIDGE_FILE?.trim()) {
|
|
7039
8107
|
const xDisplay = values["x-display"]?.trim() || process.env.DISPLAY;
|
|
@@ -7048,26 +8116,7 @@ async function main() {
|
|
|
7048
8116
|
// Enumerate what the Mac app can capture, so --window/--display have ids.
|
|
7049
8117
|
try {
|
|
7050
8118
|
const sources = await listSources(readBridgeInfo());
|
|
7051
|
-
|
|
7052
|
-
// Each entry carries the SAME `source` descriptor shape that
|
|
7053
|
-
// `session start --json` / `record --json` report for the resolved
|
|
7054
|
-
// capture, so a caller can compare "what I picked" against "what the
|
|
7055
|
-
// camera reports" with a direct object comparison — no transforming.
|
|
7056
|
-
printJson({
|
|
7057
|
-
displays: sources.displays.map((d) => ({ ...d, source: describeDisplay(d) })),
|
|
7058
|
-
windows: sources.windows.map((w) => ({ ...w, source: describeWindow(w) })),
|
|
7059
|
-
});
|
|
7060
|
-
return;
|
|
7061
|
-
}
|
|
7062
|
-
process.stdout.write(`${c.bold("DISPLAYS")}\n`);
|
|
7063
|
-
for (const d of sources.displays) {
|
|
7064
|
-
process.stdout.write(` ${d.id}\t${d.name || "display"}\t${c.dim(`${d.width}×${d.height}`)}\n`);
|
|
7065
|
-
}
|
|
7066
|
-
process.stdout.write(`${c.bold("WINDOWS")}\n`);
|
|
7067
|
-
for (const w of sources.windows) {
|
|
7068
|
-
process.stdout.write(` ${w.id}\t${windowLabel(w)}\t${c.dim(`${w.width}×${w.height}`)}\n`);
|
|
7069
|
-
}
|
|
7070
|
-
process.stdout.write(`${c.dim('record one with: clipy record --source mac-screen --window "<title or id>"')}\n`);
|
|
8119
|
+
printBridgeSources(sources, json, 'record one with: clipy record --source mac-screen --window "<title or id>"');
|
|
7071
8120
|
}
|
|
7072
8121
|
catch (e) {
|
|
7073
8122
|
die(e.message);
|
|
@@ -7091,14 +8140,30 @@ async function main() {
|
|
|
7091
8140
|
undefined,
|
|
7092
8141
|
description: values.description?.trim() || undefined,
|
|
7093
8142
|
recordingKind: values.type ? requireRecordingKind(String(values.type)) : undefined,
|
|
8143
|
+
expectedResult,
|
|
7094
8144
|
notes: (values.note ?? []).map(parseNoteFlag),
|
|
7095
8145
|
wait: Boolean(values.wait),
|
|
7096
8146
|
json,
|
|
7097
8147
|
verificationFor: values.for?.trim() || undefined,
|
|
8148
|
+
...(values.local ? { local: { out: values.out?.trim() || undefined, force: Boolean(values.force) } } : {}),
|
|
7098
8149
|
});
|
|
7099
8150
|
return;
|
|
7100
8151
|
}
|
|
7101
8152
|
case "record": {
|
|
8153
|
+
if (values.local) {
|
|
8154
|
+
await cmdRecordLocalDispatch(ctx, values, rest, {
|
|
8155
|
+
json,
|
|
8156
|
+
expectedResult,
|
|
8157
|
+
num,
|
|
8158
|
+
authFlagsPresent,
|
|
8159
|
+
audioFlagsPresent,
|
|
8160
|
+
authCapture,
|
|
8161
|
+
userDataDir,
|
|
8162
|
+
profileDirectory,
|
|
8163
|
+
audioChoice,
|
|
8164
|
+
});
|
|
8165
|
+
return;
|
|
8166
|
+
}
|
|
7102
8167
|
const source = normalizeScreenSource(String(values.source ?? "web"));
|
|
7103
8168
|
if (source !== "web" && !isScreenSource(source)) {
|
|
7104
8169
|
die("--source must be web (headless browser) or screen (the real screen: the Clipy Mac app on macOS, the CLI's own recorder on Linux)", 2);
|
|
@@ -7129,6 +8194,7 @@ async function main() {
|
|
|
7129
8194
|
undefined,
|
|
7130
8195
|
description: values.description?.trim() || undefined,
|
|
7131
8196
|
recordingKind,
|
|
8197
|
+
expectedResult,
|
|
7132
8198
|
window: values.window?.trim() || undefined,
|
|
7133
8199
|
display: values.display?.trim() || undefined,
|
|
7134
8200
|
xDisplay: values["x-display"]?.trim() || undefined,
|
|
@@ -7138,6 +8204,8 @@ async function main() {
|
|
|
7138
8204
|
notes: (values.note ?? []).map(parseNoteFlag),
|
|
7139
8205
|
json,
|
|
7140
8206
|
}).catch((e) => die(e.message));
|
|
8207
|
+
if (!result)
|
|
8208
|
+
return; // only --local returns no upload, and it never reaches here
|
|
7141
8209
|
if (values.wait && result.publicId)
|
|
7142
8210
|
await waitForArtifacts(ctx, result.publicId).catch(() => { });
|
|
7143
8211
|
if (json) {
|
|
@@ -7172,6 +8240,7 @@ async function main() {
|
|
|
7172
8240
|
undefined,
|
|
7173
8241
|
description: values.description?.trim() || undefined,
|
|
7174
8242
|
recordingKind,
|
|
8243
|
+
expectedResult,
|
|
7175
8244
|
window: values.window?.trim() || undefined,
|
|
7176
8245
|
display: values.display?.trim() || undefined,
|
|
7177
8246
|
notes: noteFlags.map(parseNoteFlag),
|
|
@@ -7210,6 +8279,7 @@ async function main() {
|
|
|
7210
8279
|
undefined,
|
|
7211
8280
|
description: values.description?.trim() || undefined,
|
|
7212
8281
|
recordingKind,
|
|
8282
|
+
expectedResult,
|
|
7213
8283
|
notes: noteFlags.map(parseNoteFlag),
|
|
7214
8284
|
viewports: values.viewports ? parseViewports(String(values.viewports)) : null,
|
|
7215
8285
|
width: num(values.width, 1280),
|
|
@@ -7228,7 +8298,17 @@ async function main() {
|
|
|
7228
8298
|
// cmdSessionStart opts. `positionalUrl` is rest[1] for `start` (session
|
|
7229
8299
|
// start <url>) — `run` has no positional url, only --url.
|
|
7230
8300
|
const buildStartOpts = (positionalUrl) => {
|
|
7231
|
-
const
|
|
8301
|
+
const localMac = Boolean(values.local) && isLocalMacSource(values.source);
|
|
8302
|
+
if (localMac && !bridgeApplicable("local"))
|
|
8303
|
+
die(LOCAL_MAC_PLATFORM, 2);
|
|
8304
|
+
if (localMac && (values.out || values.force))
|
|
8305
|
+
die(LOCAL_MAC_OUT, 2);
|
|
8306
|
+
if (values.local && values.source === "screen" && process.platform === "win32") {
|
|
8307
|
+
die("clipy session --local cannot record the Windows screen yet; use clipy record --local (Enter or Ctrl-C to stop), --url, or --source chrome-for-clipy", 2);
|
|
8308
|
+
}
|
|
8309
|
+
if (values.local && values.source === "chrome-extension")
|
|
8310
|
+
die(LOCAL_EXTENSION_REFUSAL, 2);
|
|
8311
|
+
const source = localMac ? "mac-screen" : normalizeScreenSource(String(values.source ?? "web"));
|
|
7232
8312
|
if (source !== "web" && !isScreenSource(source) && source !== "chrome-for-clipy" && source !== "chrome-extension") {
|
|
7233
8313
|
die("--source must be web (headless browser), screen (the real screen: the Clipy Mac app on macOS, the CLI's own recorder on Linux), chrome-for-clipy (the persistent automation browser), or chrome-extension (the Clipy extension inside Chrome for Clipy)", 2);
|
|
7234
8314
|
}
|
|
@@ -7267,6 +8347,7 @@ async function main() {
|
|
|
7267
8347
|
undefined,
|
|
7268
8348
|
description: values.description?.trim() || undefined,
|
|
7269
8349
|
recordingKind: values.type ? requireRecordingKind(String(values.type)) : undefined,
|
|
8350
|
+
expectedResult,
|
|
7270
8351
|
maxSec: num(values.max, SESSION_DEFAULT_MAX_SEC),
|
|
7271
8352
|
width: num(values.width, 1280),
|
|
7272
8353
|
height: num(values.height, 720),
|
|
@@ -7280,6 +8361,7 @@ async function main() {
|
|
|
7280
8361
|
profileDirectory: profileDirectory(),
|
|
7281
8362
|
audio: audioChoice(),
|
|
7282
8363
|
tabAudio: Boolean(values["tab-audio"]),
|
|
8364
|
+
...(values.local ? { local: { out: values.out?.trim() || undefined, force: Boolean(values.force) } } : {}),
|
|
7283
8365
|
};
|
|
7284
8366
|
};
|
|
7285
8367
|
if (sub === "start") {
|
|
@@ -7292,7 +8374,7 @@ async function main() {
|
|
|
7292
8374
|
return;
|
|
7293
8375
|
}
|
|
7294
8376
|
if (sub === "stop") {
|
|
7295
|
-
await cmdSessionStop(json);
|
|
8377
|
+
await cmdSessionStop(json, Boolean(values.local));
|
|
7296
8378
|
return;
|
|
7297
8379
|
}
|
|
7298
8380
|
if (sub === "abort") {
|
|
@@ -7300,7 +8382,7 @@ async function main() {
|
|
|
7300
8382
|
return;
|
|
7301
8383
|
}
|
|
7302
8384
|
if (sub === "status" || sub === undefined) {
|
|
7303
|
-
await cmdSessionStatus(json);
|
|
8385
|
+
await cmdSessionStatus(json, Boolean(values.local));
|
|
7304
8386
|
return;
|
|
7305
8387
|
}
|
|
7306
8388
|
die("usage: clipy session <start|run|stop|abort|status>", 2);
|