@agentconnect.md/daemon 1.0.0-rc.147 → 1.0.0-rc.148

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
@@ -9328,7 +9328,7 @@ function splitOn(input, char) {
9328
9328
  function first(input, offset = 0) {
9329
9329
  return isArrayLike(input) && input.length > offset ? input[offset] : void 0;
9330
9330
  }
9331
- function last(input, offset = 0) {
9331
+ function last$1(input, offset = 0) {
9332
9332
  if (isArrayLike(input) && input.length > offset) return input[input.length - 1 - offset];
9333
9333
  }
9334
9334
  function isArrayLike(input) {
@@ -9553,13 +9553,13 @@ function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
9553
9553
  return command;
9554
9554
  }
9555
9555
  function trailingArrayArgument(args) {
9556
- return asStringArray(filterType(last(args, typeof last(args) === "function" ? 1 : 0), filterArray, []));
9556
+ return asStringArray(filterType(last$1(args, typeof last$1(args) === "function" ? 1 : 0), filterArray, []));
9557
9557
  }
9558
9558
  function trailingOptionsArgument(args) {
9559
- return filterType(last(args, filterFunction(last(args)) ? 1 : 0), filterPlainObject);
9559
+ return filterType(last$1(args, filterFunction(last$1(args)) ? 1 : 0), filterPlainObject);
9560
9560
  }
9561
9561
  function trailingFunctionArgument(args, includeNoop = true) {
9562
- const callback = asFunction(last(args));
9562
+ const callback = asFunction(last$1(args));
9563
9563
  return includeNoop || isUserFunction(callback) ? callback : void 0;
9564
9564
  }
9565
9565
  var init_task_options = __esm({ "src/lib/utils/task-options.ts"() {
@@ -9620,7 +9620,7 @@ __export(utils_exports, {
9620
9620
  getTrailingOptions: () => getTrailingOptions,
9621
9621
  including: () => including,
9622
9622
  isUserFunction: () => isUserFunction,
9623
- last: () => last,
9623
+ last: () => last$1,
9624
9624
  objectToString: () => objectToString,
9625
9625
  orVoid: () => orVoid,
9626
9626
  parseStringResponse: () => parseStringResponse,
@@ -9928,7 +9928,7 @@ var init_ConfigList = __esm({ "src/lib/responses/ConfigList.ts"() {
9928
9928
  }
9929
9929
  addFile(file) {
9930
9930
  if (!(file in this.values)) {
9931
- const latest = last(this.files);
9931
+ const latest = last$1(this.files);
9932
9932
  this.values[file] = latest ? Object.create(this.values[latest]) : {};
9933
9933
  this.files.push(file);
9934
9934
  }
@@ -24418,6 +24418,14 @@ var LocalStore = class {
24418
24418
  }
24419
24419
  };
24420
24420
  //#endregion
24421
+ //#region src/store/monotonic-ts.ts
24422
+ let last = 0;
24423
+ function monotonicTs() {
24424
+ const now = Date.now();
24425
+ last = now > last ? now : last + 1;
24426
+ return String(last);
24427
+ }
24428
+ //#endregion
24421
24429
  //#region src/session/attachment-block.ts
24422
24430
  /**
24423
24431
  * Turn one Slack attachment into the richest ACP content block the agent can
@@ -24494,7 +24502,8 @@ var SessionManager = class {
24494
24502
  async handle(agentId, msg) {
24495
24503
  const agent = this.deps.agentById(agentId);
24496
24504
  if (!agent) throw new Error(`unknown agent ${agentId}`);
24497
- const { thread, ts } = transcriptCoords(msg);
24505
+ const { thread, ts: coordTs } = transcriptCoords(msg);
24506
+ const ts = msg.platform === "webchat" ? monotonicTs() : coordTs;
24498
24507
  const key = sessionKey(msg.platform, msg.channel, thread, agentId);
24499
24508
  const mention = attachmentMention(msg.attachments);
24500
24509
  this.deps.store.appendTranscript({
@@ -24555,7 +24564,7 @@ var SessionManager = class {
24555
24564
  this.deps.store.upsertSession(rec);
24556
24565
  }
24557
24566
  }
24558
- if (rec.lastDeliveredTs === null && thread !== ts && this.deps.fetchThreadHistory) {
24567
+ if (rec.lastDeliveredTs === null && thread !== ts && msg.platform !== "webchat" && this.deps.fetchThreadHistory) {
24559
24568
  if (!this.deps.store.transcriptSince(msg.channel, thread, null).some((e) => e.ts === thread)) {
24560
24569
  const history = await this.deps.fetchThreadHistory(agentId, msg.channel, thread);
24561
24570
  for (const h of history) this.deps.store.appendTranscript({
@@ -85124,7 +85133,7 @@ var Daemon = class Daemon {
85124
85133
  if (p.webchat.replyText.trim()) this.store.appendTranscript({
85125
85134
  channel: p.channel,
85126
85135
  thread: statusThread,
85127
- ts: String(Date.now()),
85136
+ ts: monotonicTs(),
85128
85137
  sender: agentId,
85129
85138
  kind: "text",
85130
85139
  text: p.webchat.replyText