@vellumai/assistant 0.9.0-dev.202606181858.5b26a8a → 0.9.0-dev.202606181950.a0151ae
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 +94 -0
- package/package.json +1 -1
- package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +3 -4
- package/src/__tests__/credential-prompt-route.test.ts +1 -0
- package/src/cli/commands/{__tests__ → memory/__tests__}/memory-v2-compare-render.test.ts +1 -1
- package/src/cli/commands/{__tests__ → memory/__tests__}/memory-v2.test.ts +8 -7
- package/src/cli/commands/{__tests__ → memory/__tests__}/memory-v3.test.ts +4 -3
- package/src/cli/commands/memory/index.ts +30 -0
- package/src/cli/commands/{memory-v2-compare-render.ts → memory/memory-v2-compare-render.ts} +1 -1
- package/src/cli/commands/{memory-v2.ts → memory/memory-v2.ts} +6 -15
- package/src/cli/commands/{memory-v3.ts → memory/memory-v3.ts} +6 -13
- package/src/cli/program.ts +2 -4
- package/src/config/schemas/channels.ts +11 -0
- package/src/daemon/handlers/config-slack-channel.ts +20 -0
- package/src/memory/conversation-key-store.ts +17 -2
- package/src/plugins/defaults/advisor/__tests__/agent-loop-integration.test.ts +4 -3
- package/src/plugins/defaults/advisor/__tests__/consult.test.ts +6 -3
- package/src/plugins/defaults/advisor/config.ts +3 -7
- package/src/plugins/defaults/advisor/consult.ts +4 -6
- package/src/plugins/defaults/advisor/steering.ts +21 -5
- package/src/plugins/defaults/advisor/tools/advisor.ts +7 -4
- package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +67 -0
- package/src/runtime/routes/conversation-management-routes.ts +22 -1
- package/src/runtime/routes/conversation-routes.ts +12 -0
- package/src/runtime/routes/integrations/slack/__tests__/channel.test.ts +8 -0
- package/src/runtime/routes/integrations/slack/channel.ts +36 -0
package/openapi.yaml
CHANGED
|
@@ -6152,6 +6152,12 @@ paths:
|
|
|
6152
6152
|
description: Only standard conversations are created by this endpoint
|
|
6153
6153
|
type: string
|
|
6154
6154
|
const: standard
|
|
6155
|
+
title:
|
|
6156
|
+
description:
|
|
6157
|
+
Explicit title for the conversation. When provided on creation, it is persisted as a user-set title (never
|
|
6158
|
+
overwritten by the auto-titler). Used by flows that mint a conversation up-front and don't want an
|
|
6159
|
+
auto-generated title.
|
|
6160
|
+
type: string
|
|
6155
6161
|
responses:
|
|
6156
6162
|
"200":
|
|
6157
6163
|
description: Successful response
|
|
@@ -13839,6 +13845,11 @@ paths:
|
|
|
13839
13845
|
type: string
|
|
13840
13846
|
botUsername:
|
|
13841
13847
|
type: string
|
|
13848
|
+
threadMode:
|
|
13849
|
+
type: string
|
|
13850
|
+
enum:
|
|
13851
|
+
- mention_only
|
|
13852
|
+
- mention_then_thread
|
|
13842
13853
|
error:
|
|
13843
13854
|
type: string
|
|
13844
13855
|
warning:
|
|
@@ -13849,6 +13860,7 @@ paths:
|
|
|
13849
13860
|
- hasAppToken
|
|
13850
13861
|
- hasUserToken
|
|
13851
13862
|
- connected
|
|
13863
|
+
- threadMode
|
|
13852
13864
|
additionalProperties: false
|
|
13853
13865
|
get:
|
|
13854
13866
|
operationId: integrations_slack_channel_config_get
|
|
@@ -13884,6 +13896,75 @@ paths:
|
|
|
13884
13896
|
type: string
|
|
13885
13897
|
botUsername:
|
|
13886
13898
|
type: string
|
|
13899
|
+
threadMode:
|
|
13900
|
+
type: string
|
|
13901
|
+
enum:
|
|
13902
|
+
- mention_only
|
|
13903
|
+
- mention_then_thread
|
|
13904
|
+
error:
|
|
13905
|
+
type: string
|
|
13906
|
+
warning:
|
|
13907
|
+
type: string
|
|
13908
|
+
required:
|
|
13909
|
+
- success
|
|
13910
|
+
- hasBotToken
|
|
13911
|
+
- hasAppToken
|
|
13912
|
+
- hasUserToken
|
|
13913
|
+
- connected
|
|
13914
|
+
- threadMode
|
|
13915
|
+
additionalProperties: false
|
|
13916
|
+
patch:
|
|
13917
|
+
operationId: integrations_slack_channel_config_patch
|
|
13918
|
+
summary: Update Slack channel settings
|
|
13919
|
+
description: Update Slack channel behavior settings (e.g. thread mode).
|
|
13920
|
+
tags:
|
|
13921
|
+
- integrations
|
|
13922
|
+
requestBody:
|
|
13923
|
+
required: true
|
|
13924
|
+
content:
|
|
13925
|
+
application/json:
|
|
13926
|
+
schema:
|
|
13927
|
+
type: object
|
|
13928
|
+
properties:
|
|
13929
|
+
threadMode:
|
|
13930
|
+
type: string
|
|
13931
|
+
enum:
|
|
13932
|
+
- mention_only
|
|
13933
|
+
- mention_then_thread
|
|
13934
|
+
description: Controls whether the bot follows threads after an initial @mention
|
|
13935
|
+
responses:
|
|
13936
|
+
"200":
|
|
13937
|
+
description: Successful response
|
|
13938
|
+
content:
|
|
13939
|
+
application/json:
|
|
13940
|
+
schema:
|
|
13941
|
+
type: object
|
|
13942
|
+
properties:
|
|
13943
|
+
success:
|
|
13944
|
+
type: boolean
|
|
13945
|
+
hasBotToken:
|
|
13946
|
+
type: boolean
|
|
13947
|
+
hasAppToken:
|
|
13948
|
+
type: boolean
|
|
13949
|
+
hasUserToken:
|
|
13950
|
+
type: boolean
|
|
13951
|
+
connected:
|
|
13952
|
+
type: boolean
|
|
13953
|
+
teamId:
|
|
13954
|
+
type: string
|
|
13955
|
+
teamName:
|
|
13956
|
+
type: string
|
|
13957
|
+
teamUrl:
|
|
13958
|
+
type: string
|
|
13959
|
+
botUserId:
|
|
13960
|
+
type: string
|
|
13961
|
+
botUsername:
|
|
13962
|
+
type: string
|
|
13963
|
+
threadMode:
|
|
13964
|
+
type: string
|
|
13965
|
+
enum:
|
|
13966
|
+
- mention_only
|
|
13967
|
+
- mention_then_thread
|
|
13887
13968
|
error:
|
|
13888
13969
|
type: string
|
|
13889
13970
|
warning:
|
|
@@ -13894,6 +13975,7 @@ paths:
|
|
|
13894
13975
|
- hasAppToken
|
|
13895
13976
|
- hasUserToken
|
|
13896
13977
|
- connected
|
|
13978
|
+
- threadMode
|
|
13897
13979
|
additionalProperties: false
|
|
13898
13980
|
post:
|
|
13899
13981
|
operationId: integrations_slack_channel_config_post
|
|
@@ -13945,6 +14027,11 @@ paths:
|
|
|
13945
14027
|
type: string
|
|
13946
14028
|
botUsername:
|
|
13947
14029
|
type: string
|
|
14030
|
+
threadMode:
|
|
14031
|
+
type: string
|
|
14032
|
+
enum:
|
|
14033
|
+
- mention_only
|
|
14034
|
+
- mention_then_thread
|
|
13948
14035
|
error:
|
|
13949
14036
|
type: string
|
|
13950
14037
|
warning:
|
|
@@ -13955,6 +14042,7 @@ paths:
|
|
|
13955
14042
|
- hasAppToken
|
|
13956
14043
|
- hasUserToken
|
|
13957
14044
|
- connected
|
|
14045
|
+
- threadMode
|
|
13958
14046
|
additionalProperties: false
|
|
13959
14047
|
/v1/integrations/telegram/commands:
|
|
13960
14048
|
post:
|
|
@@ -17000,6 +17088,12 @@ paths:
|
|
|
17000
17088
|
type: array
|
|
17001
17089
|
items:
|
|
17002
17090
|
type: string
|
|
17091
|
+
title:
|
|
17092
|
+
description:
|
|
17093
|
+
Explicit title for the conversation minted on this first message. Persisted as a user-set title (never
|
|
17094
|
+
overwritten by the auto-titler). Used by onboarding flows that mint a conversation behind the
|
|
17095
|
+
scenes.
|
|
17096
|
+
type: string
|
|
17003
17097
|
required:
|
|
17004
17098
|
- tools
|
|
17005
17099
|
- tasks
|
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@ mock.module("../memory/v2/skill-store.js", () => ({
|
|
|
52
52
|
// ---------------------------------------------------------------------------
|
|
53
53
|
|
|
54
54
|
const { registerMemoryV2Command } =
|
|
55
|
-
await import("../cli/commands/memory-v2.js");
|
|
55
|
+
await import("../cli/commands/memory/memory-v2.js");
|
|
56
56
|
const { ROUTES: memoryV2Routes, MEMORY_V2_DISABLED_CODE } =
|
|
57
57
|
await import("../runtime/routes/memory-v2-routes.js");
|
|
58
58
|
const { RouteError } = await import("../runtime/routes/errors.js");
|
|
@@ -68,9 +68,8 @@ function buildProgram(): Command {
|
|
|
68
68
|
writeErr: () => {},
|
|
69
69
|
writeOut: () => {},
|
|
70
70
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
registerMemoryV2Command(program);
|
|
71
|
+
const memory = program.command("memory");
|
|
72
|
+
registerMemoryV2Command(memory);
|
|
74
73
|
return program;
|
|
75
74
|
}
|
|
76
75
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
|
|
3
|
-
import type { ComparisonReport } from "
|
|
3
|
+
import type { ComparisonReport } from "../../../../memory/v2/harness/runner.js";
|
|
4
4
|
import {
|
|
5
5
|
renderComparisonReport,
|
|
6
6
|
renderTurnTrace,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Validates:
|
|
5
5
|
* - Subcommand registration (reembed, reembed-skills, activation, validate,
|
|
6
|
-
* ema, simulate) under `memory v2`.
|
|
7
|
-
*
|
|
6
|
+
* ema, simulate) under `memory v2`. v1 had its own subcommands but those
|
|
7
|
+
* were retired.
|
|
8
8
|
* - Each mutating subcommand maps to the right `memory_v2_backfill` op.
|
|
9
9
|
* - `validate` calls `memory_v2_validate` and pretty-prints the report.
|
|
10
10
|
* - `reembed-skills` calls `memory_v2_reembed_skills` synchronously.
|
|
@@ -40,7 +40,7 @@ let logOutput: string[] = [];
|
|
|
40
40
|
// Mocks
|
|
41
41
|
// ---------------------------------------------------------------------------
|
|
42
42
|
|
|
43
|
-
mock.module("
|
|
43
|
+
mock.module("../../../../ipc/cli-client.js", () => ({
|
|
44
44
|
cliIpcCall: async (method: string, params?: any) => {
|
|
45
45
|
lastIpcCall = { method, params };
|
|
46
46
|
return mockIpcResult;
|
|
@@ -56,7 +56,7 @@ const fakeLogger = {
|
|
|
56
56
|
error: capture,
|
|
57
57
|
debug: () => {},
|
|
58
58
|
};
|
|
59
|
-
mock.module("
|
|
59
|
+
mock.module("../../../../util/logger.js", () => ({
|
|
60
60
|
getLogger: () => fakeLogger,
|
|
61
61
|
getCliLogger: () => fakeLogger,
|
|
62
62
|
}));
|
|
@@ -72,8 +72,8 @@ const { registerMemoryV2Command } = await import("../memory-v2.js");
|
|
|
72
72
|
// ---------------------------------------------------------------------------
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* Build a fresh program and register the v2 subgroup
|
|
76
|
-
*
|
|
75
|
+
* Build a fresh program with a `memory` parent and register the v2 subgroup
|
|
76
|
+
* under it — mirroring how `registerMemoryCommand` wires the namespace.
|
|
77
77
|
*/
|
|
78
78
|
function buildProgram(): Command {
|
|
79
79
|
const program = new Command();
|
|
@@ -82,7 +82,8 @@ function buildProgram(): Command {
|
|
|
82
82
|
writeErr: () => {},
|
|
83
83
|
writeOut: () => {},
|
|
84
84
|
});
|
|
85
|
-
|
|
85
|
+
const memory = program.command("memory");
|
|
86
|
+
registerMemoryV2Command(memory);
|
|
86
87
|
return program;
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -40,7 +40,7 @@ let logOutput: string[] = [];
|
|
|
40
40
|
// Mocks
|
|
41
41
|
// ---------------------------------------------------------------------------
|
|
42
42
|
|
|
43
|
-
mock.module("
|
|
43
|
+
mock.module("../../../../ipc/cli-client.js", () => ({
|
|
44
44
|
cliIpcCall: async (
|
|
45
45
|
method: string,
|
|
46
46
|
params?: any,
|
|
@@ -60,7 +60,7 @@ const fakeLogger = {
|
|
|
60
60
|
error: capture,
|
|
61
61
|
debug: () => {},
|
|
62
62
|
};
|
|
63
|
-
mock.module("
|
|
63
|
+
mock.module("../../../../util/logger.js", () => ({
|
|
64
64
|
getLogger: () => fakeLogger,
|
|
65
65
|
getCliLogger: () => fakeLogger,
|
|
66
66
|
}));
|
|
@@ -82,7 +82,8 @@ function buildProgram(): Command {
|
|
|
82
82
|
writeErr: () => {},
|
|
83
83
|
writeOut: () => {},
|
|
84
84
|
});
|
|
85
|
-
|
|
85
|
+
const memory = program.command("memory");
|
|
86
|
+
registerMemoryV3Command(memory);
|
|
86
87
|
return program;
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
|
|
3
|
+
import { registerCommand } from "../../lib/register-command.js";
|
|
4
|
+
import { registerMemoryV2Command } from "./memory-v2.js";
|
|
5
|
+
import { registerMemoryV3Command } from "./memory-v3.js";
|
|
6
|
+
|
|
7
|
+
export function registerMemoryCommand(program: Command): void {
|
|
8
|
+
registerCommand(program, {
|
|
9
|
+
name: "memory",
|
|
10
|
+
transport: "ipc",
|
|
11
|
+
description: "Inspect and maintain the assistant memory subsystem",
|
|
12
|
+
build: (memory) => {
|
|
13
|
+
memory.addHelpText(
|
|
14
|
+
"after",
|
|
15
|
+
`
|
|
16
|
+
The memory subsystem retrieves concept pages two ways: the v2 concept-page
|
|
17
|
+
activation model (prose pages with directed edges) and the v3 section-lane
|
|
18
|
+
model (section-grain lanes cached as live shadow state). Each subgroup exposes
|
|
19
|
+
operator-facing maintenance verbs — reindexing, backfills, validation, and evals.
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
$ assistant memory v2 validate
|
|
23
|
+
$ assistant memory v3 rebuild-index`,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
registerMemoryV2Command(memory);
|
|
27
|
+
registerMemoryV3Command(memory);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* type-only imports but forbids pulling in daemon runtime modules.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { ComparisonReport } from "
|
|
12
|
+
import type { ComparisonReport } from "../../../memory/v2/harness/runner.js";
|
|
13
13
|
|
|
14
14
|
function sortedKs(report: ComparisonReport): number[] {
|
|
15
15
|
return [...report.ks].sort((a, b) => a - b);
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
import type { Command } from "commander";
|
|
20
20
|
|
|
21
|
-
import { cliIpcCall } from "
|
|
22
|
-
import type { ComparisonReport } from "
|
|
21
|
+
import { cliIpcCall } from "../../../ipc/cli-client.js";
|
|
22
|
+
import type { ComparisonReport } from "../../../memory/v2/harness/runner.js";
|
|
23
23
|
import type {
|
|
24
24
|
MemoryV2BackfillOp,
|
|
25
25
|
MemoryV2BackfillResult,
|
|
@@ -27,9 +27,9 @@ import type {
|
|
|
27
27
|
MemoryV2ReembedSkillsResult,
|
|
28
28
|
MemoryV2SimulateRouterResult,
|
|
29
29
|
MemoryV2ValidateResult,
|
|
30
|
-
} from "
|
|
31
|
-
import { registerCommand } from "
|
|
32
|
-
import { log } from "
|
|
30
|
+
} from "../../../runtime/routes/memory-v2-routes.js";
|
|
31
|
+
import { registerCommand } from "../../lib/register-command.js";
|
|
32
|
+
import { log } from "../../logger.js";
|
|
33
33
|
import {
|
|
34
34
|
renderComparisonReport,
|
|
35
35
|
renderTurnTrace,
|
|
@@ -63,16 +63,7 @@ async function runBackfillOp(op: MemoryV2BackfillOp): Promise<void> {
|
|
|
63
63
|
// Registration
|
|
64
64
|
// ---------------------------------------------------------------------------
|
|
65
65
|
|
|
66
|
-
export function registerMemoryV2Command(
|
|
67
|
-
// Reuse an existing `memory` parent if some other registrar attached to it
|
|
68
|
-
// first; otherwise create one. This keeps the registration order between
|
|
69
|
-
// sibling memory registrars unconstrained.
|
|
70
|
-
const memory =
|
|
71
|
-
program.commands.find((c) => c.name() === "memory") ??
|
|
72
|
-
program
|
|
73
|
-
.command("memory")
|
|
74
|
-
.description("Manage the v2 memory subsystem (concept-page model)");
|
|
75
|
-
|
|
66
|
+
export function registerMemoryV2Command(memory: Command): void {
|
|
76
67
|
registerCommand(memory, {
|
|
77
68
|
name: "v2",
|
|
78
69
|
transport: "ipc",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
import type { Command } from "commander";
|
|
19
19
|
|
|
20
|
-
import { cliIpcCall } from "
|
|
21
|
-
import type { MemoryEvalRunResult } from "
|
|
20
|
+
import { cliIpcCall } from "../../../ipc/cli-client.js";
|
|
21
|
+
import type { MemoryEvalRunResult } from "../../../runtime/routes/memory-eval-routes.js";
|
|
22
22
|
import type {
|
|
23
23
|
MemoryV3BackfillSectionsResult,
|
|
24
24
|
MemoryV3RebuildIndexResult,
|
|
25
|
-
} from "
|
|
26
|
-
import { registerCommand } from "
|
|
27
|
-
import { log } from "
|
|
25
|
+
} from "../../../runtime/routes/memory-v3-routes.js";
|
|
26
|
+
import { registerCommand } from "../../lib/register-command.js";
|
|
27
|
+
import { log } from "../../logger.js";
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* IPC timeout for `backfill-sections`. The one-time full-corpus section embed
|
|
@@ -42,14 +42,7 @@ const BACKFILL_IPC_TIMEOUT_MS = 30 * 60 * 1000;
|
|
|
42
42
|
*/
|
|
43
43
|
const EVAL_IPC_TIMEOUT_MS = 30 * 60 * 1000;
|
|
44
44
|
|
|
45
|
-
export function registerMemoryV3Command(
|
|
46
|
-
// Reuse an existing `memory` parent if some other registrar attached to it
|
|
47
|
-
// first; otherwise create one. This keeps the registration order between
|
|
48
|
-
// sibling memory registrars unconstrained.
|
|
49
|
-
const memory =
|
|
50
|
-
program.commands.find((c) => c.name() === "memory") ??
|
|
51
|
-
program.command("memory").description("Manage the memory subsystem");
|
|
52
|
-
|
|
45
|
+
export function registerMemoryV3Command(memory: Command): void {
|
|
53
46
|
registerCommand(memory, {
|
|
54
47
|
name: "v3",
|
|
55
48
|
transport: "ipc",
|
package/src/cli/program.ts
CHANGED
|
@@ -34,8 +34,7 @@ import { registerImageGenerationCommand } from "./commands/image-generation.js";
|
|
|
34
34
|
import { registerInferenceCommand } from "./commands/inference.js";
|
|
35
35
|
import { registerKeysCommand } from "./commands/keys.js";
|
|
36
36
|
import { registerMcpCommand } from "./commands/mcp.js";
|
|
37
|
-
import {
|
|
38
|
-
import { registerMemoryV3Command } from "./commands/memory-v3.js";
|
|
37
|
+
import { registerMemoryCommand } from "./commands/memory/index.js";
|
|
39
38
|
import { registerNotificationsCommand } from "./commands/notifications.js";
|
|
40
39
|
import { registerOAuthCommand } from "./commands/oauth/index.js";
|
|
41
40
|
import { registerPendingCommand } from "./commands/pending.js";
|
|
@@ -130,8 +129,7 @@ Examples:
|
|
|
130
129
|
registerInferenceCommand(program);
|
|
131
130
|
registerKeysCommand(program);
|
|
132
131
|
registerMcpCommand(program);
|
|
133
|
-
|
|
134
|
-
registerMemoryV3Command(program);
|
|
132
|
+
registerMemoryCommand(program);
|
|
135
133
|
registerNotificationsCommand(program);
|
|
136
134
|
registerOAuthCommand(program);
|
|
137
135
|
registerPendingCommand(program);
|
|
@@ -136,5 +136,16 @@ export const SlackConfigSchema = z
|
|
|
136
136
|
.string({ error: "slack.botUsername must be a string" })
|
|
137
137
|
.default("")
|
|
138
138
|
.describe("Slack bot display name"),
|
|
139
|
+
threadMode: z
|
|
140
|
+
.enum(["mention_only", "mention_then_thread"], {
|
|
141
|
+
error:
|
|
142
|
+
"slack.threadMode must be 'mention_only' or 'mention_then_thread'",
|
|
143
|
+
})
|
|
144
|
+
.default("mention_then_thread")
|
|
145
|
+
.describe(
|
|
146
|
+
"Controls whether the bot follows threads after an initial @mention. " +
|
|
147
|
+
"'mention_only' requires every message to @-mention the bot. " +
|
|
148
|
+
"'mention_then_thread' auto-follows the thread after the first mention.",
|
|
149
|
+
),
|
|
139
150
|
})
|
|
140
151
|
.describe("Slack channel configuration");
|
|
@@ -28,6 +28,9 @@ import { log as _log } from "./shared.js";
|
|
|
28
28
|
|
|
29
29
|
// -- Result type --
|
|
30
30
|
|
|
31
|
+
export const SlackThreadMode = z.enum(["mention_only", "mention_then_thread"]);
|
|
32
|
+
export type SlackThreadMode = z.infer<typeof SlackThreadMode>;
|
|
33
|
+
|
|
31
34
|
export const SlackChannelConfigResultSchema = z.object({
|
|
32
35
|
success: z.boolean(),
|
|
33
36
|
hasBotToken: z.boolean(),
|
|
@@ -39,6 +42,7 @@ export const SlackChannelConfigResultSchema = z.object({
|
|
|
39
42
|
teamUrl: z.string().optional(),
|
|
40
43
|
botUserId: z.string().optional(),
|
|
41
44
|
botUsername: z.string().optional(),
|
|
45
|
+
threadMode: SlackThreadMode,
|
|
42
46
|
error: z.string().optional(),
|
|
43
47
|
warning: z.string().optional(),
|
|
44
48
|
});
|
|
@@ -129,6 +133,8 @@ export async function getSlackChannelConfig(): Promise<SlackChannelConfigResult>
|
|
|
129
133
|
ensureUserTokenInjectionTemplates();
|
|
130
134
|
}
|
|
131
135
|
|
|
136
|
+
const { threadMode } = getConfig().slack;
|
|
137
|
+
|
|
132
138
|
return {
|
|
133
139
|
success: true,
|
|
134
140
|
hasBotToken,
|
|
@@ -140,6 +146,7 @@ export async function getSlackChannelConfig(): Promise<SlackChannelConfigResult>
|
|
|
140
146
|
...(teamUrl ? { teamUrl } : {}),
|
|
141
147
|
...(botUserId ? { botUserId } : {}),
|
|
142
148
|
...(botUsername ? { botUsername } : {}),
|
|
149
|
+
threadMode,
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
152
|
|
|
@@ -166,6 +173,7 @@ async function currentErrorSnapshot(
|
|
|
166
173
|
!!(errConn && errConn.status === "active") &&
|
|
167
174
|
errHasBotToken &&
|
|
168
175
|
errHasAppToken,
|
|
176
|
+
threadMode: getConfig().slack.threadMode,
|
|
169
177
|
error,
|
|
170
178
|
};
|
|
171
179
|
}
|
|
@@ -429,6 +437,7 @@ export async function setSlackChannelConfig(
|
|
|
429
437
|
hasUserToken,
|
|
430
438
|
connected: hasBotToken && hasAppToken,
|
|
431
439
|
...metadata,
|
|
440
|
+
threadMode: getConfig().slack.threadMode,
|
|
432
441
|
...(warning ? { warning } : {}),
|
|
433
442
|
};
|
|
434
443
|
}
|
|
@@ -466,6 +475,7 @@ export async function clearSlackUserToken(): Promise<SlackChannelConfigResult> {
|
|
|
466
475
|
hasUserToken,
|
|
467
476
|
connected:
|
|
468
477
|
!!(conn && conn.status === "active") && hasBotToken && hasAppToken,
|
|
478
|
+
threadMode: getConfig().slack.threadMode,
|
|
469
479
|
error:
|
|
470
480
|
result === "not-found"
|
|
471
481
|
? "Slack user token not found in secure storage"
|
|
@@ -497,6 +507,7 @@ export async function clearSlackUserToken(): Promise<SlackChannelConfigResult> {
|
|
|
497
507
|
...(teamUrl ? { teamUrl } : {}),
|
|
498
508
|
...(botUserId ? { botUserId } : {}),
|
|
499
509
|
...(botUsername ? { botUsername } : {}),
|
|
510
|
+
threadMode: getConfig().slack.threadMode,
|
|
500
511
|
};
|
|
501
512
|
}
|
|
502
513
|
|
|
@@ -530,6 +541,7 @@ export async function clearSlackChannelConfig(): Promise<SlackChannelConfigResul
|
|
|
530
541
|
hasUserToken,
|
|
531
542
|
connected:
|
|
532
543
|
!!(conn && conn.status === "active") && hasBotToken && hasAppToken,
|
|
544
|
+
threadMode: getConfig().slack.threadMode,
|
|
533
545
|
error: "Failed to delete Slack channel credentials from secure storage",
|
|
534
546
|
};
|
|
535
547
|
}
|
|
@@ -556,5 +568,13 @@ export async function clearSlackChannelConfig(): Promise<SlackChannelConfigResul
|
|
|
556
568
|
hasAppToken: false,
|
|
557
569
|
hasUserToken: false,
|
|
558
570
|
connected: false,
|
|
571
|
+
threadMode: "mention_only",
|
|
559
572
|
};
|
|
560
573
|
}
|
|
574
|
+
|
|
575
|
+
export function patchSlackChannelConfig(threadMode: SlackThreadMode): void {
|
|
576
|
+
const raw = loadRawConfig();
|
|
577
|
+
setNestedValue(raw, "slack.threadMode", threadMode);
|
|
578
|
+
saveRawConfig(raw);
|
|
579
|
+
invalidateConfigCache();
|
|
580
|
+
}
|
|
@@ -135,7 +135,16 @@ export function resolveConversationId(idOrKey: string): string | null {
|
|
|
135
135
|
*/
|
|
136
136
|
export function getOrCreateConversation(
|
|
137
137
|
conversationKey: string,
|
|
138
|
-
opts?: {
|
|
138
|
+
opts?: {
|
|
139
|
+
conversationType?: "standard";
|
|
140
|
+
/**
|
|
141
|
+
* Caller-supplied title for the conversation, used only when this call
|
|
142
|
+
* actually creates the row. Treated as a user-set title (`isAutoTitle = 0`)
|
|
143
|
+
* so the async LLM title generator's safe-overwrite check leaves it
|
|
144
|
+
* untouched. Ignored when the conversation already exists.
|
|
145
|
+
*/
|
|
146
|
+
title?: string;
|
|
147
|
+
},
|
|
139
148
|
): {
|
|
140
149
|
conversationId: string;
|
|
141
150
|
conversationType: string;
|
|
@@ -205,13 +214,19 @@ export function getOrCreateConversation(
|
|
|
205
214
|
|
|
206
215
|
const now = Date.now();
|
|
207
216
|
const conversationId = uuid();
|
|
208
|
-
const
|
|
217
|
+
const customTitle = opts?.title?.trim();
|
|
218
|
+
const title = customTitle || GENERATING_TITLE;
|
|
209
219
|
const memoryScopeId = "default";
|
|
210
220
|
|
|
211
221
|
tx.insert(conversations)
|
|
212
222
|
.values({
|
|
213
223
|
id: conversationId,
|
|
214
224
|
title,
|
|
225
|
+
// A caller-supplied title is user-set: mark it non-auto (0) so the
|
|
226
|
+
// async LLM title generator's `canReplaceTitle` check won't overwrite
|
|
227
|
+
// it. Without one, omit the column so it takes its default
|
|
228
|
+
// (AUTO_TITLE_LLM) and follows the auto-generated placeholder flow.
|
|
229
|
+
...(customTitle ? { isAutoTitle: 0 } : {}),
|
|
215
230
|
createdAt: now,
|
|
216
231
|
updatedAt: now,
|
|
217
232
|
totalInputTokens: 0,
|
|
@@ -99,12 +99,13 @@ describe("advisor — agent-loop integration", () => {
|
|
|
99
99
|
expect(sub.options?.config?.callSite).toBe("inference");
|
|
100
100
|
expect(sub.options?.config?.overrideProfile).toBe("quality-optimized");
|
|
101
101
|
expect(sub.options?.config?.tool_choice).toEqual({ type: "none" });
|
|
102
|
-
|
|
102
|
+
// No advisor-specific output cap — the resolver applies the profile budget.
|
|
103
|
+
expect(sub.options?.config?.max_tokens).toBeUndefined();
|
|
103
104
|
|
|
104
105
|
// The advisor saw the captured transcript (task present; pending tool_use stripped).
|
|
105
106
|
expect(textOf(sub.messages[0].content)).toContain("build a worker pool");
|
|
106
107
|
expect(textOf(sub.messages[sub.messages.length - 1].content)).toContain(
|
|
107
|
-
"
|
|
108
|
+
"focused strategic guidance",
|
|
108
109
|
);
|
|
109
110
|
// It also saw the model's CURRENT turn — the text it wrote right before the
|
|
110
111
|
// `advisor` tool_use — which `post-model-call` lifts out of `ctx.content`.
|
|
@@ -112,7 +113,7 @@ describe("advisor — agent-loop integration", () => {
|
|
|
112
113
|
expect(transcript).toContain("Let me consult the advisor.");
|
|
113
114
|
|
|
114
115
|
// The advisor saw the executor's system prompt (via pre-model-call).
|
|
115
|
-
expect(sub.options?.systemPrompt).toContain("senior
|
|
116
|
+
expect(sub.options?.systemPrompt).toContain("senior advisor");
|
|
116
117
|
expect(sub.options?.systemPrompt).toContain("You are a coding agent.");
|
|
117
118
|
|
|
118
119
|
// The advice flowed back into the executor's history as the tool result.
|
|
@@ -77,7 +77,8 @@ describe("consultAdvisor", () => {
|
|
|
77
77
|
expect(config.callSite).toBe("inference");
|
|
78
78
|
expect(config.overrideProfile).toBe("quality-optimized");
|
|
79
79
|
expect(config.tool_choice).toEqual({ type: "none" });
|
|
80
|
-
|
|
80
|
+
// No advisor-specific output cap — the resolver applies the profile budget.
|
|
81
|
+
expect(config.max_tokens).toBeUndefined();
|
|
81
82
|
|
|
82
83
|
const sent = sendMessageArgs?.messages as Message[];
|
|
83
84
|
expect(sent[0]).toEqual(userMsg("build a worker pool"));
|
|
@@ -87,10 +88,12 @@ describe("consultAdvisor", () => {
|
|
|
87
88
|
});
|
|
88
89
|
const lastText = (sent[sent.length - 1].content[0] as { text: string })
|
|
89
90
|
.text;
|
|
90
|
-
expect(lastText).toContain("
|
|
91
|
+
expect(lastText).toContain("focused strategic guidance");
|
|
92
|
+
// The request carries no word limit.
|
|
93
|
+
expect(lastText).not.toContain("words");
|
|
91
94
|
|
|
92
95
|
const options = sendMessageArgs?.options as { systemPrompt: string };
|
|
93
|
-
expect(options.systemPrompt).toContain("senior
|
|
96
|
+
expect(options.systemPrompt).toContain("senior advisor");
|
|
94
97
|
expect(options.systemPrompt).toContain("You are a coding agent.");
|
|
95
98
|
});
|
|
96
99
|
|
|
@@ -12,13 +12,9 @@ export const ADVISOR_CONFIG = {
|
|
|
12
12
|
* profile; the resolver falls back to the active profile if it's absent.
|
|
13
13
|
*/
|
|
14
14
|
profile: "quality-optimized",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
maxTokens: 2048,
|
|
20
|
-
/** Soft word budget requested of the advisor, biasing toward a focused start. */
|
|
21
|
-
wordLimit: 80,
|
|
15
|
+
// No advisor-specific output cap: the consult omits `max_tokens` (so the
|
|
16
|
+
// resolver applies the profile's normal output budget) and the request text
|
|
17
|
+
// carries no word limit. The advisor decides its own length.
|
|
22
18
|
/** Abort the consult if the sub-call runs longer than this. */
|
|
23
19
|
timeoutMs: 60_000,
|
|
24
20
|
/** Inject the "call advisor before substantive work" steering. */
|
|
@@ -54,11 +54,10 @@ export async function consultAdvisor(params: ConsultParams): Promise<string> {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Append the consult instruction as the final user turn, then run a
|
|
57
|
-
// tool-less
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
];
|
|
57
|
+
// tool-less completion through the resolved provider. No `max_tokens` is
|
|
58
|
+
// set, so the resolver applies the profile's normal output budget rather
|
|
59
|
+
// than an advisor-specific cap.
|
|
60
|
+
const messages: Message[] = [...history, userMessage(advisorRequestText())];
|
|
62
61
|
|
|
63
62
|
const response = await provider.sendMessage(messages, {
|
|
64
63
|
systemPrompt: buildAdvisorSystem(params.systemPrompt),
|
|
@@ -66,7 +65,6 @@ export async function consultAdvisor(params: ConsultParams): Promise<string> {
|
|
|
66
65
|
callSite: ADVISOR_CALL_SITE,
|
|
67
66
|
overrideProfile: ADVISOR_CONFIG.profile,
|
|
68
67
|
tool_choice: { type: "none" },
|
|
69
|
-
max_tokens: ADVISOR_CONFIG.maxTokens,
|
|
70
68
|
},
|
|
71
69
|
signal: withTimeout(params.signal, ADVISOR_CONFIG.timeoutMs),
|
|
72
70
|
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
/** Idempotency marker; the steering block is appended at the end of the prompt. */
|
|
11
11
|
export const STEERING_MARKER = "<!-- advisor:steering -->";
|
|
12
12
|
|
|
13
|
-
const STEERING_BODY = `You have an \`advisor\` tool backed by a stronger reviewer model. It takes NO parameters — calling it forwards your entire conversation automatically (the task, every tool call, every result). Call advisor
|
|
13
|
+
const STEERING_BODY = `You have an \`advisor\` tool backed by a stronger reviewer model. It takes NO parameters — calling it forwards your entire conversation automatically (the task, every tool call, every result). Call advisor at the moments where a second perspective matters most: when you're about to commit to an approach or interpretation, at a consequential decision or crossroads, when you're stuck, and once before you declare the task done. It needs enough context to be useful — a concrete plan, a first attempt, or initial findings to react to, not the opening turn when there's nothing to assess — and it's most valuable while there's still room to act on its advice. Give its guidance serious weight; only override it when primary-source evidence contradicts a specific claim, and say so when you do.`;
|
|
14
14
|
|
|
15
15
|
const ADVISOR_STEERING = `${STEERING_MARKER}\n${STEERING_BODY}`;
|
|
16
16
|
|
|
@@ -37,15 +37,31 @@ export function stripSteering(systemPrompt: string | null): string | null {
|
|
|
37
37
|
export function buildAdvisorSystem(
|
|
38
38
|
originalSystemPrompt: string | null,
|
|
39
39
|
): string {
|
|
40
|
-
const base = `You are a senior
|
|
40
|
+
const base = `You are a senior advisor consulted by another AI agent that is partway through a task. The entire conversation above is the agent's working context: its task or goal, every tool call it has made, and every result it has seen. The agent has paused to consult you because you bring a second, independent perspective it cannot get from inside its own reasoning loop. Your job is to maximize its odds of finishing the task correctly and efficiently.
|
|
41
|
+
|
|
42
|
+
Evaluate the work along these dimensions, and lead with whatever matters most right now:
|
|
43
|
+
|
|
44
|
+
- Approach: Is the agent's current approach the right one, or is there a materially better path? If the approach is sound, say so plainly; if it's flawed, name the specific flaw and the better alternative.
|
|
45
|
+
- Assumptions & requirements: Surface any wrong, unstated, or unverified assumption the agent is building on, and any part of the task it has misread, silently narrowed, or skipped. These are the failures it is least able to see itself.
|
|
46
|
+
- Critical risk: Identify the single failure mode most likely to derail the task — or that already has — and how to avoid or recover from it.
|
|
47
|
+
- Next step: Give one concrete action the agent can take immediately. Name the specific file, function, command, interface, or decision involved — not a generic direction.
|
|
48
|
+
- Verification: If the agent has no clear way to confirm its work is correct, tell it how it will know.
|
|
49
|
+
|
|
50
|
+
How to advise:
|
|
51
|
+
- Be specific and grounded. Cite what you actually see in the transcript — a particular result, a line of reasoning, a command that failed. Never invent details that aren't there; if a decisive fact is missing, say what the agent should go find out.
|
|
52
|
+
- Be decisive. Give a clear recommendation, not a menu of equally weighted options. When genuinely uncertain, say so and state what would resolve it.
|
|
53
|
+
- Prioritize ruthlessly. Lead with the highest-leverage point. Don't restate at length what the agent already did well, and don't pad the response with minor nitpicks — a focused, well-reasoned critique beats an exhaustive one.
|
|
54
|
+
- Stay in your lane. Advise the agent; do not role-play as it, write its final deliverable, or take its next action for it. If the agent is already on the right track, confirm it and sharpen the plan rather than manufacturing objections.
|
|
55
|
+
|
|
56
|
+
Write as much as the guidance genuinely needs, and no more.`;
|
|
41
57
|
if (!originalSystemPrompt) return base;
|
|
42
58
|
return `${base}\n\nFor context, the agent is operating under this system prompt:\n<agent_system_prompt>\n${originalSystemPrompt}\n</agent_system_prompt>`;
|
|
43
59
|
}
|
|
44
60
|
|
|
45
61
|
/**
|
|
46
62
|
* The final user turn appended to the transcript for the advisor sub-call. Asks
|
|
47
|
-
* for guidance
|
|
63
|
+
* for guidance; imposes no length limit — the advisor decides how much to say.
|
|
48
64
|
*/
|
|
49
|
-
export function advisorRequestText(
|
|
50
|
-
return `Review the conversation above — the task, the tool calls, and their results — and give focused strategic guidance on how to proceed
|
|
65
|
+
export function advisorRequestText(): string {
|
|
66
|
+
return `Review the conversation above — the task, the tool calls, and their results — and give focused strategic guidance on how to proceed.`;
|
|
51
67
|
}
|
|
@@ -22,10 +22,13 @@ import { consultAdvisor } from "../consult.js";
|
|
|
22
22
|
const advisorTool: ToolDefinition = {
|
|
23
23
|
name: "advisor",
|
|
24
24
|
description:
|
|
25
|
-
"Consult a stronger advisor model for strategic guidance.
|
|
26
|
-
"full conversation (the task, every tool call, and every
|
|
27
|
-
"automatically. Call it
|
|
28
|
-
"approach
|
|
25
|
+
"Consult a stronger advisor model for detailed feedback and strategic guidance. " +
|
|
26
|
+
"Takes NO parameters — your full conversation (the task, every tool call, and every " +
|
|
27
|
+
"result) is forwarded automatically. Call it at the moments where a second perspective " +
|
|
28
|
+
"matters most: when you're committing to an approach or interpretation, at a " +
|
|
29
|
+
"consequential decision or crossroads, when you're stuck, and once before declaring a " +
|
|
30
|
+
"task complete. Give it enough context to be useful — a concrete plan, a first attempt, " +
|
|
31
|
+
"or initial findings to react to — and call while there's still room to act on its advice.",
|
|
29
32
|
input_schema: { type: "object", properties: {}, additionalProperties: false },
|
|
30
33
|
// Read-only advice; low risk so the consult isn't gated behind a prompt.
|
|
31
34
|
defaultRiskLevel: RiskLevel.Low,
|
|
@@ -26,6 +26,8 @@ mock.module("../../assistant-event-hub.js", () => ({
|
|
|
26
26
|
broadcastMessage: () => {},
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
|
+
import { eq } from "drizzle-orm";
|
|
30
|
+
|
|
29
31
|
import { getDb } from "../../../memory/db-connection.js";
|
|
30
32
|
import { initializeDb } from "../../../memory/db-init.js";
|
|
31
33
|
import { conversations } from "../../../memory/schema.js";
|
|
@@ -71,6 +73,10 @@ function findHandler(routes: RouteDefinition[], operationId: string) {
|
|
|
71
73
|
return route.handler;
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
const createHandler = findHandler(
|
|
77
|
+
CONVERSATION_MANAGEMENT_ROUTES,
|
|
78
|
+
"createConversation",
|
|
79
|
+
);
|
|
74
80
|
const putHandler = findHandler(
|
|
75
81
|
CONVERSATION_MANAGEMENT_ROUTES,
|
|
76
82
|
"setConversationInferenceProfile",
|
|
@@ -112,6 +118,67 @@ function seedConversation(id: string): void {
|
|
|
112
118
|
// Tests
|
|
113
119
|
// ---------------------------------------------------------------------------
|
|
114
120
|
|
|
121
|
+
describe("POST /v1/conversations (createConversation)", () => {
|
|
122
|
+
beforeEach(() => {
|
|
123
|
+
clearConversations();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
function readConversation(id: string) {
|
|
127
|
+
return getDb()
|
|
128
|
+
.select({
|
|
129
|
+
title: conversations.title,
|
|
130
|
+
isAutoTitle: conversations.isAutoTitle,
|
|
131
|
+
})
|
|
132
|
+
.from(conversations)
|
|
133
|
+
.where(eq(conversations.id, id))
|
|
134
|
+
.get();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
test("with a title → persists it as a user-set title (isAutoTitle = 0)", async () => {
|
|
138
|
+
const result = (await createHandler({
|
|
139
|
+
body: { conversationType: "standard", title: "Setting up your check-in" },
|
|
140
|
+
})) as { id: string; created: boolean };
|
|
141
|
+
|
|
142
|
+
expect(result.created).toBe(true);
|
|
143
|
+
const row = readConversation(result.id);
|
|
144
|
+
expect(row?.title).toBe("Setting up your check-in");
|
|
145
|
+
// isAutoTitle = 0 keeps the async LLM titler from overwriting it.
|
|
146
|
+
expect(row?.isAutoTitle).toBe(0);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("blank title falls back to the replaceable 'New Conversation' placeholder", async () => {
|
|
150
|
+
const result = (await createHandler({
|
|
151
|
+
body: { conversationType: "standard", title: " " },
|
|
152
|
+
})) as { id: string; created: boolean };
|
|
153
|
+
|
|
154
|
+
expect(result.created).toBe(true);
|
|
155
|
+
const row = readConversation(result.id);
|
|
156
|
+
expect(row?.title).toBe("New Conversation");
|
|
157
|
+
// Default auto-title flag (1) leaves it replaceable by the auto-titler.
|
|
158
|
+
expect(row?.isAutoTitle).toBe(1);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("no title → 'New Conversation' placeholder", async () => {
|
|
162
|
+
const result = (await createHandler({
|
|
163
|
+
body: { conversationType: "standard" },
|
|
164
|
+
})) as { id: string; created: boolean };
|
|
165
|
+
|
|
166
|
+
expect(result.created).toBe(true);
|
|
167
|
+
const row = readConversation(result.id);
|
|
168
|
+
expect(row?.title).toBe("New Conversation");
|
|
169
|
+
expect(row?.isAutoTitle).toBe(1);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("non-string title → BadRequestError (not a 500), no row created", () => {
|
|
173
|
+
// The shared route adapter doesn't runtime-validate the body, so the
|
|
174
|
+
// handler must reject a malformed title before `.trim()` throws.
|
|
175
|
+
expect(() =>
|
|
176
|
+
createHandler({ body: { conversationType: "standard", title: 123 } }),
|
|
177
|
+
).toThrow(/title must be a string/);
|
|
178
|
+
expect(getDb().select().from(conversations).all()).toHaveLength(0);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
115
182
|
describe("PUT /v1/conversations/:id/inference-profile", () => {
|
|
116
183
|
beforeEach(() => {
|
|
117
184
|
clearConversations();
|
|
@@ -94,11 +94,26 @@ function cancelScheduleIfLast(conversationId: string): void {
|
|
|
94
94
|
function handleCreateConversation({ body = {}, headers }: RouteHandlerArgs) {
|
|
95
95
|
const conversationKey =
|
|
96
96
|
(body.conversationKey as string | undefined) ?? crypto.randomUUID();
|
|
97
|
+
// The shared route adapter does not runtime-validate the body against the
|
|
98
|
+
// Zod requestBody (it's codegen-only), so guard the type before trimming —
|
|
99
|
+
// a malformed `{ title: 123 }` would otherwise throw on `.trim()` and 500.
|
|
100
|
+
if (body.title !== undefined && typeof body.title !== "string") {
|
|
101
|
+
throw new BadRequestError("title must be a string");
|
|
102
|
+
}
|
|
103
|
+
const customTitle = body.title?.trim() || undefined;
|
|
97
104
|
const result = getOrCreateConversation(conversationKey, {
|
|
98
105
|
conversationType: "standard",
|
|
99
106
|
});
|
|
100
107
|
if (result.created) {
|
|
101
|
-
|
|
108
|
+
// A caller-supplied title is user-set: persist it with isAutoTitle = 0 so
|
|
109
|
+
// the async LLM titler's safe-overwrite check leaves it untouched. Without
|
|
110
|
+
// one, fall back to the neutral "New Conversation" placeholder, which stays
|
|
111
|
+
// replaceable by the auto-titler once messages arrive.
|
|
112
|
+
if (customTitle) {
|
|
113
|
+
updateConversationTitle(result.conversationId, customTitle, 0);
|
|
114
|
+
} else {
|
|
115
|
+
updateConversationTitle(result.conversationId, "New Conversation");
|
|
116
|
+
}
|
|
102
117
|
publishConversationListAndMetadataChanged(
|
|
103
118
|
"created",
|
|
104
119
|
result.conversationId,
|
|
@@ -550,6 +565,12 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
550
565
|
.literal("standard")
|
|
551
566
|
.optional()
|
|
552
567
|
.describe("Only standard conversations are created by this endpoint"),
|
|
568
|
+
title: z
|
|
569
|
+
.string()
|
|
570
|
+
.optional()
|
|
571
|
+
.describe(
|
|
572
|
+
"Explicit title for the conversation. When provided on creation, it is persisted as a user-set title (never overwritten by the auto-titler). Used by flows that mint a conversation up-front and don't want an auto-generated title.",
|
|
573
|
+
),
|
|
553
574
|
}),
|
|
554
575
|
responseBody: z.object({
|
|
555
576
|
id: z
|
|
@@ -1133,6 +1133,7 @@ export async function handleSendMessage(
|
|
|
1133
1133
|
bootstrapTemplate?: string;
|
|
1134
1134
|
initialMessage?: string;
|
|
1135
1135
|
skills?: string[];
|
|
1136
|
+
title?: string;
|
|
1136
1137
|
};
|
|
1137
1138
|
};
|
|
1138
1139
|
|
|
@@ -1310,8 +1311,13 @@ export async function handleSendMessage(
|
|
|
1310
1311
|
: sourceChannel === "vellum"
|
|
1311
1312
|
? crypto.randomUUID()
|
|
1312
1313
|
: `default:${sourceChannel}:${sourceInterface}`;
|
|
1314
|
+
// An onboarding flow may supply an explicit title for the conversation it
|
|
1315
|
+
// mints behind the scenes (e.g. the research pass) so it isn't left with an
|
|
1316
|
+
// auto-generated title. Applied only when this call creates the row.
|
|
1317
|
+
const onboardingTitle = body.onboarding?.title?.trim() || undefined;
|
|
1313
1318
|
mapping = getOrCreateConversation(resolvedConversationKey, {
|
|
1314
1319
|
conversationType: "standard",
|
|
1320
|
+
title: onboardingTitle,
|
|
1315
1321
|
});
|
|
1316
1322
|
}
|
|
1317
1323
|
|
|
@@ -2717,6 +2723,12 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
2717
2723
|
bootstrapTemplate: z.string().optional(),
|
|
2718
2724
|
initialMessage: z.string().optional(),
|
|
2719
2725
|
skills: z.array(z.string()).optional(),
|
|
2726
|
+
title: z
|
|
2727
|
+
.string()
|
|
2728
|
+
.optional()
|
|
2729
|
+
.describe(
|
|
2730
|
+
"Explicit title for the conversation minted on this first message. Persisted as a user-set title (never overwritten by the auto-titler). Used by onboarding flows that mint a conversation behind the scenes.",
|
|
2731
|
+
),
|
|
2720
2732
|
})
|
|
2721
2733
|
.describe("PreChat onboarding context, sent on the first message only")
|
|
2722
2734
|
.optional(),
|
|
@@ -28,6 +28,7 @@ let mockSetConfigResult: SlackChannelConfigResult = {
|
|
|
28
28
|
hasAppToken: false,
|
|
29
29
|
hasUserToken: false,
|
|
30
30
|
connected: false,
|
|
31
|
+
threadMode: "mention_only",
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
mock.module("../../../../../daemon/handlers/config-slack-channel.js", () => ({
|
|
@@ -37,6 +38,7 @@ mock.module("../../../../../daemon/handlers/config-slack-channel.js", () => ({
|
|
|
37
38
|
hasAppToken: z.boolean(),
|
|
38
39
|
hasUserToken: z.boolean(),
|
|
39
40
|
connected: z.boolean(),
|
|
41
|
+
threadMode: z.enum(["mention_only", "mention_then_thread"]),
|
|
40
42
|
teamId: z.string().optional(),
|
|
41
43
|
teamName: z.string().optional(),
|
|
42
44
|
teamUrl: z.string().optional(),
|
|
@@ -45,6 +47,7 @@ mock.module("../../../../../daemon/handlers/config-slack-channel.js", () => ({
|
|
|
45
47
|
error: z.string().optional(),
|
|
46
48
|
warning: z.string().optional(),
|
|
47
49
|
}),
|
|
50
|
+
SlackThreadMode: z.enum(["mention_only", "mention_then_thread"]),
|
|
48
51
|
setSlackChannelConfig: async (
|
|
49
52
|
botToken?: string,
|
|
50
53
|
appToken?: string,
|
|
@@ -59,6 +62,7 @@ mock.module("../../../../../daemon/handlers/config-slack-channel.js", () => ({
|
|
|
59
62
|
hasAppToken: false,
|
|
60
63
|
hasUserToken: false,
|
|
61
64
|
connected: false,
|
|
65
|
+
threadMode: "mention_only",
|
|
62
66
|
}),
|
|
63
67
|
clearSlackChannelConfig: async (): Promise<SlackChannelConfigResult> => ({
|
|
64
68
|
success: true,
|
|
@@ -66,7 +70,9 @@ mock.module("../../../../../daemon/handlers/config-slack-channel.js", () => ({
|
|
|
66
70
|
hasAppToken: false,
|
|
67
71
|
hasUserToken: false,
|
|
68
72
|
connected: false,
|
|
73
|
+
threadMode: "mention_only",
|
|
69
74
|
}),
|
|
75
|
+
patchSlackChannelConfig: () => {},
|
|
70
76
|
}));
|
|
71
77
|
|
|
72
78
|
import { BadRequestError } from "../../../errors.js";
|
|
@@ -81,6 +87,7 @@ describe("POST /v1/integrations/slack/channel/config", () => {
|
|
|
81
87
|
hasAppToken: false,
|
|
82
88
|
hasUserToken: false,
|
|
83
89
|
connected: false,
|
|
90
|
+
threadMode: "mention_only",
|
|
84
91
|
};
|
|
85
92
|
});
|
|
86
93
|
|
|
@@ -129,6 +136,7 @@ describe("POST /v1/integrations/slack/channel/config", () => {
|
|
|
129
136
|
hasAppToken: false,
|
|
130
137
|
hasUserToken: false,
|
|
131
138
|
connected: false,
|
|
139
|
+
threadMode: "mention_only",
|
|
132
140
|
error: 'Invalid user token: must start with "xoxp-"',
|
|
133
141
|
};
|
|
134
142
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* GET /v1/integrations/slack/channel/config — get current config status
|
|
5
5
|
* POST /v1/integrations/slack/channel/config — validate and store credentials
|
|
6
|
+
* PATCH /v1/integrations/slack/channel/config — update channel settings
|
|
6
7
|
* DELETE /v1/integrations/slack/channel/config — clear credentials
|
|
7
8
|
*/
|
|
8
9
|
|
|
@@ -11,8 +12,10 @@ import { z } from "zod";
|
|
|
11
12
|
import {
|
|
12
13
|
clearSlackChannelConfig,
|
|
13
14
|
getSlackChannelConfig,
|
|
15
|
+
patchSlackChannelConfig,
|
|
14
16
|
setSlackChannelConfig,
|
|
15
17
|
SlackChannelConfigResultSchema,
|
|
18
|
+
SlackThreadMode,
|
|
16
19
|
} from "../../../../daemon/handlers/config-slack-channel.js";
|
|
17
20
|
import { ACTOR_PRINCIPALS } from "../../../auth/route-policy.js";
|
|
18
21
|
import { BadRequestError } from "../../errors.js";
|
|
@@ -43,6 +46,20 @@ export async function handleSetSlackChannelConfig({
|
|
|
43
46
|
return result;
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
async function handlePatchSlackChannelConfig({ body = {} }: RouteHandlerArgs) {
|
|
50
|
+
const { threadMode } = body as { threadMode?: string };
|
|
51
|
+
if (threadMode !== undefined) {
|
|
52
|
+
const parsed = SlackThreadMode.safeParse(threadMode);
|
|
53
|
+
if (!parsed.success) {
|
|
54
|
+
throw new BadRequestError(
|
|
55
|
+
"threadMode must be 'mention_only' or 'mention_then_thread'",
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
patchSlackChannelConfig(parsed.data);
|
|
59
|
+
}
|
|
60
|
+
return getSlackChannelConfig();
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
async function handleClearSlackChannelConfig() {
|
|
47
64
|
return clearSlackChannelConfig();
|
|
48
65
|
}
|
|
@@ -84,6 +101,25 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
84
101
|
}),
|
|
85
102
|
responseBody: SlackChannelConfigResultSchema,
|
|
86
103
|
},
|
|
104
|
+
{
|
|
105
|
+
operationId: "integrations_slack_channel_config_patch",
|
|
106
|
+
endpoint: "integrations/slack/channel/config",
|
|
107
|
+
method: "PATCH",
|
|
108
|
+
policy: {
|
|
109
|
+
requiredScopes: ["settings.write"],
|
|
110
|
+
allowedPrincipalTypes: ACTOR_PRINCIPALS,
|
|
111
|
+
},
|
|
112
|
+
summary: "Update Slack channel settings",
|
|
113
|
+
description: "Update Slack channel behavior settings (e.g. thread mode).",
|
|
114
|
+
tags: ["integrations"],
|
|
115
|
+
handler: handlePatchSlackChannelConfig,
|
|
116
|
+
requestBody: z.object({
|
|
117
|
+
threadMode: SlackThreadMode.describe(
|
|
118
|
+
"Controls whether the bot follows threads after an initial @mention",
|
|
119
|
+
).optional(),
|
|
120
|
+
}),
|
|
121
|
+
responseBody: SlackChannelConfigResultSchema,
|
|
122
|
+
},
|
|
87
123
|
{
|
|
88
124
|
operationId: "integrations_slack_channel_config_delete",
|
|
89
125
|
endpoint: "integrations/slack/channel/config",
|