@ai-matrx/chat 0.2.2 → 0.2.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @ai-matrx/chat
2
2
 
3
+ ## 0.2.3
4
+ ### The frontend's last in-flight chat edit, carried at the P27 cutover
5
+
6
+ - `run-headless-agent-json.ts`: an edit another lane had uncommitted in matrx-frontend's
7
+ `packages/chat` when that copy was deleted, carried here verbatim.
8
+ - Consumer action: none.
9
+
3
10
  ## 0.2.2
4
11
  ### Last re-sync before matrx-frontend consumes the published package (P27)
5
12
 
@@ -28,12 +28,21 @@
28
28
  import type { ChatDispatch, ChatRootState } from "../../../../store/root-state.js";
29
29
  import type { MessagePart } from "@ai-matrx/agents/generated/stream-events";
30
30
  import type { ContextAnchor, SourceFeature, RequestInitiation } from "../../../types/instance.types.js";
31
+ import type { ApplicationScope } from "../../../types/scope.types.js";
31
32
  import type { AnyMandateKey } from "@ai-matrx/agents/mandates";
32
33
  export interface HeadlessAgentJsonOptions {
33
- /** Exact agent to run. Mutually exclusive with mandateKey. */
34
+ /** Exact agent to run. Mutually exclusive with mandateKey and shortcutId. */
34
35
  agentId?: string;
35
36
  /** Swappable mandate to resolve inside the canonical launcher, preserving config_overrides. */
36
37
  mandateKey?: AnyMandateKey;
38
+ /**
39
+ * A saved shortcut to run: the launcher resolves its agent, config and scope
40
+ * mappings exactly as a menu click would. Mutually exclusive with agentId and
41
+ * mandateKey. Pair with `applicationScope` for the shortcut's mapped values.
42
+ */
43
+ shortcutId?: string;
44
+ /** UI-captured scope values a shortcut's scopeMappings read (selection, content, …). */
45
+ applicationScope?: ApplicationScope;
37
46
  /** Stable surface key for telemetry + the focus registry. */
38
47
  surfaceKey: string;
39
48
  /** UI feature that triggered the run. */
@@ -176,7 +176,7 @@ async function runHeadlessAgentJson(dispatch, getState, opts) {
176
176
  {
177
177
  onResult: opts.onResult,
178
178
  surfaceKey: opts.surfaceKey,
179
- agentRef: opts.agentId ?? opts.mandateKey ?? "unknown"
179
+ agentRef: opts.agentId ?? opts.mandateKey ?? opts.shortcutId ?? "unknown"
180
180
  },
181
181
  result
182
182
  );
@@ -244,20 +244,20 @@ async function launchAndWait(dispatch, getState, opts) {
244
244
  };
245
245
  try {
246
246
  let executionIdentity;
247
+ const identities = [opts.agentId, opts.mandateKey, opts.shortcutId].filter((v) => v !== void 0);
248
+ if (identities.length !== 1) {
249
+ throw new Error("runHeadlessAgentJson requires exactly one of agentId, mandateKey or shortcutId");
250
+ }
247
251
  if (opts.mandateKey !== void 0) {
248
- if (opts.agentId !== void 0) {
249
- throw new Error("runHeadlessAgentJson accepts agentId or mandateKey, never both");
250
- }
251
252
  executionIdentity = { mandateKey: opts.mandateKey };
253
+ } else if (opts.shortcutId !== void 0) {
254
+ executionIdentity = { shortcutId: opts.shortcutId };
252
255
  } else {
253
- if (opts.agentId === void 0) {
254
- throw new Error("runHeadlessAgentJson requires agentId or mandateKey");
255
- }
256
256
  executionIdentity = { agentId: opts.agentId };
257
257
  }
258
258
  screamIfDeclaredFlattening(
259
259
  opts,
260
- opts.agentId ?? opts.mandateKey ?? "unknown"
260
+ opts.agentId ?? opts.mandateKey ?? opts.shortcutId ?? "unknown"
261
261
  );
262
262
  const launch = await dispatch(
263
263
  launchAgentExecution({
@@ -282,7 +282,8 @@ async function launchAndWait(dispatch, getState, opts) {
282
282
  runtime: {
283
283
  ...opts.surfaceName !== void 0 ? { surfaceName: opts.surfaceName } : {},
284
284
  ...opts.variables ? { variables: opts.variables } : {},
285
- ...opts.userInput !== void 0 ? { userInput: opts.userInput } : {}
285
+ ...opts.userInput !== void 0 ? { userInput: opts.userInput } : {},
286
+ ...opts.applicationScope ? { applicationScope: opts.applicationScope } : {}
286
287
  },
287
288
  // `callerExecutes` is the deliberate half of `autoRun: !twoStep`. A
288
289
  // headless launch normally IGNORES autoRun (no interface = nothing to
@@ -335,7 +336,7 @@ async function launchAndWait(dispatch, getState, opts) {
335
336
  pollMs,
336
337
  settleMs,
337
338
  surfaceKey: opts.surfaceKey,
338
- agentRef: opts.agentId ?? opts.mandateKey ?? "unknown",
339
+ agentRef: opts.agentId ?? opts.mandateKey ?? opts.shortcutId ?? "unknown",
339
340
  msgs,
340
341
  expect: opts.expect ?? "json",
341
342
  ...opts.signal ? { signal: opts.signal } : {},
@@ -351,7 +352,7 @@ async function launchAndWait(dispatch, getState, opts) {
351
352
  conversationId: conversationId ?? void 0,
352
353
  raw: {
353
354
  surfaceKey: opts.surfaceKey,
354
- agent: opts.agentId ?? opts.mandateKey ?? "unknown",
355
+ agent: opts.agentId ?? opts.mandateKey ?? opts.shortcutId ?? "unknown",
355
356
  detail,
356
357
  // Only when nothing readable came out: the raw shape, so a throw this
357
358
  // helper cannot read is a bug report rather than a shrug.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/chat",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "THE one AI Matrx person-to-agent chat system: the full chat (running agents, conversations, tool calls, streaming, context, surfaces, voice) as per-module subpaths @ai-matrx/chat/<domain>/<module> over a host contract (/host, /host/react) whose only required value is a db; plus the kernel compatibility entries (., /external-store, /matrx, /react, /tools, styles.css, tokens.css) until P28.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -201,24 +201,24 @@
201
201
  "server-only": "^0.0.1",
202
202
  "uuid": "^14.0.2",
203
203
  "zod": "^4.6.5",
204
- "@ai-matrx/agents": "latest",
205
204
  "@ai-matrx/alchemy": "latest",
206
- "@ai-matrx/associations": "latest",
207
205
  "@ai-matrx/browser-audio": "latest",
206
+ "@ai-matrx/associations": "latest",
208
207
  "@ai-matrx/canvas": "latest",
209
208
  "@ai-matrx/content-ir": "latest",
210
209
  "@ai-matrx/content-ir-react": "latest",
211
- "@ai-matrx/data": "latest",
210
+ "@ai-matrx/design-system": "latest",
211
+ "@ai-matrx/diff": "latest",
212
212
  "@ai-matrx/icons": "latest",
213
+ "@ai-matrx/kit": "latest",
213
214
  "@ai-matrx/media": "latest",
214
- "@ai-matrx/diff": "latest",
215
215
  "@ai-matrx/print": "latest",
216
216
  "@ai-matrx/realtime": "latest",
217
217
  "@ai-matrx/records": "latest",
218
218
  "@ai-matrx/records-ui": "latest",
219
- "@ai-matrx/kit": "latest",
220
- "@ai-matrx/design-system": "latest",
221
- "@ai-matrx/tap-target": "latest"
219
+ "@ai-matrx/tap-target": "latest",
220
+ "@ai-matrx/agents": "latest",
221
+ "@ai-matrx/data": "latest"
222
222
  },
223
223
  "devDependencies": {
224
224
  "@arethetypeswrong/cli": "^0.18.5",