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,280 @@
1
+ // Small AppKit helper for the startup handoff. Every command prints one JSON line.
2
+ //
3
+ // bridge snapshot <app>
4
+ // bridge watch <app>
5
+ // bridge quit <app> <pid> <key> <stamp>
6
+ // bridge launch <app> <port>
7
+ // bridge show <app> <pid> <key> <stamp> <frontmostPid>
8
+ // bridge wallpaper <app>
9
+ //
10
+ // It only reads input event counters and timestamps, never what was typed, and it only
11
+ // ever calls terminate(): a refused quit stays refused.
12
+ //
13
+ // A quit Apple Event that reaches an Electron app before its main process is ready is
14
+ // approved by AppKit without running the app's own quit lifecycle; the app then keeps
15
+ // working and later exits abruptly. quit therefore refuses until the app shows a window.
16
+ import AppKit
17
+ import CoreGraphics
18
+ import Foundation
19
+ import Darwin
20
+
21
+ let inputEvents: [CGEventType] = [.keyDown, .leftMouseDown, .rightMouseDown, .otherMouseDown, .scrollWheel]
22
+
23
+ func emit(_ value: Any) {
24
+ guard let data = try? JSONSerialization.data(withJSONObject: value),
25
+ let line = String(data: data, encoding: .utf8) else { exit(1) }
26
+ print(line)
27
+ fflush(stdout)
28
+ }
29
+
30
+ func fail(_ message: String) -> Never {
31
+ FileHandle.standardError.write(Data("\(message)\n".utf8))
32
+ exit(2)
33
+ }
34
+
35
+ func inputStamp() -> Int {
36
+ inputEvents.reduce(0) { $0 + Int(CGEventSource.counterForEventType(.combinedSessionState, eventType: $1)) }
37
+ }
38
+
39
+ // Mouse movement is left out on purpose: moving away from the Dock is not "using" the app.
40
+ func inputIdleMs() -> Double {
41
+ let seconds = inputEvents
42
+ .map { CGEventSource.secondsSinceLastEventType(.combinedSessionState, eventType: $0) }
43
+ .min() ?? .infinity
44
+ return seconds.isFinite ? seconds * 1000 : 1e12
45
+ }
46
+
47
+ func canonical(_ path: String) -> String {
48
+ URL(fileURLWithPath: path).resolvingSymlinksInPath().path
49
+ }
50
+
51
+ func runningApps(_ appPath: String) -> [NSRunningApplication] {
52
+ NSWorkspace.shared.runningApplications.filter {
53
+ guard let url = $0.bundleURL else { return false }
54
+ return canonical(url.path) == appPath && !$0.isTerminated
55
+ }
56
+ }
57
+
58
+ func launchMs(_ app: NSRunningApplication) -> Int {
59
+ Int((app.launchDate?.timeIntervalSince1970 ?? 0) * 1000)
60
+ }
61
+
62
+ func processKey(_ app: NSRunningApplication) -> String {
63
+ "\(app.processIdentifier):\(launchMs(app))"
64
+ }
65
+
66
+ func commandLine(_ pid: pid_t) -> String? {
67
+ let process = Process()
68
+ let pipe = Pipe()
69
+ process.executableURL = URL(fileURLWithPath: "/bin/ps")
70
+ process.arguments = ["-ww", "-o", "command=", "-p", String(pid)]
71
+ process.standardOutput = pipe
72
+ process.standardError = FileHandle.nullDevice
73
+ do { try process.run() } catch { return nil }
74
+ let data = pipe.fileHandleForReading.readDataToEndOfFile()
75
+ process.waitUntilExit()
76
+ guard process.terminationStatus == 0, let text = String(data: data, encoding: .utf8) else { return nil }
77
+ return text.isEmpty ? nil : text
78
+ }
79
+
80
+ func debugPort(_ command: String) -> Int? {
81
+ guard let range = command.range(of: #"--remote-debugging-port=\d+"#, options: .regularExpression) else { return nil }
82
+ return Int(command[range].split(separator: "=").last ?? "")
83
+ }
84
+
85
+ // On-screen, normal-level windows per process. Owner and layer are readable without
86
+ // Screen Recording permission; titles and contents are never requested.
87
+ func visibleWindowCounts() -> [Int: Int] {
88
+ guard let list = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID)
89
+ as? [[String: Any]] else { return [:] }
90
+ var counts: [Int: Int] = [:]
91
+ for window in list {
92
+ guard let pid = (window[kCGWindowOwnerPID as String] as? NSNumber)?.intValue,
93
+ (window[kCGWindowLayer as String] as? NSNumber)?.intValue == 0 else { continue }
94
+ counts[pid, default: 0] += 1
95
+ }
96
+ return counts
97
+ }
98
+
99
+ func describe(_ app: NSRunningApplication, windows: [Int: Int]) -> [String: Any] {
100
+ let command = commandLine(app.processIdentifier)
101
+ return [
102
+ "windows": windows[Int(app.processIdentifier)] ?? 0,
103
+ "pid": Int(app.processIdentifier),
104
+ "key": processKey(app),
105
+ "launchedAt": launchMs(app),
106
+ "finishedLaunching": app.isFinishedLaunching,
107
+ "argumentsKnown": command != nil,
108
+ "debugPort": command.flatMap(debugPort) as Any? ?? NSNull()
109
+ ]
110
+ }
111
+
112
+ func snapshot(_ appPath: String) -> [String: Any] {
113
+ let keyboardIdle = CGEventSource.secondsSinceLastEventType(.combinedSessionState, eventType: .keyDown) * 1000
114
+ return [
115
+ "apps": { let windows = visibleWindowCounts(); return runningApps(appPath).map { describe($0, windows: windows) } }(),
116
+ "frontmostPid": NSWorkspace.shared.frontmostApplication.map { Int($0.processIdentifier) } as Any? ?? NSNull(),
117
+ "inputIdleMs": inputIdleMs(),
118
+ "keyboardIdleMs": keyboardIdle.isFinite ? keyboardIdle : 1e12,
119
+ "inputStamp": inputStamp()
120
+ ]
121
+ }
122
+
123
+ func find(_ appPath: String, pid: String, key: String) -> NSRunningApplication? {
124
+ guard let pid = pid_t(pid) else { return nil }
125
+ return runningApps(appPath).first { $0.processIdentifier == pid && processKey($0) == key }
126
+ }
127
+
128
+ // openApplication is asynchronous and needs the main run loop to deliver its completion.
129
+ func open(_ appPath: String, _ configuration: NSWorkspace.OpenConfiguration, timeout: TimeInterval) -> NSRunningApplication? {
130
+ var opened: NSRunningApplication?
131
+ var done = false
132
+ NSWorkspace.shared.openApplication(at: URL(fileURLWithPath: appPath), configuration: configuration) { app, _ in
133
+ DispatchQueue.main.async {
134
+ opened = app
135
+ done = true
136
+ }
137
+ }
138
+ let deadline = Date(timeIntervalSinceNow: timeout)
139
+ while !done && Date() < deadline {
140
+ RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.05))
141
+ }
142
+ return opened
143
+ }
144
+
145
+ func watch(_ appPath: String) -> Never {
146
+ let center = NSWorkspace.shared.notificationCenter
147
+ let names: [NSNotification.Name] = [
148
+ NSWorkspace.didLaunchApplicationNotification,
149
+ NSWorkspace.didTerminateApplicationNotification,
150
+ NSWorkspace.didActivateApplicationNotification
151
+ ]
152
+ let tokens = names.map { name in
153
+ center.addObserver(forName: name, object: nil, queue: .main) { note in
154
+ guard let app = note.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication,
155
+ let url = app.bundleURL, canonical(url.path) == appPath else { return }
156
+ emit(["event": name.rawValue, "pid": Int(app.processIdentifier)])
157
+ }
158
+ }
159
+ emit(["event": "watching"])
160
+ withExtendedLifetime(tokens) { RunLoop.main.run() }
161
+ exit(0)
162
+ }
163
+
164
+ // Cocoa measures from the bottom of the primary screen, the renderer from its top.
165
+ func wallpaper() -> [String: Any] {
166
+ let primaryHeight = NSScreen.screens.first?.frame.height ?? 0
167
+ return ["screens": NSScreen.screens.map { screen -> [String: Any] in
168
+ let frame = screen.frame
169
+ return [
170
+ "x": frame.minX,
171
+ "y": primaryHeight - frame.maxY,
172
+ "width": frame.width,
173
+ "height": frame.height,
174
+ "image": NSWorkspace.shared.desktopImageURL(for: screen)?.path as Any? ?? NSNull()
175
+ ]
176
+ }]
177
+ }
178
+
179
+ func claimLock(_ file: String, owner: Int32) {
180
+ let fd = Darwin.open(file + ".guard", O_RDWR | O_CREAT, mode_t(0o600))
181
+ guard fd >= 0 else { fail("cannot open lock guard") }
182
+ defer { Darwin.close(fd) }
183
+ var gate = Darwin.flock()
184
+ gate.l_type = Int16(F_WRLCK)
185
+ gate.l_whence = Int16(SEEK_SET)
186
+ gate.l_len = 0
187
+ guard Darwin.fcntl(fd, F_SETLK, &gate) == 0 else { emit(["acquired": false]); return }
188
+ var before = stat()
189
+ if Darwin.lstat(file, &before) == 0 {
190
+ if let text = try? String(contentsOfFile: file, encoding: .utf8),
191
+ let pid = Int32(text.trimmingCharacters(in: .whitespacesAndNewlines)), pid > 0 {
192
+ if Darwin.kill(pid, 0) == 0 || errno == EPERM { emit(["acquired": false]); return }
193
+ guard errno == ESRCH else { fail("cannot inspect lock owner") }
194
+ }
195
+ var current = stat()
196
+ guard Darwin.lstat(file, &current) == 0, current.st_ino == before.st_ino,
197
+ current.st_dev == before.st_dev else { emit(["acquired": false]); return }
198
+ guard Darwin.unlink(file) == 0 else { emit(["acquired": false]); return }
199
+ }
200
+ let temporary = file + ".claim." + UUID().uuidString
201
+ defer { Darwin.unlink(temporary) }
202
+ do {
203
+ try "\(owner)\n".write(toFile: temporary, atomically: true, encoding: .utf8)
204
+ try FileManager.default.setAttributes([.posixPermissions: 0o600], ofItemAtPath: temporary)
205
+ emit(["acquired": Darwin.link(temporary, file) == 0])
206
+ } catch { fail("cannot write lock owner") }
207
+ }
208
+
209
+ let args = CommandLine.arguments
210
+ if args.count == 2 && args[1] == "version" {
211
+ emit(["protocol": 1, "capabilities": ["snapshot", "watch", "quit", "launch", "show", "wallpaper", "claim-lock", "window-ready"]])
212
+ exit(0)
213
+ }
214
+ guard args.count >= 3 else { fail("usage: bridge <command> <app> [...]") }
215
+ let command = args[1]
216
+ let appPath = canonical(args[2])
217
+
218
+ switch command {
219
+ case "claim-lock":
220
+ guard args.count == 4, let owner = Int32(args[3]), owner > 0 else { fail("invalid lock owner") }
221
+ claimLock(appPath, owner: owner)
222
+
223
+ case "snapshot":
224
+ emit(snapshot(appPath))
225
+
226
+ case "watch":
227
+ watch(appPath)
228
+
229
+ case "quit":
230
+ guard args.count == 6 else { fail("usage: bridge quit <app> <pid> <key> <stamp>") }
231
+ // The user started working between the decision and now: leave the app alone.
232
+ guard String(inputStamp()) == args[5] else {
233
+ emit(["accepted": false, "reason": "input-changed"])
234
+ break
235
+ }
236
+ guard let app = find(appPath, pid: args[3], key: args[4]) else {
237
+ emit(["accepted": false, "reason": "process-changed"])
238
+ break
239
+ }
240
+ guard (visibleWindowCounts()[Int(app.processIdentifier)] ?? 0) > 0 else {
241
+ emit(["accepted": false, "reason": "not-ready"])
242
+ break
243
+ }
244
+ emit(["accepted": app.terminate()])
245
+
246
+ case "launch":
247
+ guard args.count == 4 else { fail("usage: bridge launch <app> <port>") }
248
+ guard runningApps(appPath).isEmpty else {
249
+ emit(["launched": false])
250
+ break
251
+ }
252
+ let configuration = NSWorkspace.OpenConfiguration()
253
+ configuration.arguments = ["--remote-debugging-port=\(args[3])", "--remote-debugging-address=127.0.0.1"]
254
+ configuration.activates = false
255
+ configuration.addsToRecentItems = false
256
+ configuration.createsNewApplicationInstance = false
257
+ guard let app = open(appPath, configuration, timeout: 20) else {
258
+ emit(["launched": false])
259
+ break
260
+ }
261
+ emit(["launched": true, "pid": Int(app.processIdentifier), "key": processKey(app)])
262
+
263
+ case "show":
264
+ guard args.count == 7 else { fail("usage: bridge show <app> <pid> <key> <stamp> <frontmostPid>") }
265
+ let frontmost = NSWorkspace.shared.frontmostApplication.map { String($0.processIdentifier) } ?? ""
266
+ guard String(inputStamp()) == args[5], frontmost == args[6], find(appPath, pid: args[3], key: args[4]) != nil else {
267
+ emit(["shown": false])
268
+ break
269
+ }
270
+ let configuration = NSWorkspace.OpenConfiguration()
271
+ configuration.activates = true
272
+ configuration.addsToRecentItems = false
273
+ emit(["shown": open(appPath, configuration, timeout: 10) != nil])
274
+
275
+ case "wallpaper":
276
+ emit(wallpaper())
277
+
278
+ default:
279
+ fail("unknown command: \(command)")
280
+ }