@m6d/cortex-cli 1.8.0 → 1.9.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
|
@@ -13,42 +13,22 @@ export const AGENT_SLUG_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
|
13
13
|
/** Tool names become `tools.<name>()` sandbox bindings on the server. */
|
|
14
14
|
export const TOOL_NAME_PATTERN = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
15
15
|
|
|
16
|
-
export const PROMPT_VARIABLES = ["userName", "channel", "locale", "utcTime", "timezone"] as const;
|
|
17
|
-
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* key. Descriptions are plain English on purpose: variables are code-like
|
|
24
|
-
* identifiers shown in an LTR suggestion list, not localized UI copy.
|
|
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.
|
|
25
21
|
*/
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
description: "Resolved locale of the session",
|
|
37
|
-
example: "ar",
|
|
38
|
-
},
|
|
39
|
-
// The server computes utcTime per request (a consumer-supplied value
|
|
40
|
-
// still wins); timezone has no server default — only the consumer knows
|
|
41
|
-
// the session's zone, so it must arrive via session/request context or
|
|
42
|
-
// the placeholder stays literal.
|
|
43
|
-
utcTime: {
|
|
44
|
-
description: "Current time in UTC (ISO 8601)",
|
|
45
|
-
example: "2026-08-16T09:30:00Z",
|
|
46
|
-
},
|
|
47
|
-
timezone: {
|
|
48
|
-
description: "IANA time zone of the session",
|
|
49
|
-
example: "Asia/Dubai",
|
|
50
|
-
},
|
|
51
|
-
} satisfies Record<(typeof PROMPT_VARIABLES)[number], { description: string; example: string }>;
|
|
22
|
+
export const variableDeclarationSchema = z.object({
|
|
23
|
+
name: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/)
|
|
26
|
+
.max(64),
|
|
27
|
+
description: z.string().max(500),
|
|
28
|
+
example: z.string().max(200),
|
|
29
|
+
/** Computed by the SDK per request (`utcTime`, `locale`); no session value can set it. */
|
|
30
|
+
computed: z.boolean().default(false),
|
|
31
|
+
});
|
|
52
32
|
|
|
53
33
|
export const RUNTIME_ERROR_KINDS = [
|
|
54
34
|
"timeout",
|
|
@@ -101,6 +81,13 @@ export const toolEmbedSchema = z.object({
|
|
|
101
81
|
embedOrigin: z.url(),
|
|
102
82
|
});
|
|
103
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Variables a tool's input reads (`x-source` of kind `variable` on an input
|
|
86
|
+
* property). The server fills those fields from the agent's declared
|
|
87
|
+
* variables at execute time and the model never sees them.
|
|
88
|
+
*/
|
|
89
|
+
const boundVariablesSchema = z.array(variableDeclarationSchema.shape.name);
|
|
90
|
+
|
|
104
91
|
export const toolSignatureSchema = z.object({
|
|
105
92
|
toolId: z.uuid(),
|
|
106
93
|
name: z.string().regex(TOOL_NAME_PATTERN),
|
|
@@ -110,6 +97,7 @@ export const toolSignatureSchema = z.object({
|
|
|
110
97
|
signature: z.string(),
|
|
111
98
|
score: z.number().nullable(),
|
|
112
99
|
pinned: z.boolean(),
|
|
100
|
+
variables: boundVariablesSchema,
|
|
113
101
|
embed: toolEmbedSchema.optional(),
|
|
114
102
|
/** Client tools only: the published input JSON Schema, verbatim.
|
|
115
103
|
* Client-executed declarations need a real schema — the rendered
|
|
@@ -159,11 +147,22 @@ export const agentRefSchema = z.string().max(128);
|
|
|
159
147
|
*/
|
|
160
148
|
export const AGENT_REF_HEADER = "X-CC-Agent-Ref";
|
|
161
149
|
|
|
150
|
+
/**
|
|
151
|
+
* The playground operator's stand-in for a test thread's session: a
|
|
152
|
+
* URI-encoded JSON object of declared variable values, sent by cc's
|
|
153
|
+
* playground beside `X-Cortex-Playground` and honoured only when that header
|
|
154
|
+
* verifies. The server stores it as the thread's session on creation, so the
|
|
155
|
+
* customer's `loadSessionData` (which never sees cc-minted tokens) is not
|
|
156
|
+
* needed for prompts and tool sources to have values.
|
|
157
|
+
*/
|
|
158
|
+
export const PLAYGROUND_SESSION_HEADER = "X-Cortex-Playground-Session";
|
|
159
|
+
|
|
162
160
|
/** A sandbox binding a piece of rich text mentions, so the turn can register it before the model reads the text. */
|
|
163
161
|
export const mentionedToolSchema = z.object({
|
|
164
162
|
toolId: z.uuid(),
|
|
165
163
|
name: z.string().regex(TOOL_NAME_PATTERN),
|
|
166
164
|
readOnly: z.boolean(),
|
|
165
|
+
variables: boundVariablesSchema,
|
|
167
166
|
});
|
|
168
167
|
|
|
169
168
|
export const skillBodyResponseSchema = z.object({
|
|
@@ -252,6 +251,22 @@ export const triggerDeclarationSchema = z.object({
|
|
|
252
251
|
secretHash: sha256HexSchema,
|
|
253
252
|
});
|
|
254
253
|
|
|
254
|
+
/**
|
|
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.
|
|
260
|
+
*/
|
|
261
|
+
export const agentDeclarationSchema = z.object({
|
|
262
|
+
slug: agentSlugSchema,
|
|
263
|
+
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
|
+
});
|
|
269
|
+
|
|
255
270
|
export const triggerFiringResponseSchema = z.discriminatedUnion("outcome", [
|
|
256
271
|
z.object({
|
|
257
272
|
firingId: z.uuid(),
|
|
@@ -308,7 +323,10 @@ export const triggerAuthResponseSchema = z.discriminatedUnion("ok", [
|
|
|
308
323
|
]);
|
|
309
324
|
|
|
310
325
|
export const runtimeAgentConfigSchema = z.object({
|
|
326
|
+
/** The slug the request used: the agent's own or one of the server's aliases. */
|
|
311
327
|
agentId: agentSlugSchema,
|
|
328
|
+
/** The agent's own slug, the key of its `agents` entry in server code. Equals `agentId` unless an alias was used. */
|
|
329
|
+
slug: agentSlugSchema,
|
|
312
330
|
/**
|
|
313
331
|
* End-user JWT verification for this agent, managed by the agent's owner.
|
|
314
332
|
* Tokens must be asymmetrically signed (the JWKS URI serves the public
|
|
@@ -326,7 +344,8 @@ export const runtimeAgentConfigSchema = z.object({
|
|
|
326
344
|
})
|
|
327
345
|
.optional(),
|
|
328
346
|
systemPrompt: z.string(),
|
|
329
|
-
|
|
347
|
+
/** Every declared variable the published prompt, skills, or triggers reference. */
|
|
348
|
+
promptVariables: z.array(variableDeclarationSchema.shape.name),
|
|
330
349
|
defaultLocale: localeSchema,
|
|
331
350
|
/**
|
|
332
351
|
* Whether end users may upload files to this agent. Operational config
|
|
@@ -425,6 +444,8 @@ export const executeRequestSchema = z.object({
|
|
|
425
444
|
threadId: z.string().max(128).optional(),
|
|
426
445
|
userId: z.string().max(128).optional(),
|
|
427
446
|
locale: localeSchema.optional(),
|
|
447
|
+
/** Values of the variables the tool's input reads; only those names travel. */
|
|
448
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
428
449
|
})
|
|
429
450
|
.optional(),
|
|
430
451
|
});
|
|
@@ -561,17 +582,13 @@ export const syncEventSchema = z.discriminatedUnion("type", [
|
|
|
561
582
|
createdAt: z.iso.datetime(),
|
|
562
583
|
finishedAt: z.iso.datetime().nullable(),
|
|
563
584
|
}),
|
|
564
|
-
//
|
|
565
|
-
//
|
|
566
|
-
//
|
|
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.
|
|
567
588
|
z.object({
|
|
568
|
-
type: z.literal("
|
|
589
|
+
type: z.literal("agent.declare"),
|
|
569
590
|
id: z.uuid(),
|
|
570
|
-
|
|
571
|
-
triggerDeclarationSchema
|
|
572
|
-
.pick({ name: true, description: true, input: true, thread: true })
|
|
573
|
-
.extend({ agentSlug: agentSlugSchema }),
|
|
574
|
-
),
|
|
591
|
+
agents: z.array(agentDeclarationSchema),
|
|
575
592
|
createdAt: z.iso.datetime(),
|
|
576
593
|
}),
|
|
577
594
|
]);
|
|
@@ -612,6 +629,8 @@ export type ResolveResponse = z.infer<typeof resolveResponseSchema>;
|
|
|
612
629
|
export type SkillLine = z.infer<typeof skillLineSchema>;
|
|
613
630
|
export type SkillBodyResponse = z.infer<typeof skillBodyResponseSchema>;
|
|
614
631
|
export type TriggerDeclaration = z.infer<typeof triggerDeclarationSchema>;
|
|
632
|
+
export type AgentDeclaration = z.infer<typeof agentDeclarationSchema>;
|
|
633
|
+
export type VariableDeclaration = z.infer<typeof variableDeclarationSchema>;
|
|
615
634
|
export type TriggerThreadPolicy = z.infer<typeof triggerThreadPolicySchema>;
|
|
616
635
|
export type TriggerOutcome = (typeof TRIGGER_OUTCOMES)[number];
|
|
617
636
|
export type TriggerDropReason = (typeof TRIGGER_DROP_REASONS)[number];
|
|
@@ -21,6 +21,9 @@ export const MAX_ATTACHMENTS_PER_MESSAGE = 5;
|
|
|
21
21
|
|
|
22
22
|
export const ATTACHMENT_STATUSES = ["pending", "described", "failed", "skipped"] as const;
|
|
23
23
|
|
|
24
|
+
/** Who put the file in the thread: the user through the composer, or a tool mid-turn. */
|
|
25
|
+
export const ATTACHMENT_ORIGINS = ["upload", "tool"] as const;
|
|
26
|
+
|
|
24
27
|
export function checkAttachmentPolicy(contentType: string, sizeBytes: number) {
|
|
25
28
|
if (!ATTACHMENT_MIME_TYPES.some((type) => type === contentType)) return "type";
|
|
26
29
|
if (sizeBytes > ATTACHMENT_MAX_BYTES) return "size";
|
|
@@ -29,12 +32,15 @@ export function checkAttachmentPolicy(contentType: string, sizeBytes: number) {
|
|
|
29
32
|
|
|
30
33
|
export type AttachmentStatus = (typeof ATTACHMENT_STATUSES)[number];
|
|
31
34
|
|
|
35
|
+
export type AttachmentOrigin = (typeof ATTACHMENT_ORIGINS)[number];
|
|
36
|
+
|
|
32
37
|
export type AttachmentSummary = {
|
|
33
38
|
id: string;
|
|
34
39
|
filename: string;
|
|
35
40
|
contentType: string;
|
|
36
41
|
sizeBytes: number;
|
|
37
42
|
status: AttachmentStatus;
|
|
43
|
+
origin: AttachmentOrigin;
|
|
38
44
|
description?: string;
|
|
39
45
|
};
|
|
40
46
|
|
|
@@ -81,6 +87,8 @@ export type ClientToolBinding = {
|
|
|
81
87
|
toolId: string;
|
|
82
88
|
surface: "inline" | "modal";
|
|
83
89
|
embedOrigin: string;
|
|
90
|
+
/** Variables the initiate call's input reads. */
|
|
91
|
+
variables: string[];
|
|
84
92
|
};
|
|
85
93
|
|
|
86
94
|
/**
|