baro-ai 0.27.0 → 0.29.0
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/cli.mjs +385 -227
- package/dist/cli.mjs.map +1 -1
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -7188,29 +7188,6 @@ var InputText = class _InputText extends ItemContent {
|
|
|
7188
7188
|
];
|
|
7189
7189
|
}
|
|
7190
7190
|
};
|
|
7191
|
-
var UserMessageItem = class _UserMessageItem extends ContextItem {
|
|
7192
|
-
constructor(content) {
|
|
7193
|
-
super();
|
|
7194
|
-
this.type = "message";
|
|
7195
|
-
this.role = "user";
|
|
7196
|
-
this.content = content;
|
|
7197
|
-
}
|
|
7198
|
-
static create(text) {
|
|
7199
|
-
const content = InputText.create(text);
|
|
7200
|
-
return new _UserMessageItem(content);
|
|
7201
|
-
}
|
|
7202
|
-
static rehydrate(data) {
|
|
7203
|
-
const content = InputText.rehydrate(data);
|
|
7204
|
-
return new _UserMessageItem(content);
|
|
7205
|
-
}
|
|
7206
|
-
toJSON() {
|
|
7207
|
-
return {
|
|
7208
|
-
type: this.type,
|
|
7209
|
-
role: this.role,
|
|
7210
|
-
content: this.content.toJSON()
|
|
7211
|
-
};
|
|
7212
|
-
}
|
|
7213
|
-
};
|
|
7214
7191
|
var OutputText = class _OutputText extends ItemContent {
|
|
7215
7192
|
constructor(text) {
|
|
7216
7193
|
super();
|
|
@@ -7322,13 +7299,64 @@ var AgenticEnvironment = class {
|
|
|
7322
7299
|
}
|
|
7323
7300
|
subscribe(subscriber) {
|
|
7324
7301
|
this.subscribers.push(subscriber);
|
|
7302
|
+
for (const subscriber2 of this.subscribers) {
|
|
7303
|
+
if (subscriber2 === subscriber2) {
|
|
7304
|
+
subscriber2.onJoined();
|
|
7305
|
+
} else {
|
|
7306
|
+
subscriber2.onParticipantJoined(subscriber2);
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
}
|
|
7310
|
+
unsubscribe(subscriber) {
|
|
7311
|
+
this.subscribers = this.subscribers.filter((p) => p !== subscriber);
|
|
7312
|
+
for (const subscriber2 of this.subscribers) {
|
|
7313
|
+
if (subscriber2 === subscriber2) {
|
|
7314
|
+
subscriber2.onLeft();
|
|
7315
|
+
} else {
|
|
7316
|
+
subscriber2.onParticipantLeft(subscriber2);
|
|
7317
|
+
}
|
|
7318
|
+
}
|
|
7319
|
+
}
|
|
7320
|
+
deliverFunctionCall(source, item) {
|
|
7321
|
+
for (const subscriber of this.subscribers) {
|
|
7322
|
+
if (subscriber === source) {
|
|
7323
|
+
subscriber.onFunctionCall(item);
|
|
7324
|
+
} else {
|
|
7325
|
+
subscriber.onExternalFunctionCall(source, item);
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
deliverModelMessage(source, item) {
|
|
7330
|
+
for (const subscriber of this.subscribers) {
|
|
7331
|
+
if (subscriber === source) {
|
|
7332
|
+
subscriber.onModelMessage(item);
|
|
7333
|
+
} else {
|
|
7334
|
+
subscriber.onExternalModelMessage(source, item);
|
|
7335
|
+
}
|
|
7336
|
+
}
|
|
7325
7337
|
}
|
|
7326
|
-
|
|
7327
|
-
|
|
7338
|
+
deliverReasoning(source, item) {
|
|
7339
|
+
for (const subscriber of this.subscribers) {
|
|
7340
|
+
if (subscriber === source) {
|
|
7341
|
+
subscriber.onReasoning(item);
|
|
7342
|
+
} else {
|
|
7343
|
+
subscriber.onExternalReasoning(source, item);
|
|
7344
|
+
}
|
|
7345
|
+
}
|
|
7328
7346
|
}
|
|
7329
|
-
|
|
7347
|
+
deliverFunctionCallOutput(source, item) {
|
|
7330
7348
|
for (const subscriber of this.subscribers) {
|
|
7331
|
-
subscriber
|
|
7349
|
+
if (subscriber === source) {
|
|
7350
|
+
subscriber.onFunctionCallOutput(item);
|
|
7351
|
+
} else {
|
|
7352
|
+
subscriber.onExternalFunctionCallOutput(source, item);
|
|
7353
|
+
}
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
deliverMessage(source, message) {
|
|
7357
|
+
for (const subscriber of this.subscribers) {
|
|
7358
|
+
if (subscriber === source) continue;
|
|
7359
|
+
subscriber.onMessage(message);
|
|
7332
7360
|
}
|
|
7333
7361
|
}
|
|
7334
7362
|
async start() {
|
|
@@ -7342,6 +7370,67 @@ var AgenticEnvironment = class {
|
|
|
7342
7370
|
}
|
|
7343
7371
|
};
|
|
7344
7372
|
|
|
7373
|
+
// ../baro-orchestrator/src/bus.ts
|
|
7374
|
+
var BusEvent = class {
|
|
7375
|
+
toJSON() {
|
|
7376
|
+
const out = { type: this.type };
|
|
7377
|
+
for (const [key, value] of Object.entries(this)) {
|
|
7378
|
+
if (key !== "type") out[key] = value;
|
|
7379
|
+
}
|
|
7380
|
+
return out;
|
|
7381
|
+
}
|
|
7382
|
+
};
|
|
7383
|
+
var BaroEnvironment = class extends AgenticEnvironment {
|
|
7384
|
+
/**
|
|
7385
|
+
* Self-emitted: the `source` participant receives `onBusEvent`.
|
|
7386
|
+
* Every other subscriber receives `onExternalBusEvent`. Mirrors
|
|
7387
|
+
* Mozaik's symmetry for built-in delivery methods. Subscribers
|
|
7388
|
+
* that aren't `BaroParticipant` instances are silently skipped.
|
|
7389
|
+
*/
|
|
7390
|
+
deliverBusEvent(source, event) {
|
|
7391
|
+
for (const subscriber of this.subscribers) {
|
|
7392
|
+
const sub = subscriber;
|
|
7393
|
+
if (subscriber === source) {
|
|
7394
|
+
void sub.onBusEvent?.(event);
|
|
7395
|
+
} else {
|
|
7396
|
+
void sub.onExternalBusEvent?.(source, event);
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
};
|
|
7401
|
+
var BaroParticipant = class extends Participant {
|
|
7402
|
+
onJoined() {
|
|
7403
|
+
}
|
|
7404
|
+
onLeft() {
|
|
7405
|
+
}
|
|
7406
|
+
onParticipantJoined(_p) {
|
|
7407
|
+
}
|
|
7408
|
+
onParticipantLeft(_p) {
|
|
7409
|
+
}
|
|
7410
|
+
onFunctionCall(_item) {
|
|
7411
|
+
}
|
|
7412
|
+
onExternalFunctionCall(_s, _item) {
|
|
7413
|
+
}
|
|
7414
|
+
onFunctionCallOutput(_item) {
|
|
7415
|
+
}
|
|
7416
|
+
onExternalFunctionCallOutput(_s, _item) {
|
|
7417
|
+
}
|
|
7418
|
+
onReasoning(_item) {
|
|
7419
|
+
}
|
|
7420
|
+
onExternalReasoning(_s, _item) {
|
|
7421
|
+
}
|
|
7422
|
+
onModelMessage(_item) {
|
|
7423
|
+
}
|
|
7424
|
+
onExternalModelMessage(_s, _item) {
|
|
7425
|
+
}
|
|
7426
|
+
onMessage(_message) {
|
|
7427
|
+
}
|
|
7428
|
+
onBusEvent(_event) {
|
|
7429
|
+
}
|
|
7430
|
+
onExternalBusEvent(_source, _event) {
|
|
7431
|
+
}
|
|
7432
|
+
};
|
|
7433
|
+
|
|
7345
7434
|
// ../baro-orchestrator/src/git.ts
|
|
7346
7435
|
import { execFile } from "child_process";
|
|
7347
7436
|
import { promisify } from "util";
|
|
@@ -7608,7 +7697,7 @@ import { appendFileSync, mkdirSync } from "fs";
|
|
|
7608
7697
|
import { dirname } from "path";
|
|
7609
7698
|
|
|
7610
7699
|
// ../baro-orchestrator/src/types.ts
|
|
7611
|
-
var KnowledgeItem = class extends
|
|
7700
|
+
var KnowledgeItem = class extends BusEvent {
|
|
7612
7701
|
constructor(sourceAgentId, tags, summary, content, tool) {
|
|
7613
7702
|
super();
|
|
7614
7703
|
this.sourceAgentId = sourceAgentId;
|
|
@@ -7629,7 +7718,7 @@ var KnowledgeItem = class extends ContextItem {
|
|
|
7629
7718
|
};
|
|
7630
7719
|
}
|
|
7631
7720
|
};
|
|
7632
|
-
var ReplanItem = class extends
|
|
7721
|
+
var ReplanItem = class extends BusEvent {
|
|
7633
7722
|
constructor(source, reason, addedStories = [], removedStoryIds = [], modifiedDeps = /* @__PURE__ */ new Map()) {
|
|
7634
7723
|
super();
|
|
7635
7724
|
this.source = source;
|
|
@@ -7650,7 +7739,7 @@ var ReplanItem = class extends ContextItem {
|
|
|
7650
7739
|
};
|
|
7651
7740
|
}
|
|
7652
7741
|
};
|
|
7653
|
-
var CoordinationItem = class extends
|
|
7742
|
+
var CoordinationItem = class extends BusEvent {
|
|
7654
7743
|
constructor(fromAgentId, recipientId, kind, reason, payload = {}) {
|
|
7655
7744
|
super();
|
|
7656
7745
|
this.fromAgentId = fromAgentId;
|
|
@@ -7671,7 +7760,7 @@ var CoordinationItem = class extends ContextItem {
|
|
|
7671
7760
|
};
|
|
7672
7761
|
}
|
|
7673
7762
|
};
|
|
7674
|
-
var AgentTargetedMessageItem = class extends
|
|
7763
|
+
var AgentTargetedMessageItem = class extends BusEvent {
|
|
7675
7764
|
constructor(recipientId, text, metadata = {}) {
|
|
7676
7765
|
super();
|
|
7677
7766
|
this.recipientId = recipientId;
|
|
@@ -7688,7 +7777,7 @@ var AgentTargetedMessageItem = class extends ContextItem {
|
|
|
7688
7777
|
};
|
|
7689
7778
|
}
|
|
7690
7779
|
};
|
|
7691
|
-
var AgentStateItem = class extends
|
|
7780
|
+
var AgentStateItem = class extends BusEvent {
|
|
7692
7781
|
constructor(agentId, phase, detail) {
|
|
7693
7782
|
super();
|
|
7694
7783
|
this.agentId = agentId;
|
|
@@ -7705,7 +7794,22 @@ var AgentStateItem = class extends ContextItem {
|
|
|
7705
7794
|
};
|
|
7706
7795
|
}
|
|
7707
7796
|
};
|
|
7708
|
-
var
|
|
7797
|
+
var AgentUserMessageItem = class extends BusEvent {
|
|
7798
|
+
constructor(agentId, text) {
|
|
7799
|
+
super();
|
|
7800
|
+
this.agentId = agentId;
|
|
7801
|
+
this.text = text;
|
|
7802
|
+
}
|
|
7803
|
+
type = "agent_user_message";
|
|
7804
|
+
toJSON() {
|
|
7805
|
+
return {
|
|
7806
|
+
type: this.type,
|
|
7807
|
+
agentId: this.agentId,
|
|
7808
|
+
text: this.text
|
|
7809
|
+
};
|
|
7810
|
+
}
|
|
7811
|
+
};
|
|
7812
|
+
var ClaudeSystemItem = class extends BusEvent {
|
|
7709
7813
|
constructor(agentId, subtype, raw) {
|
|
7710
7814
|
super();
|
|
7711
7815
|
this.agentId = agentId;
|
|
@@ -7722,7 +7826,7 @@ var ClaudeSystemItem = class extends ContextItem {
|
|
|
7722
7826
|
};
|
|
7723
7827
|
}
|
|
7724
7828
|
};
|
|
7725
|
-
var ClaudeResultItem = class extends
|
|
7829
|
+
var ClaudeResultItem = class extends BusEvent {
|
|
7726
7830
|
constructor(agentId, subtype, sessionId, isError, resultText, usage, totalCostUsd, numTurns, durationMs, raw) {
|
|
7727
7831
|
super();
|
|
7728
7832
|
this.agentId = agentId;
|
|
@@ -7752,7 +7856,7 @@ var ClaudeResultItem = class extends ContextItem {
|
|
|
7752
7856
|
};
|
|
7753
7857
|
}
|
|
7754
7858
|
};
|
|
7755
|
-
var ClaudeStreamChunkItem = class extends
|
|
7859
|
+
var ClaudeStreamChunkItem = class extends BusEvent {
|
|
7756
7860
|
constructor(agentId, raw) {
|
|
7757
7861
|
super();
|
|
7758
7862
|
this.agentId = agentId;
|
|
@@ -7767,7 +7871,7 @@ var ClaudeStreamChunkItem = class extends ContextItem {
|
|
|
7767
7871
|
};
|
|
7768
7872
|
}
|
|
7769
7873
|
};
|
|
7770
|
-
var ClaudeRateLimitItem = class extends
|
|
7874
|
+
var ClaudeRateLimitItem = class extends BusEvent {
|
|
7771
7875
|
constructor(agentId, raw) {
|
|
7772
7876
|
super();
|
|
7773
7877
|
this.agentId = agentId;
|
|
@@ -7782,7 +7886,7 @@ var ClaudeRateLimitItem = class extends ContextItem {
|
|
|
7782
7886
|
};
|
|
7783
7887
|
}
|
|
7784
7888
|
};
|
|
7785
|
-
var CritiqueItem = class extends
|
|
7889
|
+
var CritiqueItem = class extends BusEvent {
|
|
7786
7890
|
constructor(agentId, verdict, reasoning, violatedCriteria, turn, modelUsed) {
|
|
7787
7891
|
super();
|
|
7788
7892
|
this.agentId = agentId;
|
|
@@ -7805,7 +7909,7 @@ var CritiqueItem = class extends ContextItem {
|
|
|
7805
7909
|
};
|
|
7806
7910
|
}
|
|
7807
7911
|
};
|
|
7808
|
-
var ClaudeUnknownEventItem = class extends
|
|
7912
|
+
var ClaudeUnknownEventItem = class extends BusEvent {
|
|
7809
7913
|
constructor(agentId, claudeType, raw) {
|
|
7810
7914
|
super();
|
|
7811
7915
|
this.agentId = agentId;
|
|
@@ -7822,7 +7926,7 @@ var ClaudeUnknownEventItem = class extends ContextItem {
|
|
|
7822
7926
|
};
|
|
7823
7927
|
}
|
|
7824
7928
|
};
|
|
7825
|
-
var RunStartRequestItem = class extends
|
|
7929
|
+
var RunStartRequestItem = class extends BusEvent {
|
|
7826
7930
|
constructor(reason = "user request") {
|
|
7827
7931
|
super();
|
|
7828
7932
|
this.reason = reason;
|
|
@@ -7832,7 +7936,7 @@ var RunStartRequestItem = class extends ContextItem {
|
|
|
7832
7936
|
return { type: this.type, reason: this.reason };
|
|
7833
7937
|
}
|
|
7834
7938
|
};
|
|
7835
|
-
var RunStartedItem = class extends
|
|
7939
|
+
var RunStartedItem = class extends BusEvent {
|
|
7836
7940
|
constructor(project, storyCount) {
|
|
7837
7941
|
super();
|
|
7838
7942
|
this.project = project;
|
|
@@ -7843,7 +7947,7 @@ var RunStartedItem = class extends ContextItem {
|
|
|
7843
7947
|
return { type: this.type, project: this.project, storyCount: this.storyCount };
|
|
7844
7948
|
}
|
|
7845
7949
|
};
|
|
7846
|
-
var LevelComputeRequestItem = class extends
|
|
7950
|
+
var LevelComputeRequestItem = class extends BusEvent {
|
|
7847
7951
|
constructor(reason) {
|
|
7848
7952
|
super();
|
|
7849
7953
|
this.reason = reason;
|
|
@@ -7853,7 +7957,7 @@ var LevelComputeRequestItem = class extends ContextItem {
|
|
|
7853
7957
|
return { type: this.type, reason: this.reason };
|
|
7854
7958
|
}
|
|
7855
7959
|
};
|
|
7856
|
-
var LevelStartedItem = class extends
|
|
7960
|
+
var LevelStartedItem = class extends BusEvent {
|
|
7857
7961
|
constructor(ordinal, totalLevelsHint, storyIds) {
|
|
7858
7962
|
super();
|
|
7859
7963
|
this.ordinal = ordinal;
|
|
@@ -7870,7 +7974,7 @@ var LevelStartedItem = class extends ContextItem {
|
|
|
7870
7974
|
};
|
|
7871
7975
|
}
|
|
7872
7976
|
};
|
|
7873
|
-
var LevelCompletedItem = class extends
|
|
7977
|
+
var LevelCompletedItem = class extends BusEvent {
|
|
7874
7978
|
constructor(ordinal, passed, failed) {
|
|
7875
7979
|
super();
|
|
7876
7980
|
this.ordinal = ordinal;
|
|
@@ -7887,7 +7991,7 @@ var LevelCompletedItem = class extends ContextItem {
|
|
|
7887
7991
|
};
|
|
7888
7992
|
}
|
|
7889
7993
|
};
|
|
7890
|
-
var StorySpawnRequestItem = class extends
|
|
7994
|
+
var StorySpawnRequestItem = class extends BusEvent {
|
|
7891
7995
|
constructor(storyId, prompt, model, retries, timeoutSecs) {
|
|
7892
7996
|
super();
|
|
7893
7997
|
this.storyId = storyId;
|
|
@@ -7908,7 +8012,7 @@ var StorySpawnRequestItem = class extends ContextItem {
|
|
|
7908
8012
|
};
|
|
7909
8013
|
}
|
|
7910
8014
|
};
|
|
7911
|
-
var StorySpawnedItem = class extends
|
|
8015
|
+
var StorySpawnedItem = class extends BusEvent {
|
|
7912
8016
|
constructor(storyId) {
|
|
7913
8017
|
super();
|
|
7914
8018
|
this.storyId = storyId;
|
|
@@ -7918,7 +8022,7 @@ var StorySpawnedItem = class extends ContextItem {
|
|
|
7918
8022
|
return { type: this.type, storyId: this.storyId };
|
|
7919
8023
|
}
|
|
7920
8024
|
};
|
|
7921
|
-
var FinalizeStartedItem = class extends
|
|
8025
|
+
var FinalizeStartedItem = class extends BusEvent {
|
|
7922
8026
|
constructor(branch) {
|
|
7923
8027
|
super();
|
|
7924
8028
|
this.branch = branch;
|
|
@@ -7928,7 +8032,7 @@ var FinalizeStartedItem = class extends ContextItem {
|
|
|
7928
8032
|
return { type: this.type, branch: this.branch };
|
|
7929
8033
|
}
|
|
7930
8034
|
};
|
|
7931
|
-
var PrCreatedItem = class extends
|
|
8035
|
+
var PrCreatedItem = class extends BusEvent {
|
|
7932
8036
|
constructor(url, branch, baseBranch) {
|
|
7933
8037
|
super();
|
|
7934
8038
|
this.url = url;
|
|
@@ -7945,7 +8049,7 @@ var PrCreatedItem = class extends ContextItem {
|
|
|
7945
8049
|
};
|
|
7946
8050
|
}
|
|
7947
8051
|
};
|
|
7948
|
-
var RunCompletedItem = class extends
|
|
8052
|
+
var RunCompletedItem = class extends BusEvent {
|
|
7949
8053
|
constructor(success, completedStories, failedStories, totalDurationSecs, totalAttempts, abortReason = null) {
|
|
7950
8054
|
super();
|
|
7951
8055
|
this.success = success;
|
|
@@ -7970,14 +8074,14 @@ var RunCompletedItem = class extends ContextItem {
|
|
|
7970
8074
|
};
|
|
7971
8075
|
|
|
7972
8076
|
// ../baro-orchestrator/src/participants/auditor.ts
|
|
7973
|
-
var Auditor = class extends
|
|
8077
|
+
var Auditor = class extends BaroParticipant {
|
|
7974
8078
|
path;
|
|
7975
8079
|
skipStreamChunks;
|
|
7976
8080
|
filter;
|
|
7977
8081
|
/**
|
|
7978
8082
|
* Flips to true the first time a write fails (e.g. EACCES because
|
|
7979
8083
|
* `~/.baro/runs/` is root-owned from a sudo install). Once disabled,
|
|
7980
|
-
* subsequent
|
|
8084
|
+
* subsequent events are dropped silently — losing the audit log is
|
|
7981
8085
|
* better than crashing the orchestrator on every bus event.
|
|
7982
8086
|
*/
|
|
7983
8087
|
disabled = false;
|
|
@@ -7992,14 +8096,25 @@ var Auditor = class extends Participant {
|
|
|
7992
8096
|
this.disable(`mkdir failed: ${e?.message ?? String(e)}`);
|
|
7993
8097
|
}
|
|
7994
8098
|
}
|
|
7995
|
-
async
|
|
8099
|
+
async onExternalBusEvent(source, event) {
|
|
8100
|
+
this.write(source, event);
|
|
8101
|
+
}
|
|
8102
|
+
async onExternalModelMessage(source, item) {
|
|
8103
|
+
this.write(source, item);
|
|
8104
|
+
}
|
|
8105
|
+
async onExternalFunctionCall(source, item) {
|
|
8106
|
+
this.write(source, item);
|
|
8107
|
+
}
|
|
8108
|
+
async onExternalFunctionCallOutput(source, item) {
|
|
8109
|
+
this.write(source, item);
|
|
8110
|
+
}
|
|
8111
|
+
async onExternalReasoning(source, item) {
|
|
8112
|
+
this.write(source, item);
|
|
8113
|
+
}
|
|
8114
|
+
write(source, item) {
|
|
7996
8115
|
if (this.disabled) return;
|
|
7997
|
-
if (this.skipStreamChunks && item instanceof ClaudeStreamChunkItem)
|
|
7998
|
-
|
|
7999
|
-
}
|
|
8000
|
-
if (this.filter && !this.filter(source, item)) {
|
|
8001
|
-
return;
|
|
8002
|
-
}
|
|
8116
|
+
if (this.skipStreamChunks && item instanceof ClaudeStreamChunkItem) return;
|
|
8117
|
+
if (this.filter && !this.filter(source, item)) return;
|
|
8003
8118
|
const entry = {
|
|
8004
8119
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8005
8120
|
source: this.sourceLabel(source),
|
|
@@ -8171,7 +8286,7 @@ function mapClaudeEvent(agentId, event) {
|
|
|
8171
8286
|
case "user": {
|
|
8172
8287
|
const content = event?.message?.content;
|
|
8173
8288
|
if (typeof content === "string") {
|
|
8174
|
-
items.push(
|
|
8289
|
+
items.push(new AgentUserMessageItem(agentId, content));
|
|
8175
8290
|
} else if (Array.isArray(content)) {
|
|
8176
8291
|
for (const block of content) {
|
|
8177
8292
|
if (block && typeof block === "object" && block.type === "tool_result") {
|
|
@@ -8244,7 +8359,7 @@ function stringifyToolResultContent(content) {
|
|
|
8244
8359
|
}
|
|
8245
8360
|
|
|
8246
8361
|
// ../baro-orchestrator/src/participants/claude-cli-participant.ts
|
|
8247
|
-
var ClaudeCliParticipant = class _ClaudeCliParticipant extends
|
|
8362
|
+
var ClaudeCliParticipant = class _ClaudeCliParticipant extends BaroParticipant {
|
|
8248
8363
|
constructor(agentId, opts) {
|
|
8249
8364
|
super();
|
|
8250
8365
|
this.agentId = agentId;
|
|
@@ -8376,11 +8491,10 @@ var ClaudeCliParticipant = class _ClaudeCliParticipant extends Participant {
|
|
|
8376
8491
|
this.transition("aborted");
|
|
8377
8492
|
this.proc?.kill(signal);
|
|
8378
8493
|
}
|
|
8379
|
-
async
|
|
8380
|
-
if (
|
|
8381
|
-
if (item instanceof AgentTargetedMessageItem && item.recipientId === this.agentId) {
|
|
8494
|
+
async onExternalBusEvent(_source, event) {
|
|
8495
|
+
if (event instanceof AgentTargetedMessageItem && event.recipientId === this.agentId) {
|
|
8382
8496
|
if (!this.proc?.stdin) return;
|
|
8383
|
-
this.sendUserMessage(
|
|
8497
|
+
this.sendUserMessage(event.text);
|
|
8384
8498
|
}
|
|
8385
8499
|
}
|
|
8386
8500
|
buildArgs() {
|
|
@@ -8451,23 +8565,44 @@ var ClaudeCliParticipant = class _ClaudeCliParticipant extends Participant {
|
|
|
8451
8565
|
this.lastResult = item;
|
|
8452
8566
|
this.transition(item.isError ? "failed" : "done", `result:${item.subtype}`);
|
|
8453
8567
|
}
|
|
8454
|
-
this.
|
|
8568
|
+
this.dispatch(item);
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
/**
|
|
8572
|
+
* Route a mapped stream-json item to the right Mozaik 3.9 delivery
|
|
8573
|
+
* channel. Assistant-side LLM items get their dedicated typed
|
|
8574
|
+
* channels so future Mozaik-native participants can listen
|
|
8575
|
+
* idiomatically; everything else (user-side messages, system frames,
|
|
8576
|
+
* result frames, custom Claude wrappers) rides our `BusEvent` bus.
|
|
8577
|
+
*/
|
|
8578
|
+
dispatch(item) {
|
|
8579
|
+
if (!this.envRef) return;
|
|
8580
|
+
if (item instanceof ModelMessageItem) {
|
|
8581
|
+
this.envRef.deliverModelMessage(this, item);
|
|
8582
|
+
return;
|
|
8583
|
+
}
|
|
8584
|
+
if (item instanceof FunctionCallItem) {
|
|
8585
|
+
this.envRef.deliverFunctionCall(this, item);
|
|
8586
|
+
return;
|
|
8455
8587
|
}
|
|
8588
|
+
if (item instanceof FunctionCallOutputItem) {
|
|
8589
|
+
this.envRef.deliverFunctionCallOutput(this, item);
|
|
8590
|
+
return;
|
|
8591
|
+
}
|
|
8592
|
+
this.envRef.deliverBusEvent(this, item);
|
|
8456
8593
|
}
|
|
8457
8594
|
transition(next, detail) {
|
|
8458
8595
|
if (next === this.currentPhase) return;
|
|
8459
8596
|
this.currentPhase = next;
|
|
8460
|
-
|
|
8461
|
-
this
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
);
|
|
8465
|
-
}
|
|
8597
|
+
this.envRef?.deliverBusEvent(
|
|
8598
|
+
this,
|
|
8599
|
+
new AgentStateItem(this.agentId, next, detail)
|
|
8600
|
+
);
|
|
8466
8601
|
}
|
|
8467
8602
|
};
|
|
8468
8603
|
|
|
8469
8604
|
// ../baro-orchestrator/src/participants/story-agent.ts
|
|
8470
|
-
var StoryResultItem = class extends
|
|
8605
|
+
var StoryResultItem = class extends BusEvent {
|
|
8471
8606
|
constructor(storyId, success, attempts, durationSecs, error) {
|
|
8472
8607
|
super();
|
|
8473
8608
|
this.storyId = storyId;
|
|
@@ -8488,7 +8623,7 @@ var StoryResultItem = class extends ContextItem {
|
|
|
8488
8623
|
};
|
|
8489
8624
|
}
|
|
8490
8625
|
};
|
|
8491
|
-
var StoryAgent = class extends
|
|
8626
|
+
var StoryAgent = class extends BaroParticipant {
|
|
8492
8627
|
spec;
|
|
8493
8628
|
envRef = null;
|
|
8494
8629
|
currentClaude = null;
|
|
@@ -8556,12 +8691,11 @@ var StoryAgent = class extends Participant {
|
|
|
8556
8691
|
* StoryAgent is the sole owner of AgentTargetedMessageItem → stdin
|
|
8557
8692
|
* forwarding. ClaudeCliParticipant.onContextItem does NOT do this.
|
|
8558
8693
|
*/
|
|
8559
|
-
async
|
|
8560
|
-
if (
|
|
8561
|
-
if (item instanceof AgentTargetedMessageItem && item.recipientId === this.spec.id) {
|
|
8694
|
+
async onExternalBusEvent(_source, event) {
|
|
8695
|
+
if (event instanceof AgentTargetedMessageItem && event.recipientId === this.spec.id) {
|
|
8562
8696
|
this.notifyStoryMessage?.();
|
|
8563
8697
|
}
|
|
8564
|
-
if (
|
|
8698
|
+
if (event instanceof ClaudeResultItem && event.agentId === this.spec.id) {
|
|
8565
8699
|
this.notifyStoryResult?.();
|
|
8566
8700
|
}
|
|
8567
8701
|
}
|
|
@@ -8736,7 +8870,7 @@ var StoryAgent = class extends Participant {
|
|
|
8736
8870
|
}
|
|
8737
8871
|
emitStoryResult(success, attempts, durationSecs, error) {
|
|
8738
8872
|
if (!this.envRef) return;
|
|
8739
|
-
this.envRef.
|
|
8873
|
+
this.envRef.deliverBusEvent(
|
|
8740
8874
|
this,
|
|
8741
8875
|
new StoryResultItem(this.spec.id, success, attempts, durationSecs, error)
|
|
8742
8876
|
);
|
|
@@ -8745,7 +8879,7 @@ var StoryAgent = class extends Participant {
|
|
|
8745
8879
|
if (next === this.currentPhase) return;
|
|
8746
8880
|
this.currentPhase = next;
|
|
8747
8881
|
if (this.envRef) {
|
|
8748
|
-
this.envRef.
|
|
8882
|
+
this.envRef.deliverBusEvent(
|
|
8749
8883
|
this,
|
|
8750
8884
|
new AgentStateItem(this.spec.id, next, detail)
|
|
8751
8885
|
);
|
|
@@ -8760,7 +8894,7 @@ function raceWithTimeout(p, ms, label) {
|
|
|
8760
8894
|
}
|
|
8761
8895
|
|
|
8762
8896
|
// ../baro-orchestrator/src/participants/conductor.ts
|
|
8763
|
-
var ConductorStateItem = class extends
|
|
8897
|
+
var ConductorStateItem = class extends BusEvent {
|
|
8764
8898
|
constructor(phase, detail, currentLevel, totalLevels, storyIds) {
|
|
8765
8899
|
super();
|
|
8766
8900
|
this.phase = phase;
|
|
@@ -8781,7 +8915,7 @@ var ConductorStateItem = class extends ContextItem {
|
|
|
8781
8915
|
};
|
|
8782
8916
|
}
|
|
8783
8917
|
};
|
|
8784
|
-
var Conductor = class extends
|
|
8918
|
+
var Conductor = class extends BaroParticipant {
|
|
8785
8919
|
opts;
|
|
8786
8920
|
envRef = null;
|
|
8787
8921
|
phase = "idle";
|
|
@@ -8839,14 +8973,21 @@ var Conductor = class extends Participant {
|
|
|
8839
8973
|
/**
|
|
8840
8974
|
* Single entry point. All state transitions happen here.
|
|
8841
8975
|
*
|
|
8842
|
-
* Note: the
|
|
8843
|
-
*
|
|
8844
|
-
*
|
|
8845
|
-
*
|
|
8846
|
-
*
|
|
8847
|
-
*
|
|
8848
|
-
|
|
8849
|
-
|
|
8976
|
+
* Note: the Conductor self-ticks via LevelComputeRequestItem, so it
|
|
8977
|
+
* MUST receive its own emissions. Mozaik 3.9 splits self vs external
|
|
8978
|
+
* delivery — we route both through the same handler so the state
|
|
8979
|
+
* machine sees every event regardless of source. Per-event type
|
|
8980
|
+
* guards distinguish "from outside" (RunStartRequestItem from
|
|
8981
|
+
* Operator, ReplanItem from Surgeon, StoryResultItem from StoryAgent)
|
|
8982
|
+
* from "from self" (LevelCompute).
|
|
8983
|
+
*/
|
|
8984
|
+
async onBusEvent(event) {
|
|
8985
|
+
await this.handle(event);
|
|
8986
|
+
}
|
|
8987
|
+
async onExternalBusEvent(_source, event) {
|
|
8988
|
+
await this.handle(event);
|
|
8989
|
+
}
|
|
8990
|
+
async handle(item) {
|
|
8850
8991
|
if (item instanceof RunStartRequestItem) {
|
|
8851
8992
|
await this.handleRunStart();
|
|
8852
8993
|
return;
|
|
@@ -9151,8 +9292,8 @@ ${prompt}`;
|
|
|
9151
9292
|
}
|
|
9152
9293
|
return prompt;
|
|
9153
9294
|
}
|
|
9154
|
-
emit(
|
|
9155
|
-
this.envRef?.
|
|
9295
|
+
emit(event) {
|
|
9296
|
+
this.envRef?.deliverBusEvent(this, event);
|
|
9156
9297
|
}
|
|
9157
9298
|
};
|
|
9158
9299
|
function applyReplan(prd, replan) {
|
|
@@ -9222,7 +9363,7 @@ Rules:
|
|
|
9222
9363
|
- "violated_criteria" must list the exact criterion strings that are NOT satisfied.
|
|
9223
9364
|
- If ALL criteria pass, "violated_criteria" must be an empty array.
|
|
9224
9365
|
- Do NOT include any text outside the JSON object.`;
|
|
9225
|
-
var Critic = class extends
|
|
9366
|
+
var Critic = class extends BaroParticipant {
|
|
9226
9367
|
opts;
|
|
9227
9368
|
/** agentId → number of AgentTargetedMessageItem-s emitted so far. */
|
|
9228
9369
|
emissions = /* @__PURE__ */ new Map();
|
|
@@ -9249,20 +9390,20 @@ var Critic = class extends Participant {
|
|
|
9249
9390
|
async idle() {
|
|
9250
9391
|
await Promise.allSettled([...this.pending]);
|
|
9251
9392
|
}
|
|
9252
|
-
async
|
|
9253
|
-
if (!(
|
|
9254
|
-
if (
|
|
9255
|
-
const criteria = this.opts.targets.get(
|
|
9393
|
+
async onExternalBusEvent(_source, event) {
|
|
9394
|
+
if (!(event instanceof ClaudeResultItem)) return;
|
|
9395
|
+
if (event.isError || !event.resultText) return;
|
|
9396
|
+
const criteria = this.opts.targets.get(event.agentId);
|
|
9256
9397
|
if (!criteria || criteria.length === 0) return;
|
|
9257
|
-
const turn = (this.turnCount.get(
|
|
9258
|
-
this.turnCount.set(
|
|
9398
|
+
const turn = (this.turnCount.get(event.agentId) ?? 0) + 1;
|
|
9399
|
+
this.turnCount.set(event.agentId, turn);
|
|
9259
9400
|
const work = (async () => {
|
|
9260
9401
|
const { verdict, reasoning, violatedCriteria } = await this.evaluate(
|
|
9261
|
-
|
|
9402
|
+
event.resultText,
|
|
9262
9403
|
criteria
|
|
9263
9404
|
);
|
|
9264
9405
|
const critiqueItem = new CritiqueItem(
|
|
9265
|
-
|
|
9406
|
+
event.agentId,
|
|
9266
9407
|
verdict,
|
|
9267
9408
|
reasoning,
|
|
9268
9409
|
violatedCriteria,
|
|
@@ -9270,20 +9411,22 @@ var Critic = class extends Participant {
|
|
|
9270
9411
|
this.opts.model
|
|
9271
9412
|
);
|
|
9272
9413
|
for (const env of this.getEnvironments()) {
|
|
9273
|
-
|
|
9414
|
+
;
|
|
9415
|
+
env.deliverBusEvent(this, critiqueItem);
|
|
9274
9416
|
}
|
|
9275
9417
|
if (verdict === "fail") {
|
|
9276
|
-
const emitted = this.emissions.get(
|
|
9418
|
+
const emitted = this.emissions.get(event.agentId) ?? 0;
|
|
9277
9419
|
if (emitted < this.opts.maxEmissionsPerAgent) {
|
|
9278
|
-
this.emissions.set(
|
|
9420
|
+
this.emissions.set(event.agentId, emitted + 1);
|
|
9279
9421
|
const text = buildCorrectiveMessage(reasoning, violatedCriteria);
|
|
9280
9422
|
const msg = new AgentTargetedMessageItem(
|
|
9281
|
-
|
|
9423
|
+
event.agentId,
|
|
9282
9424
|
text,
|
|
9283
9425
|
{ criticTurn: turn, emissionIndex: emitted + 1 }
|
|
9284
9426
|
);
|
|
9285
9427
|
for (const env of this.getEnvironments()) {
|
|
9286
|
-
|
|
9428
|
+
;
|
|
9429
|
+
env.deliverBusEvent(this, msg);
|
|
9287
9430
|
}
|
|
9288
9431
|
}
|
|
9289
9432
|
}
|
|
@@ -9394,7 +9537,7 @@ function extractVerdictJson(text) {
|
|
|
9394
9537
|
import { execFile as execFile3 } from "child_process";
|
|
9395
9538
|
import { promisify as promisify3 } from "util";
|
|
9396
9539
|
var execFileAsync2 = promisify3(execFile3);
|
|
9397
|
-
var Finalizer = class extends
|
|
9540
|
+
var Finalizer = class extends BaroParticipant {
|
|
9398
9541
|
opts;
|
|
9399
9542
|
envRef = null;
|
|
9400
9543
|
startedAtMs = null;
|
|
@@ -9428,7 +9571,7 @@ var Finalizer = class extends Participant {
|
|
|
9428
9571
|
setEnvironment(env) {
|
|
9429
9572
|
this.envRef = env;
|
|
9430
9573
|
}
|
|
9431
|
-
async
|
|
9574
|
+
async onExternalBusEvent(_source, item) {
|
|
9432
9575
|
if (item instanceof RunStartedItem) {
|
|
9433
9576
|
this.startedAtMs = Date.now();
|
|
9434
9577
|
if (this.baseSha == null) {
|
|
@@ -9561,8 +9704,8 @@ var Finalizer = class extends Participant {
|
|
|
9561
9704
|
this.emit(new PrCreatedItem(url, branch, baseBranch));
|
|
9562
9705
|
}
|
|
9563
9706
|
// ─── Bus & env helpers ──────────────────────────────────────────
|
|
9564
|
-
emit(
|
|
9565
|
-
this.envRef?.
|
|
9707
|
+
emit(event) {
|
|
9708
|
+
this.envRef?.deliverBusEvent(this, event);
|
|
9566
9709
|
}
|
|
9567
9710
|
log(line) {
|
|
9568
9711
|
this.opts.onLog?.(line);
|
|
@@ -9844,7 +9987,7 @@ var EXPLORATION_TOOLS = /* @__PURE__ */ new Set([
|
|
|
9844
9987
|
"WebSearch"
|
|
9845
9988
|
]);
|
|
9846
9989
|
var BROADCAST_TOOLS = /* @__PURE__ */ new Set(["Read", "Grep", "Glob", "LSP"]);
|
|
9847
|
-
var Librarian = class extends
|
|
9990
|
+
var Librarian = class extends BaroParticipant {
|
|
9848
9991
|
opts;
|
|
9849
9992
|
pending = /* @__PURE__ */ new Map();
|
|
9850
9993
|
knowledge = [];
|
|
@@ -9907,26 +10050,23 @@ var Librarian = class extends Participant {
|
|
|
9907
10050
|
...lines
|
|
9908
10051
|
].join("\n");
|
|
9909
10052
|
}
|
|
9910
|
-
async
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
if (item instanceof StorySpawnRequestItem) {
|
|
9920
|
-
this.storyHints.set(item.storyId, tokenizeHints(item.prompt));
|
|
10053
|
+
async onExternalFunctionCall(source, item) {
|
|
10054
|
+
this.recordPending(source, item);
|
|
10055
|
+
}
|
|
10056
|
+
async onExternalFunctionCallOutput(source, item) {
|
|
10057
|
+
this.completeWithOutput(source, item);
|
|
10058
|
+
}
|
|
10059
|
+
async onExternalBusEvent(_source, event) {
|
|
10060
|
+
if (event instanceof StorySpawnRequestItem) {
|
|
10061
|
+
this.storyHints.set(event.storyId, tokenizeHints(event.prompt));
|
|
9921
10062
|
return;
|
|
9922
10063
|
}
|
|
9923
|
-
if (
|
|
9924
|
-
this.inFlight.add(
|
|
10064
|
+
if (event instanceof StorySpawnedItem) {
|
|
10065
|
+
this.inFlight.add(event.storyId);
|
|
9925
10066
|
return;
|
|
9926
10067
|
}
|
|
9927
|
-
if (
|
|
9928
|
-
this.inFlight.delete(
|
|
9929
|
-
return;
|
|
10068
|
+
if (event instanceof StoryResultItem) {
|
|
10069
|
+
this.inFlight.delete(event.storyId);
|
|
9930
10070
|
}
|
|
9931
10071
|
}
|
|
9932
10072
|
recordPending(source, item) {
|
|
@@ -9963,7 +10103,7 @@ var Librarian = class extends Participant {
|
|
|
9963
10103
|
};
|
|
9964
10104
|
this.knowledge.push(entry);
|
|
9965
10105
|
for (const env of this.getEnvironments()) {
|
|
9966
|
-
env.
|
|
10106
|
+
env.deliverBusEvent(
|
|
9967
10107
|
this,
|
|
9968
10108
|
new KnowledgeItem(
|
|
9969
10109
|
entry.sourceAgentId,
|
|
@@ -10009,7 +10149,7 @@ var Librarian = class extends Participant {
|
|
|
10009
10149
|
if (already + bytes > this.opts.maxBroadcastBytesPerStory) continue;
|
|
10010
10150
|
this.broadcastBytes.set(recipientId, already + bytes);
|
|
10011
10151
|
for (const env of envs) {
|
|
10012
|
-
env.
|
|
10152
|
+
env.deliverBusEvent(
|
|
10013
10153
|
this,
|
|
10014
10154
|
new AgentTargetedMessageItem(recipientId, text, {
|
|
10015
10155
|
source: "librarian",
|
|
@@ -10076,7 +10216,7 @@ function tokenizeHints(prompt) {
|
|
|
10076
10216
|
}
|
|
10077
10217
|
|
|
10078
10218
|
// ../baro-orchestrator/src/participants/operator.ts
|
|
10079
|
-
var Operator = class extends
|
|
10219
|
+
var Operator = class extends BaroParticipant {
|
|
10080
10220
|
constructor(hooks = {}) {
|
|
10081
10221
|
super();
|
|
10082
10222
|
this.hooks = hooks;
|
|
@@ -10085,8 +10225,9 @@ var Operator = class extends Participant {
|
|
|
10085
10225
|
setEnvironment(env) {
|
|
10086
10226
|
this.envRef = env;
|
|
10087
10227
|
}
|
|
10088
|
-
|
|
10089
|
-
|
|
10228
|
+
// Operator is push-only: it emits in response to external commands,
|
|
10229
|
+
// never reacts to bus events. Default BaroParticipant no-op handlers
|
|
10230
|
+
// cover everything.
|
|
10090
10231
|
/** Translate an external command into bus action / hook callback. */
|
|
10091
10232
|
dispatch(cmd) {
|
|
10092
10233
|
switch (cmd.kind) {
|
|
@@ -10112,14 +10253,14 @@ var Operator = class extends Participant {
|
|
|
10112
10253
|
}
|
|
10113
10254
|
}
|
|
10114
10255
|
}
|
|
10115
|
-
emit(
|
|
10116
|
-
this.envRef?.
|
|
10256
|
+
emit(event) {
|
|
10257
|
+
this.envRef?.deliverBusEvent(this, event);
|
|
10117
10258
|
}
|
|
10118
10259
|
};
|
|
10119
10260
|
|
|
10120
10261
|
// ../baro-orchestrator/src/participants/sentry.ts
|
|
10121
10262
|
var WRITE_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
10122
|
-
var Sentry = class extends
|
|
10263
|
+
var Sentry = class extends BaroParticipant {
|
|
10123
10264
|
opts;
|
|
10124
10265
|
/** path → set of agentIds that have touched it. */
|
|
10125
10266
|
touchedBy = /* @__PURE__ */ new Map();
|
|
@@ -10139,53 +10280,50 @@ var Sentry = class extends Participant {
|
|
|
10139
10280
|
getTouches() {
|
|
10140
10281
|
return this.touches;
|
|
10141
10282
|
}
|
|
10142
|
-
async
|
|
10143
|
-
if (
|
|
10144
|
-
if (
|
|
10145
|
-
this.terminalPhase.set(
|
|
10283
|
+
async onExternalBusEvent(_source, event) {
|
|
10284
|
+
if (event instanceof AgentStateItem) {
|
|
10285
|
+
if (event.phase === "done" || event.phase === "failed" || event.phase === "aborted") {
|
|
10286
|
+
this.terminalPhase.set(event.agentId, event.phase);
|
|
10146
10287
|
}
|
|
10147
|
-
return;
|
|
10148
10288
|
}
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
}
|
|
10188
|
-
return;
|
|
10289
|
+
}
|
|
10290
|
+
async onExternalFunctionCall(source, item) {
|
|
10291
|
+
if (!WRITE_TOOLS.has(item.name)) return;
|
|
10292
|
+
const agentId = source.agentId;
|
|
10293
|
+
if (typeof agentId !== "string") return;
|
|
10294
|
+
const path2 = extractPath(item);
|
|
10295
|
+
if (!path2) return;
|
|
10296
|
+
const touch = {
|
|
10297
|
+
agentId,
|
|
10298
|
+
path: path2,
|
|
10299
|
+
tool: item.name,
|
|
10300
|
+
at: Date.now()
|
|
10301
|
+
};
|
|
10302
|
+
this.touches.push(touch);
|
|
10303
|
+
const set = this.touchedBy.get(path2) ?? /* @__PURE__ */ new Set();
|
|
10304
|
+
set.add(agentId);
|
|
10305
|
+
this.touchedBy.set(path2, set);
|
|
10306
|
+
const otherAgents = [...set].filter((a) => a !== agentId);
|
|
10307
|
+
if (otherAgents.length === 0) return;
|
|
10308
|
+
this.opts.onOverlap?.({
|
|
10309
|
+
path: path2,
|
|
10310
|
+
agents: [agentId, ...otherAgents]
|
|
10311
|
+
});
|
|
10312
|
+
if (!this.opts.emitNotice || this.noticedPaths.has(path2)) return;
|
|
10313
|
+
this.noticedPaths.add(path2);
|
|
10314
|
+
const reason = `agents [${[agentId, ...otherAgents].join(", ")}] both touched ${path2}`;
|
|
10315
|
+
for (const env of this.getEnvironments()) {
|
|
10316
|
+
;
|
|
10317
|
+
env.deliverBusEvent(
|
|
10318
|
+
this,
|
|
10319
|
+
new CoordinationItem(
|
|
10320
|
+
agentId,
|
|
10321
|
+
otherAgents[0],
|
|
10322
|
+
"notice",
|
|
10323
|
+
reason,
|
|
10324
|
+
{ path: path2, agents: [agentId, ...otherAgents] }
|
|
10325
|
+
)
|
|
10326
|
+
);
|
|
10189
10327
|
}
|
|
10190
10328
|
}
|
|
10191
10329
|
};
|
|
@@ -10204,7 +10342,7 @@ function extractPath(item) {
|
|
|
10204
10342
|
}
|
|
10205
10343
|
|
|
10206
10344
|
// ../baro-orchestrator/src/participants/story-factory.ts
|
|
10207
|
-
var StoryFactory = class extends
|
|
10345
|
+
var StoryFactory = class extends BaroParticipant {
|
|
10208
10346
|
constructor(opts) {
|
|
10209
10347
|
super();
|
|
10210
10348
|
this.opts = opts;
|
|
@@ -10214,17 +10352,16 @@ var StoryFactory = class extends Participant {
|
|
|
10214
10352
|
setEnvironment(env) {
|
|
10215
10353
|
this.envRef = env;
|
|
10216
10354
|
}
|
|
10217
|
-
async
|
|
10218
|
-
if (
|
|
10219
|
-
|
|
10220
|
-
await this.spawn(item);
|
|
10355
|
+
async onExternalBusEvent(_source, event) {
|
|
10356
|
+
if (event instanceof StorySpawnRequestItem) {
|
|
10357
|
+
await this.spawn(event);
|
|
10221
10358
|
return;
|
|
10222
10359
|
}
|
|
10223
|
-
if (
|
|
10224
|
-
const agent = this.active.get(
|
|
10360
|
+
if (event instanceof StoryResultItem) {
|
|
10361
|
+
const agent = this.active.get(event.storyId);
|
|
10225
10362
|
if (agent && this.envRef) {
|
|
10226
10363
|
agent.leave(this.envRef);
|
|
10227
|
-
this.active.delete(
|
|
10364
|
+
this.active.delete(event.storyId);
|
|
10228
10365
|
}
|
|
10229
10366
|
}
|
|
10230
10367
|
}
|
|
@@ -10242,7 +10379,7 @@ var StoryFactory = class extends Participant {
|
|
|
10242
10379
|
agent.join(this.envRef);
|
|
10243
10380
|
this.active.set(req.storyId, agent);
|
|
10244
10381
|
void agent.run(this.envRef);
|
|
10245
|
-
this.envRef.
|
|
10382
|
+
this.envRef.deliverBusEvent(this, new StorySpawnedItem(req.storyId));
|
|
10246
10383
|
}
|
|
10247
10384
|
};
|
|
10248
10385
|
|
|
@@ -10302,7 +10439,7 @@ Rules:
|
|
|
10302
10439
|
of a removed story to a replacement.
|
|
10303
10440
|
- "abort" \u2192 empty added/removed/modifiedDeps arrays.
|
|
10304
10441
|
- Output ONLY the JSON object, nothing else.`;
|
|
10305
|
-
var Surgeon = class extends
|
|
10442
|
+
var Surgeon = class extends BaroParticipant {
|
|
10306
10443
|
opts;
|
|
10307
10444
|
replansEmitted = 0;
|
|
10308
10445
|
pending = /* @__PURE__ */ new Set();
|
|
@@ -10321,16 +10458,17 @@ var Surgeon = class extends Participant {
|
|
|
10321
10458
|
async idle() {
|
|
10322
10459
|
await Promise.allSettled([...this.pending]);
|
|
10323
10460
|
}
|
|
10324
|
-
async
|
|
10325
|
-
if (!(
|
|
10326
|
-
if (
|
|
10461
|
+
async onExternalBusEvent(_source, event) {
|
|
10462
|
+
if (!(event instanceof StoryResultItem)) return;
|
|
10463
|
+
if (event.success) return;
|
|
10327
10464
|
if (this.replansEmitted >= this.opts.maxReplans) return;
|
|
10328
10465
|
const work = (async () => {
|
|
10329
|
-
const replan = this.opts.useLlm ? await this.evaluateWithLlm(
|
|
10466
|
+
const replan = this.opts.useLlm ? await this.evaluateWithLlm(event) : this.evaluateDeterministic(event);
|
|
10330
10467
|
if (!replan) return;
|
|
10331
10468
|
this.replansEmitted += 1;
|
|
10332
10469
|
for (const env of this.getEnvironments()) {
|
|
10333
|
-
|
|
10470
|
+
;
|
|
10471
|
+
env.deliverBusEvent(this, replan);
|
|
10334
10472
|
}
|
|
10335
10473
|
})();
|
|
10336
10474
|
this.pending.add(work);
|
|
@@ -10464,8 +10602,14 @@ function emit(event) {
|
|
|
10464
10602
|
|
|
10465
10603
|
// ../baro-orchestrator/src/orchestrate.ts
|
|
10466
10604
|
async function orchestrate(config) {
|
|
10467
|
-
const env = new
|
|
10605
|
+
const env = new BaroEnvironment();
|
|
10468
10606
|
const emitTui = config.emitTuiEvents ?? true;
|
|
10607
|
+
const llm = config.llm ?? "claude";
|
|
10608
|
+
if (llm === "openai") {
|
|
10609
|
+
process.stderr.write(
|
|
10610
|
+
"[orchestrate] llm=openai requested \u2014 no native OpenAI siblings wired yet, falling through to Claude CLI flow. Coming in 0.29+.\n"
|
|
10611
|
+
);
|
|
10612
|
+
}
|
|
10469
10613
|
if (config.auditLogPath) {
|
|
10470
10614
|
mkdirSync2(dirname2(config.auditLogPath), { recursive: true });
|
|
10471
10615
|
new Auditor({ path: config.auditLogPath }).join(env);
|
|
@@ -10608,7 +10752,7 @@ async function orchestrate(config) {
|
|
|
10608
10752
|
);
|
|
10609
10753
|
emit({ type: "dag", levels: dagLevels });
|
|
10610
10754
|
}
|
|
10611
|
-
env.
|
|
10755
|
+
env.deliverBusEvent(operator, new RunStartRequestItem("orchestrate"));
|
|
10612
10756
|
const summary = await conductor.done;
|
|
10613
10757
|
if (critic) await critic.idle();
|
|
10614
10758
|
if (surgeon) await surgeon.idle();
|
|
@@ -10641,59 +10785,56 @@ async function orchestrate(config) {
|
|
|
10641
10785
|
storyAgents: /* @__PURE__ */ new Map()
|
|
10642
10786
|
};
|
|
10643
10787
|
}
|
|
10644
|
-
var BaroEventForwarder = class extends
|
|
10788
|
+
var BaroEventForwarder = class extends BaroParticipant {
|
|
10645
10789
|
/** Story IDs that have already received a `story_start`. */
|
|
10646
10790
|
startedStories = /* @__PURE__ */ new Set();
|
|
10647
10791
|
/** Number of in-flight retry attempts per story (for `story_retry`). */
|
|
10648
10792
|
retryCounts = /* @__PURE__ */ new Map();
|
|
10649
10793
|
/** Token-usage tally per story (incrementally updated from results). */
|
|
10650
10794
|
tokensByStory = /* @__PURE__ */ new Map();
|
|
10651
|
-
async
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10795
|
+
async onExternalModelMessage(source, item) {
|
|
10796
|
+
this.handleModelMessage(source, item);
|
|
10797
|
+
}
|
|
10798
|
+
async onExternalFunctionCall(source, item) {
|
|
10799
|
+
this.handleToolCall(source, item);
|
|
10800
|
+
}
|
|
10801
|
+
async onExternalFunctionCallOutput(source, item) {
|
|
10802
|
+
this.handleToolResult(source, item);
|
|
10803
|
+
}
|
|
10804
|
+
async onExternalBusEvent(_source, event) {
|
|
10805
|
+
if (event instanceof ConductorStateItem) {
|
|
10806
|
+
this.handleConductorState(event);
|
|
10658
10807
|
return;
|
|
10659
10808
|
}
|
|
10660
|
-
if (
|
|
10661
|
-
this.
|
|
10809
|
+
if (event instanceof StoryResultItem) {
|
|
10810
|
+
this.handleStoryResult(event);
|
|
10662
10811
|
return;
|
|
10663
10812
|
}
|
|
10664
|
-
if (
|
|
10665
|
-
this.
|
|
10813
|
+
if (event instanceof ClaudeResultItem) {
|
|
10814
|
+
this.handleClaudeResult(event);
|
|
10666
10815
|
return;
|
|
10667
10816
|
}
|
|
10668
|
-
if (
|
|
10817
|
+
if (event instanceof AgentStateItem) {
|
|
10818
|
+
this.handleAgentState(event);
|
|
10669
10819
|
return;
|
|
10670
10820
|
}
|
|
10671
|
-
if (
|
|
10672
|
-
this.handleModelMessage(source, item);
|
|
10821
|
+
if (event instanceof ClaudeSystemItem) {
|
|
10673
10822
|
return;
|
|
10674
10823
|
}
|
|
10675
|
-
if (
|
|
10676
|
-
this.
|
|
10824
|
+
if (event instanceof CoordinationItem) {
|
|
10825
|
+
this.handleCoordination(event);
|
|
10677
10826
|
return;
|
|
10678
10827
|
}
|
|
10679
|
-
if (
|
|
10680
|
-
this.
|
|
10828
|
+
if (event instanceof CritiqueItem) {
|
|
10829
|
+
this.handleCritique(event);
|
|
10681
10830
|
return;
|
|
10682
10831
|
}
|
|
10683
|
-
if (
|
|
10684
|
-
this.handleCoordination(item);
|
|
10685
|
-
return;
|
|
10686
|
-
}
|
|
10687
|
-
if (item instanceof CritiqueItem) {
|
|
10688
|
-
this.handleCritique(item);
|
|
10689
|
-
return;
|
|
10690
|
-
}
|
|
10691
|
-
if (item instanceof FinalizeStartedItem) {
|
|
10832
|
+
if (event instanceof FinalizeStartedItem) {
|
|
10692
10833
|
emit({ type: "finalize_start" });
|
|
10693
10834
|
return;
|
|
10694
10835
|
}
|
|
10695
|
-
if (
|
|
10696
|
-
emit({ type: "finalize_complete", pr_url:
|
|
10836
|
+
if (event instanceof PrCreatedItem) {
|
|
10837
|
+
emit({ type: "finalize_complete", pr_url: event.url });
|
|
10697
10838
|
return;
|
|
10698
10839
|
}
|
|
10699
10840
|
}
|
|
@@ -10823,6 +10964,7 @@ function parseArgs(argv) {
|
|
|
10823
10964
|
noSentry: false,
|
|
10824
10965
|
withSurgeon: false,
|
|
10825
10966
|
surgeonUseLlm: false,
|
|
10967
|
+
llm: "claude",
|
|
10826
10968
|
help: false
|
|
10827
10969
|
};
|
|
10828
10970
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -10883,6 +11025,16 @@ function parseArgs(argv) {
|
|
|
10883
11025
|
10
|
|
10884
11026
|
);
|
|
10885
11027
|
break;
|
|
11028
|
+
case "--llm": {
|
|
11029
|
+
const v = required(argv, ++i, "--llm");
|
|
11030
|
+
if (v !== "claude" && v !== "openai") {
|
|
11031
|
+
process.stderr.write(`[cli] --llm must be 'claude' or 'openai', got '${v}'
|
|
11032
|
+
`);
|
|
11033
|
+
process.exit(2);
|
|
11034
|
+
}
|
|
11035
|
+
args.llm = v;
|
|
11036
|
+
break;
|
|
11037
|
+
}
|
|
10886
11038
|
default:
|
|
10887
11039
|
process.stderr.write(`[cli] unknown flag: ${a}
|
|
10888
11040
|
`);
|
|
@@ -10960,10 +11112,16 @@ async function main() {
|
|
|
10960
11112
|
withSurgeon: args.withSurgeon,
|
|
10961
11113
|
surgeonUseLlm: args.surgeonUseLlm,
|
|
10962
11114
|
surgeonModel: args.surgeonModel,
|
|
10963
|
-
intraLevelDelaySecs: args.intraLevelDelaySecs
|
|
11115
|
+
intraLevelDelaySecs: args.intraLevelDelaySecs,
|
|
11116
|
+
llm: args.llm
|
|
10964
11117
|
};
|
|
11118
|
+
if (args.llm === "openai" && !process.env.OPENAI_API_KEY) {
|
|
11119
|
+
process.stderr.write(
|
|
11120
|
+
"[cli] WARNING: --llm openai requested but OPENAI_API_KEY is not set.\n[cli] The current build falls through to Claude behaviour;\n[cli] set OPENAI_API_KEY before phase 3+ OpenAI siblings ship.\n"
|
|
11121
|
+
);
|
|
11122
|
+
}
|
|
10965
11123
|
process.stderr.write(
|
|
10966
|
-
`[cli] starting orchestrator: prd=${prdPath} cwd=${cwd} parallel=${args.parallel} timeout=${args.timeout}s
|
|
11124
|
+
`[cli] starting orchestrator: prd=${prdPath} cwd=${cwd} parallel=${args.parallel} timeout=${args.timeout}s llm=${args.llm}
|
|
10967
11125
|
`
|
|
10968
11126
|
);
|
|
10969
11127
|
const startedAt = Date.now();
|