@ai-matrx/agents 0.59.228 → 0.59.230

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.
@@ -6,12 +6,13 @@ import { A as AgentSummary } from '../types-DZhDqrVE.js';
6
6
  * A quick agent is a named bundle of exactly: name, system prompt, model and three settings
7
7
  * (temperature, top-p, max output tokens). It is an ordinary `agent.definition` row — one agent
8
8
  * table, one permission model, no second prompt store — marked `kind: quick` so the big catalog
9
- * can hide or group it. This entry owns the shape and the pure builders/selectors; `./writes`
10
- * owns the four database calls (the one named write allowlist entry of this package).
9
+ * can hide or group it. This entry owns the shape and the pure builders/selectors; the WRITES go
10
+ * through chat's one agent-definition write path (`agents/redux/agent-definition/definition-writes`),
11
+ * never a second one here.
11
12
  *
12
- * The marker lives in two places on purpose: `metadata.kind = "quick"` is the record's own
13
- * statement; the `kind:quick` tag rides every catalog row (the catalog read carries tags, not
14
- * metadata), so a list can filter without a second read — exactly how `chat-agent` marks presets.
13
+ * The marker is the `kind:quick` tag: it rides every catalog row, so a list can filter without a
14
+ * second read — exactly how `chat-agent` marks presets. (Rows saved before the shared write path also
15
+ * carry `metadata.kind = "quick"`; both read as quick.)
15
16
  */
16
17
 
17
18
  declare const QUICK_AGENT_KIND: "quick";
@@ -34,26 +35,81 @@ interface QuickAgentDefinition {
34
35
  interface QuickAgent extends QuickAgentDefinition {
35
36
  id: string;
36
37
  }
37
- declare const QUICK_AGENT_BOUNDS: {
38
- readonly temperature: {
39
- readonly min: 0;
40
- readonly max: 2;
41
- readonly step: 0.1;
38
+ /** One setting's slider: where it starts, where it stops, where a new agent rests. */
39
+ interface QuickAgentSettingLimit {
40
+ min: number;
41
+ max: number;
42
+ step: number;
43
+ default: number;
44
+ }
45
+ interface QuickAgentLimits {
46
+ temperature: QuickAgentSettingLimit;
47
+ topP: QuickAgentSettingLimit;
48
+ maxOutputTokens: QuickAgentSettingLimit;
49
+ }
50
+ /** A model's own settings row for one control (`ai.model` controls: min / max / default), when it states one. */
51
+ interface ModelSettingRow {
52
+ min?: number | null | undefined;
53
+ max?: number | null | undefined;
54
+ default?: unknown;
55
+ }
56
+ /** The chosen model's settings rows for the three controls; a control it does not state is absent. */
57
+ interface ModelSettingRows {
58
+ temperature?: ModelSettingRow | null | undefined;
59
+ top_p?: ModelSettingRow | null | undefined;
60
+ max_output_tokens?: ModelSettingRow | null | undefined;
61
+ }
62
+ /**
63
+ * The `agents.quick` knob values (organization and person can set them). `undefined` = the register
64
+ * has not answered yet. A probability lives in 0..1 and a temperature starts at 0 by definition;
65
+ * every other bound and every default is a knob.
66
+ */
67
+ interface QuickAgentKnobValues {
68
+ temperatureMax?: unknown;
69
+ temperatureDefault?: unknown;
70
+ topPDefault?: unknown;
71
+ maxOutputMin?: unknown;
72
+ maxOutputMax?: unknown;
73
+ maxOutputDefault?: unknown;
74
+ }
75
+ declare const QUICK_AGENT_KNOBS: {
76
+ readonly temperatureMax: {
77
+ readonly feature: "agents.quick";
78
+ readonly key: "temperature_max";
79
+ };
80
+ readonly temperatureDefault: {
81
+ readonly feature: "agents.quick";
82
+ readonly key: "temperature_default";
83
+ };
84
+ readonly topPDefault: {
85
+ readonly feature: "agents.quick";
86
+ readonly key: "top_p_default";
87
+ };
88
+ readonly maxOutputMin: {
89
+ readonly feature: "agents.quick";
90
+ readonly key: "max_output_min";
42
91
  };
43
- readonly topP: {
44
- readonly min: 0;
45
- readonly max: 1;
46
- readonly step: 0.05;
92
+ readonly maxOutputMax: {
93
+ readonly feature: "agents.quick";
94
+ readonly key: "max_output_max";
47
95
  };
48
- readonly maxOutputTokens: {
49
- readonly min: 256;
50
- readonly max: 32768;
51
- readonly step: 256;
96
+ readonly maxOutputDefault: {
97
+ readonly feature: "agents.quick";
98
+ readonly key: "max_output_default";
52
99
  };
53
100
  };
54
- declare const QUICK_AGENT_DEFAULT_SETTINGS: QuickAgentSettings;
55
- /** Settings pulled inside their bounds (a slider can never save a value the model refuses). */
56
- declare function clampQuickAgentSettings(settings: QuickAgentSettings): QuickAgentSettings;
101
+ /** A slider step that gives ~100 positions over the range, on a 1 / 2 / 5 grid (0.02 -> 0.05 style). */
102
+ declare function sliderStep(min: number, max: number): number;
103
+ /**
104
+ * THE ONE SOURCE of the three sliders' bounds and resting values: the chosen model's own settings
105
+ * rows where it states them, else the `agents.quick` knobs. `null` until every number is known (the
106
+ * panel shows no slider for a number nobody has answered — there is no code default).
107
+ */
108
+ declare function resolveQuickAgentLimits(model: ModelSettingRows | null | undefined, knobs: QuickAgentKnobValues): QuickAgentLimits | null;
109
+ /** A new agent's settings: every slider at its resting value. */
110
+ declare function defaultQuickAgentSettings(limits: QuickAgentLimits): QuickAgentSettings;
111
+ /** Settings pulled inside their limits (a slider can never save a value the model refuses). */
112
+ declare function clampQuickAgentSettings(settings: QuickAgentSettings, limits: QuickAgentLimits): QuickAgentSettings;
57
113
  /** What stops a save, in words — empty when the definition is saveable. */
58
114
  declare function quickAgentProblems(def: Pick<QuickAgentDefinition, "name" | "systemPrompt" | "modelId">): string[];
59
115
  interface QuickAgentSystemMessage {
@@ -66,28 +122,44 @@ interface QuickAgentSystemMessage {
66
122
  /** The persisted `settings` JSON: the three params plus the stream flag every agent row carries. */
67
123
  declare function quickAgentSettingsJson(settings: QuickAgentSettings): Record<string, unknown>;
68
124
  declare function quickAgentMessages(systemPrompt: string): QuickAgentSystemMessage[];
69
- /** The `agent.definition` insert for a new quick agent. Born active; no tools, variables or context. */
70
- declare function buildQuickAgentRow(def: QuickAgentDefinition, owner: {
71
- organizationId: string;
72
- userId: string;
73
- }): Record<string, unknown>;
74
- /** The `agent.definition` update for an edit: only the four things a quick agent has. */
75
- declare function buildQuickAgentUpdate(def: QuickAgentDefinition): Record<string, unknown>;
76
- /** A stored row read back as a quick agent; `null` when the row is not one. */
77
- declare function quickAgentFromRow(row: Record<string, unknown> | null | undefined): QuickAgent | null;
125
+ /**
126
+ * The agent fields a quick agent sets, in the shape of the ONE agent-definition write path
127
+ * (chat `definition-writes`): name + system message + model + the three settings, marked quick, no
128
+ * tools. Nothing else is ever part of a quick agent.
129
+ */
130
+ declare function quickAgentFields(def: QuickAgentDefinition): {
131
+ name: string;
132
+ tags: string[];
133
+ isActive: true;
134
+ isArchived: false;
135
+ modelId: string;
136
+ messages: QuickAgentSystemMessage[];
137
+ settings: Record<string, unknown>;
138
+ tools: never[];
139
+ };
140
+ /**
141
+ * A stored row read back as a quick agent; `null` when the row is not one. A setting the row does
142
+ * not carry rests at `defaults` (the resolved limits' resting values).
143
+ */
144
+ declare function quickAgentFromRow(row: Record<string, unknown> | null | undefined, defaults: QuickAgentSettings): QuickAgent | null;
78
145
  declare function isQuickAgentSummary(row: Pick<AgentSummary, "tags">): boolean;
79
146
  /**
80
- * THE PERSONAL LIST: the person's own, live quick agents out of the ONE catalog read.
81
- * (Org and system lanes are the catalogue's own tabs; this is "mine".)
147
+ * THE QUICK-AGENT LIST in the platform's visibility lanes: mine, then my organization's, then the
148
+ * system's (the catalog's own user-type / builtin split; "mine" is what the person created).
82
149
  */
150
+ declare function listQuickAgents(rows: readonly AgentSummary[], userId: string | null): {
151
+ mine: AgentSummary[];
152
+ organization: AgentSummary[];
153
+ system: AgentSummary[];
154
+ };
155
+ /** The pill's list: mine, then organization, then system. */
83
156
  declare function listMyQuickAgents(rows: readonly AgentSummary[], userId: string | null): AgentSummary[];
84
157
  /** The big catalogue's view: quick agents leave the general list (a filter, never a delete). */
85
158
  declare function withoutQuickAgents<T extends Pick<AgentSummary, "tags">>(rows: readonly T[]): T[];
86
159
 
87
160
  /**
88
- * The four database calls of a quick agent, over the EXISTING `agent.definition` table.
89
- * The only write entry of this package besides favorites (check-agents-below-chat WRITE_ALLOWLIST).
90
- * The client is the host's own RLS-bound Supabase client; nothing here knows how it was built.
161
+ * The one READ of a quick agent: its full definition (the catalog row carries no prompt). Reads
162
+ * only; every write goes through chat's one agent-definition write path.
91
163
  */
92
164
 
93
165
  interface QuickAgentClient {
@@ -95,14 +167,7 @@ interface QuickAgentClient {
95
167
  from(table: "definition"): any;
96
168
  };
97
169
  }
98
- declare function createQuickAgent(client: QuickAgentClient, def: QuickAgentDefinition, owner: {
99
- organizationId: string;
100
- userId: string;
101
- }): Promise<QuickAgent>;
102
- declare function updateQuickAgent(client: QuickAgentClient, id: string, def: QuickAgentDefinition): Promise<QuickAgent>;
103
- /** Soft delete — the same `deleted_at` every agent delete sets, so every list already hides it. */
104
- declare function deleteQuickAgent(client: QuickAgentClient, id: string): Promise<void>;
105
- /** One quick agent's full definition (the catalog row carries no prompt). */
106
- declare function readQuickAgent(client: QuickAgentClient, id: string): Promise<QuickAgent | null>;
170
+ /** One quick agent's full definition; settings the row lacks rest at `defaults`. */
171
+ declare function readQuickAgent(client: QuickAgentClient, id: string, defaults: QuickAgentSettings): Promise<QuickAgent | null>;
107
172
 
108
- export { QUICK_AGENT_BOUNDS, QUICK_AGENT_DEFAULT_SETTINGS, QUICK_AGENT_KIND, QUICK_AGENT_TAG, type QuickAgent, type QuickAgentClient, type QuickAgentDefinition, type QuickAgentSettings, type QuickAgentSystemMessage, buildQuickAgentRow, buildQuickAgentUpdate, clampQuickAgentSettings, createQuickAgent, deleteQuickAgent, isQuickAgentSummary, listMyQuickAgents, quickAgentFromRow, quickAgentMessages, quickAgentProblems, quickAgentSettingsJson, readQuickAgent, updateQuickAgent, withoutQuickAgents };
173
+ export { type ModelSettingRow, type ModelSettingRows, QUICK_AGENT_KIND, QUICK_AGENT_KNOBS, QUICK_AGENT_TAG, type QuickAgent, type QuickAgentClient, type QuickAgentDefinition, type QuickAgentKnobValues, type QuickAgentLimits, type QuickAgentSettingLimit, type QuickAgentSettings, type QuickAgentSystemMessage, clampQuickAgentSettings, defaultQuickAgentSettings, isQuickAgentSummary, listMyQuickAgents, listQuickAgents, quickAgentFields, quickAgentFromRow, quickAgentMessages, quickAgentProblems, quickAgentSettingsJson, readQuickAgent, resolveQuickAgentLimits, sliderStep, withoutQuickAgents };
@@ -1,25 +1,182 @@
1
+ // catalog/selectors.ts
2
+ function memoize1(fn) {
3
+ let lastA;
4
+ let last;
5
+ let has = false;
6
+ return (a) => {
7
+ if (!has || lastA !== a) {
8
+ last = fn(a);
9
+ lastA = a;
10
+ has = true;
11
+ }
12
+ return last;
13
+ };
14
+ }
15
+ function memoize2(fn) {
16
+ let lastA;
17
+ let lastB;
18
+ let last;
19
+ let has = false;
20
+ return (a, b) => {
21
+ if (!has || lastA !== a || lastB !== b) {
22
+ last = fn(a, b);
23
+ lastA = a;
24
+ lastB = b;
25
+ has = true;
26
+ }
27
+ return last;
28
+ };
29
+ }
30
+ var selectAllAgentCategories = memoize1(
31
+ (agents) => {
32
+ const cats = /* @__PURE__ */ new Set();
33
+ for (const a of agents) {
34
+ if (a.agentType === "user" && a.category) cats.add(a.category);
35
+ }
36
+ return Array.from(cats).sort();
37
+ }
38
+ );
39
+ var selectAllSystemAgentCategories = memoize1(
40
+ (agents) => {
41
+ const cats = /* @__PURE__ */ new Set();
42
+ for (const a of agents) {
43
+ if (a.agentType === "builtin" && a.category) cats.add(a.category);
44
+ }
45
+ return Array.from(cats).sort();
46
+ }
47
+ );
48
+ var selectAllAgentTags = memoize1(
49
+ (agents) => {
50
+ const tags = /* @__PURE__ */ new Set();
51
+ for (const a of agents) {
52
+ if (a.agentType === "user") a.tags?.forEach((t) => tags.add(t));
53
+ }
54
+ return Array.from(tags).sort();
55
+ }
56
+ );
57
+ var selectAllSystemAgentTags = memoize1(
58
+ (agents) => {
59
+ const tags = /* @__PURE__ */ new Set();
60
+ for (const a of agents) {
61
+ if (a.agentType === "builtin") a.tags?.forEach((t) => tags.add(t));
62
+ }
63
+ return Array.from(tags).sort();
64
+ }
65
+ );
66
+ var selectUserTypeAgents = memoize1(
67
+ (agents) => agents.filter((a) => a.agentType === "user")
68
+ );
69
+ var selectBuiltinTypeAgents = memoize1(
70
+ (agents) => agents.filter((a) => a.agentType === "builtin")
71
+ );
72
+ function agentMatchesArchiveFilter(agent, archFilter) {
73
+ if (archFilter === "active") return !agent.isArchived;
74
+ if (archFilter === "archived") return Boolean(agent.isArchived);
75
+ return true;
76
+ }
77
+ function countBuiltinRows(agents, archFilter) {
78
+ let n = 0;
79
+ for (const a of agents) {
80
+ if (a.agentType !== "builtin") continue;
81
+ if (!agentMatchesArchiveFilter(a, archFilter)) continue;
82
+ n += 1;
83
+ }
84
+ return n;
85
+ }
86
+ function countUserRows(agents, archFilter, predicate) {
87
+ let n = 0;
88
+ for (const a of agents) {
89
+ if (a.agentType !== "user") continue;
90
+ if (!agentMatchesArchiveFilter(a, archFilter)) continue;
91
+ if (predicate(a)) n += 1;
92
+ }
93
+ return n;
94
+ }
95
+ var isOwned = (a) => a.isOwner === true;
96
+ var isShared = (a) => a.isOwner === false && a.accessLevel != null;
97
+ var isAny = () => true;
98
+ var isFavorite = (a) => Boolean(a.isFavorite);
99
+ var selectAgentTabCounts = memoize2(
100
+ (agents, archFilter) => ({
101
+ mine: countUserRows(agents, archFilter, isOwned),
102
+ shared: countUserRows(agents, archFilter, isShared),
103
+ all: countUserRows(agents, archFilter, isAny),
104
+ system: countBuiltinRows(agents, archFilter)
105
+ })
106
+ );
107
+ var selectTotalUserAgentsCount = memoize1(
108
+ (agents) => countUserRows(agents, "active", isAny)
109
+ );
110
+ var selectTotalOwnedAgentsCount = memoize1(
111
+ (agents) => countUserRows(agents, "active", isOwned)
112
+ );
113
+ var selectTotalSharedAgentsCount = memoize1(
114
+ (agents) => countUserRows(agents, "active", isShared)
115
+ );
116
+ var selectTotalBuiltinAgentsCount = memoize1(
117
+ (agents) => countBuiltinRows(agents, "active")
118
+ );
119
+ var selectTotalFavoriteAgentsCount = memoize1(
120
+ (agents) => countUserRows(agents, "active", isFavorite)
121
+ );
122
+
1
123
  // quick/shape.ts
2
124
  var QUICK_AGENT_KIND = "quick";
3
125
  var QUICK_AGENT_TAG = "kind:quick";
4
- var QUICK_AGENT_BOUNDS = {
5
- temperature: { min: 0, max: 2, step: 0.1 },
6
- topP: { min: 0, max: 1, step: 0.05 },
7
- maxOutputTokens: { min: 256, max: 32768, step: 256 }
126
+ var QUICK_AGENT_KNOBS = {
127
+ temperatureMax: { feature: "agents.quick", key: "temperature_max" },
128
+ temperatureDefault: { feature: "agents.quick", key: "temperature_default" },
129
+ topPDefault: { feature: "agents.quick", key: "top_p_default" },
130
+ maxOutputMin: { feature: "agents.quick", key: "max_output_min" },
131
+ maxOutputMax: { feature: "agents.quick", key: "max_output_max" },
132
+ maxOutputDefault: { feature: "agents.quick", key: "max_output_default" }
8
133
  };
9
- var QUICK_AGENT_DEFAULT_SETTINGS = Object.freeze({
10
- temperature: 0.7,
11
- topP: 1,
12
- maxOutputTokens: 4096
13
- });
134
+ var isNum = (v) => typeof v === "number" && Number.isFinite(v);
135
+ function sliderStep(min, max) {
136
+ const raw = (max - min) / 100;
137
+ if (!(raw > 0)) return 1;
138
+ const pow = 10 ** Math.floor(Math.log10(raw));
139
+ const unit = raw / pow;
140
+ const nice = unit <= 1 ? 1 : unit <= 2 ? 2 : unit <= 5 ? 5 : 10;
141
+ return Number((nice * pow).toPrecision(6));
142
+ }
143
+ function limit(min, max, rest, whole) {
144
+ const step = whole ? Math.max(1, Math.round(sliderStep(min, max))) : sliderStep(min, max);
145
+ return { min, max, step, default: Math.min(max, Math.max(min, rest)) };
146
+ }
147
+ function resolveQuickAgentLimits(model, knobs) {
148
+ const t = model?.temperature;
149
+ const p = model?.top_p;
150
+ const m = model?.max_output_tokens;
151
+ const tMin = isNum(t?.min) ? t.min : 0;
152
+ const tMax = isNum(t?.max) ? t.max : knobs.temperatureMax;
153
+ const tRest = isNum(t?.default) ? t.default : knobs.temperatureDefault;
154
+ const pMin = isNum(p?.min) ? p.min : 0;
155
+ const pMax = isNum(p?.max) ? p.max : 1;
156
+ const pRest = isNum(p?.default) ? p.default : knobs.topPDefault;
157
+ const mMin = isNum(m?.min) ? m.min : knobs.maxOutputMin;
158
+ const mMax = isNum(m?.max) ? m.max : knobs.maxOutputMax;
159
+ const mRest = isNum(m?.default) ? m.default : knobs.maxOutputDefault;
160
+ if (!isNum(tMax) || !isNum(tRest) || !isNum(pRest) || !isNum(mMin) || !isNum(mMax) || !isNum(mRest)) return null;
161
+ if (tMax <= tMin || pMax <= pMin || mMax <= mMin) return null;
162
+ return {
163
+ temperature: limit(tMin, tMax, tRest, false),
164
+ topP: limit(pMin, pMax, pRest, false),
165
+ maxOutputTokens: limit(mMin, mMax, mRest, true)
166
+ };
167
+ }
168
+ function defaultQuickAgentSettings(limits) {
169
+ return { temperature: limits.temperature.default, topP: limits.topP.default, maxOutputTokens: limits.maxOutputTokens.default };
170
+ }
14
171
  function clamp(value, bound) {
15
172
  if (!Number.isFinite(value)) return bound.min;
16
173
  return Math.min(bound.max, Math.max(bound.min, value));
17
174
  }
18
- function clampQuickAgentSettings(settings) {
175
+ function clampQuickAgentSettings(settings, limits) {
19
176
  return {
20
- temperature: clamp(settings.temperature, QUICK_AGENT_BOUNDS.temperature),
21
- topP: clamp(settings.topP, QUICK_AGENT_BOUNDS.topP),
22
- maxOutputTokens: Math.round(clamp(settings.maxOutputTokens, QUICK_AGENT_BOUNDS.maxOutputTokens))
177
+ temperature: clamp(settings.temperature, limits.temperature),
178
+ topP: clamp(settings.topP, limits.topP),
179
+ maxOutputTokens: Math.round(clamp(settings.maxOutputTokens, limits.maxOutputTokens))
23
180
  };
24
181
  }
25
182
  function quickAgentProblems(def) {
@@ -30,44 +187,31 @@ function quickAgentProblems(def) {
30
187
  return problems;
31
188
  }
32
189
  function quickAgentSettingsJson(settings) {
33
- const s = clampQuickAgentSettings(settings);
34
- return { stream: true, temperature: s.temperature, top_p: s.topP, max_output_tokens: s.maxOutputTokens };
190
+ return { stream: true, temperature: settings.temperature, top_p: settings.topP, max_output_tokens: settings.maxOutputTokens };
35
191
  }
36
192
  function quickAgentMessages(systemPrompt) {
37
193
  return [{ role: "system", content: [{ type: "text", text: systemPrompt }] }];
38
194
  }
39
- function buildQuickAgentRow(def, owner) {
195
+ function quickAgentFields(def) {
40
196
  return {
41
- agent_type: "user",
42
197
  name: def.name.trim(),
43
- description: null,
44
198
  tags: [QUICK_AGENT_TAG],
45
- is_active: true,
46
- is_archived: false,
47
- model_id: def.modelId,
199
+ isActive: true,
200
+ isArchived: false,
201
+ modelId: def.modelId,
48
202
  messages: quickAgentMessages(def.systemPrompt),
49
203
  settings: quickAgentSettingsJson(def.settings),
50
- tools: [],
51
- metadata: { kind: QUICK_AGENT_KIND },
52
- created_by: owner.userId,
53
- organization_id: owner.organizationId
54
- };
55
- }
56
- function buildQuickAgentUpdate(def) {
57
- return {
58
- name: def.name.trim(),
59
- model_id: def.modelId,
60
- messages: quickAgentMessages(def.systemPrompt),
61
- settings: quickAgentSettingsJson(def.settings)
204
+ tools: []
62
205
  };
63
206
  }
64
207
  function num(value, fallback) {
65
208
  return typeof value === "number" && Number.isFinite(value) ? value : fallback;
66
209
  }
67
- function quickAgentFromRow(row) {
210
+ function quickAgentFromRow(row, defaults) {
68
211
  if (!row) return null;
69
212
  const metadata = row["metadata"];
70
- if (metadata?.["kind"] !== QUICK_AGENT_KIND) return null;
213
+ const tags = Array.isArray(row["tags"]) ? row["tags"] : [];
214
+ if (metadata?.["kind"] !== QUICK_AGENT_KIND && !tags.includes(QUICK_AGENT_TAG)) return null;
71
215
  const messages = Array.isArray(row["messages"]) ? row["messages"] : [];
72
216
  const system = messages.find((m) => m["role"] === "system");
73
217
  const parts = Array.isArray(system?.["content"]) ? system?.["content"] : [];
@@ -78,75 +222,54 @@ function quickAgentFromRow(row) {
78
222
  name: typeof row["name"] === "string" ? row["name"] : "",
79
223
  systemPrompt,
80
224
  modelId: typeof row["model_id"] === "string" ? row["model_id"] : "",
81
- settings: clampQuickAgentSettings({
82
- temperature: num(raw["temperature"], QUICK_AGENT_DEFAULT_SETTINGS.temperature),
83
- topP: num(raw["top_p"], QUICK_AGENT_DEFAULT_SETTINGS.topP),
84
- maxOutputTokens: num(raw["max_output_tokens"], QUICK_AGENT_DEFAULT_SETTINGS.maxOutputTokens)
85
- })
225
+ settings: {
226
+ temperature: num(raw["temperature"], defaults.temperature),
227
+ topP: num(raw["top_p"], defaults.topP),
228
+ maxOutputTokens: num(raw["max_output_tokens"], defaults.maxOutputTokens)
229
+ }
86
230
  };
87
231
  }
88
232
  function isQuickAgentSummary(row) {
89
233
  return row.tags.includes(QUICK_AGENT_TAG);
90
234
  }
235
+ function listQuickAgents(rows, userId) {
236
+ const live = (row) => isQuickAgentSummary(row) && !row.isArchived && row.isActive !== false;
237
+ const user = selectUserTypeAgents(rows).filter(live);
238
+ const mine = userId ? user.filter((row) => row.createdBy === userId) : [];
239
+ const organization = user.filter((row) => !mine.includes(row));
240
+ const system = selectBuiltinTypeAgents(rows).filter(live);
241
+ return { mine, organization, system };
242
+ }
91
243
  function listMyQuickAgents(rows, userId) {
92
- if (!userId) return [];
93
- return rows.filter((row) => isQuickAgentSummary(row) && row.createdBy === userId && !row.isArchived && row.isActive !== false);
244
+ const lanes = listQuickAgents(rows, userId);
245
+ return [...lanes.mine, ...lanes.organization, ...lanes.system];
94
246
  }
95
247
  function withoutQuickAgents(rows) {
96
248
  return rows.filter((row) => !isQuickAgentSummary(row));
97
249
  }
98
250
 
99
- // quick/writes.ts
100
- function refuse(def) {
101
- const problems = quickAgentProblems(def);
102
- if (problems.length > 0) throw new Error(problems[0]);
103
- }
104
- function fail(error) {
105
- throw new Error(error?.message ?? "The agent could not be saved.");
106
- }
107
- var table = (client) => client.schema("agent").from("definition");
108
- async function createQuickAgent(client, def, owner) {
109
- refuse(def);
110
- const { data, error } = await table(client).insert(buildQuickAgentRow(def, owner)).select().single();
111
- if (error) fail(error);
112
- const saved = quickAgentFromRow(data);
113
- if (!saved) fail(null);
114
- return saved;
115
- }
116
- async function updateQuickAgent(client, id, def) {
117
- refuse(def);
118
- const { data, error } = await table(client).update(buildQuickAgentUpdate(def)).eq("id", id).select().single();
119
- if (error) fail(error);
120
- const saved = quickAgentFromRow(data);
121
- if (!saved) fail(null);
122
- return saved;
123
- }
124
- async function deleteQuickAgent(client, id) {
125
- const { error } = await table(client).update({ deleted_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id);
126
- if (error) fail(error);
127
- }
128
- async function readQuickAgent(client, id) {
129
- const { data, error } = await table(client).select("id,name,model_id,messages,settings,metadata").eq("id", id).is("deleted_at", null).maybeSingle();
130
- if (error) fail(error);
131
- return quickAgentFromRow(data);
251
+ // quick/reads.ts
252
+ async function readQuickAgent(client, id, defaults) {
253
+ const { data, error } = await client.schema("agent").from("definition").select("id,name,model_id,messages,settings,tags,metadata").eq("id", id).is("deleted_at", null).maybeSingle();
254
+ if (error) throw new Error(error.message ?? "The agent could not be read.");
255
+ return quickAgentFromRow(data, defaults);
132
256
  }
133
257
  export {
134
- QUICK_AGENT_BOUNDS,
135
- QUICK_AGENT_DEFAULT_SETTINGS,
136
258
  QUICK_AGENT_KIND,
259
+ QUICK_AGENT_KNOBS,
137
260
  QUICK_AGENT_TAG,
138
- buildQuickAgentRow,
139
- buildQuickAgentUpdate,
140
261
  clampQuickAgentSettings,
141
- createQuickAgent,
142
- deleteQuickAgent,
262
+ defaultQuickAgentSettings,
143
263
  isQuickAgentSummary,
144
264
  listMyQuickAgents,
265
+ listQuickAgents,
266
+ quickAgentFields,
145
267
  quickAgentFromRow,
146
268
  quickAgentMessages,
147
269
  quickAgentProblems,
148
270
  quickAgentSettingsJson,
149
271
  readQuickAgent,
150
- updateQuickAgent,
272
+ resolveQuickAgentLimits,
273
+ sliderStep,
151
274
  withoutQuickAgents
152
275
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/agents",
3
- "version": "0.59.228",
3
+ "version": "0.59.230",
4
4
  "description": "Portable AI Matrx agent stream protocol, event projection, and safe result-presentation primitives.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -511,11 +511,11 @@
511
511
  "@ai-matrx/alchemy": "latest",
512
512
  "@ai-matrx/associations": "latest",
513
513
  "@ai-matrx/api": "latest",
514
+ "@ai-matrx/content-ir": "latest",
514
515
  "@ai-matrx/data": "latest",
515
516
  "@ai-matrx/design-system": "latest",
516
- "@ai-matrx/content-ir": "latest",
517
- "@ai-matrx/diff": "latest",
518
517
  "@ai-matrx/icons": "latest",
518
+ "@ai-matrx/diff": "latest",
519
519
  "@ai-matrx/kit": "latest"
520
520
  },
521
521
  "peerDependencies": {
@@ -561,5 +561,5 @@
561
561
  "verify:tarball": "node ./scripts/verify-tarball.mjs",
562
562
  "typegen:self-test": "node scripts/typegen/drop-guard.self-test.mjs && node scripts/typegen/check-api-types-fresh.mjs --self-test"
563
563
  },
564
- "gitHead": "b18bc55fbafb8d6529da4a296f7221c0bc6458d2"
564
+ "gitHead": "35a306a12eb221459872bac8ef0b97639a997020"
565
565
  }