runwork 0.12.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/claude-code.d.ts +21 -0
- package/dist/agents/claude-code.js +58 -2
- package/dist/agents/claude-desktop-plugin-tree.d.ts +15 -0
- package/dist/agents/claude-desktop-plugin-tree.js +37 -1
- package/dist/agents/conversation-skills.d.ts +18 -0
- package/dist/agents/conversation-skills.js +229 -0
- package/dist/agents/registry-data.d.ts +35 -0
- package/dist/agents/registry-data.js +58 -1
- package/dist/agents/runtime-detection.d.ts +82 -0
- package/dist/agents/runtime-detection.js +271 -0
- package/dist/agents/session-start-hook.d.ts +37 -0
- package/dist/agents/session-start-hook.js +159 -0
- package/dist/agents/types.d.ts +12 -0
- package/dist/api/client.d.ts +47 -0
- package/dist/api/client.js +32 -0
- package/dist/commands/doctor.js +89 -2
- package/dist/commands/inbox.d.ts +11 -0
- package/dist/commands/inbox.js +60 -0
- package/dist/commands/resume.d.ts +2 -0
- package/dist/commands/resume.js +289 -0
- package/dist/commands/save-convo.d.ts +8 -0
- package/dist/commands/save-convo.js +20 -0
- package/dist/commands/share-convo.d.ts +24 -0
- package/dist/commands/share-convo.js +167 -0
- package/dist/commands/sync.js +95 -10
- package/dist/generated/bundled-types.js +33 -33
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/dist/commands/doctor.js
CHANGED
|
@@ -2,6 +2,88 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { shouldOutputJson, jsonOut } from '../utils/output.js';
|
|
3
3
|
import { bold, dim, green, yellow, cyan } from '../ui/colors.js';
|
|
4
4
|
import { runAllChecks } from '../health/runner.js';
|
|
5
|
+
import { detectCurrentAgent } from '../agents/runtime-detection.js';
|
|
6
|
+
/**
|
|
7
|
+
* Env vars worth surfacing in --verbose for AI agents debugging their own
|
|
8
|
+
* environment. Filtered to known-safe runtime signals; never includes
|
|
9
|
+
* credentials, tokens, or anything matching common secret patterns.
|
|
10
|
+
*/
|
|
11
|
+
const VERBOSE_ENV_ALLOWLIST = [
|
|
12
|
+
// Claude Code
|
|
13
|
+
'CLAUDECODE',
|
|
14
|
+
'CLAUDE_CODE_ENTRYPOINT',
|
|
15
|
+
'CLAUDE_CODE_SESSION_ID',
|
|
16
|
+
'CLAUDE_CODE_EXECPATH',
|
|
17
|
+
'CLAUDE_EFFORT',
|
|
18
|
+
// Codex
|
|
19
|
+
'CODEX_CI',
|
|
20
|
+
'CODEX_THREAD_ID',
|
|
21
|
+
'CODEX_SANDBOX',
|
|
22
|
+
'CODEX_SANDBOX_NETWORK_DISABLED',
|
|
23
|
+
// Generic shell context
|
|
24
|
+
'PWD',
|
|
25
|
+
'SHELL',
|
|
26
|
+
'TERM',
|
|
27
|
+
'LANG',
|
|
28
|
+
// CI markers
|
|
29
|
+
'CI',
|
|
30
|
+
'GITHUB_ACTIONS',
|
|
31
|
+
];
|
|
32
|
+
function collectVerboseInfo() {
|
|
33
|
+
const env = {};
|
|
34
|
+
for (const key of VERBOSE_ENV_ALLOWLIST) {
|
|
35
|
+
if (process.env[key] !== undefined) {
|
|
36
|
+
env[key] = process.env[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const detected = detectCurrentAgent();
|
|
40
|
+
return {
|
|
41
|
+
hostAgent: detected ?? null,
|
|
42
|
+
env,
|
|
43
|
+
runtime: {
|
|
44
|
+
platform: process.platform,
|
|
45
|
+
arch: process.arch,
|
|
46
|
+
nodeVersion: process.version,
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
pid: process.pid,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function printVerboseBlock(info) {
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log(bold('Verbose runtime info'));
|
|
55
|
+
console.log('');
|
|
56
|
+
const detected = info.hostAgent;
|
|
57
|
+
if (detected) {
|
|
58
|
+
console.log(` ${green('[detected]')} Host agent: ${detected.slug}`);
|
|
59
|
+
if (detected.sessionId)
|
|
60
|
+
console.log(` sessionId: ${detected.sessionId}`);
|
|
61
|
+
if (detected.sessionFilePath)
|
|
62
|
+
console.log(` sessionFilePath: ${detected.sessionFilePath}`);
|
|
63
|
+
console.log(` source: ${detected.source}`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.log(` ${dim('[none]')} No host agent detected (not running inside a known AI agent)`);
|
|
67
|
+
}
|
|
68
|
+
console.log('');
|
|
69
|
+
console.log(bold('Env vars (allowlisted)'));
|
|
70
|
+
const envEntries = Object.entries(info.env);
|
|
71
|
+
if (envEntries.length === 0) {
|
|
72
|
+
console.log(` ${dim('(none set)')}`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
for (const [k, v] of envEntries) {
|
|
76
|
+
console.log(` ${k.padEnd(38)} ${v}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log(bold('Runtime'));
|
|
81
|
+
const r = info.runtime;
|
|
82
|
+
for (const [k, v] of Object.entries(r)) {
|
|
83
|
+
console.log(` ${k.padEnd(38)} ${v}`);
|
|
84
|
+
}
|
|
85
|
+
console.log('');
|
|
86
|
+
}
|
|
5
87
|
const STATUS_LABELS = {
|
|
6
88
|
pass: green('[pass]'),
|
|
7
89
|
warn: yellow('[warn]'),
|
|
@@ -67,14 +149,19 @@ function printHumanReport(report) {
|
|
|
67
149
|
}
|
|
68
150
|
export const doctorCommand = new Command('doctor')
|
|
69
151
|
.description('Check system health: auth, network, project config, agent setup')
|
|
70
|
-
.
|
|
152
|
+
.option('-v, --verbose', 'Include host-agent detection results, runtime info, and allowlisted env vars (useful for AI agents debugging their own environment)')
|
|
153
|
+
.action(async (opts, command) => {
|
|
71
154
|
const asJson = shouldOutputJson(command.optsWithGlobals().json);
|
|
72
155
|
const report = await runAllChecks();
|
|
156
|
+
const verboseInfo = opts.verbose ? collectVerboseInfo() : null;
|
|
73
157
|
if (asJson) {
|
|
74
|
-
jsonOut(report);
|
|
158
|
+
jsonOut(verboseInfo ? { ...report, verbose: verboseInfo } : report);
|
|
75
159
|
}
|
|
76
160
|
else {
|
|
77
161
|
printHumanReport(report);
|
|
162
|
+
if (verboseInfo) {
|
|
163
|
+
printVerboseBlock(verboseInfo);
|
|
164
|
+
}
|
|
78
165
|
}
|
|
79
166
|
if (report.checks.some(c => c.status === 'fail')) {
|
|
80
167
|
process.exit(1);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `runwork inbox` - list shared conversations visible to the current user.
|
|
4
|
+
*
|
|
5
|
+
* Scopes:
|
|
6
|
+
* --filter received shares others sent to me
|
|
7
|
+
* --filter sent shares I sent to others
|
|
8
|
+
* --filter saved my personal checkpoints (save-convo)
|
|
9
|
+
* --filter all all of the above (default)
|
|
10
|
+
*/
|
|
11
|
+
export declare const inboxCommand: Command;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { requireAuth } from '../auth/store.js';
|
|
3
|
+
import { ApiClient } from '../api/client.js';
|
|
4
|
+
import { resolveWorkspace } from '../workspace/resolve.js';
|
|
5
|
+
import { shouldOutputJson, jsonOut } from '../utils/output.js';
|
|
6
|
+
/**
|
|
7
|
+
* `runwork inbox` - list shared conversations visible to the current user.
|
|
8
|
+
*
|
|
9
|
+
* Scopes:
|
|
10
|
+
* --filter received shares others sent to me
|
|
11
|
+
* --filter sent shares I sent to others
|
|
12
|
+
* --filter saved my personal checkpoints (save-convo)
|
|
13
|
+
* --filter all all of the above (default)
|
|
14
|
+
*/
|
|
15
|
+
export const inboxCommand = new Command('inbox')
|
|
16
|
+
.description('List shared conversations visible to you')
|
|
17
|
+
.option('--filter <scope>', 'Filter: all | received | sent | saved', 'all')
|
|
18
|
+
.option('--limit <n>', 'Max rows to return', '50')
|
|
19
|
+
.option('--workspace <id>', 'Workspace ID')
|
|
20
|
+
.action(async (opts, command) => {
|
|
21
|
+
const useJson = shouldOutputJson(command.optsWithGlobals().json);
|
|
22
|
+
const scope = opts.filter === 'received' || opts.filter === 'sent' || opts.filter === 'saved'
|
|
23
|
+
? opts.filter
|
|
24
|
+
: 'all';
|
|
25
|
+
const limit = opts.limit ? parseInt(opts.limit, 10) : 50;
|
|
26
|
+
const credentials = requireAuth();
|
|
27
|
+
const client = new ApiClient(credentials);
|
|
28
|
+
const { workspaceId } = await resolveWorkspace(client, { workspace: opts.workspace });
|
|
29
|
+
try {
|
|
30
|
+
const { shares, total } = await client.listSharedConversations(workspaceId, { scope, limit });
|
|
31
|
+
if (useJson) {
|
|
32
|
+
jsonOut({ shares, total });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (shares.length === 0) {
|
|
36
|
+
console.log(`No shared conversations (scope: ${scope}).`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(`\nShared conversations (${scope}, ${total}):\n`);
|
|
40
|
+
console.log(` ${'ID'.padEnd(20)} ${'Title'.padEnd(40)} ${'Agent'.padEnd(14)} Status`);
|
|
41
|
+
console.log(' ' + '-'.repeat(96));
|
|
42
|
+
for (const raw of shares) {
|
|
43
|
+
const share = raw;
|
|
44
|
+
const id = share.id.slice(0, 18);
|
|
45
|
+
const title = (share.title || '').slice(0, 38);
|
|
46
|
+
const agent = (share.sourceAgent || 'unknown').slice(0, 12);
|
|
47
|
+
const status = share.deletedAt
|
|
48
|
+
? 'deleted'
|
|
49
|
+
: share.isPersonal
|
|
50
|
+
? 'saved'
|
|
51
|
+
: ((share.recipients ?? []).every(r => r.status === 'resumed') ? 'resumed' : 'pending');
|
|
52
|
+
console.log(` ${id.padEnd(20)} ${title.padEnd(40)} ${agent.padEnd(14)} ${status}`);
|
|
53
|
+
}
|
|
54
|
+
console.log('');
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(`Failed to list inbox: ${err instanceof Error ? err.message : err}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { writeFileSync, mkdirSync, realpathSync } from 'fs';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { spawn } from 'child_process';
|
|
6
|
+
import { requireAuth } from '../auth/store.js';
|
|
7
|
+
import { ApiClient } from '../api/client.js';
|
|
8
|
+
import { resolveWorkspace } from '../workspace/resolve.js';
|
|
9
|
+
import { shouldOutputJson, jsonOut } from '../utils/output.js';
|
|
10
|
+
import { getAgent } from '../agents/registry-data.js';
|
|
11
|
+
import { detectCurrentAgent } from '../agents/runtime-detection.js';
|
|
12
|
+
import { whichBinary } from '../utils/which.js';
|
|
13
|
+
/**
|
|
14
|
+
* Mirror of Claude Code's cwd encoding rule: replace every non-alphanumeric
|
|
15
|
+
* character with '-'. The canonical (realpath-resolved) cwd is encoded so
|
|
16
|
+
* /tmp/foo on macOS encodes the same as /private/tmp/foo (which is how
|
|
17
|
+
* Claude Code itself resolves the cwd).
|
|
18
|
+
*/
|
|
19
|
+
function encodeClaudeCodeCwd(cwd) {
|
|
20
|
+
let canonical;
|
|
21
|
+
try {
|
|
22
|
+
canonical = realpathSync(cwd);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
canonical = cwd;
|
|
26
|
+
}
|
|
27
|
+
return canonical.replace(/[^a-zA-Z0-9]/g, '-');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extract the original Claude Code session UUID from the first event of a
|
|
31
|
+
* JSONL bundle. Claude Code's `--resume <uuid>` expects this UUID; the
|
|
32
|
+
* filename on disk must match `<uuid>.jsonl`.
|
|
33
|
+
*/
|
|
34
|
+
function extractClaudeCodeUuid(jsonlContent) {
|
|
35
|
+
const firstLine = jsonlContent.split('\n').find(l => l.trim().length > 0);
|
|
36
|
+
if (!firstLine)
|
|
37
|
+
return null;
|
|
38
|
+
try {
|
|
39
|
+
const event = JSON.parse(firstLine);
|
|
40
|
+
return event.sessionId ?? null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extract the original Codex thread UUID from the first event of a rollout
|
|
48
|
+
* file. `codex resume <UUID>` accepts this id; the file's filename embeds it.
|
|
49
|
+
*/
|
|
50
|
+
function extractCodexUuid(rolloutContent) {
|
|
51
|
+
const firstLine = rolloutContent.split('\n').find(l => l.trim().length > 0);
|
|
52
|
+
if (!firstLine)
|
|
53
|
+
return null;
|
|
54
|
+
try {
|
|
55
|
+
const event = JSON.parse(firstLine);
|
|
56
|
+
return event.payload?.id ?? null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function placeClaudeJsonl(uuid, content, recipientCwd) {
|
|
63
|
+
const encoded = encodeClaudeCodeCwd(recipientCwd);
|
|
64
|
+
const projectDir = join(homedir(), '.claude', 'projects', encoded);
|
|
65
|
+
mkdirSync(projectDir, { recursive: true });
|
|
66
|
+
const placedAt = join(projectDir, `${uuid}.jsonl`);
|
|
67
|
+
writeFileSync(placedAt, content);
|
|
68
|
+
return { placedAt, runFromCwd: recipientCwd };
|
|
69
|
+
}
|
|
70
|
+
function placeCodexRollout(uuid, content) {
|
|
71
|
+
const now = new Date();
|
|
72
|
+
const yyyy = String(now.getUTCFullYear());
|
|
73
|
+
const mm = String(now.getUTCMonth() + 1).padStart(2, '0');
|
|
74
|
+
const dd = String(now.getUTCDate()).padStart(2, '0');
|
|
75
|
+
const dir = join(homedir(), '.codex', 'sessions', yyyy, mm, dd);
|
|
76
|
+
mkdirSync(dir, { recursive: true });
|
|
77
|
+
// Filename pattern Codex itself uses: rollout-YYYY-MM-DDThh-mm-ss-<uuid>.jsonl
|
|
78
|
+
const ts = now.toISOString().replace(/\.\d+Z$/, '').replace(/:/g, '-');
|
|
79
|
+
const placedAt = join(dir, `rollout-${ts}-${uuid}.jsonl`);
|
|
80
|
+
writeFileSync(placedAt, content);
|
|
81
|
+
return { placedAt };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Pick the target agent based on flag overrides, the share's sourceAgent,
|
|
85
|
+
* and what's installed locally.
|
|
86
|
+
*/
|
|
87
|
+
function pickTargetAgent(opts, sourceAgent) {
|
|
88
|
+
if (opts.agent) {
|
|
89
|
+
return getAgent(opts.agent) ?? null;
|
|
90
|
+
}
|
|
91
|
+
// Prefer the same agent the sender used, if installed
|
|
92
|
+
const source = getAgent(sourceAgent);
|
|
93
|
+
if (source && isAgentInstalled(source)) {
|
|
94
|
+
return source;
|
|
95
|
+
}
|
|
96
|
+
// Fall back to the sender's agent registry entry even if not detectably installed
|
|
97
|
+
// (the user may have it; better to print accurate instructions than abort)
|
|
98
|
+
return source ?? null;
|
|
99
|
+
}
|
|
100
|
+
function isAgentInstalled(agent) {
|
|
101
|
+
// Lightweight check: just look for the launch binary on PATH.
|
|
102
|
+
// More comprehensive detection lives in agents/detection.ts but requires
|
|
103
|
+
// async resolution; this synchronous check is good enough for resume.
|
|
104
|
+
if (agent.launch?.cli) {
|
|
105
|
+
return !!whichBinary(agent.launch.cli);
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
export const resumeCommand = new Command('resume')
|
|
110
|
+
.description('Resume a shared conversation locally in your agent of choice')
|
|
111
|
+
.argument('<share-id>', 'The share ID (sc_*) returned by share-convo or save-convo')
|
|
112
|
+
.option('--agent <slug>', 'Override target agent (e.g. claude-code, codex)')
|
|
113
|
+
.option('--into <path>', 'Override target cwd (defaults to current $PWD)')
|
|
114
|
+
.option('--dry-run', 'Print the resume command instead of executing it')
|
|
115
|
+
.option('--pick', 'Show interactive picker (requires TTY) - not yet implemented')
|
|
116
|
+
.option('--workspace <id>', 'Workspace ID')
|
|
117
|
+
.action(async (shareId, opts, command) => {
|
|
118
|
+
const useJson = shouldOutputJson(command.optsWithGlobals().json);
|
|
119
|
+
const credentials = requireAuth();
|
|
120
|
+
const client = new ApiClient(credentials);
|
|
121
|
+
const { workspaceId } = await resolveWorkspace(client, { workspace: opts.workspace });
|
|
122
|
+
let share;
|
|
123
|
+
try {
|
|
124
|
+
const { share: raw } = await client.getSharedConversation(workspaceId, shareId);
|
|
125
|
+
share = raw;
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
console.error(`Failed to fetch share ${shareId}: ${err instanceof Error ? err.message : err}`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
// If --agent not provided, detect what the user is currently in - that's
|
|
132
|
+
// often the best default ("share to me, resume in same agent")
|
|
133
|
+
if (!opts.agent) {
|
|
134
|
+
const detected = detectCurrentAgent();
|
|
135
|
+
if (detected) {
|
|
136
|
+
opts.agent = detected.slug;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const target = pickTargetAgent(opts, share.sourceAgent);
|
|
140
|
+
if (!target) {
|
|
141
|
+
console.error(`No target agent could be determined. Pass --agent <slug> or install the source agent (${share.sourceAgent}).`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
const cap = target.resumeCapability;
|
|
145
|
+
// Tier 3 fallback: no native resume - print a paste-prompt
|
|
146
|
+
if (!cap || cap.mode === 'unsupported' || !cap.nativeBundleFormat) {
|
|
147
|
+
const promptText = buildPastePrompt(shareId, share.title);
|
|
148
|
+
if (useJson) {
|
|
149
|
+
jsonOut({ mode: 'paste-prompt', shareId, prompt: promptText });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
console.log(`\n${target.name} does not support native resume. Paste this prompt into your agent:\n`);
|
|
153
|
+
console.log('---');
|
|
154
|
+
console.log(promptText);
|
|
155
|
+
console.log('---\n');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Need a matching native bundle on the share
|
|
159
|
+
const hasNative = (share.bundles ?? []).some(b => b.format === cap.nativeBundleFormat);
|
|
160
|
+
if (!hasNative) {
|
|
161
|
+
console.error(`This share has no ${cap.nativeBundleFormat} bundle (sourceAgent was ${share.sourceAgent}). ` +
|
|
162
|
+
`Falling back to paste-prompt.`);
|
|
163
|
+
const promptText = buildPastePrompt(shareId, share.title);
|
|
164
|
+
console.log('\n---');
|
|
165
|
+
console.log(promptText);
|
|
166
|
+
console.log('---\n');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// Download the native bundle content
|
|
170
|
+
const bundle = await client.downloadSharedConversationBundle(workspaceId, shareId, cap.nativeBundleFormat);
|
|
171
|
+
// Extract the ORIGINAL session UUID from the bundle content - that's
|
|
172
|
+
// what the native resume command expects, not our share ID.
|
|
173
|
+
let nativeUuid;
|
|
174
|
+
if (cap.nativeBundleFormat === 'claude-jsonl') {
|
|
175
|
+
nativeUuid = extractClaudeCodeUuid(bundle.content);
|
|
176
|
+
}
|
|
177
|
+
else if (cap.nativeBundleFormat === 'codex-rollout') {
|
|
178
|
+
nativeUuid = extractCodexUuid(bundle.content);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
console.error(`No UUID extraction strategy for native bundle format ${cap.nativeBundleFormat}`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
if (!nativeUuid) {
|
|
185
|
+
console.error(`Could not extract native session UUID from ${cap.nativeBundleFormat} bundle. ` +
|
|
186
|
+
`The bundle may be malformed.`);
|
|
187
|
+
process.exit(1);
|
|
188
|
+
}
|
|
189
|
+
// Place the file per-agent using the original UUID
|
|
190
|
+
let placement;
|
|
191
|
+
const recipientCwd = opts.into ?? process.cwd();
|
|
192
|
+
if (cap.nativeBundleFormat === 'claude-jsonl') {
|
|
193
|
+
placement = placeClaudeJsonl(nativeUuid, bundle.content, recipientCwd);
|
|
194
|
+
}
|
|
195
|
+
else if (cap.nativeBundleFormat === 'codex-rollout') {
|
|
196
|
+
placement = placeCodexRollout(nativeUuid, bundle.content);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
console.error(`No placement strategy for native bundle format ${cap.nativeBundleFormat}`);
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
// Tell the server we resumed it (best-effort)
|
|
203
|
+
client.markSharedConversationResumed(workspaceId, shareId).catch(() => {
|
|
204
|
+
// Non-fatal; the user is already up and resuming
|
|
205
|
+
});
|
|
206
|
+
if (cap.mode === 'file-drop-only') {
|
|
207
|
+
const result = {
|
|
208
|
+
mode: 'file-drop-only',
|
|
209
|
+
agent: target.slug,
|
|
210
|
+
placedAt: placement.placedAt,
|
|
211
|
+
hint: cap.manualOpenHint ?? `Open ${target.name} to find this session in your history.`,
|
|
212
|
+
};
|
|
213
|
+
if (useJson) {
|
|
214
|
+
jsonOut(result);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
console.log(`\nBundle placed at: ${placement.placedAt}`);
|
|
218
|
+
console.log(`${result.hint}\n`);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (cap.mode === 'cli-resume') {
|
|
222
|
+
// Substitute {uuid} in the resume command template with the original
|
|
223
|
+
// session UUID we extracted from the bundle content.
|
|
224
|
+
const cmd = (cap.cliResumeCommand ?? '').replace(/\{uuid\}/g, nativeUuid);
|
|
225
|
+
// If we're running inside the SAME agent we'd resume into (very common
|
|
226
|
+
// when an LLM in claude-code invokes `runwork resume` to pick up a
|
|
227
|
+
// saved claude-code conversation), exec'ing `claude --resume <uuid>`
|
|
228
|
+
// from inside that session is broken: the child claude process can't
|
|
229
|
+
// attach to the parent's TTY and the resume hits agent-specific edge
|
|
230
|
+
// cases ("No deferred tool marker found in the resumed session..."
|
|
231
|
+
// for Claude Code). Detect this and degrade to print-the-command mode
|
|
232
|
+
// so the user can copy/paste into a fresh terminal -- AND tell the
|
|
233
|
+
// caller agent that the in-session continuation path is via the
|
|
234
|
+
// `get_shared_conversation` MCP tool, which inlines the transcript.
|
|
235
|
+
const detected = detectCurrentAgent();
|
|
236
|
+
const insideSameAgent = detected && detected.slug === target.slug;
|
|
237
|
+
const shouldPrintOnly = opts.dryRun || insideSameAgent;
|
|
238
|
+
if (shouldPrintOnly) {
|
|
239
|
+
const fullCmd = placement.runFromCwd
|
|
240
|
+
? `cd "${placement.runFromCwd}" && ${cmd}`
|
|
241
|
+
: cmd;
|
|
242
|
+
const result = {
|
|
243
|
+
mode: 'cli-resume',
|
|
244
|
+
agent: target.slug,
|
|
245
|
+
placedAt: placement.placedAt,
|
|
246
|
+
command: fullCmd,
|
|
247
|
+
insideSameAgent: !!insideSameAgent,
|
|
248
|
+
};
|
|
249
|
+
if (useJson) {
|
|
250
|
+
jsonOut(result);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
console.log(`\nBundle placed at: ${placement.placedAt}`);
|
|
254
|
+
if (insideSameAgent) {
|
|
255
|
+
console.log(`\nYou are already inside ${target.name}, so I can't auto-launch a new session in this terminal.`);
|
|
256
|
+
console.log(`To resume natively, exit this session and run in a fresh terminal:`);
|
|
257
|
+
console.log(` ${fullCmd}`);
|
|
258
|
+
console.log(`\nOr ask the assistant to continue the conversation in THIS session by ` +
|
|
259
|
+
`fetching the transcript via the Runwork MCP \`get_shared_conversation\` tool ` +
|
|
260
|
+
`(share ID: ${shareId}).`);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
console.log(`Run: ${fullCmd}\n`);
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
// Exec the resume command (fresh-shell case)
|
|
268
|
+
const parts = cmd.split(' ');
|
|
269
|
+
const child = spawn(parts[0], parts.slice(1), {
|
|
270
|
+
cwd: placement.runFromCwd ?? recipientCwd,
|
|
271
|
+
stdio: 'inherit',
|
|
272
|
+
});
|
|
273
|
+
child.on('exit', (code) => {
|
|
274
|
+
process.exit(code ?? 0);
|
|
275
|
+
});
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
console.error(`Unexpected resumeCapability.mode: ${cap.mode}`);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
});
|
|
281
|
+
function buildPastePrompt(shareId, title) {
|
|
282
|
+
return `Continue the conversation that a teammate shared with me. The share ID is ${shareId} (title: "${title}").
|
|
283
|
+
|
|
284
|
+
PREFERRED: if the \`runwork\` CLI is installed locally, run:
|
|
285
|
+
runwork resume ${shareId}
|
|
286
|
+
That auto-detects your active agent and resumes natively if possible.
|
|
287
|
+
|
|
288
|
+
FALLBACK: use the Runwork MCP tool \`get_shared_conversation\` with this share ID to fetch the full transcript, then continue from where the conversation left off.`;
|
|
289
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `runwork save-convo` - personal checkpoint of the current AI conversation.
|
|
4
|
+
*
|
|
5
|
+
* Thin alias over `share-convo` with isPersonal=true. The recipient is always
|
|
6
|
+
* the sender; no notifications are sent. Same capture mechanics otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare const saveConvoCommand: Command;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { runShareConvo } from './share-convo.js';
|
|
3
|
+
/**
|
|
4
|
+
* `runwork save-convo` - personal checkpoint of the current AI conversation.
|
|
5
|
+
*
|
|
6
|
+
* Thin alias over `share-convo` with isPersonal=true. The recipient is always
|
|
7
|
+
* the sender; no notifications are sent. Same capture mechanics otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const saveConvoCommand = new Command('save-convo')
|
|
10
|
+
.description('Save the current AI conversation as a personal checkpoint')
|
|
11
|
+
.option('--transcript-file <path>', 'Path to the LLM-emitted markdown transcript (required)')
|
|
12
|
+
.option('--native-file <path>', 'Path to the native session file (optional; auto-detected from env vars)')
|
|
13
|
+
.option('--source-agent <slug>', 'Override host-agent detection')
|
|
14
|
+
.option('--title <string>', 'Short title for the conversation (required)')
|
|
15
|
+
.option('--note <string>', 'Optional note to your future self')
|
|
16
|
+
.option('--ttl-days <n>', 'Days until expiration (1-30, default 7)')
|
|
17
|
+
.option('--metadata-json <json>', 'Inline JSON object with workMode, openQuestions, etc.')
|
|
18
|
+
.option('--metadata-file <path>', 'Path to a JSON file with metadata fields')
|
|
19
|
+
.option('--workspace <id>', 'Workspace ID')
|
|
20
|
+
.action((opts, command) => runShareConvo({ ...opts, personal: true }, command, true));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `runwork share-convo` - share the current AI conversation with a teammate.
|
|
4
|
+
*
|
|
5
|
+
* Typically invoked by the `share-conversation` skill from inside an AI agent.
|
|
6
|
+
* The skill is responsible for emitting the markdown transcript and metadata;
|
|
7
|
+
* this command does the upload, host-agent detection, and native-bundle pickup.
|
|
8
|
+
*/
|
|
9
|
+
interface ShareConvoOptions {
|
|
10
|
+
to?: string[];
|
|
11
|
+
transcriptFile?: string;
|
|
12
|
+
nativeFile?: string;
|
|
13
|
+
sourceAgent?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
note?: string;
|
|
16
|
+
personal?: boolean;
|
|
17
|
+
ttlDays?: string;
|
|
18
|
+
metadataJson?: string;
|
|
19
|
+
metadataFile?: string;
|
|
20
|
+
workspace?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function runShareConvo(opts: ShareConvoOptions, command: Command, isPersonalAlias?: boolean): Promise<void>;
|
|
23
|
+
export declare const shareConvoCommand: Command;
|
|
24
|
+
export {};
|