@ycodium-ai/plugin-team 0.2.5029 → 0.2.5177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 = 143;
11
+ var PLUGIN_API_VERSION = 152;
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) => {
@@ -7213,13 +7213,21 @@ var TrialCommandResult = Union2([
7213
7213
  var normalizeTrialReason = (reason) => reason.replace(/[\s.。]+$/u, "");
7214
7214
  var TrialFailure = Struct({ category: String4, reason: String4 });
7215
7215
  var TrialView = Struct({
7216
- status: Literals(["pending", "running", "waiting", "passed", "failed", "overridden"]),
7216
+ status: Literals([
7217
+ "pending",
7218
+ "running",
7219
+ "waiting",
7220
+ "passed",
7221
+ "failed",
7222
+ "overridden",
7223
+ "imported"
7224
+ ]),
7217
7225
  evidence: NullOr(Literals(["trial", "remote", "skipped", "invoked"])),
7218
7226
  specKey: String4,
7219
7227
  attempt: Int,
7220
7228
  failure: NullOr(TrialFailure)
7221
7229
  });
7222
- var isRetryable = (status) => status === "failed" || status === "waiting";
7230
+ var isRetryable = (status) => status === "failed" || status === "waiting" || status === "imported";
7223
7231
 
7224
7232
  // src/domain/fullAccess.ts
7225
7233
  var FULL_ACCESS_NATIVE_MODE = {
@@ -7445,6 +7453,7 @@ function registerGoalCommands(ctx, service2) {
7445
7453
 
7446
7454
  // src/watch.ts
7447
7455
  import * as NodeTimers from "node:timers";
7456
+ import { holdKeyedSubscriber } from "@ycodium-ai/plugin-api";
7448
7457
 
7449
7458
  // src/domain/person.ts
7450
7459
  var personKey = (person) => person.kind === "account" ? `account:${person.userId}` : `local-owner:${person.environmentId}`;
@@ -7628,6 +7637,325 @@ var ReadBoardInput = Struct({
7628
7637
  workLineId: optionalKey2(String4)
7629
7638
  });
7630
7639
 
7640
+ // src/domain/execution.ts
7641
+ function goalExecution(goal) {
7642
+ return {
7643
+ leadMemberId: goal?.leadMemberId ?? null,
7644
+ members: goal === null ? [] : [...goal.threads, ...goal.remoteMembers ?? []]
7645
+ };
7646
+ }
7647
+ function findGoalMember(members, identity2) {
7648
+ return members.find(
7649
+ (member) => "threadId" in identity2 ? "threadId" in member && member.threadId === identity2.threadId : "principalId" in member && member.principalId === identity2.principalId
7650
+ );
7651
+ }
7652
+
7653
+ // src/domain/facts.ts
7654
+ function foldFact(state, event, decode4, keyOf2) {
7655
+ if (event.type !== "plugin.event-appended") return state;
7656
+ const decoded = decode4(event.payload);
7657
+ if (isNone2(decoded)) return state;
7658
+ return { ...state, [keyOf2(decoded.value)]: decoded.value };
7659
+ }
7660
+ function readFact(state, key) {
7661
+ return Object.hasOwn(state, key) ? state[key] : null;
7662
+ }
7663
+ function without(rows, key) {
7664
+ if (!Object.hasOwn(rows, key)) return rows;
7665
+ const next = { ...rows };
7666
+ delete next[key];
7667
+ return next;
7668
+ }
7669
+ var factEnvelope = (name, data) => Struct({ pluginId: Literal2("team"), name: Literal2(`team/${name}`), data });
7670
+ var nowIso = map5(now2, formatIso2);
7671
+ var factTime = () => runPromise2(nowIso);
7672
+
7673
+ // src/domain/recipient.ts
7674
+ var recipientOf = (principal) => principal.kind === "agent" && principal.threadId !== void 0 ? { threadId: principal.threadId } : principal.kind === "remote-agent" && principal.principalId !== void 0 ? { principalId: principal.principalId } : void 0;
7675
+ var recipientKey = (who) => "threadId" in who ? `thread:${who.threadId}` : `principal:${who.principalId}`;
7676
+
7677
+ // src/domain/binding.ts
7678
+ var MemberBoundFact = Struct({
7679
+ version: Literal2(1),
7680
+ projectId: String4,
7681
+ memberId: String4,
7682
+ specKey: String4,
7683
+ goalId: String4,
7684
+ threadId: optionalKey2(String4),
7685
+ principalId: optionalKey2(String4),
7686
+ replaces: optionalKey2(String4)
7687
+ }).check(
7688
+ makeFilter2((fact) => fact.threadId === void 0 !== (fact.principalId === void 0))
7689
+ );
7690
+ var MemberBoundEnvelope = factEnvelope("member-bound", MemberBoundFact);
7691
+ var bindingOfFact = (fact) => fact.threadId !== void 0 ? { threadId: fact.threadId } : { principalId: fact.principalId };
7692
+ function bindingsOf(goal) {
7693
+ const bindings = {};
7694
+ for (const member of goalExecution(goal).members)
7695
+ bindings[member.memberId] = "threadId" in member ? { threadId: member.threadId } : { principalId: member.principalId };
7696
+ return bindings;
7697
+ }
7698
+ function withBoundBinding(bindings, fact) {
7699
+ const next = { ...bindings };
7700
+ if (fact.replaces !== void 0) delete next[fact.replaces];
7701
+ next[fact.memberId] = bindingOfFact(fact);
7702
+ return next;
7703
+ }
7704
+ var leadAfterBinding = (leadMemberId, fact) => fact.replaces !== void 0 && leadMemberId === fact.replaces ? fact.memberId : leadMemberId;
7705
+ function withBoundMember(goal, fact) {
7706
+ if (fact.projectId !== goal.projectId || fact.goalId !== goal.goalId) return goal;
7707
+ const { remoteMembers: _before, ...rest } = goal;
7708
+ const superseded = (memberId) => memberId === fact.memberId || memberId === fact.replaces;
7709
+ const threads = goal.threads.filter((row) => !superseded(row.memberId));
7710
+ const remoteMembers = (goal.remoteMembers ?? []).filter((row) => !superseded(row.memberId));
7711
+ const binding = bindingOfFact(fact);
7712
+ const next = "threadId" in binding ? {
7713
+ threads: [...threads, { memberId: fact.memberId, threadId: binding.threadId }],
7714
+ remoteMembers
7715
+ } : {
7716
+ threads,
7717
+ remoteMembers: [
7718
+ ...remoteMembers,
7719
+ { memberId: fact.memberId, principalId: binding.principalId }
7720
+ ]
7721
+ };
7722
+ return {
7723
+ ...rest,
7724
+ leadMemberId: leadAfterBinding(goal.leadMemberId, fact),
7725
+ threads: next.threads,
7726
+ ...next.remoteMembers.length === 0 ? {} : { remoteMembers: next.remoteMembers }
7727
+ };
7728
+ }
7729
+ function targetOf(bindings, assignee, pinned) {
7730
+ if (assignee.kind !== "member") return recipientOf(assignee);
7731
+ const { memberId } = assignee;
7732
+ if (memberId === void 0) return void 0;
7733
+ const fixed = pinned !== void 0 && Object.hasOwn(pinned, memberId) ? pinned[memberId] : void 0;
7734
+ if (fixed !== void 0) return { threadId: fixed };
7735
+ return bindings !== void 0 && Object.hasOwn(bindings, memberId) ? bindings[memberId] : void 0;
7736
+ }
7737
+ function assignedToGoalMember(goal, assignees) {
7738
+ const execution = goalExecution(goal);
7739
+ const members = execution.members.filter((member) => member.memberId !== execution.leadMemberId);
7740
+ const bindings = bindingsOf(goal);
7741
+ return assignees.some((assignee) => {
7742
+ const who = targetOf(bindings, assignee);
7743
+ return who !== void 0 && findGoalMember(members, who) !== void 0;
7744
+ });
7745
+ }
7746
+
7747
+ // src/domain/pause.ts
7748
+ var LinePausedEnvelope = factEnvelope(
7749
+ "line-paused",
7750
+ Struct({
7751
+ version: Literal2(1),
7752
+ status: Literals(["paused", "resumed"]),
7753
+ projectId: String4,
7754
+ workLineId: String4
7755
+ })
7756
+ );
7757
+ var LineMemberPausedEnvelope = factEnvelope(
7758
+ "line-member-paused",
7759
+ Struct({
7760
+ version: Literal2(1),
7761
+ status: Literals(["paused", "resumed"]),
7762
+ projectId: String4,
7763
+ workLineId: String4,
7764
+ memberId: String4
7765
+ })
7766
+ );
7767
+
7768
+ // src/runtime/wakeEvents.ts
7769
+ var MemberWokenFact = Struct({
7770
+ version: Literal2(1),
7771
+ key: String4,
7772
+ projectId: String4,
7773
+ threadId: optionalKey2(String4),
7774
+ principalId: optionalKey2(String4)
7775
+ });
7776
+ var MemberWorktreeFailedFact = Struct({
7777
+ version: Literal2(1),
7778
+ projectId: String4,
7779
+ threadId: String4,
7780
+ reason: String4
7781
+ });
7782
+ var decodeEnvelope = decodeUnknownOption2(
7783
+ Union2([
7784
+ Struct({
7785
+ pluginId: Literal2("team"),
7786
+ name: Literal2("team/goal-started"),
7787
+ data: GoalStartedFact
7788
+ }),
7789
+ Struct({
7790
+ pluginId: Literal2("team"),
7791
+ name: Literal2("team/member-woken"),
7792
+ data: MemberWokenFact
7793
+ }),
7794
+ MemberBoundEnvelope,
7795
+ LinePausedEnvelope,
7796
+ LineMemberPausedEnvelope,
7797
+ Struct({
7798
+ pluginId: Literal2("team"),
7799
+ name: Literal2("team/member-worktree-failed"),
7800
+ data: MemberWorktreeFailedFact
7801
+ }),
7802
+ Struct({
7803
+ pluginId: Literal2("team"),
7804
+ name: Literal2("team/member-worktree-reported"),
7805
+ data: Struct({
7806
+ version: Literal2(1),
7807
+ projectId: String4,
7808
+ threadId: String4
7809
+ })
7810
+ })
7811
+ ])
7812
+ );
7813
+ var Principal = Union2([
7814
+ Struct({ kind: Literal2("human") }),
7815
+ Struct({ kind: Literal2("agent"), threadId: String4 }),
7816
+ // `memberId`:发言转来的远端作者、点名带着成员号(见 `asItemComment`);旧评论没有。
7817
+ Struct({
7818
+ kind: Literal2("remote-agent"),
7819
+ principalId: String4,
7820
+ memberId: optionalKey2(String4)
7821
+ }),
7822
+ Struct({ kind: Literal2("member"), memberId: String4 })
7823
+ ]);
7824
+ var Actor = Union2([
7825
+ Principal,
7826
+ Struct({ kind: Literal2("plugin"), pluginId: String4 }),
7827
+ Struct({ kind: Literals(["local-cli", "seat", "system"]) })
7828
+ ]);
7829
+ var Updater = Struct({
7830
+ kind: String4,
7831
+ threadId: optionalKey2(String4)
7832
+ });
7833
+ var StateRef = Struct({
7834
+ group: String4,
7835
+ stateId: optionalKey2(String4)
7836
+ });
7837
+ var itemFields = { projectId: String4, workItemId: String4 };
7838
+ var lineField = { workLineId: optional(NullOr(String4)) };
7839
+ var relationFields = {
7840
+ ...itemFields,
7841
+ relationKind: String4,
7842
+ relatedWorkItemId: String4
7843
+ };
7844
+ var decodeWorkEvent = decodeUnknownOption2(
7845
+ Union2([
7846
+ Struct({
7847
+ // 迁入的件(账本导入,0111 S5)与新建的件同一份载荷,按建件折。
7848
+ type: Literals(["work.item-created", "work.item-imported"]),
7849
+ payload: Struct({
7850
+ ...itemFields,
7851
+ sequenceId: Number5,
7852
+ assignees: ArraySchema(Principal),
7853
+ state: StateRef,
7854
+ ...lineField
7855
+ })
7856
+ }),
7857
+ Struct({
7858
+ type: Literal2("work.item-updated"),
7859
+ payload: Struct({
7860
+ ...itemFields,
7861
+ assignees: optional(ArraySchema(Principal)),
7862
+ state: optional(StateRef),
7863
+ actor: optional(Updater),
7864
+ ...lineField
7865
+ })
7866
+ }),
7867
+ Struct({
7868
+ type: Literal2("work.item-claimed"),
7869
+ payload: Struct({
7870
+ ...itemFields,
7871
+ assignee: Principal,
7872
+ state: optional(StateRef)
7873
+ })
7874
+ }),
7875
+ Struct({
7876
+ type: Literal2("work.relation-added"),
7877
+ payload: Struct(relationFields)
7878
+ }),
7879
+ Struct({
7880
+ type: Literal2("work.relation-removed"),
7881
+ payload: Struct(relationFields)
7882
+ }),
7883
+ Struct({
7884
+ type: Literal2("work.comment-posted"),
7885
+ payload: Struct({
7886
+ ...itemFields,
7887
+ commentId: String4,
7888
+ parentAuthor: optional(Actor),
7889
+ mentions: ArraySchema(Principal),
7890
+ actor: Actor,
7891
+ // 由件上的发言转来(见 `asItemComment`);旧评论事件没有这个键。
7892
+ fromPost: optional(Literal2(true))
7893
+ })
7894
+ })
7895
+ ])
7896
+ );
7897
+ var agentThreads = (principals) => [
7898
+ ...new Set(principals.flatMap((p) => p.kind === "agent" ? [p.threadId] : []))
7899
+ ];
7900
+ var assigneeMembers = (principals) => [
7901
+ ...new Set(principals.flatMap((p) => p.kind === "member" ? [p.memberId] : []))
7902
+ ];
7903
+ var PostRef = Union2([
7904
+ Struct({ kind: Literal2("thread"), threadId: String4 }),
7905
+ Struct({ kind: Literal2("member"), memberId: String4 }),
7906
+ Struct({
7907
+ kind: Literal2("principal"),
7908
+ principalId: String4,
7909
+ memberId: optionalKey2(String4)
7910
+ }),
7911
+ Struct({ kind: Literal2("person") })
7912
+ ]);
7913
+ var decodeItemPost = decodeUnknownOption2(
7914
+ Struct({
7915
+ postId: String4,
7916
+ projectId: String4,
7917
+ anchor: Struct({ kind: Literal2("work-item"), workItemId: String4 }),
7918
+ author: Actor,
7919
+ mentions: optional(ArraySchema(PostRef)),
7920
+ source: optional(Struct({ memberId: optional(String4) }))
7921
+ })
7922
+ );
7923
+ var asItemComment = (event) => {
7924
+ if (event.type !== "communication.post-sent") return event;
7925
+ const post = decodeItemPost(event.payload);
7926
+ if (isNone2(post)) return event;
7927
+ const { postId, projectId, anchor, author, mentions, source } = post.value;
7928
+ const actor = author.kind === "remote-agent" && source?.memberId !== void 0 ? { ...author, memberId: source.memberId } : author;
7929
+ return {
7930
+ ...event,
7931
+ type: "work.comment-posted",
7932
+ payload: {
7933
+ projectId,
7934
+ workItemId: anchor.workItemId,
7935
+ commentId: postId,
7936
+ fromPost: true,
7937
+ actor,
7938
+ mentions: (mentions ?? []).flatMap(
7939
+ (ref) => ref.kind === "thread" ? [{ kind: "agent", threadId: ref.threadId }] : ref.kind === "member" ? [{ kind: "member", memberId: ref.memberId }] : ref.kind === "principal" ? [
7940
+ {
7941
+ kind: "remote-agent",
7942
+ principalId: ref.principalId,
7943
+ ...ref.memberId === void 0 ? {} : { memberId: ref.memberId }
7944
+ }
7945
+ ] : []
7946
+ )
7947
+ }
7948
+ };
7949
+ };
7950
+ var decodeRemovedPost = decodeUnknownOption2(
7951
+ Struct({ postId: String4, projectId: String4 })
7952
+ );
7953
+ var removedPost = (event) => {
7954
+ if (event.type !== "communication.post-withdrawn" && event.type !== "communication.post-deleted")
7955
+ return null;
7956
+ return getOrNull(decodeRemovedPost(event.payload));
7957
+ };
7958
+
7631
7959
  // src/watch.ts
7632
7960
  var emptyChanges = () => ({ cursor: 0, handbookCursor: 0, membersCursor: 0 });
7633
7961
  var decodeRead = decodeUnknownSync(ReadBoardInput);
@@ -7707,9 +8035,16 @@ function registerTeamWatch(ctx, options) {
7707
8035
  );
7708
8036
  };
7709
8037
  const changed = (event, kinds) => invalidate(eventProject(event), kinds, event.sequence);
7710
- const stops = [.../* @__PURE__ */ new Set([...WORK_EVENTS, ...HANDBOOK_EVENTS, ...MEMBER_EVENTS])].map(
7711
- (type) => ctx.events.onRaw(type, (event) => changed(event, kindsOf(type)))
7712
- );
8038
+ const stops = [
8039
+ ...[.../* @__PURE__ */ new Set([...WORK_EVENTS, ...HANDBOOK_EVENTS, ...MEMBER_EVENTS])].map(
8040
+ (type) => ctx.events.onRaw(type, (event) => changed(event, kindsOf(type)))
8041
+ ),
8042
+ // 工作项上的发言就是这件上的评论(0112 U6e),同评论敲看板;挂在会话、人身上的发言不敲。
8043
+ ctx.events.onRaw("communication.post-sent", (event) => {
8044
+ const comment = asItemComment(event);
8045
+ if (comment !== event) changed(comment, ["board"]);
8046
+ })
8047
+ ];
7713
8048
  stops.push(
7714
8049
  ctx.events.onRaw("plugin.event-appended", (event) => {
7715
8050
  const fact = decodeFact(event.payload);
@@ -7734,28 +8069,21 @@ function registerTeamWatch(ctx, options) {
7734
8069
  handle: async (payload, emit, signal) => {
7735
8070
  if (signal.aborted || disposed) return;
7736
8071
  const { projectId } = decodeRead(payload);
7737
- const subscribers = listeners.get(projectId) ?? /* @__PURE__ */ new Set();
7738
- const ring = (value) => {
7739
- if (!signal.aborted && !disposed) emit(value);
7740
- };
7741
- listeners.set(projectId, subscribers);
7742
- subscribers.add(ring);
7743
- try {
7744
- ring(cursors.get(projectId) ?? emptyChanges());
7745
- await new Promise((resolve2) => {
7746
- if (signal.aborted) resolve2();
7747
- else signal.addEventListener("abort", () => resolve2(), { once: true });
7748
- });
7749
- } finally {
7750
- subscribers.delete(ring);
7751
- if (subscribers.size === 0) {
7752
- listeners.delete(projectId);
8072
+ await holdKeyedSubscriber({
8073
+ subscribers: listeners,
8074
+ key: projectId,
8075
+ signal,
8076
+ emit: (value) => {
8077
+ if (!disposed) emit(value);
8078
+ },
8079
+ current: () => cursors.get(projectId) ?? emptyChanges(),
8080
+ onLast: () => {
7753
8081
  timers.get(projectId)?.();
7754
8082
  timers.delete(projectId);
7755
8083
  pending.delete(projectId);
7756
8084
  cursors.delete(projectId);
7757
8085
  }
7758
- }
8086
+ });
7759
8087
  }
7760
8088
  });
7761
8089
  ctx.onDispose(() => {
@@ -7966,26 +8294,6 @@ function createSerial(closedMessage = "team-serial-closed") {
7966
8294
  };
7967
8295
  }
7968
8296
 
7969
- // src/domain/facts.ts
7970
- function foldFact(state, event, decode4, keyOf2) {
7971
- if (event.type !== "plugin.event-appended") return state;
7972
- const decoded = decode4(event.payload);
7973
- if (isNone2(decoded)) return state;
7974
- return { ...state, [keyOf2(decoded.value)]: decoded.value };
7975
- }
7976
- function readFact(state, key) {
7977
- return Object.hasOwn(state, key) ? state[key] : null;
7978
- }
7979
- function without(rows, key) {
7980
- if (!Object.hasOwn(rows, key)) return rows;
7981
- const next = { ...rows };
7982
- delete next[key];
7983
- return next;
7984
- }
7985
- var factEnvelope = (name, data) => Struct({ pluginId: Literal2("team"), name: Literal2(`team/${name}`), data });
7986
- var nowIso = map5(now2, formatIso2);
7987
- var factTime = () => runPromise2(nowIso);
7988
-
7989
8297
  // src/domain/service.ts
7990
8298
  var HISTORY_LIMIT = 500;
7991
8299
  var ACTIVE_LIMIT = 2e3;
@@ -8426,93 +8734,6 @@ var specOfMember = (member) => ({
8426
8734
  });
8427
8735
  var trialIdOf = (projectId, memberId, specKey, attempt) => `team-trial:${stableHash(JSON.stringify([projectId, memberId, specKey, attempt]))}`;
8428
8736
 
8429
- // src/domain/execution.ts
8430
- function goalExecution(goal) {
8431
- return {
8432
- leadMemberId: goal?.leadMemberId ?? null,
8433
- members: goal === null ? [] : [...goal.threads, ...goal.remoteMembers ?? []]
8434
- };
8435
- }
8436
- function findGoalMember(members, identity2) {
8437
- return members.find(
8438
- (member) => "threadId" in identity2 ? "threadId" in member && member.threadId === identity2.threadId : "principalId" in member && member.principalId === identity2.principalId
8439
- );
8440
- }
8441
-
8442
- // src/domain/recipient.ts
8443
- var recipientOf = (principal) => principal.kind === "agent" && principal.threadId !== void 0 ? { threadId: principal.threadId } : principal.kind === "remote-agent" && principal.principalId !== void 0 ? { principalId: principal.principalId } : void 0;
8444
- var recipientKey = (who) => "threadId" in who ? `thread:${who.threadId}` : `principal:${who.principalId}`;
8445
-
8446
- // src/domain/binding.ts
8447
- var MemberBoundFact = Struct({
8448
- version: Literal2(1),
8449
- projectId: String4,
8450
- memberId: String4,
8451
- specKey: String4,
8452
- goalId: String4,
8453
- threadId: optionalKey2(String4),
8454
- principalId: optionalKey2(String4),
8455
- replaces: optionalKey2(String4)
8456
- }).check(
8457
- makeFilter2((fact) => fact.threadId === void 0 !== (fact.principalId === void 0))
8458
- );
8459
- var MemberBoundEnvelope = factEnvelope("member-bound", MemberBoundFact);
8460
- var bindingOfFact = (fact) => fact.threadId !== void 0 ? { threadId: fact.threadId } : { principalId: fact.principalId };
8461
- function bindingsOf(goal) {
8462
- const bindings = {};
8463
- for (const member of goalExecution(goal).members)
8464
- bindings[member.memberId] = "threadId" in member ? { threadId: member.threadId } : { principalId: member.principalId };
8465
- return bindings;
8466
- }
8467
- function withBoundBinding(bindings, fact) {
8468
- const next = { ...bindings };
8469
- if (fact.replaces !== void 0) delete next[fact.replaces];
8470
- next[fact.memberId] = bindingOfFact(fact);
8471
- return next;
8472
- }
8473
- var leadAfterBinding = (leadMemberId, fact) => fact.replaces !== void 0 && leadMemberId === fact.replaces ? fact.memberId : leadMemberId;
8474
- function withBoundMember(goal, fact) {
8475
- if (fact.projectId !== goal.projectId || fact.goalId !== goal.goalId) return goal;
8476
- const { remoteMembers: _before, ...rest } = goal;
8477
- const superseded = (memberId) => memberId === fact.memberId || memberId === fact.replaces;
8478
- const threads = goal.threads.filter((row) => !superseded(row.memberId));
8479
- const remoteMembers = (goal.remoteMembers ?? []).filter((row) => !superseded(row.memberId));
8480
- const binding = bindingOfFact(fact);
8481
- const next = "threadId" in binding ? {
8482
- threads: [...threads, { memberId: fact.memberId, threadId: binding.threadId }],
8483
- remoteMembers
8484
- } : {
8485
- threads,
8486
- remoteMembers: [
8487
- ...remoteMembers,
8488
- { memberId: fact.memberId, principalId: binding.principalId }
8489
- ]
8490
- };
8491
- return {
8492
- ...rest,
8493
- leadMemberId: leadAfterBinding(goal.leadMemberId, fact),
8494
- threads: next.threads,
8495
- ...next.remoteMembers.length === 0 ? {} : { remoteMembers: next.remoteMembers }
8496
- };
8497
- }
8498
- function targetOf(bindings, assignee, pinned) {
8499
- if (assignee.kind !== "member") return recipientOf(assignee);
8500
- const { memberId } = assignee;
8501
- if (memberId === void 0) return void 0;
8502
- const fixed = pinned !== void 0 && Object.hasOwn(pinned, memberId) ? pinned[memberId] : void 0;
8503
- if (fixed !== void 0) return { threadId: fixed };
8504
- return bindings !== void 0 && Object.hasOwn(bindings, memberId) ? bindings[memberId] : void 0;
8505
- }
8506
- function assignedToGoalMember(goal, assignees) {
8507
- const execution = goalExecution(goal);
8508
- const members = execution.members.filter((member) => member.memberId !== execution.leadMemberId);
8509
- const bindings = bindingsOf(goal);
8510
- return assignees.some((assignee) => {
8511
- const who = targetOf(bindings, assignee);
8512
- return who !== void 0 && findGoalMember(members, who) !== void 0;
8513
- });
8514
- }
8515
-
8516
8737
  // src/domain/defaultModel.ts
8517
8738
  var isSelectionUnavailable = isTagged("ProviderSelectionError");
8518
8739
  var MODEL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
@@ -8618,7 +8839,7 @@ var en_default = {
8618
8839
  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.",
8619
8840
  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.`,
8620
8841
  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.",
8621
- 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.",
8842
+ 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; imported for a member moved in from another machine that has not run a trial on this home machine yet, which takes no work until its trial run is retried or its model changes; 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.",
8622
8843
  noProject: "This call is not tied to a project, so there is no team to open or change.",
8623
8844
  notLocal: "Only a thread on this machine can open a team.",
8624
8845
  invalidInput: "Check the arguments: requestId is 1-64 letters, digits, underscores or hyphens; name is 1-80 characters; goal is 1-4000 characters; leadName, if given, is 1-40 characters.",
@@ -8846,6 +9067,8 @@ var en_default = {
8846
9067
  remoteVerified: "Verified on its machine",
8847
9068
  invoked: "Session already running, no trial needed",
8848
9069
  pending: "Trial run pending",
9070
+ imported: "Moved in from another machine",
9071
+ importedNote: "Moved in from an older copy on another machine and has not run a trial on this home machine yet. It takes no work until you retry the trial run or change its model.",
8849
9072
  running: "Trial run in progress",
8850
9073
  sent: "Trial run sent",
8851
9074
  failed: "Trial run failed",
@@ -9049,11 +9272,11 @@ function handbookMessage(key, release) {
9049
9272
  var handbookReminder = (release, toLead) => toLead ? handbookMessage("reminder", release) : `${handbookMessage("reminder", release)} ${handbookMessage("memberHold")}`;
9050
9273
 
9051
9274
  // src/domain/leadBrief.ts
9052
- var PERSON_MESSAGE_RULE = "Send a message to the person only for a product decision you cannot make yourself; put progress, updates and technical problems in work item comments with work_post_comment instead.";
9275
+ var PERSON_MESSAGE_RULE = "Send a message to the person only for a product decision you cannot make yourself; put progress, updates and technical problems on the work item with send_message (to: { workItemId }) instead.";
9053
9276
  var MEMBER_CHECKS_RULE = "Before you mark an item done, run the checks that this project's rules name for the code you changed, and fix every failure. Do not mark an item done while a check still fails; say in a work item comment what still fails instead.";
9054
9277
  var NO_STASH = "Do not use git stash: all worktrees of this repository share one stash stack.";
9055
9278
  var MEMBER_NO_STASH_RULE = `${NO_STASH} To try something you can undo, commit to a temporary branch or copy files into an ignored folder inside your own worktree, and delete it before you mark the item done.`;
9056
- var MEMBER_ASK_BEFORE_OUTSIDE_RULE = "Before you change dependencies or patches, write outside the project root, or fetch code from the network (git clone, downloads), mention your lead in a work item comment (put them in the mentions parameter of the comment) and wait for an answer.";
9279
+ var MEMBER_ASK_BEFORE_OUTSIDE_RULE = "Before you change dependencies or patches, write outside the project root, or fetch code from the network (git clone, downloads), ask your lead on the work item, the way you would when stuck (see below), and wait for an answer.";
9057
9280
  var MEMBER_READ_RANGES_RULE = "Read files in ranges: find the place with Grep first, then read only the lines you need; read only the relevant section of a skill file.";
9058
9281
  var LEAD_ACCEPT_RULE = `When you check a finished item, run the checks that this project's rules name yourself. Send the item back if its changes touch patches/ or a lockfile, unless the item has a comment from you approving that change. ${NO_STASH} To compare against the base, run the same check in your own working directory on the base branch and compare the error counts; do not stash in the member's worktree.`;
9059
9282
  var PROGRESS_CHECKIN_MINUTES = 20;
@@ -9061,16 +9284,12 @@ var PROGRESS_CHECKIN_LIMIT = 2;
9061
9284
  var NO_PROGRESS_TURNS = 2;
9062
9285
  var NO_PROGRESS_DELAY_MINUTES = 2;
9063
9286
  var NO_PROGRESS_DELAY_CAP_MINUTES = 30;
9064
- 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.`;
9287
+ 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 send_message (to: { workItemId }). 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.`;
9065
9288
  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.`;
9066
- var memberStuckRule = (leadThreadId) => {
9067
- const mention = leadThreadId === void 0 ? "" : ` that mentions your lead (mentions: [{ "kind": "agent", "threadId": "${leadThreadId}" }])`;
9068
- const reply = leadThreadId === void 0 ? "" : " Your lead will reply or change the plan.";
9069
- return `If the same error still fails after you have tried to fix it twice, stop and post a work item comment with work_post_comment${mention} saying what fails and what you tried.${reply}`;
9070
- };
9289
+ var memberStuckRule = (lead) => lead === void 0 ? "If the same error still fails after you have tried to fix it twice, stop and post on the item with send_message (to: { workItemId }) saying what fails and what you tried." : `If the same error still fails after you have tried to fix it twice, stop and post on the item with send_message (to: { workItemId }, mentions: [{ "memberId": "${lead.memberId}" }]) saying what fails and what you tried, with @${lead.name} in the text. Your lead will reply or change the plan.`;
9071
9290
  var LEAD_STUCK_RULE = "When a member is stuck, answer in that item's comments before you next look in on members: give a concrete direction, split the item, or reassign it. A member is stuck when they mention you because they are stuck, and also when a comment of theirs reports a blocker, such as a test or error they cannot get past, even if it does not mention you. Do not just note it.";
9072
9291
  var LEAD_REPEATED_BLOCKER_RULE = "If, when you look in, a blocker a member reported is still there and their branch has no new commit since your last look-in, do not just ask for a work-in-progress commit: ask what they have tried and which exact line fails, then give a direction, or split or reassign the item.";
9073
- var claimCheckRule = (how) => `Each time you look in on members, also check that every item you assigned has been moved to In Progress by the member it is assigned to, and that no two members are working on the same item; if an item has not been started or is being worked on twice, ask about it in its comments or reassign it. For each member whose worktree you can read on this machine, also run git status and git log there: if it has uncommitted changes, or commits newer than the last item they delivered, while none of their items is In Progress or waiting for your review, post a comment with work_post_comment that mentions them on the item they are assigned, asking which item they are working on and telling them to ${how} before they change anything else.`;
9292
+ var claimCheckRule = (how) => `Each time you look in on members, also check that every item you assigned has been moved to In Progress by the member it is assigned to, and that no two members are working on the same item; if an item has not been started or is being worked on twice, ask about it in its comments or reassign it. For each member whose worktree you can read on this machine, also run git status and git log there: if it has uncommitted changes, or commits newer than the last item they delivered, while none of their items is In Progress or waiting for your review, post on the item they are assigned with send_message (to: { workItemId }), with @their name in the text and their memberId in mentions, asking which item they are working on and telling them to ${how} before they change anything else.`;
9074
9293
  var LEAD_CLAIM_CHECK_RULE = claimCheckRule("claim it with work_claim_item");
9075
9294
  var LEAD_START_CHECK_RULE = claimCheckRule(
9076
9295
  "move it to In Progress with work_update_item (do not claim it)"
@@ -9079,8 +9298,8 @@ var LEAD_SCHEDULE_CHECKIN_RULE = "Before you end a turn while any item of this g
9079
9298
  var LEAD_SPLIT_RULE = "Use work_create_item to split the goal into a few work items: one item per task, with a clear action in the title. Members do not see this conversation or your goal, so put everything a member needs into the description: the deliverable, the constraints, and how to hand the work in. Create them without assignees.";
9080
9299
  var LEAD_OWN_ITEM_RULE = "If a work item for this goal is assigned to you, also record it as blocked by every item you create. Each time a member marks an item done you will be told, so check it then; when they are all done, mark that item done with work_update_item.";
9081
9300
  var LEAD_REBALANCE_RULE = "When a member has nothing in progress while another member has an item waiting in line that is not blocked, move one waiting item to the idle member with work_update_item.";
9082
- var LEAD_CHECKPOINT_RULE = `Members commit and post a one-line progress comment each time they reach a step (a group of tests turns green, a file passes its typecheck, before they change approach, before they stop to wait for someone), and the team plugin mentions a member on an item in progress after ${PROGRESS_CHECKIN_MINUTES} minutes with no progress from them, up to ${PROGRESS_CHECKIN_LIMIT} times in a row. Each time you look in on members, check each item in progress: if the plugin has asked the member and there has been no answer for ${PROGRESS_CHECKIN_LIMIT * PROGRESS_CHECKIN_MINUTES} minutes since its first ask (a member on another machine that has gone offline is asked only once), or the member keeps posting progress but their branch has had no new commit for more than 30 minutes, post a comment with work_post_comment, mentioning the member in its mentions parameter, that asks them to run the tests and typecheck for what they have changed so far, commit the work in progress to their branch, and post a one-line progress and blocker comment on the item. Take the times from work_history and, when you can read the member's worktree on this machine, from git log -1 --format=%cI there, and compare them with the current time; do not estimate. When you cannot read their worktree, as with a remote member, judge by work_history and comments alone; not being able to see commits does not mean there are none.`;
9083
- var LEAD_SEND_BACK_RULE = 'If a finished item is not acceptable, send it back: use work_update_item to set its state back to an open one (see work_list_states), and change its assignees too if someone else should redo it. Then say what is wrong in a comment with work_post_comment, mentioning the member in its mentions parameter (for a local member: { "kind": "agent", "threadId": <their threadId> }); that is what wakes them.';
9301
+ var LEAD_CHECKPOINT_RULE = `Members commit and post a one-line progress comment each time they reach a step (a group of tests turns green, a file passes its typecheck, before they change approach, before they stop to wait for someone), and the team plugin mentions a member on an item in progress after ${PROGRESS_CHECKIN_MINUTES} minutes with no progress from them, up to ${PROGRESS_CHECKIN_LIMIT} times in a row. Each time you look in on members, check each item in progress: if the plugin has asked the member and there has been no answer for ${PROGRESS_CHECKIN_LIMIT * PROGRESS_CHECKIN_MINUTES} minutes since its first ask (a member on another machine that has gone offline is asked only once), or the member keeps posting progress but their branch has had no new commit for more than 30 minutes, post on the item with send_message (to: { workItemId }), with @their name in the text and their memberId in mentions, that asks them to run the tests and typecheck for what they have changed so far, commit the work in progress to their branch, and post a one-line progress and blocker comment on the item. Take the times from work_history and, when you can read the member's worktree on this machine, from git log -1 --format=%cI there, and compare them with the current time; do not estimate. When you cannot read their worktree, as with a remote member, judge by work_history and comments alone; not being able to see commits does not mean there are none.`;
9302
+ var LEAD_SEND_BACK_RULE = 'If a finished item is not acceptable, send it back: use work_update_item to set its state back to an open one (see work_list_states), and change its assignees too if someone else should redo it. Then say what is wrong on the item with send_message (to: { workItemId }), with @their name in the text and mentions: [{ "memberId": <their memberId> }]; that is what wakes them.';
9084
9303
  var LEAD_NO_MEMBER_TASKS = "Do not do members' tasks yourself, and never assign an item you create to yourself: merging, pushing and integrating the work are member tasks too.";
9085
9304
  var tableCell = (value) => value.replace(/\|/g, "\\|").replace(/[\r\n]/g, " ");
9086
9305
  var ASSIGN_ORDER_RULE = "Assign work to members with no item in progress first; do not give one member two items while another is idle. An item assigned to a local member who already has work waits in line and wakes them after their current item is finished.";
@@ -9143,14 +9362,14 @@ function leadBrief(goal, roster, options = {}) {
9143
9362
 
9144
9363
  // src/domain/goalService.ts
9145
9364
  var decodeInput = decodeUnknownOption2(StartGoalInput);
9146
- var decodeEnvelope = decodeUnknownOption2(
9365
+ var decodeEnvelope2 = decodeUnknownOption2(
9147
9366
  Struct({
9148
9367
  pluginId: Literal2("team"),
9149
9368
  name: Literal2("team/goal-started"),
9150
9369
  data: GoalStartedFact
9151
9370
  })
9152
9371
  );
9153
- var decodeGoalFact = (payload) => map(decodeEnvelope(payload), (fact) => fact.data.goal);
9372
+ var decodeGoalFact = (payload) => map(decodeEnvelope2(payload), (fact) => fact.data.goal);
9154
9373
  var decodeProjectGoalFact = (payload) => filter(decodeGoalFact(payload), isProjectGoal);
9155
9374
  var decodeLineGoalFact = (payload) => filter(decodeGoalFact(payload), (goal) => !isProjectGoal(goal));
9156
9375
  var decodeBoundEnvelope = decodeUnknownOption2(MemberBoundEnvelope);
@@ -10233,7 +10452,41 @@ var currentOf = (state, fact, attempt) => {
10233
10452
  return record2 !== null && !record2.removed && record2.specKey === fact.specKey && record2.attempt === attempt ? record2 : null;
10234
10453
  };
10235
10454
  var isTerminal = (phase) => phase === "passed" || phase === "failed" || phase === "overridden";
10455
+ function foldImportedMemberEvent(state, event) {
10456
+ if (event.type === "member.created") {
10457
+ const created = decodeCreated(event.payload);
10458
+ if (isNone2(created) || created.value.kind !== "agent") return state;
10459
+ const { projectId, memberId, agent } = created.value;
10460
+ const spec = specOfMember({ agent });
10461
+ const previous = recordOf(state, projectId, memberId);
10462
+ return put(state, {
10463
+ ...triggered(
10464
+ { projectId, memberId, removed: false, spec, specKey: specKeyOf(spec) },
10465
+ (previous?.attempt ?? 0) + 1,
10466
+ null
10467
+ ),
10468
+ phase: "imported"
10469
+ });
10470
+ }
10471
+ if (event.type === "member.updated") {
10472
+ const updated = decodeUpdated(event.payload);
10473
+ if (isNone2(updated) || updated.value.agent === void 0) return state;
10474
+ const record3 = recordOf(state, updated.value.projectId, updated.value.memberId);
10475
+ if (record3 === null) return state;
10476
+ const spec = {
10477
+ environmentId: updated.value.agent.environmentId,
10478
+ modelSelection: updated.value.agent.modelSelection
10479
+ };
10480
+ return put(state, { ...record3, spec, specKey: specKeyOf(spec) });
10481
+ }
10482
+ if (event.type !== "member.removed" && event.type !== "member.restored") return state;
10483
+ const lifecycle = decodeLifecycle(event.payload);
10484
+ if (isNone2(lifecycle)) return state;
10485
+ const record2 = recordOf(state, lifecycle.value.projectId, lifecycle.value.memberId);
10486
+ return record2 === null ? state : put(state, { ...record2, removed: event.type === "member.removed" });
10487
+ }
10236
10488
  function foldMemberEvent(state, event) {
10489
+ if (event.imported !== void 0) return foldImportedMemberEvent(state, event);
10237
10490
  if (event.type === "member.created") {
10238
10491
  const created = decodeCreated(event.payload);
10239
10492
  if (isNone2(created) || created.value.kind !== "agent") return state;
@@ -10465,7 +10718,8 @@ function trialViewOf(record2) {
10465
10718
  var statusOf = (record2) => record2.phase === "dispatched" ? record2.route === "remote" ? "waiting" : "running" : record2.phase === "started" ? "running" : record2.phase;
10466
10719
  var trialStateDefinition = {
10467
10720
  key: "trials",
10468
- version: 1,
10721
+ // 2:导入搬来的成员记成 `imported`,不再当成待试跑(0111 S5);旧快照丢弃后从事件重折。
10722
+ version: 2,
10469
10723
  events: TRIAL_EVENTS,
10470
10724
  init: emptyTrialState,
10471
10725
  apply: foldTrials
@@ -10663,264 +10917,115 @@ function createMemberWriter(ctx, rosters, queue = createSerial()) {
10663
10917
  const input = decoded.value;
10664
10918
  if (input.avatar !== void 0 && input.clearAvatar === true)
10665
10919
  return rejectMember("updateMember", "invalid-payload");
10666
- let identity2;
10667
- if (input.bindToMe !== void 0) {
10668
- const me = await meOf("updateMember", invocation);
10669
- if ("code" in me) return me;
10670
- const member = await findMember(ctx, input.projectId, input.memberId);
10671
- if (member === null) return rejectMember("updateMember", "not-found");
10672
- const held = personOfMember(member);
10673
- if (held !== null && !samePerson(held, me))
10674
- return rejectMember("updateMember", "bound-to-other");
10675
- identity2 = input.bindToMe ? { kind: "human", principal: me } : null;
10676
- }
10677
- const result2 = await refused(
10678
- "updateMember",
10679
- () => members.update({
10680
- projectId: input.projectId,
10681
- requestId: input.requestId,
10682
- memberId: input.memberId,
10683
- expectedVersion: input.expectedVersion,
10684
- ...input.name === void 0 ? {} : { name: input.name },
10685
- ...input.title === void 0 ? {} : { title: input.title },
10686
- ...input.responsibility === void 0 ? {} : { responsibility: input.responsibility },
10687
- ...input.clearAvatar === true ? { avatar: null } : input.avatar === void 0 ? {} : { avatar: input.avatar },
10688
- ...input.workInstructions === void 0 ? {} : { workInstructions: input.workInstructions },
10689
- ...input.agent === void 0 ? {} : { agent: toEngineAgent(input.agent) },
10690
- ...identity2 === void 0 ? {} : { identity: identity2 }
10691
- })
10692
- );
10693
- return "code" in result2 ? result2 : written(result2);
10694
- });
10695
- const remove = asPerson("removeMember", async (payload, members) => {
10696
- const decoded = decodeRef2(payload);
10697
- if (isNone2(decoded)) return rejectMember("removeMember", "invalid-payload");
10698
- const { projectId, requestId, memberId } = decoded.value;
10699
- const result2 = await refused(
10700
- "removeMember",
10701
- () => members.remove({ projectId, requestId, memberId })
10702
- );
10703
- return "code" in result2 ? result2 : written(result2);
10704
- });
10705
- const restore = asPerson("restoreMember", async (payload, members) => {
10706
- const decoded = decodeRef2(payload);
10707
- if (isNone2(decoded)) return rejectMember("restoreMember", "invalid-payload");
10708
- const { projectId, requestId, memberId } = decoded.value;
10709
- const result2 = await refused(
10710
- "restoreMember",
10711
- () => members.restore({ projectId, requestId, memberId })
10712
- );
10713
- return "code" in result2 ? result2 : written(result2);
10714
- });
10715
- const importLegacy = asPerson("importRoster", async (payload, members) => {
10716
- const decoded = decodeImport(payload);
10717
- if (isNone2(decoded)) return rejectMember("importRoster", "invalid-payload");
10718
- const { projectId } = decoded.value;
10719
- const stored = await rosters.stored(projectId);
10720
- if (stored?.version !== 1) return rejectMember("importRoster", "nothing-to-import");
10721
- const legacy = stored.roster;
10722
- const plan = legacy.members.map((member) => ({
10723
- member,
10724
- memberId: importedMemberId(projectId, member.memberId)
10725
- }));
10726
- const built = await Promise.all(
10727
- plan.map((entry) => findMember(ctx, projectId, entry.memberId))
10728
- );
10729
- const missing2 = plan.filter((_, index) => built[index] === null);
10730
- if (missing2.length > 0) {
10731
- let local;
10732
- if (missing2.some(({ member }) => member.principal === void 0)) {
10733
- const fallback = await defaultAgent(ctx, projectId);
10734
- if ("code" in fallback) return rejectDefault("importRoster", fallback);
10735
- local = fallback;
10736
- }
10737
- const machines = missing2.some(({ member }) => member.principal !== void 0) ? [...(await readMachines(ctx, projectId))?.values() ?? []] : [];
10738
- const remoteAgentOf = (principalId) => {
10739
- const machine = machines.find((entry) => entry.principalId === principalId);
10740
- const provider = machine === void 0 ? void 0 : readyProviders(machine)[0];
10741
- const model = provider?.defaultModel ?? provider?.models[0]?.slug;
10742
- return machine === void 0 || provider === void 0 || model === void 0 ? void 0 : {
10743
- environmentId: machine.environmentId,
10744
- modelSelection: { instanceId: provider.instanceId, model }
10745
- };
10746
- };
10747
- for (const { member, memberId } of missing2) {
10748
- const remote = member.principal === void 0 ? void 0 : remoteAgentOf(member.principal.principalId);
10749
- if (member.principal !== void 0 && remote === void 0)
10750
- return rejectMember("importRoster", "machine-missing", { memberName: member.name });
10751
- const created = await refused(
10752
- "importRoster",
10753
- () => members.create({
10754
- projectId,
10755
- memberId,
10756
- kind: "agent",
10757
- name: member.name,
10758
- ...remote === void 0 ? local : { agent: remote }
10759
- })
10760
- );
10761
- if ("code" in created)
10762
- return rejectMember("importRoster", created.code, { memberName: member.name });
10763
- }
10764
- }
10765
- const adopted = await rosters.adoptImported({
10766
- projectId,
10767
- expectedRevision: legacy.revision,
10768
- leadMemberId: importedMemberId(projectId, legacy.leadMemberId),
10769
- aliases: Object.fromEntries(plan.map((entry) => [entry.member.memberId, entry.memberId]))
10770
- });
10771
- return "code" in adopted ? rejectMember("importRoster", adopted.code) : { revision: adopted.revision, imported: missing2.length };
10772
- });
10773
- return { create, update, remove, restore, importLegacy };
10774
- }
10775
-
10776
- // src/domain/pause.ts
10777
- var LinePausedEnvelope = factEnvelope(
10778
- "line-paused",
10779
- Struct({
10780
- version: Literal2(1),
10781
- status: Literals(["paused", "resumed"]),
10782
- projectId: String4,
10783
- workLineId: String4
10784
- })
10785
- );
10786
- var LineMemberPausedEnvelope = factEnvelope(
10787
- "line-member-paused",
10788
- Struct({
10789
- version: Literal2(1),
10790
- status: Literals(["paused", "resumed"]),
10791
- projectId: String4,
10792
- workLineId: String4,
10793
- memberId: String4
10794
- })
10795
- );
10796
-
10797
- // src/runtime/wakeEvents.ts
10798
- var MemberWokenFact = Struct({
10799
- version: Literal2(1),
10800
- key: String4,
10801
- projectId: String4,
10802
- threadId: optionalKey2(String4),
10803
- principalId: optionalKey2(String4)
10804
- });
10805
- var MemberWorktreeFailedFact = Struct({
10806
- version: Literal2(1),
10807
- projectId: String4,
10808
- threadId: String4,
10809
- reason: String4
10810
- });
10811
- var decodeEnvelope2 = decodeUnknownOption2(
10812
- Union2([
10813
- Struct({
10814
- pluginId: Literal2("team"),
10815
- name: Literal2("team/goal-started"),
10816
- data: GoalStartedFact
10817
- }),
10818
- Struct({
10819
- pluginId: Literal2("team"),
10820
- name: Literal2("team/member-woken"),
10821
- data: MemberWokenFact
10822
- }),
10823
- MemberBoundEnvelope,
10824
- LinePausedEnvelope,
10825
- LineMemberPausedEnvelope,
10826
- Struct({
10827
- pluginId: Literal2("team"),
10828
- name: Literal2("team/member-worktree-failed"),
10829
- data: MemberWorktreeFailedFact
10830
- }),
10831
- Struct({
10832
- pluginId: Literal2("team"),
10833
- name: Literal2("team/member-worktree-reported"),
10834
- data: Struct({
10835
- version: Literal2(1),
10836
- projectId: String4,
10837
- threadId: String4
10838
- })
10839
- })
10840
- ])
10841
- );
10842
- var Principal = Union2([
10843
- Struct({ kind: Literal2("human") }),
10844
- Struct({ kind: Literal2("agent"), threadId: String4 }),
10845
- Struct({ kind: Literal2("remote-agent"), principalId: String4 }),
10846
- Struct({ kind: Literal2("member"), memberId: String4 })
10847
- ]);
10848
- var Actor = Union2([
10849
- Principal,
10850
- Struct({ kind: Literal2("plugin"), pluginId: String4 }),
10851
- Struct({ kind: Literals(["local-cli", "seat", "system"]) })
10852
- ]);
10853
- var Updater = Struct({
10854
- kind: String4,
10855
- threadId: optionalKey2(String4)
10856
- });
10857
- var StateRef = Struct({
10858
- group: String4,
10859
- stateId: optionalKey2(String4)
10860
- });
10861
- var itemFields = { projectId: String4, workItemId: String4 };
10862
- var lineField = { workLineId: optional(NullOr(String4)) };
10863
- var relationFields = {
10864
- ...itemFields,
10865
- relationKind: String4,
10866
- relatedWorkItemId: String4
10867
- };
10868
- var decodeWorkEvent = decodeUnknownOption2(
10869
- Union2([
10870
- Struct({
10871
- type: Literal2("work.item-created"),
10872
- payload: Struct({
10873
- ...itemFields,
10874
- sequenceId: Number5,
10875
- assignees: ArraySchema(Principal),
10876
- state: StateRef,
10877
- ...lineField
10878
- })
10879
- }),
10880
- Struct({
10881
- type: Literal2("work.item-updated"),
10882
- payload: Struct({
10883
- ...itemFields,
10884
- assignees: optional(ArraySchema(Principal)),
10885
- state: optional(StateRef),
10886
- actor: optional(Updater),
10887
- ...lineField
10888
- })
10889
- }),
10890
- Struct({
10891
- type: Literal2("work.item-claimed"),
10892
- payload: Struct({
10893
- ...itemFields,
10894
- assignee: Principal,
10895
- state: optional(StateRef)
10896
- })
10897
- }),
10898
- Struct({
10899
- type: Literal2("work.relation-added"),
10900
- payload: Struct(relationFields)
10901
- }),
10902
- Struct({
10903
- type: Literal2("work.relation-removed"),
10904
- payload: Struct(relationFields)
10905
- }),
10906
- Struct({
10907
- type: Literal2("work.comment-posted"),
10908
- payload: Struct({
10909
- ...itemFields,
10910
- commentId: String4,
10911
- parentAuthor: optional(Actor),
10912
- mentions: ArraySchema(Principal),
10913
- actor: Actor
10920
+ let identity2;
10921
+ if (input.bindToMe !== void 0) {
10922
+ const me = await meOf("updateMember", invocation);
10923
+ if ("code" in me) return me;
10924
+ const member = await findMember(ctx, input.projectId, input.memberId);
10925
+ if (member === null) return rejectMember("updateMember", "not-found");
10926
+ const held = personOfMember(member);
10927
+ if (held !== null && !samePerson(held, me))
10928
+ return rejectMember("updateMember", "bound-to-other");
10929
+ identity2 = input.bindToMe ? { kind: "human", principal: me } : null;
10930
+ }
10931
+ const result2 = await refused(
10932
+ "updateMember",
10933
+ () => members.update({
10934
+ projectId: input.projectId,
10935
+ requestId: input.requestId,
10936
+ memberId: input.memberId,
10937
+ expectedVersion: input.expectedVersion,
10938
+ ...input.name === void 0 ? {} : { name: input.name },
10939
+ ...input.title === void 0 ? {} : { title: input.title },
10940
+ ...input.responsibility === void 0 ? {} : { responsibility: input.responsibility },
10941
+ ...input.clearAvatar === true ? { avatar: null } : input.avatar === void 0 ? {} : { avatar: input.avatar },
10942
+ ...input.workInstructions === void 0 ? {} : { workInstructions: input.workInstructions },
10943
+ ...input.agent === void 0 ? {} : { agent: toEngineAgent(input.agent) },
10944
+ ...identity2 === void 0 ? {} : { identity: identity2 }
10914
10945
  })
10915
- })
10916
- ])
10917
- );
10918
- var agentThreads = (principals) => [
10919
- ...new Set(principals.flatMap((p) => p.kind === "agent" ? [p.threadId] : []))
10920
- ];
10921
- var assigneeMembers = (principals) => [
10922
- ...new Set(principals.flatMap((p) => p.kind === "member" ? [p.memberId] : []))
10923
- ];
10946
+ );
10947
+ return "code" in result2 ? result2 : written(result2);
10948
+ });
10949
+ const remove = asPerson("removeMember", async (payload, members) => {
10950
+ const decoded = decodeRef2(payload);
10951
+ if (isNone2(decoded)) return rejectMember("removeMember", "invalid-payload");
10952
+ const { projectId, requestId, memberId } = decoded.value;
10953
+ const result2 = await refused(
10954
+ "removeMember",
10955
+ () => members.remove({ projectId, requestId, memberId })
10956
+ );
10957
+ return "code" in result2 ? result2 : written(result2);
10958
+ });
10959
+ const restore = asPerson("restoreMember", async (payload, members) => {
10960
+ const decoded = decodeRef2(payload);
10961
+ if (isNone2(decoded)) return rejectMember("restoreMember", "invalid-payload");
10962
+ const { projectId, requestId, memberId } = decoded.value;
10963
+ const result2 = await refused(
10964
+ "restoreMember",
10965
+ () => members.restore({ projectId, requestId, memberId })
10966
+ );
10967
+ return "code" in result2 ? result2 : written(result2);
10968
+ });
10969
+ const importLegacy = asPerson("importRoster", async (payload, members) => {
10970
+ const decoded = decodeImport(payload);
10971
+ if (isNone2(decoded)) return rejectMember("importRoster", "invalid-payload");
10972
+ const { projectId } = decoded.value;
10973
+ const stored = await rosters.stored(projectId);
10974
+ if (stored?.version !== 1) return rejectMember("importRoster", "nothing-to-import");
10975
+ const legacy = stored.roster;
10976
+ const plan = legacy.members.map((member) => ({
10977
+ member,
10978
+ memberId: importedMemberId(projectId, member.memberId)
10979
+ }));
10980
+ const built = await Promise.all(
10981
+ plan.map((entry) => findMember(ctx, projectId, entry.memberId))
10982
+ );
10983
+ const missing2 = plan.filter((_, index) => built[index] === null);
10984
+ if (missing2.length > 0) {
10985
+ let local;
10986
+ if (missing2.some(({ member }) => member.principal === void 0)) {
10987
+ const fallback = await defaultAgent(ctx, projectId);
10988
+ if ("code" in fallback) return rejectDefault("importRoster", fallback);
10989
+ local = fallback;
10990
+ }
10991
+ const machines = missing2.some(({ member }) => member.principal !== void 0) ? [...(await readMachines(ctx, projectId))?.values() ?? []] : [];
10992
+ const remoteAgentOf = (principalId) => {
10993
+ const machine = machines.find((entry) => entry.principalId === principalId);
10994
+ const provider = machine === void 0 ? void 0 : readyProviders(machine)[0];
10995
+ const model = provider?.defaultModel ?? provider?.models[0]?.slug;
10996
+ return machine === void 0 || provider === void 0 || model === void 0 ? void 0 : {
10997
+ environmentId: machine.environmentId,
10998
+ modelSelection: { instanceId: provider.instanceId, model }
10999
+ };
11000
+ };
11001
+ for (const { member, memberId } of missing2) {
11002
+ const remote = member.principal === void 0 ? void 0 : remoteAgentOf(member.principal.principalId);
11003
+ if (member.principal !== void 0 && remote === void 0)
11004
+ return rejectMember("importRoster", "machine-missing", { memberName: member.name });
11005
+ const created = await refused(
11006
+ "importRoster",
11007
+ () => members.create({
11008
+ projectId,
11009
+ memberId,
11010
+ kind: "agent",
11011
+ name: member.name,
11012
+ ...remote === void 0 ? local : { agent: remote }
11013
+ })
11014
+ );
11015
+ if ("code" in created)
11016
+ return rejectMember("importRoster", created.code, { memberName: member.name });
11017
+ }
11018
+ }
11019
+ const adopted = await rosters.adoptImported({
11020
+ projectId,
11021
+ expectedRevision: legacy.revision,
11022
+ leadMemberId: importedMemberId(projectId, legacy.leadMemberId),
11023
+ aliases: Object.fromEntries(plan.map((entry) => [entry.member.memberId, entry.memberId]))
11024
+ });
11025
+ return "code" in adopted ? rejectMember("importRoster", adopted.code) : { revision: adopted.revision, imported: missing2.length };
11026
+ });
11027
+ return { create, update, remove, restore, importLegacy };
11028
+ }
10924
11029
 
10925
11030
  // src/runtime/deliveryPacing.ts
10926
11031
  var pairKey = (a, b) => JSON.stringify([a, b].sort());
@@ -11085,6 +11190,26 @@ var readMemberExecution = async (ctx, threadId, known) => {
11085
11190
  };
11086
11191
  var waitingOnSomeone = (execution) => execution.summary.queuePaused || execution.summary.pendingApprovalCount > 0 || execution.summary.pendingUserInputCount > 0 || (execution.pendingAsyncQuestionCount ?? 0) > 0 || (execution.awaitingPersonReplyCount ?? 0) > 0;
11087
11192
 
11193
+ // src/runtime/importHold.ts
11194
+ var CLOSED_GROUPS = /* @__PURE__ */ new Set(["completed", "cancelled"]);
11195
+ var releasesImportHold = (event, work, beforeGroup) => {
11196
+ if (event.imported !== void 0) return false;
11197
+ if (work.type === "work.item-claimed") return true;
11198
+ const payload = work.payload;
11199
+ return payload.assignees !== void 0 || payload.state !== void 0 && CLOSED_GROUPS.has(beforeGroup) && !CLOSED_GROUPS.has(payload.state.group);
11200
+ };
11201
+ var isImportHeld = (item) => item?.importHeld === true;
11202
+ var holdsAfter = (event, work, item) => item.importHeld === true && !releasesImportHold(event, work, item.stateGroup);
11203
+ var withStateOnly = (item, state) => state === void 0 ? item : {
11204
+ ...item,
11205
+ stateGroup: state.group,
11206
+ ...state.stateId === void 0 ? {} : { stateId: state.stateId }
11207
+ };
11208
+ var withImportHold = (item, keep) => {
11209
+ const { importHeld: _held, ...rest } = item;
11210
+ return keep ? { ...rest, importHeld: true } : rest;
11211
+ };
11212
+
11088
11213
  // src/runtime/wakeQueries.ts
11089
11214
  function memberWorktreeFor(goals, project2, projectId, recipient) {
11090
11215
  if (!("threadId" in recipient) || project2 === void 0) return;
@@ -11113,7 +11238,8 @@ var isAssignedOpen = (project2, workItemId, threadId) => {
11113
11238
  const item = readFact(project2.items, workItemId);
11114
11239
  return item !== null && item !== void 0 && !isClosed(item) && item.assigneeThreads.includes(threadId);
11115
11240
  };
11116
- var isWorkable = (project2, workItemId) => !isClosed(readFact(project2.items, workItemId)) && !hasOpenBlocker(project2, workItemId);
11241
+ var isWorkable = (project2, workItemId) => !isClosed(readFact(project2.items, workItemId)) && !isImportHeld(readFact(project2.items, workItemId)) && !hasOpenBlocker(project2, workItemId);
11242
+ var isStartedFor = (item, threadId) => item.stateGroup === "started" && !isImportHeld(item) && item.assigneeThreads.includes(threadId);
11117
11243
  var isOpenWorkFor = (project2, workItemId, threadId) => isAssignedOpen(project2, workItemId, threadId) && !hasOpenBlocker(project2, workItemId);
11118
11244
  var isHandedOver = (item, threadId) => {
11119
11245
  if (item.stateGroup === "started") return true;
@@ -11140,7 +11266,7 @@ var memberLookup = (project2) => {
11140
11266
  };
11141
11267
  var isMember = (project2, recipient) => "threadId" in recipient ? isGoalThread(project2, recipient.threadId) || hasPinnedOpenItem(project2, recipient.threadId) : isRemoteMember2(project2, recipient.principalId);
11142
11268
  var isQueuedUnclaimed = (item, threadId) => item.wakeStatus?.[threadId] === "pending" && !item.claimedBy.includes(threadId);
11143
- var isDeferredWake = (project2, item, threadId) => isGoalThread(project2, threadId) && !isLeadThread(project2, threadId) && item.assigneeThreads.includes(threadId) && isQueuedUnclaimed(item, threadId) && !isClosed(item);
11269
+ var isDeferredWake = (project2, item, threadId) => isGoalThread(project2, threadId) && !isLeadThread(project2, threadId) && item.assigneeThreads.includes(threadId) && isQueuedUnclaimed(item, threadId) && !isClosed(item) && !isImportHeld(item);
11144
11270
  function countDeferredWakes(project2, threadId) {
11145
11271
  let count2 = 0;
11146
11272
  for (const workItemId in project2.items) {
@@ -11242,7 +11368,8 @@ var isLiveReview = (project2, review) => {
11242
11368
  const lead = reviewLead(review);
11243
11369
  const item = readFact(project2.items, review.workItemId);
11244
11370
  const stillLead = "threadId" in lead ? isLeadThread(project2, lead.threadId) : sameLead(leadRecipientOf(scopeForLine(project2, item?.workLineId)), lead);
11245
- return stillLead && item?.stateGroup === "completed" && (openLeadItemsBlockedBy(project2, review.workItemId, lead).length > 0 || hasOpenTeamGoal(project2, review));
11371
+ return stillLead && item?.stateGroup === "completed" && // 被账本导入按住的件不出核收(规则乙)。
11372
+ !isImportHeld(item) && (openLeadItemsBlockedBy(project2, review.workItemId, lead).length > 0 || hasOpenTeamGoal(project2, review));
11246
11373
  };
11247
11374
  var isReviewDue = (project2, key) => project2.pendingReviews?.some((review) => review.key === key && isLiveReview(project2, review)) === true;
11248
11375
  var dueReviews = (project2) => (project2.pendingReviews ?? []).filter((review) => isLiveReview(project2, review)).map((review) => {
@@ -11308,9 +11435,12 @@ var itemWakeCandidate = (projectId, project2, workItemId, item, threadId, woken,
11308
11435
  sequenceId: item.sequenceId,
11309
11436
  ...memberId === void 0 ? {} : { memberId },
11310
11437
  // 成员的叫醒话里点名负责人(卡住时找谁);带队自己和解挡续做不带。
11311
- ...lead ? { lead: true } : finishing || leadThreadId === void 0 ? {} : {
11312
- leadThreadId,
11313
- ...room === void 0 || room === leadThreadId ? {} : { roomThreadId: room }
11438
+ ...lead ? { lead: true } : finishing ? {} : {
11439
+ ...leadThreadId === void 0 ? {} : {
11440
+ leadThreadId,
11441
+ ...room === void 0 || room === leadThreadId ? {} : { roomThreadId: room }
11442
+ },
11443
+ ...scope2?.leadMemberId === void 0 ? {} : { leadMemberId: scope2.leadMemberId }
11314
11444
  }
11315
11445
  };
11316
11446
  };
@@ -11414,6 +11544,11 @@ function teamItemDecision(project2, projectId, workItemId, threadId) {
11414
11544
  const item = readFact(project2.items, workItemId);
11415
11545
  if (item === null) return { kind: "held", reason: "the team has not seen this work item yet" };
11416
11546
  if (isClosed(item)) return { kind: "held", reason: "the work item is closed" };
11547
+ if (isImportHeld(item))
11548
+ return {
11549
+ kind: "held",
11550
+ reason: "the work item moved in from another machine and the home has not reassigned it yet"
11551
+ };
11417
11552
  if (hasOpenBlocker(project2, workItemId))
11418
11553
  return { kind: "held", reason: "the work item is blocked by unfinished work items" };
11419
11554
  if (isThreadGated(project2, threadId))
@@ -11889,7 +12024,7 @@ function startMemberRemovalRuntime(ctx, goals, wakes) {
11889
12024
  const member = await findMember(ctx, projectId, memberId);
11890
12025
  if (member === null || member.removedAt === null) return;
11891
12026
  const open = Object.entries(project2.items).filter(
11892
- ([, item]) => !isClosed(item) && item.assigneeMembers?.includes(memberId) === true
12027
+ ([, item]) => !isClosed(item) && !isImportHeld(item) && item.assigneeMembers?.includes(memberId) === true
11893
12028
  );
11894
12029
  const taken = open.filter(([, item]) => notYetHandedOver(item, memberId));
11895
12030
  if (taken.length === 0) return;
@@ -12200,9 +12335,7 @@ function foldRecovery(state, event, previous) {
12200
12335
  const succeeded = (session.status === "ready" || session.status === "idle") && member.status === "running";
12201
12336
  const failed = session.status === "error" && turnId !== null;
12202
12337
  if (member.status === session.status && member.turnId === turnId && !failed) return state;
12203
- const hasStarted = Object.values(project2.items).some(
12204
- (item) => item.stateGroup === "started" && item.assigneeThreads.includes(threadId)
12205
- );
12338
+ const hasStarted = Object.values(project2.items).some((item) => isStartedFor(item, threadId));
12206
12339
  const hasOpenWork = Object.keys(project2.items).some(
12207
12340
  (id) => isOpenWorkFor(project2, id, threadId)
12208
12341
  );
@@ -12240,7 +12373,7 @@ function foldRecovery(state, event, previous) {
12240
12373
  };
12241
12374
  }
12242
12375
  }
12243
- if (event.type === "work.item-updated" || event.type === "work.item-claimed" || event.type === "work.comment-posted") {
12376
+ if (event.imported === void 0 && (event.type === "work.item-updated" || event.type === "work.item-claimed" || event.type === "work.comment-posted")) {
12244
12377
  const decoded = decodeWork(event.payload);
12245
12378
  if (isNone2(decoded)) return state;
12246
12379
  const work = decoded.value;
@@ -12261,7 +12394,7 @@ function foldRecovery(state, event, previous) {
12261
12394
  if (pendingAssignees.length === 0) continue;
12262
12395
  const workable = isWorkable(project2, workItemId);
12263
12396
  for (const threadId of pendingAssignees) {
12264
- if (item.stateGroup === "started") startedThreads.add(threadId);
12397
+ if (isStartedFor(item, threadId)) startedThreads.add(threadId);
12265
12398
  if (workable) openWorkThreads.add(threadId);
12266
12399
  }
12267
12400
  }
@@ -12313,11 +12446,12 @@ function dueRecoveries(state, changedThreadId) {
12313
12446
  const stalled = member.pending.kind === "stall";
12314
12447
  if (member.handledTurnIds.includes(member.pending.turnId)) return [];
12315
12448
  const items = Object.entries(project2.items).filter(
12316
- ([workItemId, item]) => (stalled ? item.stateGroup === "started" && item.assigneeThreads.includes(threadId) : isOpenWorkFor(project2, workItemId, threadId) && !isQueuedUnclaimed(item, threadId)) && (!stalled || (member.pending?.plan?.workItemIds.includes(workItemId) || !(member.escalatedItemIds ?? []).includes(workItemId)) && !hasOpenBlocker(project2, workItemId))
12449
+ ([workItemId, item]) => (stalled ? isStartedFor(item, threadId) : isOpenWorkFor(project2, workItemId, threadId) && !isQueuedUnclaimed(item, threadId)) && (!stalled || (member.pending?.plan?.workItemIds.includes(workItemId) || !(member.escalatedItemIds ?? []).includes(workItemId)) && !hasOpenBlocker(project2, workItemId))
12317
12450
  ).map(([workItemId, item]) => ({
12318
12451
  workItemId,
12319
12452
  sequenceId: item.sequenceId,
12320
12453
  lastCommentId: item.lastCommentId,
12454
+ lastCommentFromPost: item.lastCommentFromPost === true,
12321
12455
  waitingForReply: item.lastActionCommentThreadId === threadId
12322
12456
  })).sort((a, b) => a.sequenceId - b.sequenceId);
12323
12457
  const deferredWakeCount = countDeferredWakes(project2, threadId);
@@ -12361,7 +12495,7 @@ var itemHeadline = (sequenceId, item) => {
12361
12495
  return parts.length === 0 ? "" : `${parts.join(" ")} `;
12362
12496
  };
12363
12497
  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.";
12364
- 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}`;
12498
+ var itemText = (workItemId, sequenceId, item, leadThreadId, member, roomThreadId, lead) => `${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(lead)}${roomThreadId === void 0 ? memberGroupRule(leadThreadId) : memberGroupRule(roomThreadId, false)} ${PERSON_MESSAGE_RULE}`;
12365
12499
  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}`;
12366
12500
  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}`;
12367
12501
  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.`;
@@ -12476,6 +12610,75 @@ function foldLineLead(state, event) {
12476
12610
  };
12477
12611
  }
12478
12612
 
12613
+ // src/runtime/lineStopsFold.ts
12614
+ var decodeLineLifecycle = decodeUnknownOption2(
12615
+ Struct({ projectId: String4, workLineId: String4 })
12616
+ );
12617
+ var decodeThreadDeleted = decodeUnknownOption2(Struct({ threadId: String4 }));
12618
+ function foldLineStops(state, event) {
12619
+ if (event.type === "work.line-archived" || event.type === "work.line-restored") {
12620
+ const lifecycle = decodeLineLifecycle(event.payload);
12621
+ if (isNone2(lifecycle)) return state;
12622
+ const { projectId, workLineId } = lifecycle.value;
12623
+ const project2 = readFact(state, projectId);
12624
+ if (project2?.lineScopes?.[workLineId] === void 0) return state;
12625
+ const known = project2.lineStops?.[workLineId];
12626
+ if (event.type === "work.line-archived") {
12627
+ return known === void 0 ? {
12628
+ ...state,
12629
+ [projectId]: {
12630
+ ...project2,
12631
+ lineStops: { ...project2.lineStops, [workLineId]: "archived" }
12632
+ }
12633
+ } : state;
12634
+ }
12635
+ if (known !== "archived") return state;
12636
+ return {
12637
+ ...state,
12638
+ [projectId]: { ...project2, lineStops: without(project2.lineStops ?? {}, workLineId) }
12639
+ };
12640
+ }
12641
+ if (event.type !== "thread.deleted") return state;
12642
+ const deleted = decodeThreadDeleted(event.payload);
12643
+ if (isNone2(deleted)) return state;
12644
+ const next = { ...state };
12645
+ for (const [projectId, project2] of Object.entries(state)) {
12646
+ const lines = Object.entries(project2.lineScopes ?? {}).filter(
12647
+ ([, scope2]) => roomOf(scope2) === deleted.value.threadId
12648
+ );
12649
+ if (lines.length === 0) continue;
12650
+ next[projectId] = {
12651
+ ...project2,
12652
+ lineStops: {
12653
+ ...project2.lineStops,
12654
+ ...Object.fromEntries(lines.map(([workLineId]) => [workLineId, "deleted"]))
12655
+ }
12656
+ };
12657
+ }
12658
+ return next;
12659
+ }
12660
+
12661
+ // src/runtime/removedPostFold.ts
12662
+ function foldRemovedPost(state, removed) {
12663
+ const project2 = readFact(state, removed.projectId);
12664
+ if (project2 === null) return state;
12665
+ const hit = Object.entries(project2.items).filter(
12666
+ ([, item]) => item.lastCommentFromPost === true && item.lastCommentId === removed.postId
12667
+ );
12668
+ if (hit.length === 0) return state;
12669
+ const items = { ...project2.items };
12670
+ for (const [workItemId, item] of hit) {
12671
+ const {
12672
+ lastCommentId: _gone,
12673
+ lastActionCommentThreadId: _author,
12674
+ lastCommentFromPost: _post,
12675
+ ...rest
12676
+ } = item;
12677
+ items[workItemId] = rest;
12678
+ }
12679
+ return { ...state, [removed.projectId]: { ...project2, items } };
12680
+ }
12681
+
12479
12682
  // src/runtime/linePauseFold.ts
12480
12683
  var EnginePause = Struct({
12481
12684
  projectId: String4,
@@ -12532,14 +12735,19 @@ function withPause(project2, change, legacyEventId) {
12532
12735
 
12533
12736
  // src/runtime/wakeState.ts
12534
12737
  var WAKE_STATE_KEY = "wakes";
12535
- var WAKE_STATE_VERSION = 12;
12738
+ var WAKE_STATE_VERSION = 14;
12536
12739
  var WAKE_EVENTS = [
12537
12740
  "work.item-created",
12741
+ "work.item-imported",
12538
12742
  "work.item-updated",
12539
12743
  "work.item-claimed",
12540
12744
  "work.relation-added",
12541
12745
  "work.relation-removed",
12542
12746
  "work.comment-posted",
12747
+ // 工作项上的发言就是这件上的评论(见 `asItemComment`);撤回、删除只为清掉最近一条评论。
12748
+ "communication.post-sent",
12749
+ "communication.post-withdrawn",
12750
+ "communication.post-deleted",
12543
12751
  // 看板把件交到了成员会话上(引擎叫醒了它):当成这一次「你有活」已经叫过,占名额、固定执行者都照旧。
12544
12752
  "work.item-dispatched",
12545
12753
  "plugin.event-appended",
@@ -12661,7 +12869,7 @@ var markBlockedAfterClaim = (project2, workItemId) => ({
12661
12869
  });
12662
12870
  function foldWorkWakes(state, event) {
12663
12871
  if (event.type === "plugin.event-appended") {
12664
- const decoded2 = decodeEnvelope2(event.payload);
12872
+ const decoded2 = decodeEnvelope(event.payload);
12665
12873
  if (isNone2(decoded2)) return state;
12666
12874
  const fact = decoded2.value;
12667
12875
  if (fact.name === "team/goal-started") {
@@ -12761,12 +12969,14 @@ function foldWorkWakes(state, event) {
12761
12969
  const decoded = decodeWorkEvent(event);
12762
12970
  if (isNone2(decoded)) return state;
12763
12971
  const work = decoded.value;
12972
+ if (event.imported !== void 0 && work.type === "work.comment-posted") return state;
12764
12973
  const { projectId, workItemId } = work.payload;
12765
12974
  const project2 = readFact(state, projectId) ?? emptyProject();
12766
12975
  const currentItem = readFact(project2.items, workItemId);
12767
12976
  let next = project2;
12768
12977
  switch (work.type) {
12769
12978
  case "work.item-created":
12979
+ case "work.item-imported":
12770
12980
  next = {
12771
12981
  ...project2,
12772
12982
  items: {
@@ -12792,10 +13002,25 @@ function foldWorkWakes(state, event) {
12792
13002
  }
12793
13003
  };
12794
13004
  next = withoutInitialLeadWake(next, projectId, workItemId);
13005
+ if (event.imported !== void 0)
13006
+ next = {
13007
+ ...next,
13008
+ items: {
13009
+ ...next.items,
13010
+ [workItemId]: { ...readFact(next.items, workItemId), importHeld: true }
13011
+ }
13012
+ };
12795
13013
  break;
12796
13014
  case "work.item-updated":
12797
13015
  case "work.item-claimed": {
12798
13016
  if (currentItem === null) return state;
13017
+ if (event.imported !== void 0 && currentItem.importHeld !== true) {
13018
+ next = {
13019
+ ...project2,
13020
+ items: { ...project2.items, [workItemId]: withStateOnly(currentItem, work.payload.state) }
13021
+ };
13022
+ break;
13023
+ }
12799
13024
  const direct = currentItem.directThreads ?? currentItem.assigneeThreads;
12800
13025
  const assigned = work.type === "work.item-claimed" ? {
12801
13026
  direct: [.../* @__PURE__ */ new Set([...direct, ...agentThreads([work.payload.assignee])])],
@@ -12832,15 +13057,18 @@ function foldWorkWakes(state, event) {
12832
13057
  ...project2,
12833
13058
  items: {
12834
13059
  ...project2.items,
12835
- [workItemId]: {
12836
- ...withoutLine(withoutMembers(currentItem)),
12837
- ...settled,
12838
- ...workLineId === void 0 ? {} : { workLineId },
12839
- claimedBy: [.../* @__PURE__ */ new Set([...currentItem.claimedBy, ...claimants])],
12840
- ...work.payload.state === void 0 ? {} : { stateGroup: work.payload.state.group },
12841
- ...work.payload.state?.stateId === void 0 ? {} : { stateId: work.payload.state.stateId },
12842
- lastActionCommentThreadId: null
12843
- }
13060
+ [workItemId]: withImportHold(
13061
+ {
13062
+ ...withoutLine(withoutMembers(currentItem)),
13063
+ ...settled,
13064
+ ...workLineId === void 0 ? {} : { workLineId },
13065
+ claimedBy: [.../* @__PURE__ */ new Set([...currentItem.claimedBy, ...claimants])],
13066
+ ...work.payload.state === void 0 ? {} : { stateGroup: work.payload.state.group },
13067
+ ...work.payload.state?.stateId === void 0 ? {} : { stateId: work.payload.state.stateId },
13068
+ lastActionCommentThreadId: null
13069
+ },
13070
+ holdsAfter(event, work, currentItem)
13071
+ )
12844
13072
  }
12845
13073
  };
12846
13074
  if (claimants.length > 0 && currentItem.claimedBy.length === 0 && hasOpenBlocker(next, workItemId))
@@ -12862,7 +13090,7 @@ function foldWorkWakes(state, event) {
12862
13090
  [workItemId]: work.type === "work.relation-added" ? [.../* @__PURE__ */ new Set([...blockers, related])] : blockers.filter((blocker) => blocker !== related)
12863
13091
  }
12864
13092
  };
12865
- if (work.type === "work.relation-added" && currentItem !== null && !isClosed(readFact(project2.items, related))) {
13093
+ if (work.type === "work.relation-added" && event.imported === void 0 && currentItem !== null && !isClosed(readFact(project2.items, related))) {
12866
13094
  const woken = new Set(project2.woken);
12867
13095
  const rearms = { ...project2.rearms };
12868
13096
  const wakeStatus = { ...currentItem.wakeStatus };
@@ -12889,15 +13117,18 @@ function foldWorkWakes(state, event) {
12889
13117
  }
12890
13118
  // 评论里 @ 谁、回复谁由引擎投递(提案 0085 切片 3);这里只记最近一条评论,恢复与问进度要用。
12891
13119
  case "work.comment-posted": {
12892
- const { actor, commentId } = work.payload;
13120
+ const { actor, commentId, fromPost } = work.payload;
13121
+ if (currentItem === null) break;
13122
+ const { lastCommentFromPost: _previous, ...item } = currentItem;
12893
13123
  next = {
12894
13124
  ...project2,
12895
- items: currentItem === null ? project2.items : {
13125
+ items: {
12896
13126
  ...project2.items,
12897
13127
  [workItemId]: {
12898
- ...currentItem,
13128
+ ...item,
12899
13129
  lastCommentId: commentId,
12900
- lastActionCommentThreadId: actor.kind === "agent" ? actor.threadId : null
13130
+ lastActionCommentThreadId: actor.kind === "agent" ? actor.threadId : null,
13131
+ ...fromPost === true ? { lastCommentFromPost: true } : {}
12901
13132
  }
12902
13133
  }
12903
13134
  };
@@ -12906,52 +13137,6 @@ function foldWorkWakes(state, event) {
12906
13137
  }
12907
13138
  return { ...state, [projectId]: next };
12908
13139
  }
12909
- var decodeLineLifecycle = decodeUnknownOption2(
12910
- Struct({ projectId: String4, workLineId: String4 })
12911
- );
12912
- var decodeThreadDeleted = decodeUnknownOption2(Struct({ threadId: String4 }));
12913
- function foldLineStops(state, event) {
12914
- if (event.type === "work.line-archived" || event.type === "work.line-restored") {
12915
- const lifecycle = decodeLineLifecycle(event.payload);
12916
- if (isNone2(lifecycle)) return state;
12917
- const { projectId, workLineId } = lifecycle.value;
12918
- const project2 = readFact(state, projectId);
12919
- if (project2?.lineScopes?.[workLineId] === void 0) return state;
12920
- const known = project2.lineStops?.[workLineId];
12921
- if (event.type === "work.line-archived") {
12922
- return known === void 0 ? {
12923
- ...state,
12924
- [projectId]: {
12925
- ...project2,
12926
- lineStops: { ...project2.lineStops, [workLineId]: "archived" }
12927
- }
12928
- } : state;
12929
- }
12930
- if (known !== "archived") return state;
12931
- return {
12932
- ...state,
12933
- [projectId]: { ...project2, lineStops: without(project2.lineStops ?? {}, workLineId) }
12934
- };
12935
- }
12936
- if (event.type !== "thread.deleted") return state;
12937
- const deleted = decodeThreadDeleted(event.payload);
12938
- if (isNone2(deleted)) return state;
12939
- const next = { ...state };
12940
- for (const [projectId, project2] of Object.entries(state)) {
12941
- const lines = Object.entries(project2.lineScopes ?? {}).filter(
12942
- ([, scope2]) => roomOf(scope2) === deleted.value.threadId
12943
- );
12944
- if (lines.length === 0) continue;
12945
- next[projectId] = {
12946
- ...project2,
12947
- lineStops: {
12948
- ...project2.lineStops,
12949
- ...Object.fromEntries(lines.map(([workLineId]) => [workLineId, "deleted"]))
12950
- }
12951
- };
12952
- }
12953
- return next;
12954
- }
12955
13140
  function foldEnginePause(state, event) {
12956
13141
  const change = pauseOfEngineEvent(event);
12957
13142
  if (change === null) return state;
@@ -12959,7 +13144,10 @@ function foldEnginePause(state, event) {
12959
13144
  const next = withPause(project2, change);
12960
13145
  return next === project2 ? state : { ...state, [change.projectId]: next };
12961
13146
  }
12962
- function foldWakes(state, event) {
13147
+ function foldWakes(state, raw) {
13148
+ const removed = removedPost(raw);
13149
+ if (removed !== null) return foldRemovedPost(state, removed);
13150
+ const event = asItemComment(raw);
12963
13151
  if (event.type === "work.line-paused" || event.type === "work.line-resumed")
12964
13152
  return foldEnginePause(state, event);
12965
13153
  if (event.type === "work.line-updated") return foldLineLead(state, event);
@@ -12999,6 +13187,10 @@ function startWakeRuntime(ctx, goals, options = {}) {
12999
13187
  revision: member?.workInstructionsRevision ?? null
13000
13188
  };
13001
13189
  };
13190
+ const readLead = async (projectId, memberId) => {
13191
+ const member = await findMember(ctx, projectId, memberId);
13192
+ return member === null || member === void 0 || member.removedAt !== null ? void 0 : { memberId, name: member.name };
13193
+ };
13002
13194
  const baseText = async (wake, state) => {
13003
13195
  const item = await readItem(wake.projectId, wake.workItemId);
13004
13196
  const title = item?.title;
@@ -13031,7 +13223,8 @@ function startWakeRuntime(ctx, goals, options = {}) {
13031
13223
  item,
13032
13224
  wake.leadThreadId,
13033
13225
  wake.memberId === void 0 ? void 0 : await readMemberBrief(wake.projectId, wake.memberId),
13034
- wake.roomThreadId
13226
+ wake.roomThreadId,
13227
+ wake.leadMemberId === void 0 ? void 0 : await readLead(wake.projectId, wake.leadMemberId)
13035
13228
  );
13036
13229
  return (wake.lead === true ? leadUnblockedText : unblockedText)(
13037
13230
  wake.workItemId,
@@ -13241,18 +13434,19 @@ function startWorktreeSetupRuntime(ctx, deps) {
13241
13434
 
13242
13435
  // src/runtime/recovery.ts
13243
13436
  var itemLabel = (item) => `W${item.sequenceId} (workItemId ${item.workItemId})`;
13437
+ var commentRef = (item) => `message_read refs [{ kind: "${item.lastCommentFromPost ? "post" : "comment"}", id: "${item.lastCommentId ?? ""}" }]`;
13244
13438
  var deferredText = (recovery) => recovery.deferredWakeCount === void 0 ? "" : `They also have ${recovery.deferredWakeCount} assigned ${recovery.deferredWakeCount === 1 ? "item that has" : "items that have"} not been woken yet. `;
13245
13439
  var leadText = (recovery, name, paused) => `Member ${name} (threadId ${recovery.threadId}) ${recovery.afterTurnId === void 0 ? "stopped because of an upstream error" : "could not start a session"} (${recovery.category}). ${recovery.items.map(itemLabel).join(", ")} ${recovery.items.length === 1 ? "is" : "are"} still open. ${deferredText(recovery)}${recovery.alreadyRetried ? "An automatic continuation has already been attempted for this work during these consecutive failures. " : ""}${leadInstructions(paused)}`;
13246
13440
  var commentInstructions = (recovery) => recovery.items.map(
13247
- (item) => item.lastCommentId === void 0 ? `${itemLabel(item)} has no comments yet. Continue from your existing workspace changes and turn history.` : `For ${itemLabel(item)}, the latest comment is commentId ${item.lastCommentId}. Read work_list_comments with workItemId: "${item.workItemId}" and continue from that comment and your existing workspace changes; do not start over.`
13441
+ (item) => item.lastCommentId === void 0 ? `${itemLabel(item)} has no comments yet. Continue from your existing workspace changes and turn history.` : `For ${itemLabel(item)}, the latest comment is ${commentRef(item)}. Read the item's discussion with message_list (workItemId: "${item.workItemId}") and continue from that comment and your existing workspace changes; do not start over.`
13248
13442
  ).join("\n");
13249
- var leadInstructions = (paused = false) => `${paused ? "Their sending is paused; a person needs to click Resume sending. " : ""}You can post a comment with work_post_comment, with the member in its mentions parameter, to ask them to continue (the mention wakes them), reassign the work with work_update_item, or report the problem to the person.${paused ? " A comment will wait until the person resumes sending." : ""}`;
13443
+ var leadInstructions = (paused = false) => `${paused ? "Their sending is paused; a person needs to click Resume sending. " : ""}You can post on the item with send_message (to: { workItemId }), with @their name in the text and their memberId in mentions, to ask them to continue (the mention wakes them), reassign the work with work_update_item, or report the problem to the person.${paused ? " The post will wait until the person resumes sending." : ""}`;
13250
13444
  var resumeText = (recovery) => `Your previous turn was interrupted by an upstream error (${recovery.category}). Continue ${recovery.items.map(itemLabel).join(", ")} from where you stopped.
13251
13445
  ${commentInstructions(recovery)}`;
13252
- var remindText = (recovery) => `Your turn ended normally, but ${recovery.items.map(itemLabel).join(", ")} ${recovery.items.length === 1 ? "is" : "are"} still in progress. If finished, mark the work done with work_update_item. If blocked, explain where you are stuck on the item with work_post_comment. Otherwise continue from where you stopped; do not start over.
13446
+ var remindText = (recovery) => `Your turn ended normally, but ${recovery.items.map(itemLabel).join(", ")} ${recovery.items.length === 1 ? "is" : "are"} still in progress. If finished, mark the work done with work_update_item. If blocked, explain where you are stuck on the item with send_message (to: { workItemId }). Otherwise continue from where you stopped; do not start over.
13253
13447
  ${commentInstructions(recovery)}`;
13254
13448
  var stallLeadText = (recovery, name) => `Member ${name} (threadId ${recovery.threadId}) ended this turn normally, but ${recovery.items.map(itemLabel).join(", ")} ${recovery.items.length === 1 ? "is" : "are"} still open. ${deferredText(recovery)}${recovery.alreadyRetried ? "They have already been reminded once to continue this work, with no progress since. " : ""}${recovery.items.filter((item) => item.waitingForReply).map(
13255
- (item) => `Their last action on ${itemLabel(item)} was their own comment (commentId ${item.lastCommentId}); reply to it or arrange another member to help. `
13449
+ (item) => `Their last action on ${itemLabel(item)} was their own comment (${commentRef(item)}); reply to it or arrange another member to help. `
13256
13450
  ).join("")}${leadInstructions()}`;
13257
13451
  function startRecoveryRuntime(ctx, goals, state, worktrees) {
13258
13452
  let pending = Promise.resolve();
@@ -13444,6 +13638,8 @@ function startRecoveryRuntime(ctx, goals, state, worktrees) {
13444
13638
  "work.item-updated",
13445
13639
  "work.item-claimed",
13446
13640
  "work.comment-posted",
13641
+ // 工作项上的发言就是这件上的评论;挂在会话、人身上的发言不碰恢复(见 handle)。
13642
+ "communication.post-sent",
13447
13643
  "work.relation-added",
13448
13644
  "work.relation-removed",
13449
13645
  "thread.turn-intent-queued",
@@ -13454,7 +13650,7 @@ function startRecoveryRuntime(ctx, goals, state, worktrees) {
13454
13650
  // 线或成员恢复:暂停期间扣下的恢复计划补发。
13455
13651
  "work.line-resumed"
13456
13652
  ],
13457
- handle: (event) => flush(recoveryEventScopeOf(event))
13653
+ handle: (event) => event.type === "communication.post-sent" && asItemComment(event) === event ? Promise.resolve() : flush(recoveryEventScopeOf(event))
13458
13654
  });
13459
13655
  ctx.onDispose(() => {
13460
13656
  disposed = true;
@@ -13489,7 +13685,7 @@ function startLeadCheckinRuntime(ctx, state, goals) {
13489
13685
  (page) => ctx.work.items.list({ projectId, stateGroups: [...OPEN_ITEM_GROUPS], ...page })
13490
13686
  );
13491
13687
  const ownsItem = (item) => goal.workLineId === void 0 ? item.workLineId == null || project2.lineScopes?.[item.workLineId] === void 0 : item.workLineId === goal.workLineId;
13492
- const open = items.filter(ownsItem).filter(
13688
+ const open = items.filter(ownsItem).filter((item) => !isImportHeld(readFact(project2.items, item.workItemId))).filter(
13493
13689
  (item) => item.assignees.length === 0 ? item.createdBy.kind === "agent" && item.createdBy.threadId === threadId : assignedToGoalMember(goal, item.assignees)
13494
13690
  ).map((item) => `${item.workItemId}:${item.revision}`).sort();
13495
13691
  if (open.length === 0) continue;
@@ -13568,7 +13764,8 @@ async function sampleCapacityWait(ctx, ledger, threadId, at) {
13568
13764
 
13569
13765
  // src/runtime/progressCheckin.ts
13570
13766
  var MEMBER_PREFIX = "member:";
13571
- var PROGRESS_CHECKIN_TEXT = `How far along are you on this item? There has been no progress from you here for ${PROGRESS_CHECKIN_MINUTES} minutes. Commit what you have to your branch first (a work-in-progress commit is fine), then reply here with work_post_comment: one line of progress and any blocker.`;
13767
+ var CLOSED_GROUPS2 = /* @__PURE__ */ new Set(["completed", "cancelled"]);
13768
+ var PROGRESS_CHECKIN_TEXT = `How far along are you on this item? There has been no progress from you here for ${PROGRESS_CHECKIN_MINUTES} minutes. Commit what you have to your branch first (a work-in-progress commit is fine), then reply here with send_message (to: { workItemId } of this item, replyTo this post): one line of progress and any blocker.`;
13572
13769
  var TICK_MS = 6e4;
13573
13770
  var assigneeKey = (principal) => {
13574
13771
  if (principal.kind === "member" && principal.memberId !== void 0)
@@ -13580,14 +13777,15 @@ var assigneeKeys = (principals) => principals.flatMap((principal) => {
13580
13777
  const key = assigneeKey(principal);
13581
13778
  return key === void 0 ? [] : [key];
13582
13779
  });
13780
+ var askKey = (who, memberId) => "threadId" in who || memberId === void 0 ? recipientKey(who) : `${recipientKey(who)}#member:${memberId}`;
13583
13781
  var actorKey = (principal) => {
13584
13782
  const who = recipientOf(principal);
13585
- return who === void 0 ? void 0 : recipientKey(who);
13783
+ return who === void 0 ? void 0 : askKey(who, principal.memberId);
13586
13784
  };
13587
13785
  var fresh = (at) => ({ since: at });
13588
13786
  var later = (a, b) => b !== void 0 && Date.parse(b) > Date.parse(a) ? b : a;
13589
13787
  function foldProgress2(state, event) {
13590
- const decoded = decodeWorkEvent(event);
13788
+ const decoded = decodeWorkEvent(asItemComment(event));
13591
13789
  if (Option_exports.isNone(decoded)) return state;
13592
13790
  const work = decoded.value;
13593
13791
  const { projectId, workItemId } = work.payload;
@@ -13596,7 +13794,33 @@ ${workItemId}`;
13596
13794
  const at = event.occurredAt;
13597
13795
  const current = readFact(state, key);
13598
13796
  const put2 = (item) => ({ ...state, [key]: item });
13797
+ if (event.imported !== void 0 && work.type === "work.comment-posted") return state;
13798
+ if (current !== null && current.importHeld !== true && event.imported !== void 0) {
13799
+ const group = "state" in work.payload ? work.payload.state?.group : void 0;
13800
+ return put2({
13801
+ ...current,
13802
+ started: group === void 0 ? current.started : group === "started"
13803
+ });
13804
+ }
13805
+ if (current !== null && current.importHeld === true && work.type !== "work.comment-posted") {
13806
+ const group = "state" in work.payload ? work.payload.state?.group : void 0;
13807
+ const closed = group === void 0 ? current.importClosed === true : CLOSED_GROUPS2.has(group);
13808
+ const assignees = work.type === "work.item-claimed" ? [
13809
+ ...Object.keys(current.members),
13810
+ ...[actorKey(work.payload.assignee)].flatMap((who) => who ?? [])
13811
+ ] : work.type === "work.item-updated" && work.payload.assignees !== void 0 ? assigneeKeys(work.payload.assignees) : Object.keys(current.members);
13812
+ const released = event.imported === void 0 && (work.type === "work.item-claimed" || work.type === "work.item-updated" && (work.payload.assignees !== void 0 || current.importClosed === true && group !== void 0 && !closed));
13813
+ const { importHeld: _held, importClosed: _closed, ...rest } = current;
13814
+ return put2({
13815
+ ...rest,
13816
+ started: group === void 0 ? current.started : group === "started",
13817
+ members: Object.fromEntries(assignees.map((member) => [member, fresh(at)])),
13818
+ ...released ? {} : { importHeld: true },
13819
+ ...!released && closed ? { importClosed: true } : {}
13820
+ });
13821
+ }
13599
13822
  switch (work.type) {
13823
+ case "work.item-imported":
13600
13824
  case "work.item-created": {
13601
13825
  if (isClosed({ stateGroup: work.payload.state.group })) return state;
13602
13826
  return put2({
@@ -13608,7 +13832,8 @@ ${workItemId}`;
13608
13832
  ),
13609
13833
  acted: {},
13610
13834
  asks: {},
13611
- lastCommenter: null
13835
+ lastCommenter: null,
13836
+ ...event.imported === void 0 ? {} : { importHeld: true }
13612
13837
  });
13613
13838
  }
13614
13839
  case "work.item-updated": {
@@ -13672,8 +13897,17 @@ function startProgressCheckinRuntime(ctx, goals, wakes, now3 = factTime) {
13672
13897
  const progress = ctx.derivedState({
13673
13898
  key: "progress-checkin",
13674
13899
  // 3:钟只记起算时间,成员自己的动作与插件的问话另记,指派给项目成员的钟按成员号记(问话时才解析执行者)。
13675
- version: 3,
13676
- events: ["work.item-created", "work.item-updated", "work.item-claimed", "work.comment-posted"],
13900
+ // 4:工作项上的发言当评论折(0112 U6e),已落盘的发言要重折。
13901
+ // 5:迁入的件(账本导入,0111 S5)折进来并按住,导入搬来的改动与评论不推钟。
13902
+ version: 5,
13903
+ events: [
13904
+ "work.item-created",
13905
+ "work.item-imported",
13906
+ "work.item-updated",
13907
+ "work.item-claimed",
13908
+ "work.comment-posted",
13909
+ "communication.post-sent"
13910
+ ],
13677
13911
  init: () => ({}),
13678
13912
  apply: foldProgress2
13679
13913
  });
@@ -13690,26 +13924,31 @@ function startProgressCheckinRuntime(ctx, goals, wakes, now3 = factTime) {
13690
13924
  if (waitingOnSomeone(execution)) return false;
13691
13925
  return !(execution.session.activeTurnId === null && (item.lastCommenter === recipientKey({ threadId }) || execution.summary.queue.length > 0));
13692
13926
  };
13693
- const remoteReady = async (item, principalId) => {
13927
+ const remoteReady = async (item, principalId, memberId) => {
13694
13928
  const pending = await ctx.work.remoteAgentPending.get({
13695
13929
  projectId: item.projectId,
13696
- principalId
13930
+ principalId,
13931
+ ...memberId === void 0 ? {} : { memberId }
13697
13932
  });
13698
13933
  return pending.wakes.count === 0;
13699
13934
  };
13700
13935
  let mountedAt = 0;
13701
- const ask = async (item, who, clock, at) => {
13702
- const identity2 = recipientKey(who);
13703
- const since = later(clock.since, item.acted[identity2]);
13704
- const asked = (item.asks[identity2] ?? []).filter(
13705
- (time) => Date.parse(time) > Date.parse(since)
13936
+ const ask = async (item, who, memberId, clock, at) => {
13937
+ const target = "threadId" in who ? void 0 : who.memberId ?? memberId;
13938
+ const identity2 = askKey(who, target);
13939
+ const machine = recipientKey(who);
13940
+ const sharedAsks = identity2 === machine ? [] : item.asks[machine] ?? [];
13941
+ const since = later(
13942
+ later(clock.since, item.acted[identity2]),
13943
+ identity2 === machine ? void 0 : item.acted[machine]
13706
13944
  );
13945
+ const asked = [...item.asks[identity2] ?? [], ...sharedAsks].filter((time) => Date.parse(time) > Date.parse(since)).toSorted();
13707
13946
  if (asked.length >= PROGRESS_CHECKIN_LIMIT) return;
13708
13947
  const from = Date.parse(asked.at(-1) ?? since);
13709
13948
  const counted = Math.max(from, mountedAt);
13710
13949
  const queued = "threadId" in who ? capacity.waitedWithin(who.threadId, counted, at) : 0;
13711
13950
  if (at - counted - queued < PROGRESS_CHECKIN_MINUTES * 6e4) return;
13712
- const ready = "threadId" in who ? await localReady(item, who.threadId) : await remoteReady(item, who.principalId);
13951
+ const ready = "threadId" in who ? await localReady(item, who.threadId) : await remoteReady(item, who.principalId, target);
13713
13952
  if (!ready) return;
13714
13953
  const key = stableHash(
13715
13954
  `${item.projectId}
@@ -13718,13 +13957,17 @@ ${identity2}
13718
13957
  ${since}
13719
13958
  ${asked.length}`
13720
13959
  );
13721
- await ctx.work.comments.post({
13960
+ await ctx.communication.posts.send({
13722
13961
  projectId: item.projectId,
13723
- workItemId: item.workItemId,
13962
+ to: { workItemId: item.workItemId },
13724
13963
  requestId: `team-progress-checkin:${key}`,
13725
- body: PROGRESS_CHECKIN_TEXT,
13964
+ text: PROGRESS_CHECKIN_TEXT,
13726
13965
  mentions: [
13727
- "threadId" in who ? { kind: "agent", threadId: who.threadId } : { kind: "remote-agent", principalId: who.principalId }
13966
+ "threadId" in who ? { kind: "thread", environmentId: ctx.environment.id, threadId: who.threadId } : {
13967
+ kind: "principal",
13968
+ principalId: who.principalId,
13969
+ ...target === void 0 ? {} : { memberId: target }
13970
+ }
13728
13971
  ]
13729
13972
  });
13730
13973
  };
@@ -13736,7 +13979,9 @@ ${asked.length}`
13736
13979
  );
13737
13980
  const assigneeOf = (wake, item, member, members) => member.startsWith(MEMBER_PREFIX) ? executorOf(wake[item.projectId], item.workItemId, member.slice(MEMBER_PREFIX.length)) : members.get(member);
13738
13981
  const tick = async () => {
13739
- const started = Object.values(await progress.get()).filter((item) => item.started);
13982
+ const started = Object.values(await progress.get()).filter(
13983
+ (item) => item.started && item.importHeld !== true
13984
+ );
13740
13985
  const at = Date.parse(await now3());
13741
13986
  mountedAt = Date.parse(await mounted);
13742
13987
  const wake = await wakes.get();
@@ -13770,7 +14015,8 @@ ${asked.length}`
13770
14015
  continue;
13771
14016
  if ("threadId" in who && !summaries.has(who.threadId))
13772
14017
  summaries.set(who.threadId, await sampleCapacityWait(ctx, capacity, who.threadId, at));
13773
- await ask(item, who, clock, at).catch((error) => {
14018
+ const memberId = member.startsWith(MEMBER_PREFIX) ? member.slice(MEMBER_PREFIX.length) : members.get(member)?.memberId;
14019
+ await ask(item, who, memberId, clock, at).catch((error) => {
13774
14020
  ctx.log.warn("team progress check-in failed", {
13775
14021
  workItemId: item.workItemId,
13776
14022
  member,
@@ -15119,7 +15365,7 @@ function teamLeadBrief(team) {
15119
15365
  handbookMessage("leadBrief"),
15120
15366
  `Team members and their assignment identities${team.room === void 0 ? " (your own conversation is omitted)" : ""}:`,
15121
15367
  table,
15122
- `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.`,
15368
+ `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); trial-imported members moved in from an older copy on another machine and have not run a trial on this home machine, so they take no work until you retry their trial run (team_retry_trial) or change their model (team_update_member); you can see who is ready at any time with team_roster_overview.`,
15123
15369
  `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.`,
15124
15370
  LEAD_SPLIT_RULE,
15125
15371
  'Then use work_add_relation with type "blocked_by" to record dependencies: the dependent workItemId is blocked by the prerequisite relatedWorkItemId.',
@@ -15144,7 +15390,7 @@ function teamLeadBrief(team) {
15144
15390
  LEAD_PROGRESS_SUMMARY_RULE,
15145
15391
  LEAD_SCHEDULE_CHECKIN_RULE,
15146
15392
  LEAD_WORKTREES_KEPT_RULE,
15147
- 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.`,
15393
+ 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 on the work items with send_message (to: { workItemId })." : `The person may speak to you in this conversation, and also in ${home}. Put progress, updates and technical problems on the work items with send_message (to: { workItemId }).`,
15148
15394
  "If the work item tools are unavailable, tell the user directly that this project needs the board and project memory switches turned on first."
15149
15395
  ].join("\n\n");
15150
15396
  }
@@ -15260,7 +15506,7 @@ function statusOf2(trials2, projectId, member) {
15260
15506
  if (member.kind === "human") return "human";
15261
15507
  const view = trialViewOf(recordOf(trials2, projectId, member.memberId));
15262
15508
  if (view === null) return "ready";
15263
- return view.status === "passed" || view.status === "overridden" ? "ready" : view.status === "failed" ? "trial-failed" : "trial-pending";
15509
+ return view.status === "passed" || view.status === "overridden" ? "ready" : view.status === "failed" ? "trial-failed" : view.status === "imported" ? "trial-imported" : "trial-pending";
15264
15510
  }
15265
15511
  function leadMemberName(leadName, title, tag2) {
15266
15512
  if (leadName !== void 0) return withNameTag(leadName, tag2);
@@ -15547,7 +15793,7 @@ function createTeamOverview(ctx, deps) {
15547
15793
  provider: member.agent === null ? null : member.agent.modelSelection.instanceId,
15548
15794
  remote,
15549
15795
  // 人没有试跑;远端成员没有本机试跑记录时读不出对方机器的情况,标明。
15550
- trial: member.kind === "human" ? "none" : trial === null ? remote ? "unverified" : "none" : trial.evidence === "invoked" ? "invoked" : trial.status === "failed" ? "failed" : trial.status === "passed" || trial.status === "overridden" ? "ready" : "pending",
15796
+ trial: member.kind === "human" ? "none" : trial === null ? remote ? "unverified" : "none" : trial.evidence === "invoked" ? "invoked" : trial.status === "failed" ? "failed" : trial.status === "imported" ? "imported" : trial.status === "passed" || trial.status === "overridden" ? "ready" : "pending",
15551
15797
  trialFailure: trial?.failure?.category ?? null,
15552
15798
  teams: teamsOf(member.memberId),
15553
15799
  // 这名成员被暂停的团队:整线暂停,或它在这条线上被单独暂停(ADR-0027:371);读线上的引擎事实。
@@ -16809,7 +17055,7 @@ var zh_CN_default = {
16809
17055
  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",
16810
17056
  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',
16811
17057
  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",
16812
- 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",
17058
+ 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\uFF1Bimported \u662F\u4ECE\u53E6\u4E00\u53F0\u673A\u5668\u8FC1\u5165\u3001\u8FD8\u6CA1\u5728\u8FD9\u53F0\u5BB6\u673A\u5668\u4E0A\u8BD5\u8DD1\u8FC7\u7684\u6210\u5458\uFF0C\u91CD\u65B0\u8BD5\u8DD1\u6216\u6539\u6A21\u578B\u4E4B\u524D\u4E0D\u63A5\u6D3B\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",
16813
17059
  noProject: "\u8FD9\u6B21\u8C03\u7528\u4E0D\u5C5E\u4E8E\u4EFB\u4F55\u9879\u76EE\uFF0C\u6CA1\u6709\u53EF\u5F00\u6216\u53EF\u6539\u7684\u56E2\u961F\u3002",
16814
17060
  notLocal: "\u53EA\u6709\u8FD9\u53F0\u673A\u5668\u4E0A\u7684\u4F1A\u8BDD\u80FD\u5F00\u56E2\u961F\u3002",
16815
17061
  invalidInput: "\u8BF7\u68C0\u67E5\u53C2\u6570\uFF1ArequestId \u662F 1-64 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u6216\u8FDE\u5B57\u7B26\uFF1Bname 1-80 \u5B57\uFF1Bgoal 1-4000 \u5B57\uFF1BleadName \u82E5\u7ED9\u51FA\u4E3A 1-40 \u5B57\u3002",
@@ -17037,6 +17283,8 @@ var zh_CN_default = {
17037
17283
  remoteVerified: "\u5DF2\u5728\u5B83\u7684\u673A\u5668\u4E0A\u9A8C\u8BC1",
17038
17284
  invoked: "\u4F1A\u8BDD\u5DF2\u5728\u8FD0\u884C\uFF0C\u65E0\u9700\u8BD5\u8DD1",
17039
17285
  pending: "\u7B49\u5F85\u8BD5\u8DD1",
17286
+ imported: "\u4ECE\u53E6\u4E00\u53F0\u673A\u5668\u8FC1\u5165",
17287
+ importedNote: "\u4ECE\u53E6\u4E00\u53F0\u673A\u5668\u4E0A\u7684\u65E7\u526F\u672C\u8FC1\u5165\uFF0C\u8FD8\u6CA1\u5728\u8FD9\u53F0\u5BB6\u673A\u5668\u4E0A\u8BD5\u8DD1\u8FC7\u3002\u91CD\u65B0\u8BD5\u8DD1\u6216\u6539\u6A21\u578B\u4E4B\u540E\u624D\u4F1A\u63A5\u6D3B\u3002",
17040
17288
  running: "\u8BD5\u8DD1\u4E2D",
17041
17289
  sent: "\u8BD5\u8DD1\u5DF2\u53D1\u51FA",
17042
17290
  failed: "\u8BD5\u8DD1\u51FA\u9519",
@@ -17352,6 +17600,8 @@ var desiredTrialOf = (view) => {
17352
17600
  return { outcome: "not-run", summary: "Sent to the remote agent" };
17353
17601
  case "running":
17354
17602
  return { outcome: "not-run", summary: "Running" };
17603
+ case "imported":
17604
+ return { outcome: "not-run", summary: "Moved in from another machine, not run here yet" };
17355
17605
  }
17356
17606
  };
17357
17607
  var TRIAL_FACT = /^team\/member-trial-/u;