@ai-matrx/agents 0.11.3 → 0.12.0

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.
@@ -1,8 +1,58 @@
1
1
  import { B as MatrxTransport, w as MatrxRuntimeOperationEvent, v as MatrxRuntimeExecutionStatus, d as MatrxCancelResponse } from '../operations--f5ko9Su.cjs';
2
- import { Snapshot, Draft } from '@ai-matrx/kit/content-transfer';
2
+ import { PageAction, Payload, Snapshot, Draft, TransferOutcome, TransferTarget } from '@ai-matrx/kit/content-transfer';
3
3
  import { MatrxStreamEnvelope } from '../stream/ndjson.cjs';
4
4
  import '../stream/sse.cjs';
5
5
 
6
+ /** Bind once in a host; every menu and declared surface inherits these actions. */
7
+ type MatrxTransferDestination = "notes" | "scratch" | "document" | "workbook" | "task" | "attach" | "chat" | "assistant" | "tools" | "code";
8
+ interface MatrxTransferContent {
9
+ label: string;
10
+ markdown: string;
11
+ plainText: string;
12
+ payload: Payload;
13
+ snapshot: Snapshot;
14
+ draft: Draft;
15
+ table?: {
16
+ name: string;
17
+ headers: string[];
18
+ rows: string[][];
19
+ };
20
+ signal: AbortSignal;
21
+ }
22
+ type MatrxTransferPorts = Partial<Record<MatrxTransferDestination, (content: MatrxTransferContent) => Promise<TransferOutcome>>>;
23
+ type MatrxTransferAction = PageAction & {
24
+ group: "save" | "chat";
25
+ hint: string;
26
+ /** Only these actions are offered for a manually prepared revision. */
27
+ prepared: true;
28
+ };
29
+ /** Serializes the captured CURRENT revision, never re-reads the host's source. */
30
+ declare function createMatrxTransferActions(ports: MatrxTransferPorts): MatrxTransferAction[];
31
+
32
+ type MatrxTransferIdentity = {
33
+ userId: string;
34
+ organizationId: string;
35
+ };
36
+ type SaveResult = {
37
+ ok: boolean;
38
+ id?: string;
39
+ href?: string;
40
+ error?: string;
41
+ };
42
+ interface MatrxTransferBindings {
43
+ getIdentity(): MatrxTransferIdentity;
44
+ saveNote(content: MatrxTransferContent, folder: string): Promise<TransferTarget>;
45
+ saveDocument(content: MatrxTransferContent): Promise<SaveResult>;
46
+ saveWorkbook(content: MatrxTransferContent): Promise<SaveResult>;
47
+ openNotes(content: MatrxTransferContent): void | Promise<void>;
48
+ openTask(content: MatrxTransferContent): void | Promise<void>;
49
+ openCode(content: MatrxTransferContent): void | Promise<void>;
50
+ openAttachment(target: TransferTarget): void | Promise<void>;
51
+ openChat(content: MatrxTransferContent, mode: "chat" | "assistant" | "tools", identity: MatrxTransferIdentity): void | Promise<void>;
52
+ }
53
+ /** Portable workflow and failure semantics; hosts bind only their concrete services and UI openers. */
54
+ declare function createMatrxTransferPorts(bindings: MatrxTransferBindings): Required<MatrxTransferPorts>;
55
+
6
56
  type MatrxContentTransferStatus = "completed" | "failed" | "cancelled" | "detached" | "unavailable";
7
57
  interface MatrxContentTransferIdentity {
8
58
  requestId: string;
@@ -81,4 +131,4 @@ declare function createMatrxContentTransferAdapter(options: MatrxContentTransfer
81
131
  };
82
132
  type MatrxContentTransferAdapter = ReturnType<typeof createMatrxContentTransferAdapter>;
83
133
 
84
- export { type MatrxContentTransferAdapter, type MatrxContentTransferAdapterOptions, type MatrxContentTransferDbResponse, type MatrxContentTransferDbRow, type MatrxContentTransferIdentity, type MatrxContentTransferLaunchInput, type MatrxContentTransferProgress, type MatrxContentTransferQuery, type MatrxContentTransferResult, type MatrxContentTransferStatus, type MatrxContentTransferSupabase, createMatrxContentTransferAdapter };
134
+ export { type MatrxContentTransferAdapter, type MatrxContentTransferAdapterOptions, type MatrxContentTransferDbResponse, type MatrxContentTransferDbRow, type MatrxContentTransferIdentity, type MatrxContentTransferLaunchInput, type MatrxContentTransferProgress, type MatrxContentTransferQuery, type MatrxContentTransferResult, type MatrxContentTransferStatus, type MatrxContentTransferSupabase, type MatrxTransferAction, type MatrxTransferBindings, type MatrxTransferContent, type MatrxTransferDestination, type MatrxTransferIdentity, type MatrxTransferPorts, createMatrxContentTransferAdapter, createMatrxTransferActions, createMatrxTransferPorts };
@@ -1,8 +1,58 @@
1
1
  import { B as MatrxTransport, w as MatrxRuntimeOperationEvent, v as MatrxRuntimeExecutionStatus, d as MatrxCancelResponse } from '../operations-Dp4ut-ac.js';
2
- import { Snapshot, Draft } from '@ai-matrx/kit/content-transfer';
2
+ import { PageAction, Payload, Snapshot, Draft, TransferOutcome, TransferTarget } from '@ai-matrx/kit/content-transfer';
3
3
  import { MatrxStreamEnvelope } from '../stream/ndjson.js';
4
4
  import '../stream/sse.js';
5
5
 
6
+ /** Bind once in a host; every menu and declared surface inherits these actions. */
7
+ type MatrxTransferDestination = "notes" | "scratch" | "document" | "workbook" | "task" | "attach" | "chat" | "assistant" | "tools" | "code";
8
+ interface MatrxTransferContent {
9
+ label: string;
10
+ markdown: string;
11
+ plainText: string;
12
+ payload: Payload;
13
+ snapshot: Snapshot;
14
+ draft: Draft;
15
+ table?: {
16
+ name: string;
17
+ headers: string[];
18
+ rows: string[][];
19
+ };
20
+ signal: AbortSignal;
21
+ }
22
+ type MatrxTransferPorts = Partial<Record<MatrxTransferDestination, (content: MatrxTransferContent) => Promise<TransferOutcome>>>;
23
+ type MatrxTransferAction = PageAction & {
24
+ group: "save" | "chat";
25
+ hint: string;
26
+ /** Only these actions are offered for a manually prepared revision. */
27
+ prepared: true;
28
+ };
29
+ /** Serializes the captured CURRENT revision, never re-reads the host's source. */
30
+ declare function createMatrxTransferActions(ports: MatrxTransferPorts): MatrxTransferAction[];
31
+
32
+ type MatrxTransferIdentity = {
33
+ userId: string;
34
+ organizationId: string;
35
+ };
36
+ type SaveResult = {
37
+ ok: boolean;
38
+ id?: string;
39
+ href?: string;
40
+ error?: string;
41
+ };
42
+ interface MatrxTransferBindings {
43
+ getIdentity(): MatrxTransferIdentity;
44
+ saveNote(content: MatrxTransferContent, folder: string): Promise<TransferTarget>;
45
+ saveDocument(content: MatrxTransferContent): Promise<SaveResult>;
46
+ saveWorkbook(content: MatrxTransferContent): Promise<SaveResult>;
47
+ openNotes(content: MatrxTransferContent): void | Promise<void>;
48
+ openTask(content: MatrxTransferContent): void | Promise<void>;
49
+ openCode(content: MatrxTransferContent): void | Promise<void>;
50
+ openAttachment(target: TransferTarget): void | Promise<void>;
51
+ openChat(content: MatrxTransferContent, mode: "chat" | "assistant" | "tools", identity: MatrxTransferIdentity): void | Promise<void>;
52
+ }
53
+ /** Portable workflow and failure semantics; hosts bind only their concrete services and UI openers. */
54
+ declare function createMatrxTransferPorts(bindings: MatrxTransferBindings): Required<MatrxTransferPorts>;
55
+
6
56
  type MatrxContentTransferStatus = "completed" | "failed" | "cancelled" | "detached" | "unavailable";
7
57
  interface MatrxContentTransferIdentity {
8
58
  requestId: string;
@@ -81,4 +131,4 @@ declare function createMatrxContentTransferAdapter(options: MatrxContentTransfer
81
131
  };
82
132
  type MatrxContentTransferAdapter = ReturnType<typeof createMatrxContentTransferAdapter>;
83
133
 
84
- export { type MatrxContentTransferAdapter, type MatrxContentTransferAdapterOptions, type MatrxContentTransferDbResponse, type MatrxContentTransferDbRow, type MatrxContentTransferIdentity, type MatrxContentTransferLaunchInput, type MatrxContentTransferProgress, type MatrxContentTransferQuery, type MatrxContentTransferResult, type MatrxContentTransferStatus, type MatrxContentTransferSupabase, createMatrxContentTransferAdapter };
134
+ export { type MatrxContentTransferAdapter, type MatrxContentTransferAdapterOptions, type MatrxContentTransferDbResponse, type MatrxContentTransferDbRow, type MatrxContentTransferIdentity, type MatrxContentTransferLaunchInput, type MatrxContentTransferProgress, type MatrxContentTransferQuery, type MatrxContentTransferResult, type MatrxContentTransferStatus, type MatrxContentTransferSupabase, type MatrxTransferAction, type MatrxTransferBindings, type MatrxTransferContent, type MatrxTransferDestination, type MatrxTransferIdentity, type MatrxTransferPorts, createMatrxContentTransferAdapter, createMatrxTransferActions, createMatrxTransferPorts };
@@ -1,7 +1,68 @@
1
+ // content-transfer/destinations.ts
2
+ import {
3
+ readTransferCell,
4
+ serialize
5
+ } from "@ai-matrx/kit/content-transfer";
6
+ var DESTINATIONS = [
7
+ { key: "notes", label: "Save to Notes", hint: "Choose a note or create one", group: "save" },
8
+ { key: "scratch", label: "Save to Scratch", hint: "Capture a new note immediately", group: "save" },
9
+ { key: "document", label: "Create a document", hint: "A native Matrx document", group: "save" },
10
+ { key: "workbook", label: "Create a workbook", hint: "Selected columns and rows in Matrx Sheets", group: "save" },
11
+ { key: "task", label: "Create a task", hint: "Review the title and content before saving", group: "save" },
12
+ { key: "attach", label: "Save and attach to a task or project", hint: "Save a note, then choose where it belongs", group: "save" },
13
+ { key: "code", label: "Save to Code", hint: "Choose a file and language", group: "save" },
14
+ { key: "chat", label: "Open in a new chat", hint: "Attach this content and write your request", group: "chat" },
15
+ { key: "assistant", label: "Open an assistant window", hint: "Keep this page open while you work", group: "chat" },
16
+ { key: "tools", label: "Use with connected tools", hint: "Open an assistant and choose tools or MCPs", group: "chat" }
17
+ ];
18
+ function createMatrxTransferActions(ports) {
19
+ return DESTINATIONS.flatMap(({ key, ...presentation }) => {
20
+ const port = ports[key];
21
+ if (!port) return [];
22
+ const supports = (snapshot, draft) => key !== "workbook" || (draft?.payload ?? snapshot.payload).kind === "rows";
23
+ return [{
24
+ id: `matrx:${key}`,
25
+ ...presentation,
26
+ prepared: true,
27
+ supports,
28
+ async run({ snapshot, draft, signal }) {
29
+ signal.throwIfAborted();
30
+ if (draft.snapshotId !== snapshot.id || draft.sourceId !== snapshot.sourceId || draft.sourceRevision !== snapshot.revision)
31
+ throw new Error("The prepared content does not belong to this source revision. Refresh Alchemy before continuing.");
32
+ if (!supports(snapshot, draft))
33
+ throw new Error(`${presentation.label} is unavailable for this prepared content.`);
34
+ const current = draft;
35
+ const payload = current.payload;
36
+ const columns = payload.kind === "rows" ? payload.columns.filter((column) => column.visible && column.exportable !== false && column.classification !== "secret" && column.classification !== "credential") : [];
37
+ const table = payload.kind === "rows" ? {
38
+ name: snapshot.label,
39
+ headers: columns.map((column) => column.label),
40
+ rows: payload.rows.map((row) => columns.map((column) => {
41
+ const value = readTransferCell(row, column);
42
+ return value == null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
43
+ }))
44
+ } : void 0;
45
+ const content = {
46
+ label: snapshot.label,
47
+ snapshot,
48
+ draft: current,
49
+ payload,
50
+ markdown: serialize(current, "markdown").plainText,
51
+ plainText: serialize(current, "plain").plainText,
52
+ signal,
53
+ ...table ? { table } : {}
54
+ };
55
+ signal.throwIfAborted();
56
+ return port(content);
57
+ }
58
+ }];
59
+ });
60
+ }
61
+
1
62
  // content-transfer/index.ts
2
63
  import {
3
64
  editDraft,
4
- serialize
65
+ serialize as serialize2
5
66
  } from "@ai-matrx/kit/content-transfer";
6
67
 
7
68
  // mandates/keys.generated.ts
@@ -86,6 +147,8 @@ var MANDATE_KEYS = {
86
147
  crm__save_contact: "crm.save_contact",
87
148
  data__page_guidance: "data.page_guidance",
88
149
  dictionary__workspace_guide: "dictionary.workspace_guide",
150
+ distillation__timeline_distiller: "distillation.timeline_distiller",
151
+ distillation__timeline_unfolder: "distillation.timeline_unfolder",
89
152
  education__admin_guidance: "education.admin_guidance",
90
153
  education__analytics_narrate: "education.analytics_narrate",
91
154
  education__audio_study_guidance: "education.audio_study_guidance",
@@ -201,12 +264,15 @@ var MANDATE_KEYS = {
201
264
  masterwork__approach_selector: "masterwork.approach_selector",
202
265
  masterwork__audition_judge: "masterwork.audition_judge",
203
266
  masterwork__bad_draft: "masterwork.bad_draft",
267
+ masterwork__case_oracle: "masterwork.case_oracle",
204
268
  masterwork__checkup_auditor: "masterwork.checkup_auditor",
205
269
  masterwork__coherence_partner: "masterwork.coherence_partner",
206
270
  masterwork__conductor: "masterwork.conductor",
207
271
  masterwork__corpus_cleaner: "masterwork.corpus_cleaner",
208
272
  masterwork__corpus_synthesizer: "masterwork.corpus_synthesizer",
273
+ masterwork__counterparty: "masterwork.counterparty",
209
274
  masterwork__draft_triage: "masterwork.draft_triage",
275
+ masterwork__elicitation_judge: "masterwork.elicitation_judge",
210
276
  masterwork__exception_hunter: "masterwork.exception_hunter",
211
277
  masterwork__exemplar_distiller: "masterwork.exemplar_distiller",
212
278
  masterwork__faithfulness_judge: "masterwork.faithfulness_judge",
@@ -228,6 +294,7 @@ var MANDATE_KEYS = {
228
294
  masterwork__transcript_distiller: "masterwork.transcript_distiller",
229
295
  masterwork__transcript_shortlister: "masterwork.transcript_shortlister",
230
296
  masterwork__understudy: "masterwork.understudy",
297
+ masterwork__unfolding_judge: "masterwork.unfolding_judge",
231
298
  media__youtube_analyzer: "media.youtube_analyzer",
232
299
  meet__live_intelligence: "meet.live_intelligence",
233
300
  meet__live_notes: "meet.live_notes",
@@ -1015,6 +1082,113 @@ async function rejoinRuntimeOperation(transport, requestId, options = {}) {
1015
1082
  return toRunHandle(response, options);
1016
1083
  }
1017
1084
 
1085
+ // content-transfer/destination-ports.ts
1086
+ var success = (message, target) => ({ status: "success", delivered: "action", mimeTypes: [], message, ...target ? { target } : {} });
1087
+ var active = (bindings, content, expected) => {
1088
+ content.signal.throwIfAborted();
1089
+ const identity = bindings.getIdentity();
1090
+ if (!identity.userId || !identity.organizationId) throw new Error("Sign in and select an organization to use Matrx destinations.");
1091
+ if (expected && (identity.userId !== expected.userId || identity.organizationId !== expected.organizationId)) throw new Error("Your account or organization changed while this action was being prepared.");
1092
+ return identity;
1093
+ };
1094
+ var receipt = (bindings, content, identity, target, message) => {
1095
+ try {
1096
+ active(bindings, content, identity);
1097
+ return success(message, target);
1098
+ } catch {
1099
+ return { status: "error", code: "saved-before-context-change", retryable: false, target, message: `${target.label} was saved. Your account or organization changed before it could be opened.` };
1100
+ }
1101
+ };
1102
+ var failed = (kind, content, result) => ({
1103
+ status: "error",
1104
+ code: `${kind}-save-failed`,
1105
+ retryable: false,
1106
+ message: result.error ?? `${kind === "document" ? "Document" : "Workbook"} could not be saved.`,
1107
+ ...result.id ? { target: { kind, id: result.id, label: content.label, ...result.href ? { href: result.href } : {} } } : {}
1108
+ });
1109
+ function createMatrxTransferPorts(bindings) {
1110
+ const attached = /* @__PURE__ */ new Map();
1111
+ const saveNote = async (content, folder, identity) => {
1112
+ const saved = await bindings.saveNote(content, folder);
1113
+ return saved;
1114
+ };
1115
+ return {
1116
+ notes: async (content) => {
1117
+ const identity = active(bindings, content);
1118
+ await bindings.openNotes(content);
1119
+ active(bindings, content, identity);
1120
+ return success("Notes editor opened. Choose where to save this content.");
1121
+ },
1122
+ scratch: async (content) => {
1123
+ const identity = active(bindings, content);
1124
+ const target = await saveNote(content, "Scratch", identity);
1125
+ return receipt(bindings, content, identity, target, "Saved to Scratch.");
1126
+ },
1127
+ document: async (content) => {
1128
+ const identity = active(bindings, content);
1129
+ const result = await bindings.saveDocument(content);
1130
+ if (!result.ok || !result.id || !result.href) return failed("document", content, result);
1131
+ return receipt(bindings, content, identity, { kind: "document", id: result.id, label: content.label, href: result.href }, "Saved as a Matrx document.");
1132
+ },
1133
+ workbook: async (content) => {
1134
+ const identity = active(bindings, content);
1135
+ if (!content.table) throw new Error("A workbook requires tabular content.");
1136
+ const result = await bindings.saveWorkbook(content);
1137
+ if (!result.ok || !result.id || !result.href) return failed("workbook", content, result);
1138
+ return receipt(bindings, content, identity, { kind: "workbook", id: result.id, label: content.label, href: result.href }, "Saved as a Matrx workbook.");
1139
+ },
1140
+ task: async (content) => {
1141
+ const identity = active(bindings, content);
1142
+ await bindings.openTask(content);
1143
+ active(bindings, content, identity);
1144
+ return success("Task editor opened with this content. Review and save the task.");
1145
+ },
1146
+ attach: async (content) => {
1147
+ const identity = active(bindings, content);
1148
+ const key = JSON.stringify([identity.userId, identity.organizationId, content.draft.sourceId, content.draft.sourceRevision, content.draft.revision, content.label, content.markdown]);
1149
+ let pending = attached.get(key);
1150
+ if (!pending) {
1151
+ pending = bindings.saveNote(content, "Alchemy");
1152
+ attached.set(key, pending);
1153
+ pending.catch(() => attached.delete(key));
1154
+ }
1155
+ const target = await pending;
1156
+ try {
1157
+ active(bindings, content, identity);
1158
+ await bindings.openAttachment(target);
1159
+ active(bindings, content, identity);
1160
+ return success("Note saved. Choose a task or project in the attachment window to finish attaching it.", target);
1161
+ } catch {
1162
+ return { status: "error", code: "note-saved-chooser-not-opened", retryable: false, target, message: "Note saved, but the attachment window did not open. Reopen this note to attach it; do not save another copy." };
1163
+ }
1164
+ },
1165
+ code: async (content) => {
1166
+ const identity = active(bindings, content);
1167
+ await bindings.openCode(content);
1168
+ active(bindings, content, identity);
1169
+ return success("Code editor opened. Choose the file name and language before saving.");
1170
+ },
1171
+ chat: async (content) => {
1172
+ const identity = active(bindings, content);
1173
+ await bindings.openChat(content, "chat", identity);
1174
+ active(bindings, content, identity);
1175
+ return success("New chat opened with this content attached. Write your request when ready.");
1176
+ },
1177
+ assistant: async (content) => {
1178
+ const identity = active(bindings, content);
1179
+ await bindings.openChat(content, "assistant", identity);
1180
+ active(bindings, content, identity);
1181
+ return success("Assistant window opened with this content attached. Nothing has been sent yet.");
1182
+ },
1183
+ tools: async (content) => {
1184
+ const identity = active(bindings, content);
1185
+ await bindings.openChat(content, "tools", identity);
1186
+ active(bindings, content, identity);
1187
+ return success("Assistant opened with this content attached. Choose Tools in Chat Options to use your connected MCPs.");
1188
+ }
1189
+ };
1190
+ }
1191
+
1018
1192
  // content-transfer/index.ts
1019
1193
  var SupersededRunError = class extends Error {
1020
1194
  constructor() {
@@ -1070,7 +1244,7 @@ function responseMessageId(metadata) {
1070
1244
  }
1071
1245
  function draftFromAssistant(source, text, identity) {
1072
1246
  const edited = editDraft(source, { kind: "markdown", text });
1073
- const reducedBy = serialize(source, "markdown").plainText.length - text.length;
1247
+ const reducedBy = serialize2(source, "markdown").plainText.length - text.length;
1074
1248
  return deepFreeze({
1075
1249
  ...edited,
1076
1250
  manuallyEdited: source.manuallyEdited,
@@ -1287,7 +1461,7 @@ function createMatrxContentTransferAdapter(options) {
1287
1461
  executionId: null,
1288
1462
  status: "starting"
1289
1463
  });
1290
- const preparedContent = serialize(input.draft, "markdown").plainText;
1464
+ const preparedContent = serialize2(input.draft, "markdown").plainText;
1291
1465
  let identity = null;
1292
1466
  try {
1293
1467
  const handle = await startMandateRun(
@@ -1401,6 +1575,8 @@ function createMatrxContentTransferAdapter(options) {
1401
1575
  };
1402
1576
  }
1403
1577
  export {
1404
- createMatrxContentTransferAdapter
1578
+ createMatrxContentTransferAdapter,
1579
+ createMatrxTransferActions,
1580
+ createMatrxTransferPorts
1405
1581
  };
1406
1582
  //# sourceMappingURL=index.js.map