@m6d/cortex 0.2.0 → 0.3.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/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  errorEnvelope,
13
13
  isRecord,
14
14
  unescapePointerToken
15
- } from "./index-z0594rs3.js";
15
+ } from "./index-dck60t84.js";
16
16
 
17
17
  // src/server.ts
18
18
  import { createHash, timingSafeEqual } from "node:crypto";
@@ -7085,10 +7085,8 @@ var BUILT_IN_TOOL_NAMES = [
7085
7085
  "queryDataset",
7086
7086
  "readAttachment",
7087
7087
  "readReport",
7088
- "searchKnowledge",
7089
- "searchServices",
7088
+ "searchRegistries",
7090
7089
  "searchThreadHistory",
7091
- "searchTools",
7092
7090
  REQUEST_LOCATION_TOOL,
7093
7091
  TRIGGER_ANSWER_TOOL_NAME
7094
7092
  ];
@@ -7531,7 +7529,10 @@ function canCarrySecret(url, allowed = egressAllowedHosts()) {
7531
7529
  // ../../internal/contracts/src/manifest/index.ts
7532
7530
  var TOOL_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
7533
7531
  var RESPONSE_WRAPS = ["items", "value"];
7532
+ var QUERY_STYLES = ["form", "spaceDelimited", "pipeDelimited", "deepObject"];
7533
+ var PATH_STYLES = ["simple", "label", "matrix"];
7534
7534
  var SOAP_VERSIONS = ["1.1", "1.2"];
7535
+ var jsonPointerSchema = z4.string().regex(/^\//).max(256);
7535
7536
  var SETTING_BOUNDS = {
7536
7537
  tool: {
7537
7538
  timeoutMs: { min: 100, max: 120000, default: 30000 },
@@ -7562,6 +7563,9 @@ var SETTING_BOUNDS = {
7562
7563
  function setting({ min, max, default: fallback }) {
7563
7564
  return z4.number().int().min(min).max(max).default(fallback);
7564
7565
  }
7566
+ function overridable(fields) {
7567
+ return z4.array(z4.enum(fields)).refine(uniqueBy((field) => field), "a field repeats").default([]);
7568
+ }
7565
7569
  var SLUG_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
7566
7570
  var slugSchema = z4.string().regex(SLUG_PATTERN).max(64);
7567
7571
  var HOSTNAME_PATTERN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/;
@@ -7579,8 +7583,16 @@ var tlsUrlSchema = z4.url().refine((url) => canCarrySecret(url, []));
7579
7583
  var embedOriginSchema = tlsUrlSchema.transform((value) => new URL(value).origin);
7580
7584
  var soapActionSchema = z4.string().regex(/^[^"\\\u0000-\u001f\u007f]*$/);
7581
7585
  var envelopeTemplateSchema = z4.string().refine((template) => template.trim().length > 0);
7586
+ var FORM_MEDIA_TYPES = [
7587
+ "application/x-www-form-urlencoded",
7588
+ "multipart/form-data"
7589
+ ];
7582
7590
  var toolConfigByType = {
7583
- http: z4.object({ responseWrap: z4.enum(RESPONSE_WRAPS).optional() }),
7591
+ http: z4.object({
7592
+ responseWrap: z4.enum(RESPONSE_WRAPS).optional(),
7593
+ requestMediaType: z4.enum(FORM_MEDIA_TYPES).optional(),
7594
+ resultPath: jsonPointerSchema.optional()
7595
+ }),
7584
7596
  embedded: z4.object({ embedOrigin: embedOriginSchema, surface: z4.enum(TOOL_SURFACES) }),
7585
7597
  soap: z4.object({
7586
7598
  soapVersion: z4.enum(SOAP_VERSIONS),
@@ -7679,11 +7691,30 @@ function sourceFits(source, field) {
7679
7691
  }
7680
7692
  }
7681
7693
  var fieldTargetSchema = z4.discriminatedUnion("kind", [
7682
- z4.object({ kind: z4.literal("body") }),
7683
- z4.object({ kind: z4.literal("query"), name: z4.string().trim().min(1).max(120).optional() }),
7684
- z4.object({ kind: z4.literal("path") }),
7685
- z4.object({ kind: z4.literal("header"), name: headerNameSchema.optional() }),
7686
- z4.object({ kind: z4.literal("cookie"), name: headerNameSchema.optional() })
7694
+ z4.strictObject({
7695
+ kind: z4.literal("body"),
7696
+ contentType: z4.enum(["application/json", "text/plain"]).optional(),
7697
+ style: z4.enum(QUERY_STYLES).optional(),
7698
+ explode: z4.boolean().optional()
7699
+ }),
7700
+ z4.strictObject({
7701
+ kind: z4.literal("query"),
7702
+ name: z4.string().trim().min(1).max(120).optional(),
7703
+ style: z4.enum(QUERY_STYLES).optional(),
7704
+ explode: z4.boolean().optional()
7705
+ }),
7706
+ z4.strictObject({
7707
+ kind: z4.literal("path"),
7708
+ name: z4.string().trim().min(1).max(120).optional(),
7709
+ style: z4.enum(PATH_STYLES).optional(),
7710
+ explode: z4.boolean().optional()
7711
+ }),
7712
+ z4.strictObject({
7713
+ kind: z4.literal("header"),
7714
+ name: headerNameSchema.optional(),
7715
+ explode: z4.boolean().optional()
7716
+ }),
7717
+ z4.strictObject({ kind: z4.literal("cookie"), name: headerNameSchema.optional() })
7687
7718
  ]);
7688
7719
  var SCALAR_TYPES = ["string", "number", "integer", "boolean"];
7689
7720
  var schemaTypeSchema = z4.enum([...SCALAR_TYPES, "object", "array"]);
@@ -7754,13 +7785,17 @@ function propertyIssues(property, bindable) {
7754
7785
  });
7755
7786
  }
7756
7787
  const binds = bindable && SCALAR_TYPES.some((scalar) => scalar === type);
7757
- for (const binding of ["x-source", "x-target"]) {
7758
- if (property[binding] !== undefined && !binds) {
7759
- issues.push({
7760
- at: [binding],
7761
- message: "only a top-level scalar field of a tool's input has it"
7762
- });
7763
- }
7788
+ if (property["x-source"] !== undefined && !binds) {
7789
+ issues.push({
7790
+ at: ["x-source"],
7791
+ message: "only a top-level scalar field of a tool's input has it"
7792
+ });
7793
+ }
7794
+ if (property["x-target"] !== undefined && !bindable) {
7795
+ issues.push({
7796
+ at: ["x-target"],
7797
+ message: "only a top-level field of a tool's input has it"
7798
+ });
7764
7799
  }
7765
7800
  const source = property["x-source"];
7766
7801
  if (binds && source && !sourceFits(source, { type, enum: property.enum })) {
@@ -7818,7 +7853,16 @@ var toolBaseSchema = z4.strictObject({
7818
7853
  projectOutput: z4.boolean().default(false),
7819
7854
  pinned: z4.boolean().default(false),
7820
7855
  tags: toolTagsSchema.default([]),
7821
- audience: audienceSchema
7856
+ audience: audienceSchema,
7857
+ overridable: overridable([
7858
+ "description",
7859
+ "timeoutMs",
7860
+ "maxResponseBytes",
7861
+ "rateLimitRequests",
7862
+ "rateLimitWindowSeconds",
7863
+ "pinned",
7864
+ "tags"
7865
+ ])
7822
7866
  });
7823
7867
  var calledToolSchema = toolBaseSchema.extend({
7824
7868
  inputSchema: objectSchemaOf(true).default(EMPTY_OBJECT),
@@ -7853,6 +7897,7 @@ var manifestOpenApiSchema = z4.strictObject({
7853
7897
  name: nameSchema,
7854
7898
  url: upstreamUrlSchema,
7855
7899
  credentials: credentialsSchema,
7900
+ resultPath: jsonPointerSchema.optional(),
7856
7901
  pinned: toolNamesSchema,
7857
7902
  approval: z4.strictObject({ never: toolNamesSchema, always: toolNamesSchema }).prefault({}).refine(({ never, always }) => !never.some((name) => always.includes(name)), "a tool both never and always needs approval"),
7858
7903
  audience: audienceSchema
@@ -7861,20 +7906,22 @@ var manifestServiceSchema = z4.strictObject({
7861
7906
  key: slugSchema,
7862
7907
  name: localizedLineSchema,
7863
7908
  description: localizedTextSchema,
7864
- audience: audienceSchema
7909
+ audience: audienceSchema,
7910
+ overridable: overridable(["description"])
7865
7911
  });
7866
7912
  var manifestSkillSchema = z4.strictObject({
7867
7913
  name: slugSchema,
7868
7914
  description: z4.string().trim().min(1).max(500),
7869
7915
  body: z4.string().trim().min(1),
7870
7916
  service: slugSchema.optional(),
7871
- audience: audienceSchema
7917
+ audience: audienceSchema,
7918
+ overridable: overridable(["description", "body"])
7872
7919
  });
7873
7920
  var triggerThreadPolicySchema = z4.discriminatedUnion("policy", [
7874
7921
  z4.object({ policy: z4.literal("single") }),
7875
7922
  z4.object({ policy: z4.literal("per-firing") }),
7876
7923
  z4.object({ policy: z4.literal("ephemeral") }),
7877
- z4.object({ policy: z4.literal("keyed"), key: z4.string().regex(/^\//).max(256) })
7924
+ z4.object({ policy: z4.literal("keyed"), key: jsonPointerSchema })
7878
7925
  ]);
7879
7926
  var manifestTriggerSchema = z4.strictObject({
7880
7927
  name: slugSchema.refine((name) => name !== MESSAGE_TRIGGER_NAME, "the built-in trigger's name"),
@@ -7888,7 +7935,15 @@ var manifestTriggerSchema = z4.strictObject({
7888
7935
  credential: nameSchema.optional(),
7889
7936
  fireCredential: nameSchema.optional(),
7890
7937
  model: modelSchema.optional(),
7891
- audience: audienceSchema
7938
+ audience: audienceSchema,
7939
+ overridable: overridable([
7940
+ "description",
7941
+ "instructions",
7942
+ "threadPolicy",
7943
+ "budgetPerDay",
7944
+ "disableAfterFailures",
7945
+ "model"
7946
+ ])
7892
7947
  });
7893
7948
  function unexposedPins(host) {
7894
7949
  const exposed = new Set(host.expose);
@@ -7901,7 +7956,8 @@ var manifestDatasetHostSchema = z4.strictObject({
7901
7956
  timeoutMs: setting(SETTING_BOUNDS.datasetHost.timeoutMs),
7902
7957
  expose: z4.array(datasetIdentifierSchema).min(1).max(500),
7903
7958
  pinned: z4.array(datasetIdentifierSchema).max(50).default([]),
7904
- audience: audienceSchema
7959
+ audience: audienceSchema,
7960
+ overridable: overridable(["timeoutMs"])
7905
7961
  }).superRefine((host, context) => {
7906
7962
  const unexposed = unexposedPins(host);
7907
7963
  if (unexposed.length > 0) {
@@ -7919,7 +7975,8 @@ var manifestMcpServerSchema = z4.strictObject({
7919
7975
  credentials: presentationsSchema(presentedHeaderSchema.refine((name) => !mcpTransportHeaders.has(name.toLowerCase()), "a header the MCP transport sets"), nameSchema.nullable()),
7920
7976
  include: mcpToolNamesSchema.default([]),
7921
7977
  exclude: mcpToolNamesSchema.default([]),
7922
- audience: audienceSchema
7978
+ audience: audienceSchema,
7979
+ overridable: overridable(["include", "exclude"])
7923
7980
  });
7924
7981
  var manifestWebhookSchema = z4.strictObject({
7925
7982
  name: slugSchema,
@@ -7928,13 +7985,16 @@ var manifestWebhookSchema = z4.strictObject({
7928
7985
  url: upstreamUrlSchema,
7929
7986
  credentials: presentationsSchema(presentedHeaderSchema.refine((name) => name.toLowerCase() !== EVENT_HEADER.toLowerCase(), "the header that names the event"), nameSchema),
7930
7987
  timeoutMs: setting(SETTING_BOUNDS.webhook.timeoutMs),
7931
- audience: audienceSchema
7988
+ audience: audienceSchema,
7989
+ overridable: overridable(["description", "timeoutMs"])
7932
7990
  });
7933
7991
  var manifestCollectionSchema = z4.strictObject({
7934
7992
  name: z4.string().trim().min(1).max(80),
7935
7993
  description: z4.string().trim().max(2000).default(""),
7936
7994
  service: slugSchema.optional(),
7937
- audience: audienceSchema
7995
+ citable: z4.boolean().default(true),
7996
+ audience: audienceSchema,
7997
+ overridable: overridable(["description"])
7938
7998
  });
7939
7999
  var AUTH_JWT_SECRET_ALGORITHMS = ["HS256", "HS384", "HS512"];
7940
8000
  var issuerSchema = z4.string().trim().min(1).max(2048);
@@ -7995,7 +8055,8 @@ var manifestAgentSchema = z4.strictObject({
7995
8055
  }).default({}),
7996
8056
  settings: agentSettingsSchema.prefault({}),
7997
8057
  suggestions: suggestionsSchema.default({ en: [], ar: [] }),
7998
- greeting: greetingSchema.default({ en: "", ar: "" })
8058
+ greeting: greetingSchema.default({ en: "", ar: "" }),
8059
+ overridable: overridable(["name", "prompt", "models", "settings", "suggestions", "greeting"])
7999
8060
  });
8000
8061
  function uniqueBy(key) {
8001
8062
  return (entries) => new Set(entries.map(key)).size === entries.length;
@@ -8017,12 +8078,26 @@ var manifestSchema = z4.strictObject({
8017
8078
  webhooks: listOf(manifestWebhookSchema, byName),
8018
8079
  collections: listOf(manifestCollectionSchema, byName)
8019
8080
  });
8020
- var namesByKindSchema = z4.record(manifestSchema.keyof().exclude(["id", "openapi"]), z4.array(z4.string()));
8081
+ var manifestKindSchema = manifestSchema.keyof().exclude(["id", "openapi"]);
8082
+ var namesByKindSchema = z4.record(manifestKindSchema, z4.array(z4.string()));
8021
8083
  var manifestChangesSchema = z4.object({
8022
8084
  create: namesByKindSchema,
8023
8085
  update: namesByKindSchema,
8024
8086
  delete: namesByKindSchema
8025
8087
  });
8088
+ var manifestConflictSchema = z4.strictObject({
8089
+ kind: manifestKindSchema,
8090
+ name: z4.string(),
8091
+ field: z4.string()
8092
+ });
8093
+ var conflictSideSchema = z4.enum(["live", "manifest"]);
8094
+ var manifestApplyInputSchema = manifestSchema.extend({
8095
+ prefer: conflictSideSchema.optional(),
8096
+ resolutions: z4.array(manifestConflictSchema.extend({ keep: conflictSideSchema })).default([])
8097
+ });
8098
+ var manifestPreviewSchema = manifestChangesSchema.extend({
8099
+ conflicts: z4.array(manifestConflictSchema)
8100
+ });
8026
8101
  var appliedManifestSchema = manifestChangesSchema.extend({
8027
8102
  triggerSecrets: z4.record(z4.string(), z4.string())
8028
8103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m6d/cortex",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Cortex for TypeScript backends: serve the server protocol and dataset hosts, and fire triggers",
5
5
  "license": "MIT",
6
6
  "type": "module",