@vellumai/assistant 0.11.2-dev.202608052227.261a826 → 0.11.2-dev.202608052324.a11da34
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.yaml +3 -1
- package/package.json +1 -1
- package/src/__tests__/conversation-agent-loop.test.ts +87 -0
- package/src/__tests__/profile-availability-incomplete.test.ts +113 -0
- package/src/__tests__/scaffold-managed-skill-tool.test.ts +166 -0
- package/src/daemon/conversation-agent-loop.ts +53 -29
- package/src/providers/inference/connection-availability.ts +48 -11
- package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +57 -6
- package/src/runtime/routes/default-provider-routes.ts +7 -11
- package/src/runtime/routes/inference-profile-availability-guard.ts +6 -0
- package/src/runtime/routes/inference-profiles-routes.ts +2 -9
- package/src/tools/skills/scaffold-managed.ts +82 -0
package/openapi.yaml
CHANGED
|
@@ -34596,13 +34596,14 @@ components:
|
|
|
34596
34596
|
type: string
|
|
34597
34597
|
enum:
|
|
34598
34598
|
- ok
|
|
34599
|
-
-
|
|
34599
|
+
- incomplete
|
|
34600
34600
|
- missing_connection
|
|
34601
34601
|
- missing_credential
|
|
34602
34602
|
- provider_mismatch
|
|
34603
34603
|
- unsupported_auth
|
|
34604
34604
|
- vellum_unauthenticated
|
|
34605
34605
|
- unknown
|
|
34606
|
+
- missing_default
|
|
34606
34607
|
message:
|
|
34607
34608
|
type: string
|
|
34608
34609
|
required:
|
|
@@ -34828,6 +34829,7 @@ components:
|
|
|
34828
34829
|
type: string
|
|
34829
34830
|
enum:
|
|
34830
34831
|
- ok
|
|
34832
|
+
- incomplete
|
|
34831
34833
|
- missing_connection
|
|
34832
34834
|
- missing_credential
|
|
34833
34835
|
- provider_mismatch
|
package/package.json
CHANGED
|
@@ -782,6 +782,7 @@ function makeCtx(
|
|
|
782
782
|
channelCapabilities: undefined,
|
|
783
783
|
commandIntent: undefined,
|
|
784
784
|
trustContext: undefined,
|
|
785
|
+
toolsDisabledDepth: 0,
|
|
785
786
|
|
|
786
787
|
allowedToolNames: undefined,
|
|
787
788
|
preactivatedSkillIds: undefined,
|
|
@@ -1187,6 +1188,92 @@ describe("session-agent-loop", () => {
|
|
|
1187
1188
|
runAgentLoopImpl(ctx, "hello", "msg-1", () => {}),
|
|
1188
1189
|
).rejects.toThrow("runAgentLoop called without prior persistUserMessage");
|
|
1189
1190
|
});
|
|
1191
|
+
|
|
1192
|
+
test("defers workspace Git work when tools are disabled", async () => {
|
|
1193
|
+
const ensureInitialized = mock(async () => {});
|
|
1194
|
+
const commitTurnChanges = mock(async () => {});
|
|
1195
|
+
const ctx = makeCtx({
|
|
1196
|
+
toolsDisabledDepth: 1,
|
|
1197
|
+
getWorkspaceGitService: () => ({ ensureInitialized }),
|
|
1198
|
+
commitTurnChanges,
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
await runAgentLoopImpl(ctx, "hello", "msg-1", () => {});
|
|
1202
|
+
|
|
1203
|
+
expect(ensureInitialized).not.toHaveBeenCalled();
|
|
1204
|
+
expect(commitTurnChanges).not.toHaveBeenCalled();
|
|
1205
|
+
|
|
1206
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
1207
|
+
|
|
1208
|
+
expect(commitTurnChanges).toHaveBeenCalledTimes(1);
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
test("leaves a deferred commit to an immediate follow-up turn", async () => {
|
|
1212
|
+
const commitTurnChanges = mock(async () => {});
|
|
1213
|
+
const ctx = makeCtx({
|
|
1214
|
+
toolsDisabledDepth: 1,
|
|
1215
|
+
commitTurnChanges,
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
await runAgentLoopImpl(ctx, "hello", "msg-1", () => {});
|
|
1219
|
+
ctx.setProcessing(true);
|
|
1220
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
1221
|
+
|
|
1222
|
+
expect(commitTurnChanges).not.toHaveBeenCalled();
|
|
1223
|
+
ctx.setProcessing(false);
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1226
|
+
test("initializes workspace Git before hooks when tools can run", async () => {
|
|
1227
|
+
let initialized = false;
|
|
1228
|
+
const ensureInitialized = mock(async () => {
|
|
1229
|
+
initialized = true;
|
|
1230
|
+
});
|
|
1231
|
+
const commitTurnChanges = mock(async () => {});
|
|
1232
|
+
const initializedDuringHook: boolean[] = [];
|
|
1233
|
+
registerPlugin({
|
|
1234
|
+
manifest: {
|
|
1235
|
+
name: "test-workspace-git-ready-before-hook",
|
|
1236
|
+
version: "1.0.0",
|
|
1237
|
+
},
|
|
1238
|
+
hooks: {
|
|
1239
|
+
"user-prompt-submit": async () => {
|
|
1240
|
+
initializedDuringHook.push(initialized);
|
|
1241
|
+
},
|
|
1242
|
+
},
|
|
1243
|
+
});
|
|
1244
|
+
const ctx = makeCtx({
|
|
1245
|
+
getWorkspaceGitService: () => ({ ensureInitialized }),
|
|
1246
|
+
commitTurnChanges,
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
await runAgentLoopImpl(ctx, "hello", "msg-1", () => {});
|
|
1250
|
+
|
|
1251
|
+
expect(ensureInitialized).toHaveBeenCalledTimes(1);
|
|
1252
|
+
expect(commitTurnChanges).toHaveBeenCalledTimes(1);
|
|
1253
|
+
expect(initializedDuringHook).toEqual([true]);
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
test("continues a tool-capable turn when workspace Git initialization fails", async () => {
|
|
1257
|
+
const ensureInitialized = mock(async () => {
|
|
1258
|
+
throw new Error("simulated Git initialization failure");
|
|
1259
|
+
});
|
|
1260
|
+
const events: AssistantEvent[] = [];
|
|
1261
|
+
const ctx = makeCtx({
|
|
1262
|
+
getWorkspaceGitService: () => ({ ensureInitialized }),
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
await runAgentLoopImpl(ctx, "hello", "msg-1", (event) =>
|
|
1266
|
+
events.push(event),
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
expect(ensureInitialized).toHaveBeenCalledTimes(1);
|
|
1270
|
+
expect(events.some((event) => event.type === "message_complete")).toBe(
|
|
1271
|
+
true,
|
|
1272
|
+
);
|
|
1273
|
+
expect(events.some((event) => event.type === "conversation_error")).toBe(
|
|
1274
|
+
false,
|
|
1275
|
+
);
|
|
1276
|
+
});
|
|
1190
1277
|
});
|
|
1191
1278
|
|
|
1192
1279
|
describe("disk pressure injection context", () => {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `computeProfileAvailability` on profiles that carry no dispatchable pair.
|
|
3
|
+
*
|
|
4
|
+
* A rung only wins if its profile carries both a provider and a model
|
|
5
|
+
* (`usableEntry` in config/llm-resolver.ts). A profile missing either is
|
|
6
|
+
* skipped and the call site resolves elsewhere, so the profiles read has to
|
|
7
|
+
* report that state rather than returning "nothing to judge", which clients
|
|
8
|
+
* render as healthy.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, expect, test } from "bun:test";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
computeProfileAvailability,
|
|
15
|
+
isUnavailable,
|
|
16
|
+
} from "../providers/inference/connection-availability.js";
|
|
17
|
+
import { describeUnavailableProfile } from "../runtime/routes/inference-profile-availability-guard.js";
|
|
18
|
+
|
|
19
|
+
describe("incomplete profiles", () => {
|
|
20
|
+
test("no provider and no model reports both as missing", async () => {
|
|
21
|
+
const availability = await computeProfileAvailability({});
|
|
22
|
+
expect(availability?.status).toBe("incomplete");
|
|
23
|
+
expect(availability?.message).toContain("a provider and a model");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("a model with no provider names the provider", async () => {
|
|
27
|
+
const availability = await computeProfileAvailability({
|
|
28
|
+
model: "claude-opus-5",
|
|
29
|
+
});
|
|
30
|
+
expect(availability?.status).toBe("incomplete");
|
|
31
|
+
expect(availability?.message).toContain("a provider");
|
|
32
|
+
expect(availability?.message).not.toContain("a provider and a model");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("a provider with no model names the model", async () => {
|
|
36
|
+
const availability = await computeProfileAvailability({
|
|
37
|
+
provider: "anthropic",
|
|
38
|
+
});
|
|
39
|
+
expect(availability?.status).toBe("incomplete");
|
|
40
|
+
expect(availability?.message).toContain("a model");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// The destination is deliberately unnamed: which profile a call site falls
|
|
44
|
+
// back to depends on the call site, so the message states the effect only.
|
|
45
|
+
test("the message names the effect without naming a destination", async () => {
|
|
46
|
+
const availability = await computeProfileAvailability({});
|
|
47
|
+
expect(availability?.message).toContain("fall back to another profile");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("mix profiles", () => {
|
|
52
|
+
// A mix carries no provider or model of its own: the resolver expands it to
|
|
53
|
+
// a seeded arm and judges that arm. Reporting a mix as incomplete would put
|
|
54
|
+
// a warning on every working mix profile.
|
|
55
|
+
test("a mix still reports nothing to judge", async () => {
|
|
56
|
+
const availability = await computeProfileAvailability({
|
|
57
|
+
mix: [
|
|
58
|
+
{ profile: "balanced", weight: 1 },
|
|
59
|
+
{ profile: "quality", weight: 1 },
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
expect(availability).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("a mix that also names a provider and model is judged normally", async () => {
|
|
66
|
+
const availability = await computeProfileAvailability({
|
|
67
|
+
mix: [{ profile: "balanced", weight: 1 }],
|
|
68
|
+
provider: "anthropic",
|
|
69
|
+
model: "claude-opus-5",
|
|
70
|
+
});
|
|
71
|
+
expect(availability?.status).not.toBe("incomplete");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("selection guards", () => {
|
|
76
|
+
// The resolver skips an incomplete profile on every turn, so pinning one
|
|
77
|
+
// means the user's selection is not what runs. Before `incomplete` existed,
|
|
78
|
+
// a provider without a model reached the auto-resolve branch and could
|
|
79
|
+
// return `missing_connection`, which these guards already rejected; the new
|
|
80
|
+
// verdict has to keep that door shut rather than open it.
|
|
81
|
+
test("an incomplete profile counts as unavailable", async () => {
|
|
82
|
+
expect(isUnavailable(await computeProfileAvailability({}))).toBe(true);
|
|
83
|
+
expect(
|
|
84
|
+
isUnavailable(
|
|
85
|
+
await computeProfileAvailability({ provider: "anthropic" }),
|
|
86
|
+
),
|
|
87
|
+
).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("a mix is still not judged, so it is not blocked", async () => {
|
|
91
|
+
expect(
|
|
92
|
+
isUnavailable(
|
|
93
|
+
await computeProfileAvailability({
|
|
94
|
+
mix: [{ profile: "balanced", weight: 1 }],
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// `describeUnavailableProfile` interpolates the provider, which an
|
|
101
|
+
// incomplete profile may not have. Its guidance must not leak "undefined".
|
|
102
|
+
test("the repair guidance names the fix without inventing a provider", async () => {
|
|
103
|
+
const availability = await computeProfileAvailability({});
|
|
104
|
+
const message = await describeUnavailableProfile({
|
|
105
|
+
availability: availability!,
|
|
106
|
+
provider: String(undefined),
|
|
107
|
+
repair: { kind: "repoint", profileName: "half-made" },
|
|
108
|
+
escapeHatch: false,
|
|
109
|
+
});
|
|
110
|
+
expect(message).not.toContain("undefined");
|
|
111
|
+
expect(message).toContain("provider and a model");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -32,6 +32,26 @@ mock.module("../daemon/skill-memory-refresh.js", () => ({
|
|
|
32
32
|
refreshSkillCapabilityMemories: mockRefreshSkillCapabilityMemories,
|
|
33
33
|
}));
|
|
34
34
|
|
|
35
|
+
// Background skill updates route through the notification pipeline; record
|
|
36
|
+
// the signals rather than standing up delivery.
|
|
37
|
+
let emittedSignals: Array<{
|
|
38
|
+
sourceEventName: string;
|
|
39
|
+
sourceContextId: string;
|
|
40
|
+
dedupeKey?: string;
|
|
41
|
+
contextPayload?: Record<string, unknown>;
|
|
42
|
+
}> = [];
|
|
43
|
+
mock.module("../notifications/emit-signal.js", () => ({
|
|
44
|
+
emitNotificationSignal: async (params: {
|
|
45
|
+
sourceEventName: string;
|
|
46
|
+
sourceContextId: string;
|
|
47
|
+
dedupeKey?: string;
|
|
48
|
+
contextPayload?: Record<string, unknown>;
|
|
49
|
+
}) => {
|
|
50
|
+
emittedSignals.push(params);
|
|
51
|
+
return { signalId: "test-signal" };
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
|
|
35
55
|
// Skill-card enqueue recorder. Snapshot + override (rather than a full module
|
|
36
56
|
// replacement) because other modules in this import graph (e.g. the managed
|
|
37
57
|
// store's capability seeding) import sibling jobs-store exports that must
|
|
@@ -104,6 +124,7 @@ beforeEach(() => {
|
|
|
104
124
|
skillCardJobUpserts = [];
|
|
105
125
|
skillCardUpsertThrows = false;
|
|
106
126
|
watchdogEvents.length = 0;
|
|
127
|
+
emittedSignals = [];
|
|
107
128
|
});
|
|
108
129
|
|
|
109
130
|
afterEach(() => {
|
|
@@ -1470,3 +1491,148 @@ describe("scaffold_managed_skill tool", () => {
|
|
|
1470
1491
|
).toEqual(["run-skill-a", "run-skill-b"]);
|
|
1471
1492
|
});
|
|
1472
1493
|
});
|
|
1494
|
+
|
|
1495
|
+
// ── Background skill updates are announced ─────────────────────────────────
|
|
1496
|
+
//
|
|
1497
|
+
// A background pass runs inside a hidden retrospective fork, so its tool call
|
|
1498
|
+
// renders in a conversation the user never opens. Creates reach the source
|
|
1499
|
+
// conversation as a `skill_card`; updates reach the background activity feed.
|
|
1500
|
+
|
|
1501
|
+
describe("background skill update notification", () => {
|
|
1502
|
+
/** Seed an assistant-authored skill the background pass may overwrite. */
|
|
1503
|
+
async function seedAssistantSkill(id: string, body: string): Promise<void> {
|
|
1504
|
+
await executeScaffoldManagedSkill(
|
|
1505
|
+
{
|
|
1506
|
+
skill_id: id,
|
|
1507
|
+
name: "Weekly Report Export",
|
|
1508
|
+
description: `seeded ${id}`,
|
|
1509
|
+
body_markdown: body,
|
|
1510
|
+
},
|
|
1511
|
+
makeContext(),
|
|
1512
|
+
);
|
|
1513
|
+
writeInstallMeta(join(TEST_DIR, "skills", id), {
|
|
1514
|
+
origin: "custom",
|
|
1515
|
+
installedAt: new Date().toISOString(),
|
|
1516
|
+
author: "assistant",
|
|
1517
|
+
});
|
|
1518
|
+
watchdogEvents.length = 0;
|
|
1519
|
+
skillCardJobUpserts = [];
|
|
1520
|
+
emittedSignals = [];
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
const lineage = () => ({
|
|
1524
|
+
getConversation: (id: string) =>
|
|
1525
|
+
id === "retro-run-conv"
|
|
1526
|
+
? { forkParentConversationId: "source-conv" }
|
|
1527
|
+
: null,
|
|
1528
|
+
});
|
|
1529
|
+
|
|
1530
|
+
test("a background overwrite of an existing skill notifies, keyed to the source conversation", async () => {
|
|
1531
|
+
await seedAssistantSkill("weekly-export", "Old body.");
|
|
1532
|
+
|
|
1533
|
+
const result = await executeScaffoldManagedSkill(
|
|
1534
|
+
{
|
|
1535
|
+
skill_id: "weekly-export",
|
|
1536
|
+
name: "Weekly Report Export",
|
|
1537
|
+
description: "export the weekly usage report",
|
|
1538
|
+
body_markdown: "1. Refined steps.",
|
|
1539
|
+
overwrite: true,
|
|
1540
|
+
},
|
|
1541
|
+
makeRetrospectiveContext({ conversationId: "retro-run-conv" }),
|
|
1542
|
+
lineage(),
|
|
1543
|
+
);
|
|
1544
|
+
|
|
1545
|
+
expect(result.isError).toBe(false);
|
|
1546
|
+
expect(emittedSignals).toHaveLength(1);
|
|
1547
|
+
const signal = emittedSignals[0]!;
|
|
1548
|
+
expect(signal.sourceEventName).toBe("activity.complete");
|
|
1549
|
+
// The feed item's "Go to Convo" target resolves through this id, so it
|
|
1550
|
+
// must be the conversation the work came from, not the hidden fork.
|
|
1551
|
+
expect(signal.sourceContextId).toBe("source-conv");
|
|
1552
|
+
expect(signal.contextPayload?.skillId).toBe("weekly-export");
|
|
1553
|
+
expect(String(signal.contextPayload?.summary)).toContain(
|
|
1554
|
+
"Weekly Report Export",
|
|
1555
|
+
);
|
|
1556
|
+
// The home feed falls back to `title`/`body` when no channel copy was
|
|
1557
|
+
// rendered, which is the intended quiet shape for this signal. Without
|
|
1558
|
+
// them a suppressed delivery would leave the feed item unwritten.
|
|
1559
|
+
// Named so the row is scannable in a feed several entries deep.
|
|
1560
|
+
expect(signal.contextPayload?.title).toBe(
|
|
1561
|
+
"Skill updated: Weekly Report Export",
|
|
1562
|
+
);
|
|
1563
|
+
expect(String(signal.contextPayload?.body)).toContain(
|
|
1564
|
+
"Weekly Report Export",
|
|
1565
|
+
);
|
|
1566
|
+
// Deduped per skill per day so repeated refinements cannot flood the feed.
|
|
1567
|
+
expect(signal.dedupeKey).toBe(
|
|
1568
|
+
`skill-updated:weekly-export:${new Date().toISOString().slice(0, 10)}`,
|
|
1569
|
+
);
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
test("it falls back to the run conversation when fork lineage does not resolve", async () => {
|
|
1573
|
+
await seedAssistantSkill("weekly-export", "Old body.");
|
|
1574
|
+
|
|
1575
|
+
await executeScaffoldManagedSkill(
|
|
1576
|
+
{
|
|
1577
|
+
skill_id: "weekly-export",
|
|
1578
|
+
name: "Weekly Report Export",
|
|
1579
|
+
description: "export the weekly usage report",
|
|
1580
|
+
body_markdown: "1. Refined steps.",
|
|
1581
|
+
overwrite: true,
|
|
1582
|
+
},
|
|
1583
|
+
makeRetrospectiveContext({ conversationId: "retro-run-conv" }),
|
|
1584
|
+
{ getConversation: () => null },
|
|
1585
|
+
);
|
|
1586
|
+
|
|
1587
|
+
// Still a real conversation id, so the deep link resolves rather than
|
|
1588
|
+
// falling through to an unrelated target.
|
|
1589
|
+
expect(emittedSignals).toHaveLength(1);
|
|
1590
|
+
expect(emittedSignals[0]!.sourceContextId).toBe("retro-run-conv");
|
|
1591
|
+
});
|
|
1592
|
+
|
|
1593
|
+
test("a background CREATE gets the skill card instead, with no duplicate signal", async () => {
|
|
1594
|
+
const result = await executeScaffoldManagedSkill(
|
|
1595
|
+
{
|
|
1596
|
+
skill_id: "brand-new-skill",
|
|
1597
|
+
name: "Brand New Skill",
|
|
1598
|
+
description: "something never seen before",
|
|
1599
|
+
body_markdown: "1. Do it.",
|
|
1600
|
+
},
|
|
1601
|
+
makeRetrospectiveContext({ conversationId: "retro-run-conv" }),
|
|
1602
|
+
lineage(),
|
|
1603
|
+
);
|
|
1604
|
+
|
|
1605
|
+
expect(result.isError).toBe(false);
|
|
1606
|
+
expect(skillCardJobUpserts).toHaveLength(1);
|
|
1607
|
+
expect(emittedSignals).toHaveLength(0);
|
|
1608
|
+
});
|
|
1609
|
+
|
|
1610
|
+
test("a user-directed overwrite does not notify: it is not unattended work", async () => {
|
|
1611
|
+
await executeScaffoldManagedSkill(
|
|
1612
|
+
{
|
|
1613
|
+
skill_id: "user-skill",
|
|
1614
|
+
name: "User Skill",
|
|
1615
|
+
description: "asked for",
|
|
1616
|
+
body_markdown: "V1.",
|
|
1617
|
+
},
|
|
1618
|
+
makeContext(),
|
|
1619
|
+
);
|
|
1620
|
+
emittedSignals = [];
|
|
1621
|
+
|
|
1622
|
+
await executeScaffoldManagedSkill(
|
|
1623
|
+
{
|
|
1624
|
+
skill_id: "user-skill",
|
|
1625
|
+
name: "User Skill",
|
|
1626
|
+
description: "asked for",
|
|
1627
|
+
body_markdown: "V2.",
|
|
1628
|
+
overwrite: true,
|
|
1629
|
+
},
|
|
1630
|
+
makeContext(),
|
|
1631
|
+
);
|
|
1632
|
+
|
|
1633
|
+
expect(
|
|
1634
|
+
readFileSync(join(TEST_DIR, "skills", "user-skill", "SKILL.md"), "utf-8"),
|
|
1635
|
+
).toContain("V2.");
|
|
1636
|
+
expect(emittedSignals).toHaveLength(0);
|
|
1637
|
+
});
|
|
1638
|
+
});
|
|
@@ -642,6 +642,7 @@ export async function runAgentLoopImpl(
|
|
|
642
642
|
);
|
|
643
643
|
ctx.diskPressureCleanupModeActive =
|
|
644
644
|
diskPressureDecision.action === "allow-cleanup-mode";
|
|
645
|
+
const toolsDisabledForTurn = ctx.toolsDisabledDepth > 0;
|
|
645
646
|
|
|
646
647
|
ctx.lastAssistantAttachments = [];
|
|
647
648
|
ctx.lastAttachmentWarnings = [];
|
|
@@ -722,14 +723,20 @@ export async function runAgentLoopImpl(
|
|
|
722
723
|
return;
|
|
723
724
|
}
|
|
724
725
|
|
|
725
|
-
//
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
726
|
+
// Workspace Git readiness is required only when tools can run. Tool-less
|
|
727
|
+
// callers use the same depth gate consumed by tool resolution.
|
|
728
|
+
if (!toolsDisabledForTurn) {
|
|
729
|
+
try {
|
|
730
|
+
const getWorkspaceGitServiceFn =
|
|
731
|
+
ctx.getWorkspaceGitService ?? getWorkspaceGitService;
|
|
732
|
+
const gitService = getWorkspaceGitServiceFn(ctx.workingDir);
|
|
733
|
+
await gitService.ensureInitialized();
|
|
734
|
+
} catch (err) {
|
|
735
|
+
rlog.warn(
|
|
736
|
+
{ err },
|
|
737
|
+
"Failed to initialize workspace git repo (non-fatal)",
|
|
738
|
+
);
|
|
739
|
+
}
|
|
733
740
|
}
|
|
734
741
|
|
|
735
742
|
// Auto-complete stale interactive surfaces from previous turns.
|
|
@@ -1698,28 +1705,45 @@ export async function runAgentLoopImpl(
|
|
|
1698
1705
|
|
|
1699
1706
|
if (turnStarted) {
|
|
1700
1707
|
ctx.turnCount++;
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
const outcome = await raceWithTimeout(commitPromise, maxWait);
|
|
1714
|
-
if (outcome === "timed_out") {
|
|
1715
|
-
rlog.warn(
|
|
1716
|
-
{
|
|
1717
|
-
turnNumber: ctx.turnCount,
|
|
1718
|
-
maxWaitMs: maxWait,
|
|
1719
|
-
conversationId: ctx.conversationId,
|
|
1720
|
-
},
|
|
1721
|
-
"Turn-boundary commit timed out — continuing without waiting (commit still runs in background)",
|
|
1708
|
+
const runTurnCommit = async (): Promise<void> => {
|
|
1709
|
+
const config = getConfig();
|
|
1710
|
+
const maxWait = config.workspaceGit?.turnCommitMaxWaitMs ?? 4000;
|
|
1711
|
+
const deadlineMs = Date.now() + maxWait;
|
|
1712
|
+
|
|
1713
|
+
const commitTurnChangesFn = ctx.commitTurnChanges ?? commitTurnChanges;
|
|
1714
|
+
const commitPromise = commitTurnChangesFn(
|
|
1715
|
+
ctx.workingDir,
|
|
1716
|
+
ctx.conversationId,
|
|
1717
|
+
ctx.turnCount,
|
|
1718
|
+
undefined,
|
|
1719
|
+
deadlineMs,
|
|
1722
1720
|
);
|
|
1721
|
+
const outcome = await raceWithTimeout(commitPromise, maxWait);
|
|
1722
|
+
if (outcome === "timed_out") {
|
|
1723
|
+
rlog.warn(
|
|
1724
|
+
{
|
|
1725
|
+
turnNumber: ctx.turnCount,
|
|
1726
|
+
maxWaitMs: maxWait,
|
|
1727
|
+
conversationId: ctx.conversationId,
|
|
1728
|
+
},
|
|
1729
|
+
"Turn-boundary commit timed out; continuing without waiting (commit still runs in background)",
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
if (toolsDisabledForTurn) {
|
|
1735
|
+
// Let the caller and queue drain claim an immediate follow-up turn
|
|
1736
|
+
// before starting Git. That turn will commit the accumulated disk view.
|
|
1737
|
+
setImmediate(() => {
|
|
1738
|
+
if (ctx.isProcessing()) {
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
void runTurnCommit().catch((err) => {
|
|
1742
|
+
rlog.warn({ err }, "Deferred turn-boundary commit failed");
|
|
1743
|
+
});
|
|
1744
|
+
});
|
|
1745
|
+
} else {
|
|
1746
|
+
await runTurnCommit();
|
|
1723
1747
|
}
|
|
1724
1748
|
|
|
1725
1749
|
// Recompute relationship-state.json at turn boundary (fire-and-forget).
|
|
@@ -38,14 +38,24 @@ import {
|
|
|
38
38
|
import { ROUTING_IDENTITY_PROVIDERS } from "./auth.js";
|
|
39
39
|
import { getConnection, listConnections } from "./connections.js";
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Every availability verdict, in one place. Route schemas build their zod
|
|
43
|
+
* enums from this rather than restating it, so a new status reaches the wire
|
|
44
|
+
* for every surface at once instead of drifting between them.
|
|
45
|
+
*/
|
|
46
|
+
export const CONNECTION_AVAILABILITY_STATUSES = [
|
|
47
|
+
"ok",
|
|
48
|
+
"incomplete",
|
|
49
|
+
"missing_connection",
|
|
50
|
+
"missing_credential",
|
|
51
|
+
"provider_mismatch",
|
|
52
|
+
"unsupported_auth",
|
|
53
|
+
"vellum_unauthenticated",
|
|
54
|
+
"unknown",
|
|
55
|
+
] as const;
|
|
56
|
+
|
|
41
57
|
export type ConnectionAvailabilityStatus =
|
|
42
|
-
|
|
43
|
-
| "missing_connection"
|
|
44
|
-
| "missing_credential"
|
|
45
|
-
| "provider_mismatch"
|
|
46
|
-
| "unsupported_auth"
|
|
47
|
-
| "vellum_unauthenticated"
|
|
48
|
-
| "unknown";
|
|
58
|
+
(typeof CONNECTION_AVAILABILITY_STATUSES)[number];
|
|
49
59
|
|
|
50
60
|
export interface ConnectionAvailability {
|
|
51
61
|
status: ConnectionAvailabilityStatus;
|
|
@@ -228,6 +238,11 @@ export async function computeConnectionAvailability(
|
|
|
228
238
|
*/
|
|
229
239
|
const UNAVAILABLE_STATUSES: ReadonlySet<ConnectionAvailabilityStatus> = new Set(
|
|
230
240
|
[
|
|
241
|
+
// A profile with no provider and model of its own is skipped by the
|
|
242
|
+
// resolver on every turn, so it provably cannot serve a request. It
|
|
243
|
+
// belongs here for the same reason the connection failures do: pinning
|
|
244
|
+
// one silently runs a different profile than the user selected.
|
|
245
|
+
"incomplete",
|
|
231
246
|
"missing_connection",
|
|
232
247
|
"missing_credential",
|
|
233
248
|
"provider_mismatch",
|
|
@@ -254,17 +269,39 @@ export function isUnavailable(
|
|
|
254
269
|
* dispatch would auto-resolve (an active, model-compatible row for that
|
|
255
270
|
* provider) — with no such row, the profile cannot serve requests.
|
|
256
271
|
*
|
|
257
|
-
* Returns null when there is nothing to judge
|
|
272
|
+
* Returns null when there is nothing to judge: a mix carries no provider or
|
|
273
|
+
* model of its own, because the resolver expands it to a seeded arm and
|
|
274
|
+
* judges that arm instead.
|
|
258
275
|
*/
|
|
259
276
|
export async function computeProfileAvailability(
|
|
260
277
|
entry: Record<string, unknown>,
|
|
261
278
|
): Promise<ConnectionAvailability | null> {
|
|
262
279
|
const provider = entry.provider;
|
|
263
|
-
if (typeof provider !== "string") {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
280
|
const model = typeof entry.model === "string" ? entry.model : undefined;
|
|
267
281
|
|
|
282
|
+
// A rung only wins if its profile carries BOTH a provider and a model (see
|
|
283
|
+
// `usableEntry` in config/llm-resolver.ts); one without them is skipped as
|
|
284
|
+
// "incomplete" and the call site quietly resolves elsewhere. Report that so
|
|
285
|
+
// clients can show it rather than presenting the profile as healthy.
|
|
286
|
+
if (typeof provider !== "string" || model === undefined) {
|
|
287
|
+
if (entry.mix != null) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const missing =
|
|
291
|
+
typeof provider !== "string"
|
|
292
|
+
? model === undefined
|
|
293
|
+
? "a provider and a model"
|
|
294
|
+
: "a provider"
|
|
295
|
+
: "a model";
|
|
296
|
+
// Which profile a call site falls back to depends on the call site (its
|
|
297
|
+
// shipped intent, then the balanced anchor), so this names the effect
|
|
298
|
+
// without claiming a destination it cannot know.
|
|
299
|
+
return {
|
|
300
|
+
status: "incomplete",
|
|
301
|
+
message: `Missing ${missing}, so actions using it fall back to another profile.`,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
268
305
|
// Routing-identity profiles carry no provider_connection. A model the
|
|
269
306
|
// identity cannot route reports as a mismatch rather than throwing —
|
|
270
307
|
// availability annotates, it must not fail the profiles read.
|
|
@@ -19,12 +19,24 @@ mock.module("../../assistant-event-hub.js", () => ({
|
|
|
19
19
|
broadcastMessage: () => {},
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
+
// Pinning consults connection availability, which reads the credential store.
|
|
23
|
+
// Report a stored key so a seeded connection counts as credentialed.
|
|
24
|
+
mock.module("../../../security/secure-keys.js", () => ({
|
|
25
|
+
getSecureKeyResultAsync: async () => ({
|
|
26
|
+
value: "test-key",
|
|
27
|
+
unreachable: false,
|
|
28
|
+
}),
|
|
29
|
+
}));
|
|
30
|
+
|
|
22
31
|
import { eq } from "drizzle-orm";
|
|
23
32
|
|
|
24
33
|
import { setConfig } from "../../../__tests__/helpers/set-config.js";
|
|
25
34
|
import { getDb } from "../../../persistence/db-connection.js";
|
|
26
35
|
import { initializeDb } from "../../../persistence/db-init.js";
|
|
27
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
conversations,
|
|
38
|
+
providerConnections,
|
|
39
|
+
} from "../../../persistence/schema/index.js";
|
|
28
40
|
import { ROUTES as CONVERSATION_MANAGEMENT_ROUTES } from "../conversation-management-routes.js";
|
|
29
41
|
import { ROUTES as INFERENCE_PROFILE_SESSION_ROUTES } from "../inference-profile-session-routes.js";
|
|
30
42
|
import type { RouteDefinition } from "../types.js";
|
|
@@ -41,7 +53,31 @@ await initializeDb();
|
|
|
41
53
|
// keeps its schema default (`maxTtlSeconds: 43200`).
|
|
42
54
|
// ---------------------------------------------------------------------------
|
|
43
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A credentialed connection for `provider`. Pinning a profile to a
|
|
58
|
+
* conversation is refused when the profile provably cannot dispatch, so a
|
|
59
|
+
* profile is only a valid pin target with a connection behind it.
|
|
60
|
+
*/
|
|
61
|
+
function seedKeyedConnection(provider: string): void {
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
getDb()
|
|
64
|
+
.insert(providerConnections)
|
|
65
|
+
.values({
|
|
66
|
+
name: `${provider}-personal`,
|
|
67
|
+
provider,
|
|
68
|
+
auth: JSON.stringify({
|
|
69
|
+
type: "api_key",
|
|
70
|
+
credential: `credential/${provider}/api_key`,
|
|
71
|
+
}),
|
|
72
|
+
createdAt: now,
|
|
73
|
+
updatedAt: now,
|
|
74
|
+
})
|
|
75
|
+
.onConflictDoNothing()
|
|
76
|
+
.run();
|
|
77
|
+
}
|
|
78
|
+
|
|
44
79
|
function seedProfiles(profiles: Record<string, unknown>): void {
|
|
80
|
+
seedKeyedConnection("anthropic");
|
|
45
81
|
setConfig("llm", { profiles });
|
|
46
82
|
}
|
|
47
83
|
|
|
@@ -212,11 +248,26 @@ describe("PUT /v1/conversations/:id/inference-profile", () => {
|
|
|
212
248
|
beforeEach(() => {
|
|
213
249
|
clearConversations();
|
|
214
250
|
seedProfiles({
|
|
215
|
-
fast: { model: "model-a" },
|
|
216
|
-
slow: { model: "model-b" },
|
|
251
|
+
fast: { provider: "anthropic", model: "model-a" },
|
|
252
|
+
slow: { provider: "anthropic", model: "model-b" },
|
|
217
253
|
});
|
|
218
254
|
});
|
|
219
255
|
|
|
256
|
+
// The resolver skips a profile carrying no provider and model, so pinning
|
|
257
|
+
// one would leave the conversation running something other than what was
|
|
258
|
+
// chosen. The pin is refused rather than silently honoured.
|
|
259
|
+
test("PUT rejects a profile that cannot dispatch", async () => {
|
|
260
|
+
seedProfiles({ "half-made": { provider: "anthropic" } });
|
|
261
|
+
const convId = crypto.randomUUID();
|
|
262
|
+
seedConversation(convId);
|
|
263
|
+
await expect(
|
|
264
|
+
putHandler({
|
|
265
|
+
pathParams: { id: convId },
|
|
266
|
+
body: { profile: "half-made", ttlSeconds: 600 },
|
|
267
|
+
}),
|
|
268
|
+
).rejects.toThrow(/provider and a model/);
|
|
269
|
+
});
|
|
270
|
+
|
|
220
271
|
test("PUT with ttlSeconds=600 → response includes sessionId (UUID), expiresAt, ttlSeconds=600", async () => {
|
|
221
272
|
const convId = crypto.randomUUID();
|
|
222
273
|
seedConversation(convId);
|
|
@@ -302,7 +353,7 @@ describe("PUT /v1/conversations/:id/inference-profile", () => {
|
|
|
302
353
|
describe("POST /v1/conversations/inference-profile-session (inference_profile_open)", () => {
|
|
303
354
|
beforeEach(() => {
|
|
304
355
|
clearConversations();
|
|
305
|
-
seedProfiles({ fast: { model: "model-a" } });
|
|
356
|
+
seedProfiles({ fast: { provider: "anthropic", model: "model-a" } });
|
|
306
357
|
});
|
|
307
358
|
|
|
308
359
|
test("POST with ttlSeconds=600 → same shape as PUT: sessionId UUID, expiresAt, ttlSeconds=600", async () => {
|
|
@@ -334,7 +385,7 @@ describe("POST /v1/conversations/inference-profile-session (inference_profile_op
|
|
|
334
385
|
describe("GET /v1/conversations/inference-profile-sessions (inference_profile_list)", () => {
|
|
335
386
|
beforeEach(() => {
|
|
336
387
|
clearConversations();
|
|
337
|
-
seedProfiles({ fast: { model: "model-a" } });
|
|
388
|
+
seedProfiles({ fast: { provider: "anthropic", model: "model-a" } });
|
|
338
389
|
});
|
|
339
390
|
|
|
340
391
|
test("GET inference-profile-sessions → returns sessions array with remainingSeconds", async () => {
|
|
@@ -369,7 +420,7 @@ describe("GET /v1/conversations/inference-profile-sessions (inference_profile_li
|
|
|
369
420
|
describe("POST /v1/conversations/inference-profile-session/close (inference_profile_close)", () => {
|
|
370
421
|
beforeEach(() => {
|
|
371
422
|
clearConversations();
|
|
372
|
-
seedProfiles({ fast: { model: "model-a" } });
|
|
423
|
+
seedProfiles({ fast: { provider: "anthropic", model: "model-a" } });
|
|
373
424
|
});
|
|
374
425
|
|
|
375
426
|
test("POST inference_profile_close → { noop: false, closed: { profile, sessionId } } after an open", async () => {
|
|
@@ -25,22 +25,18 @@ import {
|
|
|
25
25
|
DEFAULT_PROVIDER_CHOICES,
|
|
26
26
|
DefaultProviderSchema,
|
|
27
27
|
} from "../../config/schemas/llm.js";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
computeConnectionAvailability,
|
|
30
|
+
CONNECTION_AVAILABILITY_STATUSES,
|
|
31
|
+
} from "../../providers/inference/connection-availability.js";
|
|
29
32
|
import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
|
|
30
33
|
import { BadRequestError } from "./errors.js";
|
|
31
34
|
import type { RouteDefinition, RouteHandlerArgs } from "./types.js";
|
|
32
35
|
|
|
33
36
|
const availabilitySchema = z.object({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"missing_connection",
|
|
38
|
-
"missing_credential",
|
|
39
|
-
"provider_mismatch",
|
|
40
|
-
"unsupported_auth",
|
|
41
|
-
"vellum_unauthenticated",
|
|
42
|
-
"unknown",
|
|
43
|
-
]),
|
|
37
|
+
// `missing_default` is this route's own verdict (no default provider is
|
|
38
|
+
// configured at all), so it extends the shared set rather than living in it.
|
|
39
|
+
status: z.enum([...CONNECTION_AVAILABILITY_STATUSES, "missing_default"]),
|
|
44
40
|
/** Present on every non-`ok` status: names the broken thing and the fix. */
|
|
45
41
|
message: z.string().optional(),
|
|
46
42
|
});
|
|
@@ -100,6 +100,12 @@ async function repairGuidance(
|
|
|
100
100
|
repair: ProfileRepairHint,
|
|
101
101
|
status: ConnectionAvailability["status"],
|
|
102
102
|
): Promise<string> {
|
|
103
|
+
// An incomplete profile has no connection to diagnose: the repair is
|
|
104
|
+
// finishing the profile itself. Its `provider` may also be absent, which
|
|
105
|
+
// the branches below would interpolate as the string "undefined".
|
|
106
|
+
if (status === "incomplete") {
|
|
107
|
+
return "Set both a provider and a model on the profile in Settings → Models & Services, then retry.";
|
|
108
|
+
}
|
|
103
109
|
if (ROUTING_IDENTITY_PROVIDERS.has(provider)) {
|
|
104
110
|
return `Sign in to the "${provider}" route in Settings → Models & Services, or pick a profile backed by a provider API key, then retry.`;
|
|
105
111
|
}
|
|
@@ -38,6 +38,7 @@ import { ROUTING_IDENTITY_PROVIDERS } from "../../providers/inference/auth.js";
|
|
|
38
38
|
import type { ConnectionAvailability } from "../../providers/inference/connection-availability.js";
|
|
39
39
|
import {
|
|
40
40
|
computeProfileAvailability,
|
|
41
|
+
CONNECTION_AVAILABILITY_STATUSES,
|
|
41
42
|
isUnavailable,
|
|
42
43
|
} from "../../providers/inference/connection-availability.js";
|
|
43
44
|
import { getConnection } from "../../providers/inference/connections.js";
|
|
@@ -73,15 +74,7 @@ const RESERVED_PROFILE_NAMES = new Set([
|
|
|
73
74
|
|
|
74
75
|
const availabilitySchema = z
|
|
75
76
|
.object({
|
|
76
|
-
status: z.enum(
|
|
77
|
-
"ok",
|
|
78
|
-
"missing_connection",
|
|
79
|
-
"missing_credential",
|
|
80
|
-
"provider_mismatch",
|
|
81
|
-
"unsupported_auth",
|
|
82
|
-
"vellum_unauthenticated",
|
|
83
|
-
"unknown",
|
|
84
|
-
]),
|
|
77
|
+
status: z.enum(CONNECTION_AVAILABILITY_STATUSES),
|
|
85
78
|
message: z.string().optional(),
|
|
86
79
|
})
|
|
87
80
|
.meta({ id: "ProfileConnectionAvailability" });
|
|
@@ -4,6 +4,7 @@ import { join } from "node:path";
|
|
|
4
4
|
import type { SkillSource } from "../../config/skills.js";
|
|
5
5
|
import { loadSkillCatalog } from "../../config/skills.js";
|
|
6
6
|
import { refreshSkillCapabilityMemories } from "../../daemon/skill-memory-refresh.js";
|
|
7
|
+
import { emitNotificationSignal } from "../../notifications/emit-signal.js";
|
|
7
8
|
import { getConversation } from "../../persistence/conversation-crud.js";
|
|
8
9
|
import { upsertSkillCardInsertJob } from "../../persistence/jobs-store.js";
|
|
9
10
|
import { MEMORY_RETROSPECTIVE_ORIGIN } from "../../plugins/defaults/memory/memory-retrospective-constants.js";
|
|
@@ -66,6 +67,72 @@ function normalizeOptionalStringArray(
|
|
|
66
67
|
return { value: normalized.length > 0 ? normalized : undefined };
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Tell the user that a background pass changed a skill they already have.
|
|
72
|
+
*
|
|
73
|
+
* A newly authored skill announces itself in the conversation through the
|
|
74
|
+
* `skill_card` surface; an update announces itself here instead. The pass
|
|
75
|
+
* runs in a background fork and rewrites the body of a skill the user may be
|
|
76
|
+
* relying on, and `createManagedSkill` writes through an atomic rename
|
|
77
|
+
* keeping no prior version, so the notification pipeline is what puts the
|
|
78
|
+
* change in the background feed alongside the other unattended work (sweeps,
|
|
79
|
+
* scheduled jobs, heartbeat), where a user already looks to see what the
|
|
80
|
+
* assistant did on its own.
|
|
81
|
+
*
|
|
82
|
+
* `sourceContextId` is a conversation id so the feed item's "Go to Convo"
|
|
83
|
+
* target resolves (see `home-feed-side-effect.ts`, which looks it up via
|
|
84
|
+
* `getConversation`): the source conversation when lineage resolved, else the
|
|
85
|
+
* run's own conversation. Deduped per skill per day, so a pass that refines
|
|
86
|
+
* the same skill repeatedly cannot flood the feed. Best-effort and
|
|
87
|
+
* non-blocking: the skill is already written, and a notification failure must
|
|
88
|
+
* never turn that into a tool error.
|
|
89
|
+
*/
|
|
90
|
+
function notifyBackgroundSkillUpdate(args: {
|
|
91
|
+
skillId: string;
|
|
92
|
+
name: string;
|
|
93
|
+
conversationId: string;
|
|
94
|
+
}): void {
|
|
95
|
+
const day = new Date().toISOString().slice(0, 10);
|
|
96
|
+
void emitNotificationSignal({
|
|
97
|
+
// This emit is a tool executor's, not the scheduler's. The channel is
|
|
98
|
+
// provenance the pipeline reads: `home-feed-side-effect` derives
|
|
99
|
+
// `fromAssistant` from it, so labelling this "scheduler" would drop the
|
|
100
|
+
// item from the feed's assistant-initiated filter despite being exactly
|
|
101
|
+
// that.
|
|
102
|
+
sourceChannel: "assistant_tool",
|
|
103
|
+
sourceContextId: args.conversationId,
|
|
104
|
+
sourceEventName: "activity.complete",
|
|
105
|
+
dedupeKey: `skill-updated:${args.skillId}:${day}`,
|
|
106
|
+
contextPayload: {
|
|
107
|
+
// `summary` feeds the copy composer; `title`/`body` are the home feed's
|
|
108
|
+
// fallback when no channel copy was rendered. Without them a fully
|
|
109
|
+
// suppressed delivery (the intended shape for this signal: low urgency,
|
|
110
|
+
// background, no interruption) leaves the feed writer with no summary
|
|
111
|
+
// and it skips the item entirely, so the quiet case would surface
|
|
112
|
+
// nothing at all.
|
|
113
|
+
summary: `Updated the skill "${args.name}" from something learned in an earlier conversation.`,
|
|
114
|
+
// Named, not just "Skill updated": the feed sits several rows deep and
|
|
115
|
+
// a generic title is unscannable next to entries that name their
|
|
116
|
+
// subject (`Background job failed: memory.v2.sweep`). The word "Skill"
|
|
117
|
+
// stays because a bare skill name does not always read as one.
|
|
118
|
+
title: `Skill updated: ${args.name}`,
|
|
119
|
+
body: `Updated the skill "${args.name}" from something learned in an earlier conversation.`,
|
|
120
|
+
skillId: args.skillId,
|
|
121
|
+
},
|
|
122
|
+
attentionHints: {
|
|
123
|
+
requiresAction: false,
|
|
124
|
+
urgency: "low",
|
|
125
|
+
isAsyncBackground: true,
|
|
126
|
+
visibleInSourceNow: false,
|
|
127
|
+
},
|
|
128
|
+
}).catch((err: unknown) => {
|
|
129
|
+
log.warn(
|
|
130
|
+
{ err, skillId: args.skillId },
|
|
131
|
+
"skill update notification failed; the skill write stands",
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
69
136
|
/**
|
|
70
137
|
* Core execution logic for scaffold_managed_skill.
|
|
71
138
|
* Exported so bundled-skill executors and tests can call it directly.
|
|
@@ -355,6 +422,21 @@ export async function executeScaffoldManagedSkill(
|
|
|
355
422
|
}
|
|
356
423
|
}
|
|
357
424
|
|
|
425
|
+
// A background pass changed a skill that already existed. Creates announce
|
|
426
|
+
// themselves through the skill card below; updates announce themselves in
|
|
427
|
+
// the background activity feed. Covers an explicit `overwrite: true`
|
|
428
|
+
// refinement as well as any other background write onto a pre-existing
|
|
429
|
+
// skill.
|
|
430
|
+
const notifyConversationId =
|
|
431
|
+
sourceConversationId ?? retrospectiveConversationId;
|
|
432
|
+
if (fromRetrospective && managedSkillExistedBefore && notifyConversationId) {
|
|
433
|
+
notifyBackgroundSkillUpdate({
|
|
434
|
+
skillId: id,
|
|
435
|
+
name: normalizedName,
|
|
436
|
+
conversationId: notifyConversationId,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
358
440
|
// Surface a genuine retrospective CREATE to the user as a skill card on the
|
|
359
441
|
// source conversation, via the durable `skill_card_insert` delivery job
|
|
360
442
|
// (memory-retrospective-skill-card.ts). The creation site is the one place
|