@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.
@@ -20,10 +20,72 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // content-transfer/index.ts
21
21
  var content_transfer_exports = {};
22
22
  __export(content_transfer_exports, {
23
- createMatrxContentTransferAdapter: () => createMatrxContentTransferAdapter
23
+ createMatrxContentTransferAdapter: () => createMatrxContentTransferAdapter,
24
+ createMatrxTransferActions: () => createMatrxTransferActions,
25
+ createMatrxTransferPorts: () => createMatrxTransferPorts
24
26
  });
25
27
  module.exports = __toCommonJS(content_transfer_exports);
28
+
29
+ // content-transfer/destinations.ts
26
30
  var import_content_transfer = require("@ai-matrx/kit/content-transfer");
31
+ var DESTINATIONS = [
32
+ { key: "notes", label: "Save to Notes", hint: "Choose a note or create one", group: "save" },
33
+ { key: "scratch", label: "Save to Scratch", hint: "Capture a new note immediately", group: "save" },
34
+ { key: "document", label: "Create a document", hint: "A native Matrx document", group: "save" },
35
+ { key: "workbook", label: "Create a workbook", hint: "Selected columns and rows in Matrx Sheets", group: "save" },
36
+ { key: "task", label: "Create a task", hint: "Review the title and content before saving", group: "save" },
37
+ { key: "attach", label: "Save and attach to a task or project", hint: "Save a note, then choose where it belongs", group: "save" },
38
+ { key: "code", label: "Save to Code", hint: "Choose a file and language", group: "save" },
39
+ { key: "chat", label: "Open in a new chat", hint: "Attach this content and write your request", group: "chat" },
40
+ { key: "assistant", label: "Open an assistant window", hint: "Keep this page open while you work", group: "chat" },
41
+ { key: "tools", label: "Use with connected tools", hint: "Open an assistant and choose tools or MCPs", group: "chat" }
42
+ ];
43
+ function createMatrxTransferActions(ports) {
44
+ return DESTINATIONS.flatMap(({ key, ...presentation }) => {
45
+ const port = ports[key];
46
+ if (!port) return [];
47
+ const supports = (snapshot, draft) => key !== "workbook" || (draft?.payload ?? snapshot.payload).kind === "rows";
48
+ return [{
49
+ id: `matrx:${key}`,
50
+ ...presentation,
51
+ prepared: true,
52
+ supports,
53
+ async run({ snapshot, draft, signal }) {
54
+ signal.throwIfAborted();
55
+ if (draft.snapshotId !== snapshot.id || draft.sourceId !== snapshot.sourceId || draft.sourceRevision !== snapshot.revision)
56
+ throw new Error("The prepared content does not belong to this source revision. Refresh Alchemy before continuing.");
57
+ if (!supports(snapshot, draft))
58
+ throw new Error(`${presentation.label} is unavailable for this prepared content.`);
59
+ const current = draft;
60
+ const payload = current.payload;
61
+ const columns = payload.kind === "rows" ? payload.columns.filter((column) => column.visible && column.exportable !== false && column.classification !== "secret" && column.classification !== "credential") : [];
62
+ const table = payload.kind === "rows" ? {
63
+ name: snapshot.label,
64
+ headers: columns.map((column) => column.label),
65
+ rows: payload.rows.map((row) => columns.map((column) => {
66
+ const value = (0, import_content_transfer.readTransferCell)(row, column);
67
+ return value == null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
68
+ }))
69
+ } : void 0;
70
+ const content = {
71
+ label: snapshot.label,
72
+ snapshot,
73
+ draft: current,
74
+ payload,
75
+ markdown: (0, import_content_transfer.serialize)(current, "markdown").plainText,
76
+ plainText: (0, import_content_transfer.serialize)(current, "plain").plainText,
77
+ signal,
78
+ ...table ? { table } : {}
79
+ };
80
+ signal.throwIfAborted();
81
+ return port(content);
82
+ }
83
+ }];
84
+ });
85
+ }
86
+
87
+ // content-transfer/index.ts
88
+ var import_content_transfer2 = require("@ai-matrx/kit/content-transfer");
27
89
 
28
90
  // mandates/keys.generated.ts
29
91
  var MANDATE_KEYS = {
@@ -107,6 +169,8 @@ var MANDATE_KEYS = {
107
169
  crm__save_contact: "crm.save_contact",
108
170
  data__page_guidance: "data.page_guidance",
109
171
  dictionary__workspace_guide: "dictionary.workspace_guide",
172
+ distillation__timeline_distiller: "distillation.timeline_distiller",
173
+ distillation__timeline_unfolder: "distillation.timeline_unfolder",
110
174
  education__admin_guidance: "education.admin_guidance",
111
175
  education__analytics_narrate: "education.analytics_narrate",
112
176
  education__audio_study_guidance: "education.audio_study_guidance",
@@ -222,12 +286,15 @@ var MANDATE_KEYS = {
222
286
  masterwork__approach_selector: "masterwork.approach_selector",
223
287
  masterwork__audition_judge: "masterwork.audition_judge",
224
288
  masterwork__bad_draft: "masterwork.bad_draft",
289
+ masterwork__case_oracle: "masterwork.case_oracle",
225
290
  masterwork__checkup_auditor: "masterwork.checkup_auditor",
226
291
  masterwork__coherence_partner: "masterwork.coherence_partner",
227
292
  masterwork__conductor: "masterwork.conductor",
228
293
  masterwork__corpus_cleaner: "masterwork.corpus_cleaner",
229
294
  masterwork__corpus_synthesizer: "masterwork.corpus_synthesizer",
295
+ masterwork__counterparty: "masterwork.counterparty",
230
296
  masterwork__draft_triage: "masterwork.draft_triage",
297
+ masterwork__elicitation_judge: "masterwork.elicitation_judge",
231
298
  masterwork__exception_hunter: "masterwork.exception_hunter",
232
299
  masterwork__exemplar_distiller: "masterwork.exemplar_distiller",
233
300
  masterwork__faithfulness_judge: "masterwork.faithfulness_judge",
@@ -249,6 +316,7 @@ var MANDATE_KEYS = {
249
316
  masterwork__transcript_distiller: "masterwork.transcript_distiller",
250
317
  masterwork__transcript_shortlister: "masterwork.transcript_shortlister",
251
318
  masterwork__understudy: "masterwork.understudy",
319
+ masterwork__unfolding_judge: "masterwork.unfolding_judge",
252
320
  media__youtube_analyzer: "media.youtube_analyzer",
253
321
  meet__live_intelligence: "meet.live_intelligence",
254
322
  meet__live_notes: "meet.live_notes",
@@ -1036,6 +1104,113 @@ async function rejoinRuntimeOperation(transport, requestId, options = {}) {
1036
1104
  return toRunHandle(response, options);
1037
1105
  }
1038
1106
 
1107
+ // content-transfer/destination-ports.ts
1108
+ var success = (message, target) => ({ status: "success", delivered: "action", mimeTypes: [], message, ...target ? { target } : {} });
1109
+ var active = (bindings, content, expected) => {
1110
+ content.signal.throwIfAborted();
1111
+ const identity = bindings.getIdentity();
1112
+ if (!identity.userId || !identity.organizationId) throw new Error("Sign in and select an organization to use Matrx destinations.");
1113
+ if (expected && (identity.userId !== expected.userId || identity.organizationId !== expected.organizationId)) throw new Error("Your account or organization changed while this action was being prepared.");
1114
+ return identity;
1115
+ };
1116
+ var receipt = (bindings, content, identity, target, message) => {
1117
+ try {
1118
+ active(bindings, content, identity);
1119
+ return success(message, target);
1120
+ } catch {
1121
+ 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.` };
1122
+ }
1123
+ };
1124
+ var failed = (kind, content, result) => ({
1125
+ status: "error",
1126
+ code: `${kind}-save-failed`,
1127
+ retryable: false,
1128
+ message: result.error ?? `${kind === "document" ? "Document" : "Workbook"} could not be saved.`,
1129
+ ...result.id ? { target: { kind, id: result.id, label: content.label, ...result.href ? { href: result.href } : {} } } : {}
1130
+ });
1131
+ function createMatrxTransferPorts(bindings) {
1132
+ const attached = /* @__PURE__ */ new Map();
1133
+ const saveNote = async (content, folder, identity) => {
1134
+ const saved = await bindings.saveNote(content, folder);
1135
+ return saved;
1136
+ };
1137
+ return {
1138
+ notes: async (content) => {
1139
+ const identity = active(bindings, content);
1140
+ await bindings.openNotes(content);
1141
+ active(bindings, content, identity);
1142
+ return success("Notes editor opened. Choose where to save this content.");
1143
+ },
1144
+ scratch: async (content) => {
1145
+ const identity = active(bindings, content);
1146
+ const target = await saveNote(content, "Scratch", identity);
1147
+ return receipt(bindings, content, identity, target, "Saved to Scratch.");
1148
+ },
1149
+ document: async (content) => {
1150
+ const identity = active(bindings, content);
1151
+ const result = await bindings.saveDocument(content);
1152
+ if (!result.ok || !result.id || !result.href) return failed("document", content, result);
1153
+ return receipt(bindings, content, identity, { kind: "document", id: result.id, label: content.label, href: result.href }, "Saved as a Matrx document.");
1154
+ },
1155
+ workbook: async (content) => {
1156
+ const identity = active(bindings, content);
1157
+ if (!content.table) throw new Error("A workbook requires tabular content.");
1158
+ const result = await bindings.saveWorkbook(content);
1159
+ if (!result.ok || !result.id || !result.href) return failed("workbook", content, result);
1160
+ return receipt(bindings, content, identity, { kind: "workbook", id: result.id, label: content.label, href: result.href }, "Saved as a Matrx workbook.");
1161
+ },
1162
+ task: async (content) => {
1163
+ const identity = active(bindings, content);
1164
+ await bindings.openTask(content);
1165
+ active(bindings, content, identity);
1166
+ return success("Task editor opened with this content. Review and save the task.");
1167
+ },
1168
+ attach: async (content) => {
1169
+ const identity = active(bindings, content);
1170
+ const key = JSON.stringify([identity.userId, identity.organizationId, content.draft.sourceId, content.draft.sourceRevision, content.draft.revision, content.label, content.markdown]);
1171
+ let pending = attached.get(key);
1172
+ if (!pending) {
1173
+ pending = bindings.saveNote(content, "Alchemy");
1174
+ attached.set(key, pending);
1175
+ pending.catch(() => attached.delete(key));
1176
+ }
1177
+ const target = await pending;
1178
+ try {
1179
+ active(bindings, content, identity);
1180
+ await bindings.openAttachment(target);
1181
+ active(bindings, content, identity);
1182
+ return success("Note saved. Choose a task or project in the attachment window to finish attaching it.", target);
1183
+ } catch {
1184
+ 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." };
1185
+ }
1186
+ },
1187
+ code: async (content) => {
1188
+ const identity = active(bindings, content);
1189
+ await bindings.openCode(content);
1190
+ active(bindings, content, identity);
1191
+ return success("Code editor opened. Choose the file name and language before saving.");
1192
+ },
1193
+ chat: async (content) => {
1194
+ const identity = active(bindings, content);
1195
+ await bindings.openChat(content, "chat", identity);
1196
+ active(bindings, content, identity);
1197
+ return success("New chat opened with this content attached. Write your request when ready.");
1198
+ },
1199
+ assistant: async (content) => {
1200
+ const identity = active(bindings, content);
1201
+ await bindings.openChat(content, "assistant", identity);
1202
+ active(bindings, content, identity);
1203
+ return success("Assistant window opened with this content attached. Nothing has been sent yet.");
1204
+ },
1205
+ tools: async (content) => {
1206
+ const identity = active(bindings, content);
1207
+ await bindings.openChat(content, "tools", identity);
1208
+ active(bindings, content, identity);
1209
+ return success("Assistant opened with this content attached. Choose Tools in Chat Options to use your connected MCPs.");
1210
+ }
1211
+ };
1212
+ }
1213
+
1039
1214
  // content-transfer/index.ts
1040
1215
  var SupersededRunError = class extends Error {
1041
1216
  constructor() {
@@ -1090,8 +1265,8 @@ function responseMessageId(metadata) {
1090
1265
  return typeof value === "string" && value.length > 0 ? value : null;
1091
1266
  }
1092
1267
  function draftFromAssistant(source, text, identity) {
1093
- const edited = (0, import_content_transfer.editDraft)(source, { kind: "markdown", text });
1094
- const reducedBy = (0, import_content_transfer.serialize)(source, "markdown").plainText.length - text.length;
1268
+ const edited = (0, import_content_transfer2.editDraft)(source, { kind: "markdown", text });
1269
+ const reducedBy = (0, import_content_transfer2.serialize)(source, "markdown").plainText.length - text.length;
1095
1270
  return deepFreeze({
1096
1271
  ...edited,
1097
1272
  manuallyEdited: source.manuallyEdited,
@@ -1308,7 +1483,7 @@ function createMatrxContentTransferAdapter(options) {
1308
1483
  executionId: null,
1309
1484
  status: "starting"
1310
1485
  });
1311
- const preparedContent = (0, import_content_transfer.serialize)(input.draft, "markdown").plainText;
1486
+ const preparedContent = (0, import_content_transfer2.serialize)(input.draft, "markdown").plainText;
1312
1487
  let identity = null;
1313
1488
  try {
1314
1489
  const handle = await startMandateRun(