kizunajs 2.0.0-beta.2 → 2.0.0-beta.21

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 (81) hide show
  1. package/README.md +3 -2
  2. package/dist/{adapter-CZW-unqX.mjs → adapter-BSqNrxhq.mjs} +522 -104
  3. package/dist/adapter-C3WYdSfx.d.cts +2754 -0
  4. package/dist/{adapter-DDR_yo9L.cjs → adapter-ClaFZoab.cjs} +638 -196
  5. package/dist/adapter-D4bTPElA.d.mts +2754 -0
  6. package/dist/adapter.cjs +37 -29
  7. package/dist/adapter.d.cts +3 -5
  8. package/dist/adapter.d.mts +3 -5
  9. package/dist/adapter.mjs +5 -5
  10. package/dist/{error-response-C8Ragjcd.cjs → error-response-C9ymqSU4.cjs} +25 -5
  11. package/dist/{error-response-C839d8By.mjs → error-response-CNQaKVYd.mjs} +20 -6
  12. package/dist/{security-scheme-BrszwGD5.d.cts → error-response-NoOGdh8H.d.mts} +151 -24
  13. package/dist/{security-scheme-D3nb4XKj.d.mts → error-response-YbkRMKno.d.cts} +151 -24
  14. package/dist/generator.cjs +190 -95
  15. package/dist/generator.d.cts +189 -28
  16. package/dist/generator.d.mts +189 -28
  17. package/dist/generator.mjs +151 -60
  18. package/dist/index.cjs +159 -84
  19. package/dist/index.d.cts +193 -253
  20. package/dist/index.d.mts +193 -253
  21. package/dist/index.mjs +112 -38
  22. package/dist/jobs-entry.cjs +12 -11
  23. package/dist/jobs-entry.d.cts +1 -1
  24. package/dist/jobs-entry.d.mts +1 -1
  25. package/dist/jobs-entry.mjs +3 -2
  26. package/dist/plugin-Dw-yCjTY.cjs +233 -0
  27. package/dist/{cache-CLN5y0Xp.mjs → plugin-server-BztlE1fz.mjs} +188 -49
  28. package/dist/{cache-BgohRj0i.cjs → plugin-server-kUsK7thV.cjs} +238 -93
  29. package/dist/plugin-xxCxibmu.mjs +138 -0
  30. package/dist/plugin.cjs +8 -72
  31. package/dist/plugin.d.cts +3 -3
  32. package/dist/plugin.d.mts +3 -3
  33. package/dist/plugin.mjs +2 -68
  34. package/dist/{protected-resource-metadata-CA0v5cjg.d.mts → protected-resource-metadata-B9hMFQ9N.d.cts} +1 -1
  35. package/dist/{protected-resource-metadata-Cprrv0mt.d.cts → protected-resource-metadata-CfBVsqIk.d.mts} +1 -1
  36. package/dist/{schemas-C56no6bv.cjs → schemas-DNPVDvkd.cjs} +28 -1
  37. package/dist/{schemas-CJQcc97N.mjs → schemas-HW2FDsvz.mjs} +23 -2
  38. package/dist/schemas.cjs +3 -2
  39. package/dist/schemas.d.cts +24 -3
  40. package/dist/schemas.d.mts +24 -3
  41. package/dist/schemas.mjs +3 -3
  42. package/package.json +1 -1
  43. package/src/adapter.ts +245 -29
  44. package/src/api-definition.ts +12 -16
  45. package/src/api.ts +7 -3
  46. package/src/brand.ts +29 -0
  47. package/src/config.ts +51 -10
  48. package/src/configured.ts +13 -6
  49. package/src/define-config.ts +118 -39
  50. package/src/generator.ts +363 -46
  51. package/src/group-routes.ts +106 -0
  52. package/src/groups.ts +140 -0
  53. package/src/handler-pipeline.ts +78 -19
  54. package/src/index.ts +15 -6
  55. package/src/job-runner.ts +5 -0
  56. package/src/job-transport.ts +3 -3
  57. package/src/job.ts +8 -6
  58. package/src/jobs-dev-runner.ts +6 -0
  59. package/src/jobs.ts +61 -8
  60. package/src/kizuna.ts +56 -33
  61. package/src/plugin-server.ts +129 -19
  62. package/src/plugin.ts +269 -127
  63. package/src/routes.ts +80 -32
  64. package/src/schemas.ts +1 -0
  65. package/src/tool-answer.ts +21 -0
  66. package/src/tool-definitions.ts +166 -0
  67. package/src/tool-events.ts +90 -18
  68. package/src/tool-records.ts +11 -3
  69. package/src/tool-runner.ts +298 -0
  70. package/src/types.ts +90 -24
  71. package/src/zod-internals.ts +22 -5
  72. package/src/zod-meta.ts +7 -2
  73. package/dist/adapter-BGfMqEkM.d.cts +0 -563
  74. package/dist/adapter-Ci3cfcoT.d.mts +0 -563
  75. package/dist/api-definition-BHnh15zD.d.mts +0 -803
  76. package/dist/api-definition-DQj-ewHy.d.cts +0 -803
  77. package/dist/error-response-BBGSdgYw.d.mts +0 -67
  78. package/dist/error-response-Do38sr-9.d.cts +0 -67
  79. package/dist/plugin-Cz0kn6Lk.d.mts +0 -830
  80. package/dist/plugin-DhKvx_T0.d.cts +0 -830
  81. package/src/tags.ts +0 -67
package/dist/plugin.mjs CHANGED
@@ -1,68 +1,2 @@
1
- //#region src/plugin.ts
2
- const PLUGIN_ROUTES_META_KEY = Symbol.for("kizuna.plugin-routes");
3
- const PLUGIN_SERVERS_META_KEY = Symbol.for("kizuna.plugin-servers");
4
- /**
5
- * Declare a plugin: the routes it serves, the props an app configures it with,
6
- * and the `serve` that answers those routes. Whatever `serve` returns under
7
- * `exports` reaches every handler as `plugins.<slug>`.
8
- *
9
- * Give the factory a `Slug` parameter and {@link WithSlug} so an app can rename
10
- * what it installs, or install two of them.
11
- *
12
- * @example
13
- * ```ts
14
- * const declare = (slug: string, props: AuditProps) =>
15
- * createPlugin({
16
- * slug,
17
- * routes: {
18
- * recent: {
19
- * method: 'GET',
20
- * path: props.path ?? '/audit/recent',
21
- * responses: {
22
- * 200: z.array(EntrySchema),
23
- * },
24
- * },
25
- * },
26
- * props,
27
- * serve: ({ store }) => ({
28
- * router: {
29
- * recent: async () => ({ status: 200, body: await store.recent() }),
30
- * },
31
- * exports: {
32
- * record: (routeKey: string) => store.write(routeKey),
33
- * },
34
- * }),
35
- * });
36
- *
37
- * export function auditPlugin<const Slug extends string = 'audit'>(
38
- * props: AuditProps<Slug>
39
- * ): WithSlug<ReturnType<typeof declare>, Slug> {
40
- * return declare(props.slug ?? 'audit', props) as never;
41
- * }
42
- * ```
43
- */
44
- const createPlugin = (definition) => ({
45
- slug: definition.slug,
46
- routes: definition.routes,
47
- props: definition.props,
48
- serve: definition.serve
49
- });
50
- /**
51
- * Every plugin's routes as one tree, keyed by install name, for the adapter to
52
- * walk as it walks the api's own.
53
- */
54
- const pluginRouteTree = (plugins) => {
55
- const tree = {};
56
- for (const [pluginKey, plugin] of Object.entries(plugins ?? {})) tree[pluginKey] = plugin.routes;
57
- return tree;
58
- };
59
- /**
60
- * Every plugin in a list, keyed by its own slug.
61
- */
62
- const pluginsBySlug = (plugins) => {
63
- const bySlug = {};
64
- for (const plugin of plugins ?? []) bySlug[plugin.slug] = plugin;
65
- return bySlug;
66
- };
67
- //#endregion
68
- export { PLUGIN_ROUTES_META_KEY, PLUGIN_SERVERS_META_KEY, createPlugin, pluginRouteTree, pluginsBySlug };
1
+ import { a as definePlugin, i as RoutePathSchema, n as PLUGIN_SERVERS_META_KEY, o as pluginRouteTree, r as RouteAuthSchema, s as route, t as PLUGIN_ROUTES_META_KEY } from "./plugin-xxCxibmu.mjs";
2
+ export { PLUGIN_ROUTES_META_KEY, PLUGIN_SERVERS_META_KEY, RouteAuthSchema, RoutePathSchema, definePlugin, pluginRouteTree, route };
@@ -1,4 +1,4 @@
1
- import { a as SecurityScheme } from "./security-scheme-D3nb4XKj.mjs";
1
+ import { s as SecurityScheme } from "./error-response-YbkRMKno.cjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/validation-error.d.ts
@@ -1,4 +1,4 @@
1
- import { a as SecurityScheme } from "./security-scheme-BrszwGD5.cjs";
1
+ import { s as SecurityScheme } from "./error-response-NoOGdh8H.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/validation-error.d.ts
@@ -1,4 +1,4 @@
1
- const require_error_response = require("./error-response-C8Ragjcd.cjs");
1
+ const require_error_response = require("./error-response-C9ymqSU4.cjs");
2
2
  let zod = require("zod");
3
3
  //#region src/security-scheme.ts
4
4
  /**
@@ -233,6 +233,27 @@ const BinarySchema = zod.z.instanceof(Uint8Array);
233
233
  */
234
234
  const FileSchema = zod.z.instanceof(File);
235
235
  //#endregion
236
+ //#region src/tool-answer.ts
237
+ /**
238
+ * The person's answer to a call that needs approval, for a route's body.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * body: z.object({
243
+ * prompt: z.string(),
244
+ * answer: ToolAnswerSchema.optional(),
245
+ * }),
246
+ * ```
247
+ */
248
+ const ToolAnswerSchema = zod.z.object({
249
+ call: zod.z.object({
250
+ id: zod.z.string(),
251
+ name: zod.z.string(),
252
+ input: zod.z.unknown().optional()
253
+ }),
254
+ approved: zod.z.boolean()
255
+ });
256
+ //#endregion
236
257
  Object.defineProperty(exports, "BinarySchema", {
237
258
  enumerable: true,
238
259
  get: function() {
@@ -251,6 +272,12 @@ Object.defineProperty(exports, "ProtectedResourceMetadataSchema", {
251
272
  return ProtectedResourceMetadataSchema;
252
273
  }
253
274
  });
275
+ Object.defineProperty(exports, "ToolAnswerSchema", {
276
+ enumerable: true,
277
+ get: function() {
278
+ return ToolAnswerSchema;
279
+ }
280
+ });
254
281
  Object.defineProperty(exports, "ValidationErrorSchema", {
255
282
  enumerable: true,
256
283
  get: function() {
@@ -1,4 +1,4 @@
1
- import { r as createModel, t as ProblemDetailsSchema } from "./error-response-C839d8By.mjs";
1
+ import { r as createModel, t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/security-scheme.ts
4
4
  /**
@@ -233,4 +233,25 @@ const BinarySchema = z.instanceof(Uint8Array);
233
233
  */
234
234
  const FileSchema = z.instanceof(File);
235
235
  //#endregion
236
- export { buildProtectedResourceMetadata as a, authenticationChallenge as c, isSecurityScheme as d, resolveSecurityRequirements as f, assertCanonicalResourceUri as i, authorizationServerIssuer as l, FileSchema as n, ValidationErrorSchema as o, ProtectedResourceMetadataSchema as r, isValidationError as s, BinarySchema as t, declaredScopes as u };
236
+ //#region src/tool-answer.ts
237
+ /**
238
+ * The person's answer to a call that needs approval, for a route's body.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * body: z.object({
243
+ * prompt: z.string(),
244
+ * answer: ToolAnswerSchema.optional(),
245
+ * }),
246
+ * ```
247
+ */
248
+ const ToolAnswerSchema = z.object({
249
+ call: z.object({
250
+ id: z.string(),
251
+ name: z.string(),
252
+ input: z.unknown().optional()
253
+ }),
254
+ approved: z.boolean()
255
+ });
256
+ //#endregion
257
+ export { assertCanonicalResourceUri as a, isValidationError as c, declaredScopes as d, isSecurityScheme as f, ProtectedResourceMetadataSchema as i, authenticationChallenge as l, BinarySchema as n, buildProtectedResourceMetadata as o, resolveSecurityRequirements as p, FileSchema as r, ValidationErrorSchema as s, ToolAnswerSchema as t, authorizationServerIssuer as u };
package/dist/schemas.cjs CHANGED
@@ -1,8 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_error_response = require("./error-response-C8Ragjcd.cjs");
3
- const require_schemas = require("./schemas-C56no6bv.cjs");
2
+ const require_error_response = require("./error-response-C9ymqSU4.cjs");
3
+ const require_schemas = require("./schemas-DNPVDvkd.cjs");
4
4
  exports.BinarySchema = require_schemas.BinarySchema;
5
5
  exports.FileSchema = require_schemas.FileSchema;
6
6
  exports.ProblemDetailsSchema = require_error_response.ProblemDetailsSchema;
7
7
  exports.ProtectedResourceMetadataSchema = require_schemas.ProtectedResourceMetadataSchema;
8
+ exports.ToolAnswerSchema = require_schemas.ToolAnswerSchema;
8
9
  exports.ValidationErrorSchema = require_schemas.ValidationErrorSchema;
@@ -1,5 +1,5 @@
1
- import { t as ProblemDetailsSchema } from "./error-response-Do38sr-9.cjs";
2
- import { c as ValidationErrorFor, l as ValidationErrorSchema, r as ProtectedResourceMetadataSchema, s as ValidationError, u as ValidationIssueCode } from "./protected-resource-metadata-Cprrv0mt.cjs";
1
+ import { t as ProblemDetailsSchema } from "./error-response-YbkRMKno.cjs";
2
+ import { c as ValidationErrorFor, l as ValidationErrorSchema, r as ProtectedResourceMetadataSchema, s as ValidationError, u as ValidationIssueCode } from "./protected-resource-metadata-B9hMFQ9N.cjs";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/binary.d.ts
@@ -54,4 +54,25 @@ declare const BinarySchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Arra
54
54
  */
55
55
  declare const FileSchema: z.ZodCustom<File, File>;
56
56
  //#endregion
57
- export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, type ValidationError, type ValidationErrorFor, ValidationErrorSchema, type ValidationIssueCode };
57
+ //#region src/tool-answer.d.ts
58
+ /**
59
+ * The person's answer to a call that needs approval, for a route's body.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * body: z.object({
64
+ * prompt: z.string(),
65
+ * answer: ToolAnswerSchema.optional(),
66
+ * }),
67
+ * ```
68
+ */
69
+ declare const ToolAnswerSchema: z.ZodObject<{
70
+ call: z.ZodObject<{
71
+ id: z.ZodString;
72
+ name: z.ZodString;
73
+ input: z.ZodOptional<z.ZodUnknown>;
74
+ }, z.core.$strip>;
75
+ approved: z.ZodBoolean;
76
+ }, z.core.$strip>;
77
+ //#endregion
78
+ export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ToolAnswerSchema, type ValidationError, type ValidationErrorFor, ValidationErrorSchema, type ValidationIssueCode };
@@ -1,5 +1,5 @@
1
- import { t as ProblemDetailsSchema } from "./error-response-BBGSdgYw.mjs";
2
- import { c as ValidationErrorFor, l as ValidationErrorSchema, r as ProtectedResourceMetadataSchema, s as ValidationError, u as ValidationIssueCode } from "./protected-resource-metadata-CA0v5cjg.mjs";
1
+ import { t as ProblemDetailsSchema } from "./error-response-NoOGdh8H.mjs";
2
+ import { c as ValidationErrorFor, l as ValidationErrorSchema, r as ProtectedResourceMetadataSchema, s as ValidationError, u as ValidationIssueCode } from "./protected-resource-metadata-CfBVsqIk.mjs";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/binary.d.ts
@@ -54,4 +54,25 @@ declare const BinarySchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Arra
54
54
  */
55
55
  declare const FileSchema: z.ZodCustom<File, File>;
56
56
  //#endregion
57
- export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, type ValidationError, type ValidationErrorFor, ValidationErrorSchema, type ValidationIssueCode };
57
+ //#region src/tool-answer.d.ts
58
+ /**
59
+ * The person's answer to a call that needs approval, for a route's body.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * body: z.object({
64
+ * prompt: z.string(),
65
+ * answer: ToolAnswerSchema.optional(),
66
+ * }),
67
+ * ```
68
+ */
69
+ declare const ToolAnswerSchema: z.ZodObject<{
70
+ call: z.ZodObject<{
71
+ id: z.ZodString;
72
+ name: z.ZodString;
73
+ input: z.ZodOptional<z.ZodUnknown>;
74
+ }, z.core.$strip>;
75
+ approved: z.ZodBoolean;
76
+ }, z.core.$strip>;
77
+ //#endregion
78
+ export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ToolAnswerSchema, type ValidationError, type ValidationErrorFor, ValidationErrorSchema, type ValidationIssueCode };
package/dist/schemas.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as ProblemDetailsSchema } from "./error-response-C839d8By.mjs";
2
- import { n as FileSchema, o as ValidationErrorSchema, r as ProtectedResourceMetadataSchema, t as BinarySchema } from "./schemas-CJQcc97N.mjs";
3
- export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ValidationErrorSchema };
1
+ import { t as ProblemDetailsSchema } from "./error-response-CNQaKVYd.mjs";
2
+ import { i as ProtectedResourceMetadataSchema, n as BinarySchema, r as FileSchema, s as ValidationErrorSchema, t as ToolAnswerSchema } from "./schemas-HW2FDsvz.mjs";
3
+ export { BinarySchema, FileSchema, ProblemDetailsSchema, ProtectedResourceMetadataSchema, ToolAnswerSchema, ValidationErrorSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizunajs",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.21",
4
4
  "description": "Route declaration, validation, and the adapter API for Kizuna.js",
5
5
  "keywords": [
6
6
  "kizunajs",