@inkeep/agents-cli 0.0.0-dev-20251009010805 → 0.0.0-dev-20251009070204

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.
Files changed (2) hide show
  1. package/dist/index.js +132 -79
  2. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -49,14 +49,14 @@ var init_esm_shims = __esm({
49
49
 
50
50
  // ../packages/agents-core/src/api-client/base-client.ts
51
51
  async function apiFetch(url, options = {}) {
52
- const headers = {
52
+ const headers2 = {
53
53
  "Content-Type": "application/json",
54
54
  Accept: "application/json",
55
55
  ...options.headers || {}
56
56
  };
57
57
  return fetch(url, {
58
58
  ...options,
59
- headers
59
+ headers: headers2
60
60
  });
61
61
  }
62
62
  var init_base_client = __esm({
@@ -66,6 +66,62 @@ var init_base_client = __esm({
66
66
  }
67
67
  });
68
68
 
69
+ // ../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
70
+ import { webcrypto as crypto2 } from "crypto";
71
+ function fillPool(bytes) {
72
+ if (!pool || pool.length < bytes) {
73
+ pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
74
+ crypto2.getRandomValues(pool);
75
+ poolOffset = 0;
76
+ } else if (poolOffset + bytes > pool.length) {
77
+ crypto2.getRandomValues(pool);
78
+ poolOffset = 0;
79
+ }
80
+ poolOffset += bytes;
81
+ }
82
+ function random(bytes) {
83
+ fillPool(bytes |= 0);
84
+ return pool.subarray(poolOffset - bytes, poolOffset);
85
+ }
86
+ function customRandom(alphabet, defaultSize, getRandom) {
87
+ let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
88
+ let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
89
+ return (size = defaultSize) => {
90
+ if (!size) return "";
91
+ let id = "";
92
+ while (true) {
93
+ let bytes = getRandom(step);
94
+ let i2 = step;
95
+ while (i2--) {
96
+ id += alphabet[bytes[i2] & mask] || "";
97
+ if (id.length >= size) return id;
98
+ }
99
+ }
100
+ };
101
+ }
102
+ function customAlphabet(alphabet, size = 21) {
103
+ return customRandom(alphabet, size, random);
104
+ }
105
+ var POOL_SIZE_MULTIPLIER, pool, poolOffset;
106
+ var init_nanoid = __esm({
107
+ "../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js"() {
108
+ "use strict";
109
+ init_esm_shims();
110
+ POOL_SIZE_MULTIPLIER = 128;
111
+ }
112
+ });
113
+
114
+ // ../packages/agents-core/src/utils/conversations.ts
115
+ var generateId;
116
+ var init_conversations = __esm({
117
+ "../packages/agents-core/src/utils/conversations.ts"() {
118
+ "use strict";
119
+ init_esm_shims();
120
+ init_nanoid();
121
+ generateId = customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789", 21);
122
+ }
123
+ });
124
+
69
125
  // ../packages/agents-core/src/utils/logger.ts
70
126
  import pino from "pino";
71
127
  import pinoPretty from "pino-pretty";
@@ -795,8 +851,8 @@ var init_body = __esm({
795
851
  init_request();
796
852
  parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
797
853
  const { all = false, dot = false } = options;
798
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
799
- const contentType = headers.get("Content-Type");
854
+ const headers2 = request instanceof HonoRequest ? request.raw.headers : request.headers;
855
+ const contentType = headers2.get("Content-Type");
800
856
  if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) {
801
857
  return parseFormData(request, { all, dot });
802
858
  }
@@ -1488,9 +1544,8 @@ var init_schema = __esm({
1488
1544
  "context_configs",
1489
1545
  {
1490
1546
  ...graphScoped,
1491
- ...uiProperties,
1492
1547
  // Developer-defined Zod schema for validating incoming request context
1493
- requestContextSchema: blob("request_context_schema", { mode: "json" }).$type(),
1548
+ headersSchema: blob("headers_schema", { mode: "json" }).$type(),
1494
1549
  // Stores serialized Zod schema
1495
1550
  // Object mapping template keys to fetch definitions that use request context data
1496
1551
  contextVariables: blob("context_variables", { mode: "json" }).$type(),
@@ -2723,11 +2778,11 @@ var init_schemas = __esm({
2723
2778
  credential: CredentialReferenceApiInsertSchema.optional()
2724
2779
  });
2725
2780
  ContextConfigSelectSchema = createSelectSchema(contextConfigs).extend({
2726
- requestContextSchema: z2.unknown().optional()
2781
+ headersSchema: z2.unknown().optional()
2727
2782
  });
2728
2783
  ContextConfigInsertSchema = createInsertSchema(contextConfigs).extend({
2729
- id: resourceIdSchema,
2730
- requestContextSchema: z2.unknown().optional()
2784
+ id: resourceIdSchema.optional(),
2785
+ headersSchema: z2.unknown().optional()
2731
2786
  }).omit({
2732
2787
  createdAt: true,
2733
2788
  updatedAt: true
@@ -2962,6 +3017,7 @@ var init_ContextConfig = __esm({
2962
3017
  "../packages/agents-core/src/context/ContextConfig.ts"() {
2963
3018
  "use strict";
2964
3019
  init_esm_shims();
3020
+ init_conversations();
2965
3021
  init_logger();
2966
3022
  init_schema_conversion();
2967
3023
  init_schemas();
@@ -4560,51 +4616,6 @@ var init_client = __esm({
4560
4616
  }
4561
4617
  });
4562
4618
 
4563
- // ../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
4564
- import { webcrypto as crypto2 } from "crypto";
4565
- function fillPool(bytes) {
4566
- if (!pool || pool.length < bytes) {
4567
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
4568
- crypto2.getRandomValues(pool);
4569
- poolOffset = 0;
4570
- } else if (poolOffset + bytes > pool.length) {
4571
- crypto2.getRandomValues(pool);
4572
- poolOffset = 0;
4573
- }
4574
- poolOffset += bytes;
4575
- }
4576
- function random(bytes) {
4577
- fillPool(bytes |= 0);
4578
- return pool.subarray(poolOffset - bytes, poolOffset);
4579
- }
4580
- function customRandom(alphabet, defaultSize, getRandom) {
4581
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
4582
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
4583
- return (size = defaultSize) => {
4584
- if (!size) return "";
4585
- let id = "";
4586
- while (true) {
4587
- let bytes = getRandom(step);
4588
- let i2 = step;
4589
- while (i2--) {
4590
- id += alphabet[bytes[i2] & mask] || "";
4591
- if (id.length >= size) return id;
4592
- }
4593
- }
4594
- };
4595
- }
4596
- function customAlphabet(alphabet, size = 21) {
4597
- return customRandom(alphabet, size, random);
4598
- }
4599
- var POOL_SIZE_MULTIPLIER, pool, poolOffset;
4600
- var init_nanoid = __esm({
4601
- "../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js"() {
4602
- "use strict";
4603
- init_esm_shims();
4604
- POOL_SIZE_MULTIPLIER = 128;
4605
- }
4606
- });
4607
-
4608
4619
  // ../packages/agents-core/src/data-access/agentRelations.ts
4609
4620
  import { and, count, desc, eq, isNotNull } from "drizzle-orm";
4610
4621
  var init_agentRelations = __esm({
@@ -4690,17 +4701,6 @@ var init_auth_detection = __esm({
4690
4701
  }
4691
4702
  });
4692
4703
 
4693
- // ../packages/agents-core/src/utils/conversations.ts
4694
- var generateId;
4695
- var init_conversations = __esm({
4696
- "../packages/agents-core/src/utils/conversations.ts"() {
4697
- "use strict";
4698
- init_esm_shims();
4699
- init_nanoid();
4700
- generateId = customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789", 21);
4701
- }
4702
- });
4703
-
4704
4704
  // ../packages/agents-core/src/utils/error.ts
4705
4705
  function getTitleFromCode(code) {
4706
4706
  switch (code) {
@@ -6688,7 +6688,7 @@ var require_uri_all = __commonJS({
6688
6688
  mailtoComponents.path = void 0;
6689
6689
  if (mailtoComponents.query) {
6690
6690
  var unknownHeaders = false;
6691
- var headers = {};
6691
+ var headers2 = {};
6692
6692
  var hfields = mailtoComponents.query.split("&");
6693
6693
  for (var x2 = 0, xl = hfields.length; x2 < xl; ++x2) {
6694
6694
  var hfield = hfields[x2].split("=");
@@ -6707,11 +6707,11 @@ var require_uri_all = __commonJS({
6707
6707
  break;
6708
6708
  default:
6709
6709
  unknownHeaders = true;
6710
- headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
6710
+ headers2[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
6711
6711
  break;
6712
6712
  }
6713
6713
  }
6714
- if (unknownHeaders) mailtoComponents.headers = headers;
6714
+ if (unknownHeaders) mailtoComponents.headers = headers2;
6715
6715
  }
6716
6716
  mailtoComponents.query = void 0;
6717
6717
  for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
@@ -6748,13 +6748,13 @@ var require_uri_all = __commonJS({
6748
6748
  }
6749
6749
  components.path = to.join(",");
6750
6750
  }
6751
- var headers = mailtoComponents.headers = mailtoComponents.headers || {};
6752
- if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
6753
- if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
6751
+ var headers2 = mailtoComponents.headers = mailtoComponents.headers || {};
6752
+ if (mailtoComponents.subject) headers2["subject"] = mailtoComponents.subject;
6753
+ if (mailtoComponents.body) headers2["body"] = mailtoComponents.body;
6754
6754
  var fields = [];
6755
- for (var name in headers) {
6756
- if (headers[name] !== O[name]) {
6757
- fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
6755
+ for (var name in headers2) {
6756
+ if (headers2[name] !== O[name]) {
6757
+ fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers2[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
6758
6758
  }
6759
6759
  }
6760
6760
  if (fields.length) {
@@ -20903,15 +20903,15 @@ var init_api = __esm({
20903
20903
  * Wrapper around fetch that automatically includes Authorization header if API key is present
20904
20904
  */
20905
20905
  async authenticatedFetch(url, options = {}) {
20906
- const headers = {
20906
+ const headers2 = {
20907
20907
  ...options.headers || {}
20908
20908
  };
20909
20909
  if (this.apiKey) {
20910
- headers.Authorization = `Bearer ${this.apiKey}`;
20910
+ headers2.Authorization = `Bearer ${this.apiKey}`;
20911
20911
  }
20912
20912
  return apiFetch(url, {
20913
20913
  ...options,
20914
- headers
20914
+ headers: headers2
20915
20915
  });
20916
20916
  }
20917
20917
  getTenantId() {
@@ -22137,6 +22137,7 @@ import { generateText } from "ai";
22137
22137
  // src/commands/pull.placeholder-system.ts
22138
22138
  init_esm_shims();
22139
22139
  import { randomBytes as randomBytes2 } from "crypto";
22140
+ import { jsonSchemaToZod } from "json-schema-to-zod";
22140
22141
  var MIN_REPLACEMENT_LENGTH = 50;
22141
22142
  function generateShortId(length = 8) {
22142
22143
  return randomBytes2(Math.ceil(length / 2)).toString("hex").slice(0, length);
@@ -22148,6 +22149,16 @@ function generatePlaceholder(jsonPath) {
22148
22149
  function shouldReplaceString(value, placeholder) {
22149
22150
  return value.length >= MIN_REPLACEMENT_LENGTH && placeholder.length < value.length;
22150
22151
  }
22152
+ function isJsonSchemaPath(path3) {
22153
+ if (path3.endsWith("contextConfig.headersSchema") || path3.endsWith("responseSchema")) {
22154
+ return true;
22155
+ }
22156
+ return false;
22157
+ }
22158
+ function updateTracker(tracker, placeholder, value) {
22159
+ tracker.placeholderToValue.set(placeholder, value);
22160
+ tracker.valueToPlaceholder.set(value, placeholder);
22161
+ }
22151
22162
  function processObject(obj, tracker, path3 = "") {
22152
22163
  if (typeof obj === "string") {
22153
22164
  const existingPlaceholder = tracker.valueToPlaceholder.get(obj);
@@ -22162,12 +22173,19 @@ function processObject(obj, tracker, path3 = "") {
22162
22173
  `Placeholder collision detected: placeholder '${placeholder}' already exists with different value. Existing value length: ${existingValue.length}, New value length: ${obj.length}`
22163
22174
  );
22164
22175
  }
22165
- tracker.placeholderToValue.set(placeholder, obj);
22166
- tracker.valueToPlaceholder.set(obj, placeholder);
22176
+ updateTracker(tracker, placeholder, obj);
22167
22177
  return placeholder;
22168
22178
  }
22169
22179
  return obj;
22170
22180
  }
22181
+ if (isJsonSchemaPath(path3)) {
22182
+ try {
22183
+ const zodSchema = jsonSchemaToZod(obj);
22184
+ return zodSchema;
22185
+ } catch (error) {
22186
+ console.error("Error converting JSON schema to Zod schema:", error);
22187
+ }
22188
+ }
22171
22189
  if (Array.isArray(obj)) {
22172
22190
  return obj.map((item, index2) => processObject(item, tracker, `${path3}[${index2}]`));
22173
22191
  }
@@ -22565,6 +22583,7 @@ ${getTypeDefinitions()}
22565
22583
  IMPORTANT CONTEXT:
22566
22584
  - Agents reference resources (tools, components) by their imported variable names
22567
22585
  - The 'tools' field in agents contains tool IDs that must match the imported variable names
22586
+ - If contextConfig is present, it must be imported from '@inkeep/agents-core' and used to create the context config
22568
22587
 
22569
22588
  ${NAMING_CONVENTION_RULES}
22570
22589
 
@@ -22581,6 +22600,8 @@ REQUIREMENTS:
22581
22600
  - IMPORTANT: ANY placeholder that starts with < and ends with > MUST be wrapped in template literals (backticks)
22582
22601
  - Placeholders contain multi-line content and require template literals
22583
22602
  - This prevents TypeScript syntax errors with newlines and special characters
22603
+ - you must import { z } from 'zod' if you are using zod schemas in the graph file.
22604
+ 6. If you are writing zod schemas make them clean. For example if you see z.union([z.string(), z.null()]) write it as z.string().nullable()
22584
22605
 
22585
22606
  PLACEHOLDER HANDLING EXAMPLES:
22586
22607
  // CORRECT - Placeholder wrapped in template literals:
@@ -22591,9 +22612,40 @@ prompt: '<{{agents.facts.prompt.abc12345}}>'
22591
22612
 
22592
22613
  FULL EXAMPLE:
22593
22614
  import { agent, agentGraph } from '@inkeep/agents-sdk';
22615
+ import { contextConfig, fetchDefinition } from '@inkeep/agents-core';
22594
22616
  import { userProfile } from '../data-components/user-profile';
22595
22617
  import { searchTool } from '../tools/search-tool';
22596
22618
  import { weatherTool } from '../tools/weather-tool';
22619
+ import { z } from 'zod';
22620
+
22621
+
22622
+ const supportDescriptionFetchDefinition = fetchDefinition({
22623
+ id: 'support-description',
22624
+ name: 'Support Description',
22625
+ trigger: 'initialization',
22626
+ fetchConfig: {
22627
+ url: 'https://api.example.com/support-description',
22628
+ method: 'GET',
22629
+ headers: {
22630
+ 'Authorization': 'Bearer {{headers.sessionToken}}',
22631
+ },
22632
+ transform: 'data',
22633
+ },
22634
+ responseSchema: z.object({
22635
+ description: z.string(),
22636
+ }),
22637
+ defaultValue: 'Support Description',
22638
+ });
22639
+
22640
+ const supportGraphContext = contextConfig({
22641
+ headers: z.object({
22642
+ userId: z.string(),
22643
+ sessionToken: z.string(),
22644
+ }),
22645
+ contextVariables: {
22646
+ supportDescription: supportDescriptionDefinition,
22647
+ },
22648
+ });
22597
22649
 
22598
22650
  const routerAgent = agent({
22599
22651
  id: 'router',
@@ -22661,6 +22713,7 @@ Generate ONLY the TypeScript code without any markdown or explanations.`;
22661
22713
  console.log(`[DEBUG] - Unique tools: ${toolIds.size}`);
22662
22714
  console.log(`[DEBUG] - Data components: ${dataComponentIds.size}`);
22663
22715
  console.log(`[DEBUG] - Artifact components: ${artifactComponentIds.size}`);
22716
+ console.log(`[DEBUG] - Context config: ${graphData.contextConfig ? "Yes" : "No"}`);
22664
22717
  console.log(
22665
22718
  `[DEBUG] - Has relations: ${graphData.relations ? Object.keys(graphData.relations).length : 0}`
22666
22719
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-cli",
3
- "version": "0.0.0-dev-20251009010805",
3
+ "version": "0.0.0-dev-20251009070204",
4
4
  "description": "Inkeep CLI tool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,6 +38,7 @@
38
38
  "fs-extra": "^11.2.0",
39
39
  "inquirer": "^9.2.12",
40
40
  "inquirer-autocomplete-prompt": "^3.0.1",
41
+ "json-schema-to-zod": "^2.6.1",
41
42
  "ora": "^8.0.1",
42
43
  "picocolors": "^1.1.1",
43
44
  "pino": "^9.11.0",
@@ -45,8 +46,8 @@
45
46
  "recast": "^0.23.0",
46
47
  "ts-morph": "^26.0.0",
47
48
  "tsx": "^4.20.5",
48
- "@inkeep/agents-sdk": "^0.0.0-dev-20251009010805",
49
- "@inkeep/agents-core": "^0.0.0-dev-20251009010805"
49
+ "@inkeep/agents-core": "^0.0.0-dev-20251009070204",
50
+ "@inkeep/agents-sdk": "^0.0.0-dev-20251009070204"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@types/degit": "^2.8.6",
@@ -55,14 +56,14 @@
55
56
  "@types/node": "^20.10.0",
56
57
  "@types/prompts": "^2.4.9",
57
58
  "@vitest/coverage-v8": "^3.2.4",
59
+ "pino-pretty": "^13.1.1",
58
60
  "tsup": "^8.5.0",
59
61
  "typescript": "^5.9.2",
60
- "vitest": "^3.2.4",
61
- "pino-pretty": "^13.1.1"
62
+ "vitest": "^3.2.4"
62
63
  },
63
64
  "peerDependencies": {
64
- "zod": "^4.1.11",
65
- "@inkeep/agents-manage-ui": "0.0.0-dev-20251009010805"
65
+ "@inkeep/agents-manage-ui": "0.0.0-dev-20251009070204",
66
+ "zod": "^4.1.11"
66
67
  },
67
68
  "engines": {
68
69
  "node": ">=22.0.0"