@skrr-ai/cli 0.1.207 → 0.1.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/commands/agent/message/no-reply.js +1 -1
  2. package/dist/commands/agent/message/react.d.ts +23 -0
  3. package/dist/commands/agent/message/react.js +125 -0
  4. package/dist/commands/agent/message/resolve.d.ts +31 -0
  5. package/dist/commands/agent/message/resolve.js +111 -0
  6. package/dist/commands/agent/message/retract.js +1 -1
  7. package/dist/commands/agent/message/send.d.ts +25 -6
  8. package/dist/commands/agent/message/send.js +135 -30
  9. package/dist/commands/agent/request/list.d.ts +15 -0
  10. package/dist/commands/agent/request/list.js +82 -0
  11. package/dist/commands/agent/request/send.d.ts +18 -0
  12. package/dist/commands/agent/request/send.js +56 -0
  13. package/dist/commands/agents/access/approve.d.ts +17 -0
  14. package/dist/commands/agents/access/approve.js +94 -0
  15. package/dist/commands/agents/access/deny.d.ts +10 -0
  16. package/dist/commands/agents/access/deny.js +36 -0
  17. package/dist/commands/agents/access/list.d.ts +10 -0
  18. package/dist/commands/agents/access/list.js +55 -0
  19. package/dist/commands/agents/access/reach.d.ts +13 -0
  20. package/dist/commands/agents/access/reach.js +53 -0
  21. package/dist/commands/agents/access/revoke.d.ts +13 -0
  22. package/dist/commands/agents/access/revoke.js +50 -0
  23. package/dist/commands/agents/always-on/recovery-review.d.ts +5 -0
  24. package/dist/commands/agents/always-on/recovery-review.js +16 -0
  25. package/dist/commands/agents/chat.d.ts +8 -0
  26. package/dist/commands/agents/chat.js +369 -90
  27. package/dist/commands/agents/import.d.ts +15 -1
  28. package/dist/commands/agents/import.js +212 -24
  29. package/dist/commands/agents/intuitions/accept.d.ts +0 -1
  30. package/dist/commands/agents/intuitions/accept.js +22 -7
  31. package/dist/commands/agents/intuitions/generate.d.ts +0 -1
  32. package/dist/commands/agents/intuitions/generate.js +4 -16
  33. package/dist/commands/agents/intuitions/list.js +9 -3
  34. package/dist/commands/agents/intuitions/resume.d.ts +11 -0
  35. package/dist/commands/agents/intuitions/resume.js +37 -0
  36. package/dist/commands/agents/manager/status.js +7 -6
  37. package/dist/commands/agents/not-for-task.d.ts +24 -0
  38. package/dist/commands/agents/not-for-task.js +60 -0
  39. package/dist/commands/agents/schedule-overview.d.ts +20 -0
  40. package/dist/commands/agents/schedule-overview.js +35 -2
  41. package/dist/commands/agents/shared-memory.d.ts +24 -0
  42. package/dist/commands/agents/shared-memory.js +67 -0
  43. package/dist/commands/agents/stop.d.ts +23 -0
  44. package/dist/commands/agents/stop.js +61 -0
  45. package/dist/commands/agents/update.d.ts +7 -0
  46. package/dist/commands/agents/update.js +45 -2
  47. package/dist/commands/agents/visibility.d.ts +1 -0
  48. package/dist/commands/agents/visibility.js +14 -0
  49. package/dist/commands/code/migrate.js +3 -1
  50. package/dist/commands/convos/messages.js +5 -0
  51. package/dist/commands/convos/transcript.js +2 -2
  52. package/dist/commands/daemon/logs.d.ts +3 -1
  53. package/dist/commands/daemon/logs.js +6 -2
  54. package/dist/commands/duties/advance-next.js +16 -7
  55. package/dist/commands/duties/preflight.js +17 -13
  56. package/dist/commands/followups/show.js +9 -0
  57. package/dist/commands/followups/watch-pr.d.ts +27 -0
  58. package/dist/commands/followups/watch-pr.js +124 -0
  59. package/dist/commands/harnesses/evaluations/evidence.js +2 -2
  60. package/dist/commands/harnesses/evaluations/grant.js +1 -1
  61. package/dist/commands/harnesses/evaluations/revoke.js +1 -1
  62. package/dist/commands/harnesses/evaluations/show.js +1 -1
  63. package/dist/commands/harnesses/rollouts/grant.js +1 -1
  64. package/dist/commands/harnesses/rollouts/revoke.js +1 -1
  65. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
  66. package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
  67. package/dist/commands/memory/consolidation/index.d.ts +20 -0
  68. package/dist/commands/memory/consolidation/index.js +78 -0
  69. package/dist/commands/memory/consolidation/resume.d.ts +14 -0
  70. package/dist/commands/memory/consolidation/resume.js +46 -0
  71. package/dist/commands/memory/consolidation/undo.d.ts +18 -0
  72. package/dist/commands/memory/consolidation/undo.js +61 -0
  73. package/dist/commands/messages/list.js +9 -1
  74. package/dist/commands/slack/mutes.d.ts +10 -0
  75. package/dist/commands/slack/mutes.js +62 -0
  76. package/dist/commands/slack/unmute.d.ts +12 -0
  77. package/dist/commands/slack/unmute.js +44 -0
  78. package/dist/commands/tasks/actionability.js +10 -0
  79. package/dist/commands/tasks/ask.d.ts +50 -0
  80. package/dist/commands/tasks/ask.js +190 -0
  81. package/dist/commands/tasks/bulk-update.js +12 -0
  82. package/dist/commands/tasks/handover.js +14 -0
  83. package/dist/commands/tasks/input/answer.js +8 -2
  84. package/dist/commands/tasks/input/show.d.ts +26 -0
  85. package/dist/commands/tasks/input/show.js +185 -17
  86. package/dist/commands/tasks/list.d.ts +8 -0
  87. package/dist/commands/tasks/list.js +50 -9
  88. package/dist/commands/tasks/move.d.ts +3 -0
  89. package/dist/commands/tasks/move.js +71 -1
  90. package/dist/commands/tasks/result/show.js +19 -7
  91. package/dist/commands/tasks/result/submit.js +3 -0
  92. package/dist/commands/tasks/runs.d.ts +4 -1
  93. package/dist/commands/tasks/runs.js +22 -3
  94. package/dist/commands/tasks/show.d.ts +4 -3
  95. package/dist/commands/tasks/show.js +40 -7
  96. package/dist/commands/tasks/start.js +35 -16
  97. package/dist/commands/tasks/update.d.ts +1 -0
  98. package/dist/commands/tasks/update.js +55 -1
  99. package/dist/commands/tasks/updates/add.js +3 -0
  100. package/dist/commands/tasks/wait.d.ts +20 -0
  101. package/dist/commands/tasks/wait.js +103 -2
  102. package/dist/generated/agent-guides.json +892 -183
  103. package/dist/generated/managed-instruction-guides.json +1 -1
  104. package/dist/lib/agent-access-command.d.ts +19 -0
  105. package/dist/lib/agent-access-command.js +44 -0
  106. package/dist/lib/agent-access.d.ts +18 -0
  107. package/dist/lib/agent-access.js +48 -0
  108. package/dist/lib/agent-import/apply.d.ts +50 -0
  109. package/dist/lib/agent-import/apply.js +85 -0
  110. package/dist/lib/agent-import/plan.d.ts +132 -0
  111. package/dist/lib/agent-import/plan.js +504 -0
  112. package/dist/lib/agent-import/reader.d.ts +94 -0
  113. package/dist/lib/agent-import/reader.js +326 -0
  114. package/dist/lib/agent-import/schedule.d.ts +46 -0
  115. package/dist/lib/agent-import/schedule.js +220 -0
  116. package/dist/lib/agent-import/sources.d.ts +124 -0
  117. package/dist/lib/agent-import/sources.js +797 -0
  118. package/dist/lib/chat-stop.d.ts +17 -0
  119. package/dist/lib/chat-stop.js +70 -0
  120. package/dist/lib/cloud-reply.d.ts +21 -0
  121. package/dist/lib/cloud-reply.js +52 -0
  122. package/dist/lib/duties.js +24 -4
  123. package/dist/lib/duty-ledgers.js +19 -2
  124. package/dist/lib/file-mime.js +8 -0
  125. package/dist/lib/followups.d.ts +61 -0
  126. package/dist/lib/followups.js +39 -0
  127. package/dist/lib/handover-interview.d.ts +18 -0
  128. package/dist/lib/handover-interview.js +53 -0
  129. package/dist/lib/inbound-messages.d.ts +156 -0
  130. package/dist/lib/inbound-messages.js +375 -0
  131. package/dist/lib/input-queue.js +2 -1
  132. package/dist/lib/intuition-look.d.ts +10 -0
  133. package/dist/lib/intuition-look.js +64 -0
  134. package/dist/lib/message-intent.d.ts +18 -2
  135. package/dist/lib/message-intent.js +23 -1
  136. package/dist/lib/preflight-copy.d.ts +16 -1
  137. package/dist/lib/preflight-copy.js +33 -1
  138. package/dist/lib/record-output.d.ts +1 -1
  139. package/dist/lib/record-output.js +2 -0
  140. package/dist/lib/skill-import.d.ts +19 -0
  141. package/dist/lib/skill-import.js +34 -0
  142. package/dist/lib/slack-thread-mutes.d.ts +25 -0
  143. package/dist/lib/slack-thread-mutes.js +12 -0
  144. package/dist/lib/task-carriers.d.ts +18 -0
  145. package/dist/lib/task-carriers.js +43 -0
  146. package/dist/lib/task-extras.d.ts +5 -0
  147. package/dist/lib/task-extras.js +5 -0
  148. package/dist/lib/task-operations.d.ts +2 -0
  149. package/dist/lib/task-operations.js +28 -4
  150. package/dist/lib/task-preflight.js +1 -0
  151. package/dist/lib/task-recurrence-summary.d.ts +15 -0
  152. package/dist/lib/task-recurrence-summary.js +22 -0
  153. package/dist/lib/task-review-notice.d.ts +21 -0
  154. package/dist/lib/task-review-notice.js +46 -0
  155. package/dist/lib/task-version.d.ts +53 -0
  156. package/dist/lib/task-version.js +89 -0
  157. package/dist/lib/task-write-attribution.d.ts +7 -0
  158. package/dist/lib/task-write-attribution.js +14 -0
  159. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
  160. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
  161. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
  162. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
  163. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
  164. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
  165. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  166. package/dist/node_modules/@skrr-ai/data-provider/index.js +13492 -12505
  167. package/oclif.manifest.json +2090 -132
  168. package/package.json +9 -2
@@ -0,0 +1,797 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SKILL_FILES_MAX = exports.SKILL_FILE_DEPTH_MAX = exports.DAILY_NOTES_LIMIT = exports.AgentImportSourceError = exports.IMPORT_PERSONA_FILE_NAMES = exports.AGENT_IMPORT_APP_LABELS = exports.AGENT_IMPORT_APPS = void 0;
4
+ exports.nameFromId = nameFromId;
5
+ exports.markdownEntries = markdownEntries;
6
+ exports.detectImportApp = detectImportApp;
7
+ exports.looksLikeBotFolder = looksLikeBotFolder;
8
+ exports.readImportSource = readImportSource;
9
+ /**
10
+ * What an OpenClaw, Hermes or Orca bot folder holds, read into one shape.
11
+ *
12
+ * Each app keeps a bot on disk its own way. These readers know the layouts (taken from each app's
13
+ * documented layout as Orca's importer reads them, `skill-guides/orca-cli/references/bot-import.md`)
14
+ * and nothing else: they decide what each file IS — the bot's persona, a note it kept, a skill, a
15
+ * schedule — and what stays behind and why. Whether any of it is already on the Skrr agent, and
16
+ * what to write, is `plan.ts`'s job. Every byte is read through `SourceReader`.
17
+ *
18
+ * Deliberately NOT read, whatever the app: settings files (`openclaw.json`, Hermes `config.yaml`,
19
+ * Orca's app store), which hold channel tokens, model keys and MCP credentials; chat history; and
20
+ * anything an app ships itself. They are named in the plan as staying behind, never opened.
21
+ */
22
+ const data_provider_1 = require("@skrr-ai/data-provider");
23
+ const reader_1 = require("./reader");
24
+ const schedule_1 = require("./schedule");
25
+ exports.AGENT_IMPORT_APPS = ['openclaw', 'hermes', 'orca'];
26
+ exports.AGENT_IMPORT_APP_LABELS = Object.freeze({
27
+ openclaw: 'OpenClaw',
28
+ hermes: 'Hermes',
29
+ orca: 'Orca',
30
+ });
31
+ exports.IMPORT_PERSONA_FILE_NAMES = Object.freeze({
32
+ soul: 'SOUL.md',
33
+ identity: 'IDENTITY.md',
34
+ user: 'USER.md',
35
+ tools: 'TOOLS.md',
36
+ });
37
+ class AgentImportSourceError extends Error {
38
+ code;
39
+ constructor(code, message) {
40
+ super(message);
41
+ this.code = code;
42
+ }
43
+ }
44
+ exports.AgentImportSourceError = AgentImportSourceError;
45
+ const HEADING_RE = /^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
46
+ const BULLET_RE = /^\s{0,3}(?:[-*+]|\d+[.)])\s+(.*)$/;
47
+ const RULE_OR_TABLE_RE = /^\s*(?:[-*_=]{3,}|\|.*)\s*$/;
48
+ const COMMENT_ONLY_RE = /<!--[\s\S]*?-->/g;
49
+ const IDENTITY_NAME_RE = /^\s*[-*]?\s*\*{0,2}name\*{0,2}\s*:\s*\*{0,2}\s*(.+?)\s*$/im;
50
+ const PLACEHOLDER_RE = /^[_*([]/;
51
+ const ORCA_NON_FACT_RE = /^(?:#{1,6}(?:\s|$)|\||<!--|[\s*_=:-]+$)/;
52
+ const ORCA_SEED_RE = /^one line per fact\b/i;
53
+ const DAILY_NOTE_RE = /^\d{4}-\d{2}-\d{2}.*\.md$/i;
54
+ const MARKDOWN_RE = /\.(md|markdown|txt)$/i;
55
+ /** How many daily notes become proposals; older ones stay behind, said in the plan. */
56
+ exports.DAILY_NOTES_LIMIT = 30;
57
+ /** Enough for any bot's own schedules; a file with more is not a bot's. */
58
+ const JOBS_LIMIT = 200;
59
+ /** "research-desk" -> "Research desk". */
60
+ function nameFromId(id) {
61
+ const words = id.replace(/[_-]+/g, ' ').trim();
62
+ return words ? words[0].toUpperCase() + words.slice(1) : id;
63
+ }
64
+ function firstWords(text, max = 80) {
65
+ const flat = text.replace(/\s+/g, ' ').trim();
66
+ return flat.length <= max ? flat : `${flat.slice(0, max - 1).trimEnd()}…`;
67
+ }
68
+ function str(value) {
69
+ return typeof value === 'string' ? value.trim() : '';
70
+ }
71
+ /** Markdown with comments, headings and blank lines removed: what a person actually wrote. */
72
+ function substance(text) {
73
+ return text
74
+ .replace(COMMENT_ONLY_RE, '')
75
+ .split('\n')
76
+ .filter((line) => line.trim() && !HEADING_RE.test(line))
77
+ .join('\n')
78
+ .trim();
79
+ }
80
+ /**
81
+ * A Markdown notes file split into entries: each bullet (with its continuation lines) and each
82
+ * paragraph is one, titled by the heading it sits under. Rules, tables and comments are not notes.
83
+ */
84
+ function markdownEntries(lines) {
85
+ const entries = [];
86
+ let heading = '';
87
+ let current = null;
88
+ let inComment = false;
89
+ const flush = () => {
90
+ if (current) {
91
+ const textValue = current.parts.join('\n').trim();
92
+ if (textValue)
93
+ entries.push({ line: current.line, heading: current.heading, text: textValue });
94
+ }
95
+ current = null;
96
+ };
97
+ for (const { line, text } of lines) {
98
+ if (inComment) {
99
+ if (text.includes('-->'))
100
+ inComment = false;
101
+ continue;
102
+ }
103
+ if (text.trim().startsWith('<!--')) {
104
+ flush();
105
+ inComment = !text.includes('-->');
106
+ continue;
107
+ }
108
+ const headingMatch = HEADING_RE.exec(text);
109
+ if (headingMatch) {
110
+ flush();
111
+ heading = headingMatch[2];
112
+ continue;
113
+ }
114
+ if (!text.trim() || RULE_OR_TABLE_RE.test(text)) {
115
+ flush();
116
+ continue;
117
+ }
118
+ const bullet = BULLET_RE.exec(text);
119
+ if (bullet) {
120
+ flush();
121
+ current = { line, heading, parts: [bullet[1]] };
122
+ continue;
123
+ }
124
+ if (!current)
125
+ current = { line, heading, parts: [] };
126
+ current.parts.push(text.trim());
127
+ }
128
+ flush();
129
+ return entries;
130
+ }
131
+ function memoryPath(app, sourceAgent, ...rest) {
132
+ return ['', 'imported', app, sourceAgent, ...rest].join('/');
133
+ }
134
+ async function readPersona(reader, files) {
135
+ const out = [];
136
+ for (const [fileType, rel] of files) {
137
+ const text = await reader.readText(rel);
138
+ if (text === null)
139
+ continue;
140
+ if (!substance(text))
141
+ continue;
142
+ out.push({ fileType, from: reader.join(rel), content: text.trim() });
143
+ }
144
+ return out;
145
+ }
146
+ /** How deep in a skill folder its files are carried from: `references/api/v2/auth.md` is depth 3. */
147
+ exports.SKILL_FILE_DEPTH_MAX = 4;
148
+ /** How many files beside SKILL.md one imported skill carries. */
149
+ exports.SKILL_FILES_MAX = 64;
150
+ /** The heading the platform's own skill importers put the files under (`SkillImportService`). */
151
+ const SKILL_FILES_HEADING = '\n\n---\n\n## Supporting Files\n';
152
+ /** A fence no run of backticks in `text` can close. */
153
+ function fenceFor(text) {
154
+ let longest = 0;
155
+ for (const run of text.match(/`+/g) ?? [])
156
+ longest = Math.max(longest, run.length);
157
+ return '`'.repeat(Math.max(3, longest + 1));
158
+ }
159
+ /** One carried file as a section of the skill's content, in the platform's single-content form. */
160
+ function skillFileSection(path, text, leftOutLines) {
161
+ const fence = fenceFor(text);
162
+ const one = leftOutLines.length === 1;
163
+ const note = leftOutLines.length
164
+ ? `\n_${one ? 'Line' : 'Lines'} ${leftOutLines.join(', ')} ${one ? 'was' : 'were'} left out on import: ${one ? 'it' : 'they'} looked like a key or password._\n`
165
+ : '';
166
+ return `\n### ${path}\n${note}\n${fence}\n${text}\n${fence}\n`;
167
+ }
168
+ /**
169
+ * The files beside a SKILL.md (scripts, references, assets), read through the same reader as
170
+ * everything else, so they meet the same refusals: a key or login name, a link out of the folder,
171
+ * anything over the size limit, a database or any other file that is not plain text. Each kept file
172
+ * has its secret-looking lines left out, as SKILL.md has.
173
+ *
174
+ * Carried in the skill's content the way the platform's own importers carry them (`## Supporting
175
+ * Files`, one fenced section a file), so the skill arrives complete in one write. A file that does
176
+ * not travel is in the reader's record with its reason, by path, and the plan shows it: refused by
177
+ * the reader, past `SKILL_FILE_DEPTH_MAX` folders, past `SKILL_FILES_MAX` files, or past what one
178
+ * skill can hold (`SKILL_LIMITS.CONTENT_MAX_LENGTH`).
179
+ */
180
+ async function readSkillFiles(reader, skillDir, body) {
181
+ const files = [];
182
+ const sections = [];
183
+ let room = data_provider_1.SKILL_LIMITS.CONTENT_MAX_LENGTH - body.length - SKILL_FILES_HEADING.length;
184
+ let seen = 0;
185
+ const walk = async (rel, depth) => {
186
+ for (const entry of await reader.list(rel)) {
187
+ if (entry.kind === 'dir') {
188
+ if (depth + 1 > exports.SKILL_FILE_DEPTH_MAX)
189
+ reader.record(entry.rel, 'skill_too_deep');
190
+ else
191
+ await walk(entry.rel, depth + 1);
192
+ continue;
193
+ }
194
+ if (depth === 0 && entry.name === 'SKILL.md')
195
+ continue;
196
+ seen += 1;
197
+ if (seen > exports.SKILL_FILES_MAX) {
198
+ reader.record(entry.rel, 'skill_too_many_files');
199
+ continue;
200
+ }
201
+ const lines = await reader.readLines(entry.rel);
202
+ if (lines === null)
203
+ continue; // refused, and recorded by the reader
204
+ const from = reader.join(entry.rel);
205
+ const leftOutLines = reader.leftOut
206
+ .filter((left) => left.from === from && typeof left.line === 'number')
207
+ .map((left) => left.line);
208
+ const path = entry.rel.slice(skillDir.length + 1);
209
+ const section = skillFileSection(path, lines
210
+ .map((line) => line.text)
211
+ .join('\n')
212
+ .replace(/\n$/, ''), leftOutLines);
213
+ if (section.length > room) {
214
+ reader.record(entry.rel, 'skill_full');
215
+ continue;
216
+ }
217
+ room -= section.length;
218
+ sections.push(section);
219
+ files.push({ path, from, leftOutLines });
220
+ }
221
+ };
222
+ await walk(skillDir, 0);
223
+ return {
224
+ content: sections.length ? `${body}${SKILL_FILES_HEADING}${sections.join('')}` : body,
225
+ files,
226
+ };
227
+ }
228
+ /** Every `SKILL.md` folder under `skills/`, one level of categories deep (Hermes), skipping dot-folders. */
229
+ async function readSkills(reader, { categories = false, bundled = new Set(), } = {}) {
230
+ const skills = [];
231
+ const stays = [];
232
+ const bundledSkipped = [];
233
+ const visit = async (rel, depth) => {
234
+ for (const entry of await reader.list(rel)) {
235
+ if (entry.kind !== 'dir' || entry.name.startsWith('.'))
236
+ continue;
237
+ if (bundled.has(entry.name)) {
238
+ bundledSkipped.push(entry.name);
239
+ continue;
240
+ }
241
+ const children = await reader.list(entry.rel);
242
+ const hasSkill = children.some((child) => child.name === 'SKILL.md' && child.kind === 'file');
243
+ if (!hasSkill) {
244
+ if (categories && depth === 0)
245
+ await visit(entry.rel, 1);
246
+ continue;
247
+ }
248
+ const skillRel = `${entry.rel}/SKILL.md`;
249
+ const text = await reader.readText(skillRel);
250
+ if (text === null)
251
+ continue;
252
+ let converted;
253
+ try {
254
+ converted = (0, data_provider_1.skillFromSkillMarkdown)(text, { sourcePath: skillRel });
255
+ }
256
+ catch (err) {
257
+ if (!(err instanceof data_provider_1.ClaudeCodeImportError))
258
+ throw err;
259
+ stays.push({ what: `Skill ${entry.name}`, from: reader.join(skillRel), why: err.message });
260
+ continue;
261
+ }
262
+ const { content, files } = await readSkillFiles(reader, entry.rel, converted.skill.content);
263
+ skills.push({
264
+ from: reader.join(entry.rel),
265
+ skill: { ...converted.skill, content },
266
+ dropped: converted.dropped,
267
+ files,
268
+ });
269
+ }
270
+ };
271
+ await visit('skills', 0);
272
+ if (bundledSkipped.length) {
273
+ stays.push({
274
+ what: `${bundledSkipped.length} skill${bundledSkipped.length === 1 ? '' : 's'} that came with the app (${firstWords(bundledSkipped.join(', '), 60)})`,
275
+ from: reader.join('skills'),
276
+ why: 'They shipped with the old app, not with this bot.',
277
+ });
278
+ }
279
+ return { skills, stays };
280
+ }
281
+ // ── OpenClaw ────────────────────────────────────────────────────────────────
282
+ const OPENCLAW_SETTINGS = ['openclaw.json', 'clawdbot.json', 'moltbot.json'];
283
+ async function openClawLayout(reader) {
284
+ for (const name of OPENCLAW_SETTINGS)
285
+ if (await reader.has(name, 'file'))
286
+ return 'state';
287
+ if ((await reader.has('workspace', 'dir')) || (await reader.has('agents', 'dir')))
288
+ return 'state';
289
+ if ((await reader.has('IDENTITY.md', 'file')) ||
290
+ (await reader.has('HEARTBEAT.md', 'file')) ||
291
+ (await reader.has('BOOTSTRAP.md', 'file')) ||
292
+ ((await reader.has('AGENTS.md', 'file')) && (await reader.has('memory', 'dir')))) {
293
+ return 'workspace';
294
+ }
295
+ return null;
296
+ }
297
+ async function readOpenClaw(reader, sourceAgentFlag) {
298
+ const layout = (await openClawLayout(reader)) ?? 'workspace';
299
+ const stays = [];
300
+ let workspace = reader;
301
+ let sourceAgent = sourceAgentFlag || 'main';
302
+ // Listing the top of the folder records, by name, every key and login file in it: the plan
303
+ // names what was never opened, not only what was.
304
+ await reader.list();
305
+ if (layout === 'state') {
306
+ const candidates = sourceAgent === 'main'
307
+ ? ['workspace', 'workspace-main']
308
+ : [`workspace-${sourceAgent}`, `workspace/${sourceAgent}`];
309
+ let found = null;
310
+ for (const rel of candidates) {
311
+ if (await reader.has(rel, 'dir')) {
312
+ found = await reader.sub(rel);
313
+ if (found)
314
+ break;
315
+ }
316
+ }
317
+ if (!found) {
318
+ const agents = (await reader.list('agents'))
319
+ .filter((e) => e.kind === 'dir')
320
+ .map((e) => e.name);
321
+ throw new AgentImportSourceError('IMPORT_SOURCE_AGENT_NOT_FOUND', `No workspace for OpenClaw agent "${sourceAgent}" in ${reader.display}.` +
322
+ (agents.length
323
+ ? ` Agents here: ${agents.join(', ')} (choose one with --source-agent).`
324
+ : '') +
325
+ ' Or import the agent’s workspace folder itself.');
326
+ }
327
+ workspace = found;
328
+ await workspace.list();
329
+ for (const name of OPENCLAW_SETTINGS) {
330
+ if (await reader.has(name)) {
331
+ stays.push({
332
+ what: 'OpenClaw settings',
333
+ from: name,
334
+ why: 'Its channels, model choice, tools and their keys live there; it is never read. Connect channels and tools here again.',
335
+ });
336
+ }
337
+ }
338
+ if (await reader.has(`agents/${sourceAgent}/sessions`)) {
339
+ stays.push({
340
+ what: 'Chat history',
341
+ from: `agents/${sourceAgent}/sessions/`,
342
+ why: 'Chats stay with the old app; what it learned is in its notes.',
343
+ });
344
+ }
345
+ if (await reader.has('skills', 'dir')) {
346
+ stays.push({
347
+ what: 'Skills installed into OpenClaw itself',
348
+ from: 'skills/',
349
+ why: 'They came with the app, not with this agent.',
350
+ });
351
+ }
352
+ }
353
+ else {
354
+ // OpenClaw names a second agent's workspace `workspace-<agent>`.
355
+ const folderName = reader.root.split(/[\\/]+/).pop() ?? '';
356
+ sourceAgent = sourceAgentFlag || /^workspace-(.+)$/.exec(folderName)?.[1] || 'main';
357
+ stays.push({
358
+ what: 'Scheduled jobs',
359
+ why: 'OpenClaw keeps them beside its settings, outside this workspace. Import the OpenClaw folder (usually ~/.openclaw) to bring them.',
360
+ });
361
+ }
362
+ const persona = await readPersona(workspace, [
363
+ ['soul', 'SOUL.md'],
364
+ ['identity', 'IDENTITY.md'],
365
+ ['user', 'USER.md'],
366
+ ['tools', 'TOOLS.md'],
367
+ ]);
368
+ const identity = persona.find((file) => file.fileType === 'identity')?.content ?? '';
369
+ const declaredName = IDENTITY_NAME_RE.exec(identity)?.[1]?.replace(/\*+/g, '').trim() ?? '';
370
+ const name = declaredName && !PLACEHOLDER_RE.test(declaredName) ? declaredName : nameFromId(sourceAgent);
371
+ const memories = [];
372
+ const memoryLines = await workspace.readLines('MEMORY.md');
373
+ for (const entry of memoryLines ? markdownEntries(memoryLines) : []) {
374
+ memories.push({
375
+ from: workspace.join('MEMORY.md'),
376
+ line: entry.line,
377
+ path: memoryPath('openclaw', sourceAgent, 'memory'),
378
+ title: entry.heading
379
+ ? `${entry.heading}: ${firstWords(entry.text, 60)}`
380
+ : firstWords(entry.text),
381
+ claim: entry.text,
382
+ memoryKind: 'observation',
383
+ });
384
+ }
385
+ const runbook = await workspace.readText('AGENTS.md');
386
+ if (runbook && substance(runbook)) {
387
+ memories.push({
388
+ from: workspace.join('AGENTS.md'),
389
+ path: memoryPath('openclaw', sourceAgent, 'how-it-worked'),
390
+ title: `How ${name} worked in OpenClaw`,
391
+ claim: runbook.trim(),
392
+ memoryKind: 'procedure',
393
+ });
394
+ }
395
+ const notes = (await workspace.list('memory'))
396
+ .filter((entry) => entry.kind === 'file' && MARKDOWN_RE.test(entry.name))
397
+ .sort((a, b) => b.name.localeCompare(a.name));
398
+ const daily = notes.filter((entry) => DAILY_NOTE_RE.test(entry.name));
399
+ const topics = notes.filter((entry) => !DAILY_NOTE_RE.test(entry.name));
400
+ for (const entry of [...daily.slice(0, exports.DAILY_NOTES_LIMIT), ...topics]) {
401
+ const text = await workspace.readText(entry.rel);
402
+ if (!text || !substance(text))
403
+ continue;
404
+ const stem = entry.name.replace(MARKDOWN_RE, '');
405
+ memories.push({
406
+ from: workspace.join(entry.rel),
407
+ path: memoryPath('openclaw', sourceAgent, DAILY_NOTE_RE.test(entry.name) ? 'daily' : 'notes', stem),
408
+ title: DAILY_NOTE_RE.test(entry.name) ? `Notes from ${stem}` : nameFromId(stem),
409
+ claim: text.trim(),
410
+ memoryKind: DAILY_NOTE_RE.test(entry.name) ? 'event' : 'observation',
411
+ });
412
+ }
413
+ if (daily.length > exports.DAILY_NOTES_LIMIT) {
414
+ const older = daily.length - exports.DAILY_NOTES_LIMIT;
415
+ stays.push({
416
+ what: `${older} older daily note${older === 1 ? '' : 's'} (${daily[daily.length - 1].name} to ${daily[exports.DAILY_NOTES_LIMIT].name})`,
417
+ from: workspace.join('memory/'),
418
+ why: `The newest ${exports.DAILY_NOTES_LIMIT} come over; what mattered from older days is usually in MEMORY.md.`,
419
+ });
420
+ }
421
+ const skillRead = await readSkills(workspace);
422
+ stays.push(...skillRead.stays);
423
+ const schedules = [];
424
+ const heartbeat = await workspace.readText('HEARTBEAT.md');
425
+ if (heartbeat !== null) {
426
+ if (substance(heartbeat)) {
427
+ schedules.push({
428
+ from: workspace.join('HEARTBEAT.md'),
429
+ sourceId: 'heartbeat',
430
+ name: 'Heartbeat checklist',
431
+ instruction: heartbeat.trim(),
432
+ schedule: {
433
+ original: 'every heartbeat (its interval is set in OpenClaw’s settings, which are never read)',
434
+ savedCadence: null,
435
+ summary: 'no saved schedule: choose how often to check when you turn it on',
436
+ },
437
+ wasOff: false,
438
+ origin: 'heartbeat',
439
+ });
440
+ }
441
+ else {
442
+ stays.push({
443
+ what: 'Heartbeat',
444
+ from: workspace.join('HEARTBEAT.md'),
445
+ why: 'It is empty, so OpenClaw skipped it.',
446
+ });
447
+ }
448
+ }
449
+ if (await workspace.has('BOOTSTRAP.md', 'file')) {
450
+ stays.push({
451
+ what: 'First-run script',
452
+ from: workspace.join('BOOTSTRAP.md'),
453
+ why: 'It sets up a new OpenClaw agent; this agent is already set up.',
454
+ });
455
+ }
456
+ if (layout === 'state') {
457
+ const jobs = await reader.readJson('cron/jobs.json');
458
+ const list = Array.isArray(jobs)
459
+ ? jobs
460
+ : Array.isArray(jobs?.jobs)
461
+ ? jobs.jobs
462
+ : [];
463
+ list.slice(0, JOBS_LIMIT).forEach((job, index) => {
464
+ if (!job || typeof job !== 'object')
465
+ return;
466
+ const j = job;
467
+ const payload = (j.payload && typeof j.payload === 'object' ? j.payload : {});
468
+ const delivery = (j.delivery && typeof j.delivery === 'object' ? j.delivery : {});
469
+ if ((str(j.agentId) || 'main') !== sourceAgent)
470
+ return;
471
+ const sourceId = str(j.id) || str(j.name) || `job-${index + 1}`;
472
+ const field = `jobs[${index}]`;
473
+ const name = reader.field(str(j.name) || sourceId, 'cron/jobs.json', `${field}.name`);
474
+ // Name the field the instruction came from, so a left-out line can be found in the file.
475
+ const [instructionField, instructionText] = [
476
+ ['prompt', j.prompt],
477
+ ['message', j.message],
478
+ ['payload.message', payload.message],
479
+ ['payload.text', payload.text],
480
+ ]
481
+ .map(([key, value]) => [key, str(value)])
482
+ .find(([, value]) => value) ?? ['prompt', ''];
483
+ const instruction = reader.field(instructionText, 'cron/jobs.json', `${field}.${instructionField}`);
484
+ if (!instruction) {
485
+ stays.push({
486
+ what: `Scheduled job "${name || sourceId}"`,
487
+ from: 'cron/jobs.json',
488
+ why: 'It has no instruction to carry over.',
489
+ });
490
+ return;
491
+ }
492
+ schedules.push({
493
+ from: 'cron/jobs.json',
494
+ sourceId,
495
+ name: name || firstWords(instruction, 60),
496
+ instruction,
497
+ schedule: (0, schedule_1.readImportedSchedule)(j.schedule),
498
+ wasOff: j.enabled === false,
499
+ deliveredTo: str(delivery.channel) || str(j.deliver) || undefined,
500
+ origin: 'cron',
501
+ });
502
+ });
503
+ }
504
+ return {
505
+ app: 'openclaw',
506
+ folder: reader.display,
507
+ sourceAgent,
508
+ name,
509
+ persona,
510
+ memories,
511
+ skills: skillRead.skills,
512
+ schedules,
513
+ stays,
514
+ reader,
515
+ };
516
+ }
517
+ // ── Hermes ──────────────────────────────────────────────────────────────────
518
+ async function isHermesProfile(reader) {
519
+ return ((await reader.has('memories', 'dir')) ||
520
+ ((await reader.has('SOUL.md', 'file')) && (await reader.has('config.yaml'))));
521
+ }
522
+ /** Hermes memory files hold entries separated by a line holding only `§`. */
523
+ function hermesEntries(lines) {
524
+ const entries = [];
525
+ let current = null;
526
+ const flush = () => {
527
+ const textValue = current?.parts.join('\n').trim();
528
+ if (current && textValue)
529
+ entries.push({ line: current.line, text: textValue });
530
+ current = null;
531
+ };
532
+ for (const { line, text } of lines) {
533
+ if (text.trim() === '§') {
534
+ flush();
535
+ continue;
536
+ }
537
+ if (!current)
538
+ current = { line, parts: [] };
539
+ current.parts.push(text);
540
+ }
541
+ flush();
542
+ return entries;
543
+ }
544
+ async function readHermes(reader, sourceAgentFlag) {
545
+ const stays = [];
546
+ let profile = reader;
547
+ let sourceAgent = 'default';
548
+ if (sourceAgentFlag && sourceAgentFlag !== 'default') {
549
+ const sub = (await reader.has(`profiles/${sourceAgentFlag}`, 'dir'))
550
+ ? await reader.sub(`profiles/${sourceAgentFlag}`)
551
+ : null;
552
+ if (!sub) {
553
+ const profiles = (await reader.list('profiles'))
554
+ .filter((e) => e.kind === 'dir')
555
+ .map((e) => e.name);
556
+ throw new AgentImportSourceError('IMPORT_SOURCE_AGENT_NOT_FOUND', `No Hermes profile "${sourceAgentFlag}" in ${reader.display}.` +
557
+ (profiles.length ? ` Profiles here: default, ${profiles.join(', ')}.` : ''));
558
+ }
559
+ profile = sub;
560
+ sourceAgent = sourceAgentFlag;
561
+ }
562
+ else {
563
+ const segments = reader.root.split(/[\\/]+/);
564
+ if (segments[segments.length - 2] === 'profiles')
565
+ sourceAgent = segments[segments.length - 1];
566
+ }
567
+ await profile.list();
568
+ if (await profile.has('config.yaml')) {
569
+ stays.push({
570
+ what: 'Hermes settings',
571
+ from: profile.join('config.yaml'),
572
+ why: 'Its model, channels, MCP servers and their keys live there; it is never read. Connect channels and tools here again.',
573
+ });
574
+ }
575
+ for (const history of ['sessions', 'state.db']) {
576
+ if (await profile.has(history)) {
577
+ stays.push({
578
+ what: 'Chat history',
579
+ from: profile.join(history === 'sessions' ? 'sessions/' : history),
580
+ why: 'Chats stay with the old app and are never read; what it learned is in its memories.',
581
+ });
582
+ }
583
+ }
584
+ const persona = await readPersona(profile, [['soul', 'SOUL.md']]);
585
+ const soul = persona[0]?.content ?? '';
586
+ const heading = soul
587
+ .split('\n')
588
+ .map((line) => HEADING_RE.exec(line)?.[2])
589
+ .find(Boolean);
590
+ const name = sourceAgent !== 'default'
591
+ ? nameFromId(sourceAgent)
592
+ : heading && heading.length <= 40
593
+ ? heading
594
+ : 'Hermes';
595
+ const memories = [];
596
+ for (const [rel, kind, slot] of [
597
+ ['memories/MEMORY.md', 'observation', 'memory'],
598
+ ['memories/USER.md', 'profile', 'user'],
599
+ ]) {
600
+ const lines = await profile.readLines(rel);
601
+ for (const entry of lines ? hermesEntries(lines) : []) {
602
+ memories.push({
603
+ from: profile.join(rel),
604
+ line: entry.line,
605
+ path: memoryPath('hermes', sourceAgent, slot),
606
+ title: firstWords(entry.text),
607
+ claim: entry.text,
608
+ memoryKind: kind,
609
+ });
610
+ }
611
+ }
612
+ const manifest = (await profile.readText('skills/.bundled_manifest')) ?? '';
613
+ const bundled = new Set(manifest
614
+ .split('\n')
615
+ .map((line) => line.split(':')[0].trim())
616
+ .filter(Boolean));
617
+ const skillRead = await readSkills(profile, { categories: true, bundled });
618
+ stays.push(...skillRead.stays);
619
+ const schedules = [];
620
+ const jobs = await profile.readJson('cron/jobs.json');
621
+ const list = Array.isArray(jobs?.jobs)
622
+ ? jobs.jobs
623
+ : Array.isArray(jobs)
624
+ ? jobs
625
+ : [];
626
+ const jobsRel = profile.join('cron/jobs.json');
627
+ list.slice(0, JOBS_LIMIT).forEach((job, index) => {
628
+ if (!job || typeof job !== 'object')
629
+ return;
630
+ const j = job;
631
+ const sourceId = str(j.id) || str(j.name) || `job-${index + 1}`;
632
+ const field = `jobs[${index}]`;
633
+ const name = profile.field(str(j.name) || sourceId, 'cron/jobs.json', `${field}.name`);
634
+ if ((j.script !== undefined && j.script !== null) || j.no_agent === true) {
635
+ stays.push({
636
+ what: `Scheduled job "${name || sourceId}"`,
637
+ from: jobsRel,
638
+ why: 'It runs a script rather than the agent; scripts never travel.',
639
+ });
640
+ return;
641
+ }
642
+ const instruction = profile.field(str(j.prompt), 'cron/jobs.json', `${field}.prompt`);
643
+ if (!instruction) {
644
+ stays.push({
645
+ what: `Scheduled job "${name || sourceId}"`,
646
+ from: jobsRel,
647
+ why: 'It has no instruction to carry over.',
648
+ });
649
+ return;
650
+ }
651
+ const state = str(j.state).toLowerCase();
652
+ schedules.push({
653
+ from: jobsRel,
654
+ sourceId,
655
+ name: name || firstWords(instruction, 60),
656
+ instruction,
657
+ schedule: (0, schedule_1.readImportedSchedule)(j.schedule ?? j.schedule_display),
658
+ wasOff: j.enabled === false || state === 'paused',
659
+ deliveredTo: str(j.deliver) || undefined,
660
+ origin: 'cron',
661
+ });
662
+ });
663
+ return {
664
+ app: 'hermes',
665
+ folder: reader.display,
666
+ sourceAgent,
667
+ name,
668
+ persona,
669
+ memories,
670
+ skills: skillRead.skills,
671
+ schedules,
672
+ stays,
673
+ reader,
674
+ };
675
+ }
676
+ // ── Orca ────────────────────────────────────────────────────────────────────
677
+ async function readOrca(reader, sourceAgentFlag) {
678
+ let home = reader;
679
+ if (!(await reader.has('bot.json', 'file'))) {
680
+ const bots = [];
681
+ for (const entry of await reader.list()) {
682
+ if (entry.kind === 'dir' && (await reader.has(`${entry.name}/bot.json`, 'file')))
683
+ bots.push(entry.name);
684
+ }
685
+ if (!sourceAgentFlag || !bots.includes(sourceAgentFlag)) {
686
+ throw new AgentImportSourceError(sourceAgentFlag ? 'IMPORT_SOURCE_AGENT_NOT_FOUND' : 'IMPORT_SOURCE_AGENT_REQUIRED', bots.length
687
+ ? `${reader.display} holds several Orca bots: ${bots.join(', ')}. Choose one with --source-agent.`
688
+ : `No Orca bot in ${reader.display}: a bot's folder holds bot.json.`);
689
+ }
690
+ const sub = await reader.sub(sourceAgentFlag);
691
+ if (!sub)
692
+ throw new AgentImportSourceError('IMPORT_SOURCE_AGENT_NOT_FOUND', `Could not open ${sourceAgentFlag} in ${reader.display}.`);
693
+ home = sub;
694
+ }
695
+ await home.list();
696
+ const folderName = home.root.split(/[\\/]+/).pop() || 'bot';
697
+ const sourceAgent = sourceAgentFlag || folderName;
698
+ const bot = (await home.readJson('bot.json'));
699
+ const name = home.field(str(bot?.name), 'bot.json', 'name') || nameFromId(folderName);
700
+ const stays = [
701
+ {
702
+ what: 'Automations',
703
+ why: 'Orca keeps them in the app, not in the bot’s folder. Recreate the ones you still want as Duties.',
704
+ },
705
+ ];
706
+ for (const generated of ['AGENTS.md', 'CLAUDE.md']) {
707
+ if (await home.has(generated, 'file')) {
708
+ stays.push({
709
+ what: generated,
710
+ from: home.join(generated),
711
+ why: 'Orca writes it for its own runtime; Skrr gives the agent its own.',
712
+ });
713
+ }
714
+ }
715
+ const persona = await readPersona(home, [['soul', 'SOUL.md']]);
716
+ const memories = [];
717
+ for (const { line, text } of (await home.readLines('MEMORY.md')) ?? []) {
718
+ const fact = text.trim().replace(/^[-*+]\s+/, '');
719
+ if (!fact || ORCA_NON_FACT_RE.test(text.trim()) || ORCA_SEED_RE.test(fact))
720
+ continue;
721
+ memories.push({
722
+ from: home.join('MEMORY.md'),
723
+ line,
724
+ path: memoryPath('orca', sourceAgent, 'memory'),
725
+ title: firstWords(fact),
726
+ claim: fact,
727
+ memoryKind: 'observation',
728
+ });
729
+ }
730
+ for (const entry of await home.list('memory')) {
731
+ if (entry.kind !== 'file' || !MARKDOWN_RE.test(entry.name))
732
+ continue;
733
+ const text = await home.readText(entry.rel);
734
+ if (!text || !substance(text))
735
+ continue;
736
+ const stem = entry.name.replace(MARKDOWN_RE, '');
737
+ memories.push({
738
+ from: home.join(entry.rel),
739
+ path: memoryPath('orca', sourceAgent, 'topics', stem),
740
+ title: nameFromId(stem),
741
+ claim: text.trim(),
742
+ memoryKind: 'observation',
743
+ });
744
+ }
745
+ const skillRead = await readSkills(home);
746
+ stays.push(...skillRead.stays);
747
+ return {
748
+ app: 'orca',
749
+ folder: reader.display,
750
+ sourceAgent,
751
+ name,
752
+ persona,
753
+ memories,
754
+ skills: skillRead.skills,
755
+ schedules: [],
756
+ stays,
757
+ reader,
758
+ };
759
+ }
760
+ // ── detection ───────────────────────────────────────────────────────────────
761
+ /** Which app a folder belongs to, by its layout alone (nothing is read), or null. */
762
+ async function detectImportApp(reader) {
763
+ if (await reader.has('bot.json', 'file'))
764
+ return 'orca';
765
+ if (await isHermesProfile(reader))
766
+ return 'hermes';
767
+ if (await openClawLayout(reader))
768
+ return 'openclaw';
769
+ // A folder of Orca bots, or of Hermes profiles.
770
+ for (const entry of await reader.list()) {
771
+ if (entry.kind === 'dir' && (await reader.has(`${entry.name}/bot.json`, 'file')))
772
+ return 'orca';
773
+ }
774
+ return null;
775
+ }
776
+ /** Whether a folder looks like any app this importer reads (for routing `skrr agents import <dir>`). */
777
+ async function looksLikeBotFolder(folder) {
778
+ try {
779
+ return (await detectImportApp(await reader_1.SourceReader.open(folder))) !== null;
780
+ }
781
+ catch {
782
+ return false;
783
+ }
784
+ }
785
+ /** Read a bot folder. `app` forces the app; otherwise it is told by the folder's layout. */
786
+ async function readImportSource(folder, { app, sourceAgent } = {}) {
787
+ const reader = await reader_1.SourceReader.open(folder);
788
+ const kind = app ?? (await detectImportApp(reader));
789
+ if (!kind) {
790
+ throw new AgentImportSourceError('IMPORT_SOURCE_UNKNOWN', `${(0, reader_1.displayPath)(reader.root)} does not look like an OpenClaw, Hermes or Orca bot folder. Name the app with --from openclaw|hermes|orca.`);
791
+ }
792
+ if (kind === 'openclaw')
793
+ return readOpenClaw(reader, sourceAgent);
794
+ if (kind === 'hermes')
795
+ return readHermes(reader, sourceAgent);
796
+ return readOrca(reader, sourceAgent);
797
+ }