@phnx-labs/agents-cli 1.23.28 → 1.23.30

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 (171) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +33 -82
  3. package/dist/bootstrap.js +0 -17
  4. package/dist/cli/command-registry.js +0 -2
  5. package/dist/commands/cloud.js +0 -58
  6. package/dist/commands/config.js +0 -4
  7. package/dist/commands/daemon-index.js +1 -1
  8. package/dist/commands/daemon.js +14 -63
  9. package/dist/commands/doctor.js +0 -12
  10. package/dist/commands/events.js +1 -1
  11. package/dist/commands/feed.d.ts +1 -3
  12. package/dist/commands/feed.js +1 -6
  13. package/dist/commands/fleet-capture.js +2 -4
  14. package/dist/commands/focus.d.ts +0 -1
  15. package/dist/commands/focus.js +2 -4
  16. package/dist/commands/inspect.d.ts +1 -19
  17. package/dist/commands/inspect.js +8 -474
  18. package/dist/commands/mine.js +1 -1
  19. package/dist/commands/prune.js +2 -64
  20. package/dist/commands/ps-roster.d.ts +0 -4
  21. package/dist/commands/ps-roster.js +2 -30
  22. package/dist/commands/ps.js +1 -4
  23. package/dist/commands/repo.d.ts +1 -1
  24. package/dist/commands/repo.js +4 -4
  25. package/dist/commands/sessions-browser.d.ts +0 -2
  26. package/dist/commands/sessions-browser.js +2 -32
  27. package/dist/commands/sessions-optimize.js +3 -4
  28. package/dist/commands/setup-mine.js +0 -1
  29. package/dist/commands/ssh.js +8 -9
  30. package/dist/commands/sync.js +1 -1
  31. package/dist/commands/update.js +2 -2
  32. package/dist/commands/watchdog.js +3 -4
  33. package/dist/lib/accounting/rotate.d.ts +0 -2
  34. package/dist/lib/accounting/rotate.js +1 -4
  35. package/dist/lib/agent-spec/agents.d.ts +0 -1
  36. package/dist/lib/agent-spec/agents.js +0 -8
  37. package/dist/lib/answer-router.d.ts +1 -1
  38. package/dist/lib/answer-router.js +9 -10
  39. package/dist/lib/auth-health.d.ts +0 -1
  40. package/dist/lib/auth-health.js +0 -3
  41. package/dist/lib/cli-entry.d.ts +0 -1
  42. package/dist/lib/cli-entry.js +0 -36
  43. package/dist/lib/cloud/types.d.ts +0 -2
  44. package/dist/lib/config-keys.d.ts +1 -1
  45. package/dist/lib/config-keys.js +1 -4
  46. package/dist/lib/daemon/daemon.d.ts +0 -4
  47. package/dist/lib/daemon/daemon.js +6 -202
  48. package/dist/lib/daemon/heartbeat-service.d.ts +1 -1
  49. package/dist/lib/daemon/heartbeat-service.js +1 -8
  50. package/dist/lib/daemon-services.d.ts +1 -1
  51. package/dist/lib/daemon-services.js +1 -11
  52. package/dist/lib/device-config.d.ts +0 -2
  53. package/dist/lib/device-config.js +4 -22
  54. package/dist/lib/devices/config-migration.js +1 -3
  55. package/dist/lib/exec.d.ts +2 -5
  56. package/dist/lib/exec.js +18 -18
  57. package/dist/lib/factory/snapshot.d.ts +0 -5
  58. package/dist/lib/factory/snapshot.js +1 -28
  59. package/dist/lib/feed/events.d.ts +1 -11
  60. package/dist/lib/feed/events.js +0 -20
  61. package/dist/lib/feed/feed.d.ts +1 -3
  62. package/dist/lib/feed/feed.js +18 -1
  63. package/dist/lib/feed-outcome.d.ts +0 -2
  64. package/dist/lib/feed-outcome.js +0 -5
  65. package/dist/lib/fleet/capture.d.ts +0 -1
  66. package/dist/lib/fleet/capture.js +0 -3
  67. package/dist/lib/fleet/manifest.js +0 -6
  68. package/dist/lib/fleet/types.d.ts +0 -1
  69. package/dist/lib/harness/adapter.d.ts +0 -7
  70. package/dist/lib/harness/adapters/claude.js +0 -18
  71. package/dist/lib/harness/adapters/codex.js +0 -10
  72. package/dist/lib/harness/adapters/cursor.js +0 -11
  73. package/dist/lib/harness/adapters/kimi.js +0 -3
  74. package/dist/lib/harness/adapters/muse.js +0 -11
  75. package/dist/lib/harness/index.d.ts +1 -1
  76. package/dist/lib/harness/index.js +0 -2
  77. package/dist/lib/hosts/passthrough.js +2 -10
  78. package/dist/lib/hosts/ready.d.ts +0 -4
  79. package/dist/lib/hosts/ready.js +0 -9
  80. package/dist/lib/hosts/reconcile.d.ts +0 -1
  81. package/dist/lib/hosts/reconcile.js +0 -8
  82. package/dist/lib/installations/migrate.d.ts +0 -2
  83. package/dist/lib/installations/migrate.js +0 -145
  84. package/dist/lib/loop.js +1 -2
  85. package/dist/lib/menubar/snapshot.d.ts +0 -1
  86. package/dist/lib/menubar/snapshot.js +1 -4
  87. package/dist/lib/placement.d.ts +1 -2
  88. package/dist/lib/placement.js +4 -24
  89. package/dist/lib/profiles.d.ts +0 -1
  90. package/dist/lib/profiles.js +0 -6
  91. package/dist/lib/session/active.d.ts +4 -3
  92. package/dist/lib/session/active.js +3 -4
  93. package/dist/lib/session/db.d.ts +7 -5
  94. package/dist/lib/session/db.js +11 -14
  95. package/dist/lib/session/discover.d.ts +3 -2
  96. package/dist/lib/session/discover.js +12 -129
  97. package/dist/lib/session/live-metadata.js +0 -2
  98. package/dist/lib/session/presentation.d.ts +0 -1
  99. package/dist/lib/session/presentation.js +3 -8
  100. package/dist/lib/session/selection.d.ts +0 -2
  101. package/dist/lib/session/selection.js +2 -12
  102. package/dist/lib/session/session-cache.d.ts +2 -1
  103. package/dist/lib/session/session-cache.js +1 -0
  104. package/dist/lib/session/title.d.ts +10 -0
  105. package/dist/lib/session/title.js +9 -0
  106. package/dist/lib/staleness/detectors/commands.d.ts +1 -1
  107. package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
  108. package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
  109. package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
  110. package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
  111. package/dist/lib/staleness/detectors/rules.d.ts +1 -1
  112. package/dist/lib/staleness/detectors/skills.d.ts +1 -1
  113. package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
  114. package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
  115. package/dist/lib/staleness/writers/commands.d.ts +1 -1
  116. package/dist/lib/staleness/writers/hooks.d.ts +1 -1
  117. package/dist/lib/staleness/writers/mcp.d.ts +1 -1
  118. package/dist/lib/staleness/writers/permissions.d.ts +1 -1
  119. package/dist/lib/staleness/writers/plugins.d.ts +1 -1
  120. package/dist/lib/staleness/writers/rules.d.ts +1 -1
  121. package/dist/lib/staleness/writers/skills.d.ts +1 -1
  122. package/dist/lib/staleness/writers/subagents.d.ts +1 -1
  123. package/dist/lib/staleness/writers/workflows.d.ts +1 -1
  124. package/dist/lib/startup/command-registry.js +5 -2
  125. package/dist/lib/state.d.ts +0 -3
  126. package/dist/lib/state.js +2 -25
  127. package/dist/lib/types.d.ts +0 -1
  128. package/dist/lib/watchdog/runner.d.ts +0 -2
  129. package/dist/lib/watchdog/runner.js +0 -2
  130. package/package.json +2 -2
  131. package/scripts/postinstall.js +2 -2
  132. package/dist/commands/routines.d.ts +0 -14
  133. package/dist/commands/routines.js +0 -2149
  134. package/dist/commands/routines.test-fixture.d.ts +0 -52
  135. package/dist/commands/routines.test-fixture.js +0 -254
  136. package/dist/lib/catchup.d.ts +0 -19
  137. package/dist/lib/catchup.js +0 -83
  138. package/dist/lib/daemon/catchup-service.d.ts +0 -18
  139. package/dist/lib/daemon/catchup-service.js +0 -21
  140. package/dist/lib/daemon/runner.d.ts +0 -91
  141. package/dist/lib/daemon/runner.js +0 -1927
  142. package/dist/lib/harness/adapters/droid.d.ts +0 -2
  143. package/dist/lib/harness/adapters/droid.js +0 -14
  144. package/dist/lib/overdue.d.ts +0 -9
  145. package/dist/lib/overdue.js +0 -74
  146. package/dist/lib/routine-activation.d.ts +0 -13
  147. package/dist/lib/routine-activation.js +0 -117
  148. package/dist/lib/routine-context.d.ts +0 -59
  149. package/dist/lib/routine-context.js +0 -181
  150. package/dist/lib/routine-notify-owner.d.ts +0 -4
  151. package/dist/lib/routine-notify-owner.js +0 -49
  152. package/dist/lib/routine-notify.d.ts +0 -17
  153. package/dist/lib/routine-notify.js +0 -138
  154. package/dist/lib/routine-process-cleanup.d.ts +0 -9
  155. package/dist/lib/routine-process-cleanup.js +0 -81
  156. package/dist/lib/routine-readiness.d.ts +0 -31
  157. package/dist/lib/routine-readiness.js +0 -256
  158. package/dist/lib/routines-format.d.ts +0 -7
  159. package/dist/lib/routines-format.js +0 -127
  160. package/dist/lib/routines-placement.d.ts +0 -16
  161. package/dist/lib/routines-placement.js +0 -60
  162. package/dist/lib/routines-project.d.ts +0 -49
  163. package/dist/lib/routines-project.js +0 -306
  164. package/dist/lib/sandbox.d.ts +0 -15
  165. package/dist/lib/sandbox.js +0 -309
  166. package/dist/lib/scheduler.d.ts +0 -23
  167. package/dist/lib/scheduler.js +0 -106
  168. package/dist/lib/scheduling/routines.d.ts +0 -264
  169. package/dist/lib/scheduling/routines.js +0 -1292
  170. package/dist/lib/triggers/webhook.d.ts +0 -26
  171. package/dist/lib/triggers/webhook.js +0 -181
@@ -1,26 +0,0 @@
1
- import type { JobConfig, RunMeta } from '../scheduling/routines.js';
2
- export type WebhookSource = 'github' | 'linear';
3
- export interface IncomingWebhook {
4
- source: WebhookSource;
5
- event: string;
6
- payload: Record<string, unknown>;
7
- }
8
- export declare function webhookRepo(payload: Record<string, unknown>): string | null;
9
- export declare function webhookBranches(event: string, payload: Record<string, unknown>): string[];
10
- export declare function linearAction(payload: Record<string, unknown>): string | null;
11
- export declare function linearTeamKey(payload: Record<string, unknown>): string | null;
12
- export declare function linearLabels(payload: Record<string, unknown>): string[];
13
- export declare function githubAction(payload: Record<string, unknown>): string | null;
14
- export declare function githubLabels(payload: Record<string, unknown>): string[];
15
- export declare function jobMatchesWebhook(job: JobConfig, webhook: IncomingWebhook): boolean;
16
- export declare function matchJobsToWebhook(jobs: JobConfig[], webhook: IncomingWebhook): JobConfig[];
17
- export interface FireWebhookOptions {
18
- jobs?: JobConfig[];
19
- dispatch?: (config: JobConfig) => Promise<RunMeta>;
20
- }
21
- interface FiredJob {
22
- jobName: string;
23
- runId: string;
24
- }
25
- export declare function fireWebhookJobs(webhook: IncomingWebhook, options?: FireWebhookOptions): Promise<FiredJob[]>;
26
- export {};
@@ -1,181 +0,0 @@
1
- import { jobRunsOnThisDevice, listJobs } from '../scheduling/routines.js';
2
- import { executeJobDetached } from '../daemon/runner.js';
3
- import { emit } from '../feed/events.js';
4
- export function webhookRepo(payload) {
5
- const repo = payload?.repository;
6
- const fullName = repo?.full_name;
7
- return typeof fullName === 'string' && fullName.length > 0 ? fullName : null;
8
- }
9
- function shortRef(ref) {
10
- return ref.replace(/^refs\/(heads|tags)\//, '');
11
- }
12
- export function webhookBranches(event, payload) {
13
- const branches = new Set();
14
- const add = (v) => {
15
- if (typeof v === 'string' && v.length > 0)
16
- branches.add(shortRef(v));
17
- };
18
- switch (event) {
19
- case 'push':
20
- add(payload.ref);
21
- break;
22
- case 'pull_request': {
23
- const pr = payload.pull_request;
24
- add(pr?.base?.ref);
25
- add(pr?.head?.ref);
26
- break;
27
- }
28
- case 'workflow_run': {
29
- const run = payload.workflow_run;
30
- add(run?.head_branch);
31
- break;
32
- }
33
- default:
34
- break;
35
- }
36
- return [...branches];
37
- }
38
- export function linearAction(payload) {
39
- return typeof payload.action === 'string' ? payload.action : null;
40
- }
41
- export function linearTeamKey(payload) {
42
- const data = payload.data;
43
- const identifier = data?.identifier;
44
- if (typeof identifier === 'string') {
45
- const match = /^([A-Z][A-Z0-9]*)-\d+$/.exec(identifier);
46
- if (match)
47
- return match[1];
48
- }
49
- const team = data?.team;
50
- return typeof team?.key === 'string' ? team.key : null;
51
- }
52
- export function linearLabels(payload) {
53
- const data = payload.data;
54
- const labels = Array.isArray(data?.labels) ? data?.labels : [];
55
- return labels
56
- .map((n) => n.name)
57
- .filter((n) => typeof n === 'string' && n.length > 0);
58
- }
59
- export function githubAction(payload) {
60
- return typeof payload.action === 'string' ? payload.action : null;
61
- }
62
- export function githubLabels(payload) {
63
- const names = new Set();
64
- const add = (value) => {
65
- if (typeof value === 'string' && value.length > 0)
66
- names.add(value);
67
- };
68
- const deliveryLabel = payload.label;
69
- add(deliveryLabel?.name);
70
- const pr = payload.pull_request;
71
- const prLabels = Array.isArray(pr?.labels) ? pr.labels : [];
72
- for (const label of prLabels) {
73
- add(label.name);
74
- }
75
- const issue = payload.issue;
76
- const issueLabels = Array.isArray(issue?.labels) ? issue.labels : [];
77
- for (const label of issueLabels) {
78
- add(label.name);
79
- }
80
- return [...names];
81
- }
82
- function githubTriggerMatches(trigger, webhook) {
83
- if (webhook.source !== 'github')
84
- return false;
85
- if (trigger.event !== webhook.event)
86
- return false;
87
- if (trigger.action && githubAction(webhook.payload) !== trigger.action)
88
- return false;
89
- if (trigger.repo) {
90
- const repo = webhookRepo(webhook.payload);
91
- if (!repo || repo.toLowerCase() !== trigger.repo.toLowerCase())
92
- return false;
93
- }
94
- if (trigger.branch) {
95
- const branches = webhookBranches(webhook.event, webhook.payload);
96
- if (!branches.some((b) => b === trigger.branch))
97
- return false;
98
- }
99
- if (trigger.label) {
100
- const expected = trigger.label.toLowerCase();
101
- if (!githubLabels(webhook.payload).some((name) => name.toLowerCase() === expected))
102
- return false;
103
- }
104
- return true;
105
- }
106
- function linearTriggerMatches(trigger, webhook) {
107
- if (webhook.source !== 'linear')
108
- return false;
109
- if (trigger.event !== webhook.event)
110
- return false;
111
- if (trigger.action && linearAction(webhook.payload) !== trigger.action)
112
- return false;
113
- if (trigger.teamKey && linearTeamKey(webhook.payload) !== trigger.teamKey)
114
- return false;
115
- if (trigger.label) {
116
- const expected = trigger.label.toLowerCase();
117
- if (!linearLabels(webhook.payload).some((name) => name.toLowerCase() === expected))
118
- return false;
119
- }
120
- if (trigger.stateTo) {
121
- const data = webhook.payload.data;
122
- const current = data?.state?.name;
123
- if (current !== trigger.stateTo)
124
- return false;
125
- const updatedTo = webhook.payload.updatedFrom;
126
- if (!updatedTo || (updatedTo.state === undefined && updatedTo.stateId === undefined))
127
- return false;
128
- }
129
- if (trigger.stateFrom) {
130
- const updatedFrom = webhook.payload.updatedFrom;
131
- const previous = updatedFrom?.state?.name;
132
- if (previous !== trigger.stateFrom)
133
- return false;
134
- }
135
- return true;
136
- }
137
- export function jobMatchesWebhook(job, webhook) {
138
- const trigger = job.trigger;
139
- if (!trigger)
140
- return false;
141
- if (trigger.type === 'github_event')
142
- return githubTriggerMatches(trigger, webhook);
143
- if (trigger.type === 'linear_event')
144
- return linearTriggerMatches(trigger, webhook);
145
- return false;
146
- }
147
- export function matchJobsToWebhook(jobs, webhook) {
148
- return jobs.filter((job) => job.enabled !== false && jobRunsOnThisDevice(job) && jobMatchesWebhook(job, webhook));
149
- }
150
- class WebhookDispatchError extends Error {
151
- fired;
152
- failures;
153
- constructor(message, fired, failures) {
154
- super(message);
155
- this.fired = fired;
156
- this.failures = failures;
157
- this.name = 'WebhookDispatchError';
158
- }
159
- }
160
- export async function fireWebhookJobs(webhook, options = {}) {
161
- const jobs = options.jobs ?? listJobs();
162
- const dispatch = options.dispatch ?? executeJobDetached;
163
- const matched = matchJobsToWebhook(jobs, webhook);
164
- const fired = [];
165
- const failures = [];
166
- for (const job of matched) {
167
- emit('webhook.matched', { source: webhook.source, event: webhook.event, jobName: job.name });
168
- try {
169
- const meta = await dispatch(job);
170
- const firedJob = { jobName: job.name, runId: meta.runId };
171
- fired.push(firedJob);
172
- }
173
- catch (err) {
174
- failures.push({ jobName: job.name, error: err });
175
- }
176
- }
177
- if (failures.length > 0) {
178
- throw new WebhookDispatchError(`failed to dispatch ${failures.length} webhook routine(s): ${failures.map((f) => f.jobName).join(', ')}`, fired, failures);
179
- }
180
- return fired;
181
- }