@desplega.ai/agent-swarm 1.153.0 → 1.154.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/README.md +1 -1
- package/dist/{acp-adapter-ahmjxhek.js → acp-adapter-eb2aj8xy.js} +1 -1
- package/dist/{actions-jzrfpkmn.js → actions-kpnwp1kz.js} +18 -18
- package/dist/{app-03na2vwb.js → app-zk1apkf6.js} +6 -6
- package/dist/{assistant-hfkxvhgt.js → assistant-kwq4y50q.js} +19 -19
- package/dist/{boot-reembed-c98xrad3.js → boot-reembed-22hd3jjn.js} +7 -7
- package/dist/{boot-reembed-zt3qm9xn.js → boot-reembed-qe168424.js} +8 -8
- package/dist/{boot-scrub-logs-jcqd8ksj.js → boot-scrub-logs-pkdpsrjd.js} +5 -5
- package/dist/{claude-adapter-mgryg8g3.js → claude-adapter-3fx90nww.js} +10 -10
- package/dist/{claude-sdk-session-jjf4zss1.js → claude-sdk-session-z7fahf1k.js} +10 -10
- package/dist/{cli-1hwnb4hc.js → cli-09y3tjxz.js} +1 -1
- package/dist/{cli-b2g6mzjc.js → cli-0e31nm4n.js} +1 -1
- package/dist/{cli-5mbmvxnn.js → cli-1jpjafw4.js} +5 -5
- package/dist/{cli-bw0dfwkr.js → cli-243tzws8.js} +1 -1
- package/dist/{cli-rj7de4b2.js → cli-24k806sc.js} +1 -1
- package/dist/{cli-7g9s78jf.js → cli-3bkz2p7j.js} +7 -6
- package/dist/{cli-zcsyfw2z.js → cli-4k7jazkq.js} +4 -0
- package/dist/{cli-s5s1f2yn.js → cli-5vs0nh43.js} +25 -20
- package/dist/{cli-qrqhc31j.js → cli-6r3cgpk2.js} +94 -52
- package/dist/{cli-pgj4a5fb.js → cli-71cj99hx.js} +4 -3
- package/dist/{cli-d6hk10xx.js → cli-8sea27q4.js} +2 -2
- package/dist/{cli-a9scg8sv.js → cli-913yakhv.js} +22 -7
- package/dist/{cli-pf9q3696.js → cli-927erqqt.js} +5 -2
- package/dist/{cli-zy5w9gpt.js → cli-95jnpnqg.js} +1 -1
- package/dist/{cli-cdq08v3r.js → cli-abp3g4ax.js} +15 -2
- package/dist/{cli-nq0kgyxe.js → cli-acy6bfhr.js} +10 -7
- package/dist/{cli-n0q9b7j4.js → cli-c1v10xb2.js} +157 -52
- package/dist/{cli-tdh4hjr2.js → cli-e0pg4zeh.js} +1 -1
- package/dist/{cli-83wkg402.js → cli-e31ehqwy.js} +1 -1
- package/dist/{cli-m04pt18h.js → cli-e3229na9.js} +3 -3
- package/dist/{cli-ysc1kbet.js → cli-e3cyf59d.js} +2 -2
- package/dist/{cli-mzgyhxbe.js → cli-fdzg6jhf.js} +2 -2
- package/dist/{cli-0d9nbqxf.js → cli-g2h29qar.js} +2 -2
- package/dist/{cli-djvxhnc4.js → cli-ge67p080.js} +124 -26
- package/dist/{cli-7pnz2v6s.js → cli-hws0vn86.js} +2 -2
- package/dist/{cli-3bcmp015.js → cli-kp3qs53m.js} +2 -2
- package/dist/{cli-ybpp1srm.js → cli-myaxtgh8.js} +2 -1
- package/dist/{cli-r8tdds6s.js → cli-n62atwh9.js} +1 -1
- package/dist/{cli-6ks9xf1n.js → cli-pf1v8xhb.js} +4 -4
- package/dist/{cli-5taqtpze.js → cli-q85qhckh.js} +6 -6
- package/dist/{cli-eazstkad.js → cli-r1d3dzt6.js} +2 -2
- package/dist/{cli-ja7mrygn.js → cli-rxkqvngf.js} +2 -2
- package/dist/{cli-vw03hg5t.js → cli-stwsmd6k.js} +2 -2
- package/dist/{cli-z61ykvam.js → cli-wg04s9kr.js} +4 -3
- package/dist/cli.js +13 -12
- package/dist/{codex-adapter-8548daap.js → codex-adapter-ttdm995v.js} +5 -5
- package/dist/{codex-hook-8jexc34x.js → codex-hook-8gx7bcz0.js} +3 -3
- package/dist/{codex-session-runner-2dad8p4x.js → codex-session-runner-3v8nh4c8.js} +5 -5
- package/dist/{commands-355dbpa8.js → commands-1cxwbhhq.js} +5 -5
- package/dist/{db-4jjvwz1s.js → db-y9zwsr79.js} +23 -5
- package/dist/{dispatcher-ca590nkz.js → dispatcher-9m9zss36.js} +17 -17
- package/dist/{dsh-adapter-rgvj6ykp.js → dsh-adapter-gsb2qqf9.js} +2 -2
- package/dist/{google-generative-ai-xtw7tggr.js → google-generative-ai-gwwrnzqn.js} +1 -1
- package/dist/{google-vertex-zdqpms6n.js → google-vertex-5wfawpwz.js} +1 -1
- package/dist/{handlers-2y6dqpvf.js → handlers-36fm1bwn.js} +20 -20
- package/dist/{hook-0s8knepr.js → hook-pntw4r8h.js} +8 -8
- package/dist/{hook-k0gec254.js → hook-vwq8y26p.js} +9 -9
- package/dist/{http-jp2nb4zw.js → http-20jesakk.js} +89 -56
- package/dist/{index-42s7eezq.js → index-6artrehg.js} +17 -17
- package/dist/{index-3mq6ce93.js → index-9n5z2492.js} +17 -17
- package/dist/{index-0wzg3sp3.js → index-j5wrf1yw.js} +11 -11
- package/dist/{index-s37dbevy.js → index-m2xqpz5r.js} +18 -18
- package/dist/{index-b56xkbc7.js → index-m9ks8a7t.js} +7 -7
- package/dist/{keepalive-9pfw7t02.js → keepalive-pwxvxd2c.js} +7 -7
- package/dist/{lead-7vcmcdq4.js → lead-m789wqa3.js} +26 -26
- package/dist/{maintenance-x277jbpd.js → maintenance-bvg6w7e2.js} +8 -8
- package/dist/{oauth-refresh-sweep-5fwa7th2.js → oauth-refresh-sweep-6v4bd737.js} +6 -6
- package/dist/{onboard-17sv0f51.js → onboard-snckpcj1.js} +14 -2
- package/dist/{otel-impl-srjy4be4.js → otel-impl-e0ytens5.js} +1 -1
- package/dist/{pi-mono-adapter-946a0sdd.js → pi-mono-adapter-c4ggemhz.js} +6 -6
- package/dist/{pricing-refresh-vetcm563.js → pricing-refresh-52g2ywrw.js} +7 -7
- package/dist/{rbac-roles-cmxaddmy.js → rbac-roles-5455kfdn.js} +5 -5
- package/dist/{rbac-roles-cfzgr6r1.js → rbac-roles-hbf0xa52.js} +6 -6
- package/dist/{render-v2-f9hzff72.js → render-v2-npm8xdzh.js} +12 -8
- package/dist/{seed-pricing-jggk6rsy.js → seed-pricing-650wbr1n.js} +6 -6
- package/dist/{setup-8mfceb9t.js → setup-k1mew5rf.js} +2 -2
- package/dist/{virtual-modules-ax661xp0.js → virtual-modules-2q5b2pk4.js} +2 -2
- package/dist/{work-objects-vdsdcczj.js → work-objects-2ea3kvwg.js} +20 -20
- package/dist/{worker-cd0nhyv1.js → worker-ec6hvc4m.js} +26 -26
- package/openapi.json +74 -3
- package/package.json +2 -1
- package/plugin/opencode-plugins/lib/memory-raters.ts +7 -0
- package/src/be/db/agents.ts +75 -2
- package/src/be/db/tasks/read.ts +2 -0
- package/src/be/db/tasks/write.ts +7 -1
- package/src/be/db.ts +140 -18
- package/src/be/memory/raters/llm.ts +2 -6
- package/src/be/memory/raters/noop.ts +2 -3
- package/src/be/memory/raters/registry.ts +4 -10
- package/src/be/migrations/157_defer_provenance_and_marker.sql +27 -0
- package/src/be/seed/agent-fs-provision.ts +23 -0
- package/src/commands/onboard/compose-generator.ts +10 -0
- package/src/commands/onboard/env-generator.ts +8 -0
- package/src/commands/runner.ts +18 -2
- package/src/extensions/identity.ts +15 -7
- package/src/hooks/codex-hook.ts +7 -1
- package/src/http/agents.ts +10 -2
- package/src/http/poll.ts +7 -0
- package/src/http/schedules.ts +10 -0
- package/src/http/script-runs.ts +35 -26
- package/src/http/status.ts +2 -1
- package/src/http/tasks.ts +6 -1
- package/src/prompts/memories.ts +5 -7
- package/src/prompts/session-templates.ts +3 -2
- package/src/prompts/steering-delivery.ts +2 -0
- package/src/providers/codex-adapter.ts +3 -6
- package/src/providers/pi-mono-extension.ts +2 -5
- package/src/slack/ack.ts +43 -8
- package/src/slack/handlers.ts +7 -1
- package/src/slack/render-v2.ts +186 -17
- package/src/slack/responses.ts +1 -3
- package/src/slack/task-output.ts +66 -8
- package/src/slack/thread-buffer.ts +27 -3
- package/src/tests/agent-fs-provision-seeder.test.ts +56 -2
- package/src/tests/codex-steering-hook.test.ts +2 -2
- package/src/tests/db-task-read-contract.test.ts +9 -0
- package/src/tests/db-task-write-contract.test.ts +9 -0
- package/src/tests/defer-task.test.ts +115 -16
- package/src/tests/extension-agent-visibility.test.ts +474 -0
- package/src/tests/extensions-lifecycle.test.ts +3 -1
- package/src/tests/fetch-resolved-env.test.ts +43 -0
- package/src/tests/memory-rate-tool.test.ts +7 -10
- package/src/tests/memory-rater-defaults.test.ts +23 -0
- package/src/tests/memory-rater-e2e.test.ts +2 -3
- package/src/tests/script-connections.test.ts +3 -0
- package/src/tests/slack-render-v2.test.ts +446 -16
- package/src/tests/slack-steering.test.ts +69 -1
- package/src/tests/slack-task-output.test.ts +33 -12
- package/src/tests/steering-core.test.ts +35 -0
- package/src/tests/steering-delivery.test.ts +39 -0
- package/src/tests/steering-transport.test.ts +2 -2
- package/src/tests/workflow-live-recovery.test.ts +126 -0
- package/src/tools/defer-task.ts +64 -26
- package/src/tools/join-swarm.ts +1 -1
- package/src/tools/schedules/create-schedule.ts +11 -1
- package/src/tools/schedules/patch-schedule.ts +5 -0
- package/src/tools/schedules/update-schedule.ts +5 -0
- package/src/tools/send-task.ts +6 -0
- package/src/tools/utils.ts +1 -1
- package/src/types.ts +13 -0
- package/src/utils/memory-raters.ts +3 -0
- package/src/workflows/engine.ts +28 -0
- package/src/workflows/recovery.ts +7 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
resolveSlackUserId,
|
|
2
3
|
rewriteSlackMentions
|
|
3
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-r1d3dzt6.js";
|
|
4
5
|
import {
|
|
5
6
|
bufferedFileFailures,
|
|
6
7
|
buildEffectiveText,
|
|
@@ -8,8 +9,9 @@ import {
|
|
|
8
9
|
createSlackTaskWithFiles,
|
|
9
10
|
extractSlackMessageText,
|
|
10
11
|
fetchSlackFiles,
|
|
12
|
+
findUserByExternalId,
|
|
11
13
|
notifySlackFileFailures
|
|
12
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-6r3cgpk2.js";
|
|
13
15
|
import {
|
|
14
16
|
buildBufferFlushBlocks,
|
|
15
17
|
ensureSlackThreadTree,
|
|
@@ -18,7 +20,7 @@ import {
|
|
|
18
20
|
getSlackApp,
|
|
19
21
|
isSlackRenderV2Enabled,
|
|
20
22
|
registerTreeMessage
|
|
21
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-c1v10xb2.js";
|
|
22
24
|
import {
|
|
23
25
|
createLogEntry,
|
|
24
26
|
getAgentById,
|
|
@@ -31,11 +33,11 @@ import {
|
|
|
31
33
|
init_steering,
|
|
32
34
|
requestSteering,
|
|
33
35
|
slackContextKey
|
|
34
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-ge67p080.js";
|
|
35
37
|
import {
|
|
36
38
|
init_steering_enabled,
|
|
37
39
|
isSteeringEnabled
|
|
38
|
-
} from "./cli-
|
|
40
|
+
} from "./cli-wg04s9kr.js";
|
|
39
41
|
import {
|
|
40
42
|
__callDispose,
|
|
41
43
|
__using
|
|
@@ -234,11 +236,20 @@ ${combinedText}`;
|
|
|
234
236
|
if (latestActiveTask) {
|
|
235
237
|
console.log(`[Slack] Dependency chaining: latest active task ${latestActiveTask.id} (status: ${latestActiveTask.status})`);
|
|
236
238
|
}
|
|
239
|
+
const requestedByUserId = app ? await resolveSlackUserId(app.client, originalRequesterId, {
|
|
240
|
+
sampleEventType: "buffered_thread_reply",
|
|
241
|
+
sampleContext: items[0].text
|
|
242
|
+
}) : (await findUserByExternalId("slack", originalRequesterId))?.id;
|
|
243
|
+
const nextSenderIndex = items.findIndex((item) => item.userId !== originalRequesterId);
|
|
244
|
+
const steeringItems = nextSenderIndex === -1 ? items : items.slice(0, nextSenderIndex);
|
|
237
245
|
const steering = files.length === 0 ? await requestSlackThreadSteering({
|
|
238
246
|
channelId,
|
|
239
247
|
threadTs,
|
|
240
|
-
message: combinedText
|
|
241
|
-
|
|
248
|
+
message: nextSenderIndex === -1 ? combinedText : await rewriteSlackMentions(steeringItems.map((item) => item.text).join(`
|
|
249
|
+
---
|
|
250
|
+
`), botUserId),
|
|
251
|
+
messageTimestamps: steeringItems.map((item) => item.ts),
|
|
252
|
+
requestedByUserId
|
|
242
253
|
}) : null;
|
|
243
254
|
if (steering) {
|
|
244
255
|
console.log(`[Slack] Buffer flushed → steering ${steering.result.outcome} for task ${steering.task.id}`);
|
|
@@ -259,6 +270,9 @@ ${combinedText}`;
|
|
|
259
270
|
}
|
|
260
271
|
}
|
|
261
272
|
}
|
|
273
|
+
if (nextSenderIndex !== -1) {
|
|
274
|
+
await slackFlush(items.slice(nextSenderIndex), key, immediate);
|
|
275
|
+
}
|
|
262
276
|
return;
|
|
263
277
|
}
|
|
264
278
|
const lead = await getLeadAgent();
|
|
@@ -279,6 +293,7 @@ ${description}` : description;
|
|
|
279
293
|
slackThreadTs: threadTs,
|
|
280
294
|
slackTriggerMessageTs: items.at(-1).ts,
|
|
281
295
|
slackUserId: originalRequesterId,
|
|
296
|
+
requestedByUserId,
|
|
282
297
|
dependsOn,
|
|
283
298
|
parentTaskId: mostRecentTask?.id,
|
|
284
299
|
contextKey: slackContextKey({ channelId, threadTs })
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getMemoryRaterNames
|
|
3
|
+
} from "./cli-3bkz2p7j.js";
|
|
4
|
+
|
|
1
5
|
// src/prompts/memories.ts
|
|
2
6
|
var SIMILARITY_THRESHOLD = 0.4;
|
|
3
7
|
var RATE_TOOL_HINT = `
|
|
@@ -26,8 +30,7 @@ ${memoryContext}
|
|
|
26
30
|
return prompt;
|
|
27
31
|
}
|
|
28
32
|
function isExplicitSelfRaterEnabled() {
|
|
29
|
-
|
|
30
|
-
return ratersEnabled.includes("explicit-self");
|
|
33
|
+
return getMemoryRaterNames().includes("explicit-self");
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
// src/utils/skill-fs-writer.ts
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getScriptMcpTypes,
|
|
5
5
|
listAppRecords,
|
|
6
6
|
require_typescript
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-pf1v8xhb.js";
|
|
8
8
|
import {
|
|
9
9
|
deleteSwarmConfigByKey,
|
|
10
10
|
getAgentById,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
getSwarmConfigs,
|
|
14
14
|
init_db,
|
|
15
15
|
upsertSwarmConfig
|
|
16
|
-
} from "./cli-
|
|
16
|
+
} from "./cli-ge67p080.js";
|
|
17
17
|
import {
|
|
18
18
|
init_secret_scrubber,
|
|
19
19
|
scrubSecrets
|
|
@@ -165,6 +165,7 @@ async function ensureAgentFsCredentialsForAgent(agentId) {
|
|
|
165
165
|
key: "AGENT_FS_API_KEY"
|
|
166
166
|
}))[0];
|
|
167
167
|
if (existing?.value) {
|
|
168
|
+
await syncAgentFsDisplayName(apiUrl, existing.value, agent.name);
|
|
168
169
|
return {
|
|
169
170
|
enabled: true,
|
|
170
171
|
created: false,
|
|
@@ -209,6 +210,7 @@ async function ensureAgentFsCredentialsForAgent(agentId) {
|
|
|
209
210
|
isSecret: true,
|
|
210
211
|
description: `agent-fs API key for ${email}`
|
|
211
212
|
});
|
|
213
|
+
await syncAgentFsDisplayName(apiUrl, apiKey, agent.name);
|
|
212
214
|
return {
|
|
213
215
|
enabled: true,
|
|
214
216
|
created: true,
|
|
@@ -218,6 +220,17 @@ async function ensureAgentFsCredentialsForAgent(agentId) {
|
|
|
218
220
|
driveId: shared.driveId
|
|
219
221
|
};
|
|
220
222
|
}
|
|
223
|
+
async function syncAgentFsDisplayName(apiUrl, apiKey, name) {
|
|
224
|
+
try {
|
|
225
|
+
await agentFsRequest(apiUrl, "/auth/profile", {
|
|
226
|
+
method: "PATCH",
|
|
227
|
+
headers: { authorization: `Bearer ${apiKey}` },
|
|
228
|
+
body: { displayName: name }
|
|
229
|
+
});
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.warn(scrubSecrets(`[agent-fs] display name sync skipped: ${error instanceof AgentFsRequestError ? `HTTP ${error.status}` : "request failed"}`));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
221
234
|
async function ensureSharedOrg(apiUrl, headers) {
|
|
222
235
|
const configured = await getConfigValue("AGENT_FS_DEFAULT_ORG_ID") || await getConfigValue("AGENT_FS_SHARED_ORG_ID");
|
|
223
236
|
if (configured)
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
instantFlush,
|
|
6
6
|
requestSlackThreadSteering,
|
|
7
7
|
wasEventSeen
|
|
8
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-913yakhv.js";
|
|
9
9
|
import {
|
|
10
10
|
enrichSlackUserEmail,
|
|
11
11
|
resolveSlackUserId,
|
|
12
12
|
rewriteSlackMentions
|
|
13
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-r1d3dzt6.js";
|
|
14
14
|
import {
|
|
15
15
|
TaskCreationBlockedError,
|
|
16
16
|
broadcastMatches,
|
|
@@ -23,14 +23,14 @@ import {
|
|
|
23
23
|
hasOtherUserMention,
|
|
24
24
|
notifySlackFileFailures,
|
|
25
25
|
routeMessage
|
|
26
|
-
} from "./cli-
|
|
26
|
+
} from "./cli-6r3cgpk2.js";
|
|
27
27
|
import {
|
|
28
28
|
ackSlackMessage,
|
|
29
29
|
buildTreeBlocks,
|
|
30
30
|
ensureSlackThreadTree,
|
|
31
31
|
isSlackRenderV2Enabled,
|
|
32
32
|
registerTreeMessage
|
|
33
|
-
} from "./cli-
|
|
33
|
+
} from "./cli-c1v10xb2.js";
|
|
34
34
|
import {
|
|
35
35
|
getAgentById,
|
|
36
36
|
getAgentWorkingOnThread,
|
|
@@ -40,13 +40,14 @@ import {
|
|
|
40
40
|
getTasksByAgentId,
|
|
41
41
|
init_context_key,
|
|
42
42
|
init_db,
|
|
43
|
+
isExtensionAgent,
|
|
43
44
|
reactionName,
|
|
44
45
|
slackContextKey
|
|
45
|
-
} from "./cli-
|
|
46
|
+
} from "./cli-ge67p080.js";
|
|
46
47
|
import {
|
|
47
48
|
init_resolver,
|
|
48
49
|
resolveTemplate
|
|
49
|
-
} from "./cli-
|
|
50
|
+
} from "./cli-wg04s9kr.js";
|
|
50
51
|
import {
|
|
51
52
|
init_env_flag,
|
|
52
53
|
isEnvFlagEnabled
|
|
@@ -370,7 +371,9 @@ function registerMessageHandler(app) {
|
|
|
370
371
|
const { target } = routeResult.data;
|
|
371
372
|
if (target.kind === "agent") {
|
|
372
373
|
const agent = await getAgentById(target.agentId);
|
|
373
|
-
if (agent) {
|
|
374
|
+
if (agent && isExtensionAgent(agent)) {
|
|
375
|
+
console.warn("[Slack] Extension selected an extension-identity agent. Using the built-in router:", scrubSecrets(target.agentId));
|
|
376
|
+
} else if (agent) {
|
|
374
377
|
matches = [{ agent, matchedText: "extension" }];
|
|
375
378
|
} else {
|
|
376
379
|
console.warn("[Slack] Extension selected an unknown agent. Using the built-in router:", scrubSecrets(target.agentId));
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
getInProgressSlackTasks,
|
|
28
28
|
getLogsByTaskIdChronological,
|
|
29
29
|
getPendingSlackRelayTasks,
|
|
30
|
+
getResolvableDeferralOutcomes,
|
|
30
31
|
getSlackOutcomeMessage,
|
|
31
32
|
getSlackTasksInThread,
|
|
32
33
|
getSlackTasksMissingTree,
|
|
@@ -41,6 +42,7 @@ import {
|
|
|
41
42
|
init_reaction_shortcode,
|
|
42
43
|
isPendingSlackMessage,
|
|
43
44
|
markFinalizedSlackRelaysDelivered,
|
|
45
|
+
markSlackDeferralResolved,
|
|
44
46
|
markSlackRelayAttempted,
|
|
45
47
|
markSlackRelayDelivered,
|
|
46
48
|
markSlackTreeRendered,
|
|
@@ -50,11 +52,11 @@ import {
|
|
|
50
52
|
setSlackMessageTracking,
|
|
51
53
|
slackContextKey,
|
|
52
54
|
updateSlackMessageRecord
|
|
53
|
-
} from "./cli-
|
|
55
|
+
} from "./cli-ge67p080.js";
|
|
54
56
|
import {
|
|
55
57
|
init_types,
|
|
56
58
|
isTerminalTaskStatus
|
|
57
|
-
} from "./cli-
|
|
59
|
+
} from "./cli-4k7jazkq.js";
|
|
58
60
|
import {
|
|
59
61
|
getAppUrl,
|
|
60
62
|
init_constants
|
|
@@ -52640,7 +52642,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
|
|
|
52640
52642
|
return;
|
|
52641
52643
|
initialized = true;
|
|
52642
52644
|
try {
|
|
52643
|
-
const impl = await import("./otel-impl-
|
|
52645
|
+
const impl = await import("./otel-impl-e0ytens5.js");
|
|
52644
52646
|
await impl.boot(serviceRole);
|
|
52645
52647
|
realWithSpan = impl.withSpan;
|
|
52646
52648
|
realStartSpan = impl.startSpan;
|
|
@@ -53039,19 +53041,32 @@ function buildTreeBlocks(roots) {
|
|
|
53039
53041
|
init_db();
|
|
53040
53042
|
|
|
53041
53043
|
// src/slack/task-output.ts
|
|
53044
|
+
var LEGACY_DEFERRAL_NOTICE = /^Deferred until ([^\n(]+?) \([^\n]*?\) -> .*$/;
|
|
53042
53045
|
function slackTaskOutput(task) {
|
|
53043
53046
|
const output = task.output ?? undefined;
|
|
53044
53047
|
if (task.status !== "completed" || task.outputSchema || !task.tags?.includes("deferred")) {
|
|
53045
53048
|
return output;
|
|
53046
53049
|
}
|
|
53047
|
-
const
|
|
53048
|
-
if (!
|
|
53050
|
+
const legacy = output?.match(LEGACY_DEFERRAL_NOTICE);
|
|
53051
|
+
if (!legacy)
|
|
53049
53052
|
return output;
|
|
53050
|
-
const
|
|
53051
|
-
return
|
|
53053
|
+
const eta = legacy[1]?.trim();
|
|
53054
|
+
return eta ? `Checking back ${eta}` : output;
|
|
53052
53055
|
}
|
|
53053
|
-
function
|
|
53054
|
-
|
|
53056
|
+
function isDeferredTask(task) {
|
|
53057
|
+
if (task.status !== "completed")
|
|
53058
|
+
return false;
|
|
53059
|
+
if (task.deferredAt)
|
|
53060
|
+
return true;
|
|
53061
|
+
return !!task.tags?.includes("deferred") && task.taskType !== "deferred";
|
|
53062
|
+
}
|
|
53063
|
+
function deferralWakes(task, threadTasks) {
|
|
53064
|
+
return threadTasks.filter((candidate) => candidate.parentTaskId === task.id && candidate.taskType === "deferred");
|
|
53065
|
+
}
|
|
53066
|
+
function isAwaitingWake(task, threadTasks) {
|
|
53067
|
+
if (!isDeferredTask(task))
|
|
53068
|
+
return false;
|
|
53069
|
+
return !deferralWakes(task, threadTasks).some((wake) => wake.status === "completed" || wake.status === "failed" || wake.status === "cancelled");
|
|
53055
53070
|
}
|
|
53056
53071
|
|
|
53057
53072
|
// src/slack/responses.ts
|
|
@@ -53124,8 +53139,6 @@ async function sendInlineTaskOutput(task) {
|
|
|
53124
53139
|
}
|
|
53125
53140
|
}
|
|
53126
53141
|
async function sendTaskResponse(task) {
|
|
53127
|
-
if (isSlackEtaOnlyNotice(task))
|
|
53128
|
-
return true;
|
|
53129
53142
|
const app = getSlackApp();
|
|
53130
53143
|
if (!app || !task.slackChannelId || !task.slackThreadTs) {
|
|
53131
53144
|
return false;
|
|
@@ -53251,8 +53264,6 @@ async function updateProgressInPlace(task, progress, messageTs) {
|
|
|
53251
53264
|
}
|
|
53252
53265
|
}
|
|
53253
53266
|
async function updateToFinal(task, messageTs) {
|
|
53254
|
-
if (isSlackEtaOnlyNotice(task))
|
|
53255
|
-
return "ok";
|
|
53256
53267
|
const app = getSlackApp();
|
|
53257
53268
|
if (!app || !task.slackChannelId || !task.agentId)
|
|
53258
53269
|
return "failed";
|
|
@@ -53989,15 +54000,15 @@ async function initSlackApp() {
|
|
|
53989
54000
|
...slackApiUrl ? { clientOptions: { slackApiUrl } } : {}
|
|
53990
54001
|
});
|
|
53991
54002
|
initialized2 = true;
|
|
53992
|
-
const { registerMessageHandler } = await import("./handlers-
|
|
53993
|
-
const { registerCommandHandler } = await import("./commands-
|
|
53994
|
-
const { registerActionHandlers } = await import("./actions-
|
|
53995
|
-
const { registerWorkObjectHandlers } = await import("./work-objects-
|
|
54003
|
+
const { registerMessageHandler } = await import("./handlers-36fm1bwn.js");
|
|
54004
|
+
const { registerCommandHandler } = await import("./commands-1cxwbhhq.js");
|
|
54005
|
+
const { registerActionHandlers } = await import("./actions-kpnwp1kz.js");
|
|
54006
|
+
const { registerWorkObjectHandlers } = await import("./work-objects-2ea3kvwg.js");
|
|
53996
54007
|
registerMessageHandler(app);
|
|
53997
54008
|
registerCommandHandler(app);
|
|
53998
54009
|
registerActionHandlers(app);
|
|
53999
54010
|
registerWorkObjectHandlers(app);
|
|
54000
|
-
const { createAssistant } = await import("./assistant-
|
|
54011
|
+
const { createAssistant } = await import("./assistant-kwq4y50q.js");
|
|
54001
54012
|
app.assistant(createAssistant());
|
|
54002
54013
|
return app;
|
|
54003
54014
|
}
|
|
@@ -54006,7 +54017,7 @@ async function startSlackApp() {
|
|
|
54006
54017
|
await initSlackApp();
|
|
54007
54018
|
}
|
|
54008
54019
|
if (app) {
|
|
54009
|
-
const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-
|
|
54020
|
+
const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-npm8xdzh.js");
|
|
54010
54021
|
if (isSlackRenderV2Enabled2())
|
|
54011
54022
|
await ensureSlackRenderV2Activation();
|
|
54012
54023
|
await app.start();
|
|
@@ -54095,24 +54106,50 @@ async function finalizeSlackSteerReactions(tasks, reactionFor) {
|
|
|
54095
54106
|
}
|
|
54096
54107
|
}
|
|
54097
54108
|
}
|
|
54109
|
+
var MAX_DEFERRAL_CHAIN_HOPS = 10;
|
|
54110
|
+
async function triggerMessageTs(task) {
|
|
54111
|
+
let current = task;
|
|
54112
|
+
for (let hop = 0;current && hop <= MAX_DEFERRAL_CHAIN_HOPS; hop++) {
|
|
54113
|
+
if (current.slackTriggerMessageTs)
|
|
54114
|
+
return current.slackTriggerMessageTs;
|
|
54115
|
+
if (current.taskType !== "deferred" || !current.parentTaskId)
|
|
54116
|
+
return;
|
|
54117
|
+
current = await getTaskById(current.parentTaskId);
|
|
54118
|
+
}
|
|
54119
|
+
return;
|
|
54120
|
+
}
|
|
54121
|
+
function tasksAnsweringTrigger(threadTasks, timestamp) {
|
|
54122
|
+
const linked = threadTasks.filter((task) => task.slackTriggerMessageTs === timestamp);
|
|
54123
|
+
for (let index = 0;index < linked.length; index++) {
|
|
54124
|
+
for (const wake of deferralWakes(linked[index], threadTasks)) {
|
|
54125
|
+
if (!linked.includes(wake))
|
|
54126
|
+
linked.push(wake);
|
|
54127
|
+
}
|
|
54128
|
+
}
|
|
54129
|
+
return linked;
|
|
54130
|
+
}
|
|
54098
54131
|
async function finalizeTerminalSlackReactions(tasks) {
|
|
54099
54132
|
const app2 = getSlackApp();
|
|
54100
54133
|
if (!app2)
|
|
54101
54134
|
return;
|
|
54102
54135
|
const triggers = new Map;
|
|
54103
54136
|
for (const task of tasks) {
|
|
54104
|
-
if (!task.slackChannelId || !task.slackThreadTs
|
|
54137
|
+
if (!task.slackChannelId || !task.slackThreadTs)
|
|
54138
|
+
continue;
|
|
54139
|
+
const timestamp = await triggerMessageTs(task);
|
|
54140
|
+
if (!timestamp)
|
|
54105
54141
|
continue;
|
|
54106
|
-
const key = `${task.slackChannelId}\x00${
|
|
54142
|
+
const key = `${task.slackChannelId}\x00${timestamp}`;
|
|
54107
54143
|
triggers.set(key, {
|
|
54108
54144
|
channelId: task.slackChannelId,
|
|
54109
54145
|
threadTs: task.slackThreadTs,
|
|
54110
|
-
timestamp
|
|
54146
|
+
timestamp
|
|
54111
54147
|
});
|
|
54112
54148
|
}
|
|
54113
54149
|
for (const { channelId, threadTs, timestamp } of triggers.values()) {
|
|
54114
|
-
const
|
|
54115
|
-
|
|
54150
|
+
const threadTasks = await getSlackTasksInThread(channelId, threadTs);
|
|
54151
|
+
const linkedTasks = tasksAnsweringTrigger(threadTasks, timestamp);
|
|
54152
|
+
if (linkedTasks.length === 0 || linkedTasks.some((task) => !isTerminalTaskStatus(task.status) || isAwaitingWake(task, threadTasks))) {
|
|
54116
54153
|
continue;
|
|
54117
54154
|
}
|
|
54118
54155
|
const event = linkedTasks.every((task) => task.status === "completed") ? "completed" : "failed";
|
|
@@ -54275,7 +54312,9 @@ function isStalledMember(task, now) {
|
|
|
54275
54312
|
const idleMin = (now.getTime() - new Date(task.lastUpdatedAt).getTime()) / 60000;
|
|
54276
54313
|
return idleMin >= slackTreeStallMinutes();
|
|
54277
54314
|
}
|
|
54278
|
-
async function taskStateGlyph(task, now) {
|
|
54315
|
+
async function taskStateGlyph(task, now, threadTasks = []) {
|
|
54316
|
+
if (isAwaitingWake(task, threadTasks))
|
|
54317
|
+
return "⏳";
|
|
54279
54318
|
switch (task.status) {
|
|
54280
54319
|
case "backlog":
|
|
54281
54320
|
case "unassigned":
|
|
@@ -54362,11 +54401,11 @@ function renderProgress(progress) {
|
|
|
54362
54401
|
const cut = boundary >= MAX_TREE_PROGRESS_LENGTH / 2 ? boundary : MAX_TREE_PROGRESS_LENGTH;
|
|
54363
54402
|
return `${normalized.slice(0, cut).trimEnd()}…`;
|
|
54364
54403
|
}
|
|
54365
|
-
async function renderNodeLines(node, depth, now, isAsk) {
|
|
54404
|
+
async function renderNodeLines(node, depth, now, isAsk, threadTasks) {
|
|
54366
54405
|
const duration = formatV2Duration(new Date(node.task.createdAt), terminalEnd(node.task, now));
|
|
54367
54406
|
const indent = FIGURE_SPACE.repeat(TREE_INDENT.topLevel + Math.max(0, depth - 1) * TREE_INDENT.levelStep);
|
|
54368
54407
|
const boundedPrefix = indent.length > MAX_TREE_PREFIX_LENGTH ? `${indent.slice(0, MAX_TREE_PREFIX_LENGTH - 1)}…` : indent;
|
|
54369
|
-
let line = `${boundedPrefix}↳ ${await taskStateGlyph(node.task, now)} ${await renderNodeLabel(node, isAsk)} · ${duration} · ${getTaskLink(node.task.id)}`;
|
|
54408
|
+
let line = `${boundedPrefix}↳ ${await taskStateGlyph(node.task, now, threadTasks)} ${await renderNodeLabel(node, isAsk)} · ${duration} · ${getTaskLink(node.task.id)}`;
|
|
54370
54409
|
const progress = renderProgress(node.task.progress);
|
|
54371
54410
|
const suffix = isTerminalTreeStatus(node.task.status) ? "" : progress ? ` · ${progress}` : "";
|
|
54372
54411
|
if (suffix && line.length + suffix.length <= MAX_TREE_NODE_LINE_LENGTH) {
|
|
@@ -54377,7 +54416,7 @@ async function renderNodeLines(node, depth, now, isAsk) {
|
|
|
54377
54416
|
}
|
|
54378
54417
|
const lines = [line];
|
|
54379
54418
|
for (const child of node.children) {
|
|
54380
|
-
lines.push(...await renderNodeLines(child, depth + 1, now, false));
|
|
54419
|
+
lines.push(...await renderNodeLines(child, depth + 1, now, false, threadTasks));
|
|
54381
54420
|
}
|
|
54382
54421
|
return lines;
|
|
54383
54422
|
}
|
|
@@ -54397,6 +54436,8 @@ function threadHeaderText(tasks, now, duration) {
|
|
|
54397
54436
|
return `\uD83E\uDDF5 ⚠️ stalled — ${duration}`;
|
|
54398
54437
|
if (tasks.some((task) => !isTerminalTreeStatus(task.status)))
|
|
54399
54438
|
return `\uD83E\uDDF5 \uD83D\uDD04 working — ${duration}`;
|
|
54439
|
+
if (tasks.some((task) => isAwaitingWake(task, tasks)))
|
|
54440
|
+
return `\uD83E\uDDF5 ⏳ waiting — ${duration}`;
|
|
54400
54441
|
const hasFailure = tasks.some((task) => task.status === "failed");
|
|
54401
54442
|
return hasFailure ? `\uD83E\uDDF5 ❌ done with failures — ${duration}` : `\uD83E\uDDF5 ✅ done — ${duration}`;
|
|
54402
54443
|
}
|
|
@@ -54414,7 +54455,7 @@ async function renderThreadTree(tasks, _outcomeLinks = new Map, now = new Date,
|
|
|
54414
54455
|
const lines = [threadHeaderText(tasks, now, threadDuration)];
|
|
54415
54456
|
const roots = buildRenderForest(tasks);
|
|
54416
54457
|
for (const root of roots) {
|
|
54417
|
-
lines.push(...await renderNodeLines(root, 1, now, root.task.source === "slack"));
|
|
54458
|
+
lines.push(...await renderNodeLines(root, 1, now, root.task.source === "slack", tasks));
|
|
54418
54459
|
}
|
|
54419
54460
|
const text = normalizeV2Text(lines.join(`
|
|
54420
54461
|
`));
|
|
@@ -54424,7 +54465,7 @@ async function renderThreadTree(tasks, _outcomeLinks = new Map, now = new Date,
|
|
|
54424
54465
|
const recentLines = [];
|
|
54425
54466
|
for (let index = tasks.length - 1;index >= 0; index--) {
|
|
54426
54467
|
const task = tasks[index];
|
|
54427
|
-
const recentLine = (await renderNodeLines({ task, children: [] }, 1, now, task.source === "slack"))[0];
|
|
54468
|
+
const recentLine = (await renderNodeLines({ task, children: [] }, 1, now, task.source === "slack", tasks))[0];
|
|
54428
54469
|
const candidateLines = [recentLine, ...recentLines];
|
|
54429
54470
|
const omitted2 = index;
|
|
54430
54471
|
const marker2 = `… _${omitted2} older task${omitted2 === 1 ? "" : "s"} collapsed_`;
|
|
@@ -54693,25 +54734,31 @@ function isAskOutcomeStatus(status) {
|
|
|
54693
54734
|
function outcomeText(value, fallback) {
|
|
54694
54735
|
return value?.trim() ? value : fallback;
|
|
54695
54736
|
}
|
|
54737
|
+
var LINE_START_BLOCK = /^(?:`{3}|~{3}|[-*+]\s|\d+[.)]\s|>|#{1,6}\s|\||(?:-{3,}|\*{3,}|_{3,})[ \t]*(?:\r?\n|$)|(?: {4}|\t))/;
|
|
54738
|
+
function withStatusLead(lead, body) {
|
|
54739
|
+
const text = body.replace(/^(?:[ \t]*\r?\n)+/, "");
|
|
54740
|
+
if (LINE_START_BLOCK.test(text))
|
|
54741
|
+
return `${lead}
|
|
54742
|
+
|
|
54743
|
+
${body}`;
|
|
54744
|
+
return `${lead} ${text.trimStart()}`;
|
|
54745
|
+
}
|
|
54696
54746
|
async function outcomeContent(task, slackReplySent) {
|
|
54697
54747
|
if (task.status === "failed") {
|
|
54698
|
-
return
|
|
54699
|
-
|
|
54700
|
-
${outcomeText(task.failureReason, "Task failed.")}`;
|
|
54748
|
+
return withStatusLead("❌ **Failed:**", outcomeText(task.failureReason, "Task failed."));
|
|
54701
54749
|
}
|
|
54702
54750
|
if (task.status === "cancelled") {
|
|
54703
|
-
return
|
|
54704
|
-
|
|
54705
|
-
${outcomeText(task.failureReason, "Task was cancelled.")}`;
|
|
54751
|
+
return withStatusLead("\uD83D\uDEAB **Cancelled:**", outcomeText(task.failureReason, "Task was cancelled."));
|
|
54706
54752
|
}
|
|
54707
|
-
const isDeferred = task
|
|
54753
|
+
const isDeferred = isDeferredTask(task);
|
|
54708
54754
|
if (slackReplySent && task.status === "completed" && !isDeferred) {
|
|
54709
54755
|
const agentName = task.agentId ? (await getAgentById(task.agentId))?.name ?? "Agent" : "Agent";
|
|
54710
54756
|
return `✅ ${agentName} completed`;
|
|
54711
54757
|
}
|
|
54712
|
-
|
|
54713
|
-
|
|
54714
|
-
|
|
54758
|
+
if (isDeferred) {
|
|
54759
|
+
return withStatusLead("⏳", outcomeText(slackTaskOutput(task), "Deferred."));
|
|
54760
|
+
}
|
|
54761
|
+
return withStatusLead("✅", outcomeText(slackTaskOutput(task), "Task completed."));
|
|
54715
54762
|
}
|
|
54716
54763
|
async function agentDisplayNameFor(task) {
|
|
54717
54764
|
return task.agentId ? (await getAgentById(task.agentId))?.name ?? "Agent" : "Agent";
|
|
@@ -54719,32 +54766,31 @@ async function agentDisplayNameFor(task) {
|
|
|
54719
54766
|
async function childOutcomeContent(task, slackReplySent) {
|
|
54720
54767
|
const agentName = await agentDisplayNameFor(task);
|
|
54721
54768
|
if (task.status === "failed") {
|
|
54722
|
-
return `↳ ❌ ${agentName} — failed
|
|
54723
|
-
|
|
54724
|
-
${outcomeText(task.failureReason, "Task failed.")}`;
|
|
54769
|
+
return withStatusLead(`↳ ❌ ${agentName} — failed:`, outcomeText(task.failureReason, "Task failed."));
|
|
54725
54770
|
}
|
|
54726
|
-
if (slackReplySent && !task
|
|
54771
|
+
if (slackReplySent && !isDeferredTask(task)) {
|
|
54727
54772
|
return `↳ ✅ ${agentName} completed`;
|
|
54728
54773
|
}
|
|
54729
|
-
|
|
54730
|
-
|
|
54731
|
-
|
|
54774
|
+
if (isDeferredTask(task)) {
|
|
54775
|
+
return withStatusLead(`↳ ⏳ ${agentName} — deferred:`, outcomeText(slackTaskOutput(task), "Deferred."));
|
|
54776
|
+
}
|
|
54777
|
+
return withStatusLead(`↳ ✅ ${agentName} — result:`, outcomeText(slackTaskOutput(task), "Task completed."));
|
|
54732
54778
|
}
|
|
54733
54779
|
function isSlackContinuation(task) {
|
|
54734
54780
|
return task.source === "schedule" && task.taskType === "deferred" && !!task.slackChannelId && !!task.slackThreadTs;
|
|
54735
54781
|
}
|
|
54736
54782
|
function isChildCardCandidate(task, delegationActivatedAt) {
|
|
54737
|
-
return
|
|
54783
|
+
return task.source !== "slack" && !isSlackContinuation(task) && !!task.slackChannelId && !!task.slackThreadTs && (task.status === "completed" || task.status === "failed") && task.taskType !== "follow-up" && task.taskType !== "reroute-decision" && task.createdAt >= delegationActivatedAt;
|
|
54738
54784
|
}
|
|
54739
54785
|
function taskNeedsDirectOutcome(task, activatedAt) {
|
|
54740
|
-
return
|
|
54786
|
+
return (task.source === "slack" && isAskOutcomeStatus(task.status) || isSlackContinuation(task) && isOutcomeStatus(task.status)) && task.createdAt >= activatedAt;
|
|
54741
54787
|
}
|
|
54742
54788
|
async function conclusionResultsLines(closure) {
|
|
54743
54789
|
const lines = [];
|
|
54744
54790
|
for (const member of closure) {
|
|
54745
54791
|
if (member.taskType === "follow-up" || member.taskType === "reroute-decision")
|
|
54746
54792
|
continue;
|
|
54747
|
-
if (!isOutcomeStatus(member.status)
|
|
54793
|
+
if (!isOutcomeStatus(member.status))
|
|
54748
54794
|
continue;
|
|
54749
54795
|
const glyph = await taskStateGlyph(member, new Date);
|
|
54750
54796
|
const agentName = await agentDisplayNameFor(member);
|
|
@@ -55020,6 +55066,62 @@ async function streamOutcomeCard(task, tree, options) {
|
|
|
55020
55066
|
conclusionKind: options?.conclusionKind
|
|
55021
55067
|
});
|
|
55022
55068
|
}
|
|
55069
|
+
async function resolvedDeferralContent(wake) {
|
|
55070
|
+
if (!isDeferredTask(wake)) {
|
|
55071
|
+
const content = await outcomeContent(wake, wake.slackReplySent);
|
|
55072
|
+
return outcomePresentation(wake, content, attachmentLine(await getTaskAttachments(wake.id)));
|
|
55073
|
+
}
|
|
55074
|
+
const card = await getSlackOutcomeMessage(wake.id);
|
|
55075
|
+
const pointer = card?.permalink ? ` — ${card.permalink}` : ".";
|
|
55076
|
+
return `↪️ Resumed by ${await agentDisplayNameFor(wake)} and deferred again${pointer}`;
|
|
55077
|
+
}
|
|
55078
|
+
async function isAnsweredByDeferralCard(task, threadTasks) {
|
|
55079
|
+
if (!isSlackContinuation(task) || !task.parentTaskId || isDeferredTask(task))
|
|
55080
|
+
return false;
|
|
55081
|
+
const deferred = threadTasks.find((candidate) => candidate.id === task.parentTaskId);
|
|
55082
|
+
if (!deferred?.deferredAt)
|
|
55083
|
+
return false;
|
|
55084
|
+
const card = await getSlackOutcomeMessage(deferred.id);
|
|
55085
|
+
return !!card?.finalizedAt && !isPendingSlackMessage(card) && !card.deferralAbandonedAt;
|
|
55086
|
+
}
|
|
55087
|
+
function isTerminalSlackError(error) {
|
|
55088
|
+
const code = error.data?.error;
|
|
55089
|
+
return typeof code === "string" && code.length > 0 && code !== "ratelimited";
|
|
55090
|
+
}
|
|
55091
|
+
var DEFERRAL_REFRESH_MAX_ATTEMPTS = 5;
|
|
55092
|
+
var deferralRefreshAttempts = new Map;
|
|
55093
|
+
async function refreshResolvedDeferralCards() {
|
|
55094
|
+
const app2 = getSlackApp();
|
|
55095
|
+
if (!app2)
|
|
55096
|
+
return;
|
|
55097
|
+
for (const { card, wakeTaskId } of await getResolvableDeferralOutcomes()) {
|
|
55098
|
+
try {
|
|
55099
|
+
const wake = await getTaskById(wakeTaskId);
|
|
55100
|
+
if (!wake)
|
|
55101
|
+
continue;
|
|
55102
|
+
const content = await resolvedDeferralContent(wake);
|
|
55103
|
+
await callSlackWithRetry(app2.client, "chat.update", {
|
|
55104
|
+
channel: card.channelId,
|
|
55105
|
+
ts: card.ts,
|
|
55106
|
+
text: content
|
|
55107
|
+
});
|
|
55108
|
+
await markSlackDeferralResolved(card.id);
|
|
55109
|
+
deferralRefreshAttempts.delete(card.id);
|
|
55110
|
+
await finalizeTerminalSlackReactions([wake]);
|
|
55111
|
+
} catch (error) {
|
|
55112
|
+
const attempts = (deferralRefreshAttempts.get(card.id) ?? 0) + 1;
|
|
55113
|
+
deferralRefreshAttempts.set(card.id, attempts);
|
|
55114
|
+
const terminal = isTerminalSlackError(error);
|
|
55115
|
+
if (terminal || attempts >= DEFERRAL_REFRESH_MAX_ATTEMPTS) {
|
|
55116
|
+
await markSlackDeferralResolved(card.id, { abandoned: true });
|
|
55117
|
+
deferralRefreshAttempts.delete(card.id);
|
|
55118
|
+
console.error(`[Slack] Giving up on deferral card ${card.id} after ${attempts} attempt(s)` + `${terminal ? " (Slack refused the rewrite)" : ""}:`, error);
|
|
55119
|
+
continue;
|
|
55120
|
+
}
|
|
55121
|
+
console.error(`[Slack] Failed to resolve deferral card ${card.id} ` + `(attempt ${attempts}/${DEFERRAL_REFRESH_MAX_ATTEMPTS}):`, error);
|
|
55122
|
+
}
|
|
55123
|
+
}
|
|
55124
|
+
}
|
|
55023
55125
|
async function processSlackRenderV2() {
|
|
55024
55126
|
if (!isSlackRenderV2Enabled())
|
|
55025
55127
|
return;
|
|
@@ -55075,7 +55177,7 @@ async function processSlackRenderV2() {
|
|
|
55075
55177
|
for (const task of tasks) {
|
|
55076
55178
|
if ((await getSlackOutcomeMessage(task.id))?.finalizedAt)
|
|
55077
55179
|
continue;
|
|
55078
|
-
const isDirectCandidate = taskNeedsDirectOutcome(task, activatedAt) && isOutcomeStatus(task.status);
|
|
55180
|
+
const isDirectCandidate = taskNeedsDirectOutcome(task, activatedAt) && isOutcomeStatus(task.status) && !await isAnsweredByDeferralCard(task, tasks);
|
|
55079
55181
|
const isChildCandidate = delegationEnabled && delegationActivatedAt !== null && isChildCardCandidate(task, delegationActivatedAt) && !task.slackReplySent;
|
|
55080
55182
|
if (isDirectCandidate || isChildCandidate) {
|
|
55081
55183
|
needsOutcome = true;
|
|
@@ -55174,6 +55276,8 @@ async function processSlackRenderV2() {
|
|
|
55174
55276
|
continue;
|
|
55175
55277
|
if ((await getSlackOutcomeMessage(task.id))?.finalizedAt)
|
|
55176
55278
|
continue;
|
|
55279
|
+
if (await isAnsweredByDeferralCard(task, tasks))
|
|
55280
|
+
continue;
|
|
55177
55281
|
const deferByClosure = task.source === "slack" && delegationEnabled && delegationActivatedAt !== null && task.createdAt >= delegationActivatedAt;
|
|
55178
55282
|
if (!deferByClosure) {
|
|
55179
55283
|
if (!outcomeDeliveryGate(task.id))
|
|
@@ -55236,6 +55340,7 @@ async function processSlackRenderV2() {
|
|
|
55236
55340
|
console.error(`[Slack] Failed to update v2 tree ${tree.id}:`, error);
|
|
55237
55341
|
}
|
|
55238
55342
|
}
|
|
55343
|
+
await refreshResolvedDeferralCards();
|
|
55239
55344
|
}
|
|
55240
55345
|
function _resetSlackRenderV2ForTests() {
|
|
55241
55346
|
for (const timer of pendingTreeUpdates.values())
|
|
@@ -55249,4 +55354,4 @@ function _resetSlackRenderV2ForTests() {
|
|
|
55249
55354
|
outcomeDeliveryFailures.clear();
|
|
55250
55355
|
}
|
|
55251
55356
|
|
|
55252
|
-
export { initialize, ensure, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, require_dist7 as require_dist, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks,
|
|
55357
|
+
export { initialize, ensure, isPollTracingEnabled, initOtel, withSpan, startSpan, withSpanContext, withRemoteContext, injectTraceContext, recordSessionCost, recordDbRetentionSweep, recordDbRetentionStatement, require_dist7 as require_dist, slackTaskOutput, ackSlackMessage, getTaskLink, getTaskUrl, markdownToSlack, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks, getAgentDisplayName, getAgentEmoji, isSlackRenderV2Enabled, isSlackDelegationEnabled, callSlackWithRetry, formatV2Duration, renderThreadTree, ensureSlackThreadTree, withStatusLead, childOutcomeContent, streamOutcomeCard, refreshResolvedDeferralCards, processSlackRenderV2, _resetSlackRenderV2ForTests, registerTreeMessage, getSlackApp, initSlackApp, startSlackApp, stopSlackApp };
|