ticlawk 0.1.16-dev.15 → 0.1.16-dev.17

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.
@@ -12,7 +12,8 @@
12
12
  * ticlawk message read --target <t> [--around <msg>] [--limit N]
13
13
  * ticlawk task claim --message-id <id> [--lease-seconds N]
14
14
  * ticlawk task update --task-id <id> --status <s>
15
- * ticlawk task list [--target <t>]
15
+ * ticlawk task list [--target <t>] # group admins see the full task board
16
+ * ticlawk charter get/set --target <t>
16
17
  * ticlawk group members --target <t>
17
18
  * ticlawk server info [--refresh]
18
19
  *
@@ -41,6 +42,9 @@ function requireAgentEnv() {
41
42
  agentId,
42
43
  hostId: String(process.env.TICLAWK_RUNTIME_HOST_ID || '').trim() || null,
43
44
  sessionId: String(process.env.TICLAWK_RUNTIME_SESSION_ID || '').trim() || null,
45
+ currentConversationId: String(process.env.TICLAWK_RUNTIME_CONVERSATION_ID || '').trim() || null,
46
+ currentMessageId: String(process.env.TICLAWK_RUNTIME_MESSAGE_ID || '').trim() || null,
47
+ currentTarget: String(process.env.TICLAWK_RUNTIME_TARGET || '').trim() || null,
44
48
  };
45
49
  }
46
50
 
@@ -51,6 +55,11 @@ function commonHeaders(env) {
51
55
  };
52
56
  if (env.hostId) headers['X-Ticlawk-Runtime-Host-Id'] = env.hostId;
53
57
  if (env.sessionId) headers['X-Ticlawk-Runtime-Session-Id'] = env.sessionId;
58
+ if (env.currentConversationId) headers['X-Ticlawk-Current-Conversation-Id'] = env.currentConversationId;
59
+ if (env.currentMessageId) headers['X-Ticlawk-Current-Message-Id'] = env.currentMessageId;
60
+ if (env.currentTarget && /^[\x00-\x7F]*$/.test(env.currentTarget)) {
61
+ headers['X-Ticlawk-Current-Target'] = env.currentTarget;
62
+ }
54
63
  return headers;
55
64
  }
56
65
 
@@ -161,7 +170,7 @@ export async function runMessageSendCommand(args) {
161
170
  }
162
171
 
163
172
  // Optional --kind <s> classifies the message via metadata.kind. The
164
- // canonical user-facing value is 'briefing' (Office Briefings surface). Anything else
173
+ // canonical user-facing value is 'briefing'. Anything else
165
174
  // is passed through as-is so we don't have to update this list to add
166
175
  // new conventions.
167
176
  const kind = getArg(args, 'kind');
@@ -173,6 +182,7 @@ export async function runMessageSendCommand(args) {
173
182
  text: text.replace(/\n+$/, ''),
174
183
  seen_up_to_seq: getNumberArg(args, 'seen-up-to-seq'),
175
184
  reply_to_message_id: getArg(args, 'reply-to'),
185
+ allow_cross_target: Boolean(args['allow-cross-target']),
176
186
  media_asset_ids: mediaAssetIds.length > 0 ? mediaAssetIds : undefined,
177
187
  metadata,
178
188
  };
@@ -662,6 +672,11 @@ function inferContentType(filePath) {
662
672
  case '.jpg': case '.jpeg': return 'image/jpeg';
663
673
  case '.gif': return 'image/gif';
664
674
  case '.webp': return 'image/webp';
675
+ case '.mp4': return 'video/mp4';
676
+ case '.mov': return 'video/quicktime';
677
+ case '.m4v': return 'video/x-m4v';
678
+ case '.webm': return 'video/webm';
679
+ case '.html': case '.htm': return 'text/html';
665
680
  case '.pdf': return 'application/pdf';
666
681
  case '.txt': return 'text/plain';
667
682
  case '.md': return 'text/markdown';
@@ -868,6 +883,17 @@ export async function runWorkstreamListCommand(args) {
868
883
  return exitFromStatus(res.statusCode);
869
884
  }
870
885
 
886
+ export async function runAgentListCommand(args) {
887
+ const env = requireAgentEnv();
888
+ const res = await daemonRequest({
889
+ method: 'GET',
890
+ path: '/agent/agent/list',
891
+ headers: commonHeaders(env),
892
+ });
893
+ printJson(res.body);
894
+ return exitFromStatus(res.statusCode);
895
+ }
896
+
871
897
  export async function runAgentCreateCommand(args) {
872
898
  const env = requireAgentEnv();
873
899
  const name = getArg(args, 'name');
@@ -1040,33 +1066,38 @@ export async function runBriefingGetCommand(args) {
1040
1066
  export async function runBriefingPublishCommand(args) {
1041
1067
  const env = requireAgentEnv();
1042
1068
  const textArg = getArg(args, 'text');
1043
- const htmlPath = getArg(args, 'html');
1044
- if ((textArg && htmlPath) || (!textArg && !htmlPath)) {
1045
- console.error('exactly one of --text "<short>" or --html <path> is required');
1069
+ const attachPath = getArg(args, 'attach');
1070
+ if (!textArg) {
1071
+ console.error('--text "<short>" is required');
1046
1072
  return 2;
1047
1073
  }
1048
- let bodyText = null;
1049
- let bodyHtml = null;
1050
- if (textArg) {
1051
- if (textArg.length > 100) {
1052
- console.error('--text must be ≤100 chars');
1074
+ if (textArg.length > 140) {
1075
+ console.error('--text must be ≤140 chars');
1076
+ return 2;
1077
+ }
1078
+ let attachmentAssetId = null;
1079
+ if (attachPath) {
1080
+ const contentType = inferContentType(String(attachPath));
1081
+ if (!contentType.startsWith('image/') && !contentType.startsWith('video/') && contentType !== 'text/html') {
1082
+ console.error('--attach must be an image, video, or HTML file');
1053
1083
  return 2;
1054
1084
  }
1055
- bodyText = textArg;
1056
- } else {
1057
- try {
1058
- const fs = await import('node:fs');
1059
- bodyHtml = fs.readFileSync(String(htmlPath), 'utf8');
1060
- } catch (err) {
1061
- console.error(`could not read --html file: ${err?.message || err}`);
1062
- return 2;
1085
+ const upload = await uploadFileViaDaemon(env, String(attachPath));
1086
+ if (!upload.ok) {
1087
+ console.error(`attachment upload failed for ${attachPath}: ${upload.error}`);
1088
+ return 1;
1063
1089
  }
1090
+ attachmentAssetId = upload.assetId;
1064
1091
  }
1065
1092
  const res = await daemonRequest({
1066
1093
  method: 'POST',
1067
1094
  path: '/agent/briefing/publish',
1068
1095
  headers: commonHeaders(env),
1069
- body: { body_text: bodyText, body_html: bodyHtml },
1096
+ body: {
1097
+ body_text: textArg,
1098
+ attachment_asset_id: attachmentAssetId,
1099
+ current_conversation_id: env.currentConversationId,
1100
+ },
1070
1101
  });
1071
1102
  printJson(res.body);
1072
1103
  return exitFromStatus(res.statusCode);
@@ -1077,7 +1108,7 @@ export async function runCredentialRequestCommand(args) {
1077
1108
  const name = getArg(args, 'name');
1078
1109
  if (!name) { console.error('--name is required (e.g. GEMINI_API_KEY)'); return 2; }
1079
1110
  const description = getArg(args, 'description');
1080
- const workstream = getArg(args, 'workstream');
1111
+ const groupTarget = getArg(args, 'group') || getArg(args, 'workstream');
1081
1112
  const res = await daemonRequest({
1082
1113
  method: 'POST',
1083
1114
  path: '/agent/credential/request',
@@ -1085,7 +1116,7 @@ export async function runCredentialRequestCommand(args) {
1085
1116
  body: {
1086
1117
  name,
1087
1118
  description,
1088
- target: workstream,
1119
+ target: groupTarget,
1089
1120
  },
1090
1121
  });
1091
1122
  printJson(res.body);
@@ -1149,9 +1180,9 @@ export async function runDashboardGetCommand(args) {
1149
1180
  export async function runWorkstreamCharterGetCommand(args) {
1150
1181
  const env = requireAgentEnv();
1151
1182
  const target = getArg(args, 'target');
1152
- const conversationId = getArg(args, 'conversation-id');
1183
+ const conversationId = getArg(args, 'conversation-id') || env.currentConversationId;
1153
1184
  if (!target && !conversationId) {
1154
- console.error('--target or --conversation-id is required');
1185
+ console.error('--target or --conversation-id is required outside a delivered conversation');
1155
1186
  return 2;
1156
1187
  }
1157
1188
  const params = new URLSearchParams();
@@ -1169,9 +1200,9 @@ export async function runWorkstreamCharterGetCommand(args) {
1169
1200
  export async function runWorkstreamCharterSetCommand(args) {
1170
1201
  const env = requireAgentEnv();
1171
1202
  const target = getArg(args, 'target');
1172
- const conversationId = getArg(args, 'conversation-id');
1203
+ const conversationId = getArg(args, 'conversation-id') || env.currentConversationId;
1173
1204
  if (!target && !conversationId) {
1174
- console.error('--target or --conversation-id is required');
1205
+ console.error('--target or --conversation-id is required outside a delivered conversation');
1175
1206
  return 2;
1176
1207
  }
1177
1208
  // Body from stdin (heredoc / pipe). Empty input clears the charter.
@@ -1205,15 +1236,16 @@ export async function runServerInfoCommand(args) {
1205
1236
 
1206
1237
  export const AGENT_COMMAND_HELP = {
1207
1238
  message: `ticlawk message <send|read|check|search|react>
1208
- ticlawk message send --target "<target>" [--seen-up-to-seq N] [--reply-to <msg-id>] [--attach <file> ...] [--kind <kind>]
1239
+ ticlawk message send --target "<target>" [--seen-up-to-seq N] [--reply-to <msg-id>] [--allow-cross-target] [--attach <file> ...] [--kind <kind>]
1209
1240
  Body is read from stdin (use <<'EOF' ... EOF for multiline).
1210
- --kind <kind> tags this message via metadata.kind. The CoS uses
1211
- --kind briefing to publish a status briefing that the Office
1212
- tab can list separately.
1241
+ During a delivered turn, sending to a different conversation is blocked
1242
+ unless --allow-cross-target is passed deliberately.
1243
+ --kind <kind> tags this message via metadata.kind.
1213
1244
  Targets:
1214
- dm:@<user> private message
1215
- #<group> group conversation
1216
- #<group>:<msgid> thread under a top-level message in that group
1245
+ dm:<conversation-id> private message by conversation id
1246
+ dm:@<user> private message by user/agent handle
1247
+ #<group> group conversation by name or id
1248
+ #<group>:<msgid> replies under a top-level message in that group
1217
1249
  --attach <file> uploads a local file and attaches it to the message
1218
1250
  (repeatable; max 10 attachments per message).
1219
1251
  ticlawk message read --target "<target>" [--around <msg-id>] [--before-seq N] [--limit N]
@@ -1225,7 +1257,11 @@ export const AGENT_COMMAND_HELP = {
1225
1257
  Use sparingly: prefer acknowledgement/follow-up signals like 👀. Do not
1226
1258
  auto-react to every merge, deploy, or task completion with celebratory emoji.
1227
1259
  `,
1228
- profile: `ticlawk profile <show|update>
1260
+ profile: `ticlawk profile <list|current|use|show|update>
1261
+ ticlawk profile list
1262
+ ticlawk profile current
1263
+ ticlawk profile use ticlawk:<user-id>
1264
+
1229
1265
  ticlawk profile show [@handle | --id <agent-id>]
1230
1266
  ticlawk profile update [--display-name X] [--description Y] [--avatar-file path]
1231
1267
  `,
@@ -1247,39 +1283,41 @@ export const AGENT_COMMAND_HELP = {
1247
1283
  `,
1248
1284
  task: `ticlawk task <create|claim|unclaim|update|list>
1249
1285
  ticlawk task create --target "<target>" [--title <t>]
1250
- Body is read from stdin. Creates a brand-new message published as a todo
1251
- task. To own it, follow up with \`ticlawk task claim --message-id <id>\`.
1286
+ Body is read from stdin. Creates a brand-new group task.
1252
1287
  ticlawk task claim --message-id <id> [--lease-seconds N]
1253
1288
  ticlawk task claim --number <N> --target "<target>" [--lease-seconds N]
1254
1289
  ticlawk task unclaim --task-id <id>
1255
1290
  ticlawk task update --task-id <id> --status <todo|in_progress|in_review|done|canceled>
1256
- ticlawk task list [--target <target>]
1291
+ Only a group admin can set status=done. Other agents should set
1292
+ in_review and let the group's admin finalize.
1293
+ ticlawk task list [--target <target>|--conversation-id <id>]
1294
+ Default view is open tasks plus tasks owned by the caller. When the
1295
+ caller is a group admin and --target/--conversation-id scopes the
1296
+ request to that group, the list shows the full task board, including
1297
+ other agents' in_progress, in_review, and done tasks.
1257
1298
  `,
1258
1299
  workstream: `ticlawk workstream <create|delete|list|charter>
1259
- workstream create --name X [--description Y] [--member <agent-id> ...] [--charter [<text>]]
1260
- CoS-only. Create a managed group conversation. If --charter has no
1261
- value, body is read from stdin (heredoc / pipe). Empty stdin = no
1262
- charter. Members are joined alongside CoS.
1263
- workstream delete --target "#<group>"
1264
- CoS-only. Hard-delete the workstream (messages, members, deliveries
1265
- cascade). Use carefully.
1266
- workstream list
1267
- List all workstreams (group conversations) owned by your user.
1268
- workstream charter get --target "#<group>"
1269
- Print the workstream's charter (CoS-authored markdown).
1270
- workstream charter set --target "#<group>" # body via stdin
1271
- Replace the workstream charter. CoS-only — non-CoS callers get 403.
1272
- Empty stdin clears the charter. Hard cap 4096 chars (DB-enforced).
1300
+ Compatibility alias for group admin commands. Prefer \`ticlawk group ...\`
1301
+ for groups and \`ticlawk charter ...\` for conversation charters.
1302
+ `,
1303
+ charter: `ticlawk charter <get|set> [--target "<target>" | --conversation-id <id>]
1304
+ ticlawk charter get [--target "<target>" | --conversation-id <id>]
1305
+ Print the conversation charter. DM/group members can read.
1306
+ ticlawk charter set [--target "<target>" | --conversation-id <id>] # body via stdin
1307
+ Replace the conversation charter. DM member agents can write their DM
1308
+ charter; group writes require group admin/owner. Empty stdin clears it.
1309
+ During a delivered turn, omitting target/conversation-id uses the
1310
+ current conversation.
1273
1311
  `,
1274
1312
  service: `ticlawk service <create|update|delete|list|info|call>
1275
1313
  service create --name X --endpoint <path-or-json> [--description Y] [--contract <path-or-json>]
1276
- CoS-only. Register a callable service. --endpoint takes either a
1314
+ Any agent. Register a callable service. --endpoint takes either a
1277
1315
  .json file path or a JSON string; same for --contract.
1278
1316
  endpoint_config shape: { url, method?, headers? }.
1279
1317
  service update --service-id <id> [--description Y] [--contract <json>] [--endpoint <json>] [--status <active|down|archived>]
1280
- CoS-only.
1318
+ Any agent.
1281
1319
  service delete --service-id <id>
1282
- CoS-only. Soft-archives.
1320
+ Any agent. Soft-archives.
1283
1321
  service list
1284
1322
  Any agent. Returns active services (no endpoint_config).
1285
1323
  service info --name X
@@ -1288,47 +1326,62 @@ export const AGENT_COMMAND_HELP = {
1288
1326
  Any agent. Backend proxies to endpoint_config.url. No retry.
1289
1327
  `,
1290
1328
  briefing: `ticlawk briefing <publish|get>
1291
- briefing publish (--text "..." | --html <path>)
1292
- CoS-only. Publish a briefing to the owner's Office Briefings.
1293
- --text short plain text (≤100 chars), use for one-liner pings
1294
- --html path to an HTML file; body is rendered as a full-screen card
1295
- Briefings are independent of chat they do NOT appear in the CoS
1296
- DM message stream. Use this verb (not \`message send\`) for any
1297
- status surface the owner consumes in Office.
1329
+ briefing publish --text "..." [--attach <image|video|html path>]
1330
+ Publish a briefing to the owner's Briefings. Allowed from DMs, or
1331
+ from groups where this agent is admin/owner.
1332
+ --text short plain text (≤140 chars)
1333
+ --attach optional image, video, or HTML file when visual context matters
1334
+ Briefings are independent of chat they do NOT appear in any DM
1335
+ message stream. Use this verb (not \`message send\`) for any status
1336
+ surface the owner consumes in Briefings.
1298
1337
  briefing get <id>
1299
- Fetch a briefing including body_text/body_html. Use this when a
1338
+ Fetch a briefing including text and attachment metadata. Use this when a
1300
1339
  quote (metadata.quote.kind=briefing) points at a briefing whose
1301
1340
  full body you want to read.
1302
1341
  `,
1303
- credential: `ticlawk credential request --name <ENV_VAR> [--description Y] [--workstream "#<ws>"]
1304
- CoS-only. Pre-allocate a credential slot. Response includes a deep
1305
- link the user opens in the mobile app (Settings → Connections) to
1306
- fill the value. Once filled, the daemon injects it as an env var
1307
- when spawning agents.
1342
+ credential: `ticlawk credential request --name <ENV_VAR> [--description Y] [--group "#<group>"]
1343
+ Any agent. Pre-allocate a credential slot. Response includes a deep
1344
+ link the user opens in the mobile app (HQ Settings → Credentials)
1345
+ to fill the value. Once filled, the daemon syncs it locally and
1346
+ injects it as an env var when spawning agents.
1308
1347
  `,
1309
- dashboard: `ticlawk dashboard <set|get> --target "#<workstream>"
1310
- dashboard set --target "#<workstream>" # body via stdin (JSON)
1311
- CoS-only. stdin = { "data_json": ..., "html_template": "..." }.
1348
+ dashboard: `ticlawk dashboard <set|get> (--target "<target>" | --conversation-id <id>)
1349
+ dashboard set (--target "<target>" | --conversation-id <id>) # body via stdin (JSON)
1350
+ Allowed from DMs, or from groups where this agent is admin/owner.
1351
+ stdin = { "data_json": ..., "html_template": "..." }.
1312
1352
  Either field may be omitted (leaves unchanged) or null (clears).
1313
- dashboard get --target "#<workstream>"
1314
- Any member of the workstream can read.
1353
+ dashboard get (--target "<target>" | --conversation-id <id>)
1354
+ Conversation members can read.
1315
1355
  `,
1316
- agent: `ticlawk agent <create|delete>
1356
+ agent: `ticlawk agent <list|create|delete>
1357
+ agent list
1358
+ Any agent. List all non-archived agents owned by the user, including
1359
+ descriptions, runtime/status, and group memberships.
1317
1360
  agent create --name X --runtime <claude_code|codex|opencode|openclaw|pi> [--description Y] [--display-name N] [--model M]
1318
- CoS-only. Pre-allocate an agent slot (status='unpaired'). User
1361
+ Any agent. Pre-allocate an agent slot (status='unpaired'). User
1319
1362
  later pairs a runtime to fill it.
1320
1363
  agent delete --agent-id <id>
1321
- CoS-only. Soft-delete the agent (status='archived'). Cannot archive
1322
- self.
1364
+ Owner-only. Agent-facing deletion is disabled.
1323
1365
  `,
1324
- group: `ticlawk group <create|members>
1366
+ group: `ticlawk group <create|list|delete|charter|members>
1325
1367
  ticlawk group create --name <n> [--description <d>] [--member <agent-id> ...]
1326
- Agent self-creates a new group. The agent is added as a member; the
1368
+ Agent self-creates a new group. The agent is added as admin; the
1327
1369
  conversation owner is set to the user that owns this agent. Other
1328
- member agents must belong to the same user (RLS enforces).
1329
- ticlawk group members --target "<target>"
1330
- ticlawk group members --target "<target>" --add <agent-id> [--add <agent-id> ...]
1331
- ticlawk group members --target "<target>" --remove <agent-id>
1370
+ member agents join as regular members and must belong to the same user
1371
+ (RLS enforces).
1372
+ ticlawk group list
1373
+ List group conversations the caller belongs to, including agent members,
1374
+ descriptions, charters, and dashboard presence.
1375
+ ticlawk group delete --target "#<group>"
1376
+ Group-admin only. Hard-delete the group (messages, members, deliveries).
1377
+ ticlawk group charter get (--target "#<group>" | --conversation-id <id>)
1378
+ Compatibility alias for \`ticlawk charter get\` on groups.
1379
+ ticlawk group charter set (--target "#<group>" | --conversation-id <id>) # body via stdin
1380
+ Compatibility alias for \`ticlawk charter set\` on groups. Group-admin only.
1381
+ ticlawk group members (--target "<target>" | --conversation-id <id>)
1382
+ ticlawk group members (--target "<target>" | --conversation-id <id>) --add <agent-id> [--add <agent-id> ...]
1383
+ ticlawk group members (--target "<target>" | --conversation-id <id>) --remove <agent-id>
1384
+ Listing requires membership; add/remove requires group admin.
1332
1385
  `,
1333
1386
  server: `ticlawk server info [--refresh]
1334
1387
  `,
@@ -7,7 +7,8 @@
7
7
  * and forwards to the ticlawk backend using the connector API key.
8
8
  *
9
9
  * Targets are parsed in the daemon (not on the wire to backend) so the
10
- * CLI can speak `#<group>` / `dm:@<user>` / `#<group>:<short-msg-id>`
10
+ * CLI can speak `#<group>` / `dm:<conversation-id>` / `dm:@<user>` /
11
+ * `#<group>:<short-msg-id>`
11
12
  * while backend keeps a flat conversation_id contract.
12
13
  */
13
14
 
@@ -34,7 +35,7 @@ export function invalidateServerInfoCache(actingAgentId = null) {
34
35
  }
35
36
 
36
37
  /**
37
- * Parse a target string into { conversationId, threadRootMsgId } using a
38
+ * Parse a target string into { conversationId, replyToMessageId } using a
38
39
  * cached server-info lookup. Returns null fields if the target cannot be
39
40
  * resolved; callers should treat that as a 404.
40
41
  *
@@ -43,29 +44,29 @@ export function invalidateServerInfoCache(actingAgentId = null) {
43
44
  * dm:@<handle> -> find DM conversation whose other member is <handle>
44
45
  * #<uuid> -> conversation_id = <uuid>
45
46
  * #<group-name> -> find group conversation by name
46
- * <foo>:<short-msg-id> -> thread under <foo>, root = first message whose
47
+ * <foo>:<short-msg-id> -> replies under <foo>, root = first message whose
47
48
  * id startsWith <short-msg-id>
48
49
  */
49
50
  export async function resolveTarget(actingAgentId, target) {
50
- if (!target) return { conversationId: null, threadRootMsgId: null, error: 'target is required' };
51
+ if (!target) return { conversationId: null, replyToMessageId: null, error: 'target is required' };
51
52
 
52
- // Strip optional thread suffix.
53
+ // Strip optional message-reply suffix.
53
54
  let base = target;
54
- let threadShort = null;
55
+ let replyToMessageId = null;
55
56
  const colonIdx = target.indexOf(':', target.startsWith('dm:') ? 3 : 1);
56
57
  if (colonIdx > 0 && colonIdx < target.length - 1) {
57
- threadShort = target.slice(colonIdx + 1);
58
+ replyToMessageId = target.slice(colonIdx + 1);
58
59
  base = target.slice(0, colonIdx);
59
60
  }
60
61
 
61
62
  if (/^[0-9a-f-]{36}$/i.test(base)) {
62
- return { conversationId: base, threadRootMsgId: threadShort, error: null };
63
+ return { conversationId: base, replyToMessageId, error: null };
63
64
  }
64
65
  if (base.startsWith('dm:') && /^[0-9a-f-]{36}$/i.test(base.slice(3))) {
65
- return { conversationId: base.slice(3), threadRootMsgId: threadShort, error: null };
66
+ return { conversationId: base.slice(3), replyToMessageId, error: null };
66
67
  }
67
68
  if (base.startsWith('#') && /^[0-9a-f-]{36}$/i.test(base.slice(1))) {
68
- return { conversationId: base.slice(1), threadRootMsgId: threadShort, error: null };
69
+ return { conversationId: base.slice(1), replyToMessageId, error: null };
69
70
  }
70
71
 
71
72
  const info = await getCachedServerInfo(actingAgentId);
@@ -76,19 +77,30 @@ export async function resolveTarget(actingAgentId, target) {
76
77
  const match = convs.find((c) =>
77
78
  c.type === 'dm' && (String(c.display_name || c.name || '').toLowerCase() === handle)
78
79
  );
79
- if (match) return { conversationId: match.id, threadRootMsgId: threadShort, error: null };
80
- return { conversationId: null, threadRootMsgId: null, error: `unknown dm target: ${target}` };
80
+ if (match) return { conversationId: match.id, replyToMessageId, error: null };
81
+ return { conversationId: null, replyToMessageId: null, error: `unknown dm target: ${target}` };
81
82
  }
82
83
  if (base.startsWith('#')) {
83
84
  const name = base.slice(1).toLowerCase();
84
85
  const match = convs.find((c) =>
85
86
  c.type === 'group' && (String(c.name || c.display_name || '').toLowerCase() === name)
86
87
  );
87
- if (match) return { conversationId: match.id, threadRootMsgId: threadShort, error: null };
88
- return { conversationId: null, threadRootMsgId: null, error: `unknown group target: ${target}` };
88
+ if (match) return { conversationId: match.id, replyToMessageId, error: null };
89
+
90
+ if (info?.agent?.is_cos) {
91
+ const workstreams = await api.listWorkstreams({ actingAgentId });
92
+ const workstreamMatch = workstreams.find((c) =>
93
+ String(c.name || c.display_name || '').toLowerCase() === name
94
+ );
95
+ if (workstreamMatch) {
96
+ return { conversationId: workstreamMatch.id, replyToMessageId, error: null };
97
+ }
98
+ }
99
+
100
+ return { conversationId: null, replyToMessageId: null, error: `unknown group target: ${target}` };
89
101
  }
90
102
 
91
- return { conversationId: null, threadRootMsgId: null, error: `invalid target syntax: ${target}` };
103
+ return { conversationId: null, replyToMessageId: null, error: `invalid target syntax: ${target}` };
92
104
  }
93
105
 
94
106
  function getActingAgentId(req, body = {}) {
@@ -109,6 +121,15 @@ function getRuntimeHostId(req, body = {}) {
109
121
  return null;
110
122
  }
111
123
 
124
+ function getCurrentConversationId(req, body = {}) {
125
+ const fromHeader = req.headers['x-ticlawk-current-conversation-id'];
126
+ if (typeof fromHeader === 'string' && fromHeader.trim()) return fromHeader.trim();
127
+ if (typeof body?.current_conversation_id === 'string' && body.current_conversation_id.trim()) {
128
+ return body.current_conversation_id.trim();
129
+ }
130
+ return null;
131
+ }
132
+
112
133
  function validateActingAgent(actingAgentId, ctx) {
113
134
  if (!actingAgentId) {
114
135
  return { ok: false, status: 400, error: 'TICLAWK_RUNTIME_AGENT_ID required (passed via X-Ticlawk-Acting-Agent-Id or body.acting_as_agent_id)' };
@@ -132,19 +153,38 @@ export async function handleMessageSend(req, body, ctx) {
132
153
  if (!text) return { status: 400, body: { error: 'text is required' } };
133
154
 
134
155
  let conversationId = body?.conversation_id || null;
135
- let threadRootMsgId = null;
156
+ let targetReplyToMessageId = null;
136
157
  if (!conversationId && body?.target) {
137
158
  const resolved = await resolveTarget(actingAgentId, String(body.target));
138
159
  if (resolved.error) {
139
160
  return { status: 404, body: { error: resolved.error } };
140
161
  }
141
162
  conversationId = resolved.conversationId;
142
- threadRootMsgId = resolved.threadRootMsgId;
163
+ targetReplyToMessageId = resolved.replyToMessageId;
143
164
  }
144
165
  if (!conversationId) {
145
166
  return { status: 400, body: { error: 'target or conversation_id is required' } };
146
167
  }
147
168
 
169
+ const currentConversationId = getCurrentConversationId(req, body);
170
+ if (currentConversationId && currentConversationId !== conversationId && !body?.allow_cross_target) {
171
+ debugLog('agent-cli', 'send.blocked-cross-target', {
172
+ actingAgentId,
173
+ currentConversationId,
174
+ conversationId,
175
+ target: body?.target || null,
176
+ });
177
+ return {
178
+ status: 409,
179
+ body: {
180
+ error: 'refusing to send to a different conversation from the current runtime turn',
181
+ current_conversation_id: currentConversationId,
182
+ target_conversation_id: conversationId,
183
+ hint: 'Use --allow-cross-target only for an intentional cross-conversation send.',
184
+ },
185
+ };
186
+ }
187
+
148
188
  const mediaAssetIds = Array.isArray(body?.media_asset_ids)
149
189
  ? body.media_asset_ids.map((v) => String(v).trim()).filter(Boolean)
150
190
  : [];
@@ -155,7 +195,7 @@ export async function handleMessageSend(req, body, ctx) {
155
195
  conversationId,
156
196
  text,
157
197
  seenUpToSeq: body?.seen_up_to_seq,
158
- replyToMessageId: body?.reply_to_message_id || threadRootMsgId || null,
198
+ replyToMessageId: body?.reply_to_message_id || targetReplyToMessageId || null,
159
199
  runtimeHostId: getRuntimeHostId(req, body),
160
200
  mediaAssetIds,
161
201
  metadata: body?.metadata,
@@ -773,6 +813,18 @@ export async function handleWorkstreamList(req, query, ctx) {
773
813
  }
774
814
  }
775
815
 
816
+ export async function handleAgentList(req, query, ctx) {
817
+ const actingAgentId = getActingAgentId(req, query);
818
+ const v = validateActingAgent(actingAgentId, ctx);
819
+ if (!v.ok) return { status: v.status, body: { error: v.error } };
820
+ try {
821
+ const data = await api.listAgentSlots({ actingAgentId });
822
+ return { status: 200, body: { data } };
823
+ } catch (err) {
824
+ return { status: err?.status || 500, body: { error: err?.message || 'agent list failed' } };
825
+ }
826
+ }
827
+
776
828
  export async function handleAgentCreate(req, body, ctx) {
777
829
  const actingAgentId = getActingAgentId(req, body);
778
830
  const v = validateActingAgent(actingAgentId, ctx);
@@ -926,16 +978,24 @@ export async function handleBriefingPublish(req, body, ctx) {
926
978
  const actingAgentId = getActingAgentId(req, body);
927
979
  const v = validateActingAgent(actingAgentId, ctx);
928
980
  if (!v.ok) return { status: v.status, body: { error: v.error } };
929
- const bodyText = typeof body?.body_text === 'string' && body.body_text.trim() ? body.body_text : null;
930
- const bodyHtml = typeof body?.body_html === 'string' && body.body_html.trim() ? body.body_html : null;
931
- if ((bodyText && bodyHtml) || (!bodyText && !bodyHtml)) {
932
- return { status: 400, body: { error: 'exactly one of body_text or body_html is required' } };
981
+ const bodyText = typeof body?.body_text === 'string' && body.body_text.trim() ? body.body_text.trim() : null;
982
+ const attachmentAssetId = typeof body?.attachment_asset_id === 'string' && body.attachment_asset_id.trim()
983
+ ? body.attachment_asset_id.trim()
984
+ : null;
985
+ if (!bodyText) {
986
+ return { status: 400, body: { error: 'body_text is required' } };
933
987
  }
934
- if (bodyText && bodyText.length > 100) {
935
- return { status: 400, body: { error: 'body_text must be ≤100 chars' } };
988
+ if (bodyText && bodyText.length > 140) {
989
+ return { status: 400, body: { error: 'body_text must be ≤140 chars' } };
936
990
  }
991
+ const currentConversationId = getCurrentConversationId(req, body);
937
992
  try {
938
- const data = await api.publishBriefing({ actingAgentId, bodyText, bodyHtml });
993
+ const data = await api.publishBriefing({
994
+ actingAgentId,
995
+ bodyText,
996
+ attachmentAssetId,
997
+ currentConversationId,
998
+ });
939
999
  return { status: 200, body: data };
940
1000
  } catch (err) {
941
1001
  return { status: err?.status || 500, body: { error: err?.message || 'briefing publish failed' } };
package/src/core/http.mjs CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  handleWorkstreamCreate,
9
9
  handleWorkstreamDelete,
10
10
  handleWorkstreamList,
11
+ handleAgentList,
11
12
  handleAgentCreate,
12
13
  handleAgentDelete,
13
14
  handleWorkstreamDashboardSet,
@@ -267,6 +268,10 @@ export function startLocalHttpServer({ port, adapter, ctx }) {
267
268
  const r = await handleWorkstreamList(req, parseQuery(req.url || ''), cliCtx);
268
269
  return writeJson(res, r.status, r.body);
269
270
  }
271
+ if (urlNoQuery === '/agent/agent/list' && method === 'GET') {
272
+ const r = await handleAgentList(req, parseQuery(req.url || ''), cliCtx);
273
+ return writeJson(res, r.status, r.body);
274
+ }
270
275
  if (urlNoQuery === '/agent/agent/create' && method === 'POST') {
271
276
  const body = await readJsonBody(req);
272
277
  if (body === null) return writeJson(res, 400, { error: 'invalid json body' });
@@ -15,6 +15,7 @@
15
15
  const STRIPPED_KEYS = new Set([
16
16
  'TICLAWK_CONNECTOR_API_KEY',
17
17
  'TICLAWK_CONNECTOR_WS_URL',
18
+ 'TICLAWK_CREDENTIAL_NAMES',
18
19
  'TICLAWK_SETUP_CODE',
19
20
  ]);
20
21
 
@@ -35,11 +36,17 @@ export function buildAgentRuntimeEnv({
35
36
  sessionId,
36
37
  hostId,
37
38
  daemonUrl,
39
+ conversationId,
40
+ messageId,
41
+ target,
38
42
  } = {}) {
39
43
  const out = {};
40
44
  if (agentId) out.TICLAWK_RUNTIME_AGENT_ID = String(agentId);
41
45
  if (sessionId) out.TICLAWK_RUNTIME_SESSION_ID = String(sessionId);
42
46
  if (hostId) out.TICLAWK_RUNTIME_HOST_ID = String(hostId);
47
+ if (conversationId) out.TICLAWK_RUNTIME_CONVERSATION_ID = String(conversationId);
48
+ if (messageId) out.TICLAWK_RUNTIME_MESSAGE_ID = String(messageId);
49
+ if (target) out.TICLAWK_RUNTIME_TARGET = String(target);
43
50
  out.TICLAWK_RUNTIME_DAEMON_URL = daemonUrl || 'http://127.0.0.1:8741';
44
51
  return out;
45
52
  }