@cleocode/cleo 2026.4.115 → 2026.4.117
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/index.js +188 -2
- package/dist/cli/index.js.map +2 -2
- package/package.json +9 -9
package/dist/cli/index.js
CHANGED
|
@@ -16459,6 +16459,15 @@ var init_conduit2 = __esm({
|
|
|
16459
16459
|
);
|
|
16460
16460
|
return wrapResult(result, "query", "conduit", operation, startTime);
|
|
16461
16461
|
}
|
|
16462
|
+
case "listen": {
|
|
16463
|
+
const result = await this.listenTopic(
|
|
16464
|
+
params?.topicName,
|
|
16465
|
+
params?.agentId,
|
|
16466
|
+
params?.limit,
|
|
16467
|
+
params?.since
|
|
16468
|
+
);
|
|
16469
|
+
return wrapResult(result, "query", "conduit", operation, startTime);
|
|
16470
|
+
}
|
|
16462
16471
|
default:
|
|
16463
16472
|
return unsupportedOp("query", "conduit", operation, startTime);
|
|
16464
16473
|
}
|
|
@@ -16498,6 +16507,24 @@ var init_conduit2 = __esm({
|
|
|
16498
16507
|
);
|
|
16499
16508
|
return wrapResult(result, "mutate", "conduit", operation, startTime);
|
|
16500
16509
|
}
|
|
16510
|
+
case "subscribe": {
|
|
16511
|
+
const result = await this.subscribeTopic(
|
|
16512
|
+
params?.topicName,
|
|
16513
|
+
params?.agentId,
|
|
16514
|
+
params?.filter
|
|
16515
|
+
);
|
|
16516
|
+
return wrapResult(result, "mutate", "conduit", operation, startTime);
|
|
16517
|
+
}
|
|
16518
|
+
case "publish": {
|
|
16519
|
+
const result = await this.publishToTopic(
|
|
16520
|
+
params?.topicName,
|
|
16521
|
+
params?.content,
|
|
16522
|
+
params?.kind,
|
|
16523
|
+
params?.payload,
|
|
16524
|
+
params?.agentId
|
|
16525
|
+
);
|
|
16526
|
+
return wrapResult(result, "mutate", "conduit", operation, startTime);
|
|
16527
|
+
}
|
|
16501
16528
|
default:
|
|
16502
16529
|
return unsupportedOp("mutate", "conduit", operation, startTime);
|
|
16503
16530
|
}
|
|
@@ -16514,8 +16541,8 @@ var init_conduit2 = __esm({
|
|
|
16514
16541
|
}
|
|
16515
16542
|
getSupportedOperations() {
|
|
16516
16543
|
return {
|
|
16517
|
-
query: ["status", "peek"],
|
|
16518
|
-
mutate: ["start", "stop", "send"]
|
|
16544
|
+
query: ["status", "peek", "listen"],
|
|
16545
|
+
mutate: ["start", "stop", "send", "subscribe", "publish"]
|
|
16519
16546
|
};
|
|
16520
16547
|
}
|
|
16521
16548
|
// ---------------------------------------------------------------------------
|
|
@@ -16722,6 +16749,165 @@ var init_conduit2 = __esm({
|
|
|
16722
16749
|
}
|
|
16723
16750
|
};
|
|
16724
16751
|
}
|
|
16752
|
+
// ── A2A Topic Operations (T1252) ────────────────────────────────────────
|
|
16753
|
+
/**
|
|
16754
|
+
* Subscribe agent to a named topic.
|
|
16755
|
+
*
|
|
16756
|
+
* Uses `LocalTransport` exclusively — topic operations require conduit.db.
|
|
16757
|
+
*
|
|
16758
|
+
* @param topicName - Topic name, e.g. `"epic-T1149.wave-2"`.
|
|
16759
|
+
* @param agentId - Agent id (defaults to active agent).
|
|
16760
|
+
* @param _filter - Reserved for future filter support.
|
|
16761
|
+
* @task T1252
|
|
16762
|
+
*/
|
|
16763
|
+
async subscribeTopic(topicName, agentId, _filter) {
|
|
16764
|
+
if (!topicName) {
|
|
16765
|
+
return {
|
|
16766
|
+
success: false,
|
|
16767
|
+
error: { code: "E_ARGS", message: 'Must specify "topicName"' }
|
|
16768
|
+
};
|
|
16769
|
+
}
|
|
16770
|
+
const credential = await this.resolveCredential(agentId);
|
|
16771
|
+
const { LocalTransport } = await import("@cleocode/core/conduit");
|
|
16772
|
+
if (!LocalTransport.isAvailable(process.cwd())) {
|
|
16773
|
+
return {
|
|
16774
|
+
success: false,
|
|
16775
|
+
error: { code: "E_CONDUIT", message: "conduit.db not found \u2014 run: cleo init" }
|
|
16776
|
+
};
|
|
16777
|
+
}
|
|
16778
|
+
const transport = new LocalTransport();
|
|
16779
|
+
await transport.connect({
|
|
16780
|
+
agentId: credential.agentId,
|
|
16781
|
+
apiKey: credential.apiKey,
|
|
16782
|
+
apiBaseUrl: credential.apiBaseUrl
|
|
16783
|
+
});
|
|
16784
|
+
try {
|
|
16785
|
+
await transport.subscribeTopic(topicName);
|
|
16786
|
+
return {
|
|
16787
|
+
success: true,
|
|
16788
|
+
data: {
|
|
16789
|
+
agentId: credential.agentId,
|
|
16790
|
+
topicName,
|
|
16791
|
+
message: `Subscribed to topic: ${topicName}`
|
|
16792
|
+
}
|
|
16793
|
+
};
|
|
16794
|
+
} finally {
|
|
16795
|
+
await transport.disconnect();
|
|
16796
|
+
}
|
|
16797
|
+
}
|
|
16798
|
+
/**
|
|
16799
|
+
* Publish a message to a named topic.
|
|
16800
|
+
*
|
|
16801
|
+
* Uses `LocalTransport` exclusively — topic operations require conduit.db.
|
|
16802
|
+
*
|
|
16803
|
+
* @param topicName - Target topic name.
|
|
16804
|
+
* @param content - Message content (required).
|
|
16805
|
+
* @param kind - Message kind (default `"message"`).
|
|
16806
|
+
* @param payload - Optional structured payload.
|
|
16807
|
+
* @param agentId - Publisher agent id (defaults to active agent).
|
|
16808
|
+
* @task T1252
|
|
16809
|
+
*/
|
|
16810
|
+
async publishToTopic(topicName, content, kind, payload, agentId) {
|
|
16811
|
+
if (!topicName) {
|
|
16812
|
+
return {
|
|
16813
|
+
success: false,
|
|
16814
|
+
error: { code: "E_ARGS", message: 'Must specify "topicName"' }
|
|
16815
|
+
};
|
|
16816
|
+
}
|
|
16817
|
+
if (!content) {
|
|
16818
|
+
return {
|
|
16819
|
+
success: false,
|
|
16820
|
+
error: { code: "E_ARGS", message: 'Must specify "content"' }
|
|
16821
|
+
};
|
|
16822
|
+
}
|
|
16823
|
+
const credential = await this.resolveCredential(agentId);
|
|
16824
|
+
const { LocalTransport } = await import("@cleocode/core/conduit");
|
|
16825
|
+
if (!LocalTransport.isAvailable(process.cwd())) {
|
|
16826
|
+
return {
|
|
16827
|
+
success: false,
|
|
16828
|
+
error: { code: "E_CONDUIT", message: "conduit.db not found \u2014 run: cleo init" }
|
|
16829
|
+
};
|
|
16830
|
+
}
|
|
16831
|
+
const transport = new LocalTransport();
|
|
16832
|
+
await transport.connect({
|
|
16833
|
+
agentId: credential.agentId,
|
|
16834
|
+
apiKey: credential.apiKey,
|
|
16835
|
+
apiBaseUrl: credential.apiBaseUrl
|
|
16836
|
+
});
|
|
16837
|
+
try {
|
|
16838
|
+
const result = await transport.publishToTopic(topicName, content, { kind, payload });
|
|
16839
|
+
return {
|
|
16840
|
+
success: true,
|
|
16841
|
+
data: {
|
|
16842
|
+
messageId: result.messageId,
|
|
16843
|
+
from: credential.agentId,
|
|
16844
|
+
topicName,
|
|
16845
|
+
transport: "local",
|
|
16846
|
+
publishedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16847
|
+
}
|
|
16848
|
+
};
|
|
16849
|
+
} finally {
|
|
16850
|
+
await transport.disconnect();
|
|
16851
|
+
}
|
|
16852
|
+
}
|
|
16853
|
+
/**
|
|
16854
|
+
* One-shot poll for topic messages.
|
|
16855
|
+
*
|
|
16856
|
+
* Returns messages published to the topic (ordered oldest-first).
|
|
16857
|
+
* Uses `LocalTransport` exclusively — topic operations require conduit.db.
|
|
16858
|
+
*
|
|
16859
|
+
* @param topicName - Topic name to poll.
|
|
16860
|
+
* @param agentId - Agent id (defaults to active agent).
|
|
16861
|
+
* @param limit - Maximum messages to return (default 50).
|
|
16862
|
+
* @param since - Return only messages after this ISO 8601 timestamp.
|
|
16863
|
+
* @task T1252
|
|
16864
|
+
*/
|
|
16865
|
+
async listenTopic(topicName, agentId, limit, since) {
|
|
16866
|
+
if (!topicName) {
|
|
16867
|
+
return {
|
|
16868
|
+
success: false,
|
|
16869
|
+
error: { code: "E_ARGS", message: 'Must specify "topicName"' }
|
|
16870
|
+
};
|
|
16871
|
+
}
|
|
16872
|
+
const startMs = Date.now();
|
|
16873
|
+
const credential = await this.resolveCredential(agentId);
|
|
16874
|
+
const { LocalTransport } = await import("@cleocode/core/conduit");
|
|
16875
|
+
if (!LocalTransport.isAvailable(process.cwd())) {
|
|
16876
|
+
return {
|
|
16877
|
+
success: false,
|
|
16878
|
+
error: { code: "E_CONDUIT", message: "conduit.db not found \u2014 run: cleo init" }
|
|
16879
|
+
};
|
|
16880
|
+
}
|
|
16881
|
+
const transport = new LocalTransport();
|
|
16882
|
+
await transport.connect({
|
|
16883
|
+
agentId: credential.agentId,
|
|
16884
|
+
apiKey: credential.apiKey,
|
|
16885
|
+
apiBaseUrl: credential.apiBaseUrl
|
|
16886
|
+
});
|
|
16887
|
+
try {
|
|
16888
|
+
const sinceUnix = since ? Math.floor(new Date(since).getTime() / 1e3) : 0;
|
|
16889
|
+
const messages = await transport.pollTopic(topicName, {
|
|
16890
|
+
limit: limit ?? 50,
|
|
16891
|
+
since: sinceUnix
|
|
16892
|
+
});
|
|
16893
|
+
return {
|
|
16894
|
+
success: true,
|
|
16895
|
+
data: {
|
|
16896
|
+
topicName,
|
|
16897
|
+
messages: messages.map((m) => ({
|
|
16898
|
+
id: m.id,
|
|
16899
|
+
from: m.from,
|
|
16900
|
+
content: m.content,
|
|
16901
|
+
conversationId: m.threadId,
|
|
16902
|
+
timestamp: m.timestamp
|
|
16903
|
+
})),
|
|
16904
|
+
listenedForMs: Date.now() - startMs
|
|
16905
|
+
}
|
|
16906
|
+
};
|
|
16907
|
+
} finally {
|
|
16908
|
+
await transport.disconnect();
|
|
16909
|
+
}
|
|
16910
|
+
}
|
|
16725
16911
|
/** Send a message to an agent or conversation. Uses LocalTransport when conduit.db is available. */
|
|
16726
16912
|
async sendMessage(content, to, conversationId, agentId) {
|
|
16727
16913
|
if (!to && !conversationId) {
|