@songsid/agend 2.1.4-beta.53 → 2.1.4-beta.55
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/instructions.js
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
function isClassicInstance(params) {
|
|
5
|
+
return params.runtimeIdentity?.kind === "classic";
|
|
6
|
+
}
|
|
7
|
+
function mcpCrossInstanceReplyRule(classic) {
|
|
8
|
+
if (!classic) {
|
|
9
|
+
return "- `[from:instance-name]` → answer with `send_to_instance`, or `report_result` with the correlation_id shown. Never `reply`.";
|
|
10
|
+
}
|
|
11
|
+
return "- `[from:instance-name]` → answer the sender with `send_to_instance`/`report_result`. Only when the request explicitly asks you to communicate with humans in your bound ClassicBot channel (ask, notify, follow up, or mention someone), use `reply` for that channel-facing action. With `requires_reply=true`, also report the outcome to the sender.";
|
|
12
|
+
}
|
|
13
|
+
function fullCrossInstanceMessageRule(classic) {
|
|
14
|
+
if (!classic) {
|
|
15
|
+
return "- `[from:instance-name]` — from another fleet instance → use `send_to_instance` or `report_result`, NOT the `reply` tool.";
|
|
16
|
+
}
|
|
17
|
+
return "- `[from:instance-name]` — from another fleet instance → answer the sender with `send_to_instance` or `report_result`. Only when the request explicitly asks you to communicate with humans in your bound ClassicBot channel (ask, notify, follow up, or mention someone), use `reply` for that channel-facing action. With `requires_reply=true`, also report the outcome to the sender.";
|
|
18
|
+
}
|
|
19
|
+
function fullCrossInstanceCollaborationRule(classic) {
|
|
20
|
+
if (!classic) {
|
|
21
|
+
return "2. Cross-instance messages appear as `[from:instance-name]`. Reply via send_to_instance or report_result, NOT reply.";
|
|
22
|
+
}
|
|
23
|
+
return "2. Cross-instance messages appear as `[from:instance-name]`. Answer the sender via send_to_instance or report_result. Use reply only to carry out an explicit request to communicate with humans in your bound ClassicBot channel; when `requires_reply=true`, separately report the outcome to the sender.";
|
|
24
|
+
}
|
|
25
|
+
function cliCrossInstanceRule(classic) {
|
|
26
|
+
if (!classic) {
|
|
27
|
+
return [
|
|
28
|
+
"## Runtime Cross-instance Rule",
|
|
29
|
+
"This is a fleet-topic instance. For `[from:INSTANCE]`, answer the sender with `agend-agent send` or `agend-agent report`; never use `agend-agent reply`.",
|
|
30
|
+
].join("\n");
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
"## Runtime Cross-instance Rule",
|
|
34
|
+
"This is a ClassicBot instance. For `[from:INSTANCE]`, answer the sender with `agend-agent send` or `agend-agent report`.",
|
|
35
|
+
"Only when the request explicitly asks you to communicate with humans in your bound ClassicBot channel (ask, notify, follow up, or mention someone), use `agend-agent reply` for that channel-facing action. With `requires_reply=true`, also report the outcome to the sender.",
|
|
36
|
+
].join("\n");
|
|
37
|
+
}
|
|
4
38
|
/**
|
|
5
39
|
* Compact contract for the MCP server's `instructions` field.
|
|
6
40
|
*
|
|
@@ -14,6 +48,7 @@ import { fileURLToPath } from "node:url";
|
|
|
14
48
|
*/
|
|
15
49
|
export function buildMcpCoreInstructions(params) {
|
|
16
50
|
const { instanceName, workingDirectory, runtimeIdentity } = params;
|
|
51
|
+
const classic = isClassicInstance(params);
|
|
17
52
|
const runtime = runtimeIdentity
|
|
18
53
|
? ` Runtime: kind=${runtimeIdentity.kind}, backend=${runtimeIdentity.backend}, model=${runtimeIdentity.model}.`
|
|
19
54
|
: "";
|
|
@@ -22,7 +57,7 @@ export function buildMcpCoreInstructions(params) {
|
|
|
22
57
|
"",
|
|
23
58
|
"## Reply contract",
|
|
24
59
|
"- `[user:name via platform, id:ID]` → answer with the `reply` tool. Never direct text.",
|
|
25
|
-
|
|
60
|
+
mcpCrossInstanceReplyRule(classic),
|
|
26
61
|
"- A turn ends only after that tool call — post your conclusion, then close with a short line like `.`.",
|
|
27
62
|
"- Nothing to add on a cross-instance message? Staying silent is valid.",
|
|
28
63
|
"",
|
|
@@ -37,6 +72,7 @@ export function buildMcpCoreInstructions(params) {
|
|
|
37
72
|
export function buildFleetInstructions(params) {
|
|
38
73
|
const { instanceName, workingDirectory, runtimeIdentity, displayName, description, customPrompt } = params;
|
|
39
74
|
const sections = [];
|
|
75
|
+
const classic = isClassicInstance(params);
|
|
40
76
|
// ── Identity ──
|
|
41
77
|
sections.push(`# AgEnD Fleet Context\nYou are **${instanceName}**, an instance in an AgEnD fleet.\nYour working directory is \`${workingDirectory}\`.`);
|
|
42
78
|
if (runtimeIdentity) {
|
|
@@ -55,13 +91,14 @@ export function buildFleetInstructions(params) {
|
|
|
55
91
|
if (params.cliInstructions) {
|
|
56
92
|
// CLI mode: inject CLI quick reference
|
|
57
93
|
sections.push(params.cliInstructions);
|
|
94
|
+
sections.push(cliCrossInstanceRule(classic));
|
|
58
95
|
}
|
|
59
96
|
else {
|
|
60
97
|
// MCP mode: inject MCP tool usage instructions
|
|
61
98
|
sections.push([
|
|
62
99
|
"## Message Format",
|
|
63
100
|
"- `[user:name via platform, id:USER_ID]` — from a Telegram/Discord user → reply with the `reply` tool.",
|
|
64
|
-
|
|
101
|
+
fullCrossInstanceMessageRule(classic),
|
|
65
102
|
"",
|
|
66
103
|
"A turn isn't finished until the channel has your conclusion — posted via `reply` (or",
|
|
67
104
|
"`send_to_instance` / `report_result` for another instance). That call is the last step of",
|
|
@@ -86,7 +123,7 @@ export function buildFleetInstructions(params) {
|
|
|
86
123
|
"",
|
|
87
124
|
"## Collaboration Rules",
|
|
88
125
|
"1. Use fleet tools for cross-instance communication. Never assume direct file access to another instance's repo.",
|
|
89
|
-
|
|
126
|
+
fullCrossInstanceCollaborationRule(classic),
|
|
90
127
|
"3. Use list_instances to discover available instances before sending messages.",
|
|
91
128
|
"4. You only have direct access to files under your own working directory.",
|
|
92
129
|
"5. Task flow: `delegate_task` → silent work → `report_result`. Zero messages in between. Never send ack/confirmation.",
|
package/dist/instructions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBzC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA+B;IACtE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACnE,MAAM,OAAO,GAAG,eAAe;QAC7B,CAAC,CAAC,kBAAkB,eAAe,CAAC,IAAI,aAAa,eAAe,CAAC,OAAO,WAAW,eAAe,CAAC,KAAK,GAAG;QAC/G,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;QACL,aAAa,YAAY,8CAA8C,gBAAgB,MAAM,OAAO,EAAE;QACtG,EAAE;QACF,mBAAmB;QACnB,wFAAwF;QACxF,
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBzC,SAAS,iBAAiB,CAAC,MAA+B;IACxD,OAAO,MAAM,CAAC,eAAe,EAAE,IAAI,KAAK,SAAS,CAAC;AACpD,CAAC;AAED,SAAS,yBAAyB,CAAC,OAAgB;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,6HAA6H,CAAC;IACvI,CAAC;IACD,OAAO,0VAA0V,CAAC;AACpW,CAAC;AAED,SAAS,4BAA4B,CAAC,OAAgB;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,2HAA2H,CAAC;IACrI,CAAC;IACD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