@m6d/cortex-cli 1.9.0 → 1.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m6d/cortex-cli",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "Scaffold and operate Cortex servers",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,9 +15,9 @@ export const TOOL_NAME_PATTERN = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
15
15
 
16
16
  /**
17
17
  * A variable the server fills per request: a session value, a request-context
18
- * value, or one the SDK computes. Declared per agent so the console offers
19
- * exactly what that agent's server provides, in prompts and as tool input
20
- * sources alike.
18
+ * value, or one the SDK computes. Declared once per server so the console
19
+ * offers exactly what that server provides to the agents created on it, in
20
+ * prompts and as tool input sources alike.
21
21
  */
22
22
  export const variableDeclarationSchema = z.object({
23
23
  name: z
@@ -30,6 +30,25 @@ export const variableDeclarationSchema = z.object({
30
30
  computed: z.boolean().default(false),
31
31
  });
32
32
 
33
+ /**
34
+ * Variables the SDK itself fills for every agent, listed first in a server's
35
+ * declaration so the console offers them like any consumer-declared one.
36
+ */
37
+ export const SDK_VARIABLES = [
38
+ {
39
+ name: "utcTime",
40
+ description: "Current time in UTC (ISO 8601)",
41
+ example: "2026-09-12T08:30:00Z",
42
+ computed: true,
43
+ },
44
+ {
45
+ name: "locale",
46
+ description: "Resolved locale of the session",
47
+ example: "ar",
48
+ computed: true,
49
+ },
50
+ ] as const satisfies ReadonlyArray<z.infer<typeof variableDeclarationSchema>>;
51
+
33
52
  export const RUNTIME_ERROR_KINDS = [
34
53
  "timeout",
35
54
  "upstream_4xx",
@@ -48,6 +67,43 @@ export const JSON_SCHEMA_ISSUE_KINDS = ["missing", "unexpected", "type_mismatch"
48
67
 
49
68
  export const agentSlugSchema = z.string().regex(AGENT_SLUG_PATTERN);
50
69
  export const localeSchema = z.enum(["en", "ar"]);
70
+
71
+ /**
72
+ * The widget's landing-page prompt chips, per locale. Every source of them
73
+ * (the Control Center agent row, a server-code override, the capabilities
74
+ * handshake) stores this exact shape, so the widget never sees a blank or
75
+ * unbounded chip whichever source won. Pure validation, no transforms: a
76
+ * value that passes is served verbatim, so each source trims before it
77
+ * stores.
78
+ */
79
+ export const SUGGESTION_LIMITS = { perLocale: 6, chipLength: 200 } as const;
80
+ export const suggestionsSchema = z.record(
81
+ localeSchema,
82
+ z
83
+ .array(
84
+ z
85
+ .string()
86
+ .min(1)
87
+ .max(SUGGESTION_LIMITS.chipLength)
88
+ .refine((chip) => chip === chip.trim(), "chip has surrounding whitespace"),
89
+ )
90
+ .max(SUGGESTION_LIMITS.perLocale),
91
+ );
92
+ export type Suggestions = z.infer<typeof suggestionsSchema>;
93
+
94
+ /**
95
+ * The blank-chat landing's headline per locale. Empty means the widget's
96
+ * built-in default for that locale; like suggestions, served verbatim.
97
+ */
98
+ export const GREETING_MAX_LENGTH = 200;
99
+ export const greetingSchema = z.record(
100
+ localeSchema,
101
+ z
102
+ .string()
103
+ .max(GREETING_MAX_LENGTH)
104
+ .refine((text) => text === text.trim(), "greeting has surrounding whitespace"),
105
+ );
106
+ export type Greeting = z.infer<typeof greetingSchema>;
51
107
  export const catalogVersionSchema = z.string().regex(/^[0-9a-f]{16}$/);
52
108
 
53
109
  export const sharedShapeSchema = z.object({
@@ -252,19 +308,13 @@ export const triggerDeclarationSchema = z.object({
252
308
  });
253
309
 
254
310
  /**
255
- * What a server runs for one agent, sent whole at boot in `agent.declare`. An
256
- * agent exists in the Control Center only through a declaration, and only
257
- * its declaring server may serve it. Everything the console validates
258
- * against (variables, code skills, code triggers) is here rather than
259
- * assumed.
311
+ * What a server offers every agent the Control Center creates for it, sent
312
+ * whole at boot in `server.declare`: the `{{variables}}` its session loader
313
+ * and request context fill, SDK ones included. Agents in the server's own
314
+ * code never appear here; the Control Center is blind to them.
260
315
  */
261
- export const agentDeclarationSchema = z.object({
262
- slug: agentSlugSchema,
316
+ export const serverDeclarationSchema = z.object({
263
317
  variables: z.array(variableDeclarationSchema),
264
- skills: z.array(skillLineSchema),
265
- triggers: z.array(
266
- triggerDeclarationSchema.pick({ name: true, description: true, input: true, thread: true }),
267
- ),
268
318
  });
269
319
 
270
320
  export const triggerFiringResponseSchema = z.discriminatedUnion("outcome", [
@@ -370,6 +420,10 @@ export const runtimeAgentConfigSchema = z.object({
370
420
  triggers: z.array(triggerDeclarationSchema).default([]),
371
421
  /** Whether end users may message this agent; false makes it headless. */
372
422
  messageTrigger: z.boolean().default(true),
423
+ /** Operational like `messageTrigger`: edited on the agent row without republishing. */
424
+ suggestions: suggestionsSchema,
425
+ /** Operational like `suggestions`. */
426
+ greeting: greetingSchema,
373
427
  /** Absent from older Control Centers; reports then carry only the slug. */
374
428
  agentRef: agentRefSchema.optional(),
375
429
  catalogVersion: catalogVersionSchema,
@@ -582,13 +636,12 @@ export const syncEventSchema = z.discriminatedUnion("type", [
582
636
  createdAt: z.iso.datetime(),
583
637
  finishedAt: z.iso.datetime().nullable(),
584
638
  }),
585
- // Everything the server runs, sent whole at boot. Replaces the server's
586
- // previous declaration, so an agent removed from code leaves cc with its
587
- // skills and triggers.
639
+ // What the server offers console-created agents, sent whole at boot and
640
+ // replacing the previous declaration.
588
641
  z.object({
589
- type: z.literal("agent.declare"),
642
+ type: z.literal("server.declare"),
590
643
  id: z.uuid(),
591
- agents: z.array(agentDeclarationSchema),
644
+ ...serverDeclarationSchema.shape,
592
645
  createdAt: z.iso.datetime(),
593
646
  }),
594
647
  ]);
@@ -629,7 +682,7 @@ export type ResolveResponse = z.infer<typeof resolveResponseSchema>;
629
682
  export type SkillLine = z.infer<typeof skillLineSchema>;
630
683
  export type SkillBodyResponse = z.infer<typeof skillBodyResponseSchema>;
631
684
  export type TriggerDeclaration = z.infer<typeof triggerDeclarationSchema>;
632
- export type AgentDeclaration = z.infer<typeof agentDeclarationSchema>;
685
+ export type ServerDeclaration = z.infer<typeof serverDeclarationSchema>;
633
686
  export type VariableDeclaration = z.infer<typeof variableDeclarationSchema>;
634
687
  export type TriggerThreadPolicy = z.infer<typeof triggerThreadPolicySchema>;
635
688
  export type TriggerOutcome = (typeof TRIGGER_OUTCOMES)[number];
@@ -99,6 +99,10 @@ export type AgentCapabilities = {
99
99
  attachments: boolean;
100
100
  /** False when the agent's `message` trigger is off: the widget hides its composer. */
101
101
  messages: boolean;
102
+ /** Prompt chips on the blank-chat landing per locale, the runtime contract's `suggestionsSchema` shape; clicking one sends it as the first message. */
103
+ suggestions: Record<"en" | "ar", string[]>;
104
+ /** Headline of the blank-chat landing per locale; "" falls back to the widget's built-in copy. */
105
+ greeting: Record<"en" | "ar", string>;
102
106
  };
103
107
 
104
108
  export type MessageMetadata = {