@tangle-network/agent-app 0.45.58 → 0.45.60

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.
@@ -10,17 +10,17 @@
10
10
  * instead of losing the file silently.
11
11
  *
12
12
  * Storage-parameterized port of gtm-agent's `promote-file-parts.ts` with the
13
- * refactor gtm never made: persistence goes through the injected
14
- * {@link WriteAttachmentFn} (gtm hard-wired its vault writer), the path strategy
15
- * is the injected `buildAttachmentPath` (neutral `uploads/agent/<date>/` default,
16
- * no domain bucket taxonomy baked), the MIME map is an injectable hook, and the
17
- * date segment reads an injectable clock. The idempotent `hash8(id ?? url ??
18
- * filename)` naming is preserved so re-promoting the same source part resolves
19
- * to the same path.
13
+ * refactor gtm never made: persistence goes through an injected stable writer
14
+ * or ownership-safe adapter, the path strategy is the injected
15
+ * `buildAttachmentPath` (neutral `uploads/agent/<date>/` default, no domain
16
+ * bucket taxonomy baked), the MIME map is an injectable hook, and the date
17
+ * segment reads an injectable clock. The logical `hash8(id ?? url ?? filename)`
18
+ * naming is preserved. Atomic callers also receive a fresh ownership suffix so
19
+ * an ambiguous write cannot overwrite an older object.
20
20
  */
21
21
  import { type SandboxExecChannel } from '../sandbox/binary-read';
22
22
  import { type ChatAttachmentKind, type ChatAttachmentPart } from '../chat-store/parts';
23
- import type { WriteAttachmentFn } from './attachment-store';
23
+ import { type AtomicAttachmentWriter, type WriteAttachmentFn } from './attachment-store';
24
24
  /** Default ceiling on a promoted file's raw (pre-encoding) byte size. */
25
25
  export declare const PROMOTE_MAX_FILE_BYTES: number;
26
26
  /** Define the structure for a raw file part with optional metadata and media type information */
@@ -59,8 +59,8 @@ export interface AttachmentPathArgs {
59
59
  }
60
60
  /** Default MIME hook: extension → mime, or `text/plain` for the unknown. */
61
61
  export declare function sniffMimeFromName(filename: string): string;
62
- /** Define options for promoting a part of an agent file within a specific session and scope */
63
- export interface PromoteAgentFilePartOptions {
62
+ type PromoteFilePartLogger = Pick<Console, 'error'>;
63
+ interface PromoteFilePartCommonOptions {
64
64
  raw: RawAgentFilePart;
65
65
  /** The turn's box — required only to promote a sandbox-path part; a `data:`
66
66
  * URI needs none. */
@@ -69,8 +69,6 @@ export interface PromoteAgentFilePartOptions {
69
69
  scopeId: string;
70
70
  /** The turn's session id, used for the sandbox stat/read exec calls. */
71
71
  sessionId: string;
72
- /** REQUIRED store writer — no default (the product owns its store). */
73
- writeAttachment: WriteAttachmentFn;
74
72
  /** Store-path strategy. Default {@link defaultBuildAttachmentPath}. */
75
73
  buildAttachmentPath?: (args: AttachmentPathArgs) => string;
76
74
  /** Raw-byte ceiling. Default {@link PROMOTE_MAX_FILE_BYTES}. */
@@ -79,6 +77,25 @@ export interface PromoteAgentFilePartOptions {
79
77
  sniffMime?: (filename: string) => string;
80
78
  /** Clock for the date path segment. Default `() => new Date()`. */
81
79
  now?: () => Date;
80
+ /** Unique id source for tests or a product's id service. */
81
+ createWriteId?: () => string;
82
+ /** Server-side sink for redacted storage details. */
83
+ logger?: PromoteFilePartLogger;
84
+ }
85
+ /** Stable promotion options from the original writer contract. */
86
+ export interface PromoteAgentFilePartOptions extends PromoteFilePartCommonOptions {
87
+ /** REQUIRED store writer — no default (the product owns its store). */
88
+ writeAttachment: WriteAttachmentFn;
89
+ }
90
+ /** Ownership-safe promotion options for new products. */
91
+ export interface AtomicPromoteAgentFilePartOptions extends PromoteFilePartCommonOptions {
92
+ /** Complete writer + ambiguous-write cleanup adapter. */
93
+ attachmentWriter: AtomicAttachmentWriter;
82
94
  }
83
- /** Promote a part of an agent file with optional byte limits and MIME type detection */
95
+ /** Promote a part using the stable writer contract. */
84
96
  export declare function promoteAgentFilePart(options: PromoteAgentFilePartOptions): Promise<PromoteFilePartResult>;
97
+ /** Promote a part using an ownership-safe writer and cleanup adapter. */
98
+ export declare function promoteAgentFilePart(options: AtomicPromoteAgentFilePartOptions): Promise<PromoteFilePartResult>;
99
+ /** Promote a part when the caller selects the writer contract at runtime. */
100
+ export declare function promoteAgentFilePart(options: PromoteAgentFilePartOptions | AtomicPromoteAgentFilePartOptions): Promise<PromoteFilePartResult>;
101
+ export {};
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runSqliteStatements
3
- } from "../chunk-LRHVCVEW.js";
3
+ } from "../chunk-Q4ZER4HI.js";
4
4
  import {
5
5
  DEFAULT_ATTACHMENT_PROMPT_HEADER,
6
6
  attachmentInputToPart,
@@ -5907,6 +5907,11 @@ function formatModelCost(msg, models) {
5907
5907
  if (!isFinite(cost) || cost <= 0) return null;
5908
5908
  return cost < 0.01 ? `$${cost.toFixed(4)}` : `$${cost.toFixed(2)}`;
5909
5909
  }
5910
+ function reasoningPreview(reasoning) {
5911
+ const flat = reasoning.replace(/\s+/g, " ").trim();
5912
+ if (!flat) return void 0;
5913
+ return flat.length > 120 ? `${flat.slice(0, 119)}\u2026` : flat;
5914
+ }
5910
5915
  function formatTokensPerSecond(msg) {
5911
5916
  if (msg.completionTokens == null || !msg.durationMs) return null;
5912
5917
  return `${Math.round(msg.completionTokens / (msg.durationMs / 1e3))} tok/s`;
@@ -6500,7 +6505,15 @@ function AssistantMessageImpl({
6500
6505
  title: !hasAnswerText ? /* @__PURE__ */ jsxs13("span", { className: "agent-shimmer", "data-motion": "essential", children: [
6501
6506
  "Thinking",
6502
6507
  thinkingSeconds >= 1 ? ` \xB7 ${thinkingSeconds}s` : "\u2026"
6503
- ] }) : thinkMsRef.current != null ? `Thought for ${Math.max(1, Math.round(thinkMsRef.current / 1e3))}s` : "Thought process",
6508
+ ] }) : thinkMsRef.current != null ? (
6509
+ // Words, not the abbreviated unit — "Thought for 4 seconds" reads
6510
+ // like a sentence; "4s" reads like a log line.
6511
+ `Thought for ${(() => {
6512
+ const s = Math.max(1, Math.round(thinkMsRef.current / 1e3));
6513
+ return `${s} second${s === 1 ? "" : "s"}`;
6514
+ })()}`
6515
+ ) : "Thought process",
6516
+ description: hasAnswerText ? reasoningPreview(reasoning) : void 0,
6504
6517
  status: hasAnswerText ? "idle" : "running",
6505
6518
  open: reasoningOpen,
6506
6519
  onOpenChange: (next) => setReasoningToggled(next),
@@ -6508,7 +6521,7 @@ function AssistantMessageImpl({
6508
6521
  "div",
6509
6522
  {
6510
6523
  ref: reasoningScrollRef,
6511
- className: "max-h-48 overflow-y-auto whitespace-pre-wrap px-3 py-2.5 text-xs leading-relaxed text-muted-foreground",
6524
+ className: "max-h-48 overflow-y-auto whitespace-pre-wrap px-3 py-2.5 text-sm leading-relaxed text-muted-foreground",
6512
6525
  children: reasoning
6513
6526
  }
6514
6527
  )
@@ -6838,4 +6851,4 @@ export {
6838
6851
  useThinkingSeconds,
6839
6852
  ChatMessages
6840
6853
  };
6841
- //# sourceMappingURL=chunk-UPXDBHEE.js.map
6854
+ //# sourceMappingURL=chunk-FOXGPGXF.js.map