@m6d/cortex-cli 0.25.0 → 0.25.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m6d/cortex-cli",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Scaffold Cortex projects and manage a Cortex deployment",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -3853,7 +3853,7 @@ export type ManagementProcedures = {
3853
3853
  id: string;
3854
3854
  kind: "turn" | "subagent" | "tool";
3855
3855
  status: "running" | "waiting" | "completed" | "failed" | "cancelled";
3856
- reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | null;
3856
+ reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | "output_limit" | null;
3857
3857
  createdAt: string;
3858
3858
  finishedAt: string | null;
3859
3859
  source: "user" | "trigger" | "schedule" | "run" | null;
@@ -4029,7 +4029,7 @@ export type ManagementProcedures = {
4029
4029
  id: string;
4030
4030
  kind: "turn" | "subagent" | "tool";
4031
4031
  status: "running" | "waiting" | "completed" | "failed" | "cancelled";
4032
- reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | null;
4032
+ reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | "output_limit" | null;
4033
4033
  createdAt: string;
4034
4034
  finishedAt: string | null;
4035
4035
  source: "user" | "trigger" | "schedule" | "run" | null;
@@ -6208,7 +6208,7 @@ export type ManagementProcedures = {
6208
6208
  kind: "turn" | "subagent" | "tool";
6209
6209
  subagentRunId: string | null;
6210
6210
  status: "running" | "waiting" | "completed" | "failed" | "cancelled";
6211
- reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | null;
6211
+ reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | "output_limit" | null;
6212
6212
  result: unknown;
6213
6213
  waits: Array<{
6214
6214
  kind: "approval" | "client_tool";
@@ -6292,7 +6292,7 @@ export type ManagementProcedures = {
6292
6292
  kind: "turn" | "subagent" | "tool";
6293
6293
  subagentRunId: string | null;
6294
6294
  status: "running" | "waiting" | "completed" | "failed" | "cancelled";
6295
- reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | null;
6295
+ reason: "no_output" | "invalid_output" | "stopped" | "cancelled" | "parent_cancelled" | "lost" | "timeout" | "output_limit" | null;
6296
6296
  result: unknown;
6297
6297
  waits: Array<{
6298
6298
  kind: "approval" | "client_tool";
@@ -14,7 +14,8 @@ export type RunStatus = (typeof RUN_STATUSES)[number];
14
14
  /**
15
15
  * Why a run ended as it did: a trigger's answer that never came or never
16
16
  * fit its schema, a stop, a cancel (its own, or its parent's), a producer
17
- * that died (`lost`), or one that ran out of time.
17
+ * that died (`lost`), one that ran out of time, or a model answer the
18
+ * output limit cut off (`output_limit`).
18
19
  */
19
20
  export const RUN_REASONS = [
20
21
  "no_output",
@@ -24,6 +25,7 @@ export const RUN_REASONS = [
24
25
  "parent_cancelled",
25
26
  "lost",
26
27
  "timeout",
28
+ "output_limit",
27
29
  ] as const;
28
30
  export type RunReason = (typeof RUN_REASONS)[number];
29
31
 
@@ -8,6 +8,7 @@
8
8
  * alike.
9
9
  */
10
10
 
11
+ import { isRecord } from "../json/index";
11
12
  import type { RunReason, RunStatus } from "../runs/index";
12
13
 
13
14
  /** The UI locales every localized value is keyed by; the console's message catalogs follow it. */
@@ -335,6 +336,58 @@ export function approvalTitleOf(input: unknown) {
335
336
  return modelLineOf(input, APPROVAL_TITLE_FIELD);
336
337
  }
337
338
 
339
+ /** One input field an approval tool's schema declares (`ApprovalInput`). */
340
+ export type ApprovalField = {
341
+ name: string;
342
+ /** The field may carry a secret: it, anything inside it, or anything containing it is marked `x-sensitive`. */
343
+ sensitive?: true;
344
+ /** Cortex fills the field itself and refuses a call that writes it, so no card shows it. */
345
+ sourced?: true;
346
+ };
347
+
348
+ /** How the calls of a tool that waits for the user's approval show their input (`ToolCallMetadata.approvalInput`). */
349
+ export type ApprovalInput = {
350
+ /** The fields its schema declares, in its order. */
351
+ fields: ApprovalField[];
352
+ /** Any other key the model writes may carry a secret, as the schemas that would admit it say. */
353
+ extraSensitive?: true;
354
+ };
355
+
356
+ /**
357
+ * Each key of a call's input as its tool's `approval` classes it, with its
358
+ * value: the declared fields the input holds, in the tool's order, then the
359
+ * keys the model added, in its. The title, which the card shows apart, is
360
+ * none of them.
361
+ */
362
+ export function approvalKeysOf(input: unknown, approval: ApprovalInput | undefined) {
363
+ if (!isRecord(input) || !approval) return [];
364
+ const declared = new Set(approval.fields.map(({ name }) => name));
365
+ const extra = Object.keys(input).filter(
366
+ (name) => !declared.has(name) && name !== APPROVAL_TITLE_FIELD,
367
+ );
368
+ return approval.fields
369
+ .filter(({ name }) => Object.hasOwn(input, name))
370
+ .concat(
371
+ extra.map((name) => ({
372
+ name,
373
+ ...(approval.extraSensitive && { sensitive: true as const }),
374
+ })),
375
+ )
376
+ .map((field) => ({ ...field, value: input[field.name] }));
377
+ }
378
+
379
+ /**
380
+ * What a call the user decides on will run with: every key it forwards
381
+ * (`approvalKeysOf`) but the fields Cortex fills. A sensitive one says only
382
+ * that it is set (`hidden`), never its value.
383
+ */
384
+ export function approvalEntriesOf(input: unknown, approval: ApprovalInput | undefined) {
385
+ return approvalKeysOf(input, approval).flatMap(({ name, value, sensitive, sourced }) => {
386
+ if (sourced) return [];
387
+ return [sensitive ? { name, hidden: true as const } : { name, value }];
388
+ });
389
+ }
390
+
338
391
  /**
339
392
  * What Cortex stamps on a tool call's `metadata.cortex` from its first chunk,
340
393
  * so the live part and the stored one agree.
@@ -355,6 +408,12 @@ export type ToolCallMetadata = {
355
408
  * live run asked it.
356
409
  */
357
410
  paused?: { runId: string; interrupt: RunInterrupt };
411
+ /**
412
+ * Set on a call of a tool that waits for the user's approval: how its card shows the
413
+ * input (`approvalEntriesOf`) while the call waits. Every view of the call leaves a
414
+ * sensitive key's value out.
415
+ */
416
+ approvalInput?: ApprovalInput;
358
417
  };
359
418
 
360
419
  /** An interrupt as a paused run raises it on its end, in AG-UI's shape. */
@@ -28,7 +28,7 @@ import { applyPorts, type Ports } from "@/scaffold/ports";
28
28
  * `@m6d/cortex` range below are stamped by scripts/sync-package-versions.ts
29
29
  * before the CLI publishes, so a scaffold pins what was current then.
30
30
  */
31
- const CORTEX_VERSION = "0.24.0";
31
+ const CORTEX_VERSION = "0.24.1";
32
32
 
33
33
  /** This machine as Cortex's containers name it: the one private host the stack's egress policy admits. */
34
34
  export const DOCKER_HOST = "host.docker.internal";
@@ -147,7 +147,7 @@ function packageJson({ name, datasets, setup }: Project) {
147
147
  verify: "bun run format:check && bun run lint && bun run spellcheck && bun run check && bun run audit",
148
148
  },
149
149
  dependencies: {
150
- "@m6d/cortex": "~0.12.0",
150
+ "@m6d/cortex": "~0.12.1",
151
151
  // drizzle 1.0 is in beta; this is the build `@m6d/cortex/drizzle` is tested against.
152
152
  ...(datasets ? { "drizzle-orm": "1.0.0-beta.15-859cf75" } : {}),
153
153
  hono: "^4.12.3",