toolcraft 0.0.2 → 0.0.4

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 (85) hide show
  1. package/README.md +461 -58
  2. package/dist/cli.compile-check.js +1 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +768 -40
  5. package/dist/human-in-loop/approval-tasks.d.ts +31 -0
  6. package/dist/human-in-loop/approval-tasks.js +201 -0
  7. package/dist/human-in-loop/approvals-commands.d.ts +11 -0
  8. package/dist/human-in-loop/approvals-commands.js +191 -0
  9. package/dist/human-in-loop/config.d.ts +11 -0
  10. package/dist/human-in-loop/config.js +21 -0
  11. package/dist/human-in-loop/default-provider.d.ts +2 -0
  12. package/dist/human-in-loop/default-provider.js +26 -0
  13. package/dist/human-in-loop/gate.d.ts +4 -0
  14. package/dist/human-in-loop/gate.js +57 -0
  15. package/dist/human-in-loop/index.d.ts +7 -0
  16. package/dist/human-in-loop/index.js +4 -0
  17. package/dist/human-in-loop/runner.d.ts +3 -0
  18. package/dist/human-in-loop/runner.js +196 -0
  19. package/dist/human-in-loop/spawn.d.ts +3 -0
  20. package/dist/human-in-loop/spawn.js +16 -0
  21. package/dist/human-in-loop/state-machine.d.ts +4 -0
  22. package/dist/human-in-loop/state-machine.js +10 -0
  23. package/dist/human-in-loop/types.d.ts +41 -0
  24. package/dist/human-in-loop/types.js +13 -0
  25. package/dist/index.compile-check.js +24 -0
  26. package/dist/index.d.ts +32 -13
  27. package/dist/index.js +82 -17
  28. package/dist/json-schema-converter.d.ts +21 -0
  29. package/dist/json-schema-converter.js +432 -0
  30. package/dist/mcp-proxy.d.ts +8 -0
  31. package/dist/mcp-proxy.js +383 -0
  32. package/dist/mcp.compile-check.js +1 -0
  33. package/dist/mcp.d.ts +2 -0
  34. package/dist/mcp.js +103 -11
  35. package/dist/sdk.compile-check.js +77 -0
  36. package/dist/sdk.d.ts +14 -5
  37. package/dist/sdk.js +57 -6
  38. package/dist/user-error.d.ts +3 -0
  39. package/dist/user-error.js +6 -0
  40. package/node_modules/@poe-code/agent-human-in-loop/README.md +42 -0
  41. package/node_modules/@poe-code/agent-human-in-loop/dist/index.d.ts +5 -0
  42. package/node_modules/@poe-code/agent-human-in-loop/dist/index.js +3 -0
  43. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/mock.d.ts +2 -0
  44. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/mock.js +11 -0
  45. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript-script.d.ts +4 -0
  46. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript-script.js +40 -0
  47. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript.d.ts +6 -0
  48. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript.js +33 -0
  49. package/node_modules/@poe-code/agent-human-in-loop/dist/request-approval.d.ts +4 -0
  50. package/node_modules/@poe-code/agent-human-in-loop/dist/request-approval.js +4 -0
  51. package/node_modules/@poe-code/agent-human-in-loop/dist/types.d.ts +14 -0
  52. package/node_modules/@poe-code/agent-human-in-loop/dist/types.js +1 -0
  53. package/node_modules/@poe-code/agent-human-in-loop/package.json +25 -0
  54. package/node_modules/@poe-code/agent-mcp-config/dist/apply.d.ts +6 -0
  55. package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +175 -0
  56. package/node_modules/@poe-code/agent-mcp-config/dist/configs.d.ts +22 -0
  57. package/node_modules/@poe-code/agent-mcp-config/dist/configs.js +74 -0
  58. package/node_modules/@poe-code/agent-mcp-config/dist/index.d.ts +3 -0
  59. package/node_modules/@poe-code/agent-mcp-config/dist/index.js +2 -0
  60. package/node_modules/@poe-code/agent-mcp-config/dist/shapes.d.ts +31 -0
  61. package/node_modules/@poe-code/agent-mcp-config/dist/shapes.js +87 -0
  62. package/node_modules/@poe-code/agent-mcp-config/dist/types.d.ts +25 -0
  63. package/node_modules/@poe-code/agent-mcp-config/dist/types.js +1 -0
  64. package/node_modules/@poe-code/agent-mcp-config/package.json +25 -0
  65. package/node_modules/@poe-code/task-list/README.md +114 -0
  66. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.d.ts +2 -0
  67. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +466 -0
  68. package/node_modules/@poe-code/task-list/dist/backends/utils.d.ts +8 -0
  69. package/node_modules/@poe-code/task-list/dist/backends/utils.js +58 -0
  70. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.d.ts +2 -0
  71. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +444 -0
  72. package/node_modules/@poe-code/task-list/dist/index.d.ts +4 -0
  73. package/node_modules/@poe-code/task-list/dist/index.js +4 -0
  74. package/node_modules/@poe-code/task-list/dist/open.d.ts +3 -0
  75. package/node_modules/@poe-code/task-list/dist/open.js +34 -0
  76. package/node_modules/@poe-code/task-list/dist/schema/store.schema.json +32 -0
  77. package/node_modules/@poe-code/task-list/dist/schema/task.schema.json +33 -0
  78. package/node_modules/@poe-code/task-list/dist/state-machine.d.ts +16 -0
  79. package/node_modules/@poe-code/task-list/dist/state-machine.js +67 -0
  80. package/node_modules/@poe-code/task-list/dist/state.d.ts +29 -0
  81. package/node_modules/@poe-code/task-list/dist/state.js +61 -0
  82. package/node_modules/@poe-code/task-list/dist/types.d.ts +116 -0
  83. package/node_modules/@poe-code/task-list/dist/types.js +37 -0
  84. package/node_modules/@poe-code/task-list/package.json +26 -0
  85. package/package.json +22 -7
@@ -0,0 +1,432 @@
1
+ import { S } from "toolcraft-schema";
2
+ export function convertJsonSchema(schema) {
3
+ if (hasSelfReferencingRef(schema, schema)) {
4
+ return applyMetadata(S.Json(), schema, {
5
+ nullable: schema.nullable === true,
6
+ });
7
+ }
8
+ return convertSchema(schema, schema);
9
+ }
10
+ function convertSchema(schema, root) {
11
+ const resolvedSchema = resolveReferencedSchema(schema, root);
12
+ const normalizedSchema = normalizeNullability(resolvedSchema);
13
+ const composition = normalizedSchema.schema.oneOf ?? normalizedSchema.schema.anyOf;
14
+ if (Array.isArray(normalizedSchema.schema.type)) {
15
+ throw new Error(`Unsupported JSON Schema type array: ${JSON.stringify(normalizedSchema.schema.type)}.`);
16
+ }
17
+ if (resolvedSchema.const !== undefined) {
18
+ return convertConstSchema(resolvedSchema, normalizedSchema.nullable);
19
+ }
20
+ if (resolvedSchema.enum !== undefined) {
21
+ return convertEnumSchema(resolvedSchema, normalizedSchema.nullable);
22
+ }
23
+ if (composition !== undefined) {
24
+ return convertCompositionSchema(normalizedSchema.schema, root, normalizedSchema.nullable);
25
+ }
26
+ if (isRecordSchema(normalizedSchema.schema)) {
27
+ return applyMetadata(S.Record(convertSchema(normalizedSchema.schema.additionalProperties, root)), normalizedSchema.schema, {
28
+ nullable: normalizedSchema.nullable,
29
+ });
30
+ }
31
+ switch (normalizedSchema.schema.type) {
32
+ case "string":
33
+ return S.String({
34
+ ...createCommonOptions(normalizedSchema.schema, normalizedSchema.nullable, getStringDefault(normalizedSchema.schema.default)),
35
+ ...(normalizedSchema.schema.pattern === undefined
36
+ ? {}
37
+ : { pattern: normalizedSchema.schema.pattern }),
38
+ });
39
+ case "number":
40
+ return S.Number(createCommonOptions(normalizedSchema.schema, normalizedSchema.nullable, getNumberDefault(normalizedSchema.schema.default)));
41
+ case "integer":
42
+ return S.Number({
43
+ ...createCommonOptions(normalizedSchema.schema, normalizedSchema.nullable, getIntegerDefault(normalizedSchema.schema.default)),
44
+ jsonType: "integer",
45
+ });
46
+ case "boolean":
47
+ return S.Boolean(createCommonOptions(normalizedSchema.schema, normalizedSchema.nullable, getBooleanDefault(normalizedSchema.schema.default)));
48
+ case "array":
49
+ if (normalizedSchema.schema.items === undefined) {
50
+ throw new Error('JSON Schema arrays must define "items".');
51
+ }
52
+ return S.Array(convertSchema(normalizedSchema.schema.items, root), createCommonOptions(normalizedSchema.schema, normalizedSchema.nullable, getArrayDefault(normalizedSchema.schema.default)));
53
+ case "object":
54
+ return convertObjectSchema(normalizedSchema.schema, root, {
55
+ nullable: normalizedSchema.nullable,
56
+ });
57
+ case "null":
58
+ return applyMetadata(S.Json(), normalizedSchema.schema, {
59
+ default: getJsonDefault(normalizedSchema.schema.default) ?? null,
60
+ nullable: true,
61
+ });
62
+ case undefined:
63
+ if (normalizedSchema.nullable) {
64
+ return applyMetadata(S.Json(), normalizedSchema.schema, {
65
+ nullable: true,
66
+ });
67
+ }
68
+ throw new Error("Unsupported JSON Schema: missing type, enum, const, or composition.");
69
+ }
70
+ throw new Error(`Unsupported JSON Schema type: ${JSON.stringify(normalizedSchema.schema.type)}.`);
71
+ }
72
+ function convertConstSchema(schema, nullable) {
73
+ if (isPrimitiveEnumValue(schema.const)) {
74
+ return S.Enum([schema.const], {
75
+ ...createCommonOptions(schema, nullable, schema.const),
76
+ default: schema.const,
77
+ ...(schema.type === "integer" && typeof schema.const === "number"
78
+ ? { jsonType: "integer" }
79
+ : {}),
80
+ });
81
+ }
82
+ return applyMetadata(S.Json(), schema, {
83
+ default: schema.const,
84
+ nullable: nullable || schema.const === null,
85
+ description: appendDescription(schema.description, `Constant JSON value: ${JSON.stringify(schema.const)}.`),
86
+ });
87
+ }
88
+ function convertEnumSchema(schema, nullable) {
89
+ const values = schema.enum ?? [];
90
+ const nonNullValues = values.filter((value) => value !== null);
91
+ const hasNull = nonNullValues.length !== values.length;
92
+ if (nonNullValues.every(isPrimitiveEnumValue) && nonNullValues.length > 0) {
93
+ return S.Enum(nonNullValues, {
94
+ ...createCommonOptions(schema, nullable || hasNull, getPrimitiveEnumDefault(schema.default, nonNullValues)),
95
+ ...(schema.type === "integer" && nonNullValues.every((value) => Number.isInteger(value))
96
+ ? { jsonType: "integer" }
97
+ : {}),
98
+ });
99
+ }
100
+ return applyMetadata(S.Json(), schema, {
101
+ nullable: nullable || hasNull,
102
+ description: appendDescription(schema.description, `Allowed JSON values: ${values.map((value) => JSON.stringify(value)).join(", ")}.`),
103
+ });
104
+ }
105
+ function convertCompositionSchema(schema, root, nullable) {
106
+ const branches = [...(schema.oneOf ?? schema.anyOf ?? [])].map((branch) => resolveReferencedSchema(branch, root));
107
+ const discriminator = findDiscriminator(branches, root);
108
+ if (discriminator !== undefined) {
109
+ const convertedBranches = Object.fromEntries(branches.map((branch) => [
110
+ getDiscriminatorLiteral(branch, discriminator, root),
111
+ convertObjectSchema(branch, root, {
112
+ omitProperty: discriminator,
113
+ }),
114
+ ]));
115
+ return applyMetadata(S.OneOf({
116
+ discriminator,
117
+ branches: convertedBranches,
118
+ }), schema, {
119
+ nullable,
120
+ });
121
+ }
122
+ return applyMetadata(S.Union(branches.map((branch) => convertObjectSchema(branch, root, {}))), schema, {
123
+ nullable,
124
+ });
125
+ }
126
+ function convertObjectSchema(schema, root, options) {
127
+ const resolvedSchema = resolveReferencedSchema(schema, root);
128
+ const normalizedSchema = normalizeNullability(resolvedSchema);
129
+ const properties = normalizedSchema.schema.properties ?? {};
130
+ const requiredKeys = new Set(normalizedSchema.schema.required ?? []);
131
+ const shape = {};
132
+ if (normalizedSchema.schema.type !== "object" && normalizedSchema.schema.properties === undefined) {
133
+ throw new Error("Expected an object schema branch.");
134
+ }
135
+ for (const [key, propertySchema] of Object.entries(properties)) {
136
+ if (key === options.omitProperty) {
137
+ continue;
138
+ }
139
+ const convertedProperty = convertSchema(propertySchema, root);
140
+ shape[key] = requiredKeys.has(key) ? convertedProperty : S.Optional(convertedProperty);
141
+ }
142
+ return applyMetadata(S.Object(shape, {
143
+ ...(typeof normalizedSchema.schema.additionalProperties === "boolean"
144
+ ? { additionalProperties: normalizedSchema.schema.additionalProperties }
145
+ : {}),
146
+ }), normalizedSchema.schema, {
147
+ nullable: options.nullable ?? normalizedSchema.nullable,
148
+ });
149
+ }
150
+ function createCommonOptions(schema, nullable, defaultValue) {
151
+ return {
152
+ ...(schema.description === undefined ? {} : { description: schema.description }),
153
+ ...(defaultValue === undefined ? {} : { default: defaultValue }),
154
+ ...(nullable ? { nullable: true } : {}),
155
+ };
156
+ }
157
+ function applyMetadata(schema, source, overrides) {
158
+ const result = { ...schema };
159
+ const description = overrides.description ?? source.description;
160
+ const hasDefaultOverride = Object.prototype.hasOwnProperty.call(overrides, "default");
161
+ const defaultValue = hasDefaultOverride ? overrides.default : source.default;
162
+ if (description !== undefined) {
163
+ result.description = description;
164
+ }
165
+ if (defaultValue !== undefined) {
166
+ result.default = defaultValue;
167
+ }
168
+ if (overrides.nullable === true) {
169
+ result.nullable = true;
170
+ }
171
+ return result;
172
+ }
173
+ function normalizeNullability(schema) {
174
+ if (!Array.isArray(schema.type)) {
175
+ return {
176
+ schema,
177
+ nullable: schema.nullable === true,
178
+ };
179
+ }
180
+ const nextTypes = schema.type.filter((value) => value !== "null");
181
+ if (nextTypes.length === schema.type.length) {
182
+ return {
183
+ schema,
184
+ nullable: schema.nullable === true,
185
+ };
186
+ }
187
+ return {
188
+ schema: {
189
+ ...schema,
190
+ type: nextTypes.length === 0 ? undefined : nextTypes.length === 1 ? nextTypes[0] : nextTypes,
191
+ nullable: undefined,
192
+ },
193
+ nullable: true,
194
+ };
195
+ }
196
+ function isRecordSchema(schema) {
197
+ const propertyKeys = Object.keys(schema.properties ?? {});
198
+ return (schema.type === "object" &&
199
+ propertyKeys.length === 0 &&
200
+ typeof schema.additionalProperties === "object" &&
201
+ schema.additionalProperties !== null);
202
+ }
203
+ function findDiscriminator(branches, root) {
204
+ const [firstBranch] = branches;
205
+ if (firstBranch === undefined) {
206
+ throw new Error("JSON Schema composition requires at least one branch.");
207
+ }
208
+ const candidateKeys = Object.keys(firstBranch.properties ?? {});
209
+ for (const candidate of candidateKeys) {
210
+ const values = [];
211
+ let matches = true;
212
+ for (const branch of branches) {
213
+ const requiredKeys = new Set(branch.required ?? []);
214
+ if (!requiredKeys.has(candidate)) {
215
+ matches = false;
216
+ break;
217
+ }
218
+ const literal = getDiscriminatorLiteral(branch, candidate, root);
219
+ if (literal === undefined) {
220
+ matches = false;
221
+ break;
222
+ }
223
+ values.push(literal);
224
+ }
225
+ if (matches && new Set(values).size === values.length) {
226
+ return candidate;
227
+ }
228
+ }
229
+ return undefined;
230
+ }
231
+ function getDiscriminatorLiteral(branch, key, root) {
232
+ const propertySchema = branch.properties?.[key];
233
+ if (propertySchema === undefined) {
234
+ return undefined;
235
+ }
236
+ const resolvedProperty = resolveReferencedSchema(propertySchema, root);
237
+ if (typeof resolvedProperty.const === "string") {
238
+ return resolvedProperty.const;
239
+ }
240
+ if (resolvedProperty.enum !== undefined &&
241
+ resolvedProperty.enum.length === 1 &&
242
+ typeof resolvedProperty.enum[0] === "string") {
243
+ return resolvedProperty.enum[0];
244
+ }
245
+ return undefined;
246
+ }
247
+ function resolveReferencedSchema(schema, root) {
248
+ if (schema.$ref === undefined) {
249
+ return schema;
250
+ }
251
+ const resolvedTarget = resolveLocalRef(root, schema.$ref);
252
+ if (resolvedTarget === undefined) {
253
+ throw new Error(`Unsupported JSON Schema $ref: ${JSON.stringify(schema.$ref)}.`);
254
+ }
255
+ const { $ref: ignoredRef, ...siblingKeywords } = schema;
256
+ void ignoredRef;
257
+ const resolvedSchema = resolveReferencedSchema(resolvedTarget, root);
258
+ if (Object.keys(siblingKeywords).length === 0) {
259
+ return resolvedSchema;
260
+ }
261
+ return mergeJsonSchemas(resolvedSchema, siblingKeywords);
262
+ }
263
+ function mergeJsonSchemas(base, overlay) {
264
+ const mergedProperties = base.properties === undefined && overlay.properties === undefined
265
+ ? undefined
266
+ : {
267
+ ...(base.properties ?? {}),
268
+ ...(overlay.properties ?? {}),
269
+ };
270
+ const mergedDefs = base.$defs === undefined && overlay.$defs === undefined
271
+ ? undefined
272
+ : {
273
+ ...(base.$defs ?? {}),
274
+ ...(overlay.$defs ?? {}),
275
+ };
276
+ const mergedRequired = base.required === undefined && overlay.required === undefined
277
+ ? undefined
278
+ : [...new Set([...(base.required ?? []), ...(overlay.required ?? [])])];
279
+ return {
280
+ ...base,
281
+ ...overlay,
282
+ ...(mergedDefs === undefined ? {} : { $defs: mergedDefs }),
283
+ ...(mergedProperties === undefined ? {} : { properties: mergedProperties }),
284
+ ...(mergedRequired === undefined ? {} : { required: mergedRequired }),
285
+ };
286
+ }
287
+ function hasSelfReferencingRef(schema, root, path = "#", activePaths = new Set()) {
288
+ const nextActivePaths = new Set(activePaths);
289
+ nextActivePaths.add(path);
290
+ const localRefPath = getLocalRefPath(schema.$ref);
291
+ if (localRefPath !== undefined) {
292
+ if (nextActivePaths.has(localRefPath)) {
293
+ return true;
294
+ }
295
+ const target = resolveLocalRef(root, localRefPath);
296
+ if (target !== undefined && hasSelfReferencingRef(target, root, localRefPath, nextActivePaths)) {
297
+ return true;
298
+ }
299
+ }
300
+ if (schema.items !== undefined && hasSelfReferencingRef(schema.items, root, `${path}/items`, nextActivePaths)) {
301
+ return true;
302
+ }
303
+ if (typeof schema.additionalProperties === "object" &&
304
+ schema.additionalProperties !== null &&
305
+ hasSelfReferencingRef(schema.additionalProperties, root, `${path}/additionalProperties`, nextActivePaths)) {
306
+ return true;
307
+ }
308
+ for (const [key, childSchema] of Object.entries(schema.properties ?? {})) {
309
+ if (hasSelfReferencingRef(childSchema, root, `${path}/properties/${escapeJsonPointerSegment(key)}`, nextActivePaths)) {
310
+ return true;
311
+ }
312
+ }
313
+ for (const [key, childSchema] of Object.entries(schema.$defs ?? {})) {
314
+ if (hasSelfReferencingRef(childSchema, root, `${path}/$defs/${escapeJsonPointerSegment(key)}`, nextActivePaths)) {
315
+ return true;
316
+ }
317
+ }
318
+ for (const [index, childSchema] of (schema.oneOf ?? []).entries()) {
319
+ if (hasSelfReferencingRef(childSchema, root, `${path}/oneOf/${index}`, nextActivePaths)) {
320
+ return true;
321
+ }
322
+ }
323
+ for (const [index, childSchema] of (schema.anyOf ?? []).entries()) {
324
+ if (hasSelfReferencingRef(childSchema, root, `${path}/anyOf/${index}`, nextActivePaths)) {
325
+ return true;
326
+ }
327
+ }
328
+ return false;
329
+ }
330
+ function getLocalRefPath(ref) {
331
+ if (ref === undefined) {
332
+ return undefined;
333
+ }
334
+ if (ref === "#") {
335
+ return "#";
336
+ }
337
+ return ref.startsWith("#/") ? ref : undefined;
338
+ }
339
+ function resolveLocalRef(root, ref) {
340
+ const path = getLocalRefPath(ref);
341
+ if (path === undefined) {
342
+ return undefined;
343
+ }
344
+ if (path === "#") {
345
+ return root;
346
+ }
347
+ const segments = path.slice(2).split("/").map(unescapeJsonPointerSegment);
348
+ let current = root;
349
+ for (const segment of segments) {
350
+ if (Array.isArray(current)) {
351
+ const index = parseArrayIndex(segment);
352
+ if (index === undefined) {
353
+ return undefined;
354
+ }
355
+ current = current[index];
356
+ continue;
357
+ }
358
+ if (!isPlainObject(current)) {
359
+ return undefined;
360
+ }
361
+ current = current[segment];
362
+ }
363
+ return isPlainObject(current) ? current : undefined;
364
+ }
365
+ function appendDescription(description, addition) {
366
+ if (addition === undefined || addition.length === 0) {
367
+ return description;
368
+ }
369
+ if (description === undefined || description.length === 0) {
370
+ return addition;
371
+ }
372
+ return `${description} ${addition}`;
373
+ }
374
+ function isPrimitiveEnumValue(value) {
375
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
376
+ }
377
+ function getStringDefault(value) {
378
+ return typeof value === "string" ? value : undefined;
379
+ }
380
+ function getNumberDefault(value) {
381
+ return typeof value === "number" ? value : undefined;
382
+ }
383
+ function getIntegerDefault(value) {
384
+ return typeof value === "number" && Number.isInteger(value) ? value : undefined;
385
+ }
386
+ function getBooleanDefault(value) {
387
+ return typeof value === "boolean" ? value : undefined;
388
+ }
389
+ function getArrayDefault(value) {
390
+ return Array.isArray(value) && value.every((item) => isJsonValue(item)) ? value : undefined;
391
+ }
392
+ function getPrimitiveEnumDefault(value, candidates) {
393
+ return isPrimitiveEnumValue(value) && candidates.includes(value) ? value : undefined;
394
+ }
395
+ function getJsonDefault(value) {
396
+ return isJsonValue(value) ? value : undefined;
397
+ }
398
+ function isJsonValue(value) {
399
+ if (value === null) {
400
+ return true;
401
+ }
402
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
403
+ return true;
404
+ }
405
+ if (Array.isArray(value)) {
406
+ return value.every((item) => isJsonValue(item));
407
+ }
408
+ if (!isPlainObject(value)) {
409
+ return false;
410
+ }
411
+ return Object.values(value).every((item) => isJsonValue(item));
412
+ }
413
+ function isPlainObject(value) {
414
+ return typeof value === "object" && value !== null && !Array.isArray(value);
415
+ }
416
+ function escapeJsonPointerSegment(value) {
417
+ return value.split("~").join("~0").split("/").join("~1");
418
+ }
419
+ function unescapeJsonPointerSegment(value) {
420
+ return value.split("~1").join("/").split("~0").join("~");
421
+ }
422
+ function parseArrayIndex(value) {
423
+ if (value.length === 0) {
424
+ return undefined;
425
+ }
426
+ for (const char of value) {
427
+ if (char < "0" || char > "9") {
428
+ return undefined;
429
+ }
430
+ }
431
+ return Number.parseInt(value, 10);
432
+ }
@@ -0,0 +1,8 @@
1
+ import type { McpServerConfig } from "@poe-code/agent-mcp-config";
2
+ import { McpClient } from "tiny-mcp-client";
3
+ import type { Group } from "./index.js";
4
+ export declare function hasMcpProxyGroups(root: Group<any>): boolean;
5
+ export declare function resolveCachePath(name: string, projectRoot?: string): string;
6
+ export declare function parseRefreshEnv(value: string | undefined): "all" | Set<string> | undefined;
7
+ export declare function dialUpstream(name: string, config: McpServerConfig): Promise<McpClient>;
8
+ export declare function resolveMcpProxies(root: Group<any>): Promise<void>;