@nbardy/oompa 0.7.1 → 0.7.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.
@@ -34,11 +34,11 @@
34
34
  (throw (ex-info (str "Binary not found on PATH: " name) {:binary name}))))))
35
35
 
36
36
  ;; =============================================================================
37
- ;; Opencode Output Parsing (harness-specific, lives here not in agent-cli)
37
+ ;; NDJSON Output Parsing (harness-specific, lives here not in agent-cli)
38
38
  ;; =============================================================================
39
39
 
40
- (defn- parse-opencode-run-output
41
- "Parse `opencode run --format json` NDJSON output.
40
+ (defn- parse-ndjson-output
41
+ "Parse NDJSON output from CLIs (opencode, gemini).
42
42
  Returns {:session-id string|nil, :text string|nil}."
43
43
  [s]
44
44
  (let [raw (or s "")
@@ -51,6 +51,7 @@
51
51
  doall)
52
52
  session-id (or (some #(or (:sessionID %)
53
53
  (:sessionId %)
54
+ (:session_id %)
54
55
  (get-in % [:part :sessionID])
55
56
  (get-in % [:part :sessionId]))
56
57
  events)
@@ -58,8 +59,11 @@
58
59
  text (->> events
59
60
  (keep (fn [event]
60
61
  (let [event-type (or (:type event) (get-in event [:part :type]))
61
- chunk (or (:text event) (get-in event [:part :text]))]
62
- (when (and (= event-type "text")
62
+ role (or (:role event) (get-in event [:part :role]))
63
+ chunk (or (:text event) (get-in event [:part :text]) (:content event))]
64
+ (when (and (or (= event-type "text")
65
+ (and (= event-type "message")
66
+ (= role "assistant")))
63
67
  (string? chunk)
64
68
  (not (str/blank? chunk)))
65
69
  chunk))))
@@ -90,11 +94,29 @@
90
94
  ;; :session - session ID strategy (:uuid, :extracted, :implicit)
91
95
  ;; :output - output format (:plain or :ndjson)
92
96
 
97
+ (def ^:private gemini-behavior
98
+ {:stdin :close :session :implicit :output :ndjson})
99
+
93
100
  (def registry
94
- {:codex {:stdin :close :session :uuid :output :plain}
95
- :claude {:stdin :prompt :session :uuid :output :plain}
96
- :opencode {:stdin :close :session :extracted :output :ndjson}
97
- :gemini {:stdin :close :session :implicit :output :plain}})
101
+ (merge
102
+ {:codex {:stdin :close :session :uuid :output :plain}
103
+ :claude {:stdin :prompt :session :uuid :output :plain}
104
+ :opencode {:stdin :close :session :extracted :output :ndjson}
105
+ :gemini gemini-behavior}
106
+ {:gemini1 gemini-behavior
107
+ :gemini2 gemini-behavior
108
+ :gemini3 gemini-behavior}))
109
+
110
+ (defn- gemini-alias?
111
+ [harness-kw]
112
+ (and (keyword? harness-kw)
113
+ (re-matches #"^gemini\\d+$" (name harness-kw))))
114
+
115
+ (defn valid-harness?
116
+ "True for explicit registry entries and any `geminiNN` alias."
117
+ [harness-kw]
118
+ (or (contains? (set (keys registry)) harness-kw)
119
+ (gemini-alias? harness-kw)))
98
120
 
99
121
  ;; =============================================================================
100
122
  ;; Registry Access
@@ -104,6 +126,7 @@
104
126
  "Look up harness config. Throws on unknown harness (no silent fallback)."
105
127
  [harness-kw]
106
128
  (or (get registry harness-kw)
129
+ (when (gemini-alias? harness-kw) gemini-behavior)
107
130
  (throw (ex-info (str "Unknown harness: " harness-kw
108
131
  ". Known: " (str/join ", " (map name (keys registry))))
109
132
  {:harness harness-kw}))))
@@ -190,7 +213,7 @@
190
213
  [harness-kw raw-output session-id]
191
214
  (let [{:keys [output]} (get-config harness-kw)]
192
215
  (if (= output :ndjson)
193
- (let [parsed (parse-opencode-run-output raw-output)]
216
+ (let [parsed (parse-ndjson-output raw-output)]
194
217
  {:output (or (:text parsed) raw-output)
195
218
  :session-id (or (:session-id parsed) session-id)})
196
219
  {:output raw-output
@@ -66,8 +66,10 @@
66
66
  :workers (mapv (fn [w]
67
67
  {:id (:id w)
68
68
  :harness (name (:harness w))
69
- :model (:model w)
70
- :reasoning (:reasoning w)
69
+ :model (:model w)
70
+ :reasoning (:reasoning w)
71
+ :runs (:runs w)
72
+ :max-cycles (:max-cycles w)
71
73
  :iterations (:iterations w)
72
74
  :can-plan (:can-plan w)
73
75
  :prompts (:prompts w)})
@@ -125,13 +127,14 @@
125
127
  session-id links to the Claude CLI conversation on disk for debugging.
126
128
  Written at cycle end so dashboards can track progress in real-time."
127
129
  [swarm-id worker-id cycle
128
- {:keys [outcome duration-ms claimed-task-ids recycled-tasks
130
+ {:keys [run outcome duration-ms claimed-task-ids recycled-tasks
129
131
  error-snippet review-rounds session-id]}]
130
132
  (when swarm-id
131
133
  (let [filename (format "%s-c%d.json" worker-id cycle)]
132
134
  (write-json! (str (cycles-dir swarm-id) "/" filename)
133
135
  {:worker-id worker-id
134
136
  :cycle cycle
137
+ :run (or run 1)
135
138
  :outcome (name outcome)
136
139
  :timestamp (str (java.time.Instant/now))
137
140
  :duration-ms duration-ms
@@ -48,7 +48,14 @@
48
48
  (def merge-strategies #{:fast-forward :no-ff :squash :rebase})
49
49
  (def conflict-resolutions #{:ours :theirs :manual :abort})
50
50
 
51
- (defn agent-type? [x] (contains? agent-types x))
51
+ (defn- gemini-indexed-account?
52
+ [x]
53
+ (and (keyword? x)
54
+ (re-matches #"^gemini\d+$" (name x))))
55
+
56
+ (defn agent-type? [x]
57
+ (or (contains? agent-types x)
58
+ (gemini-indexed-account? x)))
52
59
  (defn agent-role? [x] (contains? agent-roles x))
53
60
  (defn task-status? [x] (contains? task-statuses x))
54
61
  (defn worktree-status? [x] (contains? worktree-statuses x))