@ycodium-ai/plugin-team 0.2.4372 → 0.2.4394
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/assets/ui.js +17 -9
- package/dist/index.js +1109 -211
- package/locales/en.json +43 -5
- package/locales/zh-CN.json +43 -5
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all3) => {
|
|
|
8
8
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
9
9
|
|
|
10
10
|
// ../../packages/plugin-api/src/version.ts
|
|
11
|
-
var PLUGIN_API_VERSION =
|
|
11
|
+
var PLUGIN_API_VERSION = 114;
|
|
12
12
|
|
|
13
13
|
// ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=2379c0b6f6365efdc960ef467ae589e40827f36fbfe7992e14580cecfa87fd2b/node_modules/effect/dist/Pipeable.js
|
|
14
14
|
var pipeArguments = (self, args2) => {
|
|
@@ -7251,7 +7251,13 @@ var TeamGoal = Struct({
|
|
|
7251
7251
|
goalId: String4.check(isPattern2(REQUEST_ID_PATTERN)),
|
|
7252
7252
|
goal: String4.check(isMinLength(1), isMaxLength(GOAL_MAX_LENGTH)),
|
|
7253
7253
|
titleSeed: optionalKey2(String4),
|
|
7254
|
+
/** 负责人成员。线目标里它跟着引擎线的 `leadMemberId` 走(见 `lineLead.ts`);落盘的事实是开目标时的那位。 */
|
|
7254
7255
|
leadMemberId: String4,
|
|
7256
|
+
/**
|
|
7257
|
+
* 房间自己的 agent 成员(开团队的那条会话对应的成员)。只在折叠里随换负责人出现,落盘的事实没有它;没有就是
|
|
7258
|
+
* `leadMemberId`。
|
|
7259
|
+
*/
|
|
7260
|
+
roomMemberId: optionalKey2(String4),
|
|
7255
7261
|
threads: ArraySchema(Struct({ memberId: String4, threadId: String4 })),
|
|
7256
7262
|
remoteMembers: optionalKey2(
|
|
7257
7263
|
ArraySchema(Struct({ memberId: String4, principalId: String4 }))
|
|
@@ -7945,11 +7951,11 @@ function createSerial(closedMessage = "team-serial-closed") {
|
|
|
7945
7951
|
}
|
|
7946
7952
|
|
|
7947
7953
|
// src/domain/facts.ts
|
|
7948
|
-
function foldFact(state, event, decode4,
|
|
7954
|
+
function foldFact(state, event, decode4, keyOf2) {
|
|
7949
7955
|
if (event.type !== "plugin.event-appended") return state;
|
|
7950
7956
|
const decoded = decode4(event.payload);
|
|
7951
7957
|
if (isNone2(decoded)) return state;
|
|
7952
|
-
return { ...state, [
|
|
7958
|
+
return { ...state, [keyOf2(decoded.value)]: decoded.value };
|
|
7953
7959
|
}
|
|
7954
7960
|
function readFact(state, key) {
|
|
7955
7961
|
return Object.hasOwn(state, key) ? state[key] : null;
|
|
@@ -8260,7 +8266,10 @@ async function deliverWake(ctx, input) {
|
|
|
8260
8266
|
await ctx.communication.records.send({
|
|
8261
8267
|
projectId: input.projectId,
|
|
8262
8268
|
requestId: input.requestId,
|
|
8263
|
-
to: {
|
|
8269
|
+
to: {
|
|
8270
|
+
principalId: recipient.principalId,
|
|
8271
|
+
...recipient.memberId === void 0 ? {} : { memberId: recipient.memberId }
|
|
8272
|
+
},
|
|
8264
8273
|
text: typeof input.text === "string" ? input.text : await input.text(),
|
|
8265
8274
|
delivery: input.steer ? "steer" : "wake"
|
|
8266
8275
|
});
|
|
@@ -8348,7 +8357,7 @@ ${await worktreeSetupSentence(ctx, input.projectId, branch)}`
|
|
|
8348
8357
|
}
|
|
8349
8358
|
if (!delivered) await startTurn(failure === void 0 ? "" : FALLBACK_SUFFIX);
|
|
8350
8359
|
if (worktree !== void 0 && failure !== void 0 && failure.reported !== true) {
|
|
8351
|
-
const reported = await deliverWake(ctx, {
|
|
8360
|
+
const reported = worktree.leadThreadId === void 0 ? true : await deliverWake(ctx, {
|
|
8352
8361
|
projectId: input.projectId,
|
|
8353
8362
|
recipient: { threadId: worktree.leadThreadId },
|
|
8354
8363
|
requestId: `team-worktree-report:${threadId}`,
|
|
@@ -8528,6 +8537,31 @@ async function defaultAgent(ctx, projectId) {
|
|
|
8528
8537
|
};
|
|
8529
8538
|
}
|
|
8530
8539
|
|
|
8540
|
+
// src/domain/lineLead.ts
|
|
8541
|
+
var NO_LEAD = "";
|
|
8542
|
+
var decodeLineUpdated = decodeUnknownOption2(
|
|
8543
|
+
Struct({
|
|
8544
|
+
projectId: String4,
|
|
8545
|
+
workLineId: String4,
|
|
8546
|
+
leadMemberId: optionalKey2(NullOr(String4))
|
|
8547
|
+
})
|
|
8548
|
+
);
|
|
8549
|
+
var leadChangeOfEngineEvent = (event) => {
|
|
8550
|
+
if (event.type !== "work.line-updated") return null;
|
|
8551
|
+
const decoded = decodeLineUpdated(event.payload);
|
|
8552
|
+
if (isNone2(decoded)) return null;
|
|
8553
|
+
const { projectId, workLineId, leadMemberId } = decoded.value;
|
|
8554
|
+
return leadMemberId === void 0 ? null : { projectId, workLineId, leadMemberId };
|
|
8555
|
+
};
|
|
8556
|
+
var roomMemberOf = (goal) => goal.roomMemberId ?? goal.leadMemberId;
|
|
8557
|
+
var roomThreadOf = (goal) => goal.threads.find((row) => row.memberId === roomMemberOf(goal))?.threadId;
|
|
8558
|
+
function withLineLead(goal, change) {
|
|
8559
|
+
const next = change.leadMemberId ?? NO_LEAD;
|
|
8560
|
+
if (goal.workLineId === void 0 || goal.projectId !== change.projectId || goal.workLineId !== change.workLineId || goal.leadMemberId === next)
|
|
8561
|
+
return goal;
|
|
8562
|
+
return { ...goal, roomMemberId: roomMemberOf(goal), leadMemberId: next };
|
|
8563
|
+
}
|
|
8564
|
+
|
|
8531
8565
|
// locales/en.json
|
|
8532
8566
|
var en_default = {
|
|
8533
8567
|
presentation: {
|
|
@@ -8556,7 +8590,8 @@ var en_default = {
|
|
|
8556
8590
|
},
|
|
8557
8591
|
team: {
|
|
8558
8592
|
openTool: "Turn this thread into a team. Call it only after the person has agreed, in this thread, to the team you proposed: who joins (members already in the project, including agents on the other machines that joined this project; work_list_machines lists those machines) and which new members you will create after the team is open. A member that does not exist yet comes after this call: create it with team_create_member, then add it with team_set_members. This thread becomes the team's lead and its group chat and is renamed to the team's name: the members you list are added to it, and each local agent member gets its own thread under yours. Pass a new requestId, and reuse it only to retry the same call. name is the team's name (at most 80 characters); goal is a summary of what was agreed (at most 4000 characters); memberIds are the memberIds of the project members to bring in (not yourself; you are added as the lead); leadName optionally names you as a project member (1-40 characters). The call returns the team's work line, the members and whether each one is ready, and your brief. A thread that already is a team, or belongs to one, cannot open another.",
|
|
8559
|
-
setMembersTool:
|
|
8593
|
+
setMembersTool: `Change who is on this team (only the team's lead can: its conversation, or its own session on another machine). add: memberIds of project members to bring in; remove: memberIds to take out. Work assigned to a removed member that has not reached it yet is taken back and given to you; work already in their hands stays with them until you decide. You cannot remove yourself, and you cannot change members or leads of other teams. The result says returnStatus: "done" with returnedToYou (the work item IDs given back to you), or "pending": the members are already changed and the work is still being given back, which finishes by itself; call again with the same requestId to read where it stands. Pass a new requestId, and reuse it only to retry the same call.`,
|
|
8594
|
+
setLeadTool: "Hand the lead of this team to another member of it (only the team's current lead can, from its conversation or its own session on another machine; the person is not asked). memberId: the memberId of a member already on the team, a person or an agent on another machine included; add them first with team_set_members if they are not. After the call you are an ordinary member and cannot take it back: only the new lead or the person can hand it on. Your open work items move to the new lead (including ones you are already working on) and the new lead is told it leads now, so finish or hand off what you are doing before you call it. It is written once: if the team or its lead was changed at the same moment, nothing is written and the call is refused (lead-changed); read the team again, decide again, and call with a new requestId. Reuse a requestId only to read the result of the same call again.",
|
|
8560
8595
|
rosterOverviewTool: "Read everything you need to plan a team: every member of this project with their kind, machine, model, how their trial run stands (trial is none when no trial applies, such as a person; unverified for an agent on another machine with no trial record here; pending until the trial passes; ready once it passed or was skipped; failed; invoked for the thread that is itself the lead and needs no trial), and the teams they are in (with whether they lead it). Read it before you propose a team and before you create a member.",
|
|
8561
8596
|
noProject: "This call is not tied to a project, so there is no team to open or change.",
|
|
8562
8597
|
notLocal: "Only a thread on this machine can open a team.",
|
|
@@ -8572,10 +8607,15 @@ var en_default = {
|
|
|
8572
8607
|
modelNotInCatalog: "The model chosen for member {{memberId}} is not in that provider instance's model list. Check list_models, then change it with team_update_member.",
|
|
8573
8608
|
noDefaultModel: "Member {{memberId}} has no model of its own and the project has no default model. Give them one with team_update_member.",
|
|
8574
8609
|
duplicateTeamName: "A team named {{name}} already exists in this project. Choose another name and use a new requestId.",
|
|
8575
|
-
leadOnly: "Only the lead
|
|
8576
|
-
cannotRemoveLead: "You cannot remove yourself, the lead of this team.",
|
|
8610
|
+
leadOnly: "Only the lead of a team can change its members or hand over the lead.",
|
|
8611
|
+
cannotRemoveLead: "You cannot remove yourself, the lead of this team. Hand the lead to another member with team_set_lead first.",
|
|
8612
|
+
alreadyLead: "You already are the lead of this team. Pass the memberId of another member of the team.",
|
|
8613
|
+
memberNotOnTeam: "Member {{memberId}} is not on this team. Add them with team_set_members first, then hand over the lead.",
|
|
8577
8614
|
teamArchived: "This team is archived. Ask the person to unarchive the thread before changing it.",
|
|
8578
|
-
versionConflict: "The team was changed at the same moment. Read it again and retry with a new requestId."
|
|
8615
|
+
versionConflict: "The team was changed at the same moment. Read it again and retry with a new requestId.",
|
|
8616
|
+
memberMachineUpdate: "member-machine-update-required: Update the member machine to use the team tools as a lead. Its host-signed MCP scope does not name the member, or is too old.",
|
|
8617
|
+
severalTeams: "This member leads more than one team, so the call cannot tell which team it is about. Ask the person to hand the lead of one of them to someone else first.",
|
|
8618
|
+
leadChanged: "The team or its lead was changed at the same moment, so nothing was written. Read the team again, decide again, and call with a new requestId."
|
|
8579
8619
|
},
|
|
8580
8620
|
coordinator: {
|
|
8581
8621
|
createTool: `Add an AI teammate to this project's team as the lead of the current goal. Pass a new requestId, and reuse it only to retry the same request. The member runs on this machine unless you give environmentId: another machine that joined this project (work_list_machines lists them with the providers each one offers). Give the provider instanceId and model together (both or neither); on this machine they default to the project's default model, while on another machine they are required and must be a ready provider instance that machine reported. The new member joins the current goal and gets its own thread under yours, normally within moments (if that fails you are told why, and it is retried every couple of minutes); in a team opened with team_open, that starts once you add the member with team_set_members; once it is ready you can assign work to it with work_update_item and assignees [{ "kind": "member", "memberId": <the memberId this tool returns> }]. Check who is on the team first with work_list_members.`,
|
|
@@ -8637,6 +8677,37 @@ var en_default = {
|
|
|
8637
8677
|
boardOff: "The lead needs the board. Turn on the board switch above.",
|
|
8638
8678
|
memoryOff: "The lead needs project memory. Turn on the project memory switch above."
|
|
8639
8679
|
},
|
|
8680
|
+
teamMembers: {
|
|
8681
|
+
title: "Team members",
|
|
8682
|
+
add: "Add member",
|
|
8683
|
+
addTitle: "Add member",
|
|
8684
|
+
addChoose: "Choose a member",
|
|
8685
|
+
addNone: "Every member of this project is already on the team",
|
|
8686
|
+
addConfirm: "Add",
|
|
8687
|
+
makeLead: "Make lead",
|
|
8688
|
+
makeLeadFor: "Make {{name}} the lead",
|
|
8689
|
+
leadTitle: "Make {{name}} the lead?",
|
|
8690
|
+
leadDescription_one: "{{lead}}'s {{count}} open work item moves to {{name}}, including ones already in progress. {{lead}} stays on the team as a member.",
|
|
8691
|
+
leadDescription_other: "{{lead}}'s {{count}} open work items move to {{name}}, including ones already in progress. {{lead}} stays on the team as a member.",
|
|
8692
|
+
leadDescriptionNone: "{{lead}} stays on the team as a member.",
|
|
8693
|
+
leadConfirm: "Make lead",
|
|
8694
|
+
remove: "Remove",
|
|
8695
|
+
removeFor: "Remove {{name}}",
|
|
8696
|
+
removeTitle: "Remove {{name}} from the team?",
|
|
8697
|
+
removeDescription: "Work that has not reached them yet goes back to the lead. Work already in their hands stays with them until it is done.",
|
|
8698
|
+
removeDescriptionCount_one: "{{count}} work item that has not reached them goes back to the lead. Work already in their hands stays with them until it is done.",
|
|
8699
|
+
removeDescriptionCount_other: "{{count}} work items that have not reached them go back to the lead. Work already in their hands stays with them until it is done.",
|
|
8700
|
+
removeConfirm: "Remove",
|
|
8701
|
+
working: "Working\u2026",
|
|
8702
|
+
addDescription: "An agent member takes work after its trial run passes; a person can take work as soon as they join.",
|
|
8703
|
+
archived: "This team is archived, so its members can't be changed.",
|
|
8704
|
+
leadStays: "Make someone else the lead first",
|
|
8705
|
+
cancel: "Cancel",
|
|
8706
|
+
loadFailed: "The team's members could not be loaded. Try again.",
|
|
8707
|
+
failed: "The change was not made. The team may have just been changed, so the list was reloaded.",
|
|
8708
|
+
leadOffline: "{{name}}'s machine is offline. The lead stays as it is and carries on when the machine is back; or make someone else the lead.",
|
|
8709
|
+
returning: "Member removed. Their work items are still being given back to the lead."
|
|
8710
|
+
},
|
|
8640
8711
|
members: {
|
|
8641
8712
|
title: "Members",
|
|
8642
8713
|
open: "View members",
|
|
@@ -8747,7 +8818,7 @@ var en_default = {
|
|
|
8747
8818
|
passed: "Trial passed",
|
|
8748
8819
|
skipped: "Trial skipped",
|
|
8749
8820
|
remoteVerified: "Verified on its machine",
|
|
8750
|
-
invoked: "
|
|
8821
|
+
invoked: "Session already running, no trial needed",
|
|
8751
8822
|
pending: "Trial run pending",
|
|
8752
8823
|
running: "Trial run in progress",
|
|
8753
8824
|
sent: "Trial run sent",
|
|
@@ -8925,6 +8996,7 @@ var en_default = {
|
|
|
8925
8996
|
revert_handbook: "Revert handbook",
|
|
8926
8997
|
open: "Open team",
|
|
8927
8998
|
set_members: "Change team members",
|
|
8999
|
+
set_lead: "Hand over the team lead",
|
|
8928
9000
|
roster_overview: "Read roster",
|
|
8929
9001
|
trial_started: "Start trial",
|
|
8930
9002
|
trial_done: "Finish trial",
|
|
@@ -8952,7 +9024,7 @@ var NO_PROGRESS_TURNS = 2;
|
|
|
8952
9024
|
var NO_PROGRESS_DELAY_MINUTES = 2;
|
|
8953
9025
|
var NO_PROGRESS_DELAY_CAP_MINUTES = 30;
|
|
8954
9026
|
var MEMBER_PROGRESS_RULE = `Report as you go: each time a group of tests turns green, a file you changed passes its typecheck, you are about to change approach because you are stuck, or you are about to stop and wait for someone, commit what you have to your own branch (a work-in-progress commit is fine) and post one line of progress and any blocker on the item with work_post_comment. Do not wait until the whole item is done. If an item of yours goes ${PROGRESS_CHECKIN_MINUTES} minutes with no progress from you, the team plugin mentions you on it to ask; answer it the same way.`;
|
|
8955
|
-
var memberGroupRule = (
|
|
9027
|
+
var memberGroupRule = (groupThreadId, leadsGroup = true) => groupThreadId === void 0 ? "" : ` The group is ${leadsGroup ? "your lead's conversation" : "the team's own conversation, which is not your lead's"}. Read older group records with message_list { groupThreadId: "${groupThreadId}" }, and older conversation messages with list_thread_messages { threadId: "${groupThreadId}" }. To answer in the group use send_message with to: { group: { threadId: "${groupThreadId}" } }, mentions for any member your text addresses with @name, and replyTo the record you are answering; a reply on its own wakes nobody, so mention the member you need in the text.`;
|
|
8956
9028
|
var memberStuckRule = (leadThreadId) => {
|
|
8957
9029
|
const mention = leadThreadId === void 0 ? "" : ` that mentions your lead (mentions: [{ "kind": "agent", "threadId": "${leadThreadId}" }])`;
|
|
8958
9030
|
const reply = leadThreadId === void 0 ? "" : " Your lead will reply or change the plan.";
|
|
@@ -9057,6 +9129,13 @@ var foldGoals = (state, event) => {
|
|
|
9057
9129
|
return merged === goal ? next : { ...next, [fact.projectId]: merged };
|
|
9058
9130
|
};
|
|
9059
9131
|
var foldLineGoals = (state, event) => {
|
|
9132
|
+
const lead = leadChangeOfEngineEvent(event);
|
|
9133
|
+
if (lead !== null) {
|
|
9134
|
+
const goal = readFact(state, lead.workLineId);
|
|
9135
|
+
if (goal === null) return state;
|
|
9136
|
+
const changed = withLineLead(goal, lead);
|
|
9137
|
+
return changed === goal ? state : { ...state, [lead.workLineId]: changed };
|
|
9138
|
+
}
|
|
9060
9139
|
const next = foldFact(state, event, decodeLineGoalFact, (goal) => goal.workLineId);
|
|
9061
9140
|
if (event.type !== "plugin.event-appended") return next;
|
|
9062
9141
|
const bound = decodeBoundEnvelope(event.payload);
|
|
@@ -9080,8 +9159,9 @@ function createGoalService(ctx, rosterService, options = {}) {
|
|
|
9080
9159
|
});
|
|
9081
9160
|
const lineGoals = ctx.derivedState({
|
|
9082
9161
|
key: "line-goals",
|
|
9083
|
-
|
|
9084
|
-
|
|
9162
|
+
// 2:折叠 `work.line-updated` 的负责人变化,旧状态从事件重建。
|
|
9163
|
+
version: 2,
|
|
9164
|
+
events: ["plugin.event-appended", "work.line-updated"],
|
|
9085
9165
|
init: () => ({}),
|
|
9086
9166
|
apply: foldLineGoals
|
|
9087
9167
|
});
|
|
@@ -9514,24 +9594,28 @@ function registerCoordinator(ctx, runtime) {
|
|
|
9514
9594
|
tools: [
|
|
9515
9595
|
{
|
|
9516
9596
|
name: "create_member",
|
|
9597
|
+
remoteAvailable: true,
|
|
9517
9598
|
description: coordinatorMessage("createTool"),
|
|
9518
9599
|
inputSchema: toolSchema(CreateMemberToolInput),
|
|
9519
9600
|
handle: (input, invocation) => runTool(() => runtime.create(decodeCreate(input), invocation))
|
|
9520
9601
|
},
|
|
9521
9602
|
{
|
|
9522
9603
|
name: "update_member",
|
|
9604
|
+
remoteAvailable: true,
|
|
9523
9605
|
description: coordinatorMessage("updateTool"),
|
|
9524
9606
|
inputSchema: toolSchema(UpdateMemberToolInput),
|
|
9525
9607
|
handle: (input, invocation) => runTool(() => runtime.update(decodeUpdate(input), invocation))
|
|
9526
9608
|
},
|
|
9527
9609
|
{
|
|
9528
9610
|
name: "remove_member",
|
|
9611
|
+
remoteAvailable: true,
|
|
9529
9612
|
description: coordinatorMessage("removeTool"),
|
|
9530
9613
|
inputSchema: toolSchema(MemberRefToolInput),
|
|
9531
9614
|
handle: (input, invocation) => runTool(() => runtime.remove(decodeRef(input), invocation))
|
|
9532
9615
|
},
|
|
9533
9616
|
{
|
|
9534
9617
|
name: "restore_member",
|
|
9618
|
+
remoteAvailable: true,
|
|
9535
9619
|
description: coordinatorMessage("restoreTool"),
|
|
9536
9620
|
inputSchema: toolSchema(MemberRefToolInput),
|
|
9537
9621
|
handle: (input, invocation) => runTool(() => runtime.restore(decodeRef(input), invocation))
|
|
@@ -9575,21 +9659,39 @@ function memberRefusal(error) {
|
|
|
9575
9659
|
};
|
|
9576
9660
|
}
|
|
9577
9661
|
|
|
9662
|
+
// src/team/messages.ts
|
|
9663
|
+
function teamMessage(key, values = {}) {
|
|
9664
|
+
return interpolateMessage(en_default.team[key], values);
|
|
9665
|
+
}
|
|
9666
|
+
|
|
9578
9667
|
// src/coordinator/lead.ts
|
|
9579
9668
|
async function checkLead(goals, invocation) {
|
|
9580
9669
|
const projectId = invocation.projectId;
|
|
9581
9670
|
if (projectId === null) return { ok: false, reason: "no-project" };
|
|
9582
9671
|
const caller = invocation.caller;
|
|
9672
|
+
const refused2 = async () => ({
|
|
9673
|
+
ok: false,
|
|
9674
|
+
// 项目里还没有任何目标(没有负责人可言)与有目标但调用者不是它的负责人,给调用者不同的话。
|
|
9675
|
+
reason: (await goals.allOf(projectId)).length === 0 ? "no-goal" : "lead-only"
|
|
9676
|
+
});
|
|
9677
|
+
if (caller?.kind === "remote-agent") {
|
|
9678
|
+
const { memberId, principalId } = caller;
|
|
9679
|
+
if (memberId === void 0) return { ok: false, reason: "update-required" };
|
|
9680
|
+
const led = (await goals.allOf(projectId)).filter(
|
|
9681
|
+
(goal3) => goal3.leadMemberId === memberId && goal3.remoteMembers?.some(
|
|
9682
|
+
(row) => row.memberId === memberId && row.principalId === principalId
|
|
9683
|
+
) === true
|
|
9684
|
+
);
|
|
9685
|
+
if (led.length > 1) return { ok: false, reason: "several-teams" };
|
|
9686
|
+
const [goal2] = led;
|
|
9687
|
+
return goal2 === void 0 ? refused2() : { ok: true, projectId, leadMemberId: goal2.leadMemberId, goal: goal2 };
|
|
9688
|
+
}
|
|
9583
9689
|
const goal = caller?.kind === "thread" ? await goals.ofThread(projectId, caller.threadId) : null;
|
|
9584
9690
|
const seat = goal !== null && caller?.kind === "thread" ? findGoalMember(goal.threads, { threadId: caller.threadId }) : void 0;
|
|
9585
|
-
if (goal === null || seat === void 0 || seat.memberId !== goal.leadMemberId)
|
|
9586
|
-
return {
|
|
9587
|
-
ok: false,
|
|
9588
|
-
// 项目里还没有任何目标(没有负责人可言)与有目标但调用者不是它的负责人,给调用者不同的话。
|
|
9589
|
-
reason: (await goals.allOf(projectId)).length === 0 ? "no-goal" : "lead-only"
|
|
9590
|
-
};
|
|
9691
|
+
if (goal === null || seat === void 0 || seat.memberId !== goal.leadMemberId) return refused2();
|
|
9591
9692
|
return { ok: true, projectId, leadMemberId: goal.leadMemberId, goal };
|
|
9592
9693
|
}
|
|
9694
|
+
var remoteLeadRefusal = (reason) => teamMessage(reason === "update-required" ? "memberMachineUpdate" : "severalTeams");
|
|
9593
9695
|
|
|
9594
9696
|
// src/coordinator/state.ts
|
|
9595
9697
|
var MEMBER_CHANGE_EVENTS = ["plugin.event-appended"];
|
|
@@ -9741,6 +9843,8 @@ function startCoordinatorRuntime(ctx, deps) {
|
|
|
9741
9843
|
const requireLead = async (invocation) => {
|
|
9742
9844
|
const lead = await checkLead(deps.goals, invocation);
|
|
9743
9845
|
if (lead.ok) return lead;
|
|
9846
|
+
if (lead.reason === "update-required" || lead.reason === "several-teams")
|
|
9847
|
+
throw new Error(remoteLeadRefusal(lead.reason));
|
|
9744
9848
|
throw new Error(
|
|
9745
9849
|
coordinatorMessage(
|
|
9746
9850
|
lead.reason === "no-project" ? "noProject" : lead.reason === "no-goal" ? "noGoal" : "leadOnly"
|
|
@@ -10819,6 +10923,23 @@ var lineScopeOfThread = (project2, threadId) => {
|
|
|
10819
10923
|
};
|
|
10820
10924
|
var scopeOfPrincipal = (project2, principalId) => scopesOf(project2).find((scope2) => scope2.remoteMembers.includes(principalId));
|
|
10821
10925
|
var isGoalThread = (project2, threadId) => scopeOfThread(project2, threadId) !== void 0;
|
|
10926
|
+
var leadThreadsOf = (scope2) => {
|
|
10927
|
+
const bound = scope2.leadMemberId === void 0 ? null : readFact(scope2.bindings ?? {}, scope2.leadMemberId);
|
|
10928
|
+
return bound !== null && "threadId" in bound ? [bound.threadId] : [];
|
|
10929
|
+
};
|
|
10930
|
+
var leadRecipientOf = (scope2) => {
|
|
10931
|
+
const thread = scope2?.leadThreads?.[0];
|
|
10932
|
+
if (thread !== void 0) return { threadId: thread };
|
|
10933
|
+
const bound = scope2?.leadMemberId === void 0 ? null : readFact(scope2.bindings ?? {}, scope2.leadMemberId);
|
|
10934
|
+
return bound !== null && "principalId" in bound ? { principalId: bound.principalId, memberId: scope2.leadMemberId } : void 0;
|
|
10935
|
+
};
|
|
10936
|
+
var isLeadRecipient = (project2, who, workLineId) => {
|
|
10937
|
+
const lead = leadRecipientOf(scopeOfRecipient(project2, who, workLineId));
|
|
10938
|
+
if (lead === void 0) return false;
|
|
10939
|
+
if ("threadId" in who) return "threadId" in lead && lead.threadId === who.threadId;
|
|
10940
|
+
return "principalId" in lead && lead.principalId === who.principalId && lead.memberId === who.memberId;
|
|
10941
|
+
};
|
|
10942
|
+
var roomOf = (scope2) => scope2.roomThread ?? scope2.leadThreads?.[0];
|
|
10822
10943
|
var isLeadThread = (project2, threadId) => scopesOf(project2).some((scope2) => scope2.leadThreads?.includes(threadId) === true);
|
|
10823
10944
|
var isRemoteMember2 = (project2, principalId) => scopeOfPrincipal(project2, principalId) !== void 0;
|
|
10824
10945
|
var leadOfThread = (project2, threadId) => scopeOfThread(project2, threadId)?.leadThreads?.[0];
|
|
@@ -10838,6 +10959,7 @@ var placeOfRecipient = (project2, who, workLineId) => {
|
|
|
10838
10959
|
var scopeOfRecipient = (project2, who, workLineId) => placeOfRecipient(project2, who, workLineId)?.scope;
|
|
10839
10960
|
var memberOfRecipientIn = (scope2, who) => {
|
|
10840
10961
|
if ("threadId" in who) return scope2.memberIds?.[who.threadId];
|
|
10962
|
+
if (who.memberId !== void 0) return who.memberId;
|
|
10841
10963
|
for (const [memberId, recipient] of Object.entries(scope2.bindings ?? {}))
|
|
10842
10964
|
if ("principalId" in recipient && recipient.principalId === who.principalId) return memberId;
|
|
10843
10965
|
return void 0;
|
|
@@ -10868,11 +10990,11 @@ function memberWorktreeFor(goals, project2, projectId, recipient) {
|
|
|
10868
10990
|
if (!("threadId" in recipient) || project2 === void 0) return;
|
|
10869
10991
|
const { threadId } = recipient;
|
|
10870
10992
|
const scope2 = scopeOfThread(project2, threadId);
|
|
10871
|
-
if (scope2 === void 0 || scope2.leadThreads?.includes(threadId))
|
|
10993
|
+
if (scope2 === void 0 || scope2.leadThreads?.includes(threadId) || threadId === roomOf(scope2))
|
|
10994
|
+
return;
|
|
10872
10995
|
const leadThreadId = scope2.leadThreads?.[0];
|
|
10873
|
-
if (leadThreadId === void 0) return;
|
|
10874
10996
|
return {
|
|
10875
|
-
leadThreadId,
|
|
10997
|
+
...leadThreadId === void 0 ? {} : { leadThreadId },
|
|
10876
10998
|
failure: project2.worktreeFailures?.[threadId],
|
|
10877
10999
|
// 只在要建树或报失败时读目标取名字,叫醒的热路径不多读。
|
|
10878
11000
|
name: async () => (await goals.read(projectId, { forThread: threadId }))?.members.find(
|
|
@@ -10928,7 +11050,13 @@ function countDeferredWakes(project2, threadId) {
|
|
|
10928
11050
|
return count2;
|
|
10929
11051
|
}
|
|
10930
11052
|
var exemptFromTrial = (project2, recipient, workItemId) => {
|
|
10931
|
-
if (project2 === void 0
|
|
11053
|
+
if (project2 === void 0) return false;
|
|
11054
|
+
if (!("threadId" in recipient))
|
|
11055
|
+
return isLeadRecipient(
|
|
11056
|
+
project2,
|
|
11057
|
+
recipient,
|
|
11058
|
+
workItemId === void 0 ? void 0 : readFact(project2.items, workItemId)?.workLineId
|
|
11059
|
+
);
|
|
10932
11060
|
if (isLeadThread(project2, recipient.threadId)) return true;
|
|
10933
11061
|
if (workItemId === void 0) return false;
|
|
10934
11062
|
const item = readFact(project2.items, workItemId);
|
|
@@ -10956,6 +11084,13 @@ function executorOf(project2, workItemId, memberId) {
|
|
|
10956
11084
|
}
|
|
10957
11085
|
|
|
10958
11086
|
// src/runtime/reviewWakes.ts
|
|
11087
|
+
var isAssignedOpenToLead = (project2, workItemId, lead) => {
|
|
11088
|
+
if ("threadId" in lead) return isAssignedOpen(project2, workItemId, lead.threadId);
|
|
11089
|
+
const item = readFact(project2.items, workItemId);
|
|
11090
|
+
return item !== null && item !== void 0 && !isClosed(item) && item.assigneeMembers?.includes(lead.memberId) === true;
|
|
11091
|
+
};
|
|
11092
|
+
var sameLead = (a, b) => a !== void 0 && ("threadId" in a ? "threadId" in b && a.threadId === b.threadId : "principalId" in b && a.principalId === b.principalId && a.memberId === b.memberId);
|
|
11093
|
+
var reviewLead = (review) => "threadId" in review ? { threadId: review.threadId } : { principalId: review.principalId, memberId: review.memberId };
|
|
10959
11094
|
var decodeCompletion = decodeUnknownOption2(
|
|
10960
11095
|
Struct({
|
|
10961
11096
|
projectId: String4,
|
|
@@ -10968,13 +11103,17 @@ var decodeCompletion = decodeUnknownOption2(
|
|
|
10968
11103
|
})
|
|
10969
11104
|
);
|
|
10970
11105
|
var openLeadItemsBlockedBy = (project2, workItemId, lead) => lead === void 0 ? [] : Object.entries(project2.items).filter(
|
|
10971
|
-
([id]) =>
|
|
11106
|
+
([id]) => isAssignedOpenToLead(project2, id, lead) && readFact(project2.blockers, id)?.includes(workItemId) === true
|
|
10972
11107
|
);
|
|
10973
11108
|
var hasOpenTeamGoal = (project2, review) => {
|
|
10974
11109
|
const item = readFact(project2.items, review.workItemId);
|
|
10975
11110
|
if (item === null) return false;
|
|
10976
11111
|
const scope2 = scopeOfRecipient(project2, review.by, item.workLineId);
|
|
10977
|
-
return scope2 !== void 0 && scope2 === scopeForLine(project2, item.workLineId) && scope2.goalId !== void 0 && scope2
|
|
11112
|
+
return scope2 !== void 0 && scope2 === scopeForLine(project2, item.workLineId) && scope2.goalId !== void 0 && sameLead(leadRecipientOf(scope2), reviewLead(review)) && isAssignedOpenToLead(
|
|
11113
|
+
project2,
|
|
11114
|
+
teamGoalItemId(review.projectId, scope2.goalId),
|
|
11115
|
+
reviewLead(review)
|
|
11116
|
+
);
|
|
10978
11117
|
};
|
|
10979
11118
|
function reviewOnUpdate(previous, next, event) {
|
|
10980
11119
|
const decoded = decodeCompletion(event.payload);
|
|
@@ -10982,22 +11121,29 @@ function reviewOnUpdate(previous, next, event) {
|
|
|
10982
11121
|
const { projectId, workItemId, actor } = decoded.value;
|
|
10983
11122
|
if (readFact(previous.items, workItemId)?.stateGroup === "completed") return null;
|
|
10984
11123
|
const by = actor.kind === "agent" ? { threadId: actor.threadId } : { principalId: actor.principalId };
|
|
10985
|
-
const lead = scopeOfRecipient(next, by, readFact(next.items, workItemId)?.workLineId)
|
|
11124
|
+
const lead = leadRecipientOf(scopeOfRecipient(next, by, readFact(next.items, workItemId)?.workLineId)) ?? leadRecipientOf(next);
|
|
10986
11125
|
if (lead === void 0) return null;
|
|
10987
11126
|
if (!isMember(next, by) || "threadId" in by && isLeadThread(next, by.threadId)) return null;
|
|
11127
|
+
if ("memberId" in lead && readFact(next.items, workItemId)?.assigneeMembers?.includes(lead.memberId) === true)
|
|
11128
|
+
return null;
|
|
10988
11129
|
const goals = openLeadItemsBlockedBy(next, workItemId, lead);
|
|
10989
11130
|
const review = {
|
|
10990
|
-
key: `review:${workItemId}:${lead}#${event.sequence}`,
|
|
11131
|
+
key: `review:${workItemId}:${"threadId" in lead ? lead.threadId : `${lead.principalId}:${lead.memberId}`}#${event.sequence}`,
|
|
10991
11132
|
projectId,
|
|
10992
11133
|
workItemId,
|
|
10993
|
-
|
|
10994
|
-
|
|
11134
|
+
by,
|
|
11135
|
+
...lead
|
|
10995
11136
|
};
|
|
10996
11137
|
if (goals.some(([id]) => isWorkable(next, id)) || goals.length === 0 && !hasOpenTeamGoal(next, review))
|
|
10997
11138
|
return null;
|
|
10998
11139
|
return review;
|
|
10999
11140
|
}
|
|
11000
|
-
var isLiveReview = (project2, review) =>
|
|
11141
|
+
var isLiveReview = (project2, review) => {
|
|
11142
|
+
const lead = reviewLead(review);
|
|
11143
|
+
const item = readFact(project2.items, review.workItemId);
|
|
11144
|
+
const stillLead = "threadId" in lead ? isLeadThread(project2, lead.threadId) : sameLead(leadRecipientOf(scopeForLine(project2, item?.workLineId)), lead);
|
|
11145
|
+
return stillLead && item?.stateGroup === "completed" && (openLeadItemsBlockedBy(project2, review.workItemId, lead).length > 0 || hasOpenTeamGoal(project2, review));
|
|
11146
|
+
};
|
|
11001
11147
|
var isReviewDue = (project2, key) => project2.pendingReviews?.some((review) => review.key === key && isLiveReview(project2, review)) === true;
|
|
11002
11148
|
var dueReviews = (project2) => (project2.pendingReviews ?? []).filter((review) => isLiveReview(project2, review)).map((review) => {
|
|
11003
11149
|
const item = readFact(project2.items, review.workItemId);
|
|
@@ -11047,6 +11193,8 @@ var itemWakeCandidate = (projectId, project2, workItemId, item, threadId, woken,
|
|
|
11047
11193
|
if (!finishing && !item.assigneeThreads.includes(threadId)) return null;
|
|
11048
11194
|
const lead = isLeadThread(project2, threadId);
|
|
11049
11195
|
const leadThreadId = leadOfThread(project2, threadId);
|
|
11196
|
+
const scope2 = scopeOfThread(project2, threadId);
|
|
11197
|
+
const room = scope2 === void 0 ? void 0 : roomOf(scope2);
|
|
11050
11198
|
const key = finishing ? unblockedWakeKey(workItemId, threadId, unblocked) : itemWakeKey(workItemId, threadId, readFact(project2.rearms, `${workItemId}:${threadId}`) ?? 0);
|
|
11051
11199
|
if (woken.has(key) || !finishing && !lead && item.wakeStatus?.[threadId] === "released")
|
|
11052
11200
|
return null;
|
|
@@ -11060,7 +11208,10 @@ var itemWakeCandidate = (projectId, project2, workItemId, item, threadId, woken,
|
|
|
11060
11208
|
sequenceId: item.sequenceId,
|
|
11061
11209
|
...memberId === void 0 ? {} : { memberId },
|
|
11062
11210
|
// 成员的叫醒话里点名负责人(卡住时找谁);带队自己和解挡续做不带。
|
|
11063
|
-
...lead ? { lead: true } : finishing || leadThreadId === void 0 ? {} : {
|
|
11211
|
+
...lead ? { lead: true } : finishing || leadThreadId === void 0 ? {} : {
|
|
11212
|
+
leadThreadId,
|
|
11213
|
+
...room === void 0 || room === leadThreadId ? {} : { roomThreadId: room }
|
|
11214
|
+
}
|
|
11064
11215
|
};
|
|
11065
11216
|
};
|
|
11066
11217
|
var engineDispatches = (project2, wake) => wake.kind === "item" && wake.memberId !== void 0 && "threadId" in wake && wake.key === itemWakeKey(wake.workItemId, wake.threadId, 0) && lineScopeOfThread(project2, wake.threadId) !== void 0;
|
|
@@ -11294,6 +11445,73 @@ function registerDispatchGate(ctx, deps) {
|
|
|
11294
11445
|
return ctx.operations.guard({ operations: ["work.dispatch"], check });
|
|
11295
11446
|
}
|
|
11296
11447
|
|
|
11448
|
+
// src/trial/hostState.ts
|
|
11449
|
+
import { projectOrNull } from "@ycodium-ai/plugin-api";
|
|
11450
|
+
function projectGone(ctx) {
|
|
11451
|
+
const known = /* @__PURE__ */ new Map();
|
|
11452
|
+
return async (projectId) => {
|
|
11453
|
+
const cached2 = known.get(projectId);
|
|
11454
|
+
if (cached2 !== void 0) return cached2;
|
|
11455
|
+
const gone = await projectOrNull(ctx.projects, projectId).then(
|
|
11456
|
+
(project2) => project2 === null || project2.archivedAt != null,
|
|
11457
|
+
() => false
|
|
11458
|
+
);
|
|
11459
|
+
known.set(projectId, gone);
|
|
11460
|
+
return gone;
|
|
11461
|
+
};
|
|
11462
|
+
}
|
|
11463
|
+
function reasonOf(error) {
|
|
11464
|
+
const summary = summarizeError(error, "");
|
|
11465
|
+
const tag2 = typeof error === "object" && error !== null && "_tag" in error && typeof error._tag === "string" ? error._tag : "";
|
|
11466
|
+
return tag2 === "" || summary.includes(tag2) ? summary : `${tag2}: ${summary}`;
|
|
11467
|
+
}
|
|
11468
|
+
var REJECTED_REASONS = /* @__PURE__ */ new Set(["rejected", ...CONFLICT_REASONS]);
|
|
11469
|
+
var isRejection = (error) => REJECTED_REASONS.has(dataCommandReason(error) ?? "");
|
|
11470
|
+
|
|
11471
|
+
// src/runtime/leadNotice.ts
|
|
11472
|
+
async function leadAddressOf(ctx, goal) {
|
|
11473
|
+
const thread = goal.threads.find((row) => row.memberId === goal.leadMemberId)?.threadId;
|
|
11474
|
+
if (thread !== void 0) return { kind: "thread", threadId: thread };
|
|
11475
|
+
const remote = goal.remoteMembers?.find((row) => row.memberId === goal.leadMemberId);
|
|
11476
|
+
if (remote !== void 0)
|
|
11477
|
+
return { kind: "remote", principalId: remote.principalId, memberId: remote.memberId };
|
|
11478
|
+
const room = roomThreadOf(goal);
|
|
11479
|
+
if (goal.leadMemberId === "" || room === void 0) return null;
|
|
11480
|
+
const member = await findMember(ctx, goal.projectId, goal.leadMemberId, { textLimit: 2 });
|
|
11481
|
+
const person = member === null ? null : personOfMember(member);
|
|
11482
|
+
return person === null ? null : { kind: "person", person, aboutThreadId: room };
|
|
11483
|
+
}
|
|
11484
|
+
var leadAddressKey = (address) => address.kind === "thread" ? address.threadId : address.kind === "remote" ? `${address.principalId}:${address.memberId}` : personKey(address.person);
|
|
11485
|
+
async function tellLeadAt(ctx, projectId, address, note) {
|
|
11486
|
+
if (address.kind === "thread" || address.kind === "remote") {
|
|
11487
|
+
const wake = () => deliverWake(ctx, {
|
|
11488
|
+
projectId,
|
|
11489
|
+
recipient: address.kind === "thread" ? { threadId: address.threadId } : { principalId: address.principalId, memberId: address.memberId },
|
|
11490
|
+
requestId: note.requestId,
|
|
11491
|
+
messageId: `${note.requestId}:message`,
|
|
11492
|
+
wake: { reason: "notice" },
|
|
11493
|
+
text: note.text
|
|
11494
|
+
});
|
|
11495
|
+
return address.kind === "thread" ? wake() : wake().catch((error) => {
|
|
11496
|
+
if (isRejection(error)) return false;
|
|
11497
|
+
throw error;
|
|
11498
|
+
});
|
|
11499
|
+
}
|
|
11500
|
+
try {
|
|
11501
|
+
await ctx.communication.records.send({
|
|
11502
|
+
projectId,
|
|
11503
|
+
requestId: note.requestId,
|
|
11504
|
+
to: { person: address.person },
|
|
11505
|
+
aboutThreadId: address.aboutThreadId,
|
|
11506
|
+
text: note.text
|
|
11507
|
+
});
|
|
11508
|
+
return true;
|
|
11509
|
+
} catch (error) {
|
|
11510
|
+
if (isRejection(error)) return false;
|
|
11511
|
+
throw error;
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
|
|
11297
11515
|
// src/runtime/memberBinding.ts
|
|
11298
11516
|
var MEMBER_BINDING_EVENTS = [
|
|
11299
11517
|
"member.created",
|
|
@@ -11369,13 +11587,13 @@ function startMemberBindingRuntime(ctx, goals, rosters, wakes, trials2) {
|
|
|
11369
11587
|
if (!await stillCurrent(goal)) return void 0;
|
|
11370
11588
|
const baseId = teamThreadId(projectId, goal.goalId, member.memberId);
|
|
11371
11589
|
const threadId = generation === void 0 ? baseId : `${baseId}:r${generation}`;
|
|
11372
|
-
const
|
|
11373
|
-
if (goal.workLineId !== void 0 &&
|
|
11590
|
+
const room = roomThreadOf(goal);
|
|
11591
|
+
if (goal.workLineId !== void 0 && room !== void 0)
|
|
11374
11592
|
await createTeamThread(ctx, {
|
|
11375
11593
|
projectId,
|
|
11376
11594
|
memberId: member.memberId,
|
|
11377
11595
|
threadId,
|
|
11378
|
-
parentThreadId:
|
|
11596
|
+
parentThreadId: room,
|
|
11379
11597
|
title: goalThreadTitle(goal, member.name),
|
|
11380
11598
|
selection: resolved.selection
|
|
11381
11599
|
});
|
|
@@ -11408,17 +11626,14 @@ function startMemberBindingRuntime(ctx, goals, rosters, wakes, trials2) {
|
|
|
11408
11626
|
..."threadId" in former ? { threadId: former.threadId } : { principalId: former.principalId }
|
|
11409
11627
|
});
|
|
11410
11628
|
};
|
|
11411
|
-
const tellLead = async (goal,
|
|
11629
|
+
const tellLead = async (goal, member, failure, rebinding = false) => {
|
|
11412
11630
|
const key = stableHash(
|
|
11413
11631
|
JSON.stringify([goal.projectId, goal.goalId, member.memberId, failure.code])
|
|
11414
11632
|
);
|
|
11415
11633
|
if (told.has(key)) return;
|
|
11416
|
-
const
|
|
11417
|
-
|
|
11418
|
-
recipient: { threadId: leadThreadId },
|
|
11634
|
+
const address = await leadAddressOf(ctx, goal);
|
|
11635
|
+
const delivered = address !== null && await tellLeadAt(ctx, goal.projectId, address, {
|
|
11419
11636
|
requestId: `team-member-unbound-notice:${key}`,
|
|
11420
|
-
messageId: `team-member-unbound-notice-message:${key}`,
|
|
11421
|
-
wake: { reason: "notice" },
|
|
11422
11637
|
text: rebinding ? `Member ${member.name} (memberId ${member.memberId}) passed its trial run with the new setup but could not be moved onto it: ${failure.detail}. Work not yet handed to them waits until it is. Fix the cause, for example change their model with team_update_member; they are set up again within a couple of minutes.` : `Member ${member.name} (memberId ${member.memberId}) could not join this goal: ${failure.detail}. Work assigned to them waits until they join. Fix the cause, for example change their model with team_update_member; they are set up again within a couple of minutes.`
|
|
11423
11638
|
});
|
|
11424
11639
|
if (delivered) told.add(key);
|
|
@@ -11450,8 +11665,7 @@ function startMemberBindingRuntime(ctx, goals, rosters, wakes, trials2) {
|
|
|
11450
11665
|
const { projectId } = goal;
|
|
11451
11666
|
if (only !== void 0 && projectId !== only) continue;
|
|
11452
11667
|
try {
|
|
11453
|
-
|
|
11454
|
-
if (lead === void 0) continue;
|
|
11668
|
+
if (roomThreadOf(goal) === void 0) continue;
|
|
11455
11669
|
if (goal.workLineId !== void 0 && wake[projectId]?.lineStops?.[goal.workLineId] === "deleted")
|
|
11456
11670
|
continue;
|
|
11457
11671
|
const scope2 = await bindScope(goal, wake[projectId]);
|
|
@@ -11491,7 +11705,7 @@ function startMemberBindingRuntime(ctx, goals, rosters, wakes, trials2) {
|
|
|
11491
11705
|
}
|
|
11492
11706
|
);
|
|
11493
11707
|
if (failure === void 0) return;
|
|
11494
|
-
await tellLead(goal,
|
|
11708
|
+
await tellLead(goal, member, failure, generation !== void 0).catch(
|
|
11495
11709
|
(error) => ctx.log.warn("team member binding failure could not be reported to the lead", {
|
|
11496
11710
|
projectId,
|
|
11497
11711
|
memberId: member.memberId,
|
|
@@ -11578,26 +11792,38 @@ function startMemberRemovalRuntime(ctx, goals, wakes) {
|
|
|
11578
11792
|
const taken = open.filter(([, item]) => notYetHandedOver(item, memberId));
|
|
11579
11793
|
if (taken.length === 0) return;
|
|
11580
11794
|
const keep = open.filter(([, item]) => !notYetHandedOver(item, memberId));
|
|
11581
|
-
const
|
|
11582
|
-
const
|
|
11795
|
+
const teamGoals = await goals.allOf(projectId);
|
|
11796
|
+
const leadOf = async (item) => {
|
|
11797
|
+
const line = item.workLineId === void 0 ? void 0 : project2.lineScopes?.[item.workLineId];
|
|
11798
|
+
if (line === void 0) {
|
|
11799
|
+
const thread = project2.leadThreads?.[0];
|
|
11800
|
+
return thread === void 0 ? void 0 : { kind: "thread", threadId: thread };
|
|
11801
|
+
}
|
|
11802
|
+
const goal = teamGoals.find((row) => row.workLineId === item.workLineId);
|
|
11803
|
+
return goal === void 0 ? void 0 : await leadAddressOf(ctx, goal) ?? void 0;
|
|
11804
|
+
};
|
|
11805
|
+
const leadsByKey = /* @__PURE__ */ new Map();
|
|
11806
|
+
const leadKeyOf = /* @__PURE__ */ new Map();
|
|
11807
|
+
for (const [workItemId, item] of open) {
|
|
11808
|
+
const address = await leadOf(item);
|
|
11809
|
+
if (address === void 0) continue;
|
|
11810
|
+
leadKeyOf.set(workItemId, leadAddressKey(address));
|
|
11811
|
+
if (taken.some(([takenId]) => takenId === workItemId))
|
|
11812
|
+
leadsByKey.set(leadAddressKey(address), address);
|
|
11813
|
+
}
|
|
11583
11814
|
const list = (rows) => rows.map(([workItemId, item]) => label(workItemId, item.sequenceId)).join("; ");
|
|
11584
|
-
for (const lead of
|
|
11585
|
-
|
|
11586
|
-
const isProjectLead = lead === project2.leadThreads?.[0];
|
|
11815
|
+
for (const [lead, address] of leadsByKey) {
|
|
11816
|
+
const isProjectLead = address.kind === "thread" && address.threadId === project2.leadThreads?.[0];
|
|
11587
11817
|
if (isProjectLead && await goals.current(projectId) === null) continue;
|
|
11588
|
-
const mine = (rows) => rows.filter(([
|
|
11818
|
+
const mine = (rows) => rows.filter(([workItemId]) => leadKeyOf.get(workItemId) === lead);
|
|
11589
11819
|
const key = stableHash(
|
|
11590
11820
|
JSON.stringify(
|
|
11591
11821
|
isProjectLead ? [projectId, memberId, member.removedAt] : [projectId, memberId, member.removedAt, lead]
|
|
11592
11822
|
)
|
|
11593
11823
|
);
|
|
11594
11824
|
const heldBack = mine(keep);
|
|
11595
|
-
const told = await
|
|
11596
|
-
projectId,
|
|
11597
|
-
recipient: { threadId: lead },
|
|
11825
|
+
const told = await tellLeadAt(ctx, projectId, address, {
|
|
11598
11826
|
requestId: `team-member-removed-notice:${key}`,
|
|
11599
|
-
messageId: `team-member-removed-notice-message:${key}`,
|
|
11600
|
-
wake: { reason: "notice" },
|
|
11601
11827
|
text: [
|
|
11602
11828
|
`Member ${member.name} (memberId ${memberId}) was removed from this project's team.`,
|
|
11603
11829
|
`Work that had not reached them yet was taken off them and now has no assignee: ${list(mine(taken))}. Assign it to another member with work_update_item.`,
|
|
@@ -11612,7 +11838,7 @@ function startMemberRemovalRuntime(ctx, goals, wakes) {
|
|
|
11612
11838
|
{
|
|
11613
11839
|
projectId,
|
|
11614
11840
|
memberId,
|
|
11615
|
-
|
|
11841
|
+
lead
|
|
11616
11842
|
}
|
|
11617
11843
|
);
|
|
11618
11844
|
return;
|
|
@@ -12012,7 +12238,7 @@ function dueRecoveries(state, changedThreadId) {
|
|
|
12012
12238
|
|
|
12013
12239
|
// ../../packages/ycodium-system-text/src/memberInstructions.ts
|
|
12014
12240
|
var MEMBER_INSTRUCTIONS_LIMIT = 2e3;
|
|
12015
|
-
var memberInstructionsClause = (member, server) => member?.instructions == null || member.instructions.trim() === "" ? "" : ` Your standing work instructions as a member of this team: ${member.instructions}${member.nextOffset === null ? "" : ` (This is the first part only. Read the rest with work_read_member${server === void 0 ? "" : " on the " + server + " MCP server"}, passing memberId "${member.memberId}" and textOffset ${member.nextOffset}.)`}`;
|
|
12241
|
+
var memberInstructionsClause = (member, server) => member?.instructions == null || member.instructions.trim() === "" ? "" : ` Your standing work instructions as a member of this team: ${member.instructions}${member.nextOffset === null ? "" : ` (This is the first part only. Read the rest with work_read_member${server === void 0 ? "" : " on the " + server + " MCP server"}, passing memberId "${member.memberId}" and textOffset ${member.nextOffset}${member.revision == null ? "" : `, plus expectedRevision ${member.revision}. If it reports a revision conflict, the instructions were edited since this part: discard it and read them again from the start without textOffset or expectedRevision`}.)`}`;
|
|
12016
12242
|
|
|
12017
12243
|
// src/runtime/wakeTexts.ts
|
|
12018
12244
|
var workLabel = (workItemId, sequenceId) => sequenceId === void 0 ? `the work item with workItemId ${workItemId}` : `work item W${sequenceId} (workItemId ${workItemId})`;
|
|
@@ -12031,7 +12257,7 @@ var itemHeadline = (sequenceId, item) => {
|
|
|
12031
12257
|
return parts.length === 0 ? "" : `${parts.join(" ")} `;
|
|
12032
12258
|
};
|
|
12033
12259
|
var startClause = (member) => member === void 0 ? "Otherwise claim it with work_claim_item before you change any file." : "Otherwise start it before you change any file: use work_update_item to move it into an in-progress state (see work_list_states) and leave its assignees as they are. It is assigned to you as a team member, so do not claim it with work_claim_item; claiming is for work nobody holds.";
|
|
12034
|
-
var itemText = (workItemId, sequenceId, item, leadThreadId, member) => `${itemHeadline(sequenceId, item)}You have ${workLabel(workItemId, sequenceId)}. ${handbookMessage("memberBrief")} Then read it with work_read_items, passing workItemIds: ["${workItemId}"]. If it is blocked by items that are not done yet, do not start it; you will be told again when they are done. ${startClause(member)}${memberInstructionsClause(member)} Before you change anything, search this repository's rules and checks with memory_search and follow what applies. Then work on it. ${MEMBER_READ_RANGES_RULE} ${MEMBER_NO_STASH_RULE} ${MEMBER_ASK_BEFORE_OUTSIDE_RULE} ${MEMBER_CHECKS_RULE} ${MEMBER_PROGRESS_RULE} ${memberStuckRule(leadThreadId)}${memberGroupRule(leadThreadId)} ${PERSON_MESSAGE_RULE}`;
|
|
12260
|
+
var itemText = (workItemId, sequenceId, item, leadThreadId, member, roomThreadId) => `${itemHeadline(sequenceId, item)}You have ${workLabel(workItemId, sequenceId)}. ${handbookMessage("memberBrief")} Then read it with work_read_items, passing workItemIds: ["${workItemId}"]. If it is blocked by items that are not done yet, do not start it; you will be told again when they are done. ${startClause(member)}${memberInstructionsClause(member)} Before you change anything, search this repository's rules and checks with memory_search and follow what applies. Then work on it. ${MEMBER_READ_RANGES_RULE} ${MEMBER_NO_STASH_RULE} ${MEMBER_ASK_BEFORE_OUTSIDE_RULE} ${MEMBER_CHECKS_RULE} ${MEMBER_PROGRESS_RULE} ${memberStuckRule(leadThreadId)}${roomThreadId === void 0 ? memberGroupRule(leadThreadId) : memberGroupRule(roomThreadId, false)} ${PERSON_MESSAGE_RULE}`;
|
|
12035
12261
|
var leadItemText = (workItemId, sequenceId, title) => `You have ${titled(workItemId, sequenceId, title)}. You lead this team, so this item is the goal itself: do not claim it or do its work yourself. Read it with work_read_items, passing workItemIds: ["${workItemId}"]. If it has no work items yet, split it as your team brief says. ${LEAD_SPLIT_RULE} ${LEAD_OWN_ITEM_RULE} Record dependencies and assign each item to one member as the brief describes. ${LEAD_NO_MEMBER_TASKS} ${PERSON_MESSAGE_RULE}`;
|
|
12036
12262
|
var leadUnblockedText = (workItemId, sequenceId, title) => `Everything blocking ${titled(workItemId, sequenceId, title)} is done now. Read those items with work_read_items and check the results. ${LEAD_ACCEPT_RULE} ${LEAD_SEND_BACK_RULE} When all of them are acceptable, mark this item done with work_update_item. ${LEAD_NO_MEMBER_TASKS}`;
|
|
12037
12263
|
var unblockedText = (workItemId, sequenceId, title) => `Everything blocking ${titled(workItemId, sequenceId, title)} is done now. Read those items with work_read_items, finish this one, and mark it done with work_update_item.`;
|
|
@@ -12120,6 +12346,32 @@ function memberStarter(previous, settled, moved) {
|
|
|
12120
12346
|
return threadId !== void 0 && Object.values(settled.memberThreads ?? {}).includes(threadId) ? threadId : void 0;
|
|
12121
12347
|
}
|
|
12122
12348
|
|
|
12349
|
+
// src/runtime/lineLeadFold.ts
|
|
12350
|
+
function foldLineLead(state, event) {
|
|
12351
|
+
const change = leadChangeOfEngineEvent(event);
|
|
12352
|
+
if (change === null) return state;
|
|
12353
|
+
const project2 = readFact(state, change.projectId);
|
|
12354
|
+
const scope2 = project2?.lineScopes?.[change.workLineId];
|
|
12355
|
+
const leadMemberId = change.leadMemberId ?? NO_LEAD;
|
|
12356
|
+
if (project2 === null || scope2 === void 0 || scope2.leadMemberId === leadMemberId) return state;
|
|
12357
|
+
const room = roomOf(scope2);
|
|
12358
|
+
return {
|
|
12359
|
+
...state,
|
|
12360
|
+
[change.projectId]: {
|
|
12361
|
+
...project2,
|
|
12362
|
+
lineScopes: {
|
|
12363
|
+
...project2.lineScopes,
|
|
12364
|
+
[change.workLineId]: {
|
|
12365
|
+
...scope2,
|
|
12366
|
+
leadMemberId,
|
|
12367
|
+
...room === void 0 ? {} : { roomThread: room },
|
|
12368
|
+
leadThreads: leadThreadsOf({ bindings: scope2.bindings, leadMemberId })
|
|
12369
|
+
}
|
|
12370
|
+
}
|
|
12371
|
+
}
|
|
12372
|
+
};
|
|
12373
|
+
}
|
|
12374
|
+
|
|
12123
12375
|
// src/runtime/linePauseFold.ts
|
|
12124
12376
|
var EnginePause = Struct({
|
|
12125
12377
|
projectId: String4,
|
|
@@ -12176,7 +12428,7 @@ function withPause(project2, change, legacyEventId) {
|
|
|
12176
12428
|
|
|
12177
12429
|
// src/runtime/wakeState.ts
|
|
12178
12430
|
var WAKE_STATE_KEY = "wakes";
|
|
12179
|
-
var WAKE_STATE_VERSION =
|
|
12431
|
+
var WAKE_STATE_VERSION = 12;
|
|
12180
12432
|
var WAKE_EVENTS = [
|
|
12181
12433
|
"work.item-created",
|
|
12182
12434
|
"work.item-updated",
|
|
@@ -12196,6 +12448,8 @@ var WAKE_EVENTS = [
|
|
|
12196
12448
|
// 团队的线归档、恢复,负责人会话被删:这个团队停工(见 `lineStops`)。
|
|
12197
12449
|
"work.line-archived",
|
|
12198
12450
|
"work.line-restored",
|
|
12451
|
+
// 线换了负责人:线目标范围里的带队会话跟着换(见 `leadThreads`)。
|
|
12452
|
+
"work.line-updated",
|
|
12199
12453
|
"thread.deleted"
|
|
12200
12454
|
];
|
|
12201
12455
|
var emptyProject = () => ({
|
|
@@ -12218,14 +12472,18 @@ var withoutLine = ({ workLineId: _line, ...item }) => item;
|
|
|
12218
12472
|
var lineAfterUpdate = (current, change) => change === void 0 ? current : change ?? void 0;
|
|
12219
12473
|
var scopeOfGoal = (goal) => {
|
|
12220
12474
|
const { members } = goalExecution(goal);
|
|
12475
|
+
const roomThread = isProjectGoal(goal) ? void 0 : roomThreadOf(goal);
|
|
12476
|
+
const bindings = bindingsOf(goal);
|
|
12221
12477
|
return {
|
|
12222
12478
|
goalId: goal.goalId,
|
|
12223
|
-
|
|
12479
|
+
...isProjectGoal(goal) ? {} : { leadMemberId: goal.leadMemberId },
|
|
12480
|
+
...roomThread === void 0 ? {} : { roomThread },
|
|
12481
|
+
bindings,
|
|
12224
12482
|
memberIds: Object.fromEntries(goal.threads.map((member) => [member.threadId, member.memberId])),
|
|
12225
12483
|
threads: [
|
|
12226
12484
|
...new Set(members.flatMap((member) => "threadId" in member ? [member.threadId] : []))
|
|
12227
12485
|
],
|
|
12228
|
-
leadThreads: goal.threads.filter((thread) => thread.memberId === goal.leadMemberId).map((thread) => thread.threadId),
|
|
12486
|
+
leadThreads: isProjectGoal(goal) ? goal.threads.filter((thread) => thread.memberId === goal.leadMemberId).map((thread) => thread.threadId) : leadThreadsOf({ bindings, leadMemberId: goal.leadMemberId }),
|
|
12229
12487
|
...goal.briefDelivered === "inline" ? { inlineBrief: true } : {},
|
|
12230
12488
|
remoteMembers: [
|
|
12231
12489
|
...new Set(
|
|
@@ -12237,11 +12495,12 @@ var scopeOfGoal = (goal) => {
|
|
|
12237
12495
|
var bindIntoScope = (scope2, fact) => {
|
|
12238
12496
|
const binding = bindingOfFact(fact);
|
|
12239
12497
|
const previous = readFact(scope2.bindings ?? {}, fact.memberId);
|
|
12240
|
-
const dropThread = previous !== null && "threadId" in previous && !scope2.leadThreads?.includes(previous.threadId) ? previous.threadId : void 0;
|
|
12498
|
+
const dropThread = previous !== null && "threadId" in previous && !scope2.leadThreads?.includes(previous.threadId) && previous.threadId !== roomOf(scope2) ? previous.threadId : void 0;
|
|
12241
12499
|
const dropPrincipal = previous !== null && "principalId" in previous ? previous.principalId : void 0;
|
|
12500
|
+
const bindings = withBoundBinding(scope2.bindings, fact);
|
|
12242
12501
|
return {
|
|
12243
12502
|
...scope2,
|
|
12244
|
-
bindings
|
|
12503
|
+
bindings,
|
|
12245
12504
|
threads: [
|
|
12246
12505
|
.../* @__PURE__ */ new Set([
|
|
12247
12506
|
...scope2.threads.filter((threadId) => threadId !== dropThread),
|
|
@@ -12254,7 +12513,9 @@ var bindIntoScope = (scope2, fact) => {
|
|
|
12254
12513
|
..."principalId" in binding ? [binding.principalId] : []
|
|
12255
12514
|
])
|
|
12256
12515
|
],
|
|
12257
|
-
..."threadId" in binding ? { memberIds: { ...scope2.memberIds, [binding.threadId]: fact.memberId } } : {}
|
|
12516
|
+
..."threadId" in binding ? { memberIds: { ...scope2.memberIds, [binding.threadId]: fact.memberId } } : {},
|
|
12517
|
+
// 负责人成员(重新)绑定:带队会话按新的绑定重算,改绑到别的机器就空了。
|
|
12518
|
+
...fact.memberId === scope2.leadMemberId ? { leadThreads: leadThreadsOf({ bindings, leadMemberId: scope2.leadMemberId }) } : {}
|
|
12258
12519
|
};
|
|
12259
12520
|
};
|
|
12260
12521
|
var withoutInitialLeadWake = (project2, projectId, workItemId) => {
|
|
@@ -12574,7 +12835,7 @@ function foldLineStops(state, event) {
|
|
|
12574
12835
|
const next = { ...state };
|
|
12575
12836
|
for (const [projectId, project2] of Object.entries(state)) {
|
|
12576
12837
|
const lines = Object.entries(project2.lineScopes ?? {}).filter(
|
|
12577
|
-
([, scope2]) => scope2
|
|
12838
|
+
([, scope2]) => roomOf(scope2) === deleted.value.threadId
|
|
12578
12839
|
);
|
|
12579
12840
|
if (lines.length === 0) continue;
|
|
12580
12841
|
next[projectId] = {
|
|
@@ -12597,6 +12858,7 @@ function foldEnginePause(state, event) {
|
|
|
12597
12858
|
function foldWakes(state, event) {
|
|
12598
12859
|
if (event.type === "work.line-paused" || event.type === "work.line-resumed")
|
|
12599
12860
|
return foldEnginePause(state, event);
|
|
12861
|
+
if (event.type === "work.line-updated") return foldLineLead(state, event);
|
|
12600
12862
|
return foldRecovery(
|
|
12601
12863
|
pruneReviews(state, foldLineStops(foldWorkWakes(state, event), event)),
|
|
12602
12864
|
event,
|
|
@@ -12629,7 +12891,8 @@ function startWakeRuntime(ctx, goals, options = {}) {
|
|
|
12629
12891
|
return {
|
|
12630
12892
|
memberId,
|
|
12631
12893
|
instructions: member?.workInstructions ?? null,
|
|
12632
|
-
nextOffset: member?.workInstructionsWindow?.nextOffset ?? null
|
|
12894
|
+
nextOffset: member?.workInstructionsWindow?.nextOffset ?? null,
|
|
12895
|
+
revision: member?.workInstructionsRevision ?? null
|
|
12633
12896
|
};
|
|
12634
12897
|
};
|
|
12635
12898
|
const baseText = async (wake, state) => {
|
|
@@ -12663,7 +12926,8 @@ function startWakeRuntime(ctx, goals, options = {}) {
|
|
|
12663
12926
|
wake.sequenceId,
|
|
12664
12927
|
item,
|
|
12665
12928
|
wake.leadThreadId,
|
|
12666
|
-
wake.memberId === void 0 ? void 0 : await readMemberBrief(wake.projectId, wake.memberId)
|
|
12929
|
+
wake.memberId === void 0 ? void 0 : await readMemberBrief(wake.projectId, wake.memberId),
|
|
12930
|
+
wake.roomThreadId
|
|
12667
12931
|
);
|
|
12668
12932
|
return (wake.lead === true ? leadUnblockedText : unblockedText)(
|
|
12669
12933
|
wake.workItemId,
|
|
@@ -12672,14 +12936,18 @@ function startWakeRuntime(ctx, goals, options = {}) {
|
|
|
12672
12936
|
);
|
|
12673
12937
|
};
|
|
12674
12938
|
const compose = async (wake, state) => {
|
|
12675
|
-
const
|
|
12676
|
-
const
|
|
12677
|
-
const
|
|
12939
|
+
const project2 = state[wake.projectId];
|
|
12940
|
+
const remoteLeadLine = "principalId" in wake && wake.memberId !== void 0 ? readFact(project2.items, wake.workItemId)?.workLineId : void 0;
|
|
12941
|
+
const remoteLeadScope = remoteLeadLine === void 0 ? void 0 : project2.lineScopes?.[remoteLeadLine];
|
|
12942
|
+
const team = "threadId" in wake ? lineScopeOfThread(project2, wake.threadId) : remoteLeadScope === void 0 || remoteLeadLine === void 0 ? void 0 : { workLineId: remoteLeadLine, scope: remoteLeadScope };
|
|
12943
|
+
const memberId = team === void 0 ? void 0 : "threadId" in wake ? team.scope.memberIds?.[wake.threadId] : wake.memberId;
|
|
12944
|
+
const digest = team === void 0 || memberId === void 0 || !("threadId" in wake) && wake.memberId === void 0 || // 房间自己的 agent 就在房间里,不需要把房间里说的话摘给它;换过负责人之后不在房间里的负责人照样要摘。
|
|
12945
|
+
"threadId" in wake && wake.threadId === roomOf(team.scope) || options.groupDigest === void 0 ? null : await options.groupDigest.prepare({
|
|
12678
12946
|
projectId: wake.projectId,
|
|
12679
12947
|
workLineId: team.workLineId,
|
|
12680
12948
|
memberId,
|
|
12681
|
-
threadId: wake.threadId,
|
|
12682
|
-
leadThreadId: team.scope
|
|
12949
|
+
recipient: "threadId" in wake ? { threadId: wake.threadId } : { principalId: wake.principalId, memberId },
|
|
12950
|
+
leadThreadId: roomOf(team.scope) ?? "",
|
|
12683
12951
|
wakeKey: wake.key,
|
|
12684
12952
|
// 群记录的发件人取成员名(会话号 → 成员号 → 名单),读不到就退回 Lead / Member。
|
|
12685
12953
|
// 名单在这一次摘要里只读一次:惰性缓存同一个 Promise,不随每条记录重读。
|
|
@@ -13485,7 +13753,12 @@ var ReminderSent = Struct({
|
|
|
13485
13753
|
});
|
|
13486
13754
|
|
|
13487
13755
|
// src/handbook/state.ts
|
|
13488
|
-
var HANDBOOK_EVENTS2 = [
|
|
13756
|
+
var HANDBOOK_EVENTS2 = [
|
|
13757
|
+
"plugin.event-appended",
|
|
13758
|
+
"wiki.handbook-released",
|
|
13759
|
+
// 线上负责人的变化:手册里的「负责人」跟着引擎线走。
|
|
13760
|
+
"work.line-updated"
|
|
13761
|
+
];
|
|
13489
13762
|
var emptyHandbookState = () => ({
|
|
13490
13763
|
projects: {},
|
|
13491
13764
|
intents: {},
|
|
@@ -13563,6 +13836,24 @@ var queueReminders = (pending, project2, projectId, release, members) => {
|
|
|
13563
13836
|
return next;
|
|
13564
13837
|
};
|
|
13565
13838
|
function foldHandbook(state, event) {
|
|
13839
|
+
const lead = leadChangeOfEngineEvent(event);
|
|
13840
|
+
if (lead !== null) {
|
|
13841
|
+
const project3 = readFact(state.projects, lead.projectId);
|
|
13842
|
+
const goal = project3?.lineGoals?.[lead.workLineId];
|
|
13843
|
+
if (project3 === null || goal === void 0) return state;
|
|
13844
|
+
const changed = withLineLead(goal, lead);
|
|
13845
|
+
if (changed === goal) return state;
|
|
13846
|
+
return {
|
|
13847
|
+
...state,
|
|
13848
|
+
projects: {
|
|
13849
|
+
...state.projects,
|
|
13850
|
+
[lead.projectId]: {
|
|
13851
|
+
...project3,
|
|
13852
|
+
lineGoals: { ...project3.lineGoals, [lead.workLineId]: changed }
|
|
13853
|
+
}
|
|
13854
|
+
}
|
|
13855
|
+
};
|
|
13856
|
+
}
|
|
13566
13857
|
if (event.type === "wiki.handbook-released") {
|
|
13567
13858
|
const fact2 = decodeRelease(event.payload);
|
|
13568
13859
|
const project3 = readFact(state.projects, fact2.projectId) ?? emptyHandbookProject();
|
|
@@ -13726,7 +14017,8 @@ function startHandbookRuntime(ctx, worktrees) {
|
|
|
13726
14017
|
// 6:折叠也认 team/roster-set 里的导入别名与 team/member-bound。这两种事实在升级前的历史里都不存在(别名只在
|
|
13727
14018
|
// 导入时写,绑定是本版本才有),旧快照续跑不缺东西,所以不必因此再升;规则同 wakeState.ts:折叠对已落盘的历史
|
|
13728
14019
|
// 多折出了东西才升版本。
|
|
13729
|
-
|
|
14020
|
+
// 7:折叠 `work.line-updated` 的负责人变化;已落盘的线更新事件要重折,旧状态从事件重建。
|
|
14021
|
+
version: 7,
|
|
13730
14022
|
events: HANDBOOK_EVENTS2,
|
|
13731
14023
|
init: emptyHandbookState,
|
|
13732
14024
|
apply: foldHandbook
|
|
@@ -14384,7 +14676,7 @@ function createArchiveMirror(ctx, deps) {
|
|
|
14384
14676
|
const wakes = await deps.wakes.get();
|
|
14385
14677
|
for (const [projectId, project2] of Object.entries(wakes)) {
|
|
14386
14678
|
for (const [workLineId, scope2] of Object.entries(project2.lineScopes ?? {})) {
|
|
14387
|
-
const leadThreadId = scope2
|
|
14679
|
+
const leadThreadId = roomOf(scope2);
|
|
14388
14680
|
if (leadThreadId === void 0) continue;
|
|
14389
14681
|
if (threadId !== void 0 && lineScopeOfThread(project2, threadId)?.workLineId !== workLineId)
|
|
14390
14682
|
continue;
|
|
@@ -14446,11 +14738,25 @@ var TeamSetMembersInput = Struct({
|
|
|
14446
14738
|
add: optionalKey2(ArraySchema(MemberId)),
|
|
14447
14739
|
remove: optionalKey2(ArraySchema(MemberId))
|
|
14448
14740
|
});
|
|
14741
|
+
var TeamSetLeadInput = Struct({ requestId: RequestId, memberId: MemberId });
|
|
14742
|
+
var LineMembersView = Struct({
|
|
14743
|
+
workLineId: String4,
|
|
14744
|
+
version: Int,
|
|
14745
|
+
archived: Boolean3,
|
|
14746
|
+
leadMemberId: NullOr(String4),
|
|
14747
|
+
memberIds: ArraySchema(String4),
|
|
14748
|
+
/** 现任负责人名下还开着的件数:设别人为负责人时这些会改给新负责人。 */
|
|
14749
|
+
leadOpenItems: Int,
|
|
14750
|
+
/** 成员号 → 它名下还没交到手上的开着的件数:移除它时会退回负责人的;没有的成员不在里面。 */
|
|
14751
|
+
returnable: Record(String4, Int),
|
|
14752
|
+
/** 只在「移除」命令的结果里带:成员组已改,名下的件还没退完(会自己做完)。 */
|
|
14753
|
+
returnPending: optionalKey2(Boolean3)
|
|
14754
|
+
});
|
|
14449
14755
|
var LineChangeIntended = Struct({
|
|
14450
14756
|
version: Literal2(1),
|
|
14451
14757
|
projectId: String4,
|
|
14452
14758
|
requestId: String4,
|
|
14453
|
-
op: Literals(["open", "set-members"]),
|
|
14759
|
+
op: Literals(["open", "set-members", "set-lead"]),
|
|
14454
14760
|
callerThreadId: String4,
|
|
14455
14761
|
inputHash: String4,
|
|
14456
14762
|
input: Unknown2
|
|
@@ -14470,11 +14776,6 @@ var LineChangeCompleted = Struct({
|
|
|
14470
14776
|
])
|
|
14471
14777
|
});
|
|
14472
14778
|
|
|
14473
|
-
// src/team/messages.ts
|
|
14474
|
-
function teamMessage(key, values = {}) {
|
|
14475
|
-
return interpolateMessage(en_default.team[key], values);
|
|
14476
|
-
}
|
|
14477
|
-
|
|
14478
14779
|
// src/team/state.ts
|
|
14479
14780
|
var lineChangeKey = (projectId, callerThreadId, requestId) => JSON.stringify([projectId, callerThreadId, requestId]);
|
|
14480
14781
|
var decode2 = decodeUnknownOption2(
|
|
@@ -14512,13 +14813,23 @@ var TeamRuleError = class extends Error {
|
|
|
14512
14813
|
this.code = code;
|
|
14513
14814
|
}
|
|
14514
14815
|
};
|
|
14816
|
+
var refuseLead = (reason) => reason === "update-required" ? new TeamRuleError("member-machine-update-required", remoteLeadRefusal(reason)) : reason === "several-teams" ? new TeamRuleError("several-teams", remoteLeadRefusal(reason)) : new TeamRuleError("lead-only", teamMessage("leadOnly"));
|
|
14515
14817
|
var mark = (projectId, threadId, requestId) => stableHash(JSON.stringify([projectId, threadId, requestId]));
|
|
14516
|
-
function
|
|
14818
|
+
function localCallerOf(invocation) {
|
|
14517
14819
|
const { projectId, caller } = invocation;
|
|
14518
14820
|
if (projectId === null) throw new TeamRuleError("no-project", teamMessage("noProject"));
|
|
14519
14821
|
if (caller?.kind !== "thread") throw new TeamRuleError("not-local", teamMessage("notLocal"));
|
|
14520
14822
|
return { projectId, callerThreadId: caller.threadId };
|
|
14521
14823
|
}
|
|
14824
|
+
function callerOf(invocation) {
|
|
14825
|
+
const { projectId, caller } = invocation;
|
|
14826
|
+
if (projectId === null) throw new TeamRuleError("no-project", teamMessage("noProject"));
|
|
14827
|
+
if (caller?.kind === "thread") return { projectId, callerThreadId: caller.threadId };
|
|
14828
|
+
if (caller?.kind !== "remote-agent")
|
|
14829
|
+
throw new TeamRuleError("not-local", teamMessage("notLocal"));
|
|
14830
|
+
if (caller.memberId === void 0) throw refuseLead("update-required");
|
|
14831
|
+
return { projectId, callerThreadId: `remote:${caller.principalId}:${caller.memberId}` };
|
|
14832
|
+
}
|
|
14522
14833
|
function createLineChangeRunner(ctx, deps) {
|
|
14523
14834
|
const complete = async (intent, outcome) => {
|
|
14524
14835
|
await ctx.events.append({
|
|
@@ -14583,6 +14894,37 @@ function createLineChangeRunner(ctx, deps) {
|
|
|
14583
14894
|
await deps.changes.get();
|
|
14584
14895
|
return finish(intent, request.run);
|
|
14585
14896
|
},
|
|
14897
|
+
/**
|
|
14898
|
+
* 只做一次、不自动重做的改动(`team_set_lead`):同号重放回第一次成功的结果(换了内容算冲突),否则现在就做;
|
|
14899
|
+
* 成功后才记下结果供重放;做不成(规则拒绝、冲突、写失败)一律原样抛出,什么都不记,也不会在重启时补做。
|
|
14900
|
+
*/
|
|
14901
|
+
async once(request) {
|
|
14902
|
+
const { projectId, callerThreadId, requestId } = request;
|
|
14903
|
+
const known = (await deps.changes.get())[lineChangeKey(projectId, callerThreadId, requestId)];
|
|
14904
|
+
if (known !== void 0) {
|
|
14905
|
+
if (known.intent.op !== request.op || known.intent.inputHash !== request.inputHash)
|
|
14906
|
+
throw new TeamRuleError("request-conflict", teamMessage("requestConflict"));
|
|
14907
|
+
if (known.completed?.outcome.status === "succeeded") return known.completed.outcome.result;
|
|
14908
|
+
}
|
|
14909
|
+
const result2 = await request.run();
|
|
14910
|
+
const intent = {
|
|
14911
|
+
version: 1,
|
|
14912
|
+
projectId,
|
|
14913
|
+
requestId,
|
|
14914
|
+
op: request.op,
|
|
14915
|
+
callerThreadId,
|
|
14916
|
+
inputHash: request.inputHash,
|
|
14917
|
+
input: null
|
|
14918
|
+
};
|
|
14919
|
+
await ctx.events.append({
|
|
14920
|
+
commandId: `team-line-intended:${mark(projectId, callerThreadId, requestId)}`,
|
|
14921
|
+
name: "line-change-intended",
|
|
14922
|
+
aggregate: { kind: "project", id: projectId },
|
|
14923
|
+
data: intent
|
|
14924
|
+
});
|
|
14925
|
+
await complete(intent, { status: "succeeded", result: result2 });
|
|
14926
|
+
return result2;
|
|
14927
|
+
},
|
|
14586
14928
|
/** 挂载对账:意图落了、结局没落的这一种改动,用记着的输入接着做。 */
|
|
14587
14929
|
async reconcile(op, run2) {
|
|
14588
14930
|
for (const record2 of Object.values(await deps.changes.get())) {
|
|
@@ -14603,6 +14945,7 @@ function createLineChangeRunner(ctx, deps) {
|
|
|
14603
14945
|
// src/team/brief.ts
|
|
14604
14946
|
var REMOTE_WHERE_PREFIX = "machine: ";
|
|
14605
14947
|
function teamLeadBrief(team) {
|
|
14948
|
+
const home = team.room === void 0 ? "this conversation" : `the team conversation ${team.room}`;
|
|
14606
14949
|
const table = [
|
|
14607
14950
|
"| Member | memberId | threadId / machine | Ready |",
|
|
14608
14951
|
"| --- | --- | --- | --- |",
|
|
@@ -14612,11 +14955,11 @@ function teamLeadBrief(team) {
|
|
|
14612
14955
|
].join("\n");
|
|
14613
14956
|
const hasRemote = team.members.some((member) => member.where.startsWith(REMOTE_WHERE_PREFIX));
|
|
14614
14957
|
return [
|
|
14615
|
-
`You are now the lead of the team "${team.name}". This conversation is the team: the person talks to you here, and your members are woken from here.`,
|
|
14958
|
+
team.room === void 0 ? `You are now the lead of the team "${team.name}". This conversation is the team: the person talks to you here, and your members are woken from here.` : team.remote === true ? `You are now the lead of the team "${team.name}". You are on another machine from the team's conversation ${team.room}, so you work through messages: the person talks to the team there and your members are woken from there. Read it with message_list { groupThreadId: "${team.room}" }; it is also where the person answers what the team is waiting on. Another member led before you; their open work items are now yours.` : `You are now the lead of the team "${team.name}". The team is the conversation ${team.room}, not this one: the person talks to the team there and your members are woken from there. Read it with list_thread_messages { threadId: "${team.room}" }; it is also where the person answers what the team is waiting on. Another member led before you; their open work items are now yours.`,
|
|
14616
14959
|
"What was agreed:",
|
|
14617
14960
|
team.goal,
|
|
14618
14961
|
handbookMessage("leadBrief"),
|
|
14619
|
-
|
|
14962
|
+
`Team members and their assignment identities${team.room === void 0 ? " (your own conversation is omitted)" : ""}:`,
|
|
14620
14963
|
table,
|
|
14621
14964
|
`Members whose Ready value is trial-pending are still being trial-run and start work when they pass; trial-failed members need a fix first (team_update_member or team_retry_trial); you can see who is ready at any time with team_roster_overview.`,
|
|
14622
14965
|
`This team's work line is "${team.workLineId}". Every work item you create for this team must be created with workLineId "${team.workLineId}" (work_create_item), and work_list_items with workLineIds ["${team.workLineId}"] shows only this team's items. The goal is on the board as work item "${team.goalItemId}", assigned to you so the person can see when it is finished. Do not claim it or work on it yourself.`,
|
|
@@ -14633,17 +14976,17 @@ function teamLeadBrief(team) {
|
|
|
14633
14976
|
LEAD_START_CHECK_RULE,
|
|
14634
14977
|
LEAD_REBALANCE_RULE,
|
|
14635
14978
|
...hasRemote ? [
|
|
14636
|
-
|
|
14979
|
+
`Members marked with a machine run on that other machine. Assign them work like the others; their machine picks it up and runs them with the model in their member record. Do not create conversations, start turns, or send wake-up signals for them on this machine; if their machine is offline, the work waits until it is back. A comment that mentions a remote member wakes them on their machine; once they mark an item done they stop working on it, so to send work back you reopen the item as described above. Whatever a remote member needs a person for is handled on their machine, not in ${home}.`
|
|
14637
14980
|
] : [],
|
|
14638
|
-
|
|
14639
|
-
|
|
14981
|
+
`How the group works: when a member is woken it is shown what was said in this group since it last looked (the person's words and yours, plus group records, at most about 30 messages; never any tool call or thinking), so you do not have to repeat what was agreed. Older messages are read with ${team.remote === true ? "" : `list_thread_messages on ${home}, and older group records with `}message_list { groupThreadId: ${home} }. Members cannot see anything else you do, so put what a member needs into the work item description.`,
|
|
14982
|
+
`To ask a member something in the group, use send_message with to: { group: { threadId: ${home} } } and mentions: [{ memberId }] for each member your text addresses with @name. Each mentioned member is woken; other group messages and members' replies reach you as a quiet copy in your inbox and never start a turn for you. Members answer in the group with replyTo to the record they are answering; a reply on its own wakes nobody, so a member who needs you mentions you in the text.`,
|
|
14640
14983
|
`The person can pause this team or one member on its line: while paused nothing is handed out and group messages are not delivered, and resuming carries on from where it stopped. When an agent's back-and-forth in the group makes no progress for ${NO_PROGRESS_TURNS} turns, the wake-ups it causes are delayed (${NO_PROGRESS_DELAY_MINUTES} minutes, doubling up to ${NO_PROGRESS_DELAY_CAP_MINUTES} minutes); a person's message always goes immediately, and a turn a member spent waiting on someone does not count as no progress.`,
|
|
14641
|
-
|
|
14642
|
-
|
|
14984
|
+
`Members run with full access. When something still needs a person, such as an approval, a question for the person, a plan to confirm or a tool asking for information, it appears in ${home} for the person to answer. You cannot answer it for them. When you are woken you are told what the team is waiting on; plan around the blocked members instead of waiting.`,
|
|
14985
|
+
`The person can stop the team by archiving ${home}: no new work is handed out, each member finishes the step it is on and stops, and unarchiving lets the team carry on from where it stopped.`,
|
|
14643
14986
|
LEAD_PROGRESS_SUMMARY_RULE,
|
|
14644
14987
|
LEAD_SCHEDULE_CHECKIN_RULE,
|
|
14645
14988
|
LEAD_WORKTREES_KEPT_RULE,
|
|
14646
|
-
"The person is in this conversation: ask them directly in your replies. Use send_message only for people who are not in it. Put progress, updates and technical problems in work item comments with work_post_comment.",
|
|
14989
|
+
team.room === void 0 ? "The person is in this conversation: ask them directly in your replies. Use send_message only for people who are not in it. Put progress, updates and technical problems in work item comments with work_post_comment." : `The person may speak to you in this conversation, and also in ${home}. Put progress, updates and technical problems in work item comments with work_post_comment.`,
|
|
14647
14990
|
"If the work item tools are unavailable, tell the user directly that this project needs the board and project memory switches turned on first."
|
|
14648
14991
|
].join("\n\n");
|
|
14649
14992
|
}
|
|
@@ -14948,7 +15291,7 @@ function createTeamOpener(ctx, deps, runner = createLineChangeRunner(ctx, deps),
|
|
|
14948
15291
|
};
|
|
14949
15292
|
};
|
|
14950
15293
|
const open = async (payload, invocation) => {
|
|
14951
|
-
const { projectId, callerThreadId } =
|
|
15294
|
+
const { projectId, callerThreadId } = localCallerOf(invocation);
|
|
14952
15295
|
const decoded = decodeOpen(payload);
|
|
14953
15296
|
if (isNone2(decoded) || goalText(decoded.value.goal) === null || decoded.value.name.trim() === "")
|
|
14954
15297
|
throw new TeamRuleError("invalid-input", teamMessage("invalidInput"));
|
|
@@ -15065,73 +15408,122 @@ function createTeamOverview(ctx, deps) {
|
|
|
15065
15408
|
};
|
|
15066
15409
|
}
|
|
15067
15410
|
|
|
15411
|
+
// src/team/setLead.ts
|
|
15412
|
+
var decodeSet = decodeUnknownOption2(TeamSetLeadInput);
|
|
15413
|
+
function createTeamLeadChanger(ctx, deps, runner) {
|
|
15414
|
+
const setLead = async (payload, invocation) => {
|
|
15415
|
+
const { projectId, callerThreadId } = callerOf(invocation);
|
|
15416
|
+
const decoded = decodeSet(payload);
|
|
15417
|
+
if (isNone2(decoded))
|
|
15418
|
+
throw new TeamRuleError("invalid-input", teamMessage("invalidInput"));
|
|
15419
|
+
const input = decoded.value;
|
|
15420
|
+
return runner.once({
|
|
15421
|
+
op: "set-lead",
|
|
15422
|
+
projectId,
|
|
15423
|
+
callerThreadId,
|
|
15424
|
+
requestId: input.requestId,
|
|
15425
|
+
inputHash: stableHash(JSON.stringify([input.memberId])),
|
|
15426
|
+
run: async () => {
|
|
15427
|
+
const lead = await checkLead(deps.goals, invocation);
|
|
15428
|
+
if (!lead.ok) throw refuseLead(lead.reason);
|
|
15429
|
+
const workLineId = lead.goal.workLineId;
|
|
15430
|
+
if (workLineId === void 0) throw refuseLead("lead-only");
|
|
15431
|
+
const { line } = await ctx.work.lines.get({ projectId, workLineId });
|
|
15432
|
+
if (line.leadMemberId !== lead.goal.leadMemberId)
|
|
15433
|
+
throw new TeamRuleError("lead-changed", teamMessage("leadChanged"));
|
|
15434
|
+
if (input.memberId === line.leadMemberId)
|
|
15435
|
+
throw new TeamRuleError("already-lead", teamMessage("alreadyLead"));
|
|
15436
|
+
const member = await findMember(ctx, projectId, input.memberId, { textLimit: 2 });
|
|
15437
|
+
if (member === null)
|
|
15438
|
+
throw new TeamRuleError(
|
|
15439
|
+
"member-not-found",
|
|
15440
|
+
teamMessage("memberNotFound", { memberId: input.memberId })
|
|
15441
|
+
);
|
|
15442
|
+
if (member.removedAt !== null)
|
|
15443
|
+
throw new TeamRuleError(
|
|
15444
|
+
"member-removed",
|
|
15445
|
+
teamMessage("memberRemoved", { memberId: input.memberId })
|
|
15446
|
+
);
|
|
15447
|
+
if (line.archivedAt !== null)
|
|
15448
|
+
throw new TeamRuleError("team-archived", teamMessage("teamArchived"));
|
|
15449
|
+
if (!line.memberIds.includes(input.memberId))
|
|
15450
|
+
throw new TeamRuleError(
|
|
15451
|
+
"member-not-on-team",
|
|
15452
|
+
teamMessage("memberNotOnTeam", { memberId: input.memberId })
|
|
15453
|
+
);
|
|
15454
|
+
try {
|
|
15455
|
+
await ctx.work.lines.update({
|
|
15456
|
+
projectId,
|
|
15457
|
+
workLineId,
|
|
15458
|
+
expectedVersion: line.version,
|
|
15459
|
+
requestId: `team-line-lead:${mark(projectId, callerThreadId, input.requestId)}`,
|
|
15460
|
+
leadMemberId: input.memberId
|
|
15461
|
+
});
|
|
15462
|
+
} catch (error) {
|
|
15463
|
+
if (hostRefusalCode(error) === "version-conflict")
|
|
15464
|
+
throw new TeamRuleError("lead-changed", teamMessage("leadChanged"));
|
|
15465
|
+
throw error;
|
|
15466
|
+
}
|
|
15467
|
+
return { status: "updated", workLineId, leadMemberId: input.memberId };
|
|
15468
|
+
}
|
|
15469
|
+
});
|
|
15470
|
+
};
|
|
15471
|
+
return { setLead };
|
|
15472
|
+
}
|
|
15473
|
+
|
|
15474
|
+
// src/team/lineWrite.ts
|
|
15475
|
+
async function writeLineVersioned(input, write) {
|
|
15476
|
+
const line = input.first ?? await input.readLine();
|
|
15477
|
+
try {
|
|
15478
|
+
return await write(line, "");
|
|
15479
|
+
} catch (error) {
|
|
15480
|
+
if (!input.isConflict(error)) throw error;
|
|
15481
|
+
try {
|
|
15482
|
+
return await write(await input.readLine(), ":2");
|
|
15483
|
+
} catch (second) {
|
|
15484
|
+
throw input.isConflict(second) && input.exhausted !== void 0 ? input.exhausted() : second;
|
|
15485
|
+
}
|
|
15486
|
+
}
|
|
15487
|
+
}
|
|
15488
|
+
|
|
15068
15489
|
// src/team/setMembers.ts
|
|
15069
|
-
var
|
|
15490
|
+
var decodeSet2 = decodeUnknownOption2(TeamSetMembersInput);
|
|
15070
15491
|
var Plan = Struct({
|
|
15071
15492
|
...TeamSetMembersInput.fields,
|
|
15072
15493
|
plan: Struct({
|
|
15073
15494
|
add: ArraySchema(String4),
|
|
15074
15495
|
remove: ArraySchema(String4)
|
|
15075
|
-
})
|
|
15496
|
+
}),
|
|
15497
|
+
/** 调用时的团队(线):远端负责人没有会话号可查,意图里记下它。 */
|
|
15498
|
+
workLineId: optionalKey2(String4)
|
|
15076
15499
|
});
|
|
15077
15500
|
var decodePlan = decodeUnknownOption2(Plan);
|
|
15078
15501
|
function createTeamMembersChanger(ctx, deps, runner) {
|
|
15079
15502
|
const run2 = async (intent) => {
|
|
15080
15503
|
const { projectId, callerThreadId, requestId } = intent;
|
|
15081
|
-
const { plan } = getOrThrow(decodePlan(intent.input));
|
|
15082
|
-
const
|
|
15083
|
-
if (
|
|
15084
|
-
|
|
15085
|
-
const
|
|
15086
|
-
|
|
15087
|
-
if (line.archivedAt !== null)
|
|
15504
|
+
const { plan, workLineId: recorded } = getOrThrow(decodePlan(intent.input));
|
|
15505
|
+
const workLineId = recorded ?? (await deps.goals.ofThread(projectId, callerThreadId))?.workLineId;
|
|
15506
|
+
if (workLineId === void 0) throw refuseLead("lead-only");
|
|
15507
|
+
const readLine = async () => (await ctx.work.lines.get({ projectId, workLineId })).line;
|
|
15508
|
+
const first = await readLine();
|
|
15509
|
+
if (first.archivedAt !== null)
|
|
15088
15510
|
throw new TeamRuleError("team-archived", teamMessage("teamArchived"));
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
requestId: `team-line-members:${mark(projectId, callerThreadId, requestId)}${attempt === 1 ? "" : `:${attempt}`}`,
|
|
15098
|
-
...plan.add.length === 0 ? {} : { addMemberIds: plan.add },
|
|
15099
|
-
...plan.remove.length === 0 ? {} : { removeMemberIds: plan.remove }
|
|
15100
|
-
});
|
|
15101
|
-
break;
|
|
15102
|
-
} catch (error) {
|
|
15103
|
-
if (hostRefusalCode(error) !== "version-conflict") throw error;
|
|
15104
|
-
if (attempt >= 2)
|
|
15105
|
-
throw new TeamRuleError("version-conflict", teamMessage("versionConflict"));
|
|
15106
|
-
line = (await ctx.work.lines.get({ projectId, workLineId })).line;
|
|
15107
|
-
}
|
|
15108
|
-
}
|
|
15109
|
-
}
|
|
15110
|
-
const project2 = readFact(await deps.wakes.get(), projectId);
|
|
15111
|
-
const returned = [];
|
|
15112
|
-
for (const [workItemId, item] of Object.entries(project2?.items ?? {})) {
|
|
15113
|
-
if (item.workLineId !== workLineId || isClosed(item)) continue;
|
|
15114
|
-
const taken = plan.remove.filter(
|
|
15115
|
-
(id) => item.assigneeMembers?.includes(id) === true && notYetHandedOver(item, id)
|
|
15116
|
-
);
|
|
15117
|
-
if (taken.length === 0) continue;
|
|
15118
|
-
const written2 = await updateAssignees(ctx, {
|
|
15511
|
+
const written2 = plan.add.length === 0 && plan.remove.length === 0 ? null : await writeLineVersioned(
|
|
15512
|
+
{
|
|
15513
|
+
readLine,
|
|
15514
|
+
first,
|
|
15515
|
+
isConflict: (error) => hostRefusalCode(error) === "version-conflict",
|
|
15516
|
+
exhausted: () => new TeamRuleError("version-conflict", teamMessage("versionConflict"))
|
|
15517
|
+
},
|
|
15518
|
+
async (line, suffix) => (await ctx.work.lines.update({
|
|
15119
15519
|
projectId,
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
return kept.some(
|
|
15128
|
-
(assignee) => assignee.kind === "member" && assignee.memberId === leadMemberId
|
|
15129
|
-
) ? kept : [...kept, { kind: "member", memberId: leadMemberId }];
|
|
15130
|
-
}
|
|
15131
|
-
});
|
|
15132
|
-
if (!written2) continue;
|
|
15133
|
-
returned.push(workItemId);
|
|
15134
|
-
}
|
|
15520
|
+
workLineId,
|
|
15521
|
+
expectedVersion: line.version,
|
|
15522
|
+
requestId: `team-line-members:${mark(projectId, callerThreadId, requestId)}${suffix}`,
|
|
15523
|
+
...plan.add.length === 0 ? {} : { addMemberIds: plan.add },
|
|
15524
|
+
...plan.remove.length === 0 ? {} : { removeMemberIds: plan.remove }
|
|
15525
|
+
})).sequence
|
|
15526
|
+
);
|
|
15135
15527
|
const trials2 = await deps.trials.get();
|
|
15136
15528
|
const added = await Promise.all(
|
|
15137
15529
|
plan.add.map(async (memberId) => {
|
|
@@ -15147,16 +15539,24 @@ function createTeamMembersChanger(ctx, deps, runner) {
|
|
|
15147
15539
|
workLineId,
|
|
15148
15540
|
added,
|
|
15149
15541
|
removed: plan.remove,
|
|
15150
|
-
|
|
15542
|
+
// 移出的收尾(还没交到它手上的活退回负责人)是线更新事件上的待办,页面的「移除」共用:结果里不固化「退回了几件」,
|
|
15543
|
+
// 记下线更新的提交序号,每次回结果时(含同号重放)再读收尾的现状。
|
|
15544
|
+
removalSequence: written2 === null || plan.remove.length === 0 ? void 0 : written2
|
|
15151
15545
|
};
|
|
15152
15546
|
};
|
|
15547
|
+
const withReturn = async (projectId, recorded) => {
|
|
15548
|
+
const { removalSequence, ...rest } = recorded;
|
|
15549
|
+
if (removalSequence === void 0) return rest;
|
|
15550
|
+
const outcome = await deps.lineRemovals.outcomeOf(projectId, rest.workLineId, removalSequence);
|
|
15551
|
+
return outcome.done ? { ...rest, returnStatus: "done", returnedToYou: outcome.returned } : { ...rest, returnStatus: "pending" };
|
|
15552
|
+
};
|
|
15153
15553
|
const setMembers = async (payload, invocation) => {
|
|
15154
15554
|
const { projectId, callerThreadId } = callerOf(invocation);
|
|
15155
|
-
const decoded =
|
|
15555
|
+
const decoded = decodeSet2(payload);
|
|
15156
15556
|
if (isNone2(decoded))
|
|
15157
15557
|
throw new TeamRuleError("invalid-input", teamMessage("invalidInput"));
|
|
15158
15558
|
const input = decoded.value;
|
|
15159
|
-
|
|
15559
|
+
const result2 = await runner.submit({
|
|
15160
15560
|
op: "set-members",
|
|
15161
15561
|
projectId,
|
|
15162
15562
|
callerThreadId,
|
|
@@ -15165,10 +15565,10 @@ function createTeamMembersChanger(ctx, deps, runner) {
|
|
|
15165
15565
|
run: run2,
|
|
15166
15566
|
precheck: async () => {
|
|
15167
15567
|
const lead = await checkLead(deps.goals, invocation);
|
|
15168
|
-
|
|
15169
|
-
if (!lead.ok || workLineId === void 0)
|
|
15170
|
-
throw new TeamRuleError("lead-only", teamMessage("leadOnly"));
|
|
15568
|
+
if (!lead.ok) throw refuseLead(lead.reason);
|
|
15171
15569
|
const { goal } = lead;
|
|
15570
|
+
const workLineId = goal.workLineId;
|
|
15571
|
+
if (workLineId === void 0) throw refuseLead("lead-only");
|
|
15172
15572
|
if ((input.remove ?? []).includes(goal.leadMemberId))
|
|
15173
15573
|
throw new TeamRuleError("cannot-remove-lead", teamMessage("cannotRemoveLead"));
|
|
15174
15574
|
for (const memberId of new Set(input.add ?? [])) {
|
|
@@ -15187,6 +15587,7 @@ function createTeamMembersChanger(ctx, deps, runner) {
|
|
|
15187
15587
|
const onLine = new Set(line.memberIds);
|
|
15188
15588
|
return {
|
|
15189
15589
|
...input,
|
|
15590
|
+
workLineId,
|
|
15190
15591
|
plan: {
|
|
15191
15592
|
add: [...new Set(input.add ?? [])].filter((id) => !onLine.has(id)),
|
|
15192
15593
|
remove: [...new Set(input.remove ?? [])].filter((id) => onLine.has(id))
|
|
@@ -15194,6 +15595,7 @@ function createTeamMembersChanger(ctx, deps, runner) {
|
|
|
15194
15595
|
};
|
|
15195
15596
|
}
|
|
15196
15597
|
});
|
|
15598
|
+
return withReturn(projectId, result2);
|
|
15197
15599
|
};
|
|
15198
15600
|
return { setMembers, reconcile: () => runner.reconcile("set-members", run2) };
|
|
15199
15601
|
}
|
|
@@ -15203,6 +15605,7 @@ function registerTeamTools(ctx, deps, queue) {
|
|
|
15203
15605
|
const runner = createLineChangeRunner(ctx, deps);
|
|
15204
15606
|
const opener = createTeamOpener(ctx, deps, runner);
|
|
15205
15607
|
const changer = createTeamMembersChanger(ctx, deps, runner);
|
|
15608
|
+
const leadChanger = createTeamLeadChanger(ctx, deps, runner);
|
|
15206
15609
|
const overview = createTeamOverview(ctx, deps);
|
|
15207
15610
|
const serial = (task) => queue.run(task);
|
|
15208
15611
|
ctx.toolkit({
|
|
@@ -15216,12 +15619,21 @@ function registerTeamTools(ctx, deps, queue) {
|
|
|
15216
15619
|
},
|
|
15217
15620
|
{
|
|
15218
15621
|
name: "set_members",
|
|
15622
|
+
remoteAvailable: true,
|
|
15219
15623
|
description: teamMessage("setMembersTool"),
|
|
15220
15624
|
inputSchema: toolSchema(TeamSetMembersInput),
|
|
15221
15625
|
handle: (input, invocation) => runTool(() => serial(() => changer.setMembers(input, invocation)))
|
|
15222
15626
|
},
|
|
15627
|
+
{
|
|
15628
|
+
name: "set_lead",
|
|
15629
|
+
remoteAvailable: true,
|
|
15630
|
+
description: teamMessage("setLeadTool"),
|
|
15631
|
+
inputSchema: toolSchema(TeamSetLeadInput),
|
|
15632
|
+
handle: (input, invocation) => runTool(() => serial(() => leadChanger.setLead(input, invocation)))
|
|
15633
|
+
},
|
|
15223
15634
|
{
|
|
15224
15635
|
name: "roster_overview",
|
|
15636
|
+
remoteAvailable: true,
|
|
15225
15637
|
description: teamMessage("rosterOverviewTool"),
|
|
15226
15638
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
15227
15639
|
handle: (_input, invocation) => runTool(async () => {
|
|
@@ -15240,15 +15652,456 @@ function registerTeamTools(ctx, deps, queue) {
|
|
|
15240
15652
|
return { ready };
|
|
15241
15653
|
}
|
|
15242
15654
|
|
|
15243
|
-
// src/
|
|
15655
|
+
// src/runtime/followUp.ts
|
|
15656
|
+
var SWEEP_MS = 12e4;
|
|
15657
|
+
var LOG_EVERY_FAILURES = 15;
|
|
15658
|
+
function startFollowUp(ctx, options) {
|
|
15659
|
+
const queue = createSerial(`${options.name}-closed`);
|
|
15660
|
+
ctx.onDispose(queue.close);
|
|
15661
|
+
const failures = /* @__PURE__ */ new Map();
|
|
15662
|
+
const execute = async (trigger) => {
|
|
15663
|
+
for (const row of await options.pending(trigger === "sweep" ? void 0 : trigger.through)) {
|
|
15664
|
+
const key = options.keyOf(row);
|
|
15665
|
+
if (trigger !== "sweep" && trigger.project !== void 0 && trigger.project !== options.projectOf(row))
|
|
15666
|
+
continue;
|
|
15667
|
+
try {
|
|
15668
|
+
if (await options.settle(row) === "settled") failures.delete(key);
|
|
15669
|
+
} catch (error) {
|
|
15670
|
+
const count2 = (failures.get(key) ?? 0) + 1;
|
|
15671
|
+
failures.set(key, count2);
|
|
15672
|
+
if (count2 === 1 || count2 % LOG_EVERY_FAILURES === 0)
|
|
15673
|
+
ctx.log.warn(`${options.name} follow-up failed; it is retried on the next sweep`, {
|
|
15674
|
+
key,
|
|
15675
|
+
count: count2,
|
|
15676
|
+
error
|
|
15677
|
+
});
|
|
15678
|
+
}
|
|
15679
|
+
}
|
|
15680
|
+
};
|
|
15681
|
+
const flush = (trigger = {}) => queue.run(() => execute(trigger));
|
|
15682
|
+
ctx.reactor({
|
|
15683
|
+
name: options.name,
|
|
15684
|
+
events: options.events,
|
|
15685
|
+
handle: (event) => options.accepts !== void 0 && !options.accepts(event) ? Promise.resolve() : flush({ project: event.aggregateKind === "project" ? event.aggregateId : void 0 })
|
|
15686
|
+
});
|
|
15687
|
+
ctx.interval({ name: options.name, everyMs: SWEEP_MS, handle: () => flush("sweep") });
|
|
15688
|
+
const ready = flush();
|
|
15689
|
+
void ready.catch(
|
|
15690
|
+
(error) => ctx.log.warn(`${options.name} follow-up catch-up failed`, { error })
|
|
15691
|
+
);
|
|
15692
|
+
return { flush, ready };
|
|
15693
|
+
}
|
|
15694
|
+
|
|
15695
|
+
// src/team/leadHandover.ts
|
|
15696
|
+
var decodeLineCreated = decodeUnknownOption2(
|
|
15697
|
+
Struct({
|
|
15698
|
+
projectId: String4,
|
|
15699
|
+
workLineId: String4,
|
|
15700
|
+
leadMemberId: optionalKey2(NullOr(String4))
|
|
15701
|
+
})
|
|
15702
|
+
);
|
|
15703
|
+
var Settled = Struct({
|
|
15704
|
+
version: Literal2(1),
|
|
15705
|
+
workLineId: String4,
|
|
15706
|
+
sequence: Number5
|
|
15707
|
+
});
|
|
15708
|
+
var decodeSettled = decodeUnknownOption2(factEnvelope("lead-handover-settled", Settled));
|
|
15709
|
+
function foldLeadHandovers(state, event) {
|
|
15710
|
+
if (event.type === "work.line-created") {
|
|
15711
|
+
const created = decodeLineCreated(event.payload);
|
|
15712
|
+
if (isNone2(created) || typeof created.value.leadMemberId !== "string") return state;
|
|
15713
|
+
return {
|
|
15714
|
+
...state,
|
|
15715
|
+
leads: { ...state.leads, [created.value.workLineId]: created.value.leadMemberId }
|
|
15716
|
+
};
|
|
15717
|
+
}
|
|
15718
|
+
const change = leadChangeOfEngineEvent(event);
|
|
15719
|
+
if (change !== null && change.leadMemberId !== null) {
|
|
15720
|
+
const previous = readFact(state.leads, change.workLineId);
|
|
15721
|
+
const leads = { ...state.leads, [change.workLineId]: change.leadMemberId };
|
|
15722
|
+
if (previous === null || previous === change.leadMemberId) return { ...state, leads };
|
|
15723
|
+
const open2 = readFact(state.pending, change.workLineId);
|
|
15724
|
+
const from = [.../* @__PURE__ */ new Set([...open2?.from ?? [], previous])].filter(
|
|
15725
|
+
(memberId) => memberId !== change.leadMemberId
|
|
15726
|
+
);
|
|
15727
|
+
return {
|
|
15728
|
+
leads,
|
|
15729
|
+
pending: {
|
|
15730
|
+
...state.pending,
|
|
15731
|
+
[change.workLineId]: {
|
|
15732
|
+
projectId: change.projectId,
|
|
15733
|
+
workLineId: change.workLineId,
|
|
15734
|
+
from,
|
|
15735
|
+
to: change.leadMemberId,
|
|
15736
|
+
sequence: event.sequence
|
|
15737
|
+
}
|
|
15738
|
+
}
|
|
15739
|
+
};
|
|
15740
|
+
}
|
|
15741
|
+
if (event.type !== "plugin.event-appended") return state;
|
|
15742
|
+
const settled = decodeSettled(event.payload);
|
|
15743
|
+
if (isNone2(settled)) return state;
|
|
15744
|
+
const open = readFact(state.pending, settled.value.data.workLineId);
|
|
15745
|
+
return open === null || open.sequence !== settled.value.data.sequence ? state : { ...state, pending: without(state.pending, settled.value.data.workLineId) };
|
|
15746
|
+
}
|
|
15747
|
+
var leadHandoverStateDefinition = {
|
|
15748
|
+
key: "lead-handovers",
|
|
15749
|
+
// 2:清空负责人不再改写「线上现在的负责人」。
|
|
15750
|
+
version: 2,
|
|
15751
|
+
events: ["work.line-created", "work.line-updated", "plugin.event-appended"],
|
|
15752
|
+
init: () => ({ leads: {}, pending: {} }),
|
|
15753
|
+
apply: foldLeadHandovers
|
|
15754
|
+
};
|
|
15755
|
+
async function briefRoster(ctx, goal, memberIds, trials2) {
|
|
15756
|
+
const machines = await readMachines(ctx, goal.projectId);
|
|
15757
|
+
const rows = [];
|
|
15758
|
+
for (const memberId of memberIds) {
|
|
15759
|
+
const member = await findMember(ctx, goal.projectId, memberId, { textLimit: 2 });
|
|
15760
|
+
if (member === null || member.removedAt !== null) continue;
|
|
15761
|
+
const remote = isRemoteMember(member, ctx.environment.id);
|
|
15762
|
+
const thread = goal.threads.find((row) => row.memberId === memberId)?.threadId;
|
|
15763
|
+
rows.push({
|
|
15764
|
+
name: member.name,
|
|
15765
|
+
memberId,
|
|
15766
|
+
where: remote ? `${REMOTE_WHERE_PREFIX}${(member.agent === null ? void 0 : machines?.get(member.agent.environmentId))?.name ?? "not joined"}` : member.kind === "human" ? "person" : thread ?? "not joined",
|
|
15767
|
+
status: statusOf2(trials2, goal.projectId, member)
|
|
15768
|
+
});
|
|
15769
|
+
}
|
|
15770
|
+
return rows;
|
|
15771
|
+
}
|
|
15772
|
+
var threadsOfMembers = (scope2, memberIds) => new Set(
|
|
15773
|
+
Object.entries(scope2?.memberIds ?? {}).flatMap(
|
|
15774
|
+
([threadId, memberId]) => memberIds.includes(memberId) ? [threadId] : []
|
|
15775
|
+
)
|
|
15776
|
+
);
|
|
15777
|
+
var heldByMembers = (item, memberIds, threads) => (item.assigneeMembers ?? []).some((memberId) => memberIds.includes(memberId)) || item.assigneeThreads.some((threadId) => threads.has(threadId));
|
|
15778
|
+
async function reassign(ctx, project2, pending, fromThreads) {
|
|
15779
|
+
const { projectId, workLineId, to, sequence } = pending;
|
|
15780
|
+
const holders = new Set(pending.from);
|
|
15781
|
+
for (const [workItemId, item] of Object.entries(project2?.items ?? {})) {
|
|
15782
|
+
if (item.workLineId !== workLineId || isClosed(item)) continue;
|
|
15783
|
+
if (!heldByMembers(item, pending.from, fromThreads)) continue;
|
|
15784
|
+
await updateAssignees(ctx, {
|
|
15785
|
+
projectId,
|
|
15786
|
+
workItemId,
|
|
15787
|
+
requestKey: `team-lead-handover-item:${stableHash(JSON.stringify([projectId, workItemId, to, sequence]))}`,
|
|
15788
|
+
change: (assignees) => {
|
|
15789
|
+
const rest = assignees.filter(
|
|
15790
|
+
(assignee) => !(assignee.kind === "member" && holders.has(assignee.memberId) || assignee.kind === "agent" && fromThreads.has(assignee.threadId))
|
|
15791
|
+
);
|
|
15792
|
+
if (rest.length === assignees.length) return null;
|
|
15793
|
+
return rest.some((assignee) => assignee.kind === "member" && assignee.memberId === to) ? rest : [...rest, { kind: "member", memberId: to }];
|
|
15794
|
+
}
|
|
15795
|
+
});
|
|
15796
|
+
}
|
|
15797
|
+
}
|
|
15798
|
+
function startLeadHandoverRuntime(ctx, deps) {
|
|
15799
|
+
const settle = async (pending) => {
|
|
15800
|
+
const { projectId, workLineId, to, sequence } = pending;
|
|
15801
|
+
const settled = async () => {
|
|
15802
|
+
await ctx.events.append({
|
|
15803
|
+
commandId: `team-lead-handover-settled:${stableHash(JSON.stringify([workLineId, sequence]))}`,
|
|
15804
|
+
name: "lead-handover-settled",
|
|
15805
|
+
aggregate: { kind: "project", id: projectId },
|
|
15806
|
+
data: { version: 1, workLineId, sequence }
|
|
15807
|
+
});
|
|
15808
|
+
return "settled";
|
|
15809
|
+
};
|
|
15810
|
+
const goal = (await deps.goals.allOf(projectId)).find((row) => row.workLineId === workLineId);
|
|
15811
|
+
if (goal === void 0) return settled();
|
|
15812
|
+
const { line } = await ctx.work.lines.get({ projectId, workLineId });
|
|
15813
|
+
if (line.archivedAt !== null || line.leadMemberId !== to) return "waiting";
|
|
15814
|
+
const wake = readFact(await deps.wakes.get(), projectId) ?? void 0;
|
|
15815
|
+
const fromThreads = threadsOfMembers(wake?.lineScopes?.[workLineId], pending.from);
|
|
15816
|
+
await reassign(ctx, wake, pending, fromThreads);
|
|
15817
|
+
const member = await findMember(ctx, projectId, to, { textLimit: 2 });
|
|
15818
|
+
const thread = goal.threads.find((row) => row.memberId === to)?.threadId;
|
|
15819
|
+
const remote = goal.remoteMembers?.find((row) => row.memberId === to);
|
|
15820
|
+
if (member !== null && member.kind === "agent" && thread === void 0 && remote === void 0)
|
|
15821
|
+
return "waiting";
|
|
15822
|
+
if (thread !== void 0 || remote !== void 0) {
|
|
15823
|
+
const room = roomThreadOf(goal);
|
|
15824
|
+
const members = await briefRoster(
|
|
15825
|
+
ctx,
|
|
15826
|
+
goal,
|
|
15827
|
+
line.memberIds.filter((memberId) => memberId !== to),
|
|
15828
|
+
await deps.trials.get()
|
|
15829
|
+
);
|
|
15830
|
+
const key = stableHash(JSON.stringify([projectId, workLineId, to, sequence]));
|
|
15831
|
+
const delivered = await deliverWake(ctx, {
|
|
15832
|
+
projectId,
|
|
15833
|
+
recipient: thread !== void 0 ? { threadId: thread } : { principalId: remote.principalId, memberId: remote.memberId },
|
|
15834
|
+
requestId: `team-lead-handover:${key}`,
|
|
15835
|
+
messageId: `team-lead-handover-message:${key}`,
|
|
15836
|
+
wake: { reason: "instructions" },
|
|
15837
|
+
text: teamLeadBrief({
|
|
15838
|
+
name: line.name,
|
|
15839
|
+
goal: goal.goal,
|
|
15840
|
+
workLineId,
|
|
15841
|
+
goalItemId: teamGoalItemId(projectId, goal.goalId),
|
|
15842
|
+
members,
|
|
15843
|
+
...room === void 0 || room === thread ? {} : { room },
|
|
15844
|
+
...remote === void 0 || thread !== void 0 ? {} : { remote: true }
|
|
15845
|
+
})
|
|
15846
|
+
});
|
|
15847
|
+
if (!delivered) return "waiting";
|
|
15848
|
+
}
|
|
15849
|
+
return settled();
|
|
15850
|
+
};
|
|
15851
|
+
return startFollowUp(ctx, {
|
|
15852
|
+
name: "team-lead-handover",
|
|
15853
|
+
// 线恢复归档、新负责人的会话取消归档、新负责人的会话绑上,都可能让待办能做了。
|
|
15854
|
+
events: [
|
|
15855
|
+
"work.line-updated",
|
|
15856
|
+
"work.line-restored",
|
|
15857
|
+
"thread.unarchived",
|
|
15858
|
+
"plugin.event-appended"
|
|
15859
|
+
],
|
|
15860
|
+
accepts: (event) => event.type !== "plugin.event-appended" || event.payload?.name === "team/member-bound",
|
|
15861
|
+
pending: async () => Object.values((await deps.state.get()).pending),
|
|
15862
|
+
keyOf: (row) => `${row.workLineId}:${String(row.sequence)}`,
|
|
15863
|
+
projectOf: (row) => row.projectId,
|
|
15864
|
+
settle
|
|
15865
|
+
});
|
|
15866
|
+
}
|
|
15867
|
+
|
|
15868
|
+
// src/team/lineRemovals.ts
|
|
15869
|
+
var keyOf = (workLineId, sequence) => `${workLineId}:${String(sequence)}`;
|
|
15870
|
+
var decodeLineUpdated2 = decodeUnknownOption2(
|
|
15871
|
+
Struct({
|
|
15872
|
+
projectId: String4,
|
|
15873
|
+
workLineId: String4,
|
|
15874
|
+
removedMemberIds: optionalKey2(ArraySchema(String4))
|
|
15875
|
+
})
|
|
15876
|
+
);
|
|
15877
|
+
var Settled2 = Struct({
|
|
15878
|
+
version: Literal2(1),
|
|
15879
|
+
workLineId: String4,
|
|
15880
|
+
sequence: Number5,
|
|
15881
|
+
returned: optionalKey2(ArraySchema(String4))
|
|
15882
|
+
});
|
|
15883
|
+
var decodeSettled2 = decodeUnknownOption2(factEnvelope("line-removal-settled", Settled2));
|
|
15884
|
+
function foldLineRemovals(state, event) {
|
|
15885
|
+
if (event.type === "work.line-updated") {
|
|
15886
|
+
const updated = decodeLineUpdated2(event.payload);
|
|
15887
|
+
if (isNone2(updated)) return state;
|
|
15888
|
+
const { projectId, workLineId: workLineId2, removedMemberIds } = updated.value;
|
|
15889
|
+
if (removedMemberIds === void 0 || removedMemberIds.length === 0) return state;
|
|
15890
|
+
return {
|
|
15891
|
+
...state,
|
|
15892
|
+
[keyOf(workLineId2, event.sequence)]: {
|
|
15893
|
+
projectId,
|
|
15894
|
+
workLineId: workLineId2,
|
|
15895
|
+
removed: removedMemberIds,
|
|
15896
|
+
sequence: event.sequence
|
|
15897
|
+
}
|
|
15898
|
+
};
|
|
15899
|
+
}
|
|
15900
|
+
if (event.type !== "plugin.event-appended") return state;
|
|
15901
|
+
const settled = decodeSettled2(event.payload);
|
|
15902
|
+
if (isNone2(settled)) return state;
|
|
15903
|
+
const { workLineId, sequence, returned } = settled.value.data;
|
|
15904
|
+
const key = keyOf(workLineId, sequence);
|
|
15905
|
+
const row = state[key];
|
|
15906
|
+
return row === void 0 ? state : { ...state, [key]: { ...row, returned: returned ?? [] } };
|
|
15907
|
+
}
|
|
15908
|
+
var lineRemovalStateDefinition = {
|
|
15909
|
+
key: "line-removals",
|
|
15910
|
+
version: 2,
|
|
15911
|
+
events: ["work.line-updated", "plugin.event-appended"],
|
|
15912
|
+
init: () => ({}),
|
|
15913
|
+
apply: foldLineRemovals
|
|
15914
|
+
};
|
|
15915
|
+
async function returnUnreachedItems(ctx, wakes, input) {
|
|
15916
|
+
const { projectId, workLineId, leadMemberId, removed, requestKey: requestKey2 } = input;
|
|
15917
|
+
const project2 = readFact(await wakes.get(), projectId);
|
|
15918
|
+
const returned = [];
|
|
15919
|
+
for (const [workItemId, item] of Object.entries(project2?.items ?? {})) {
|
|
15920
|
+
if (item.workLineId !== workLineId || isClosed(item)) continue;
|
|
15921
|
+
const taken = removed.filter(
|
|
15922
|
+
(id) => item.assigneeMembers?.includes(id) === true && notYetHandedOver(item, id)
|
|
15923
|
+
);
|
|
15924
|
+
if (taken.length === 0) continue;
|
|
15925
|
+
const written2 = await updateAssignees(ctx, {
|
|
15926
|
+
projectId,
|
|
15927
|
+
workItemId,
|
|
15928
|
+
requestKey: `team-member-returned:${stableHash(JSON.stringify([projectId, workItemId, requestKey2]))}`,
|
|
15929
|
+
change: (assignees) => {
|
|
15930
|
+
const kept = assignees.filter(
|
|
15931
|
+
(assignee) => !(assignee.kind === "member" && taken.includes(assignee.memberId))
|
|
15932
|
+
);
|
|
15933
|
+
if (kept.length === assignees.length) return null;
|
|
15934
|
+
return kept.some(
|
|
15935
|
+
(assignee) => assignee.kind === "member" && assignee.memberId === leadMemberId
|
|
15936
|
+
) ? kept : [...kept, { kind: "member", memberId: leadMemberId }];
|
|
15937
|
+
}
|
|
15938
|
+
});
|
|
15939
|
+
if (written2) returned.push(workItemId);
|
|
15940
|
+
}
|
|
15941
|
+
return returned;
|
|
15942
|
+
}
|
|
15943
|
+
function unreachedItemCount(project2, workLineId, memberId) {
|
|
15944
|
+
return Object.values(project2?.items ?? {}).filter(
|
|
15945
|
+
(item) => item.workLineId === workLineId && !isClosed(item) && item.assigneeMembers?.includes(memberId) === true && notYetHandedOver(item, memberId)
|
|
15946
|
+
).length;
|
|
15947
|
+
}
|
|
15948
|
+
function startLineRemovals(ctx, deps) {
|
|
15949
|
+
let appended = 0;
|
|
15950
|
+
const settle = async (row) => {
|
|
15951
|
+
const { projectId, workLineId, sequence } = row;
|
|
15952
|
+
const done2 = async (returned) => {
|
|
15953
|
+
const receipt = await ctx.events.append({
|
|
15954
|
+
commandId: `team-line-removal-settled:${stableHash(JSON.stringify([workLineId, sequence]))}`,
|
|
15955
|
+
name: "line-removal-settled",
|
|
15956
|
+
aggregate: { kind: "project", id: projectId },
|
|
15957
|
+
data: { version: 1, workLineId, sequence, returned }
|
|
15958
|
+
});
|
|
15959
|
+
appended = Math.max(appended, receipt.sequence);
|
|
15960
|
+
return "settled";
|
|
15961
|
+
};
|
|
15962
|
+
if ((await deps.goals.allOf(projectId)).every((goal) => goal.workLineId !== workLineId))
|
|
15963
|
+
return done2([]);
|
|
15964
|
+
const { line } = await ctx.work.lines.get({ projectId, workLineId });
|
|
15965
|
+
if (line.archivedAt !== null || line.leadMemberId === null) return "waiting";
|
|
15966
|
+
const gone = row.removed.filter((memberId) => !line.memberIds.includes(memberId));
|
|
15967
|
+
return done2(
|
|
15968
|
+
gone.length === 0 ? [] : await returnUnreachedItems(ctx, deps.wakes, {
|
|
15969
|
+
projectId,
|
|
15970
|
+
workLineId,
|
|
15971
|
+
leadMemberId: line.leadMemberId,
|
|
15972
|
+
removed: gone,
|
|
15973
|
+
requestKey: keyOf(workLineId, sequence)
|
|
15974
|
+
})
|
|
15975
|
+
);
|
|
15976
|
+
};
|
|
15977
|
+
const { ready, flush } = startFollowUp(ctx, {
|
|
15978
|
+
name: "team-line-removal",
|
|
15979
|
+
events: ["work.line-updated", "work.line-restored"],
|
|
15980
|
+
pending: async (through) => Object.values(
|
|
15981
|
+
await deps.state.get(through === void 0 ? void 0 : { throughSequence: through })
|
|
15982
|
+
).filter((row) => row.returned === void 0),
|
|
15983
|
+
keyOf: (row) => keyOf(row.workLineId, row.sequence),
|
|
15984
|
+
projectOf: (row) => row.projectId,
|
|
15985
|
+
settle
|
|
15986
|
+
});
|
|
15987
|
+
return {
|
|
15988
|
+
ready,
|
|
15989
|
+
outcomeOf: async (projectId, workLineId, throughSequence) => {
|
|
15990
|
+
await flush({ project: projectId, through: throughSequence });
|
|
15991
|
+
const rows = Object.values(
|
|
15992
|
+
await deps.state.get({ throughSequence: Math.max(throughSequence, appended) })
|
|
15993
|
+
).filter(
|
|
15994
|
+
(row2) => row2.projectId === projectId && row2.workLineId === workLineId && row2.sequence <= throughSequence
|
|
15995
|
+
);
|
|
15996
|
+
const row = rows.toSorted((a, b) => b.sequence - a.sequence)[0];
|
|
15997
|
+
if (row === void 0) return { done: true, returned: [] };
|
|
15998
|
+
return row.returned === void 0 ? { done: false } : { done: true, returned: row.returned };
|
|
15999
|
+
}
|
|
16000
|
+
};
|
|
16001
|
+
}
|
|
16002
|
+
|
|
16003
|
+
// src/team/lineMembers.ts
|
|
15244
16004
|
var RequestId2 = String4.check(isPattern2(REQUEST_ID_PATTERN));
|
|
15245
|
-
var
|
|
16005
|
+
var LineRef = Struct({ projectId: String4, workLineId: String4 });
|
|
16006
|
+
var LineMemberInput = Struct({
|
|
16007
|
+
...LineRef.fields,
|
|
15246
16008
|
requestId: RequestId2,
|
|
16009
|
+
memberId: String4
|
|
16010
|
+
});
|
|
16011
|
+
var decodeRef3 = decodeUnknownSync(LineRef);
|
|
16012
|
+
var decodeMemberInput = decodeUnknownSync(LineMemberInput);
|
|
16013
|
+
function leadOpenItemCount(project2, workLineId, leadMemberId) {
|
|
16014
|
+
if (project2 === void 0 || leadMemberId === null) return 0;
|
|
16015
|
+
const threads = threadsOfMembers(project2.lineScopes?.[workLineId], [leadMemberId]);
|
|
16016
|
+
return Object.values(project2.items).filter(
|
|
16017
|
+
(item) => item.workLineId === workLineId && !isClosed(item) && heldByMembers(item, [leadMemberId], threads)
|
|
16018
|
+
).length;
|
|
16019
|
+
}
|
|
16020
|
+
function registerLineMemberCommands(ctx, deps) {
|
|
16021
|
+
const view = async (projectId, workLineId) => {
|
|
16022
|
+
const { line } = await ctx.work.lines.get({ projectId, workLineId });
|
|
16023
|
+
const project2 = readFact(await deps.wakes.get(), projectId) ?? void 0;
|
|
16024
|
+
return {
|
|
16025
|
+
workLineId,
|
|
16026
|
+
version: line.version,
|
|
16027
|
+
archived: line.archivedAt !== null,
|
|
16028
|
+
leadMemberId: line.leadMemberId,
|
|
16029
|
+
memberIds: line.memberIds,
|
|
16030
|
+
leadOpenItems: leadOpenItemCount(project2, workLineId, line.leadMemberId),
|
|
16031
|
+
returnable: Object.fromEntries(
|
|
16032
|
+
// 负责人不能直接移除,不数它。
|
|
16033
|
+
line.memberIds.flatMap((memberId) => {
|
|
16034
|
+
const count2 = memberId === line.leadMemberId ? 0 : unreachedItemCount(project2, workLineId, memberId);
|
|
16035
|
+
return count2 === 0 ? [] : [[memberId, count2]];
|
|
16036
|
+
})
|
|
16037
|
+
)
|
|
16038
|
+
};
|
|
16039
|
+
};
|
|
16040
|
+
ctx.command({
|
|
16041
|
+
name: "lineMembers",
|
|
16042
|
+
scope: "read",
|
|
16043
|
+
payloadSchema: payloadSchemaOf(LineRef),
|
|
16044
|
+
handle: async (payload) => {
|
|
16045
|
+
const { projectId, workLineId } = decodeRef3(payload);
|
|
16046
|
+
return view(projectId, workLineId);
|
|
16047
|
+
}
|
|
16048
|
+
});
|
|
16049
|
+
const write = async (invocation, kind, input) => {
|
|
16050
|
+
const { projectId, workLineId, memberId, requestId } = input;
|
|
16051
|
+
return writeLineVersioned(
|
|
16052
|
+
{
|
|
16053
|
+
readLine: async () => (await ctx.work.lines.get({ projectId, workLineId })).line,
|
|
16054
|
+
isConflict: (error) => hostRefusalCode(error) === "version-conflict"
|
|
16055
|
+
},
|
|
16056
|
+
async (line, suffix) => {
|
|
16057
|
+
const { sequence } = await invocation.asPerson.work.lines.update({
|
|
16058
|
+
projectId,
|
|
16059
|
+
workLineId,
|
|
16060
|
+
expectedVersion: line.version,
|
|
16061
|
+
requestId: `team-line-${kind}:${stableHash(JSON.stringify([projectId, workLineId, memberId, requestId]))}${suffix}`,
|
|
16062
|
+
...kind === "add" ? { addMemberIds: [memberId] } : {},
|
|
16063
|
+
...kind === "remove" ? { removeMemberIds: [memberId] } : {},
|
|
16064
|
+
...kind === "lead" ? { leadMemberId: memberId } : {}
|
|
16065
|
+
});
|
|
16066
|
+
return { line, sequence };
|
|
16067
|
+
}
|
|
16068
|
+
);
|
|
16069
|
+
};
|
|
16070
|
+
const handler = (kind) => async (payload, invocation) => {
|
|
16071
|
+
if (invocation.asPerson === void 0)
|
|
16072
|
+
throw Object.assign(new Error("Only a person can change who is on a team"), {
|
|
16073
|
+
code: "needs-person"
|
|
16074
|
+
});
|
|
16075
|
+
const input = decodeMemberInput(payload);
|
|
16076
|
+
return deps.queue.run(async () => {
|
|
16077
|
+
const { sequence } = await write(invocation, kind, input);
|
|
16078
|
+
const outcome = kind === "remove" ? await deps.lineRemovals.outcomeOf(input.projectId, input.workLineId, sequence) : null;
|
|
16079
|
+
const current = await view(input.projectId, input.workLineId);
|
|
16080
|
+
return outcome !== null && !outcome.done ? { ...current, returnPending: true } : current;
|
|
16081
|
+
});
|
|
16082
|
+
};
|
|
16083
|
+
for (const [name, kind] of [
|
|
16084
|
+
["lineAddMember", "add"],
|
|
16085
|
+
["lineRemoveMember", "remove"],
|
|
16086
|
+
["lineSetLead", "lead"]
|
|
16087
|
+
])
|
|
16088
|
+
ctx.command({
|
|
16089
|
+
name,
|
|
16090
|
+
scope: "operate",
|
|
16091
|
+
payloadSchema: payloadSchemaOf(LineMemberInput),
|
|
16092
|
+
handle: handler(kind)
|
|
16093
|
+
});
|
|
16094
|
+
}
|
|
16095
|
+
|
|
16096
|
+
// src/team/pause.ts
|
|
16097
|
+
var RequestId3 = String4.check(isPattern2(REQUEST_ID_PATTERN));
|
|
16098
|
+
var LinePauseInput = Struct({
|
|
16099
|
+
requestId: RequestId3,
|
|
15247
16100
|
projectId: String4,
|
|
15248
16101
|
workLineId: String4
|
|
15249
16102
|
});
|
|
15250
16103
|
var LineMemberPauseInput = Struct({
|
|
15251
|
-
requestId:
|
|
16104
|
+
requestId: RequestId3,
|
|
15252
16105
|
projectId: String4,
|
|
15253
16106
|
workLineId: String4,
|
|
15254
16107
|
memberId: String4
|
|
@@ -15552,6 +16405,7 @@ async function scanRecords(ctx, projectId, groupThreadId, watermark, nameOfThrea
|
|
|
15552
16405
|
return { lines: [], upTo: null, more: false, ids };
|
|
15553
16406
|
}
|
|
15554
16407
|
}
|
|
16408
|
+
var digestKey = (workLineId, recipient) => "threadId" in recipient ? recipient.threadId : `remote:${workLineId}:${recipient.principalId}:${recipient.memberId}`;
|
|
15555
16409
|
function createGroupDigest(ctx, state) {
|
|
15556
16410
|
return {
|
|
15557
16411
|
/**
|
|
@@ -15559,10 +16413,11 @@ function createGroupDigest(ctx, state) {
|
|
|
15559
16413
|
* 别的叫醒另起一份,从还没前进的水位重新装配。
|
|
15560
16414
|
*/
|
|
15561
16415
|
async prepare(input) {
|
|
15562
|
-
const
|
|
15563
|
-
const
|
|
16416
|
+
const key = digestKey(input.workLineId, input.recipient);
|
|
16417
|
+
const digestId = stableHash(JSON.stringify([key, input.wakeKey]));
|
|
16418
|
+
const known = readFact(await state.get(), key);
|
|
15564
16419
|
if (known?.prepared?.digestId === digestId)
|
|
15565
|
-
return { digestId,
|
|
16420
|
+
return { digestId, key, body: known.prepared.body };
|
|
15566
16421
|
const execution = await ctx.projections.getThreadExecution(input.leadThreadId);
|
|
15567
16422
|
const records = await scanRecords(
|
|
15568
16423
|
ctx.communication,
|
|
@@ -15588,7 +16443,8 @@ function createGroupDigest(ctx, state) {
|
|
|
15588
16443
|
const body = [
|
|
15589
16444
|
`[Group chat: ${lines.length} new message${lines.length === 1 ? "" : "s"} in this group since you last looked. This is what others said, not confirmed facts.]`,
|
|
15590
16445
|
...lines.map((line) => line.text),
|
|
15591
|
-
|
|
16446
|
+
// 别的机器上的成员读不了本机会话,只能用 message_list。
|
|
16447
|
+
`${more ? "Earlier messages are not shown. " : ""}Read more with ${"threadId" in input.recipient ? `list_thread_messages { threadId: "${input.leadThreadId}" } and group records with ` : ""}message_list { groupThreadId: "${input.leadThreadId}" }.`
|
|
15592
16448
|
].join("\n");
|
|
15593
16449
|
const receipt = await ctx.events.append({
|
|
15594
16450
|
commandId: `team-group-digest-prepared:${digestId}`,
|
|
@@ -15600,7 +16456,7 @@ function createGroupDigest(ctx, state) {
|
|
|
15600
16456
|
projectId: input.projectId,
|
|
15601
16457
|
workLineId: input.workLineId,
|
|
15602
16458
|
memberId: input.memberId,
|
|
15603
|
-
threadId:
|
|
16459
|
+
threadId: key,
|
|
15604
16460
|
digestId,
|
|
15605
16461
|
body,
|
|
15606
16462
|
...scanned.upTo === null ? {} : { upTo: scanned.upTo },
|
|
@@ -15608,7 +16464,7 @@ function createGroupDigest(ctx, state) {
|
|
|
15608
16464
|
}
|
|
15609
16465
|
});
|
|
15610
16466
|
await state.get({ throughSequence: receipt.sequence });
|
|
15611
|
-
return { digestId,
|
|
16467
|
+
return { digestId, key, body };
|
|
15612
16468
|
},
|
|
15613
16469
|
/**
|
|
15614
16470
|
* 引擎叫醒了这条会话(看板交件):随那次叫醒补充出去的那一份算已投递,水位前进。没有装配好的就什么也不做。
|
|
@@ -15616,7 +16472,11 @@ function createGroupDigest(ctx, state) {
|
|
|
15616
16472
|
async confirmPrepared(projectId, threadId) {
|
|
15617
16473
|
const prepared = readFact(await state.get(), threadId)?.prepared;
|
|
15618
16474
|
if (prepared == null) return;
|
|
15619
|
-
await this.confirm(projectId, {
|
|
16475
|
+
await this.confirm(projectId, {
|
|
16476
|
+
digestId: prepared.digestId,
|
|
16477
|
+
key: threadId,
|
|
16478
|
+
body: prepared.body
|
|
16479
|
+
});
|
|
15620
16480
|
},
|
|
15621
16481
|
/** 叫醒已被宿主受理:水位前进。同一份只落一次。 */
|
|
15622
16482
|
async confirm(projectId, digest) {
|
|
@@ -15628,7 +16488,7 @@ function createGroupDigest(ctx, state) {
|
|
|
15628
16488
|
version: 1,
|
|
15629
16489
|
status: "delivered",
|
|
15630
16490
|
projectId,
|
|
15631
|
-
threadId: digest.
|
|
16491
|
+
threadId: digest.key,
|
|
15632
16492
|
digestId: digest.digestId
|
|
15633
16493
|
}
|
|
15634
16494
|
});
|
|
@@ -15665,7 +16525,8 @@ var zh_CN_default = {
|
|
|
15665
16525
|
},
|
|
15666
16526
|
team: {
|
|
15667
16527
|
openTool: "\u628A\u8FD9\u6761\u4F1A\u8BDD\u53D8\u6210\u4E00\u4E2A\u56E2\u961F\u3002\u53EA\u5728\u4EBA\u5DF2\u7ECF\u5728\u8FD9\u6761\u4F1A\u8BDD\u91CC\u540C\u610F\u4E86\u4F60\u63D0\u7684\u56E2\u961F\u65B9\u6848\u4E4B\u540E\u624D\u8C03\uFF1A\u8C01\u52A0\u5165\uFF08\u5DF2\u5728\u9879\u76EE\u91CC\u7684\u6210\u5458\uFF0C\u5305\u62EC\u52A0\u8FDB\u8FD9\u4E2A\u9879\u76EE\u7684\u5176\u4ED6\u673A\u5668\u4E0A\u7684 agent\uFF1Bwork_list_machines \u5217\u51FA\u8FD9\u4E9B\u673A\u5668\uFF09\u3001\u56E2\u961F\u5F00\u597D\u4E4B\u540E\u8981\u65B0\u5EFA\u54EA\u4E9B\u6210\u5458\u3002\u8FD8\u4E0D\u5B58\u5728\u7684\u6210\u5458\u5728\u8FD9\u6B21\u8C03\u7528\u4E4B\u540E\u518D\u6765\uFF1A\u5148\u7528 team_create_member \u65B0\u5EFA\uFF0C\u518D\u7528 team_set_members \u62C9\u8FDB\u6765\u3002\u8FD9\u6761\u4F1A\u8BDD\u4ECE\u6B64\u662F\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u548C\u7FA4\u804A\uFF0C\u5E76\u6539\u540D\u4E3A\u56E2\u961F\u540D\uFF1A\u4F60\u5217\u7684\u6210\u5458\u52A0\u8FDB\u6765\uFF0C\u6BCF\u4E2A\u672C\u673A agent \u6210\u5458\u5728\u4F60\u7684\u4F1A\u8BDD\u540D\u4E0B\u5F97\u5230\u81EA\u5DF1\u7684\u4F1A\u8BDD\u3002requestId \u8981\u7528\u65B0\u7684\uFF0C\u53EA\u6709\u91CD\u8BD5\u540C\u4E00\u6B21\u8C03\u7528\u65F6\u624D\u6CBF\u7528\u3002name \u662F\u56E2\u961F\u540D\uFF08\u6700\u591A 80 \u5B57\uFF09\uFF1Bgoal \u662F\u8C08\u59A5\u5185\u5BB9\u7684\u6458\u8981\uFF08\u6700\u591A 4000 \u5B57\uFF09\uFF1BmemberIds \u662F\u8981\u62C9\u8FDB\u6765\u7684\u9879\u76EE\u6210\u5458\u7684 memberId\uFF08\u4E0D\u542B\u4F60\u81EA\u5DF1\uFF0C\u4F60\u4F1A\u4F5C\u4E3A\u8D1F\u8D23\u4EBA\u52A0\u8FDB\u6765\uFF09\uFF1BleadName \u53EF\u9009\uFF0C\u662F\u4F60\u4F5C\u4E3A\u9879\u76EE\u6210\u5458\u7684\u540D\u5B57\uFF081-40 \u5B57\uFF09\u3002\u8FD4\u56DE\u56E2\u961F\u7684\u5DE5\u4F5C\u7EBF\u3001\u6210\u5458\u548C\u6BCF\u4E2A\u6210\u5458\u662F\u5426\u5C31\u7EEA\uFF0C\u4EE5\u53CA\u4F60\u7684\u5F00\u5DE5\u8BF4\u660E\u3002\u5DF2\u7ECF\u662F\u56E2\u961F\u3001\u6216\u5C5E\u4E8E\u67D0\u4E2A\u56E2\u961F\u7684\u4F1A\u8BDD\u4E0D\u80FD\u518D\u5F00\u56E2\u961F\u3002",
|
|
15668
|
-
setMembersTool:
|
|
16528
|
+
setMembersTool: '\u6539\u8FD9\u4E2A\u56E2\u961F\u91CC\u6709\u8C01\uFF08\u53EA\u6709\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u80FD\u8C03\uFF1A\u5B83\u7684\u4F1A\u8BDD\uFF0C\u6216\u5B83\u5728\u522B\u7684\u673A\u5668\u4E0A\u7684\u4F1A\u8BDD\uFF09\u3002add\uFF1A\u8981\u62C9\u8FDB\u6765\u7684\u9879\u76EE\u6210\u5458\u7684 memberId\uFF1Bremove\uFF1A\u8981\u79FB\u51FA\u7684 memberId\u3002\u79FB\u51FA\u7684\u6210\u5458\u540D\u4E0B\u8FD8\u6CA1\u5230\u5B83\u624B\u4E0A\u7684\u6D3B\u4F1A\u6536\u56DE\u5E76\u4EA4\u7ED9\u4F60\uFF0C\u5DF2\u7ECF\u5728\u5B83\u624B\u4E0A\u7684\u6D3B\u7559\u7ED9\u5B83\uFF0C\u7531\u4F60\u51B3\u5B9A\u3002\u4F60\u4E0D\u80FD\u79FB\u51FA\u81EA\u5DF1\uFF0C\u4E5F\u4E0D\u80FD\u52A8\u522B\u7684\u56E2\u961F\u7684\u6210\u5458\u548C\u8D1F\u8D23\u4EBA\u3002\u7ED3\u679C\u91CC returnStatus \u662F "done"\uFF08\u5E26 returnedToYou\uFF1A\u9000\u7ED9\u4F60\u7684\u4EF6\u53F7\uFF09\u6216 "pending"\uFF1A\u6210\u5458\u5DF2\u7ECF\u6539\u597D\uFF0C\u4EF6\u8FD8\u5728\u9000\uFF0C\u4F1A\u81EA\u5DF1\u505A\u5B8C\uFF0C\u7528\u540C\u4E00\u4E2A requestId \u518D\u8C03\u4E00\u6B21\u53EF\u4EE5\u8BFB\u5230\u73B0\u72B6\u3002requestId \u8981\u7528\u65B0\u7684\uFF0C\u53EA\u6709\u91CD\u8BD5\u540C\u4E00\u6B21\u8C03\u7528\u65F6\u624D\u6CBF\u7528\u3002',
|
|
16529
|
+
setLeadTool: "\u628A\u8FD9\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u4EA4\u7ED9\u56E2\u961F\u91CC\u7684\u53E6\u4E00\u540D\u6210\u5458\uFF08\u53EA\u6709\u56E2\u961F\u73B0\u5728\u7684\u8D1F\u8D23\u4EBA\u80FD\u8C03\uFF1A\u5B83\u7684\u4F1A\u8BDD\uFF0C\u6216\u5B83\u5728\u522B\u7684\u673A\u5668\u4E0A\u7684\u4F1A\u8BDD\uFF1B\u4E0D\u7528\u4EBA\u786E\u8BA4\uFF09\u3002memberId\uFF1A\u5DF2\u5728\u56E2\u961F\u91CC\u7684\u6210\u5458\u7684 memberId\uFF0C\u4EBA\u3001\u522B\u7684\u673A\u5668\u4E0A\u7684 agent \u6210\u5458\u90FD\u53EF\u4EE5\uFF1B\u4E0D\u5728\u56E2\u961F\u91CC\u5C31\u5148\u7528 team_set_members \u52A0\u8FDB\u6765\u3002\u8C03\u7528\u4E4B\u540E\u4F60\u662F\u666E\u901A\u6210\u5458\uFF0C\u4E0D\u80FD\u81EA\u5DF1\u6536\u56DE\uFF1A\u53EA\u6709\u65B0\u8D1F\u8D23\u4EBA\u6216\u4EBA\u80FD\u518D\u4EA4\u51FA\u53BB\u3002\u4F60\u540D\u4E0B\u8FD8\u5F00\u7740\u7684\u4EF6\uFF08\u542B\u5DF2\u7ECF\u5728\u505A\u7684\uFF09\u4F1A\u6539\u7ED9\u65B0\u8D1F\u8D23\u4EBA\uFF0C\u65B0\u8D1F\u8D23\u4EBA\u4F1A\u6536\u5230\u300C\u4F60\u73B0\u5728\u662F\u8D1F\u8D23\u4EBA\u300D\u7684\u8BF4\u660E\uFF0C\u6240\u4EE5\u624B\u4E0A\u7684\u4E8B\u5148\u6536\u5C3E\u6216\u4EA4\u4EE3\u6E05\u695A\u518D\u8C03\u3002\u53EA\u5199\u4E00\u6B21\uFF1A\u56E2\u961F\u6216\u5B83\u7684\u8D1F\u8D23\u4EBA\u521A\u597D\u540C\u65F6\u88AB\u6539\u4E86\u5C31\u4EC0\u4E48\u90FD\u4E0D\u5199\u3001\u62D2\u7EDD\u8FD9\u6B21\u8C03\u7528\uFF08lead-changed\uFF09\uFF0C\u91CD\u65B0\u8BFB\u4E00\u904D\u56E2\u961F\u3001\u518D\u51B3\u5B9A\uFF0C\u7528\u65B0\u7684 requestId \u8C03\u7528\u3002\u540C\u4E00\u4E2A requestId \u53EA\u7528\u6765\u518D\u8BFB\u540C\u4E00\u6B21\u8C03\u7528\u7684\u7ED3\u679C\u3002",
|
|
15669
16530
|
rosterOverviewTool: "\u8BFB\u51FA\u89C4\u5212\u56E2\u961F\u9700\u8981\u7684\u5168\u90E8\u4FE1\u606F\uFF1A\u8FD9\u4E2A\u9879\u76EE\u7684\u6BCF\u4E2A\u6210\u5458\uFF0C\u542B\u79CD\u7C7B\u3001\u673A\u5668\u3001\u6A21\u578B\u3001\u8BD5\u8DD1\u8FDB\u5EA6\uFF08trial \u53D6\u503C\uFF1Anone \u8868\u793A\u4E0D\u9002\u7528\uFF0C\u6BD4\u5982\u4EBA\uFF1Bunverified \u662F\u522B\u7684\u673A\u5668\u4E0A\u3001\u8FD9\u91CC\u8FD8\u6CA1\u6709\u8BD5\u8DD1\u8BB0\u5F55\u7684 agent\uFF1Bpending \u662F\u8FD8\u6CA1\u901A\u8FC7\uFF1Bready \u662F\u5DF2\u901A\u8FC7\u6216\u5DF2\u8DF3\u8FC7\uFF1Bfailed \u662F\u5931\u8D25\uFF1Binvoked \u662F\u8FD9\u6761\u4F1A\u8BDD\u672C\u8EAB\u5C31\u662F\u8D1F\u8D23\u4EBA\uFF0C\u65E0\u9700\u8BD5\u8DD1\uFF09\uFF0C\u4EE5\u53CA\u6240\u5728\u7684\u56E2\u961F\uFF08\u662F\u4E0D\u662F\u90A3\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\uFF09\u3002\u63D0\u56E2\u961F\u65B9\u6848\u4E4B\u524D\u3001\u65B0\u5EFA\u6210\u5458\u4E4B\u524D\u5148\u8BFB\u5B83\u3002",
|
|
15670
16531
|
noProject: "\u8FD9\u6B21\u8C03\u7528\u4E0D\u5C5E\u4E8E\u4EFB\u4F55\u9879\u76EE\uFF0C\u6CA1\u6709\u53EF\u5F00\u6216\u53EF\u6539\u7684\u56E2\u961F\u3002",
|
|
15671
16532
|
notLocal: "\u53EA\u6709\u8FD9\u53F0\u673A\u5668\u4E0A\u7684\u4F1A\u8BDD\u80FD\u5F00\u56E2\u961F\u3002",
|
|
@@ -15681,10 +16542,15 @@ var zh_CN_default = {
|
|
|
15681
16542
|
modelNotInCatalog: "\u7ED9\u6210\u5458 {{memberId}} \u9009\u7684\u6A21\u578B\u4E0D\u5728\u8BE5 provider \u5B9E\u4F8B\u7684\u6A21\u578B\u6E05\u5355\u91CC\u3002\u67E5 list_models\uFF0C\u518D\u7528 team_update_member \u6539\u3002",
|
|
15682
16543
|
noDefaultModel: "\u6210\u5458 {{memberId}} \u6CA1\u6709\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u9879\u76EE\u4E5F\u6CA1\u6709\u9ED8\u8BA4\u6A21\u578B\u3002\u7528 team_update_member \u7ED9\u5B83\u4E00\u4E2A\u3002",
|
|
15683
16544
|
duplicateTeamName: "\u8FD9\u4E2A\u9879\u76EE\u91CC\u5DF2\u7ECF\u6709\u540D\u4E3A {{name}} \u7684\u56E2\u961F\u3002\u6362\u4E2A\u540D\u5B57\uFF0C\u5E76\u7528\u65B0\u7684 requestId\u3002",
|
|
15684
|
-
leadOnly: "\u53EA\u6709\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\
|
|
15685
|
-
cannotRemoveLead: "\u4F60\u662F\u8FD9\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\uFF0C\u4E0D\u80FD\u79FB\u51FA\u81EA\u5DF1\u3002",
|
|
16545
|
+
leadOnly: "\u53EA\u6709\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u80FD\u6539\u5B83\u7684\u6210\u5458\u6216\u4EA4\u51FA\u8D1F\u8D23\u4EBA\u3002",
|
|
16546
|
+
cannotRemoveLead: "\u4F60\u662F\u8FD9\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\uFF0C\u4E0D\u80FD\u79FB\u51FA\u81EA\u5DF1\u3002\u5148\u7528 team_set_lead \u628A\u8D1F\u8D23\u4EBA\u4EA4\u7ED9\u522B\u7684\u6210\u5458\u3002",
|
|
16547
|
+
alreadyLead: "\u4F60\u5DF2\u7ECF\u662F\u8FD9\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u3002\u8BF7\u4F20\u56E2\u961F\u91CC\u53E6\u4E00\u540D\u6210\u5458\u7684 memberId\u3002",
|
|
16548
|
+
memberNotOnTeam: "\u6210\u5458 {{memberId}} \u4E0D\u5728\u8FD9\u4E2A\u56E2\u961F\u91CC\u3002\u5148\u7528 team_set_members \u628A\u5B83\u52A0\u8FDB\u6765\uFF0C\u518D\u4EA4\u51FA\u8D1F\u8D23\u4EBA\u3002",
|
|
15686
16549
|
teamArchived: "\u8FD9\u4E2A\u56E2\u961F\u5DF2\u5F52\u6863\u3002\u8BF7\u4EBA\u5148\u53D6\u6D88\u5F52\u6863\u8FD9\u6761\u4F1A\u8BDD\u518D\u6539\u3002",
|
|
15687
|
-
versionConflict: "\u56E2\u961F\u521A\u597D\u540C\u65F6\u88AB\u6539\u4E86\u3002\u91CD\u65B0\u8BFB\u4E00\u904D\uFF0C\u7528\u65B0\u7684 requestId \u518D\u8BD5\u3002"
|
|
16550
|
+
versionConflict: "\u56E2\u961F\u521A\u597D\u540C\u65F6\u88AB\u6539\u4E86\u3002\u91CD\u65B0\u8BFB\u4E00\u904D\uFF0C\u7528\u65B0\u7684 requestId \u518D\u8BD5\u3002",
|
|
16551
|
+
memberMachineUpdate: "member-machine-update-required\uFF1A\u8BF7\u5148\u5347\u7EA7\u6210\u5458\u673A\uFF0C\u624D\u80FD\u4EE5\u8D1F\u8D23\u4EBA\u8EAB\u4EFD\u7528\u56E2\u961F\u5DE5\u5177\u3002\u5B83\u7B7E\u540D\u7684 MCP \u8303\u56F4\u91CC\u6CA1\u6709\u5199\u660E\u662F\u54EA\u540D\u6210\u5458\uFF0C\u6216\u7248\u672C\u592A\u65E7\u3002",
|
|
16552
|
+
severalTeams: "\u8FD9\u540D\u6210\u5458\u5E26\u7740\u4E0D\u6B62\u4E00\u4E2A\u56E2\u961F\uFF0C\u8FD9\u6B21\u8C03\u7528\u8BF4\u4E0D\u6E05\u662F\u54EA\u4E2A\u56E2\u961F\u3002\u8BF7\u5148\u8BA9\u4EBA\u628A\u5176\u4E2D\u4E00\u4E2A\u56E2\u961F\u7684\u8D1F\u8D23\u4EBA\u4EA4\u7ED9\u522B\u4EBA\u3002",
|
|
16553
|
+
leadChanged: "\u56E2\u961F\u6216\u5B83\u7684\u8D1F\u8D23\u4EBA\u521A\u597D\u540C\u65F6\u88AB\u6539\u4E86\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u5199\u3002\u91CD\u65B0\u8BFB\u4E00\u904D\u56E2\u961F\uFF0C\u518D\u51B3\u5B9A\uFF0C\u7528\u65B0\u7684 requestId \u8C03\u7528\u3002"
|
|
15688
16554
|
},
|
|
15689
16555
|
coordinator: {
|
|
15690
16556
|
createTool: '\u4EE5\u5F53\u524D\u76EE\u6807\u8D1F\u8D23\u4EBA\u7684\u8EAB\u4EFD\uFF0C\u7ED9\u8FD9\u4E2A\u9879\u76EE\u7684\u56E2\u961F\u52A0\u4E00\u4E2A AI \u961F\u53CB\u3002requestId \u8981\u7528\u65B0\u7684\uFF0C\u53EA\u6709\u91CD\u8BD5\u540C\u4E00\u6B21\u8BF7\u6C42\u65F6\u624D\u6CBF\u7528\u3002\u6210\u5458\u8DD1\u5728\u8FD9\u53F0\u673A\u5668\u4E0A\uFF0C\u9664\u975E\u4F60\u7ED9 environmentId\uFF1A\u52A0\u8FDB\u8FD9\u4E2A\u9879\u76EE\u7684\u53E6\u4E00\u53F0\u673A\u5668\uFF08work_list_machines \u5217\u51FA\u8FD9\u4E9B\u673A\u5668\u548C\u5404\u81EA\u63D0\u4F9B\u7684 provider\uFF09\u3002provider \u7684 instanceId \u548C model \u8981\u4E48\u90FD\u7ED9\uFF0C\u8981\u4E48\u90FD\u4E0D\u7ED9\uFF1B\u5728\u8FD9\u53F0\u673A\u5668\u4E0A\u4E0D\u7ED9\u5C31\u7528\u9879\u76EE\u7684\u9ED8\u8BA4\u6A21\u578B\uFF0C\u5728\u522B\u7684\u673A\u5668\u4E0A\u5FC5\u987B\u7ED9\uFF0C\u800C\u4E14\u5FC5\u987B\u662F\u90A3\u53F0\u673A\u5668\u62A5\u6765\u7684\u3001\u5DF2\u5C31\u7EEA\u7684 provider \u5B9E\u4F8B\u3002\u65B0\u6210\u5458\u52A0\u5165\u5F53\u524D\u76EE\u6807\uFF0C\u5728\u4F60\u7684\u4F1A\u8BDD\u540D\u4E0B\u5F97\u5230\u81EA\u5DF1\u7684\u4F1A\u8BDD\uFF0C\u901A\u5E38\u7247\u523B\u5C31\u597D\uFF08\u5931\u8D25\u4F1A\u544A\u8BC9\u4F60\u539F\u56E0\uFF0C\u5E76\u6BCF\u9694\u51E0\u5206\u949F\u91CD\u8BD5\uFF09\uFF1B\u5728 team_open \u5F00\u7684\u56E2\u961F\u91CC\uFF0C\u8981\u7B49\u4F60\u7528 team_set_members \u628A\u5B83\u62C9\u8FDB\u6765\u624D\u5F00\u59CB\uFF1B\u5C31\u7EEA\u540E\u53EF\u4EE5\u7528 work_update_item \u5E76\u5E26 assignees [{ "kind": "member", "memberId": <\u8FD9\u4E2A\u5DE5\u5177\u8FD4\u56DE\u7684 memberId> }] \u7ED9\u5B83\u6D3E\u6D3B\u3002\u5148\u7528 work_list_members \u770B\u56E2\u961F\u91CC\u6709\u8C01\u3002',
|
|
@@ -15746,6 +16612,37 @@ var zh_CN_default = {
|
|
|
15746
16612
|
boardOff: "\u8D1F\u8D23\u4EBA\u8981\u7528\u770B\u677F\uFF0C\u5148\u6253\u5F00\u4E0A\u9762\u7684\u770B\u677F\u5F00\u5173\u3002",
|
|
15747
16613
|
memoryOff: "\u8D1F\u8D23\u4EBA\u8981\u7528\u9879\u76EE\u8BB0\u5FC6\uFF0C\u5148\u6253\u5F00\u4E0A\u9762\u7684\u9879\u76EE\u8BB0\u5FC6\u5F00\u5173\u3002"
|
|
15748
16614
|
},
|
|
16615
|
+
teamMembers: {
|
|
16616
|
+
title: "\u56E2\u961F\u6210\u5458",
|
|
16617
|
+
add: "\u6DFB\u52A0\u6210\u5458",
|
|
16618
|
+
addTitle: "\u6DFB\u52A0\u6210\u5458",
|
|
16619
|
+
addChoose: "\u9009\u62E9\u6210\u5458",
|
|
16620
|
+
addNone: "\u9879\u76EE\u91CC\u7684\u6210\u5458\u90FD\u5DF2\u5728\u8FD9\u4E2A\u56E2\u961F\u91CC",
|
|
16621
|
+
addConfirm: "\u6DFB\u52A0",
|
|
16622
|
+
makeLead: "\u8BBE\u4E3A\u8D1F\u8D23\u4EBA",
|
|
16623
|
+
makeLeadFor: "\u5C06 {{name}} \u8BBE\u4E3A\u8D1F\u8D23\u4EBA",
|
|
16624
|
+
leadTitle: "\u5C06 {{name}} \u8BBE\u4E3A\u8D1F\u8D23\u4EBA\uFF1F",
|
|
16625
|
+
leadDescription_one: "{{lead}} \u540D\u4E0B\u8FD8\u5F00\u7740\u7684 {{count}} \u4EF6\u4F1A\u6539\u7ED9 {{name}}\uFF0C\u5DF2\u7ECF\u5728\u505A\u7684\u4E5F\u4E00\u8D77\u62FF\u8D70\u3002{{lead}} \u7559\u4F5C\u56E2\u961F\u91CC\u7684\u666E\u901A\u6210\u5458\u3002",
|
|
16626
|
+
leadDescription_other: "{{lead}} \u540D\u4E0B\u8FD8\u5F00\u7740\u7684 {{count}} \u4EF6\u4F1A\u6539\u7ED9 {{name}}\uFF0C\u5DF2\u7ECF\u5728\u505A\u7684\u4E5F\u4E00\u8D77\u62FF\u8D70\u3002{{lead}} \u7559\u4F5C\u56E2\u961F\u91CC\u7684\u666E\u901A\u6210\u5458\u3002",
|
|
16627
|
+
leadDescriptionNone: "{{lead}} \u7559\u4F5C\u56E2\u961F\u91CC\u7684\u666E\u901A\u6210\u5458\u3002",
|
|
16628
|
+
leadConfirm: "\u8BBE\u4E3A\u8D1F\u8D23\u4EBA",
|
|
16629
|
+
remove: "\u79FB\u9664",
|
|
16630
|
+
removeFor: "\u79FB\u9664 {{name}}",
|
|
16631
|
+
removeTitle: "\u628A {{name}} \u79FB\u51FA\u56E2\u961F\uFF1F",
|
|
16632
|
+
removeDescription: "\u8FD8\u6CA1\u4EA4\u5230\u5B83\u624B\u4E0A\u7684\u6D3B\u4F1A\u9000\u56DE\u8D1F\u8D23\u4EBA\uFF0C\u5DF2\u7ECF\u5728\u5B83\u624B\u4E0A\u7684\u7559\u7ED9\u5B83\u505A\u5B8C\u3002",
|
|
16633
|
+
removeDescriptionCount_one: "\u8FD8\u6CA1\u4EA4\u5230\u5B83\u624B\u4E0A\u7684 {{count}} \u4EF6\u4F1A\u9000\u56DE\u8D1F\u8D23\u4EBA\uFF0C\u5DF2\u7ECF\u5728\u5B83\u624B\u4E0A\u7684\u7559\u7ED9\u5B83\u505A\u5B8C\u3002",
|
|
16634
|
+
removeDescriptionCount_other: "\u8FD8\u6CA1\u4EA4\u5230\u5B83\u624B\u4E0A\u7684 {{count}} \u4EF6\u4F1A\u9000\u56DE\u8D1F\u8D23\u4EBA\uFF0C\u5DF2\u7ECF\u5728\u5B83\u624B\u4E0A\u7684\u7559\u7ED9\u5B83\u505A\u5B8C\u3002",
|
|
16635
|
+
removeConfirm: "\u79FB\u9664",
|
|
16636
|
+
working: "\u5904\u7406\u4E2D\u2026",
|
|
16637
|
+
addDescription: "agent \u6210\u5458\u8981\u5148\u901A\u8FC7\u8BD5\u8DD1\u624D\u80FD\u63A5\u6D3B\uFF0C\u4EBA\u52A0\u5165\u540E\u5373\u53EF\u63A5\u6D3B\u3002",
|
|
16638
|
+
archived: "\u8FD9\u4E2A\u56E2\u961F\u5DF2\u5F52\u6863\uFF0C\u4E0D\u80FD\u6539\u6210\u5458\u3002",
|
|
16639
|
+
leadStays: "\u5148\u628A\u8D1F\u8D23\u4EBA\u4EA4\u7ED9\u522B\u4EBA",
|
|
16640
|
+
cancel: "\u53D6\u6D88",
|
|
16641
|
+
loadFailed: "\u56E2\u961F\u6210\u5458\u8BFB\u4E0D\u51FA\u6765\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
16642
|
+
failed: "\u6CA1\u6709\u6539\u6210\u3002\u56E2\u961F\u53EF\u80FD\u521A\u88AB\u6539\u8FC7\uFF0C\u5217\u8868\u5DF2\u5237\u65B0\u3002",
|
|
16643
|
+
leadOffline: "{{name}} \u6240\u5728\u7684\u673A\u5668\u79BB\u7EBF\u4E86\u3002\u8D1F\u8D23\u4EBA\u4FDD\u6301\u4E0D\u53D8\uFF0C\u673A\u5668\u56DE\u6765\u540E\u63A5\u7740\u505A\uFF1B\u4E5F\u53EF\u4EE5\u6539\u8BA9\u522B\u4EBA\u5F53\u8D1F\u8D23\u4EBA\u3002",
|
|
16644
|
+
returning: "\u6210\u5458\u5DF2\u79FB\u51FA\uFF0C\u540D\u4E0B\u7684\u4EF6\u8FD8\u5728\u9000\u56DE\u8D1F\u8D23\u4EBA\u3002"
|
|
16645
|
+
},
|
|
15749
16646
|
members: {
|
|
15750
16647
|
title: "\u6210\u5458",
|
|
15751
16648
|
open: "\u67E5\u770B\u6210\u5458",
|
|
@@ -15856,7 +16753,7 @@ var zh_CN_default = {
|
|
|
15856
16753
|
passed: "\u8BD5\u8DD1\u901A\u8FC7",
|
|
15857
16754
|
skipped: "\u5DF2\u8DF3\u8FC7\u8BD5\u8DD1",
|
|
15858
16755
|
remoteVerified: "\u5DF2\u5728\u5B83\u7684\u673A\u5668\u4E0A\u9A8C\u8BC1",
|
|
15859
|
-
invoked: "\
|
|
16756
|
+
invoked: "\u4F1A\u8BDD\u5DF2\u5728\u8FD0\u884C\uFF0C\u65E0\u9700\u8BD5\u8DD1",
|
|
15860
16757
|
pending: "\u7B49\u5F85\u8BD5\u8DD1",
|
|
15861
16758
|
running: "\u8BD5\u8DD1\u4E2D",
|
|
15862
16759
|
sent: "\u8BD5\u8DD1\u5DF2\u53D1\u51FA",
|
|
@@ -16034,6 +16931,7 @@ var zh_CN_default = {
|
|
|
16034
16931
|
revert_handbook: "\u9000\u56DE\u624B\u518C",
|
|
16035
16932
|
open: "\u5F00\u56E2\u961F",
|
|
16036
16933
|
set_members: "\u8C03\u6574\u56E2\u961F\u6210\u5458",
|
|
16934
|
+
set_lead: "\u4EA4\u51FA\u56E2\u961F\u8D1F\u8D23\u4EBA",
|
|
16037
16935
|
roster_overview: "\u8BFB\u53D6\u6210\u5458\u6982\u89C8",
|
|
16038
16936
|
trial_started: "\u5F00\u59CB\u8BD5\u8DD1",
|
|
16039
16937
|
trial_done: "\u5B8C\u6210\u8BD5\u8DD1",
|
|
@@ -16105,6 +17003,7 @@ function registerTrial(ctx, runtime) {
|
|
|
16105
17003
|
},
|
|
16106
17004
|
{
|
|
16107
17005
|
name: "retry_trial",
|
|
17006
|
+
remoteAvailable: true,
|
|
16108
17007
|
description: trialMessage("retryTool"),
|
|
16109
17008
|
inputSchema: toolSchema(RetryTrialToolInput),
|
|
16110
17009
|
handle: (input, invocation) => runTool(() => runtime.retryAsLead(decodeLeadRetry(input).memberId, invocation))
|
|
@@ -16236,29 +17135,6 @@ var factKey = (record2) => ({
|
|
|
16236
17135
|
attempt: record2.attempt
|
|
16237
17136
|
});
|
|
16238
17137
|
|
|
16239
|
-
// src/trial/hostState.ts
|
|
16240
|
-
import { projectOrNull } from "@ycodium-ai/plugin-api";
|
|
16241
|
-
function projectGone(ctx) {
|
|
16242
|
-
const known = /* @__PURE__ */ new Map();
|
|
16243
|
-
return async (projectId) => {
|
|
16244
|
-
const cached2 = known.get(projectId);
|
|
16245
|
-
if (cached2 !== void 0) return cached2;
|
|
16246
|
-
const gone = await projectOrNull(ctx.projects, projectId).then(
|
|
16247
|
-
(project2) => project2 === null || project2.archivedAt != null,
|
|
16248
|
-
() => false
|
|
16249
|
-
);
|
|
16250
|
-
known.set(projectId, gone);
|
|
16251
|
-
return gone;
|
|
16252
|
-
};
|
|
16253
|
-
}
|
|
16254
|
-
function reasonOf(error) {
|
|
16255
|
-
const summary = summarizeError(error, "");
|
|
16256
|
-
const tag2 = typeof error === "object" && error !== null && "_tag" in error && typeof error._tag === "string" ? error._tag : "";
|
|
16257
|
-
return tag2 === "" || summary.includes(tag2) ? summary : `${tag2}: ${summary}`;
|
|
16258
|
-
}
|
|
16259
|
-
var REJECTED_REASONS = /* @__PURE__ */ new Set(["rejected", ...CONFLICT_REASONS]);
|
|
16260
|
-
var isRejection = (error) => REJECTED_REASONS.has(dataCommandReason(error) ?? "");
|
|
16261
|
-
|
|
16262
17138
|
// src/trial/dispatch.ts
|
|
16263
17139
|
async function remoteRoute(env, projectId, environmentId) {
|
|
16264
17140
|
const machines = await readMachines(env.ctx, projectId);
|
|
@@ -16442,34 +17318,41 @@ var nameOf = async (env, record2) => (await findMember(env.ctx, record2.projectI
|
|
|
16442
17318
|
var leadRow = (goal) => goal.threads.find((row) => row.memberId === goal.leadMemberId);
|
|
16443
17319
|
async function goalLeadThreadId(env, projectId) {
|
|
16444
17320
|
const [goal] = await env.deps.goals.allOf(projectId);
|
|
16445
|
-
return goal === void 0 ? void 0 : leadRow(goal)?.threadId;
|
|
17321
|
+
return goal === void 0 ? void 0 : leadRow(goal)?.threadId ?? roomThreadOf(goal);
|
|
16446
17322
|
}
|
|
16447
|
-
async function
|
|
17323
|
+
async function openLeadGoals(env, record2) {
|
|
16448
17324
|
const goals = await env.deps.goals.allOf(record2.projectId);
|
|
16449
17325
|
const wake = readFact(await env.deps.wakes.get(), record2.projectId);
|
|
16450
17326
|
if (wake === null) return [];
|
|
16451
|
-
const
|
|
17327
|
+
const open = [];
|
|
16452
17328
|
for (const goal of goals) {
|
|
16453
|
-
|
|
16454
|
-
if (lead === void 0 || record2.memberId === goal.leadMemberId || !goalOpen(wake, goal))
|
|
16455
|
-
continue;
|
|
17329
|
+
if (record2.memberId === goal.leadMemberId || !goalOpen(wake, goal)) continue;
|
|
16456
17330
|
if (goal.workLineId !== void 0 && !await memberOnLine(env.ctx, record2.projectId, goal.workLineId, record2.memberId))
|
|
16457
17331
|
continue;
|
|
16458
|
-
|
|
17332
|
+
open.push(goal);
|
|
16459
17333
|
}
|
|
16460
|
-
return
|
|
17334
|
+
return open;
|
|
16461
17335
|
}
|
|
16462
|
-
async function
|
|
17336
|
+
async function openLeadThreads(env, record2) {
|
|
17337
|
+
return (await openLeadGoals(env, record2)).flatMap((goal) => {
|
|
17338
|
+
const lead = leadRow(goal);
|
|
17339
|
+
return lead === void 0 ? [] : [lead.threadId];
|
|
17340
|
+
});
|
|
17341
|
+
}
|
|
17342
|
+
async function openLeadAddresses(env, record2) {
|
|
17343
|
+
const addresses = [];
|
|
17344
|
+
for (const goal of await openLeadGoals(env, record2)) {
|
|
17345
|
+
const address = await leadAddressOf(env.ctx, goal);
|
|
17346
|
+
if (address !== null) addresses.push(address);
|
|
17347
|
+
}
|
|
17348
|
+
return addresses;
|
|
17349
|
+
}
|
|
17350
|
+
async function tellLeads(env, addresses, projectId, key, text) {
|
|
16463
17351
|
let delivered = false;
|
|
16464
|
-
for (const [index,
|
|
16465
|
-
const
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
recipient: { threadId: leadThreadId },
|
|
16469
|
-
requestId,
|
|
16470
|
-
messageId: `${requestId}:message`,
|
|
16471
|
-
text,
|
|
16472
|
-
wake: { reason: "notice" }
|
|
17352
|
+
for (const [index, address] of addresses.entries()) {
|
|
17353
|
+
const sent = await tellLeadAt(env.ctx, projectId, address, {
|
|
17354
|
+
requestId: index === 0 ? key : `${key}:${leadAddressKey(address)}`,
|
|
17355
|
+
text
|
|
16473
17356
|
});
|
|
16474
17357
|
delivered ||= sent;
|
|
16475
17358
|
}
|
|
@@ -16484,7 +17367,7 @@ async function tellFailure(env, record2, told) {
|
|
|
16484
17367
|
const reason = trialFailureText(record2.failure.category, record2.failure.reason);
|
|
16485
17368
|
const delivered = await tellLeads(
|
|
16486
17369
|
env,
|
|
16487
|
-
await
|
|
17370
|
+
await openLeadAddresses(env, record2),
|
|
16488
17371
|
record2.projectId,
|
|
16489
17372
|
key,
|
|
16490
17373
|
// 「再试一次」只给工具会答应的那种失败(`leadRetryVerdict`);其余只剩换规格和写给人。
|
|
@@ -16936,8 +17819,11 @@ function startTrialRuntime(ctx, deps, options = {}) {
|
|
|
16936
17819
|
};
|
|
16937
17820
|
const retryAsLead = (memberId, invocation) => serial(async () => {
|
|
16938
17821
|
const lead = await checkLead(deps.goals, invocation);
|
|
16939
|
-
if (!lead.ok)
|
|
17822
|
+
if (!lead.ok) {
|
|
17823
|
+
if (lead.reason === "update-required" || lead.reason === "several-teams")
|
|
17824
|
+
throw new Error(remoteLeadRefusal(lead.reason));
|
|
16940
17825
|
throw new Error(trialMessage(lead.reason === "no-project" ? "noProject" : "leadOnlyRetry"));
|
|
17826
|
+
}
|
|
16941
17827
|
const record2 = recordOf(await state.get(), lead.projectId, memberId);
|
|
16942
17828
|
if (record2 === null || record2.removed) throw new Error(trialMessage("retryMemberMissing"));
|
|
16943
17829
|
const verdict = leadRetryVerdict(record2);
|
|
@@ -16997,13 +17883,18 @@ var index_default = definePlugin({
|
|
|
16997
17883
|
groupDigest,
|
|
16998
17884
|
teamWaiting: (memberThreads, nameOf2) => teamWaitingList(ctx, memberThreads, nameOf2)
|
|
16999
17885
|
});
|
|
17886
|
+
const lineRemovals = startLineRemovals(ctx, {
|
|
17887
|
+
state: ctx.derivedState(lineRemovalStateDefinition),
|
|
17888
|
+
goals,
|
|
17889
|
+
wakes: wakes.state
|
|
17890
|
+
});
|
|
17000
17891
|
registerTeamTools(
|
|
17001
17892
|
ctx,
|
|
17002
17893
|
{
|
|
17003
17894
|
goals,
|
|
17004
17895
|
trials: trialState,
|
|
17005
|
-
|
|
17006
|
-
|
|
17896
|
+
changes: ctx.derivedState(lineChangeStateDefinition),
|
|
17897
|
+
lineRemovals
|
|
17007
17898
|
},
|
|
17008
17899
|
memberQueue
|
|
17009
17900
|
);
|
|
@@ -17021,12 +17912,19 @@ var index_default = definePlugin({
|
|
|
17021
17912
|
});
|
|
17022
17913
|
registerWakeSupplement(ctx, wakes, groupDigest);
|
|
17023
17914
|
registerPauseCommands(ctx, { wakes: wakes.state, queue: memberQueue });
|
|
17915
|
+
registerLineMemberCommands(ctx, { wakes: wakes.state, queue: memberQueue, lineRemovals });
|
|
17024
17916
|
startArchiveMirror(
|
|
17025
17917
|
ctx,
|
|
17026
17918
|
{ state: ctx.derivedState(archiveStateDefinition), wakes: wakes.state },
|
|
17027
17919
|
memberQueue
|
|
17028
17920
|
);
|
|
17029
17921
|
startLineNameMirror(ctx, memberQueue);
|
|
17922
|
+
startLeadHandoverRuntime(ctx, {
|
|
17923
|
+
state: ctx.derivedState(leadHandoverStateDefinition),
|
|
17924
|
+
goals,
|
|
17925
|
+
wakes: wakes.state,
|
|
17926
|
+
trials: trialState
|
|
17927
|
+
});
|
|
17030
17928
|
startMemberBindingRuntime(ctx, goals, rosters, wakes.state, {
|
|
17031
17929
|
rebindTargets: rebindReader(trialState)
|
|
17032
17930
|
});
|