@chosengeneration/light-code 0.50.0 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +686 -115
- package/dist/client/client.js +68 -68
- package/dist/server.js +685 -114
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -39663,7 +39663,32 @@ var agentAssignmentSchema = external_exports.object({
|
|
|
39663
39663
|
* has looked at the tab without editing anything. Storing the default verbatim would pin
|
|
39664
39664
|
* every user to whatever it said the day they first opened it.
|
|
39665
39665
|
*/
|
|
39666
|
-
prompt: external_exports.string().optional()
|
|
39666
|
+
prompt: external_exports.string().optional(),
|
|
39667
|
+
/**
|
|
39668
|
+
* Whether this specialist may read and search the workspace, overriding the role's default.
|
|
39669
|
+
*
|
|
39670
|
+
* On the assignment rather than the role because it depends on *who* is answering: a small
|
|
39671
|
+
* local model given five lookups can spend them all and answer worse, where a strong one
|
|
39672
|
+
* uses them well. Absent means the role's own default.
|
|
39673
|
+
*/
|
|
39674
|
+
tools: external_exports.boolean().optional(),
|
|
39675
|
+
/**
|
|
39676
|
+
* Whether this specialist may change things, each change through the approval gate.
|
|
39677
|
+
*
|
|
39678
|
+
* Off by default everywhere. §12b's rule is that a consultant is read-only; this is the
|
|
39679
|
+
* deliberate exception, and it is per role because "the programmer may edit" and "the tester
|
|
39680
|
+
* may edit" are quite different decisions.
|
|
39681
|
+
*/
|
|
39682
|
+
write: external_exports.boolean().optional(),
|
|
39683
|
+
/**
|
|
39684
|
+
* Whether this role is in play at all.
|
|
39685
|
+
*
|
|
39686
|
+
* Distinct from unassigning it, which is why both exist: unassigning forgets *who* answered,
|
|
39687
|
+
* and somebody switching a specialist off for one job does not want to lose the model, the
|
|
39688
|
+
* prompt and the flags they set up. Absent means on, so nothing changes for a config written
|
|
39689
|
+
* before this.
|
|
39690
|
+
*/
|
|
39691
|
+
enabled: external_exports.boolean().optional()
|
|
39667
39692
|
}).strict();
|
|
39668
39693
|
var customRoleSchema = external_exports.object({
|
|
39669
39694
|
id: external_exports.string().min(1),
|
|
@@ -43249,6 +43274,11 @@ var Conversation = class {
|
|
|
43249
43274
|
|
|
43250
43275
|
// ../../packages/core/dist/agents/roles.js
|
|
43251
43276
|
var AGENT_ROLES = ["expert", "programmer", "reviewer", "tester", "librarian"];
|
|
43277
|
+
var CUSTOM_ROLE_LIMIT = 5;
|
|
43278
|
+
var ROLE_ID = /^[a-z][a-z0-9-]{1,23}$/;
|
|
43279
|
+
function isValidRoleId(id) {
|
|
43280
|
+
return ROLE_ID.test(id) && !AGENT_ROLES.includes(id);
|
|
43281
|
+
}
|
|
43252
43282
|
function isAgentRole(value, custom2 = []) {
|
|
43253
43283
|
return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
|
|
43254
43284
|
}
|
|
@@ -43262,6 +43292,13 @@ var SHARED_TAIL = [
|
|
|
43262
43292
|
"",
|
|
43263
43293
|
"Answer in prose and short lists. No preamble about being happy to help."
|
|
43264
43294
|
];
|
|
43295
|
+
var MAY_WRITE = [
|
|
43296
|
+
"",
|
|
43297
|
+
"You can also change this workspace: edit files, and record a skill. Every such change is shown",
|
|
43298
|
+
"to the user and approved by them before it happens, so make each one small enough to read and",
|
|
43299
|
+
"say what it is for. Prefer telling the assistant what to change where the change is large or",
|
|
43300
|
+
"spans files \u2014 it has the whole picture and you have only what you asked for."
|
|
43301
|
+
].join("\n");
|
|
43265
43302
|
var SHARED_WITH_TOOLS = [
|
|
43266
43303
|
"You can read this workspace: open files, list them, and search. Use that rather than guessing,",
|
|
43267
43304
|
"and rather than asking the assistant for something you can fetch yourself. You have a small",
|
|
@@ -43279,8 +43316,9 @@ var SHARED_BLIND = [
|
|
|
43279
43316
|
"",
|
|
43280
43317
|
...SHARED_TAIL
|
|
43281
43318
|
].join("\n");
|
|
43282
|
-
function specialistPreamble(usesTools) {
|
|
43283
|
-
|
|
43319
|
+
function specialistPreamble(usesTools, canWrite = false) {
|
|
43320
|
+
const base = usesTools ? SHARED_WITH_TOOLS : SHARED_BLIND;
|
|
43321
|
+
return canWrite ? `${base}${MAY_WRITE}` : base;
|
|
43284
43322
|
}
|
|
43285
43323
|
var DEFINITIONS = {
|
|
43286
43324
|
expert: {
|
|
@@ -43289,6 +43327,7 @@ var DEFINITIONS = {
|
|
|
43289
43327
|
/* Planning a change means knowing what is already there, and it spans files the asker
|
|
43290
43328
|
* cannot paste all of. */
|
|
43291
43329
|
usesTools: true,
|
|
43330
|
+
canWrite: false,
|
|
43292
43331
|
prompt: [
|
|
43293
43332
|
"You are a senior engineer being consulted by another AI assistant that is doing the work.",
|
|
43294
43333
|
"",
|
|
@@ -43306,6 +43345,7 @@ var DEFINITIONS = {
|
|
|
43306
43345
|
/* It is handed a spec and the surrounding code and asked to write. Looking around buys
|
|
43307
43346
|
* a slower answer that is no better. */
|
|
43308
43347
|
usesTools: false,
|
|
43348
|
+
canWrite: false,
|
|
43309
43349
|
prompt: [
|
|
43310
43350
|
"You are an experienced programmer writing code for another AI assistant to apply.",
|
|
43311
43351
|
"",
|
|
@@ -43336,6 +43376,7 @@ var DEFINITIONS = {
|
|
|
43336
43376
|
/* Most of what a review turns on is *around* the diff — the callers, the neighbouring
|
|
43337
43377
|
* function, whether this convention is really the convention. */
|
|
43338
43378
|
usesTools: true,
|
|
43379
|
+
canWrite: false,
|
|
43339
43380
|
prompt: [
|
|
43340
43381
|
"You are reviewing a change written by another AI assistant.",
|
|
43341
43382
|
"",
|
|
@@ -43363,6 +43404,7 @@ var DEFINITIONS = {
|
|
|
43363
43404
|
/* The change is in front of it and the cases come from reasoning about it, not from
|
|
43364
43405
|
* reading more of the codebase. */
|
|
43365
43406
|
usesTools: false,
|
|
43407
|
+
canWrite: false,
|
|
43366
43408
|
prompt: [
|
|
43367
43409
|
"You design tests for code written by another AI assistant.",
|
|
43368
43410
|
"",
|
|
@@ -43382,6 +43424,7 @@ var DEFINITIONS = {
|
|
|
43382
43424
|
* left it answering from whatever happened to be pasted in. This is the role the flag
|
|
43383
43425
|
* exists for. */
|
|
43384
43426
|
usesTools: true,
|
|
43427
|
+
canWrite: false,
|
|
43385
43428
|
prompt: [
|
|
43386
43429
|
"You answer questions about how things are done here: internal libraries, house conventions,",
|
|
43387
43430
|
"the shape of existing code, and what has already been written down.",
|
|
@@ -43391,7 +43434,29 @@ var DEFINITIONS = {
|
|
|
43391
43434
|
"you are inferring \u2014 a convention you guessed at, stated confidently, becomes the convention.",
|
|
43392
43435
|
"",
|
|
43393
43436
|
"If the material does not answer the question, say so and say what would. Do not fill the gap",
|
|
43394
|
-
"with how it is usually done elsewhere unless you label it as exactly that."
|
|
43437
|
+
"with how it is usually done elsewhere unless you label it as exactly that.",
|
|
43438
|
+
"",
|
|
43439
|
+
/*
|
|
43440
|
+
* The one specialist that may write, and only this one thing.
|
|
43441
|
+
*
|
|
43442
|
+
* The objection was never that the librarian should not record what it knows — it is the
|
|
43443
|
+
* role that can see the gap. It was that a consultation asks nobody, so a skill written
|
|
43444
|
+
* there would be prose injected into every later prompt that no human had read (§13's
|
|
43445
|
+
* persistent prompt-injection vector). That was answered by making this path *ask*:
|
|
43446
|
+
* `runConsultation` routes anything in ALWAYS_ASK_TOOLS through the same approval gate the
|
|
43447
|
+
* agent loop uses, so the user sees the source exactly as they would for any other write.
|
|
43448
|
+
*
|
|
43449
|
+
* Everything else stays read-only. `consultBoundary.test.ts` holds that line, and pins the
|
|
43450
|
+
* rule that any name allowed past the group filter must be one the gate will stop on.
|
|
43451
|
+
*/
|
|
43452
|
+
"When the answer is something worth writing down \u2014 a convention you had to piece together,",
|
|
43453
|
+
"a gotcha that will catch the next person, a procedure that is currently only in somebody's",
|
|
43454
|
+
"head \u2014 say so and **write it with `write_skill`**. The user is shown the text and",
|
|
43455
|
+
"approves it before anything is recorded, so write it as it should stand rather than",
|
|
43456
|
+
"describing what it would say. If they decline, say what you would have written and why.",
|
|
43457
|
+
"",
|
|
43458
|
+
"Say plainly when something already written down is **wrong or out of date**. A stale skill",
|
|
43459
|
+
"is worse than a missing one, because it is believed."
|
|
43395
43460
|
].join("\n")
|
|
43396
43461
|
}
|
|
43397
43462
|
};
|
|
@@ -43413,7 +43478,10 @@ function roleInfo(role, custom2 = []) {
|
|
|
43413
43478
|
* accessibility — and those all turn on code the asker did not think to paste. The flag is
|
|
43414
43479
|
* there to turn it off for the ones that are really "write this to spec".
|
|
43415
43480
|
*/
|
|
43416
|
-
usesTools: defined.usesTools !== false
|
|
43481
|
+
usesTools: defined.usesTools !== false,
|
|
43482
|
+
// Off unless asked for: a role invented in a hurry should not be able to edit the
|
|
43483
|
+
// repository because nobody thought about the box.
|
|
43484
|
+
canWrite: defined.canWrite === true
|
|
43417
43485
|
};
|
|
43418
43486
|
}
|
|
43419
43487
|
return {
|
|
@@ -43421,7 +43489,8 @@ function roleInfo(role, custom2 = []) {
|
|
|
43421
43489
|
name: role,
|
|
43422
43490
|
summary: "This role is no longer defined.",
|
|
43423
43491
|
prompt: "",
|
|
43424
|
-
usesTools: false
|
|
43492
|
+
usesTools: false,
|
|
43493
|
+
canWrite: false
|
|
43425
43494
|
};
|
|
43426
43495
|
}
|
|
43427
43496
|
function allRoles(custom2 = []) {
|
|
@@ -43431,7 +43500,11 @@ function defaultPromptFor(role, custom2 = []) {
|
|
|
43431
43500
|
return roleInfo(role, custom2).prompt;
|
|
43432
43501
|
}
|
|
43433
43502
|
function buildAgentPrompt(options) {
|
|
43434
|
-
const lines = [
|
|
43503
|
+
const lines = [
|
|
43504
|
+
options.prompt.trim(),
|
|
43505
|
+
"",
|
|
43506
|
+
specialistPreamble(options.usesTools, options.canWrite === true)
|
|
43507
|
+
];
|
|
43435
43508
|
if (options.briefing !== void 0 && options.briefing.trim().length > 0) {
|
|
43436
43509
|
lines.push("", options.briefing);
|
|
43437
43510
|
}
|
|
@@ -43660,6 +43733,7 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
43660
43733
|
} else if (options.pythonToolsAvailable === true) {
|
|
43661
43734
|
lines.push("", "Python tools:", "- `create_python_tool` makes a real, registered, callable tool. Use it whenever the user", ' asks for a "tool", even if writing a script would be easier.', "- Writing a .py file with `write_to_file` does NOT create a tool. It is just a file, and", " nothing can call it. Never describe that as having created a tool.", "- `update_python_tool` edits one, `delete_python_tool` removes one.");
|
|
43662
43735
|
}
|
|
43736
|
+
lines.push("", "Specialist roles:", "- The team of specialists is configurable, and you can change it. `read_role_prompt` shows", " what a role is told it is (no argument lists them all); `update_role` changes that, or a", " custom role's name, summary and workspace access.", "- `create_role` invents one \u2014 a security reviewer, say \u2014 and `delete_role` removes a custom", " one. The user approves each of these, seeing the whole role or a diff of it.", '- So "make the reviewer stricter" or "add a role that reviews SQL" is something to do, not', " something to explain how to do by hand.");
|
|
43663
43737
|
if (options.skills !== void 0 || options.skillsSearchable === true) {
|
|
43664
43738
|
lines.push("", "Skills, before anything else:", "- Check the skills for this workspace before you plan or answer. They record how *this*", " project works, and they exist because someone was tired of explaining it.", "- A skill that applies overrides your general knowledge. Do not restate a convention it", " contradicts.", ...options.teamSkillsAvailable === true ? [
|
|
43665
43739
|
"- `search_team_skills` searches what OTHER people have taught their assistants. Use it",
|
|
@@ -44146,6 +44220,9 @@ function trailerFor(agent, team) {
|
|
|
44146
44220
|
if (agent.role === "reviewer" && programmer !== void 0) {
|
|
44147
44221
|
lines.push("", "If the programmer wrote this code, take the findings back to it rather than fixing them yourself: paste the code as it stands, the findings in full, and anything you have already checked. It may disagree, and a disagreement is an answer \u2014 you have the real file and neither of them does, so you settle it and say which way you went. Re-review only if the fix was substantial enough that this review no longer describes the code.");
|
|
44148
44222
|
}
|
|
44223
|
+
if (agent.role === "librarian") {
|
|
44224
|
+
lines.push("", "It can record a skill itself, and the user will have approved the text before it was written \u2014 so if it says it wrote one, that is done and not something to repeat. If it said something already written down is wrong or out of date, act on that: a stale skill is worse than a missing one, because it is believed.");
|
|
44225
|
+
}
|
|
44149
44226
|
if (agent.role === "programmer") {
|
|
44150
44227
|
lines.push("", "Check this against the real file before applying it \u2014 it was written from what you pasted, so it can miss a convention or a caller it was never shown.");
|
|
44151
44228
|
}
|
|
@@ -44163,9 +44240,12 @@ function resolveTeam(context) {
|
|
|
44163
44240
|
const assignment = context.config?.roles?.[role] ?? defaultAssignment(role, context);
|
|
44164
44241
|
if (assignment === void 0)
|
|
44165
44242
|
continue;
|
|
44243
|
+
if (assignment.enabled === false)
|
|
44244
|
+
continue;
|
|
44166
44245
|
const info = roleInfo(role, custom2);
|
|
44167
44246
|
const prompt = assignment.prompt ?? defaultPromptFor(role, custom2);
|
|
44168
44247
|
const usesTools = assignment.tools ?? info.usesTools;
|
|
44248
|
+
const canWrite = assignment.write ?? info.canWrite;
|
|
44169
44249
|
if (assignment.kind === "cli") {
|
|
44170
44250
|
resolved.push({
|
|
44171
44251
|
role,
|
|
@@ -44175,11 +44255,14 @@ function resolveTeam(context) {
|
|
|
44175
44255
|
label: "Claude",
|
|
44176
44256
|
prompt,
|
|
44177
44257
|
usesTools,
|
|
44258
|
+
canWrite,
|
|
44178
44259
|
available: context.cliAvailable,
|
|
44179
44260
|
...context.cliAvailable ? {} : { reason: "The Claude CLI is not available on this machine." }
|
|
44180
44261
|
});
|
|
44181
44262
|
continue;
|
|
44182
44263
|
}
|
|
44264
|
+
if (assignment.profileId === void 0)
|
|
44265
|
+
continue;
|
|
44183
44266
|
const profile = context.profiles.find((candidate) => candidate.id === assignment.profileId);
|
|
44184
44267
|
resolved.push({
|
|
44185
44268
|
role,
|
|
@@ -44190,6 +44273,7 @@ function resolveTeam(context) {
|
|
|
44190
44273
|
label: profile?.label ?? assignment.profileId ?? "unassigned",
|
|
44191
44274
|
prompt,
|
|
44192
44275
|
usesTools,
|
|
44276
|
+
canWrite,
|
|
44193
44277
|
available: profile !== void 0,
|
|
44194
44278
|
/*
|
|
44195
44279
|
* A profile that has been deleted leaves the role unavailable and says so, rather than
|
|
@@ -44484,11 +44568,26 @@ function buildRoster(team, self) {
|
|
|
44484
44568
|
"- **Readers** \u2014 the reviewer, the tester, the librarian. Worth a step where another pair of",
|
|
44485
44569
|
" eyes changes what happens: risky or fiddly code, a step that finishes something, a",
|
|
44486
44570
|
" convention you would otherwise be guessing at.",
|
|
44571
|
+
'- **The librarian writes down what should be written down.** A step like "record how this',
|
|
44572
|
+
' is set up" is a good one to allocate: it reads what already exists and records the skill',
|
|
44573
|
+
" itself. The user approves the text before it is saved, so word the step as recording.",
|
|
44487
44574
|
"- **The programmer writes.** Where a step is a self-contained piece of code with a spec",
|
|
44488
44575
|
" clear enough to hand over \u2014 a parser, a schema, a set of pure functions \u2014 say so and give",
|
|
44489
44576
|
" it to the programmer. The assistant checks what comes back against the real file and",
|
|
44490
44577
|
" applies it, so this is delegation rather than trust.",
|
|
44491
44578
|
"",
|
|
44579
|
+
/*
|
|
44580
|
+
* A role invented by the user, which no fixed description can cover.
|
|
44581
|
+
*
|
|
44582
|
+
* The two bullets above name the built-in five, and a plan written only from them would
|
|
44583
|
+
* quietly skip a `db-reviewer` the user went to the trouble of creating — the same failure
|
|
44584
|
+
* as never allocating the programmer, arriving from the other direction. The summary is the
|
|
44585
|
+
* only thing that can describe it, so the instruction is to read it.
|
|
44586
|
+
*/
|
|
44587
|
+
"- **A role you do not recognise is described by its summary above.** The user invented it",
|
|
44588
|
+
" and wrote that line, so treat it as the authority on what the role is for and allocate it",
|
|
44589
|
+
" where the summary says it helps.",
|
|
44590
|
+
"",
|
|
44492
44591
|
"Only where it genuinely changes the outcome: a plan that routes every step through all of",
|
|
44493
44592
|
"them is ceremony, and one that routes none wastes a team that is sitting there."
|
|
44494
44593
|
);
|
|
@@ -44538,11 +44637,109 @@ function buildAgentBriefing(input) {
|
|
|
44538
44637
|
return sections.join("\n");
|
|
44539
44638
|
}
|
|
44540
44639
|
|
|
44640
|
+
// ../../packages/core/dist/approval/commands.js
|
|
44641
|
+
function isCommandAllowlisted(command, allowlist) {
|
|
44642
|
+
return allowlist.includes(command);
|
|
44643
|
+
}
|
|
44644
|
+
function addToAllowlist(command, allowlist) {
|
|
44645
|
+
return allowlist.includes(command) ? [...allowlist] : [...allowlist, command];
|
|
44646
|
+
}
|
|
44647
|
+
function removeFromAllowlist(command, allowlist) {
|
|
44648
|
+
return allowlist.filter((entry) => entry !== command);
|
|
44649
|
+
}
|
|
44650
|
+
|
|
44651
|
+
// ../../packages/core/dist/approval/types.js
|
|
44652
|
+
function requiresApproval(group) {
|
|
44653
|
+
return group !== "always";
|
|
44654
|
+
}
|
|
44655
|
+
|
|
44656
|
+
// ../../packages/core/dist/approval/policy.js
|
|
44657
|
+
function isApprovableGroup(group) {
|
|
44658
|
+
return group === "read" || group === "edit" || group === "command" || group === "mcp";
|
|
44659
|
+
}
|
|
44660
|
+
function categoryEnabled(group, settings) {
|
|
44661
|
+
if (settings === void 0 || !isApprovableGroup(group))
|
|
44662
|
+
return false;
|
|
44663
|
+
return settings[group] === true;
|
|
44664
|
+
}
|
|
44665
|
+
var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
|
|
44666
|
+
"create_python_tool",
|
|
44667
|
+
"update_python_tool",
|
|
44668
|
+
"delete_python_tool",
|
|
44669
|
+
"write_skill",
|
|
44670
|
+
"delete_skill",
|
|
44671
|
+
/*
|
|
44672
|
+
* VBA installed into a workbook runs on this machine as this user, and nobody reviews a macro
|
|
44673
|
+
* afterwards. That is the same act as creating a Python tool, so it gets the same rule: a
|
|
44674
|
+
* human sees the source once, and no category toggle can stand in for that.
|
|
44675
|
+
*/
|
|
44676
|
+
"excel_write_macro",
|
|
44677
|
+
/*
|
|
44678
|
+
* Running a macro executes somebody else's VBA as the user: it can rewrite the workbook, write
|
|
44679
|
+
* files, or send mail. That is not something a category toggle should ever cover, and the
|
|
44680
|
+
* approval showing the actual source is the only thing standing between "run DoTheThing" and
|
|
44681
|
+
* whatever DoTheThing does.
|
|
44682
|
+
*/
|
|
44683
|
+
"excel_run_macro",
|
|
44684
|
+
/*
|
|
44685
|
+
* The plan is what holds the assistant to work the user agreed, so a category toggle must
|
|
44686
|
+
* never stand in for reading the change. Auto-approving this would mean an agent could widen
|
|
44687
|
+
* its own instructions and then point at them as authority — and both the panel and the
|
|
44688
|
+
* prompt would look right afterwards, because both would be reading the new plan.
|
|
44689
|
+
*/
|
|
44690
|
+
"update_plan",
|
|
44691
|
+
/*
|
|
44692
|
+
* A role's prompt is prose injected into a model that then advises on this repository's code —
|
|
44693
|
+
* the reason `agents` is user-scope only. Softening a reviewer does not error; it approves
|
|
44694
|
+
* things, in the same tone as before. A category toggle must never stand in for reading that
|
|
44695
|
+
* diff.
|
|
44696
|
+
*/
|
|
44697
|
+
"update_role",
|
|
44698
|
+
// Inventing one is the same act as rewriting one: a prompt that will advise on this code.
|
|
44699
|
+
"create_role",
|
|
44700
|
+
// And removing one takes a prompt somebody wrote with it.
|
|
44701
|
+
"delete_role"
|
|
44702
|
+
]);
|
|
44703
|
+
function decideFromPolicy(request, approvals) {
|
|
44704
|
+
if (!requiresApproval(request.group))
|
|
44705
|
+
return "approve";
|
|
44706
|
+
if (ALWAYS_ASK_TOOLS.has(request.toolName))
|
|
44707
|
+
return void 0;
|
|
44708
|
+
if (approvals === void 0)
|
|
44709
|
+
return void 0;
|
|
44710
|
+
if (approvals.allowedTools?.includes(request.toolName) === true)
|
|
44711
|
+
return "approve";
|
|
44712
|
+
if (request.group === "command") {
|
|
44713
|
+
const command = commandFromPreview(request.preview);
|
|
44714
|
+
if (command !== void 0 && isCommandAllowlisted(command, approvals.allowedCommands ?? [])) {
|
|
44715
|
+
return "approve";
|
|
44716
|
+
}
|
|
44717
|
+
}
|
|
44718
|
+
return categoryEnabled(request.group, approvals.autoApprove) ? "approve" : void 0;
|
|
44719
|
+
}
|
|
44720
|
+
function commandFromPreview(preview) {
|
|
44721
|
+
return preview.kind === "command" ? preview.command : void 0;
|
|
44722
|
+
}
|
|
44723
|
+
var PolicyApprovalGate = class {
|
|
44724
|
+
inner;
|
|
44725
|
+
getApprovals;
|
|
44726
|
+
constructor(inner, getApprovals) {
|
|
44727
|
+
this.inner = inner;
|
|
44728
|
+
this.getApprovals = getApprovals;
|
|
44729
|
+
}
|
|
44730
|
+
async requestApproval(request) {
|
|
44731
|
+
const decided = decideFromPolicy(request, this.getApprovals());
|
|
44732
|
+
if (decided !== void 0)
|
|
44733
|
+
return decided;
|
|
44734
|
+
return this.inner.requestApproval(request);
|
|
44735
|
+
}
|
|
44736
|
+
};
|
|
44737
|
+
|
|
44541
44738
|
// ../../packages/core/dist/agents/consult.js
|
|
44542
44739
|
var CONSULT_MAX_STEPS = 5;
|
|
44543
44740
|
var ALLOWED_GROUPS = /* @__PURE__ */ new Set(["read"]);
|
|
44544
|
-
function toolsForConsultation(all) {
|
|
44545
|
-
return all.filter((tool) => ALLOWED_GROUPS.has(tool.group) && tool.name !== "ask_agent" && tool.name !== "ask_expert");
|
|
44741
|
+
function toolsForConsultation(all, extra = /* @__PURE__ */ new Set()) {
|
|
44742
|
+
return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !== "ask_expert");
|
|
44546
44743
|
}
|
|
44547
44744
|
async function runConsultation(options) {
|
|
44548
44745
|
const limit = options.maxSteps ?? CONSULT_MAX_STEPS;
|
|
@@ -44592,7 +44789,10 @@ async function runConsultation(options) {
|
|
|
44592
44789
|
}
|
|
44593
44790
|
try {
|
|
44594
44791
|
const parsed = tool.parametersSchema.safeParse(JSON.parse(call.arguments || "{}"));
|
|
44595
|
-
const
|
|
44792
|
+
const permitted = tool.group === "read" && !ALWAYS_ASK_TOOLS.has(tool.name) || options.approve !== void 0 && await options.approve(tool, parsed.data);
|
|
44793
|
+
const result = !permitted ? {
|
|
44794
|
+
content: `The user did not approve ${tool.name}. Say what you would have written and why, and let the assistant put it to them instead.`
|
|
44795
|
+
} : parsed.success ? await tool.execute(parsed.data, options.context) : {
|
|
44596
44796
|
content: `Those arguments are not valid: ${parsed.error.issues.map((i) => i.message).join("; ")}`
|
|
44597
44797
|
};
|
|
44598
44798
|
messages.push({ role: "tool", toolCallId: call.id, content: String(result.content) });
|
|
@@ -48578,7 +48778,12 @@ var NEVER_AVAILABLE_TO_SCHEDULES = [
|
|
|
48578
48778
|
* Rewriting the plan it is being held to, with nobody there to approve the diff. Same ladder
|
|
48579
48779
|
* as `schedule_prompt`: a run that can change its own instructions is bounded by nothing.
|
|
48580
48780
|
*/
|
|
48581
|
-
"update_plan"
|
|
48781
|
+
"update_plan",
|
|
48782
|
+
// Rewriting what a specialist is, unattended. The same ladder: a run that can redefine its own
|
|
48783
|
+
// reviewer can arrange to be reviewed favourably by the next one.
|
|
48784
|
+
"update_role",
|
|
48785
|
+
"create_role",
|
|
48786
|
+
"delete_role"
|
|
48582
48787
|
];
|
|
48583
48788
|
function scheduleAppliesHere(schedule, workspaceRoot) {
|
|
48584
48789
|
if (schedule.workspaceRoot === void 0)
|
|
@@ -49750,93 +49955,6 @@ async function indexWorkspace(options) {
|
|
|
49750
49955
|
};
|
|
49751
49956
|
}
|
|
49752
49957
|
|
|
49753
|
-
// ../../packages/core/dist/approval/types.js
|
|
49754
|
-
function requiresApproval(group) {
|
|
49755
|
-
return group !== "always";
|
|
49756
|
-
}
|
|
49757
|
-
|
|
49758
|
-
// ../../packages/core/dist/approval/commands.js
|
|
49759
|
-
function isCommandAllowlisted(command, allowlist) {
|
|
49760
|
-
return allowlist.includes(command);
|
|
49761
|
-
}
|
|
49762
|
-
function addToAllowlist(command, allowlist) {
|
|
49763
|
-
return allowlist.includes(command) ? [...allowlist] : [...allowlist, command];
|
|
49764
|
-
}
|
|
49765
|
-
function removeFromAllowlist(command, allowlist) {
|
|
49766
|
-
return allowlist.filter((entry) => entry !== command);
|
|
49767
|
-
}
|
|
49768
|
-
|
|
49769
|
-
// ../../packages/core/dist/approval/policy.js
|
|
49770
|
-
function isApprovableGroup(group) {
|
|
49771
|
-
return group === "read" || group === "edit" || group === "command" || group === "mcp";
|
|
49772
|
-
}
|
|
49773
|
-
function categoryEnabled(group, settings) {
|
|
49774
|
-
if (settings === void 0 || !isApprovableGroup(group))
|
|
49775
|
-
return false;
|
|
49776
|
-
return settings[group] === true;
|
|
49777
|
-
}
|
|
49778
|
-
var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
|
|
49779
|
-
"create_python_tool",
|
|
49780
|
-
"update_python_tool",
|
|
49781
|
-
"delete_python_tool",
|
|
49782
|
-
"write_skill",
|
|
49783
|
-
"delete_skill",
|
|
49784
|
-
/*
|
|
49785
|
-
* VBA installed into a workbook runs on this machine as this user, and nobody reviews a macro
|
|
49786
|
-
* afterwards. That is the same act as creating a Python tool, so it gets the same rule: a
|
|
49787
|
-
* human sees the source once, and no category toggle can stand in for that.
|
|
49788
|
-
*/
|
|
49789
|
-
"excel_write_macro",
|
|
49790
|
-
/*
|
|
49791
|
-
* Running a macro executes somebody else's VBA as the user: it can rewrite the workbook, write
|
|
49792
|
-
* files, or send mail. That is not something a category toggle should ever cover, and the
|
|
49793
|
-
* approval showing the actual source is the only thing standing between "run DoTheThing" and
|
|
49794
|
-
* whatever DoTheThing does.
|
|
49795
|
-
*/
|
|
49796
|
-
"excel_run_macro",
|
|
49797
|
-
/*
|
|
49798
|
-
* The plan is what holds the assistant to work the user agreed, so a category toggle must
|
|
49799
|
-
* never stand in for reading the change. Auto-approving this would mean an agent could widen
|
|
49800
|
-
* its own instructions and then point at them as authority — and both the panel and the
|
|
49801
|
-
* prompt would look right afterwards, because both would be reading the new plan.
|
|
49802
|
-
*/
|
|
49803
|
-
"update_plan"
|
|
49804
|
-
]);
|
|
49805
|
-
function decideFromPolicy(request, approvals) {
|
|
49806
|
-
if (!requiresApproval(request.group))
|
|
49807
|
-
return "approve";
|
|
49808
|
-
if (ALWAYS_ASK_TOOLS.has(request.toolName))
|
|
49809
|
-
return void 0;
|
|
49810
|
-
if (approvals === void 0)
|
|
49811
|
-
return void 0;
|
|
49812
|
-
if (approvals.allowedTools?.includes(request.toolName) === true)
|
|
49813
|
-
return "approve";
|
|
49814
|
-
if (request.group === "command") {
|
|
49815
|
-
const command = commandFromPreview(request.preview);
|
|
49816
|
-
if (command !== void 0 && isCommandAllowlisted(command, approvals.allowedCommands ?? [])) {
|
|
49817
|
-
return "approve";
|
|
49818
|
-
}
|
|
49819
|
-
}
|
|
49820
|
-
return categoryEnabled(request.group, approvals.autoApprove) ? "approve" : void 0;
|
|
49821
|
-
}
|
|
49822
|
-
function commandFromPreview(preview) {
|
|
49823
|
-
return preview.kind === "command" ? preview.command : void 0;
|
|
49824
|
-
}
|
|
49825
|
-
var PolicyApprovalGate = class {
|
|
49826
|
-
inner;
|
|
49827
|
-
getApprovals;
|
|
49828
|
-
constructor(inner, getApprovals) {
|
|
49829
|
-
this.inner = inner;
|
|
49830
|
-
this.getApprovals = getApprovals;
|
|
49831
|
-
}
|
|
49832
|
-
async requestApproval(request) {
|
|
49833
|
-
const decided = decideFromPolicy(request, this.getApprovals());
|
|
49834
|
-
if (decided !== void 0)
|
|
49835
|
-
return decided;
|
|
49836
|
-
return this.inner.requestApproval(request);
|
|
49837
|
-
}
|
|
49838
|
-
};
|
|
49839
|
-
|
|
49840
49958
|
// ../../packages/core/dist/checkpoints/shadowGit.js
|
|
49841
49959
|
import { execFile as execFile2 } from "node:child_process";
|
|
49842
49960
|
import fs7 from "node:fs/promises";
|
|
@@ -57131,6 +57249,29 @@ function looksUnfinished(text) {
|
|
|
57131
57249
|
var CONTINUE_PROMPT = "You described what you were about to do but did not call a tool, so nothing happened. If you meant to act, call the tool now. If you were already finished, call attempt_completion with a summary instead.";
|
|
57132
57250
|
var MAX_CONTINUE_NUDGES = 1;
|
|
57133
57251
|
|
|
57252
|
+
// ../../packages/core/dist/agent/repairHistory.js
|
|
57253
|
+
var UNANSWERED = "This tool call never reported a result \u2014 the turn ended before it did. Nothing can be assumed about whether it ran or what it changed. If it still matters, call it again; otherwise carry on.";
|
|
57254
|
+
function repairUnansweredToolCalls(messages) {
|
|
57255
|
+
const answered = /* @__PURE__ */ new Set();
|
|
57256
|
+
for (const message3 of messages) {
|
|
57257
|
+
if (message3.role === "tool" && message3.toolCallId !== void 0)
|
|
57258
|
+
answered.add(message3.toolCallId);
|
|
57259
|
+
}
|
|
57260
|
+
const repaired = [];
|
|
57261
|
+
for (const message3 of messages) {
|
|
57262
|
+
repaired.push(message3);
|
|
57263
|
+
if (message3.role !== "assistant" || message3.toolCalls === void 0)
|
|
57264
|
+
continue;
|
|
57265
|
+
for (const call of message3.toolCalls) {
|
|
57266
|
+
if (answered.has(call.id))
|
|
57267
|
+
continue;
|
|
57268
|
+
repaired.push({ role: "tool", toolCallId: call.id, content: UNANSWERED });
|
|
57269
|
+
answered.add(call.id);
|
|
57270
|
+
}
|
|
57271
|
+
}
|
|
57272
|
+
return repaired;
|
|
57273
|
+
}
|
|
57274
|
+
|
|
57134
57275
|
// ../../packages/core/dist/agent/truncate.js
|
|
57135
57276
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
57136
57277
|
import fs14 from "node:fs/promises";
|
|
@@ -57228,7 +57369,7 @@ var MAX_REFUNDED_STEPS = 20;
|
|
|
57228
57369
|
var MAX_CONSECUTIVE_MISTAKES = 3;
|
|
57229
57370
|
async function prepareModelMessages(conversation, provider, tools, options, events) {
|
|
57230
57371
|
const contextWindow = options.contextWindow ?? 0;
|
|
57231
|
-
let messages = conversation.toModelMessages();
|
|
57372
|
+
let messages = repairUnansweredToolCalls(conversation.toModelMessages());
|
|
57232
57373
|
if (options.compactionEnabled !== false && contextWindow > 0) {
|
|
57233
57374
|
const estimated = computeBreakdown(messages, tools, contextWindow).total;
|
|
57234
57375
|
if (shouldCompact(messages, estimated, contextWindow, options.compaction ?? {})) {
|
|
@@ -57238,7 +57379,7 @@ async function prepareModelMessages(conversation, provider, tools, options, even
|
|
|
57238
57379
|
if (summary !== void 0) {
|
|
57239
57380
|
conversation.applyCompaction(summary, conversation.compactedCount() + result.summarisedCount);
|
|
57240
57381
|
events.onCompacted?.(result.summarisedCount);
|
|
57241
|
-
messages = conversation.toModelMessages();
|
|
57382
|
+
messages = repairUnansweredToolCalls(conversation.toModelMessages());
|
|
57242
57383
|
}
|
|
57243
57384
|
}
|
|
57244
57385
|
}
|
|
@@ -57458,12 +57599,20 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
|
|
|
57458
57599
|
}
|
|
57459
57600
|
conversation.addAssistantMessage(assistantText, [toolCall]);
|
|
57460
57601
|
events.onToolCall(toolCall);
|
|
57461
|
-
|
|
57462
|
-
|
|
57463
|
-
|
|
57464
|
-
|
|
57465
|
-
|
|
57466
|
-
|
|
57602
|
+
let result;
|
|
57603
|
+
try {
|
|
57604
|
+
result = await runOneToolCall(toolCall, toolRegistry, toolContext, options, events, {
|
|
57605
|
+
hasCheckpoint: () => checkpointTaken,
|
|
57606
|
+
markCheckpointTaken: () => {
|
|
57607
|
+
checkpointTaken = true;
|
|
57608
|
+
}
|
|
57609
|
+
}, mode);
|
|
57610
|
+
} catch (error51) {
|
|
57611
|
+
result = {
|
|
57612
|
+
content: `"${toolCall.name}" failed: ${error51 instanceof Error ? error51.message : String(error51)}`,
|
|
57613
|
+
isError: true
|
|
57614
|
+
};
|
|
57615
|
+
}
|
|
57467
57616
|
const forModel = options.truncationStore !== void 0 ? (await truncateToolResult(result.content, options.truncationStore)).content : result.content;
|
|
57468
57617
|
conversation.addToolResultMessage(toolCall.id, forModel);
|
|
57469
57618
|
events.onToolResult(toolCall, result);
|
|
@@ -59547,6 +59696,232 @@ var OfficeBridge = class {
|
|
|
59547
59696
|
}
|
|
59548
59697
|
};
|
|
59549
59698
|
|
|
59699
|
+
// ../../packages/core/dist/tools/roleTools.js
|
|
59700
|
+
var readParams = external_exports.object({
|
|
59701
|
+
role: external_exports.string().describe("Which role to read \u2014 one of the roles configured here. Omit to list them all.").optional()
|
|
59702
|
+
});
|
|
59703
|
+
function createReadRolePromptTool(access) {
|
|
59704
|
+
return {
|
|
59705
|
+
name: "read_role_prompt",
|
|
59706
|
+
group: "read",
|
|
59707
|
+
description: "Read a specialist role's current system prompt \u2014 what it is told it is. Call this before changing one, so the change is an edit to what the user wrote rather than a replacement for it. With no role, lists the roles that exist here.",
|
|
59708
|
+
parametersSchema: readParams,
|
|
59709
|
+
async execute(params) {
|
|
59710
|
+
const roles = access.list();
|
|
59711
|
+
if (params.role === void 0) {
|
|
59712
|
+
if (roles.length === 0)
|
|
59713
|
+
return { content: "No roles are configured." };
|
|
59714
|
+
return {
|
|
59715
|
+
content: roles.map((entry) => `- ${entry.role} (${entry.name})` + (entry.assigned ? "" : " \u2014 nobody assigned") + (entry.edited ? " \u2014 prompt edited" : " \u2014 default prompt")).join("\n")
|
|
59716
|
+
};
|
|
59717
|
+
}
|
|
59718
|
+
const role = params.role.trim().toLowerCase();
|
|
59719
|
+
const prompt = access.current(role);
|
|
59720
|
+
if (prompt === void 0) {
|
|
59721
|
+
return {
|
|
59722
|
+
content: `There is no "${role}" role. The roles here are: ${roles.map((entry) => entry.role).join(", ")}.`,
|
|
59723
|
+
isError: true
|
|
59724
|
+
};
|
|
59725
|
+
}
|
|
59726
|
+
const edited = roles.find((entry) => entry.role === role)?.edited === true;
|
|
59727
|
+
return {
|
|
59728
|
+
content: `The ${role}'s prompt${edited ? " (edited by the user)" : " (the default)"}:
|
|
59729
|
+
|
|
59730
|
+
${prompt}`
|
|
59731
|
+
};
|
|
59732
|
+
}
|
|
59733
|
+
};
|
|
59734
|
+
}
|
|
59735
|
+
var updateParams2 = external_exports.object({
|
|
59736
|
+
role: external_exports.string().describe("Which role to change."),
|
|
59737
|
+
prompt: external_exports.string().optional().describe("The complete new prompt. It replaces the current one rather than being added to it, so include what is staying. An empty string resets the role to its default prompt; omit it entirely to leave the prompt alone."),
|
|
59738
|
+
/*
|
|
59739
|
+
* Name and summary are editable for the same reason the prompt is: they are how the role
|
|
59740
|
+
* presents itself. The summary especially — it is the line every other specialist sees and the
|
|
59741
|
+
* one the expert allocates from, so a role whose summary is wrong gets used for the wrong work.
|
|
59742
|
+
* Only a user-defined role can change them; a built-in one is what it is.
|
|
59743
|
+
*/
|
|
59744
|
+
name: external_exports.string().optional().describe("A new display name. Custom roles only."),
|
|
59745
|
+
summary: external_exports.string().optional().describe("A new one-line summary of what it is for. Custom roles only. This is what the expert allocates from, so it matters more than the name."),
|
|
59746
|
+
usesTools: external_exports.boolean().optional().describe("Whether it may read and search the workspace. Omit to leave unchanged."),
|
|
59747
|
+
reason: external_exports.string().optional().describe("One line on what is changing and why, shown to the user above the diff.")
|
|
59748
|
+
});
|
|
59749
|
+
function createUpdateRolePromptTool(access) {
|
|
59750
|
+
return {
|
|
59751
|
+
name: "update_role",
|
|
59752
|
+
/*
|
|
59753
|
+
* `edit`, and deliberately not `always`: `decideFromPolicy` approves the `always` group
|
|
59754
|
+
* *before* it consults ALWAYS_ASK_TOOLS, so putting it there would silently auto-approve the
|
|
59755
|
+
* one thing this must always ask about. The same trap `update_plan` nearly fell into.
|
|
59756
|
+
*/
|
|
59757
|
+
group: "edit",
|
|
59758
|
+
description: 'Change a specialist role: its system prompt, and for a role the user invented, its name, its summary, or whether it may read the workspace. Use it when the user says a specialist should behave differently ("make the reviewer stricter about error handling"). Read the role first and edit what is there rather than writing a new prompt from scratch. Only what you pass is changed. The user is shown a diff and must approve it, and it applies to every future consultation of that role.',
|
|
59759
|
+
parametersSchema: updateParams2,
|
|
59760
|
+
async preview(params) {
|
|
59761
|
+
const role = params.role.trim().toLowerCase();
|
|
59762
|
+
const details = access.details(role);
|
|
59763
|
+
const before = describeRole(details, access.current(role) ?? "");
|
|
59764
|
+
const nextPrompt = params.prompt === void 0 ? access.current(role) ?? "" : (
|
|
59765
|
+
// Empty means reset, so the diff shows what the default actually says — otherwise the
|
|
59766
|
+
// approval reads as "delete this prompt" rather than "go back to the built-in one".
|
|
59767
|
+
params.prompt.trim().length === 0 ? access.fallback(role) ?? "" : params.prompt.trim()
|
|
59768
|
+
);
|
|
59769
|
+
const after = describeRole(details === void 0 ? void 0 : {
|
|
59770
|
+
...details,
|
|
59771
|
+
...params.name !== void 0 ? { name: params.name.trim() } : {},
|
|
59772
|
+
...params.summary !== void 0 ? { summary: params.summary.trim() } : {},
|
|
59773
|
+
...params.usesTools !== void 0 ? { usesTools: params.usesTools } : {}
|
|
59774
|
+
}, nextPrompt);
|
|
59775
|
+
return {
|
|
59776
|
+
kind: "diff",
|
|
59777
|
+
path: `the ${role} role`,
|
|
59778
|
+
before,
|
|
59779
|
+
after,
|
|
59780
|
+
...params.reason !== void 0 && params.reason.trim().length > 0 ? { note: params.reason.trim() } : {}
|
|
59781
|
+
};
|
|
59782
|
+
},
|
|
59783
|
+
async execute(params) {
|
|
59784
|
+
const role = params.role.trim().toLowerCase();
|
|
59785
|
+
if (access.current(role) === void 0) {
|
|
59786
|
+
return {
|
|
59787
|
+
content: `There is no "${role}" role. The roles here are: ${access.list().map((entry) => entry.role).join(", ")}.`,
|
|
59788
|
+
isError: true
|
|
59789
|
+
};
|
|
59790
|
+
}
|
|
59791
|
+
const details = access.details(role);
|
|
59792
|
+
const changingIdentity = params.name !== void 0 || params.summary !== void 0 || params.usesTools !== void 0;
|
|
59793
|
+
if (changingIdentity && details?.custom !== true) {
|
|
59794
|
+
return {
|
|
59795
|
+
content: `Only the prompt can be changed on a built-in role. "${role}" is built in, so its name, summary and workspace access are fixed. Create a role of your own if you need a different one.`,
|
|
59796
|
+
isError: true
|
|
59797
|
+
};
|
|
59798
|
+
}
|
|
59799
|
+
if (changingIdentity && details !== void 0) {
|
|
59800
|
+
await access.create({
|
|
59801
|
+
id: details.id,
|
|
59802
|
+
name: params.name?.trim() ?? details.name,
|
|
59803
|
+
summary: params.summary?.trim() ?? details.summary,
|
|
59804
|
+
// Carried over rather than re-sent: this path is about identity, and the prompt has its
|
|
59805
|
+
// own store. Passing the old one back keeps the two from disagreeing.
|
|
59806
|
+
prompt: details.prompt,
|
|
59807
|
+
usesTools: params.usesTools ?? details.usesTools
|
|
59808
|
+
});
|
|
59809
|
+
}
|
|
59810
|
+
if (params.prompt !== void 0) {
|
|
59811
|
+
const next = params.prompt.trim();
|
|
59812
|
+
await access.save(role, next.length === 0 ? void 0 : next);
|
|
59813
|
+
}
|
|
59814
|
+
return {
|
|
59815
|
+
content: `The ${role} is updated and the user approved it. Every consultation of that role from now on uses it.`
|
|
59816
|
+
};
|
|
59817
|
+
}
|
|
59818
|
+
};
|
|
59819
|
+
}
|
|
59820
|
+
var createParams2 = external_exports.object({
|
|
59821
|
+
id: external_exports.string().describe('Short id the assistant will use to reach it, e.g. "security". Lowercase letters, digits and hyphens. It cannot be changed afterwards.'),
|
|
59822
|
+
name: external_exports.string().describe('What to call it in the settings panel, e.g. "Security reviewer".'),
|
|
59823
|
+
summary: external_exports.string().describe("One line on what it is for. Every other specialist sees this, and the expert allocates from it when writing a plan \u2014 so say what it is good for, not what it is."),
|
|
59824
|
+
prompt: external_exports.string().describe("Its system prompt: what it is told it is and how to answer. What it may and may not do is added automatically, so do not write rules about tools or permissions."),
|
|
59825
|
+
usesTools: external_exports.boolean().describe("Whether it may read and search the workspace. True where the answer depends on code the asker cannot paste; false where the question carries everything it needs.")
|
|
59826
|
+
});
|
|
59827
|
+
function createCreateRoleTool(access) {
|
|
59828
|
+
return {
|
|
59829
|
+
name: "create_role",
|
|
59830
|
+
// `edit`, never `always` — see the note on `update_role_prompt`.
|
|
59831
|
+
group: "edit",
|
|
59832
|
+
description: "Create a new specialist role beyond the built-in ones, when the user wants a kind of reviewer or helper the team does not have \u2014 a security reviewer, a performance reviewer, one that knows a particular part of this codebase. A role is its prompt, so write that carefully. The user is shown the whole role and must approve it, and then assigns a model to it in Settings \u2192 Agents before it can answer.",
|
|
59833
|
+
parametersSchema: createParams2,
|
|
59834
|
+
async preview(params) {
|
|
59835
|
+
const { used, limit } = access.capacity();
|
|
59836
|
+
return {
|
|
59837
|
+
kind: "text",
|
|
59838
|
+
text: [
|
|
59839
|
+
`Create the role "${params.id.trim().toLowerCase()}" (${used + 1} of ${limit}).`,
|
|
59840
|
+
"",
|
|
59841
|
+
`Name: ${params.name}`,
|
|
59842
|
+
`For: ${params.summary}`,
|
|
59843
|
+
`Reads: ${params.usesTools ? "yes \u2014 it can read and search the workspace" : "no \u2014 it answers from the question alone"}`,
|
|
59844
|
+
"",
|
|
59845
|
+
"What it is told:",
|
|
59846
|
+
"",
|
|
59847
|
+
params.prompt.trim()
|
|
59848
|
+
].join("\n")
|
|
59849
|
+
};
|
|
59850
|
+
},
|
|
59851
|
+
async execute(params) {
|
|
59852
|
+
const id = params.id.trim().toLowerCase();
|
|
59853
|
+
if (access.current(id) !== void 0) {
|
|
59854
|
+
return {
|
|
59855
|
+
content: `There is already a "${id}" role. Change it with update_role_prompt rather than creating it again.`,
|
|
59856
|
+
isError: true
|
|
59857
|
+
};
|
|
59858
|
+
}
|
|
59859
|
+
try {
|
|
59860
|
+
await access.create({ ...params, id });
|
|
59861
|
+
} catch (error51) {
|
|
59862
|
+
return {
|
|
59863
|
+
content: error51 instanceof Error ? error51.message : String(error51),
|
|
59864
|
+
isError: true
|
|
59865
|
+
};
|
|
59866
|
+
}
|
|
59867
|
+
return {
|
|
59868
|
+
content: `The ${id} role exists and the user approved it. Nobody answers it yet \u2014 it needs a model assigned in Settings \u2192 Agents before it can be consulted. Tell the user that.`
|
|
59869
|
+
};
|
|
59870
|
+
}
|
|
59871
|
+
};
|
|
59872
|
+
}
|
|
59873
|
+
function describeRole(details, prompt) {
|
|
59874
|
+
if (details === void 0)
|
|
59875
|
+
return prompt;
|
|
59876
|
+
return [
|
|
59877
|
+
`Name: ${details.name}`,
|
|
59878
|
+
`For: ${details.summary}`,
|
|
59879
|
+
`Reads: ${details.usesTools ? "yes" : "no"}`,
|
|
59880
|
+
"",
|
|
59881
|
+
prompt
|
|
59882
|
+
].join("\n");
|
|
59883
|
+
}
|
|
59884
|
+
var deleteParams3 = external_exports.object({
|
|
59885
|
+
role: external_exports.string().describe("Which custom role to remove. Built-in roles cannot be deleted.")
|
|
59886
|
+
});
|
|
59887
|
+
function createDeleteRoleTool(access) {
|
|
59888
|
+
return {
|
|
59889
|
+
name: "delete_role",
|
|
59890
|
+
group: "edit",
|
|
59891
|
+
description: "Remove a role the user invented, along with whatever model was assigned to it. Built-in roles cannot be removed. The user is shown the role, including its prompt, and must approve. Nothing else refers to it afterwards, so any plan step naming it should be revised in the same turn.",
|
|
59892
|
+
parametersSchema: deleteParams3,
|
|
59893
|
+
async preview(params) {
|
|
59894
|
+
const role = params.role.trim().toLowerCase();
|
|
59895
|
+
const details = access.details(role);
|
|
59896
|
+
return {
|
|
59897
|
+
kind: "text",
|
|
59898
|
+
text: details === void 0 ? `There is no "${role}" role to delete.` : [
|
|
59899
|
+
`Delete the "${details.id}" role and its assignment.`,
|
|
59900
|
+
"",
|
|
59901
|
+
describeRole(details, details.prompt),
|
|
59902
|
+
"",
|
|
59903
|
+
"The prompt above is removed with it."
|
|
59904
|
+
].join("\n")
|
|
59905
|
+
};
|
|
59906
|
+
},
|
|
59907
|
+
async execute(params) {
|
|
59908
|
+
const role = params.role.trim().toLowerCase();
|
|
59909
|
+
const details = access.details(role);
|
|
59910
|
+
if (details === void 0) {
|
|
59911
|
+
return { content: `There is no "${role}" role.`, isError: true };
|
|
59912
|
+
}
|
|
59913
|
+
if (!details.custom) {
|
|
59914
|
+
return {
|
|
59915
|
+
content: `"${role}" is one of the built-in roles and cannot be deleted. Leave it unassigned if it should not be used.`,
|
|
59916
|
+
isError: true
|
|
59917
|
+
};
|
|
59918
|
+
}
|
|
59919
|
+
await access.remove(role);
|
|
59920
|
+
return { content: `The ${role} role is gone, and so is its assignment.` };
|
|
59921
|
+
}
|
|
59922
|
+
};
|
|
59923
|
+
}
|
|
59924
|
+
|
|
59550
59925
|
// ../../packages/core/dist/office/vbaCheck.js
|
|
59551
59926
|
function splitLine(line) {
|
|
59552
59927
|
let bare = "";
|
|
@@ -60743,6 +61118,54 @@ ${preview.text}` } : {}
|
|
|
60743
61118
|
post({ type: "plan", plan: activePlan ?? "" });
|
|
60744
61119
|
postPlanProgress();
|
|
60745
61120
|
}
|
|
61121
|
+
const rolePromptAccess = {
|
|
61122
|
+
list: () => knownRoles(cachedAgentDefinitions).map((role) => ({
|
|
61123
|
+
role,
|
|
61124
|
+
name: roleInfo(role, cachedAgentDefinitions).name,
|
|
61125
|
+
assigned: cachedTeam.some((agent) => agent.role === role),
|
|
61126
|
+
edited: cachedAgentRoles?.[role]?.prompt !== void 0
|
|
61127
|
+
})),
|
|
61128
|
+
current: (role) => {
|
|
61129
|
+
if (!isAgentRole(role, cachedAgentDefinitions))
|
|
61130
|
+
return void 0;
|
|
61131
|
+
return cachedAgentRoles?.[role]?.prompt ?? defaultPromptFor(role, cachedAgentDefinitions);
|
|
61132
|
+
},
|
|
61133
|
+
fallback: (role) => isAgentRole(role, cachedAgentDefinitions) ? defaultPromptFor(role, cachedAgentDefinitions) : void 0,
|
|
61134
|
+
details: (role) => {
|
|
61135
|
+
if (!isAgentRole(role, cachedAgentDefinitions))
|
|
61136
|
+
return void 0;
|
|
61137
|
+
const info = roleInfo(role, cachedAgentDefinitions);
|
|
61138
|
+
return {
|
|
61139
|
+
id: role,
|
|
61140
|
+
name: info.name,
|
|
61141
|
+
summary: info.summary,
|
|
61142
|
+
prompt: cachedAgentRoles?.[role]?.prompt ?? info.prompt,
|
|
61143
|
+
usesTools: cachedAgentRoles?.[role]?.tools ?? info.usesTools,
|
|
61144
|
+
custom: cachedAgentDefinitions.some((definition) => definition.id === role)
|
|
61145
|
+
};
|
|
61146
|
+
},
|
|
61147
|
+
remove: async (role) => {
|
|
61148
|
+
await handleDeleteCustomRole(role);
|
|
61149
|
+
},
|
|
61150
|
+
create: async (role) => {
|
|
61151
|
+
await handleSaveCustomRole(role);
|
|
61152
|
+
},
|
|
61153
|
+
capacity: () => ({ used: cachedAgentDefinitions.length, limit: CUSTOM_ROLE_LIMIT }),
|
|
61154
|
+
save: async (role, prompt) => {
|
|
61155
|
+
await saveAgents((current) => {
|
|
61156
|
+
const roles = { ...current.roles ?? {} };
|
|
61157
|
+
const existing = roles[role] ?? { kind: "profile" };
|
|
61158
|
+
if (prompt === void 0) {
|
|
61159
|
+
const rest = { ...existing };
|
|
61160
|
+
delete rest.prompt;
|
|
61161
|
+
roles[role] = rest;
|
|
61162
|
+
} else {
|
|
61163
|
+
roles[role] = { ...existing, prompt };
|
|
61164
|
+
}
|
|
61165
|
+
return { ...current, roles };
|
|
61166
|
+
});
|
|
61167
|
+
}
|
|
61168
|
+
};
|
|
60746
61169
|
const planAccess = {
|
|
60747
61170
|
current: () => activePlan,
|
|
60748
61171
|
save: async (nextPlan) => {
|
|
@@ -61010,6 +61433,8 @@ ${preview.text}` } : {}
|
|
|
61010
61433
|
let cachedCodeGenerator;
|
|
61011
61434
|
let cachedTeam = [];
|
|
61012
61435
|
let cachedTeamGuidance;
|
|
61436
|
+
let cachedAgentRoles;
|
|
61437
|
+
let cachedAgentDefinitions = [];
|
|
61013
61438
|
let cachedBudgetMatters = false;
|
|
61014
61439
|
let cachedMentionExcludes;
|
|
61015
61440
|
let cachedReportsCost;
|
|
@@ -61060,6 +61485,8 @@ ${preview.text}` } : {}
|
|
|
61060
61485
|
cliAvailable: expertCli?.available === true
|
|
61061
61486
|
};
|
|
61062
61487
|
cachedTeam = resolveTeam(teamContext);
|
|
61488
|
+
cachedAgentRoles = config2.agents?.roles;
|
|
61489
|
+
cachedAgentDefinitions = config2.agents?.definitions ?? [];
|
|
61063
61490
|
cachedTeamGuidance = config2.agents?.teamGuidance;
|
|
61064
61491
|
cachedBudgetMatters = budgetMatters(teamContext);
|
|
61065
61492
|
cachedProgrammingProfileId = config2.programmingProfileId;
|
|
@@ -61213,6 +61640,10 @@ ${preview.text}` } : {}
|
|
|
61213
61640
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
61214
61641
|
combined.register(createUpdatePlanTool(planAccess), { dispatchOnly: dispatcher });
|
|
61215
61642
|
combined.register(createPlanProgressTool(planAccess), { dispatchOnly: dispatcher });
|
|
61643
|
+
combined.register(createReadRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61644
|
+
combined.register(createUpdateRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61645
|
+
combined.register(createCreateRoleTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61646
|
+
combined.register(createDeleteRoleTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61216
61647
|
combined.register(createNotifyTool({
|
|
61217
61648
|
notify: (message3, level, details) => {
|
|
61218
61649
|
if (details !== void 0) {
|
|
@@ -61957,7 +62388,7 @@ ${preview.text}` } : {}
|
|
|
61957
62388
|
}
|
|
61958
62389
|
if (input.authType === "none")
|
|
61959
62390
|
return { type: "none" };
|
|
61960
|
-
const typed = input.apiKey.trim();
|
|
62391
|
+
const typed = (input.apiKey ?? "").trim();
|
|
61961
62392
|
if (describeSecretRef(typed).kind === "env") {
|
|
61962
62393
|
await secrets.delete(apiKeyRefFor(id));
|
|
61963
62394
|
return { type: "apiKey", apiKeyRef: typed };
|
|
@@ -62111,6 +62542,19 @@ ${preview.text}` } : {}
|
|
|
62111
62542
|
}
|
|
62112
62543
|
}
|
|
62113
62544
|
async function profileFromForm(input) {
|
|
62545
|
+
const fieldErrors = validateProviderForm({
|
|
62546
|
+
label: input.label,
|
|
62547
|
+
wireFormat: input.wireFormat,
|
|
62548
|
+
baseUrl: input.baseUrl,
|
|
62549
|
+
model: input.model
|
|
62550
|
+
});
|
|
62551
|
+
if (fieldErrors.length > 0) {
|
|
62552
|
+
post({
|
|
62553
|
+
type: "error",
|
|
62554
|
+
message: fieldErrors.map((issue2) => `${issue2.path}: ${issue2.message}`).join("; ")
|
|
62555
|
+
});
|
|
62556
|
+
return void 0;
|
|
62557
|
+
}
|
|
62114
62558
|
const baseUrl = input.baseUrl.trim();
|
|
62115
62559
|
if (baseUrl.length === 0) {
|
|
62116
62560
|
post({ type: "error", message: "Enter a base URL first." });
|
|
@@ -62195,7 +62639,9 @@ ${preview.text}` } : {}
|
|
|
62195
62639
|
cliAvailable: cli?.available === true
|
|
62196
62640
|
};
|
|
62197
62641
|
const assigned = new Map(resolveTeam(teamContext).map((agent) => [agent.role, agent]));
|
|
62198
|
-
const
|
|
62642
|
+
const definitions = config2.agents?.definitions ?? [];
|
|
62643
|
+
const customIds = new Set(definitions.map((definition) => definition.id));
|
|
62644
|
+
const roles = allRoles(definitions).map((info) => {
|
|
62199
62645
|
const agent = assigned.get(info.role);
|
|
62200
62646
|
const prompt = config2.agents?.roles?.[info.role]?.prompt;
|
|
62201
62647
|
return {
|
|
@@ -62207,8 +62653,14 @@ ${preview.text}` } : {}
|
|
|
62207
62653
|
label: agent?.label ?? "Nobody",
|
|
62208
62654
|
available: agent?.available ?? false,
|
|
62209
62655
|
...agent?.reason !== void 0 ? { reason: agent.reason } : {},
|
|
62210
|
-
prompt: prompt ?? defaultPromptFor(info.role),
|
|
62211
|
-
promptIsDefault: prompt === void 0
|
|
62656
|
+
prompt: prompt ?? defaultPromptFor(info.role, definitions),
|
|
62657
|
+
promptIsDefault: prompt === void 0,
|
|
62658
|
+
...customIds.has(info.role) ? { custom: true } : {},
|
|
62659
|
+
// The assignment's override where there is one, else the role's own default — the same
|
|
62660
|
+
// resolution `resolveTeam` does, so the switch in the tab shows what will actually happen.
|
|
62661
|
+
usesTools: config2.agents?.roles?.[info.role]?.tools ?? info.usesTools,
|
|
62662
|
+
canWrite: config2.agents?.roles?.[info.role]?.write ?? info.canWrite,
|
|
62663
|
+
enabled: config2.agents?.roles?.[info.role]?.enabled !== false
|
|
62212
62664
|
};
|
|
62213
62665
|
});
|
|
62214
62666
|
const guidance = config2.agents?.teamGuidance;
|
|
@@ -62237,6 +62689,51 @@ ${preview.text}` } : {}
|
|
|
62237
62689
|
}
|
|
62238
62690
|
});
|
|
62239
62691
|
}
|
|
62692
|
+
async function handleSaveCustomRole(role) {
|
|
62693
|
+
const id = role.id.trim().toLowerCase();
|
|
62694
|
+
if (!isValidRoleId(id)) {
|
|
62695
|
+
post({
|
|
62696
|
+
type: "error",
|
|
62697
|
+
message: `"${id}" is not a usable role id. Use lowercase letters, digits and hyphens, starting with a letter, and not the name of a built-in role.`
|
|
62698
|
+
});
|
|
62699
|
+
return;
|
|
62700
|
+
}
|
|
62701
|
+
if (role.name.trim().length === 0) {
|
|
62702
|
+
post({ type: "error", message: "A role needs a name." });
|
|
62703
|
+
return;
|
|
62704
|
+
}
|
|
62705
|
+
await saveAgents((current) => {
|
|
62706
|
+
const definitions = [...current.definitions ?? []];
|
|
62707
|
+
const at = definitions.findIndex((candidate) => candidate.id === id);
|
|
62708
|
+
const next = {
|
|
62709
|
+
id,
|
|
62710
|
+
name: role.name.trim(),
|
|
62711
|
+
summary: role.summary.trim(),
|
|
62712
|
+
prompt: role.prompt.trim(),
|
|
62713
|
+
usesTools: role.usesTools,
|
|
62714
|
+
canWrite: role.canWrite === true
|
|
62715
|
+
};
|
|
62716
|
+
if (at === -1) {
|
|
62717
|
+
if (definitions.length >= CUSTOM_ROLE_LIMIT) {
|
|
62718
|
+
throw new Error(`That would be ${String(definitions.length + 1)} custom roles. The limit is ${String(CUSTOM_ROLE_LIMIT)}: the expert allocates from this list, and its judgement is what a longer one costs.`);
|
|
62719
|
+
}
|
|
62720
|
+
definitions.push(next);
|
|
62721
|
+
} else
|
|
62722
|
+
definitions[at] = next;
|
|
62723
|
+
return { ...current, definitions };
|
|
62724
|
+
});
|
|
62725
|
+
}
|
|
62726
|
+
async function handleDeleteCustomRole(id) {
|
|
62727
|
+
await saveAgents((current) => {
|
|
62728
|
+
const roles = { ...current.roles ?? {} };
|
|
62729
|
+
delete roles[id];
|
|
62730
|
+
return {
|
|
62731
|
+
...current,
|
|
62732
|
+
roles,
|
|
62733
|
+
definitions: (current.definitions ?? []).filter((candidate) => candidate.id !== id)
|
|
62734
|
+
};
|
|
62735
|
+
});
|
|
62736
|
+
}
|
|
62240
62737
|
async function saveAgents(change) {
|
|
62241
62738
|
try {
|
|
62242
62739
|
const { config: config2 } = await configManager.load();
|
|
@@ -64268,6 +64765,7 @@ ${preview.text}` } : {}
|
|
|
64268
64765
|
// disagree — a specialist told it can read, and then given nothing to read with, wastes a
|
|
64269
64766
|
// step discovering that.
|
|
64270
64767
|
usesTools: agent.usesTools,
|
|
64768
|
+
canWrite: agent.canWrite,
|
|
64271
64769
|
...request.files !== void 0 ? { files: request.files } : {},
|
|
64272
64770
|
/*
|
|
64273
64771
|
* What exists in this workspace.
|
|
@@ -64296,6 +64794,11 @@ ${preview.text}` } : {}
|
|
|
64296
64794
|
const cli = expertCli;
|
|
64297
64795
|
if (cli === void 0 || !cli.available)
|
|
64298
64796
|
throw new Error("The Claude CLI is not available.");
|
|
64797
|
+
if (cachedBudgetMatters) {
|
|
64798
|
+
const verdict = checkExpertBudget(expertSpend, effectiveExpertLimits());
|
|
64799
|
+
if (!verdict.allowed)
|
|
64800
|
+
throw new Error(verdict.message);
|
|
64801
|
+
}
|
|
64299
64802
|
const answer = await consultExpert(cli, {
|
|
64300
64803
|
question: prompt,
|
|
64301
64804
|
/*
|
|
@@ -64306,6 +64809,10 @@ ${preview.text}` } : {}
|
|
|
64306
64809
|
cwd: workspaceRoot ?? process.cwd(),
|
|
64307
64810
|
...request.signal !== void 0 ? { signal: request.signal } : {}
|
|
64308
64811
|
});
|
|
64812
|
+
recordConsultation({
|
|
64813
|
+
isError: answer.isError,
|
|
64814
|
+
...answer.costUsd !== void 0 ? { costUsd: answer.costUsd } : {}
|
|
64815
|
+
});
|
|
64309
64816
|
if (answer.isError)
|
|
64310
64817
|
throw new Error(answer.text);
|
|
64311
64818
|
return { advice: answer.text, label: agent.label };
|
|
@@ -64316,7 +64823,13 @@ ${preview.text}` } : {}
|
|
|
64316
64823
|
throw new Error(`No profile "${agent.profileId ?? ""}" exists any more.`);
|
|
64317
64824
|
}
|
|
64318
64825
|
const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
|
|
64319
|
-
const
|
|
64826
|
+
const extraTools = new Set(agent.role === "librarian" ? ["write_skill"] : []);
|
|
64827
|
+
if (agent.canWrite) {
|
|
64828
|
+
extraTools.add("write_to_file");
|
|
64829
|
+
extraTools.add("apply_diff");
|
|
64830
|
+
extraTools.add("write_skill");
|
|
64831
|
+
}
|
|
64832
|
+
const readOnly = agent.usesTools ? toolsForConsultation(agentBriefingTools?.() ?? [], extraTools) : [];
|
|
64320
64833
|
const context = consultationContext?.();
|
|
64321
64834
|
const result = await runConsultation({
|
|
64322
64835
|
provider,
|
|
@@ -64326,6 +64839,24 @@ ${preview.text}` } : {}
|
|
|
64326
64839
|
// With no context there is nothing to read *with*, so it answers from the question alone
|
|
64327
64840
|
// rather than being offered tools that would fail.
|
|
64328
64841
|
context: context ?? {},
|
|
64842
|
+
/*
|
|
64843
|
+
* The same gate the agent loop uses, so an approval raised by a specialist is
|
|
64844
|
+
* indistinguishable from one raised by the assistant — same prompt, same ground truth, same
|
|
64845
|
+
* always-ask rule. A second approval path would be a second place for the rule to be wrong.
|
|
64846
|
+
*/
|
|
64847
|
+
approve: async (tool, args) => {
|
|
64848
|
+
const preview = await tool.preview?.(args, context ?? {}).catch(() => void 0);
|
|
64849
|
+
const decision = await approvalGate.requestApproval({
|
|
64850
|
+
id: `agent-${agent.role}-${String(Date.now())}-${tool.name}`,
|
|
64851
|
+
toolName: tool.name,
|
|
64852
|
+
group: tool.group,
|
|
64853
|
+
preview: preview ?? {
|
|
64854
|
+
kind: "text",
|
|
64855
|
+
text: `The ${agent.role} wants to run ${tool.name}.`
|
|
64856
|
+
}
|
|
64857
|
+
});
|
|
64858
|
+
return decision === "approve";
|
|
64859
|
+
},
|
|
64329
64860
|
...request.signal !== void 0 ? { signal: request.signal } : {},
|
|
64330
64861
|
onStep: (name) => logger.info(`${agent.role} looked up ${name}`)
|
|
64331
64862
|
});
|
|
@@ -65089,7 +65620,7 @@ ${preview.text}` } : {}
|
|
|
65089
65620
|
} else if (message3.type === "setAgentRole") {
|
|
65090
65621
|
const assignment = message3.assignment;
|
|
65091
65622
|
const role = message3.role;
|
|
65092
|
-
if (!isAgentRole(role)) {
|
|
65623
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65093
65624
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65094
65625
|
return;
|
|
65095
65626
|
}
|
|
@@ -65109,7 +65640,7 @@ ${preview.text}` } : {}
|
|
|
65109
65640
|
} else if (message3.type === "setAgentPrompt") {
|
|
65110
65641
|
const role = message3.role;
|
|
65111
65642
|
const prompt = message3.prompt;
|
|
65112
|
-
if (!isAgentRole(role)) {
|
|
65643
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65113
65644
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65114
65645
|
return;
|
|
65115
65646
|
}
|
|
@@ -65140,10 +65671,50 @@ ${preview.text}` } : {}
|
|
|
65140
65671
|
}
|
|
65141
65672
|
return { ...current, teamGuidance: guidance };
|
|
65142
65673
|
});
|
|
65674
|
+
} else if (message3.type === "saveCustomRole") {
|
|
65675
|
+
void handleSaveCustomRole(message3);
|
|
65676
|
+
} else if (message3.type === "deleteCustomRole") {
|
|
65677
|
+
void handleDeleteCustomRole(message3.id);
|
|
65678
|
+
} else if (message3.type === "setRoleEnabled") {
|
|
65679
|
+
const role = message3.role;
|
|
65680
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65681
|
+
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65682
|
+
return;
|
|
65683
|
+
}
|
|
65684
|
+
void saveAgents((current) => {
|
|
65685
|
+
const roles = { ...current.roles ?? {} };
|
|
65686
|
+
roles[role] = {
|
|
65687
|
+
...roles[role] ?? { kind: "profile" },
|
|
65688
|
+
enabled: message3.enabled
|
|
65689
|
+
};
|
|
65690
|
+
return { ...current, roles };
|
|
65691
|
+
});
|
|
65692
|
+
} else if (message3.type === "setRoleWrite") {
|
|
65693
|
+
const role = message3.role;
|
|
65694
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65695
|
+
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65696
|
+
return;
|
|
65697
|
+
}
|
|
65698
|
+
void saveAgents((current) => {
|
|
65699
|
+
const roles = { ...current.roles ?? {} };
|
|
65700
|
+
roles[role] = { ...roles[role] ?? { kind: "profile" }, write: message3.canWrite };
|
|
65701
|
+
return { ...current, roles };
|
|
65702
|
+
});
|
|
65703
|
+
} else if (message3.type === "setRoleTools") {
|
|
65704
|
+
const role = message3.role;
|
|
65705
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65706
|
+
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65707
|
+
return;
|
|
65708
|
+
}
|
|
65709
|
+
void saveAgents((current) => {
|
|
65710
|
+
const roles = { ...current.roles ?? {} };
|
|
65711
|
+
roles[role] = { ...roles[role] ?? { kind: "profile" }, tools: message3.usesTools };
|
|
65712
|
+
return { ...current, roles };
|
|
65713
|
+
});
|
|
65143
65714
|
} else if (message3.type === "setAgentColor") {
|
|
65144
65715
|
const role = message3.role;
|
|
65145
65716
|
const color = message3.color;
|
|
65146
|
-
if (!isAgentRole(role)) {
|
|
65717
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
65147
65718
|
post({ type: "error", message: `There is no "${role}" role.` });
|
|
65148
65719
|
return;
|
|
65149
65720
|
}
|