@desplega.ai/agent-swarm 1.100.2 → 1.100.4
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/openapi.json +1 -1
- package/package.json +1 -1
- package/src/be/db.ts +131 -4
- package/src/be/memory/raters/retrieval.ts +6 -3
- package/src/be/migrations/097_memory_retrieval_grouping.sql +10 -0
- package/src/github/handlers.ts +84 -7
- package/src/github/templates.ts +6 -2
- package/src/heartbeat/heartbeat.ts +191 -5
- package/src/providers/claude-adapter.ts +41 -4
- package/src/slack/assistant.ts +28 -0
- package/src/slack/channel-join.ts +38 -3
- package/src/slack/handlers.ts +4 -1
- package/src/tasks/worker-follow-up.ts +181 -20
- package/src/tests/claude-adapter-binary.test.ts +74 -0
- package/src/tests/github-handlers-inline-comments.test.ts +308 -0
- package/src/tests/heartbeat-reroute-decision.test.ts +570 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +137 -0
- package/src/tests/heartbeat.test.ts +4 -2
- package/src/tests/memory-rater-implicit-citation.test.ts +31 -0
- package/src/tests/prompt-template-remaining.test.ts +2 -1
- package/src/tests/slack-assistant-comention-production.test.ts +319 -0
- package/src/tests/slack-assistant-comention.test.ts +139 -0
- package/src/tests/slack-channel-join.test.ts +150 -16
- package/src/tests/workflow-swarm-script.test.ts +225 -0
- package/src/tests/workflow-template.test.ts +17 -0
- package/src/tools/send-task.ts +51 -1
- package/src/tools/templates.ts +61 -0
- package/src/workflows/engine.ts +22 -1
- package/src/workflows/retry-poller.ts +2 -3
- package/src/workflows/template.ts +48 -0
|
@@ -10,6 +10,10 @@ export interface InterpolateResult {
|
|
|
10
10
|
unresolved: string[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface DeepInterpolateOptions {
|
|
14
|
+
preserveRawTokens?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
export function interpolate(template: string, ctx: Record<string, unknown>): InterpolateResult {
|
|
14
18
|
const unresolved: string[] = [];
|
|
15
19
|
const result = template.replace(/\{\{([^}]+)\}\}/g, (_match, path: string) => {
|
|
@@ -43,18 +47,62 @@ function safeStringify(value: unknown): string {
|
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
/** Matches a string that is EXACTLY one {{path}} token with no surrounding text. */
|
|
51
|
+
const EXACT_TOKEN_RE = /^\{\{([^}]+)\}\}$/;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a dot-separated path against a context object.
|
|
55
|
+
* Returns `{ found: true, value }` on success, `{ found: false }` when any
|
|
56
|
+
* segment is missing or the traversal hits a non-object.
|
|
57
|
+
*/
|
|
58
|
+
function resolvePath(
|
|
59
|
+
path: string,
|
|
60
|
+
ctx: Record<string, unknown>,
|
|
61
|
+
): { found: true; value: unknown } | { found: false } {
|
|
62
|
+
const keys = path.trim().split(".");
|
|
63
|
+
let value: unknown = ctx;
|
|
64
|
+
for (const key of keys) {
|
|
65
|
+
if (value == null || typeof value !== "object") return { found: false };
|
|
66
|
+
value = (value as Record<string, unknown>)[key];
|
|
67
|
+
}
|
|
68
|
+
if (value === undefined) return { found: false };
|
|
69
|
+
return { found: true, value };
|
|
70
|
+
}
|
|
71
|
+
|
|
46
72
|
/**
|
|
47
73
|
* Deep-interpolate an arbitrary value tree (objects, arrays, strings).
|
|
74
|
+
*
|
|
75
|
+
* When `preserveRawTokens` is true and a string value is **exactly** one
|
|
76
|
+
* `{{path}}` token with no surrounding text, the resolved value is returned
|
|
77
|
+
* as-is (preserving object / array / number / boolean types). This is the
|
|
78
|
+
* "raw injection" path used by `swarm-script` node `config.args`.
|
|
79
|
+
*
|
|
80
|
+
* When a string contains multiple tokens or surrounding text (e.g.
|
|
81
|
+
* `"prefix-{{x}}"`) the existing string-interpolation path is used so the
|
|
82
|
+
* result remains a string.
|
|
83
|
+
*
|
|
48
84
|
* Non-string leaves are passed through unchanged.
|
|
49
85
|
*/
|
|
50
86
|
export function deepInterpolate(
|
|
51
87
|
value: unknown,
|
|
52
88
|
ctx: Record<string, unknown>,
|
|
89
|
+
options: DeepInterpolateOptions = {},
|
|
53
90
|
): { value: unknown; unresolved: string[] } {
|
|
54
91
|
const allUnresolved: string[] = [];
|
|
55
92
|
|
|
56
93
|
function walk(v: unknown): unknown {
|
|
57
94
|
if (typeof v === "string") {
|
|
95
|
+
const exactMatch = options.preserveRawTokens ? EXACT_TOKEN_RE.exec(v) : null;
|
|
96
|
+
if (exactMatch?.[1]) {
|
|
97
|
+
const path = exactMatch[1].trim();
|
|
98
|
+
const resolved = resolvePath(path, ctx);
|
|
99
|
+
if (!resolved.found) {
|
|
100
|
+
allUnresolved.push(path);
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
return resolved.value;
|
|
104
|
+
}
|
|
105
|
+
// Multi-token or mixed string - fall back to string interpolation.
|
|
58
106
|
const { result, unresolved } = interpolate(v, ctx);
|
|
59
107
|
allUnresolved.push(...unresolved);
|
|
60
108
|
return result;
|