agent-things 0.0.0-stage → 1.2.2

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 (124) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +5 -0
  3. package/README.md +221 -2
  4. package/bin/agent-things.cjs +8 -0
  5. package/bin/antigravity-session-status.cjs +96 -0
  6. package/bin/claude-session-status.cjs +55 -0
  7. package/bin/codex-session-status.cjs +287 -0
  8. package/mods/agent-things-ui/.claude-plugin/plugin.json +12 -0
  9. package/mods/agent-things-ui/SKILL.md +10 -0
  10. package/mods/agent-things-ui/hooks/controls.js +112 -0
  11. package/mods/agent-things-ui/hooks/foundation.js +431 -0
  12. package/mods/agent-things-ui/hooks/hooks.json +1 -0
  13. package/mods/agent-things-ui/hooks/presentation.js +223 -0
  14. package/mods/agent-things-ui/hooks/progress.js +1 -0
  15. package/mods/agent-things-ui/hooks/register.js +382 -0
  16. package/native/bin/bridge +0 -0
  17. package/native/bin/bridge.json +20 -0
  18. package/native/session-status-bridge.swift +280 -0
  19. package/outputs/antigravity-session-status.js +2476 -0
  20. package/outputs/codex-session-status.js +1761 -0
  21. package/package.json +75 -4
  22. package/scripts/build-antigravity-bundle.cjs +35 -0
  23. package/scripts/build-codex-bundle.cjs +31 -0
  24. package/scripts/build-native-bridge.cjs +55 -0
  25. package/scripts/build-shared-ui.cjs +16 -0
  26. package/scripts/setup-antigravity-service.cjs +71 -0
  27. package/scripts/setup-claude-service.cjs +21 -0
  28. package/skills/agent-things/SKILL.en.md +95 -0
  29. package/skills/agent-things/SKILL.md +99 -0
  30. package/skills/codex/things/SKILL.en.md +10 -0
  31. package/skills/codex/things/SKILL.md +10 -0
  32. package/skills/things/SKILL.en.md +10 -0
  33. package/skills/things/SKILL.md +10 -0
  34. package/skills/things/checklist.en.md +91 -0
  35. package/skills/things/checklist.md +95 -0
  36. package/src/analysis-app-server.cjs +74 -0
  37. package/src/analysis-assets/output.en.schema.json +93 -0
  38. package/src/analysis-assets/output.schema.json +93 -0
  39. package/src/analysis-assets/prompt.en.txt +17 -0
  40. package/src/analysis-assets/prompt.zh-CN.txt +18 -0
  41. package/src/analysis-budget.cjs +105 -0
  42. package/src/analysis-git.cjs +38 -0
  43. package/src/analysis-history.cjs +150 -0
  44. package/src/analysis-ledger.cjs +82 -0
  45. package/src/analysis-log.cjs +62 -0
  46. package/src/analysis-runner.cjs +203 -0
  47. package/src/analysis-service.cjs +197 -0
  48. package/src/analysis-source.cjs +72 -0
  49. package/src/antigravity-card.cjs +2063 -0
  50. package/src/antigravity-hook.cjs +138 -0
  51. package/src/antigravity-mcp-config.cjs +36 -0
  52. package/src/app-server.cjs +96 -0
  53. package/src/cdp.cjs +115 -0
  54. package/src/claude-inline-install.cjs +38 -0
  55. package/src/claude-mcp-config.cjs +29 -0
  56. package/src/cli/arguments.cjs +30 -0
  57. package/src/cli/environment-probe.cjs +130 -0
  58. package/src/cli/integration-state.cjs +15 -0
  59. package/src/cli/interactive-cli.cjs +236 -0
  60. package/src/cli/prompt-tui.cjs +420 -0
  61. package/src/cli/setup-orchestrator.cjs +449 -0
  62. package/src/codex-mcp-config.cjs +67 -0
  63. package/src/harnesses/antigravity/analysis-profile.cjs +41 -0
  64. package/src/harnesses/antigravity/antigravity-git.cjs +89 -0
  65. package/src/harnesses/antigravity/antigravity-harness.js +1477 -0
  66. package/src/harnesses/antigravity/antigravity-injector.cjs +104 -0
  67. package/src/harnesses/antigravity/antigravity-migration.cjs +235 -0
  68. package/src/harnesses/antigravity/antigravity-service.cjs +357 -0
  69. package/src/harnesses/antigravity/antigravity-title.cjs +155 -0
  70. package/src/harnesses/antigravity/gemini-runner.cjs +304 -0
  71. package/src/harnesses/antigravity/transcript-cleaner.cjs +129 -0
  72. package/src/harnesses/antigravity/transcript-source.cjs +100 -0
  73. package/src/harnesses/claude/claude-harness.js +93 -0
  74. package/src/harnesses/claude/claude-host-helper.cjs +176 -0
  75. package/src/harnesses/claude/claude-injector.cjs +95 -0
  76. package/src/harnesses/claude/claude-local-source.cjs +106 -0
  77. package/src/harnesses/claude/claude-navigation.cjs +99 -0
  78. package/src/harnesses/claude/claude-runner.cjs +74 -0
  79. package/src/harnesses/claude/claude-service.cjs +313 -0
  80. package/src/harnesses/claude/claude-source.cjs +70 -0
  81. package/src/harnesses/codex/codex-analysis.cjs +10 -0
  82. package/src/harnesses/codex/codex-card-bridge.js +123 -0
  83. package/src/harnesses/codex/codex-card-events.cjs +76 -0
  84. package/src/harnesses/codex/codex-card.cjs +169 -0
  85. package/src/harnesses/codex/codex-git.cjs +24 -0
  86. package/src/harnesses/codex/codex-harness.js +229 -0
  87. package/src/harnesses/codex/codex-local-card.js +97 -0
  88. package/src/harnesses/codex/codex-progress-context.cjs +84 -0
  89. package/src/harnesses/codex/codex-service.cjs +502 -0
  90. package/src/i18n.cjs +174 -0
  91. package/src/launchd.cjs +105 -0
  92. package/src/lifecycle-lock.cjs +13 -0
  93. package/src/local-progress-http.cjs +267 -0
  94. package/src/manual-status-agent.cjs +12 -0
  95. package/src/manual-status-startup.cjs +66 -0
  96. package/src/manual-status-store.cjs +466 -0
  97. package/src/mcp-stdio.cjs +67 -0
  98. package/src/model-router.cjs +63 -0
  99. package/src/native-bridge.cjs +17 -0
  100. package/src/npm-updates.cjs +228 -0
  101. package/src/plugins/things/assets/logo.svg +13 -0
  102. package/src/plugins/things/plugin.json +6 -0
  103. package/src/plugins/things/sidecars/things_board/app.js +447 -0
  104. package/src/plugins/things/sidecars/things_board/index.html +2141 -0
  105. package/src/plugins/things/sidecars/things_board/main.mjs +652 -0
  106. package/src/plugins/things/sidecars/things_board/package.json +6 -0
  107. package/src/plugins/things/sidecars/things_board/sidecar.json +21 -0
  108. package/src/plugins/things/sidecars/things_board/styles.css +560 -0
  109. package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +434 -0
  110. package/src/progress-error.cjs +54 -0
  111. package/src/progress-tools.cjs +145 -0
  112. package/src/project-path.cjs +15 -0
  113. package/src/renderer-resource.cjs +17 -0
  114. package/src/request-budget.cjs +24 -0
  115. package/src/resolve.cjs +51 -0
  116. package/src/runtime-install.cjs +635 -0
  117. package/src/session-status-filter.cjs +136 -0
  118. package/src/session-status.js +992 -0
  119. package/src/session-view.cjs +34 -0
  120. package/src/startup/controller.cjs +354 -0
  121. package/src/startup/watch.cjs +126 -0
  122. package/src/state-file-lock.cjs +31 -0
  123. package/src/task-provenance.cjs +42 -0
  124. package/src/ui-foundation.cjs +435 -0
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const os = require('node:os');
5
+ const crypto = require('node:crypto');
6
+ const { CdpSession, listTargets } = require('../../cdp.cjs');
7
+ const { readRendererResource } = require('../../renderer-resource.cjs');
8
+ const { readConfiguredLang } = require('../../i18n.cjs');
9
+
10
+ class AntigravityInjector {
11
+ constructor(credentials, { allowOrigin = () => {} } = {}) {
12
+ this.credentials = credentials;
13
+ this.allowOrigin = allowOrigin;
14
+ this.sessions = new Map();
15
+ this.scanning = false;
16
+ this.stopped = false;
17
+ }
18
+
19
+ async scan() {
20
+ if (this.scanning || this.stopped) return;
21
+ this.scanning = true;
22
+ try {
23
+ const portFile = path.join(os.homedir(), 'Library/Application Support/Antigravity/DevToolsActivePort');
24
+ if (!fs.existsSync(portFile)) return;
25
+ const port = Number(fs.readFileSync(portFile, 'utf8').split('\n')[0]);
26
+ const targets = (await listTargets(port, 800)).filter(target => {
27
+ if (target.type !== 'page') return false;
28
+ const url = new URL(target.url);
29
+ if (url.protocol === 'vscode-file:' && url.hostname === 'vscode-app') return true;
30
+ return ['http:', 'https:'].includes(url.protocol) && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname) && /^\/(?:c\/|$)/.test(url.pathname);
31
+ });
32
+ const live = new Set(targets.map(target => target.id));
33
+ for (const [id, entry] of this.sessions) if (!live.has(id)) { entry.session.close(); this.sessions.delete(id); }
34
+ const root = path.resolve(__dirname, '../..');
35
+ const lang = readConfiguredLang();
36
+ const connection = {
37
+ origin: `http://127.0.0.1:${this.credentials.port}`,
38
+ token: this.credentials.token,
39
+ brainDir: path.resolve(os.homedir(), '.gemini', 'antigravity', 'brain'),
40
+ lang,
41
+ };
42
+ const sessionStatusPath = fs.existsSync(path.join(root, 'src', 'session-status.js'))
43
+ ? path.join(root, 'src', 'session-status.js')
44
+ : path.join(root, 'session-status.js');
45
+ const resource = readRendererResource({
46
+ harnessFile: path.join(__dirname, 'antigravity-harness.js'),
47
+ rendererFile: sessionStatusPath,
48
+ lang,
49
+ });
50
+ const source = `window.__agentThingsConnection = ${JSON.stringify(connection)};\n${resource.source}`;
51
+ const version = crypto.createHash('sha256').update(source).digest('hex');
52
+ for (const target of targets) {
53
+ if (this.stopped) break;
54
+ const origin = new URL(target.url).origin;
55
+ if (origin !== 'null') this.allowOrigin(origin);
56
+ let entry = this.sessions.get(target.id);
57
+ if (!entry) {
58
+ const session = new CdpSession(target, port);
59
+ entry = { session }; this.sessions.set(target.id, entry);
60
+ try { await session.connect(); }
61
+ catch (error) { session.close(); this.sessions.delete(target.id); throw error; }
62
+ if (this.stopped) { session.close(); this.sessions.delete(target.id); break; }
63
+ }
64
+ try {
65
+ const { result } = await entry.session.evaluate(`(() => {
66
+ window.__agentThingsConnection = ${JSON.stringify(connection)};
67
+ const old = window.__codexSessionStatus;
68
+ if (old?.status().version === ${JSON.stringify(version)}) return true;
69
+ const saved = old?.exportForReload?.();
70
+ if (saved?.busy) return false;
71
+ const load = new Function(${JSON.stringify(source)} + '\\nreturn installCodexSessionStatus;');
72
+ old?.destroy();
73
+ try { load()(${JSON.stringify(version)}, saved); }
74
+ catch (error) {
75
+ ${entry.source ? `new Function(${JSON.stringify(entry.source)} + '\\nreturn installCodexSessionStatus;')()(${JSON.stringify(entry.version)}, saved);` : ''}
76
+ throw error;
77
+ }
78
+ return true;
79
+ })()`);
80
+ if (result.value) { entry.source = source; entry.version = version; }
81
+ } catch (error) {
82
+ entry.session.close(); this.sessions.delete(target.id); throw error;
83
+ }
84
+ }
85
+ } finally { this.scanning = false; }
86
+ }
87
+
88
+ async stop() {
89
+ this.stopped = true;
90
+ const entries = [...this.sessions.values()];
91
+ this.sessions.clear();
92
+ await Promise.all(entries.map(async entry => {
93
+ try {
94
+ if (entry.version) await entry.session.evaluate(`(() => {
95
+ const current = window.__codexSessionStatus;
96
+ if (current?.status().version === ${JSON.stringify(entry.version)}) current.destroy();
97
+ })()`);
98
+ } catch { /* The window may already have closed. */ }
99
+ finally { entry.session.close(); }
100
+ }));
101
+ }
102
+ }
103
+
104
+ module.exports = { AntigravityInjector };
@@ -0,0 +1,235 @@
1
+ 'use strict';
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const { withStateFileLock } = require('../../state-file-lock.cjs');
5
+ const { ManualStatusStore } = require('../../manual-status-store.cjs');
6
+
7
+ /**
8
+ * 合并一对 Antigravity 会话键 (旧键 legacyKey 与规范键 canonicalKey)
9
+ * 严格按照时间轴中实际完成的 analysis 事件判定发生序号,而非使用 record.actionSequence 或缺失的 item.actionSequence
10
+ */
11
+ function mergeSessionPair(legacyKey, canonicalKey, stateData, report = { unresolvedAnalyses: [] }) {
12
+ const legacyRecord = stateData.records?.[legacyKey];
13
+ const canonicalRecord = stateData.records?.[canonicalKey];
14
+
15
+ // 1. 查找最大的有效清除序列号(严禁与时间戳比较,必须使用 actionSequence)
16
+ const legacyClearedSeq = legacyRecord?.clearedAtSequence || 0;
17
+ const canonicalClearedSeq = canonicalRecord?.clearedAtSequence || 0;
18
+ const maxClearedSeq = Math.max(legacyClearedSeq, canonicalClearedSeq);
19
+
20
+ // 2. 处理当前状态记录(手动记录)
21
+ let finalRecord = null;
22
+ const compareRecords = (a, b) => ((b?.actionSequence || 0) - (a?.actionSequence || 0))
23
+ || ((b?.revision || 0) - (a?.revision || 0)) || ((b?.updatedAt || 0) - (a?.updatedAt || 0));
24
+ const records = [legacyRecord, canonicalRecord].filter(Boolean);
25
+
26
+ // 找出所有在清除边界之后的活跃记录
27
+ const activeRecords = records.filter(r => (r.actionSequence || 0) > maxClearedSeq && r.state !== null);
28
+
29
+ if (activeRecords.length > 0) {
30
+ // 手动保存会推进 actionSequence,取最大的最新有效记录
31
+ activeRecords.sort(compareRecords);
32
+ finalRecord = { ...activeRecords[0] };
33
+ if (maxClearedSeq > 0) finalRecord.clearedAtSequence = maxClearedSeq;
34
+ } else {
35
+ // 两个键都已被清除,或原本就为空
36
+ if (maxClearedSeq > 0) {
37
+ const highestSeq = Math.max(legacyRecord?.actionSequence || 0, canonicalRecord?.actionSequence || 0, maxClearedSeq);
38
+ finalRecord = {
39
+ state: null,
40
+ actionSequence: highestSeq,
41
+ clearedAtSequence: maxClearedSeq,
42
+ revision: Math.max(legacyRecord?.revision || 0, canonicalRecord?.revision || 0),
43
+ updatedAt: Math.max(legacyRecord?.updatedAt || 0, canonicalRecord?.updatedAt || 0, Date.now()),
44
+ };
45
+ } else if (records.length > 0) {
46
+ records.sort(compareRecords);
47
+ finalRecord = { ...records[0] };
48
+ }
49
+ }
50
+
51
+ // 3. 处理 Analysis & Ledger
52
+ // 真实落盘结构为 { checkpoint, sources, ledger, projectGit },自身不含 actionSequence!
53
+ // 核心逻辑:从 timeline 中找到与该 key 关联的实际 completed 分析事件,以事件的 actionSequence 作为其实际完成序号
54
+ const rawTimeline = stateData.timeline || [];
55
+
56
+ function findAnalysisActionSequence(key) {
57
+ const events = rawTimeline.filter(e => e.key === key && e.source === 'analysis' && e.status === 'completed');
58
+ if (events.length === 0) return null; // 无法从时间轴找到完成事件佐证
59
+ events.sort((a, b) => (b.actionSequence || 0) - (a.actionSequence || 0));
60
+ return events[0].actionSequence || 0;
61
+ }
62
+
63
+ let finalAnalysis = null;
64
+ const legacyAnalysis = stateData.analysis?.[legacyKey];
65
+ const canonicalAnalysis = stateData.analysis?.[canonicalKey];
66
+ const analyses = [
67
+ legacyAnalysis ? { item: legacyAnalysis, key: legacyKey } : null,
68
+ canonicalAnalysis ? { item: canonicalAnalysis, key: canonicalKey } : null,
69
+ ].filter(Boolean).sort((a, b) => compareRecords(stateData.records?.[a.key], stateData.records?.[b.key]));
70
+
71
+ let bestAnalysisSeq = -1;
72
+
73
+ for (const { item, key } of analyses) {
74
+ const eventSeq = findAnalysisActionSequence(key);
75
+
76
+ if (eventSeq === null) {
77
+ // 无法可靠证明该分析是在清除前还是清除后产生
78
+ if (maxClearedSeq > 0) {
79
+ // 如果该会话发生过清除,且无法证明此分析在清除之后完成,绝不能静默选它
80
+ report.unresolvedAnalyses.push({
81
+ key,
82
+ reason: '分析对象缺少时间轴完成事件佐证,存在于清除边界会话中,已保留在备份中并在迁移中安全剔除',
83
+ analysisSummary: item.ledger?.summary || '',
84
+ });
85
+ continue;
86
+ } else {
87
+ // 若从未被清除过,且当前尚未选定分析,则作为备选
88
+ if (!finalAnalysis) {
89
+ finalAnalysis = structuredClone(item);
90
+ bestAnalysisSeq = 0;
91
+ }
92
+ continue;
93
+ }
94
+ }
95
+
96
+ // 与清除序号对比:严格发生在清除边界之后的合法分析才予以保留
97
+ if (maxClearedSeq > 0 && eventSeq <= maxClearedSeq) {
98
+ continue;
99
+ }
100
+
101
+ if (eventSeq > bestAnalysisSeq) {
102
+ bestAnalysisSeq = eventSeq;
103
+ finalAnalysis = structuredClone(item);
104
+ }
105
+ }
106
+
107
+ // 检查点连续性校验:对齐生产 commitCheckpoint 真实结构
108
+ // 校验 turnHashes、versions(prompt/schema/ledger)与 extractorVersion
109
+ if (finalAnalysis) {
110
+ const checkpoint = finalAnalysis.checkpoint;
111
+ let isConsistent = true;
112
+ if (checkpoint) {
113
+ if (!Array.isArray(checkpoint.turnHashes) || !checkpoint.versions?.prompt || !checkpoint.extractorVersion) {
114
+ isConsistent = false;
115
+ }
116
+ }
117
+ if (!isConsistent) {
118
+ delete finalAnalysis.checkpoint;
119
+ }
120
+ }
121
+
122
+ // 4. 处理 Timeline 事件(去重并保留清除边界之后的事件)
123
+ const combinedTimeline = [];
124
+ const eventSeen = new Set();
125
+
126
+ for (const event of rawTimeline) {
127
+ if (event.key === legacyKey || event.key === canonicalKey) {
128
+ if (maxClearedSeq > 0 && (event.actionSequence || 0) <= maxClearedSeq) {
129
+ continue;
130
+ }
131
+ // 事件身份去重(同一毫秒内但 actionSequence 不同的两次操作均保留)
132
+ const eventId = `${event.actionSequence || 0}:${event.source || ''}:${event.status || ''}:${event.requestedAt || 0}`;
133
+ if (!eventSeen.has(eventId)) {
134
+ eventSeen.add(eventId);
135
+ const cloned = structuredClone(event);
136
+ cloned.key = canonicalKey;
137
+ combinedTimeline.push(cloned);
138
+ }
139
+ } else {
140
+ combinedTimeline.push(event);
141
+ }
142
+ }
143
+
144
+ // 5. 应用合并结果
145
+ if (stateData.records) {
146
+ delete stateData.records[legacyKey];
147
+ if (finalRecord) {
148
+ stateData.records[canonicalKey] = finalRecord;
149
+ } else {
150
+ delete stateData.records[canonicalKey];
151
+ }
152
+ }
153
+
154
+ if (stateData.analysis) {
155
+ delete stateData.analysis[legacyKey];
156
+ if (finalAnalysis) {
157
+ stateData.analysis[canonicalKey] = finalAnalysis;
158
+ } else {
159
+ delete stateData.analysis[canonicalKey];
160
+ }
161
+ }
162
+
163
+ stateData.timeline = combinedTimeline;
164
+ }
165
+
166
+ function migrateAntigravityKeys(stateData) {
167
+ if (!stateData || typeof stateData !== 'object') return stateData;
168
+
169
+ const records = stateData.records || {};
170
+ const processedCleanIds = new Set();
171
+ const report = {
172
+ unresolvedAnalyses: [],
173
+ migratedCleanIds: [],
174
+ };
175
+
176
+ const keys = new Set([...Object.keys(records), ...Object.keys(stateData.analysis || {}), ...(stateData.timeline || []).map(event => event.key)]);
177
+ for (const rawKey of keys) {
178
+ try {
179
+ const parsed = JSON.parse(rawKey);
180
+ if (Array.isArray(parsed) && parsed[0] === 'local') {
181
+ const idStr = String(parsed[1]);
182
+ const cleanId = idStr.replace(/^local:/, '');
183
+ if (processedCleanIds.has(cleanId)) continue;
184
+ processedCleanIds.add(cleanId);
185
+
186
+ const legacyKey = JSON.stringify(['local', 'local:' + cleanId]);
187
+ const canonicalKey = JSON.stringify(['local', cleanId]);
188
+
189
+ if (records[legacyKey] || stateData.analysis?.[legacyKey] || stateData.timeline?.some(event => event.key === legacyKey)) {
190
+ mergeSessionPair(legacyKey, canonicalKey, stateData, report);
191
+ report.migratedCleanIds.push(cleanId);
192
+ }
193
+ }
194
+ } catch (_) {}
195
+ }
196
+
197
+ return { data: stateData, report };
198
+ }
199
+
200
+ function executeMigration(stateFilePath) {
201
+ if (!fs.existsSync(stateFilePath)) return { migrated: false, reason: '文件不存在' };
202
+
203
+ return withStateFileLock(stateFilePath, () => {
204
+ const raw = fs.readFileSync(stateFilePath, 'utf8');
205
+ // Validate the persisted schema before touching an existing ledger.
206
+ const data = new ManualStatusStore(stateFilePath).data;
207
+ const { data: migratedData, report } = migrateAntigravityKeys(data);
208
+ if (!report.migratedCleanIds.length) return { migrated: false, reason: '会话键已规范化' };
209
+
210
+ migratedData.revision++;
211
+ for (const id of report.migratedCleanIds) {
212
+ const record = migratedData.records[JSON.stringify(['local', id])];
213
+ if (record) record.revision = migratedData.revision;
214
+ }
215
+ const backupPath = `${stateFilePath}.bak_migrate_${Date.now()}_${process.pid}`;
216
+ fs.writeFileSync(backupPath, raw, { mode: 0o600, flag: 'wx' });
217
+ const tmp = `${stateFilePath}.${process.pid}.tmp`;
218
+ try {
219
+ fs.writeFileSync(tmp, JSON.stringify(migratedData, null, 2) + '\n', { mode: 0o600 });
220
+ fs.renameSync(tmp, stateFilePath);
221
+ } finally { if (fs.existsSync(tmp)) fs.unlinkSync(tmp); }
222
+
223
+ return {
224
+ migrated: true,
225
+ backupPath,
226
+ report,
227
+ };
228
+ });
229
+ }
230
+
231
+ module.exports = {
232
+ mergeSessionPair,
233
+ migrateAntigravityKeys,
234
+ executeMigration,
235
+ };