@mawaru/sdk 0.18.0 → 0.20.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.
@@ -776,7 +776,7 @@ describe("saveGraphBodySchema(hooks)", () => {
776
776
  on_output: false,
777
777
  })
778
778
 
779
- it("program ノードの hooks 配列を受け付ける(省略時は [] が補われる)", () => {
779
+ it("hooks 配列を受け付ける(省略時は [] が補われる)", () => {
780
780
  const withHooks = {
781
781
  ...programNode(),
782
782
  hooks: [hook(), { ...hook("通知"), ref: "main" }],
@@ -795,14 +795,13 @@ describe("saveGraphBodySchema(hooks)", () => {
795
795
  expect(without.nodes[0]?.hooks).toEqual([])
796
796
  })
797
797
 
798
- it("program 以外のノードへの hooks を拒否する", () => {
798
+ it("program 以外のノードにも hooks をアタッチできる", () => {
799
799
  for (const node of [makeNode(), humanNode()]) {
800
- expect(() =>
801
- saveGraphBodySchema.parse({
802
- nodes: [{ ...node, hooks: [hook()] }],
803
- connections: [],
804
- }),
805
- ).toThrow(/program ノード/)
800
+ const parsed = saveGraphBodySchema.parse({
801
+ nodes: [{ ...node, hooks: [hook()] }],
802
+ connections: [],
803
+ })
804
+ expect(parsed.nodes[0]?.hooks).toHaveLength(1)
806
805
  }
807
806
  })
808
807
 
package/_schemas/graph.ts CHANGED
@@ -208,7 +208,7 @@ export const componentConfigSchema = z.object({
208
208
  })
209
209
  export type ComponentConfig = z.infer<typeof componentConfigSchema>
210
210
 
211
- // ノードにアタッチされた IOHook(node_hooks に対応。アタッチできるのは program ノードのみ)。
211
+ // ノードにアタッチされた IOHook(node_hooks に対応。アタッチは全 kind で可能)。
212
212
  // on_input / on_output / on_signal はアタッチ時に repo の config.json(hookManifestSchema)から
213
213
  // エディタが焼き込むスナップショット。ref 省略時はデフォルトブランチ
214
214
  // (docs/tasks/done/NodeIOHooks(ノードへのIOフックのアタッチ).md・
@@ -385,15 +385,6 @@ export const saveGraphBodySchema = z
385
385
  })
386
386
  }
387
387
 
388
- // フックをアタッチできるのは program ノードのみ
389
- if (node.kind !== "program" && node.hooks.length > 0) {
390
- ctx.addIssue({
391
- code: "custom",
392
- path: ["nodes", i, "hooks"],
393
- message: "フックをアタッチできるのは program ノードだけです",
394
- })
395
- }
396
-
397
388
  // フックの重複アタッチ(unique(node_id, hook_dir) の事前検証)
398
389
  const hookDirs = new Set<string>()
399
390
  node.hooks.forEach((hook, j) => {
@@ -161,7 +161,7 @@ export const componentConfigSchema = z.object({
161
161
  // 起動時の mergeRefs が行う。コンポーネントの設定値(refs)と1ノードのコンポーネント化.md)
162
162
  refs: z.record(z.string(), z.unknown()).optional(),
163
163
  });
164
- // ノードにアタッチされた IOHook(node_hooks に対応。アタッチできるのは program ノードのみ)。
164
+ // ノードにアタッチされた IOHook(node_hooks に対応。アタッチは全 kind で可能)。
165
165
  // on_input / on_output / on_signal はアタッチ時に repo の config.json(hookManifestSchema)から
166
166
  // エディタが焼き込むスナップショット。ref 省略時はデフォルトブランチ
167
167
  // (docs/tasks/done/NodeIOHooks(ノードへのIOフックのアタッチ).md・
@@ -318,14 +318,6 @@ export const saveGraphBodySchema = z
318
318
  message: "out ポートが最低1つ必要です",
319
319
  });
320
320
  }
321
- // フックをアタッチできるのは program ノードのみ
322
- if (node.kind !== "program" && node.hooks.length > 0) {
323
- ctx.addIssue({
324
- code: "custom",
325
- path: ["nodes", i, "hooks"],
326
- message: "フックをアタッチできるのは program ノードだけです",
327
- });
328
- }
329
321
  // フックの重複アタッチ(unique(node_id, hook_dir) の事前検証)
330
322
  const hookDirs = new Set();
331
323
  node.hooks.forEach((hook, j) => {
package/dist/typegen.js CHANGED
@@ -78,6 +78,13 @@ export const tsTypeFromJsonSchema = (schema, indent = 0) => {
78
78
  if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
79
79
  return "unknown";
80
80
  }
81
+ // file 型(x-mawaru-type マーカー):runner が実行前に参照を実体化し、その位置を
82
+ // ワークスペースのローカルパス(文字列)に置き換えて handler へ渡す/handler は
83
+ // 出力にローカルパスを書く契約なので、参照 object ではなく string を生成する
84
+ // (AI 側の schemaWithFilesAsPath と同じ規約)
85
+ if (schema["x-mawaru-type"] === "file") {
86
+ return "string";
87
+ }
81
88
  if ("const" in schema) {
82
89
  return literalType(schema.const);
83
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mawaru/sdk",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "mawaru 実行 repo の開発 SDK。契約スキーマ(config.json 規約・ループ graph API)の正 + typegen / validate CLI",
5
5
  "type": "module",
6
6
  "bin": {