@alan-ai-hq/agent-manager 0.1.115 → 0.1.117

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.
Files changed (2) hide show
  1. package/dist/index.cjs +71 -9
  2. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -34932,7 +34932,7 @@ function buildComputerReadiness(input2) {
34932
34932
  }
34933
34933
 
34934
34934
  // src/version.ts
34935
- var AGENT_VERSION = "0.1.115";
34935
+ var AGENT_VERSION = "0.1.117";
34936
34936
 
34937
34937
  // src/daemon/status.ts
34938
34938
  var PENDING_RUN_START_TTL_MS = 10 * 6e4;
@@ -60697,6 +60697,22 @@ function recoverInterruptedRange(options, conversationId, runId) {
60697
60697
  );
60698
60698
  return recovered;
60699
60699
  }
60700
+ function waitUntil(at, signal) {
60701
+ return new Promise((resolve14) => {
60702
+ const done = () => {
60703
+ signal.removeEventListener("abort", done);
60704
+ clearTimeout(timer);
60705
+ resolve14();
60706
+ };
60707
+ const timer = setTimeout(done, Math.max(0, at - Date.now()));
60708
+ signal.addEventListener("abort", done, { once: true });
60709
+ });
60710
+ }
60711
+ function isDelivered(state) {
60712
+ if (!state || state.endOffset === void 0) return true;
60713
+ const size = state.endOffset - state.startOffset;
60714
+ return state.syncedOffset === size && state.finalizedOffset === size;
60715
+ }
60700
60716
  function decodeId(name) {
60701
60717
  try {
60702
60718
  const id = decodeURIComponent(name);
@@ -60772,10 +60788,15 @@ async function replayClosedTranscripts(options) {
60772
60788
  signal: options.signal,
60773
60789
  sandbox: state.sandbox
60774
60790
  };
60791
+ const cooldownUntil = Math.max(state.pushRetryAfter ?? 0, state.liveRetryAfter ?? 0);
60775
60792
  const push2 = startTranscriptPush(target, options.onProblem);
60776
60793
  const live = startTranscriptLive(target, options.onProblem);
60777
60794
  try {
60778
60795
  await Promise.all([push2.flush(), live.flush()]);
60796
+ if (cooldownUntil > Date.now() && !isDelivered(readConversationSyncState(options.configPath, conversationId).runs[runId])) {
60797
+ await waitUntil(cooldownUntil, options.signal);
60798
+ if (!options.signal.aborted) await Promise.all([push2.flush(), live.flush()]);
60799
+ }
60779
60800
  } finally {
60780
60801
  await Promise.all([push2.stop(), live.stop()]);
60781
60802
  }
@@ -61018,6 +61039,8 @@ var RuntimeSkillCoordinator = class {
61018
61039
  }
61019
61040
  async runUnlocked(initialScan, scanRequest) {
61020
61041
  const attemptedDesiredRevisions = /* @__PURE__ */ new Set();
61042
+ const offeredReportIds = /* @__PURE__ */ new Set();
61043
+ const executedCommandIds = /* @__PURE__ */ new Set();
61021
61044
  if (initialScan) {
61022
61045
  this.pendingInventory = await this.scan(initialScan);
61023
61046
  }
@@ -61027,6 +61050,7 @@ var RuntimeSkillCoordinator = class {
61027
61050
  status2.appliedRevision,
61028
61051
  initialScan || this.lastScanInput ? void 0 : scanRequest
61029
61052
  );
61053
+ for (const id of this.pendingReportIds()) offeredReportIds.add(id);
61030
61054
  const response = await this.control.sync(request);
61031
61055
  this.accept(response.acceptedAttemptIds);
61032
61056
  let producedWork = false;
@@ -61036,6 +61060,8 @@ var RuntimeSkillCoordinator = class {
61036
61060
  producedWork = true;
61037
61061
  }
61038
61062
  for (const command of response.commands) {
61063
+ if (executedCommandIds.has(command.commandId)) continue;
61064
+ executedCommandIds.add(command.commandId);
61039
61065
  switch (command.kind) {
61040
61066
  case "scan":
61041
61067
  this.pendingInventory = await this.scan(command.input);
@@ -61077,7 +61103,10 @@ var RuntimeSkillCoordinator = class {
61077
61103
  }
61078
61104
  }
61079
61105
  }
61080
- if (!producedWork && !this.hasPendingReports()) return;
61106
+ if (!producedWork && !this.hasUnofferedReports(offeredReportIds)) {
61107
+ this.discardRefusedReports(offeredReportIds);
61108
+ return;
61109
+ }
61081
61110
  }
61082
61111
  throw new Error("Skill synchronization did not converge after 10 exchanges");
61083
61112
  }
@@ -61116,10 +61145,37 @@ var RuntimeSkillCoordinator = class {
61116
61145
  if (accepted.has(commandId)) this.completedCommandIds.delete(commandId);
61117
61146
  }
61118
61147
  }
61119
- hasPendingReports() {
61120
- return Boolean(
61121
- this.pendingInventory || this.pendingApplied || this.pendingPublished.size > 0 || this.pendingResolvedConflicts.size > 0 || this.completedCommandIds.size > 0
61122
- );
61148
+ pendingReportIds() {
61149
+ return [
61150
+ ...this.pendingInventory ? [this.pendingInventory.attemptId] : [],
61151
+ ...this.pendingApplied ? [this.pendingApplied.attemptId] : [],
61152
+ ...this.pendingPublished.keys(),
61153
+ ...this.pendingResolvedConflicts.keys(),
61154
+ ...this.completedCommandIds
61155
+ ];
61156
+ }
61157
+ hasUnofferedReports(offered) {
61158
+ return this.pendingReportIds().some((id) => !offered.has(id));
61159
+ }
61160
+ /**
61161
+ * A report the server saw and declined to acknowledge will never be
61162
+ * acknowledged: previews and conflict resolutions expire server-side, and a
61163
+ * completed command id stops matching once the context revision it was
61164
+ * derived from moves. Keeping them means every later run re-sends a report
61165
+ * the server always ignores. Inventory and applied results are deliberately
61166
+ * exempt — the server acknowledges those unconditionally, so a miss there
61167
+ * means a genuinely new attempt is still owed.
61168
+ */
61169
+ discardRefusedReports(offered) {
61170
+ for (const commandId of [...this.pendingPublished.keys()]) {
61171
+ if (offered.has(commandId)) this.pendingPublished.delete(commandId);
61172
+ }
61173
+ for (const commandId of [...this.pendingResolvedConflicts.keys()]) {
61174
+ if (offered.has(commandId)) this.pendingResolvedConflicts.delete(commandId);
61175
+ }
61176
+ for (const commandId of [...this.completedCommandIds]) {
61177
+ if (offered.has(commandId)) this.completedCommandIds.delete(commandId);
61178
+ }
61123
61179
  }
61124
61180
  async runExclusively(work) {
61125
61181
  const previous = this.tail;
@@ -62593,7 +62649,7 @@ function ensureProviderCliInstalled(backendKind, options) {
62593
62649
  function joinLines(lines) {
62594
62650
  return lines.join("\n");
62595
62651
  }
62596
- function currentUserSection(user) {
62652
+ function currentUserSection(user, visibility) {
62597
62653
  if (!user) return null;
62598
62654
  const lines = ["# Current User"];
62599
62655
  if (user.name) lines.push(`- **Name**: ${user.name}`);
@@ -62601,7 +62657,7 @@ function currentUserSection(user) {
62601
62657
  lines.push(`- **User ID**: ${user.id}`);
62602
62658
  lines.push("");
62603
62659
  lines.push(
62604
- "This is the person who initiated this conversation. When creating tasks or assigning work, default to assigning to this user unless explicitly instructed otherwise."
62660
+ visibility === "team" ? "This session is shared with the team. When creating tasks or assigning work, create them on this team. The person above started the session." : visibility === "private" ? "This session is private to this person. When creating tasks or assigning work, default to assigning to this user unless explicitly instructed otherwise." : "This is the person who initiated this conversation. When creating tasks or assigning work, default to assigning to this user unless explicitly instructed otherwise."
62605
62661
  );
62606
62662
  return joinLines(lines);
62607
62663
  }
@@ -62732,7 +62788,7 @@ function prototypeSection(owner) {
62732
62788
  function buildPromptContext(config4) {
62733
62789
  const owner = resolveRunOwnership(config4);
62734
62790
  return [
62735
- currentUserSection(config4.currentUser),
62791
+ currentUserSection(config4.currentUser, config4.sessionVisibility),
62736
62792
  taskContextSection(config4.taskMeta),
62737
62793
  pullRequestSection(config4.prMeta),
62738
62794
  artifactIdsSection(owner),
@@ -62952,6 +63008,7 @@ function buildAgentRunConfig(input2) {
62952
63008
  taskId: input2.taskId ?? input2.taskMeta?.id,
62953
63009
  teamId: input2.teamId,
62954
63010
  currentUser: input2.currentUser,
63011
+ sessionVisibility: input2.sessionVisibility,
62955
63012
  workflowTools: input2.workflowTools,
62956
63013
  workflowId: input2.workflowId,
62957
63014
  workflowExecutionId: input2.workflowExecutionId,
@@ -63674,6 +63731,7 @@ async function launchRun(ctx, payload, plan) {
63674
63731
  taskId: payload.taskId,
63675
63732
  teamId: payload.teamId,
63676
63733
  currentUser: payload.currentUser,
63734
+ sessionVisibility: payload.sessionVisibility,
63677
63735
  workflowTools: payload.workflowTools,
63678
63736
  workflowId: payload.workflowId,
63679
63737
  workflowExecutionId: payload.workflowExecutionId,
@@ -69512,6 +69570,7 @@ var WSClient = class {
69512
69570
  conversationId: data.conversationId,
69513
69571
  teamId: data.teamId,
69514
69572
  currentUser: data.currentUser,
69573
+ sessionVisibility: data.sessionVisibility,
69515
69574
  terminalContextRefs: data.terminalContextRefs,
69516
69575
  terminalSnapshots: data.terminalSnapshots,
69517
69576
  externalMcpServers: data.externalMcpServers
@@ -70126,6 +70185,7 @@ function initialTurn(seed) {
70126
70185
  cloudEnvironmentId: void 0,
70127
70186
  teamId: seed.teamId,
70128
70187
  currentUser: seed.currentUser,
70188
+ sessionVisibility: seed.sessionVisibility,
70129
70189
  terminalContextRefs: void 0,
70130
70190
  terminalSnapshots: void 0
70131
70191
  };
@@ -70172,6 +70232,7 @@ function applyUserMessage(turn, patch) {
70172
70232
  taskId: kept(patch.taskId, turn.taskId),
70173
70233
  conversationId: kept(patch.conversationId, turn.conversationId),
70174
70234
  currentUser: kept(patch.currentUser, turn.currentUser),
70235
+ sessionVisibility: kept(patch.sessionVisibility, turn.sessionVisibility),
70175
70236
  teamId: kept(patch.teamId, turn.teamId),
70176
70237
  terminalContextRefs: kept(patch.terminalContextRefs, turn.terminalContextRefs),
70177
70238
  terminalSnapshots: kept(patch.terminalSnapshots, turn.terminalSnapshots)
@@ -70489,6 +70550,7 @@ async function runSandbox(config4) {
70489
70550
  taskId: turn.taskId,
70490
70551
  teamId: turn.teamId,
70491
70552
  currentUser: turn.currentUser,
70553
+ sessionVisibility: turn.sessionVisibility,
70492
70554
  workflowTools: turn.workflowTools,
70493
70555
  workflowId,
70494
70556
  workflowExecutionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alan-ai-hq/agent-manager",
3
- "version": "0.1.115",
3
+ "version": "0.1.117",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "description": "Alan agent runtime — cloud sandbox and local daemon (alan-agent CLI)",
@@ -27,9 +27,9 @@
27
27
  "tsup": "^8.5.1",
28
28
  "tsx": "^4.19.0",
29
29
  "typescript": "~5.9.3",
30
+ "@alan-ai/sandbox-runtime-spec": "0.1.0",
30
31
  "@alan-ai/agent-core": "0.1.0",
31
- "@alan-ai/shared": "0.1.0",
32
- "@alan-ai/sandbox-runtime-spec": "0.1.0"
32
+ "@alan-ai/shared": "0.1.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsup",