@agentchatme/agent-core 0.6.0 → 0.7.1

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/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  AGENT_LOCK_DIR_ENV,
3
+ COULD_NOT_PROCESS_FILE,
3
4
  DAEMON_LOCK_FILE,
4
5
  DEFAULT_API_BASE,
5
6
  FAILED_CYCLE_OUTCOMES,
6
7
  HEARTBEAT_FILE,
7
8
  INTEGRATION_STATUS_FILE,
9
+ INTEGRATION_STATUS_STALE_MS,
8
10
  LEASE_RENEW_MS,
9
11
  LEASE_STALE_MS,
10
12
  LEGACY_STATUS_FILE,
@@ -15,6 +17,7 @@ import {
15
17
  MANUAL_MAX_REDIRECTS,
16
18
  MANUAL_SKILL_NAME,
17
19
  MANUAL_URL,
20
+ PausedConversations,
18
21
  REPEATED_FAILED_CYCLES,
19
22
  SOCKET_STATES,
20
23
  STANDBY_MARKER_FRESH_MS,
@@ -39,8 +42,11 @@ import {
39
42
  clearIntegrationStatus,
40
43
  clearPending,
41
44
  clearStandby,
45
+ couldNotProcessPath,
42
46
  credentialsPath,
47
+ describeCouldNotProcessCounts,
43
48
  describeManualSync,
49
+ describePausedConversations,
44
50
  envApiKey,
45
51
  envKeyConflict,
46
52
  external_exports,
@@ -53,7 +59,9 @@ import {
53
59
  identityLineOf,
54
60
  idle,
55
61
  integrationStatusAge,
62
+ integrationStatusFresh,
56
63
  integrationStatusPath,
64
+ integrationStatusStaleFor,
57
65
  isRunnerFactory,
58
66
  leaseHolder,
59
67
  loadTexts,
@@ -74,8 +82,10 @@ import {
74
82
  readIntegrationStatus,
75
83
  readManualVersion,
76
84
  readPending,
85
+ repeatedFailedRuns,
77
86
  resetLeaseObservations,
78
87
  resolveIdentity,
88
+ runtimeCheckFailingNow,
79
89
  standbyMarkerPath,
80
90
  standbyWaiting,
81
91
  statePath,
@@ -84,7 +94,7 @@ import {
84
94
  writeCredentials,
85
95
  writeIntegrationStatus,
86
96
  writePending
87
- } from "./chunk-EDB33Z22.js";
97
+ } from "./chunk-AQTRC7G4.js";
88
98
  import {
89
99
  HOSTED_MCP_PATH,
90
100
  PROBE_KILL_WAIT_MS,
@@ -92,7 +102,7 @@ import {
92
102
  hostedMcpUrl,
93
103
  probeHostedMcp,
94
104
  runProbe
95
- } from "./chunk-QUANHUVW.js";
105
+ } from "./chunk-4PCDVXAR.js";
96
106
  import {
97
107
  DEFAULT_RUN_BUDGET_MS,
98
108
  DEFAULT_RUN_PROFILE,
@@ -123,7 +133,7 @@ import {
123
133
  spawnCommand,
124
134
  spawnCommandSync,
125
135
  workdirExposesHome
126
- } from "./chunk-AVLI55C5.js";
136
+ } from "./chunk-5KMQ23O6.js";
127
137
 
128
138
  // src/integration/tray.ts
129
139
  import { INBOX_TRAY_MAX_LIMIT } from "agentchatme";
@@ -364,6 +374,26 @@ function renderDeclinedBlock(copy) {
364
374
  ].join("\n");
365
375
  }
366
376
 
377
+ // src/integration/run-context.ts
378
+ var RUN_CONTEXT_ENV = {
379
+ wakeKind: "AGENTCHAT_WAKE_KIND",
380
+ runId: "AGENTCHAT_RUN_ID",
381
+ conversationId: "AGENTCHAT_CONVERSATION_ID"
382
+ };
383
+ function without(env, name) {
384
+ for (const key of Object.keys(env)) if (key.toUpperCase() === name) delete env[key];
385
+ }
386
+ function runContextEnv(env, request) {
387
+ const out = { ...env };
388
+ for (const name of Object.values(RUN_CONTEXT_ENV)) without(out, name);
389
+ out[RUN_CONTEXT_ENV.wakeKind] = request.kind;
390
+ out[RUN_CONTEXT_ENV.runId] = request.runId;
391
+ if (request.kind === "conversation" && request.conversationId !== void 0 && request.conversationId.length > 0) {
392
+ out[RUN_CONTEXT_ENV.conversationId] = request.conversationId;
393
+ }
394
+ return out;
395
+ }
396
+
367
397
  // src/identity/commands.ts
368
398
  import * as readline from "readline";
369
399
  import { AgentChatClient, integration as kit2 } from "agentchatme";
@@ -1089,6 +1119,38 @@ The key was not saved.`);
1089
1119
  } : { name: "wake-cycles", verdict: "PASS", detail: `last cycle ${last.outcome} at ${last.at} (${cycles.length} recent)` }
1090
1120
  );
1091
1121
  }
1122
+ const failedRuns = repeatedFailedRuns(integration);
1123
+ if (failedRuns !== null) {
1124
+ const lastRun = integration?.last_run ?? null;
1125
+ checks.push({
1126
+ name: "runs",
1127
+ verdict: "WARN",
1128
+ detail: `the last ${failedRuns} runs did not get done${lastRun !== null ? ` (latest: ${lastRun.state}${lastRun.detail ? ` \u2014 ${lastRun.detail}` : ""})` : ""}; the cards stay on the tray`
1129
+ });
1130
+ }
1131
+ const cnp = integration?.could_not_process ?? null;
1132
+ if (cnp !== null) {
1133
+ const paused = describePausedConversations(cnp.paused_conversations);
1134
+ const lastCheck = cnp.last_runtime_check;
1135
+ const counts = describeCouldNotProcessCounts(cnp);
1136
+ if (paused !== null) {
1137
+ checks.push({ name: "could-not-process", verdict: "WARN", detail: paused.replace(/^could not process: /, "") });
1138
+ } else if (lastCheck !== null && runtimeCheckFailingNow(integration)) {
1139
+ checks.push(
1140
+ integrationStatusFresh(integration) ? {
1141
+ name: "could-not-process",
1142
+ verdict: "WARN",
1143
+ detail: `the runtime check failed (${lastCheck.detail ?? "no detail"}; ${lastCheck.at}): while it fails, a conversation whose run fails is not reported, its card stays on the tray and the server wakes the agent again`
1144
+ } : {
1145
+ name: "could-not-process",
1146
+ verdict: "WARN",
1147
+ detail: `the daemon has not written its status for ${integrationStatusStaleFor(integration)} \u2014 it may be down (a running daemon rewrites it every 30 s); the runtime check that failed at ${lastCheck.at} says nothing about now`
1148
+ }
1149
+ );
1150
+ } else if (counts !== null) {
1151
+ checks.push({ name: "could-not-process", verdict: "PASS", detail: counts.replace(/^could not process: /, "") });
1152
+ }
1153
+ }
1092
1154
  if (profile.extraDoctorChecks !== void 0) {
1093
1155
  try {
1094
1156
  checks.push(...await profile.extraDoctorChecks({ ...opts, ...texts }));
@@ -1764,6 +1826,7 @@ export {
1764
1826
  AGENT_LOCK_DIR_ENV,
1765
1827
  ANCHOR_END,
1766
1828
  ANCHOR_START,
1829
+ COULD_NOT_PROCESS_FILE,
1767
1830
  DAEMON_LOCK_FILE,
1768
1831
  DEFAULT_API_BASE,
1769
1832
  DEFAULT_RUN_BUDGET_MS,
@@ -1776,6 +1839,7 @@ export {
1776
1839
  INTEGRATION_ENV_LEGACY,
1777
1840
  INTEGRATION_ENV_LEGACY_REMOVAL,
1778
1841
  INTEGRATION_STATUS_FILE,
1842
+ INTEGRATION_STATUS_STALE_MS,
1779
1843
  LEASE_RENEW_MS,
1780
1844
  LEASE_STALE_MS,
1781
1845
  LEGACY_STATUS_FILE,
@@ -1789,8 +1853,10 @@ export {
1789
1853
  OWN_RUN_WARNING,
1790
1854
  PEER_RUN_WARNING,
1791
1855
  PROBE_KILL_WAIT_MS,
1856
+ PausedConversations,
1792
1857
  REPEATED_FAILED_CYCLES,
1793
1858
  RUN_BUDGET_ENV,
1859
+ RUN_CONTEXT_ENV,
1794
1860
  RUN_PROFILES,
1795
1861
  RUN_PROFILE_ENV,
1796
1862
  SOCKET_STATES,
@@ -1825,9 +1891,12 @@ export {
1825
1891
  clientHeadersOf,
1826
1892
  clientIdentityOf,
1827
1893
  clientNameOf,
1894
+ couldNotProcessPath,
1828
1895
  createIdentityCommands,
1829
1896
  credentialsPath,
1897
+ describeCouldNotProcessCounts,
1830
1898
  describeManualSync,
1899
+ describePausedConversations,
1831
1900
  describeRunProfile,
1832
1901
  envApiKey,
1833
1902
  envKeyConflict,
@@ -1845,7 +1914,9 @@ export {
1845
1914
  integrationDisabled,
1846
1915
  integrationDisabledBy,
1847
1916
  integrationStatusAge,
1917
+ integrationStatusFresh,
1848
1918
  integrationStatusPath,
1919
+ integrationStatusStaleFor,
1849
1920
  isRunProfile,
1850
1921
  isRunnerFactory,
1851
1922
  launchdPlist,
@@ -1883,12 +1954,15 @@ export {
1883
1954
  renderAnchorBlock,
1884
1955
  renderDeclinedBlock,
1885
1956
  renderUnregisteredBlock,
1957
+ repeatedFailedRuns,
1886
1958
  resetLeaseObservations,
1887
1959
  resolveIdentity,
1888
1960
  resolveRunBudgetMs,
1889
1961
  resolveRunProfile,
1962
+ runContextEnv,
1890
1963
  runProbe,
1891
1964
  runProfileWarning,
1965
+ runtimeCheckFailingNow,
1892
1966
  serviceDefinitionCurrent,
1893
1967
  serviceInstalled,
1894
1968
  serviceLabelFor,