@integrity-labs/agt-cli 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,14 @@ import {
6
6
  exchangeApiKey,
7
7
  extractCommandNotFound,
8
8
  extractFrontmatter,
9
+ formatActorId,
9
10
  getApiKey,
10
11
  getFramework,
11
12
  getHostId,
12
13
  getIntegration,
13
14
  isParseError,
14
15
  isResolveError,
16
+ isSelfCompletion,
15
17
  parseDeliveryTarget,
16
18
  provision,
17
19
  provisionIsolationHook,
@@ -20,7 +22,7 @@ import {
20
22
  resolveChannels,
21
23
  resolveDmTarget,
22
24
  wrapScheduledTaskPrompt
23
- } from "../chunk-IQI7XAQ6.js";
25
+ } from "../chunk-WDF7NJ2F.js";
24
26
  import {
25
27
  findTaskByTemplate,
26
28
  getProjectDir,
@@ -1042,8 +1044,21 @@ function startRealtimeConfig(config2) {
1042
1044
  });
1043
1045
  log2(`[realtime] Subscribing to agents table for ${agentIds.length} agent(s)`);
1044
1046
  }
1047
+ var METRICS_WINDOW = 200;
1048
+ var kanbanMetrics = {
1049
+ delivered: 0,
1050
+ suppressedSelfActor: 0,
1051
+ dropped: 0,
1052
+ latencies: []
1053
+ };
1054
+ function recordLatency(ms) {
1055
+ kanbanMetrics.latencies.push(ms);
1056
+ if (kanbanMetrics.latencies.length > METRICS_WINDOW) {
1057
+ kanbanMetrics.latencies.shift();
1058
+ }
1059
+ }
1045
1060
  function startRealtimeKanban(config2) {
1046
- const { agentIds, onTodayItem, log: log2 } = config2;
1061
+ const { agentIds, onTodayItem, onCompletion, log: log2 } = config2;
1047
1062
  if (agentIds.length === 0) return;
1048
1063
  const sb = ensureClient(config2);
1049
1064
  const filterStr = agentIds.length === 1 ? `agent_id=eq.${agentIds[0]}` : `agent_id=in.(${agentIds.join(",")})`;
@@ -1070,6 +1085,33 @@ function startRealtimeKanban(config2) {
1070
1085
  log2(`[realtime] Kanban item moved to 'today': "${item.title}" for agent ${item.agent_id}`);
1071
1086
  onTodayItem(item);
1072
1087
  }
1088
+ if (onCompletion && (item.status === "done" || item.status === "failed") && old.status !== item.status) {
1089
+ const event = {
1090
+ agent_id: item.agent_id,
1091
+ item_id: item.id,
1092
+ status: item.status,
1093
+ last_actor_id: item.last_actor_id ?? null,
1094
+ completed_at: item.completed_at ?? null,
1095
+ title: item.title
1096
+ };
1097
+ if (isSelfCompletion(event)) {
1098
+ kanbanMetrics.suppressedSelfActor++;
1099
+ return;
1100
+ }
1101
+ const commitTs = payload.commit_timestamp;
1102
+ const latencyMs = commitTs ? Math.max(0, Date.now() - new Date(commitTs).getTime()) : 0;
1103
+ try {
1104
+ onCompletion(event);
1105
+ recordLatency(latencyMs);
1106
+ kanbanMetrics.delivered++;
1107
+ log2(
1108
+ `[realtime] Kanban completion: agent=${item.agent_id} item=${item.id} status=${item.status} actor=${item.last_actor_id ?? "unknown"} latency_ms=${latencyMs}`
1109
+ );
1110
+ } catch (err) {
1111
+ kanbanMetrics.dropped++;
1112
+ log2(`[realtime] Kanban completion handler error: ${err.message}`);
1113
+ }
1114
+ }
1073
1115
  }).subscribe((status) => {
1074
1116
  if (status === "SUBSCRIBED") {
1075
1117
  log2("[realtime] Kanban channel connected");
@@ -1078,6 +1120,7 @@ function startRealtimeKanban(config2) {
1078
1120
  }
1079
1121
  });
1080
1122
  log2(`[realtime] Subscribing to agent_kanban_items for ${agentIds.length} agent(s)`);
1123
+ void formatActorId;
1081
1124
  }
1082
1125
  function startRealtimePluginContext(config2) {
1083
1126
  const { agentIds, onContextChange, log: log2 } = config2;
@@ -3987,6 +4030,18 @@ function ensureRealtimeKanbanStarted(agentStates) {
3987
4030
  }
3988
4031
  }
3989
4032
  },
4033
+ // ENG-4507: kanban completion notification — surfaces user-driven
4034
+ // closures to the daemon log + telemetry surface. The agent-runtime
4035
+ // ingestion path is the kanban_list `closed_by` annotation (no live
4036
+ // injection in this slice — the agent reads its board between turns
4037
+ // and sees the new state naturally).
4038
+ onCompletion: (event) => {
4039
+ const agent = agentStates.find((a) => a.agentId === event.agent_id);
4040
+ const codeName = agent?.codeName ?? event.agent_id;
4041
+ log(
4042
+ `[realtime] Kanban completion forwarded for '${codeName}': item=${event.item_id} status=${event.status} actor=${event.last_actor_id ?? "unknown"}`
4043
+ );
4044
+ },
3990
4045
  log
3991
4046
  });
3992
4047
  realtimeKanbanStarted = true;
@@ -5090,6 +5145,7 @@ function generateArtifacts(agent, refreshData, adapter) {
5090
5145
  reportsTo,
5091
5146
  personalitySeed,
5092
5147
  knowledge: (refreshData.knowledge ?? []).filter((k) => !!k.content),
5148
+ knowledgeDelivery: refreshData.agent.knowledge_delivery ?? "both",
5093
5149
  teamMembers: refreshData.team_members ?? void 0,
5094
5150
  people: refreshData.people ?? void 0
5095
5151
  };