@ai-matrx/chat 0.2.0 → 0.2.2

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/agent-copy/AlchemySurfaceBridge.d.ts +1 -1
  3. package/dist/agent-copy/AlchemySurfaceBridge.js +1 -1
  4. package/dist/agent-copy/buildAgentPayload.d.ts +1 -1
  5. package/dist/agent-copy/buildAgentPayload.js +1 -1
  6. package/dist/agent-copy/page-capture/pageCapture.d.ts +1 -1
  7. package/dist/agents/components/inputs/smart-input/AgentTextarea.d.ts +1 -2
  8. package/dist/agents/components/inputs/smart-input/AgentTextarea.js +0 -12
  9. package/dist/agents/components/inputs/smart-input/InputActionButtons.js +3 -3
  10. package/dist/agents/components/inputs/smart-input/SmartAgentInputStacked.js +13 -7
  11. package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.d.ts +8 -1
  12. package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.js +3 -1
  13. package/dist/agents/components/inputs/smart-input/composer/ComposerMetaRow.js +1 -1
  14. package/dist/agents/components/inputs/smart-input/composer/ComposerModeSwitch.js +10 -15
  15. package/dist/agents/components/inputs/smart-input/composer/useComposerFold.d.ts +3 -2
  16. package/dist/agents/components/inputs/smart-input/composer/useComposerFold.js +30 -5
  17. package/dist/agents/components/messages-display/MessageTimestamp.d.ts +8 -1
  18. package/dist/agents/components/messages-display/MessageTimestamp.js +3 -4
  19. package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.js +5 -3
  20. package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.d.ts +5 -0
  21. package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.js +36 -13
  22. package/dist/agents/components/messages-display/assistant/AssistantTurnGroup.js +3 -1
  23. package/dist/surfaces/manifests/_baseline.manifest.d.ts +59 -0
  24. package/dist/surfaces/manifests/_baseline.manifest.js +56 -1
  25. package/dist/surfaces/runtime/SurfaceRuntimeContext.d.ts +1 -1
  26. package/dist/surfaces/runtime/custom-field-targets.d.ts +6 -6
  27. package/dist/surfaces/runtime/custom-field-targets.js +7 -21
  28. package/dist/surfaces/runtime/surface-feedback.d.ts +7 -9
  29. package/dist/surfaces/runtime/surface-feedback.js +8 -21
  30. package/dist/surfaces/runtime/surface-writeback.d.ts +5 -2
  31. package/dist/surfaces/runtime/surface-writeback.js +171 -135
  32. package/dist/surfaces/runtime/window-forms.d.ts +2 -2
  33. package/dist/surfaces/runtime/window-forms.js +3 -9
  34. package/dist/utils/connectors/marks.d.ts +2 -2
  35. package/dist/utils/connectors/marks.js +2 -9
  36. package/package.json +14 -8
@@ -101,9 +101,57 @@ const PLATFORM_CONTEXT_VALUES = {
101
101
  sortOrder: 9997
102
102
  }
103
103
  };
104
+ const BASELINE_SURFACE_NAME = "matrx-platform/baseline";
105
+ const SURFACE_FEEDBACK_KINDS = [
106
+ "missing_capability",
107
+ "wrong_or_unclear_description",
108
+ "bug",
109
+ "missing_data",
110
+ "suggestion"
111
+ ];
112
+ const SURFACE_FEEDBACK_MESSAGE_MIN = 10;
113
+ const SURFACE_FEEDBACK_MESSAGE_MAX = 4e3;
114
+ const CUSTOM_FIELDS_MAX_PER_WRITE = 10;
115
+ const PLATFORM_WRITE_TARGETS = {
116
+ window_form_fields: {
117
+ name: "window_form_fields",
118
+ label: "Fields in an open window",
119
+ description: `Change fields in an open window that has no registered surface (listed in your context as window::<title>). Value: { "window": "<title exactly as listed>", "changes": [{ "field": "<field key>", "value": <new value> }] }. A text or number field takes a string or number, a checkbox or switch takes true/false, a list takes the text of one of its choices (a wrong choice is refused with the real ones). Every change is checked against the field's rules before anything lands; the person approves first, and the window's own Save still decides.`,
120
+ valueType: "object",
121
+ mode: "draft",
122
+ applyPolicy: "ask"
123
+ },
124
+ surface_feedback: {
125
+ name: "surface_feedback",
126
+ label: "Feedback about this page",
127
+ description: `Save feedback about this page (surface) for the team that builds it \u2014 it changes NOTHING on the page and nobody is asked. Use it when something about the page got in your way: a write you needed does not exist, a description was wrong or unclear, data you needed was missing or arrived in an awkward form, or something broke. Also use it when the person asks you to give feedback on this page. Value: { "kind": "${SURFACE_FEEDBACK_KINDS.join(" | ")}", "message": "<what happened and what would have helped, ${SURFACE_FEEDBACK_MESSAGE_MIN}-${SURFACE_FEEDBACK_MESSAGE_MAX} characters>", "target_or_value": "<optional: the write target or value name it concerns>" }. It is filed for the surface named on this line; pass \`surface\` to file it for another open surface instead.`,
128
+ valueType: "object",
129
+ mode: "entity",
130
+ applyPolicy: "auto"
131
+ },
132
+ custom_fields_add: {
133
+ name: "custom_fields_add",
134
+ label: "Add custom fields",
135
+ description: `Add custom fields (new columns) to the kind of record shown on this page \u2014 SAVED immediately after the person approves, and every record of that kind gets the field (empty until filled in). Value: { "entity": "<entity token, required only when more than one section is listed>", "fields": [{ "label": "<the field's name as a person reads it>", "type": "<one of the types below; default text>" }] } \u2014 1 to ${CUSTOM_FIELDS_MAX_PER_WRITE} fields. Refused before the person is asked: a name already used, a name asked for twice, an unknown type, or a person who may not add fields (the store's reason is returned). This adds the FIELD only; it does not fill in a value.`,
136
+ valueType: "object",
137
+ mode: "entity",
138
+ applyPolicy: "ask"
139
+ },
140
+ custom_fields_set: {
141
+ name: "custom_fields_set",
142
+ label: "Fill in custom fields",
143
+ description: `Set this record's custom-field values \u2014 SAVED immediately after the person approves; a field left out is left alone. Value: { "entity": "<entity token, only when more than one section is listed>", "values": { "<field name or key>": <value> } }. A number field takes a number, a date field an ISO date (YYYY-MM-DD), text fields a string; null clears a value. Refused before the person is asked: a field that does not exist (the existing ones are named), or a person who may not fill them in. To add a NEW field use custom_fields_add.`,
144
+ valueType: "object",
145
+ mode: "entity",
146
+ applyPolicy: "ask"
147
+ }
148
+ };
149
+ function isPlatformWriteTarget(name) {
150
+ return Object.prototype.hasOwnProperty.call(PLATFORM_WRITE_TARGETS, name);
151
+ }
104
152
  const PLATFORM_RESERVED_NAMES = {
105
153
  values: Object.keys(PLATFORM_CONTEXT_VALUES),
106
- writeTargets: ["window_form_fields", "surface_feedback", "custom_fields_add", "custom_fields_set"]
154
+ writeTargets: Object.keys(PLATFORM_WRITE_TARGETS)
107
155
  };
108
156
  const PAGE_OFF_WITHHELD = [
109
157
  "route_brief",
@@ -140,16 +188,23 @@ function withAllBaselines(surfaceSpecific) {
140
188
  }
141
189
  export {
142
190
  AMBIENT_VALUES,
191
+ BASELINE_SURFACE_NAME,
143
192
  BASELINE_VALUES,
144
193
  BASELINE_VALUE_NAMES,
194
+ CUSTOM_FIELDS_MAX_PER_WRITE,
145
195
  OWN_CONVERSATION_WITHHELD,
146
196
  PAGELESS_CONTENT_INLINE_CEILING,
147
197
  PAGE_OFF_WITHHELD,
148
198
  PERSON_CONTEXT_VALUES,
149
199
  PLATFORM_CONTEXT_VALUES,
150
200
  PLATFORM_RESERVED_NAMES,
201
+ PLATFORM_WRITE_TARGETS,
151
202
  POINTER_INLINE_CEILINGS,
203
+ SURFACE_FEEDBACK_KINDS,
204
+ SURFACE_FEEDBACK_MESSAGE_MAX,
205
+ SURFACE_FEEDBACK_MESSAGE_MIN,
152
206
  allBaseline,
207
+ isPlatformWriteTarget,
153
208
  mergeBaselineValues,
154
209
  pickBaseline,
155
210
  withAllBaselines
@@ -1,7 +1,7 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { SurfaceScopePayload } from "../types.js";
3
3
  import type { InstanceContextEntry } from "../../agents/types/instance.types.js";
4
- import type { SurfaceHandle } from "@ai-matrx/kit/content-transfer";
4
+ import type { SurfaceHandle } from "@ai-matrx/alchemy/operate";
5
5
  import type { ApplySurfaceWriteOptions } from "./surface-writeback.js";
6
6
  /**
7
7
  * What a write handler may RETURN so the caller (and, for an agent write, the
@@ -8,9 +8,10 @@
8
8
  * that page could add a custom field; an agent on the same page could not —
9
9
  * nothing offered it. Declaring a target on every manifest would be 643 copies
10
10
  * of one sentence, so this is a PLATFORM target like `surface_feedback` and
11
- * `window_form_fields`: declared here once, belonging to no manifest, offered
12
- * whenever at least one custom-fields section is mounted, and routed by the
13
- * writeback seam (`surface-writeback.ts`) to the section's own door.
11
+ * `window_form_fields`: declared once on the baseline surface every surface
12
+ * inherits (`_baseline.manifest.ts`), offered whenever at least one
13
+ * custom-fields section is mounted, and written through the one write door
14
+ * (`surface-writeback.ts` `applyPlatformWrite`) to the section's own door.
14
15
  *
15
16
  * The section owns the write: it hands its host a door (records-ui
16
17
  * `agentDoor` prop → `CustomFieldsAgentDoor`), which checks the whole request
@@ -23,11 +24,10 @@
23
24
  */
24
25
  import type { SurfaceWriteTarget } from "../types.js";
25
26
  import type { SurfaceWriteOutcome } from "./SurfaceRuntimeContext.js";
26
- export declare const CUSTOM_FIELDS_TARGET_NAME = "custom_fields_add";
27
- export declare const CUSTOM_FIELDS_SET_TARGET_NAME = "custom_fields_set";
27
+ export declare const CUSTOM_FIELDS_TARGET_NAME: "custom_fields_add";
28
+ export declare const CUSTOM_FIELDS_SET_TARGET_NAME: "custom_fields_set";
28
29
  /** The surface value a section contributes when its surface declares it (baseline `custom_fields`). */
29
30
  export declare const CUSTOM_FIELDS_VALUE_NAME = "custom_fields";
30
- export declare const CUSTOM_FIELDS_MAX_PER_WRITE = 10;
31
31
  export declare function providerOwnsCustomFields(surfaceName: string): boolean;
32
32
  export interface CustomFieldAddRequest {
33
33
  label: string;
@@ -1,7 +1,7 @@
1
- const CUSTOM_FIELDS_TARGET_NAME = "custom_fields_add";
2
- const CUSTOM_FIELDS_SET_TARGET_NAME = "custom_fields_set";
1
+ import { CUSTOM_FIELDS_MAX_PER_WRITE, PLATFORM_WRITE_TARGETS } from "../manifests/_baseline.manifest.js";
2
+ const CUSTOM_FIELDS_TARGET_NAME = PLATFORM_WRITE_TARGETS.custom_fields_add.name;
3
+ const CUSTOM_FIELDS_SET_TARGET_NAME = PLATFORM_WRITE_TARGETS.custom_fields_set.name;
3
4
  const CUSTOM_FIELDS_VALUE_NAME = "custom_fields";
4
- const CUSTOM_FIELDS_MAX_PER_WRITE = 10;
5
5
  const PROVIDER_OWNED_CUSTOM_FIELDS = /* @__PURE__ */ new Set(["matrx-user/notes"]);
6
6
  function providerOwnsCustomFields(surfaceName) {
7
7
  return PROVIDER_OWNED_CUSTOM_FIELDS.has(surfaceName);
@@ -31,20 +31,13 @@ function describeDoor(door) {
31
31
  const may = s.mayAdd === true ? "you may add" : s.mayAdd === null ? "still checking who may add" : `adding is refused: ${s.refusal ?? "this person may not add a field here"}`;
32
32
  return `entity "${s.entityToken}" (${what}, record ${s.recordId}) \u2014 fields: ${held}; ${may}`;
33
33
  }
34
- const BASE_DESCRIPTION = `Add custom fields (new columns) to the kind of record shown on this page \u2014 SAVED immediately after the person approves, and every record of that kind gets the field (empty until filled in). Value: { "entity": "<entity token, required only when more than one section is listed>", "fields": [{ "label": "<the field's name as a person reads it>", "type": "<one of the types below; default text>" }] } \u2014 1 to ${CUSTOM_FIELDS_MAX_PER_WRITE} fields. Refused before the person is asked: a name already used, a name asked for twice, an unknown type, or a person who may not add fields (the store's reason is returned). This adds the FIELD only; it does not fill in a value.`;
35
34
  function customFieldsTarget() {
36
35
  const mounted = listCustomFieldsDoors();
37
36
  const types = mounted[0]?.state().types ?? [];
38
37
  const typeLine = types.length > 0 ? ` Types: ${types.map((t) => `${t.value} (${t.label})`).join(", ")}.` : "";
39
38
  const sections = mounted.length > 0 ? ` Sections on this page: ${mounted.map(describeDoor).join(" | ")}.` : "";
40
- return {
41
- name: CUSTOM_FIELDS_TARGET_NAME,
42
- label: "Add custom fields",
43
- description: `${BASE_DESCRIPTION}${typeLine}${sections}`,
44
- valueType: "object",
45
- mode: "entity",
46
- applyPolicy: "ask"
47
- };
39
+ const declared = PLATFORM_WRITE_TARGETS.custom_fields_add;
40
+ return { ...declared, description: `${declared.description}${typeLine}${sections}` };
48
41
  }
49
42
  function customFieldsProblems(value, mounted = listCustomFieldsDoors()) {
50
43
  const none = { door: null, fields: [] };
@@ -151,14 +144,8 @@ function hasCustomFieldsSetDoors() {
151
144
  function customFieldsSetTarget() {
152
145
  const mounted = listCustomFieldsDoors().filter((d) => typeof d.setValues === "function");
153
146
  const sections = mounted.length > 0 ? ` Sections on this page: ${mounted.map(describeDoor).join(" | ")}.` : "";
154
- return {
155
- name: CUSTOM_FIELDS_SET_TARGET_NAME,
156
- label: "Fill in custom fields",
157
- description: `Set this record's custom-field values \u2014 SAVED immediately after the person approves; a field left out is left alone. Value: { "entity": "<entity token, only when more than one section is listed>", "values": { "<field name or key>": <value> } }. A number field takes a number, a date field an ISO date (YYYY-MM-DD), text fields a string; null clears a value. Refused before the person is asked: a field that does not exist (the existing ones are named), or a person who may not fill them in. To add a NEW field use ${CUSTOM_FIELDS_TARGET_NAME}.${sections}`,
158
- valueType: "object",
159
- mode: "entity",
160
- applyPolicy: "ask"
161
- };
147
+ const declared = PLATFORM_WRITE_TARGETS.custom_fields_set;
148
+ return { ...declared, description: `${declared.description}${sections}` };
162
149
  }
163
150
  function customFieldsSetProblems(value, mounted = listCustomFieldsDoors().filter((d) => typeof d.setValues === "function")) {
164
151
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -197,7 +184,6 @@ async function applyCustomFieldsSetWrite(value) {
197
184
  };
198
185
  }
199
186
  export {
200
- CUSTOM_FIELDS_MAX_PER_WRITE,
201
187
  CUSTOM_FIELDS_SET_TARGET_NAME,
202
188
  CUSTOM_FIELDS_TARGET_NAME,
203
189
  CUSTOM_FIELDS_VALUE_NAME,
@@ -7,10 +7,10 @@
7
7
  * exam dates", "create_classes never said X"). The team reads it the next time
8
8
  * it updates that surface (`pnpm surface:feedback --surface <name>`).
9
9
  *
10
- * Like `window_form_fields` (`window-forms.ts`) it is declared here once and
11
- * belongs to no manifest: `listLiveWriteTargets` offers it whenever at least
12
- * one registered surface is mounted, and `applySurfaceWrite` routes it to
13
- * `applySurfaceFeedbackWrite` in the seam. It changes NOTHING on the page, so
10
+ * Like `window_form_fields` (`window-forms.ts`) it is declared once on the
11
+ * baseline surface (`_baseline.manifest.ts`): `listLiveWriteTargets` offers it
12
+ * whenever at least one registered surface is mounted, and it is written
13
+ * through the one write door (`surface-writeback.ts` `applyPlatformWrite`). It changes NOTHING on the page, so
14
14
  * it is `auto` — the person is never interrupted by a card for it.
15
15
  *
16
16
  * Storage is the central triage table `users.user_feedback`, written through
@@ -20,18 +20,16 @@
20
20
  */
21
21
  import type { ChatFeedbackInput, ChatFeedbackType } from "../../host/contract.js";
22
22
  import type { SurfaceWriteTarget } from "../types.js";
23
+ import { SURFACE_FEEDBACK_KINDS } from "../manifests/_baseline.manifest.js";
23
24
  import type { SurfaceWriteOutcome } from "./SurfaceRuntimeContext.js";
24
- export declare const SURFACE_FEEDBACK_TARGET_NAME = "surface_feedback";
25
- export declare const SURFACE_FEEDBACK_KINDS: readonly ["missing_capability", "wrong_or_unclear_description", "bug", "missing_data", "suggestion"];
25
+ export declare const SURFACE_FEEDBACK_TARGET_NAME: "surface_feedback";
26
26
  export type SurfaceFeedbackKind = (typeof SURFACE_FEEDBACK_KINDS)[number];
27
- export declare const SURFACE_FEEDBACK_MESSAGE_MIN = 10;
28
- export declare const SURFACE_FEEDBACK_MESSAGE_MAX = 4000;
29
27
  export interface SurfaceFeedbackValue {
30
28
  kind: SurfaceFeedbackKind;
31
29
  message: string;
32
30
  target_or_value?: string;
33
31
  }
34
- /** The platform target — declared once; offered whenever a surface is mounted. */
32
+ /** The platform target — declared once on the baseline surface (`_baseline.manifest.ts`); offered whenever a surface is mounted. */
35
33
  export declare const SURFACE_FEEDBACK_TARGET: SurfaceWriteTarget;
36
34
  /**
37
35
  * Pre-write check. Throws a sentence the agent can act on; nothing is written
@@ -1,24 +1,14 @@
1
1
  import { getChatHost } from "../../host/configure.js";
2
2
  import { getStoreSingleton } from "../../store/store-singleton.js";
3
- const SURFACE_FEEDBACK_TARGET_NAME = "surface_feedback";
4
- const SURFACE_FEEDBACK_KINDS = [
5
- "missing_capability",
6
- "wrong_or_unclear_description",
7
- "bug",
8
- "missing_data",
9
- "suggestion"
10
- ];
11
- const SURFACE_FEEDBACK_MESSAGE_MIN = 10;
12
- const SURFACE_FEEDBACK_MESSAGE_MAX = 4e3;
3
+ import {
4
+ PLATFORM_WRITE_TARGETS,
5
+ SURFACE_FEEDBACK_KINDS,
6
+ SURFACE_FEEDBACK_MESSAGE_MAX,
7
+ SURFACE_FEEDBACK_MESSAGE_MIN
8
+ } from "../manifests/_baseline.manifest.js";
9
+ const SURFACE_FEEDBACK_TARGET_NAME = PLATFORM_WRITE_TARGETS.surface_feedback.name;
13
10
  const KIND_LIST = SURFACE_FEEDBACK_KINDS.join(" | ");
14
- const SURFACE_FEEDBACK_TARGET = {
15
- name: SURFACE_FEEDBACK_TARGET_NAME,
16
- label: "Feedback about this page",
17
- description: `Save feedback about this page (surface) for the team that builds it \u2014 it changes NOTHING on the page and nobody is asked. Use it when something about the page got in your way: a write you needed does not exist, a description was wrong or unclear, data you needed was missing or arrived in an awkward form, or something broke. Also use it when the person asks you to give feedback on this page. Value: { "kind": "${KIND_LIST}", "message": "<what happened and what would have helped, ${SURFACE_FEEDBACK_MESSAGE_MIN}-${SURFACE_FEEDBACK_MESSAGE_MAX} characters>", "target_or_value": "<optional: the write target or value name it concerns>" }. It is filed for the surface named on this line; pass \`surface\` to file it for another open surface instead.`,
18
- valueType: "object",
19
- mode: "entity",
20
- applyPolicy: "auto"
21
- };
11
+ const SURFACE_FEEDBACK_TARGET = PLATFORM_WRITE_TARGETS.surface_feedback;
22
12
  const ALLOWED_KEYS = /* @__PURE__ */ new Set(["kind", "message", "target_or_value"]);
23
13
  function validateSurfaceFeedback(value) {
24
14
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -101,9 +91,6 @@ async function saveSurfaceFeedback(value, ctx) {
101
91
  };
102
92
  }
103
93
  export {
104
- SURFACE_FEEDBACK_KINDS,
105
- SURFACE_FEEDBACK_MESSAGE_MAX,
106
- SURFACE_FEEDBACK_MESSAGE_MIN,
107
94
  SURFACE_FEEDBACK_TARGET,
108
95
  SURFACE_FEEDBACK_TARGET_NAME,
109
96
  buildSurfaceFeedbackInput,
@@ -233,8 +233,11 @@ export declare function registerSurfaceWritePolicies(policies: WritePolicyMap, k
233
233
  export declare const surfaceWriteApprovals: ApprovalPort;
234
234
  /**
235
235
  * The declarations the door reads: every manifest, with each target's
236
- * EFFECTIVE policy. No `ancestry`: a resolved manifest already carries what it
237
- * inherits, so a target resolves on the surface that is writing.
236
+ * EFFECTIVE policy, plus the BASELINE surface (`BASELINE_SURFACE_NAME`), which
237
+ * declares the platform's own targets (`PLATFORM_WRITE_TARGETS`). The only
238
+ * ancestry is the baseline: a resolved manifest already carries what it
239
+ * inherits from its parents, so a surface's own target resolves on the surface
240
+ * that is writing, and a platform target on the baseline every surface sits on.
238
241
  */
239
242
  export declare const surfaceWriteDeclarations: WriteDoorDeclarations;
240
243
  /**