@deepraxis/cli 0.3.0-dev.6da4327 → 0.3.0-dev.9bfcf33

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 (3) hide show
  1. package/COMMANDS.md +11 -8
  2. package/dist/praxis.js +998 -124
  3. package/package.json +1 -1
package/dist/praxis.js CHANGED
@@ -7088,7 +7088,7 @@ across all toolsets allowed.`
7088
7088
  type: "array",
7089
7089
  itemType: "object",
7090
7090
  required: false,
7091
- description: "Platform resources and services this service agent's codemode may reach, as one list of typed bindings. Only kind=service accepts a nonempty list; general and personal agents return 400. There are two kinds. A resource binding names one resource with id and access: database (id db_..., read_only or read_write), vector_store (id vs_..., read_only or read_write), file (id file- plus 24 letters or digits, as the File API returns it; read_only), media_library (any id without ':' or whitespace, read_only or read_write), model (a model catalog id, invoke), workflow and script (id <namespace>/<name>, invoke). A service binding opens a whole service and carries only enabled: search, browser, ticket, crm, canvas or cut. There is no binding by default; enabling one opens every public method of that service. At most 20 bindings per type, no repeated type and id, and each service type at most once. A session is authorized by the agent version it runs: newly added bindings apply only to new sessions, and a version saved with apply=false changes no access until it is applied. Applying a version that disables, removes or downgrades a binding revokes it immediately in running sessions on older versions. A resource that is not bound returns 404, a service that is not opened returns 403, and a write to a resource bound read_only returns 403 BINDING_READ_ONLY. Unknown types, fields on the wrong kind (id, access or instructions on a service binding), wrong access and malformed ids return 400. The former databases, vector_stores and files fields are removed and return 400. Omit on create for no bindings. Saving checks added or changed database, vector_store, media_library and file bindings in the organization: unknown or deleted ids return 400. If an owner is unavailable or takes more than 3 seconds, saving succeeds with verified=false for the affected bindings. Unchanged bindings keep their previous verification result and are not rechecked. workflow and script ids are not verified at save time."
7091
+ description: `Platform resources and services this service agent's codemode may reach, as one list of typed bindings. Only kind=service accepts a nonempty list; general and personal agents return 400. There are two kinds. A resource binding names one resource with id and access: database (id db_..., read_only or read_write), vector_store (id vs_..., read_only or read_write), file (id file- plus 24 letters or digits, as the File API returns it; read_only), media_library (any id without ':' or whitespace, read_only or read_write), model (a model catalog id, invoke), workflow and script (id <namespace>/<name>, invoke). A service binding opens a whole service and carries only enabled: search, browser, ticket, crm, canvas or cut. The ticket service is bound by default: a service agent whose list has no ticket entry may call the ticket API, and {"type": "ticket", "enabled": false} removes it. Every other service stays closed until it is bound. An open service allows every public method of that service. At most 20 bindings per type, no repeated type and id, and each service type at most once. A session is authorized by the agent version it runs: newly added bindings apply only to new sessions, and a version saved with apply=false changes no access until it is applied. Applying a version that disables, removes or downgrades a binding revokes it immediately in running sessions on older versions. A resource that is not bound returns 404, a service that is not opened returns 403, and a write to a resource bound read_only returns 403 BINDING_READ_ONLY. Unknown types, fields on the wrong kind (id, access or instructions on a service binding), wrong access and malformed ids return 400. The former databases, vector_stores and files fields are removed and return 400. Omit on create for the default: the ticket service only. Saving checks added or changed database, vector_store, media_library and file bindings in the organization: unknown or deleted ids return 400. If an owner is unavailable or takes more than 3 seconds, saving succeeds with verified=false for the affected bindings. Unchanged bindings keep their previous verification result and are not rechecked. workflow and script ids are not verified at save time.`
7092
7092
  },
7093
7093
  {
7094
7094
  name: "kind",
@@ -14312,6 +14312,16 @@ file at the root of that directory.`
14312
14312
  required: false,
14313
14313
  description: "可省略;账户使用 default 项目。"
14314
14314
  },
14315
+ {
14316
+ name: "visibility",
14317
+ type: "string",
14318
+ enum: [
14319
+ "private",
14320
+ "organization"
14321
+ ],
14322
+ required: false,
14323
+ description: "谁能看到这个新会话:默认 private 只有创建者;organization 允许同组织其他成员只读观看画面。"
14324
+ },
14315
14325
  {
14316
14326
  name: "keepAlive",
14317
14327
  type: "boolean",
@@ -14503,6 +14513,42 @@ file at the root of that directory.`
14503
14513
  }
14504
14514
  ]
14505
14515
  },
14516
+ {
14517
+ resource: "browser.sessions",
14518
+ method: "retrieveFrame",
14519
+ summary: "读取会话只读画面帧",
14520
+ description: "读取会话的一张只读画面帧(JPEG 字节)。创建者可读,同组织其他成员只在该会话声明为组织可见时可读;其余情况一律返回 404 SESSION_NOT_FOUND,不提示会话是否存在。响应体没有任何可控制浏览器的凭据,且不接受任何动作参数。",
14521
+ http: "GET",
14522
+ path: "/browser/v1/sessions/{sessionId}/frame",
14523
+ streaming: "no",
14524
+ pagination: false,
14525
+ pathParams: [
14526
+ {
14527
+ name: "sessionId",
14528
+ sdkName: "sessionId",
14529
+ description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
14530
+ }
14531
+ ],
14532
+ query: []
14533
+ },
14534
+ {
14535
+ resource: "browser.sessions",
14536
+ method: "frames",
14537
+ summary: "订阅会话只读画面",
14538
+ description: "SSE:只推送只读画面帧,event 为 frame 或 end,data 为帧的 JSON 或 null;帧 data 是 JPEG 的 base64 编码,ts 是浏览器产生该帧的时刻(epoch 毫秒),约每秒最多 5 帧。评论 ping 每 15 秒一次,end 后关闭。这条通道与 /sessions/{sessionId}/stream 相互独立:它的消息只含画面,绝不含 wsUrl、signingKey、connectUrl、debuggerUrl、debuggerFullscreenUrl。创建者可订阅,同组织其他成员只在该会话声明为组织可见时可订阅;其余情况一律返回 404 SESSION_NOT_FOUND。",
14539
+ http: "GET",
14540
+ path: "/browser/v1/sessions/{sessionId}/frames",
14541
+ streaming: "always",
14542
+ pagination: false,
14543
+ pathParams: [
14544
+ {
14545
+ name: "sessionId",
14546
+ sdkName: "sessionId",
14547
+ description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
14548
+ }
14549
+ ],
14550
+ query: []
14551
+ },
14506
14552
  {
14507
14553
  resource: "browser.sessions.handoff",
14508
14554
  method: "create",
@@ -14599,6 +14645,16 @@ file at the root of that directory.`
14599
14645
  type: "string",
14600
14646
  required: true,
14601
14647
  description: "当前观看者的稳定标识;同一观看者重复心跳应使用相同值,长度为 1–128 个 UTF-16 代码单元。"
14648
+ },
14649
+ {
14650
+ name: "kind",
14651
+ type: "string",
14652
+ enum: [
14653
+ "control",
14654
+ "readonly"
14655
+ ],
14656
+ required: false,
14657
+ description: "观看者类型:control 是需要控制浏览器的客户端,readonly 是只读观看者。只读观看者发送 control 也会按 readonly 记录。"
14602
14658
  }
14603
14659
  ]
14604
14660
  }
@@ -21832,7 +21888,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
21832
21888
  resource: "media.libraries.assets",
21833
21889
  method: "list",
21834
21890
  summary: "List assets",
21835
- description: "Upload content into an active library and return a Cloudinary-compatible resource. Use file for a multipart file, data URI, public HTTPS URL or same-owner file identifier. Reusing public_id overwrites by default; overwrite=false returns the existing resource. Chunk uploads require both chunk headers.",
21891
+ description: "Upload content into an active library and return the stored asset. Use file for a multipart file, data URI, public HTTPS URL or same-owner file identifier. Reusing public_id overwrites by default; overwrite=false returns the existing asset. Chunk uploads require both chunk headers.",
21836
21892
  http: "GET",
21837
21893
  path: "/media/v1/libraries/{library_id}/assets",
21838
21894
  streaming: "no",
@@ -21851,17 +21907,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
21851
21907
  required: false,
21852
21908
  description: "Filter by the exact organizational folder path; an empty value selects assets at the root. Descendant folders are not included."
21853
21909
  },
21854
- {
21855
- name: "resource_type",
21856
- type: "string",
21857
- enum: [
21858
- "image",
21859
- "video",
21860
- "raw"
21861
- ],
21862
- required: false,
21863
- description: "image, video (including audio), raw; auto is accepted by Upload actions only, and listing with auto returns 400."
21864
- },
21865
21910
  {
21866
21911
  name: "material_type",
21867
21912
  type: "string",
@@ -21876,10 +21921,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
21876
21921
  "text_template",
21877
21922
  "animation_preset",
21878
21923
  "lut",
21879
- "transition_map"
21924
+ "transition_map",
21925
+ "file"
21880
21926
  ],
21881
21927
  required: false,
21882
- description: "Filter assets to one kind of material, independent of the stored resource_type. Omit to list every material type. Assets stored before this field existed match no material_type filter."
21928
+ description: "Filter assets to one kind of material. Audio is one material type; use audio_role to tell speech, music and sound effects apart. Omit to list every material type."
21883
21929
  },
21884
21930
  {
21885
21931
  name: "cursor",
@@ -21994,18 +22040,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
21994
22040
  required: false,
21995
22041
  description: "Requires an image and visual understanding enabled in the library; otherwise returns UNSUPPORTED. Tagging is asynchronous."
21996
22042
  },
21997
- {
21998
- name: "resource_type",
21999
- type: "string",
22000
- enum: [
22001
- "image",
22002
- "video",
22003
- "raw",
22004
- "auto"
22005
- ],
22006
- required: false,
22007
- description: "Upload category: image for images, video for video or audio, raw for unprocessed files, or auto to detect the category. Defaults to auto."
22008
- },
22009
22043
  {
22010
22044
  name: "type",
22011
22045
  type: "string",
@@ -22117,18 +22151,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22117
22151
  required: false,
22118
22152
  description: "Minimum confidence for adding generated labels to tags, from 0 to 1 inclusive. Requires an image and enabled visual understanding; labels appear after processing completes."
22119
22153
  },
22120
- {
22121
- name: "resource_type",
22122
- type: "string",
22123
- enum: [
22124
- "image",
22125
- "video",
22126
- "raw",
22127
- "auto"
22128
- ],
22129
- required: false,
22130
- description: "Upload category: image for images, video for video or audio, raw for unprocessed files, or auto to detect the category. Defaults to auto."
22131
- },
22132
22154
  {
22133
22155
  name: "type",
22134
22156
  type: "string",
@@ -22245,7 +22267,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22245
22267
  resource: "media.assets",
22246
22268
  method: "edit",
22247
22269
  summary: "Edit asset",
22248
- description: "Edit an existing asset and store the result as a new asset. Use library_id from creation or listing and asset_id from asset creation or listing; library_id also accepts the literal default, which resolves to the organization’s default library before the credential check. The source asset is never overwritten: the new asset hangs under it in the edit chain, records it in derived_from, and reads back with assets.lineage, so earlier steps stay reachable. The body is operation plus the optional model, asset_folder, understanding and idempotency_key; operation.type selects the edit and carries that operation’s own fields. This release performs variations, inpaint, erase, replace_object, recolor, remove_background and replace_background on images; every other type in the operation vocabulary — the video and audio edits — is refused with OPERATION_NOT_SUPPORTED. inpaint takes mask, a PNG File identifier beginning with file- whose transparent area marks the region to replace, plus the prompt describing what belongs there. Aspects beyond the source asset’s material type return REFERENCE_TYPE_MISMATCH. Editing is charged through Router and the job records the charge in usage. The response is 202 with a queued Job whose type is image, whose operation is the edit applied, and whose source_asset_id is the asset edited; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until it is completed or failed, then read the produced asset. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/edits with {\"operation\":{\"type\":\"variations\",\"strength\":\"subtle\"}}.",
22270
+ description: "Edit an existing asset and store the result as a new asset. Use library_id from creation or listing and asset_id from asset creation or listing; library_id also accepts the literal default, which resolves to the organization’s default library before the credential check. The source asset is never overwritten: the new asset hangs under it in the edit chain, records it in derived_from, and reads back with assets.lineage, so earlier steps stay reachable. The body is operation plus the optional model, asset_folder, understanding and idempotency_key; operation.type selects the edit and carries that operation’s own fields. This release performs variations, inpaint, erase, replace_object, recolor, remove_background and replace_background on images; every other type in the operation vocabulary — the video and audio edits — is refused with OPERATION_NOT_SUPPORTED. inpaint takes mask, a PNG File identifier beginning with file- whose transparent area marks the region to replace, plus the prompt describing what belongs there. Aspects beyond the source asset’s material type return REFERENCE_TYPE_MISMATCH. Editing is billed by the model usage it consumes, at the same prices as the model API, and the job records the charge in usage. The response is 202 with a queued Job whose type is image, whose operation is the edit applied, and whose source_asset_id is the asset edited; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until it is completed or failed, then read the produced asset. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/edits with {\"operation\":{\"type\":\"variations\",\"strength\":\"subtle\"}}.",
22249
22271
  http: "POST",
22250
22272
  path: "/media/v1/libraries/{library_id}/assets/{asset_id}/edits",
22251
22273
  streaming: "no",
@@ -22276,7 +22298,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22276
22298
  name: "model",
22277
22299
  type: "string",
22278
22300
  required: false,
22279
- description: "Router model that performs the edit; omit it to use the library default image model."
22301
+ description: "Model that performs the edit; omit it to use the library default image model."
22280
22302
  },
22281
22303
  {
22282
22304
  name: "asset_folder",
@@ -22513,7 +22535,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22513
22535
  resource: "media.speech",
22514
22536
  method: "create",
22515
22537
  summary: "Create speech",
22516
- description: "Synthesise speech from text and store the recording straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still synthesise. input is the text to speak and voice is required; speed is passed to the provider unchanged, and instructions and language are refused with OPERATION_NOT_SUPPORTED in this release. A voice that names a voice material of this library is refused the same way — voice cloning opens with voices.create. The provider caps one request at a short stretch of text, so a long input is cut into segments at paragraph and sentence boundaries and synthesised in order, then joined into the single recording the library receives: nothing is spoken twice and nothing is dropped. Because the segments are joined byte for byte, a multi-segment input accepts only response_format mp3 (the default) or pcm; opus is available for a single-segment input. A speech job has one result however many segments it took. Synthesis is charged through Router and the job records the charge in usage; a request refused before it starts costs nothing. The response is 202 with a queued Job whose type is speech and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced asset from the library — the recording carries material_type audio, audio_role voice, ai_generated true, and provenance naming this job, the text spoken and the model. Send Idempotency-Key, or idempotency_key in the body, to retry without synthesising and charging twice. Example: POST /media/v1/libraries/default/audio/speech with {\"input\":\"A red kite above a calm sea at sunrise.\",\"voice\":\"alloy\"}.",
22538
+ description: "Synthesise speech from text and store the recording straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still synthesise. input is the text to speak and voice is required; speed is passed to the provider unchanged, and instructions and language are refused with OPERATION_NOT_SUPPORTED in this release. A voice that names a voice material of this library is refused the same way — voice cloning opens with voices.create. The provider caps one request at a short stretch of text, so a long input is cut into segments at paragraph and sentence boundaries and synthesised in order, then joined into the single recording the library receives: nothing is spoken twice and nothing is dropped. Because the segments are joined byte for byte, a multi-segment input accepts only response_format mp3 (the default) or pcm; opus is available for a single-segment input. A speech job has one result however many segments it took. Synthesis is billed by the model usage it consumes, at the same prices as the model API, and the job records the charge in usage; a request refused before it starts costs nothing. The response is 202 with a queued Job whose type is speech and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced asset from the library — the recording carries material_type audio, audio_role voice, ai_generated true, and provenance naming this job, the text spoken and the model. Send Idempotency-Key, or idempotency_key in the body, to retry without synthesising and charging twice. Example: POST /media/v1/libraries/default/audio/speech with {\"input\":\"A red kite above a calm sea at sunrise.\",\"voice\":\"alloy\"}.",
22517
22539
  http: "POST",
22518
22540
  path: "/media/v1/libraries/{library_id}/audio/speech",
22519
22541
  streaming: "no",
@@ -22745,7 +22767,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22745
22767
  resource: "media.images",
22746
22768
  method: "generate",
22747
22769
  summary: "Generate image",
22748
- description: "Generate one or more images from a text prompt and store them straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still generate. The request body is the image request itself: prompt is required, and n, size, background, output_format, output, references, seed, model, asset_folder and understanding are optional. Set output to sticker for a cut-out with a transparent background. references attach existing assets with a role — edit_target, style, structure or subject — and a model that cannot honour a role returns REFERENCE_TYPE_MISMATCH. Aspect ratio is not accepted for images; name size instead. Generation is charged through Router and the job records the charge in usage; nothing is charged for a request refused before it starts. The response is 202 with a queued Job whose type is image and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced assets from the library. Send Idempotency-Key, or idempotency_key in the body, to retry without generating and charging twice. Example: POST /media/v1/libraries/default/images/generations with {\"prompt\":\"A red kite above a calm sea at sunrise\",\"n\":1,\"output\":\"sticker\"}.",
22770
+ description: "Generate one or more images from a text prompt and store them straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still generate. The request body is the image request itself: prompt is required, and n, size, background, output_format, output, references, seed, model, asset_folder and understanding are optional. Set output to sticker for a cut-out with a transparent background. references attach existing assets with a role — edit_target, style, structure or subject — and a model that cannot honour a role returns REFERENCE_TYPE_MISMATCH. Aspect ratio is not accepted for images; name size instead. Generation is billed by the model usage it consumes, at the same prices as the model API, and the job records the charge in usage; nothing is charged for a request refused before it starts. The response is 202 with a queued Job whose type is image and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced assets from the library. Send Idempotency-Key, or idempotency_key in the body, to retry without generating and charging twice. Example: POST /media/v1/libraries/default/images/generations with {\"prompt\":\"A red kite above a calm sea at sunrise\",\"n\":1,\"output\":\"sticker\"}.",
22749
22771
  http: "POST",
22750
22772
  path: "/media/v1/libraries/{library_id}/images/generations",
22751
22773
  streaming: "no",
@@ -22765,7 +22787,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22765
22787
  name: "prompt",
22766
22788
  type: "string",
22767
22789
  required: true,
22768
- description: "Text prompt describing the image to generate; Router forwards it to the image model unchanged."
22790
+ description: "Text prompt describing the image to generate; the image model receives it unchanged."
22769
22791
  },
22770
22792
  {
22771
22793
  name: "negative_prompt",
@@ -22783,7 +22805,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22783
22805
  name: "size",
22784
22806
  type: "string",
22785
22807
  required: false,
22786
- description: "Requested pixel size written as width x height. Router validates it against the chosen model and rejects an unsupported size with INVALID_PARAMS."
22808
+ description: "Requested pixel size written as width x height. The chosen model is validated against it and an unsupported size is rejected with INVALID_PARAMS."
22787
22809
  },
22788
22810
  {
22789
22811
  name: "background",
@@ -22822,7 +22844,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22822
22844
  type: "array",
22823
22845
  itemType: "object",
22824
22846
  required: false,
22825
- description: "Existing assets the model may use, each with the role it plays. Router answers REFERENCE_TYPE_MISMATCH when the chosen model cannot honour a role."
22847
+ description: "Existing assets the model may use, each with the role it plays. A chosen model that cannot honour a role answers REFERENCE_TYPE_MISMATCH."
22826
22848
  },
22827
22849
  {
22828
22850
  name: "seed",
@@ -22834,7 +22856,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
22834
22856
  name: "model",
22835
22857
  type: "string",
22836
22858
  required: false,
22837
- description: "Router model with image-generation capability; omit it to use the library default image model."
22859
+ description: "Model with image-generation capability; omit it to use the library default image model."
22838
22860
  },
22839
22861
  {
22840
22862
  name: "asset_folder",
@@ -23052,10 +23074,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23052
23074
  "text_template",
23053
23075
  "animation_preset",
23054
23076
  "lut",
23055
- "transition_map"
23077
+ "transition_map",
23078
+ "file"
23056
23079
  ],
23057
23080
  required: false,
23058
- description: "What this asset is as a reusable material, as opposed to resource_type (its stored file category). Omitted on assets stored before this field existed and on raw assets that are not materials."
23081
+ description: "What this asset is as a reusable material. Always present: a file whose specific kind cannot be identified is file."
23059
23082
  }
23060
23083
  ]
23061
23084
  }
@@ -23121,7 +23144,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23121
23144
  type: "array",
23122
23145
  itemType: "string",
23123
23146
  enum: [
23124
- "resource_type",
23147
+ "material_type",
23125
23148
  "format",
23126
23149
  "asset_folder",
23127
23150
  "processing_state"
@@ -23194,10 +23217,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23194
23217
  "text_template",
23195
23218
  "animation_preset",
23196
23219
  "lut",
23197
- "transition_map"
23220
+ "transition_map",
23221
+ "file"
23198
23222
  ],
23199
23223
  required: false,
23200
- description: "What this asset is as a reusable material, as opposed to resource_type (its stored file category). Omitted on assets stored before this field existed and on raw assets that are not materials."
23224
+ description: "What this asset is as a reusable material. Always present: a file whose specific kind cannot be identified is file."
23201
23225
  }
23202
23226
  ]
23203
23227
  }
@@ -23314,7 +23338,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23314
23338
  resource: "media.videos",
23315
23339
  method: "generate",
23316
23340
  summary: "Generate video",
23317
- description: "Generate one or more videos from a text prompt and store them straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still generate. mode says what the video is anchored to: text needs only a prompt, image animates the existing image named by first_frame, and first_last interpolates between first_frame and last_frame. The frames must be image or sticker assets of the same library; Router is sent a fetchable URL for each, recorded in the produced asset’s provenance. mode reference and output gif are refused with OPERATION_NOT_SUPPORTED in this release, and negative_prompt, references and an unknown mode are refused before anything is charged. Every output lands in the library as a video asset as soon as it is ready — there is no candidate state and nothing expires, so outputs.save is not part of this lane. Generation is charged per second through Router and the job records the charge in usage; a refused request costs nothing. The response is 202 with a queued Job whose type is video and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced assets from the library. Send Idempotency-Key, or idempotency_key in the body, to retry without generating and charging twice. Example: POST /media/v1/libraries/default/videos/generations with {\"prompt\":\"A red kite above a calm sea at sunrise\",\"mode\":\"text\",\"n\":1}.",
23341
+ description: "Generate one or more videos from a text prompt and store them straight into the library. Use library_id from creation or listing; the path segment {library_id} also accepts the literal default, which resolves to the organization’s default library before the credential check, so an agent that has never listed a library can still generate. mode says what the video is anchored to: text needs only a prompt, image animates the existing image named by first_frame, and first_last interpolates between first_frame and last_frame. The frames must be image or sticker assets of the same library; a fetchable URL for each is sent to the model and recorded in the produced asset’s provenance. mode reference and output gif are refused with OPERATION_NOT_SUPPORTED in this release, and negative_prompt, references and an unknown mode are refused before anything is charged. Every output lands in the library as a video asset as soon as it is ready — there is no candidate state and nothing expires, so outputs.save is not part of this lane. Generation is billed per second by the model usage it consumes, at the same prices as the model API, and the job records the charge in usage; a refused request costs nothing. The response is 202 with a queued Job whose type is video and whose operation is generate; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed, then read the produced assets from the library. Send Idempotency-Key, or idempotency_key in the body, to retry without generating and charging twice. Example: POST /media/v1/libraries/default/videos/generations with {\"prompt\":\"A red kite above a calm sea at sunrise\",\"mode\":\"text\",\"n\":1}.",
23318
23342
  http: "POST",
23319
23343
  path: "/media/v1/libraries/{library_id}/videos/generations",
23320
23344
  streaming: "no",
@@ -23334,7 +23358,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23334
23358
  name: "prompt",
23335
23359
  type: "string",
23336
23360
  required: true,
23337
- description: "Text prompt describing the video to generate; Router forwards it to the video model unchanged."
23361
+ description: "Text prompt describing the video to generate; the video model receives it unchanged."
23338
23362
  },
23339
23363
  {
23340
23364
  name: "negative_prompt",
@@ -23377,7 +23401,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23377
23401
  name: "duration_seconds",
23378
23402
  type: "integer",
23379
23403
  required: false,
23380
- description: "Requested video length in seconds. Router validates it against the chosen model’s supported durations and rejects an unsupported value with INVALID_PARAMS."
23404
+ description: "Requested video length in seconds. The chosen model’s supported durations are validated against it and an unsupported value is rejected with INVALID_PARAMS."
23381
23405
  },
23382
23406
  {
23383
23407
  name: "resolution",
@@ -23389,13 +23413,13 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23389
23413
  "4k"
23390
23414
  ],
23391
23415
  required: false,
23392
- description: "Requested output resolution; Router validates it against the chosen model."
23416
+ description: "Requested output resolution, validated against the chosen model."
23393
23417
  },
23394
23418
  {
23395
23419
  name: "aspect_ratio",
23396
23420
  type: "string",
23397
23421
  required: false,
23398
- description: "Output aspect ratio written as width:height; defaults to 16:9. Router validates it against the chosen model and rejects an unsupported ratio with INVALID_PARAMS."
23422
+ description: "Output aspect ratio written as width:height; defaults to 16:9. The chosen model is validated against it and an unsupported ratio is rejected with INVALID_PARAMS."
23399
23423
  },
23400
23424
  {
23401
23425
  name: "generate_audio",
@@ -23429,7 +23453,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
23429
23453
  name: "model",
23430
23454
  type: "string",
23431
23455
  required: false,
23432
- description: "Router model with video-generation capability; omit it to use the library default video model."
23456
+ description: "Model with video-generation capability; omit it to use the library default video model."
23433
23457
  },
23434
23458
  {
23435
23459
  name: "asset_folder",
@@ -25093,7 +25117,9 @@ for more details.`
25093
25117
  "openai.images.generations",
25094
25118
  "openai.responses",
25095
25119
  "openai.videos",
25096
- "typesafe.systemone"
25120
+ "typesafe.systemone",
25121
+ "volcengine.music",
25122
+ "volcengine.voice_clone"
25097
25123
  ],
25098
25124
  required: false,
25099
25125
  description: "Match any comma-separated declared protocol ID; omitted or empty includes all models. Combined with type and output_modalities using AND. Invalid IDs return 400 with all legal values."
@@ -29193,6 +29219,12 @@ for more details.`
29193
29219
  required: true,
29194
29220
  description: "Name as the text will mention it; it must be unique inside this library after normalization, and it is what a unit claims when it links this entry."
29195
29221
  },
29222
+ {
29223
+ name: "group",
29224
+ type: "string",
29225
+ required: false,
29226
+ description: "Free-text group to file this entry under, such as a layer of the setting, a faction or a cast, so people and later sessions find related entries together; leave it out or send an empty string for no group. At most 60 characters."
29227
+ },
29196
29228
  {
29197
29229
  name: "aliases",
29198
29230
  type: "array",
@@ -29364,6 +29396,12 @@ for more details.`
29364
29396
  required: false,
29365
29397
  description: "New name for this entry, which also changes what the text has to mention for detection to find it."
29366
29398
  },
29399
+ {
29400
+ name: "group",
29401
+ type: "string",
29402
+ required: false,
29403
+ description: "New group, replacing the previous one when group is named in the update mask; an empty string removes the entry from its group. At most 60 characters."
29404
+ },
29367
29405
  {
29368
29406
  name: "aliases",
29369
29407
  type: "array",
@@ -32261,6 +32299,31 @@ for more details.`
32261
32299
  }
32262
32300
  ]
32263
32301
  },
32302
+ {
32303
+ resource: "ticket.repositories",
32304
+ method: "update",
32305
+ summary: "Update repositories",
32306
+ description: "Update repositories within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
32307
+ http: "PATCH",
32308
+ path: "/ticket/v1/repositories/{id}",
32309
+ streaming: "no",
32310
+ pagination: false,
32311
+ pathParams: [
32312
+ {
32313
+ name: "id",
32314
+ sdkName: "id",
32315
+ description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
32316
+ }
32317
+ ],
32318
+ query: [
32319
+ {
32320
+ name: "repository",
32321
+ type: "string",
32322
+ required: false,
32323
+ description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
32324
+ }
32325
+ ]
32326
+ },
32264
32327
  {
32265
32328
  resource: "ticket.tickets",
32266
32329
  method: "list",
@@ -35680,6 +35743,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
35680
35743
  ...options.headers
35681
35744
  }
35682
35745
  });
35746
+ var browserGetSessionFrame = (options) => (options.client ?? client).get({
35747
+ security: [{
35748
+ key: "BrowserBearer",
35749
+ scheme: "bearer",
35750
+ type: "http"
35751
+ }],
35752
+ url: "/browser/v1/sessions/{sessionId}/frame",
35753
+ ...options
35754
+ });
35683
35755
  var browserListContexts = (options) => (options?.client ?? client).get({
35684
35756
  security: [{
35685
35757
  key: "BrowserBearer",
@@ -35768,6 +35840,15 @@ var browserStreamSession = (options) => (options.client ?? client).sse.get({
35768
35840
  url: "/browser/v1/sessions/{sessionId}/stream",
35769
35841
  ...options
35770
35842
  });
35843
+ var browserStreamSessionFrames = (options) => (options.client ?? client).sse.get({
35844
+ security: [{
35845
+ key: "BrowserBearer",
35846
+ scheme: "bearer",
35847
+ type: "http"
35848
+ }],
35849
+ url: "/browser/v1/sessions/{sessionId}/frames",
35850
+ ...options
35851
+ });
35771
35852
  var browserSeleniumUnsupported = (options) => (options?.client ?? client).get({
35772
35853
  security: [{
35773
35854
  key: "BrowserBearer",
@@ -44187,6 +44268,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
44187
44268
  url: "/ticket/v1/repositories",
44188
44269
  ...options
44189
44270
  });
44271
+ var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
44272
+ security: [{
44273
+ key: "BearerAuth",
44274
+ scheme: "bearer",
44275
+ type: "http"
44276
+ }, {
44277
+ key: "ApiKeyAuth",
44278
+ name: "X-API-Key",
44279
+ type: "apiKey"
44280
+ }],
44281
+ url: "/ticket/v1/repositories/{id}",
44282
+ ...options
44283
+ });
44190
44284
 
44191
44285
  // ../../packages/sdk/typescript/src/core/pagination.ts
44192
44286
  class Page {
@@ -44634,6 +44728,7 @@ function createBrowser(transport) {
44634
44728
  events: {
44635
44729
  list: bind(transport, browserListEvents)
44636
44730
  },
44731
+ frames: bindStream(transport, browserStreamSessionFrames),
44637
44732
  handoff: {
44638
44733
  complete: bind(transport, browserCompleteHandoff),
44639
44734
  create: bind(transport, browserRequestHandoff)
@@ -44641,6 +44736,7 @@ function createBrowser(transport) {
44641
44736
  list: bind(transport, browserListSessions),
44642
44737
  retrieve: bind(transport, browserGetSession),
44643
44738
  retrieveDebug: bind(transport, browserGetDebug),
44739
+ retrieveFrame: bind(transport, browserGetSessionFrame),
44644
44740
  stream: bindStream(transport, browserStreamSession),
44645
44741
  update: bind(transport, browserCloseSession),
44646
44742
  viewer: {
@@ -45480,7 +45576,8 @@ function createTicket(transport) {
45480
45576
  update: bind(transport, ticketPatchMilestonesNumber)
45481
45577
  },
45482
45578
  repositories: {
45483
- list: bind(transport, ticketGetRepositories)
45579
+ list: bind(transport, ticketGetRepositories),
45580
+ update: bind(transport, ticketPatchRepositoriesId)
45484
45581
  },
45485
45582
  tickets: {
45486
45583
  comments: {
@@ -49769,7 +49866,7 @@ function retop(store, id, top, rev) {
49769
49866
  // ../../packages/canvas/document/src/connector.ts
49770
49867
  var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
49771
49868
  var ARROWS = ["end", "start", "both", "none"];
49772
- var ROUTES = ["straight"];
49869
+ var ROUTES = ["straight", "elbow"];
49773
49870
  var ARROW_LENGTH_FACTOR = 6;
49774
49871
  var ARROW_HALF_ANGLE_DEG = 25;
49775
49872
  var EPSILON = 0.000000001;
@@ -49857,6 +49954,30 @@ function normalize(p) {
49857
49954
  const l = Math.hypot(p.x, p.y);
49858
49955
  return { x: p.x / l, y: p.y / l };
49859
49956
  }
49957
+ function rectsOverlap(a, b) {
49958
+ return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
49959
+ }
49960
+ function segmentCrossesBox(a, b, box) {
49961
+ const shrink = 0.000001;
49962
+ const dx = b.x - a.x;
49963
+ const dy = b.y - a.y;
49964
+ let t0 = 0;
49965
+ let t1 = 1;
49966
+ const slab = (start, delta, min, max) => {
49967
+ if (Math.abs(delta) < 0.000000000001)
49968
+ return start > min && start < max;
49969
+ const ta = (min - start) / delta;
49970
+ const tb = (max - start) / delta;
49971
+ t0 = Math.max(t0, Math.min(ta, tb));
49972
+ t1 = Math.min(t1, Math.max(ta, tb));
49973
+ return t0 <= t1;
49974
+ };
49975
+ if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
49976
+ return false;
49977
+ if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
49978
+ return false;
49979
+ return t1 > t0;
49980
+ }
49860
49981
  function dashRanges(length, dash) {
49861
49982
  const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
49862
49983
  if (!pattern.length)
@@ -49878,40 +49999,106 @@ function n(value) {
49878
49999
  const rounded = Math.round(value * 100) / 100;
49879
50000
  return String(Object.is(rounded, -0) ? 0 : rounded);
49880
50001
  }
50002
+ var isHorizontal = (side) => side === "left" || side === "right";
50003
+ function elbowPath(from, to, fromMagnet, toMagnet) {
50004
+ if (fromMagnet === "center" || toMagnet === "center")
50005
+ throw new OpRejectedError({
50006
+ code: "INVALID_VALUE",
50007
+ property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
50008
+ reason: "elbow routing needs an edge, not the centre"
50009
+ });
50010
+ const dx = centerOf(to.box).x - centerOf(from.box).x;
50011
+ const dy = centerOf(to.box).y - centerOf(from.box).y;
50012
+ const across = Math.abs(dx) > Math.abs(dy);
50013
+ const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
50014
+ const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
50015
+ const p1 = magnetPoint(from.box, fromSide);
50016
+ const p2 = magnetPoint(to.box, toSide);
50017
+ const out = [p1];
50018
+ if (isHorizontal(fromSide) === isHorizontal(toSide)) {
50019
+ if (isHorizontal(fromSide)) {
50020
+ const midX = (p1.x + p2.x) / 2;
50021
+ out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
50022
+ } else {
50023
+ const midY = (p1.y + p2.y) / 2;
50024
+ out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
50025
+ }
50026
+ } else {
50027
+ out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
50028
+ }
50029
+ out.push(p2);
50030
+ const kept = [];
50031
+ for (const p of out) {
50032
+ const last = kept[kept.length - 1];
50033
+ if (last && last.x === p.x && last.y === p.y)
50034
+ continue;
50035
+ if (last && kept.length >= 2) {
50036
+ const before = kept[kept.length - 2];
50037
+ if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
50038
+ kept.pop();
50039
+ }
50040
+ kept.push(p);
50041
+ }
50042
+ return kept;
50043
+ }
50044
+ function cumulative(points) {
50045
+ const cum = [0];
50046
+ for (let i = 1;i < points.length; i++)
50047
+ cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
50048
+ return cum;
50049
+ }
50050
+ function pointAt(points, cum, s) {
50051
+ const total = cum[cum.length - 1];
50052
+ const at = Math.max(0, Math.min(s, total));
50053
+ let i = 0;
50054
+ while (i < points.length - 2 && cum[i + 1] < at)
50055
+ i++;
50056
+ const span = cum[i + 1] - cum[i];
50057
+ const f = span < EPSILON ? 0 : (at - cum[i]) / span;
50058
+ const a = points[i];
50059
+ const b = points[i + 1];
50060
+ return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
50061
+ }
49881
50062
  function connectorGeometry(from, to, opts = {}) {
49882
50063
  const arrow = opts.arrow ?? "end";
49883
50064
  const strokeWidth = opts.strokeWidth ?? 1.5;
49884
50065
  const labelPos = opts.labelPos ?? 0.5;
49885
50066
  const fromMagnet = opts.fromMagnet ?? "auto";
49886
50067
  const toMagnet = opts.toMagnet ?? "auto";
49887
- const fromCenter = centerOf(from.box);
49888
- const toCenter = centerOf(to.box);
49889
- const p1 = endPoint(from, fromMagnet, toCenter);
49890
- const p2 = endPoint(to, toMagnet, fromCenter);
49891
- const length = Math.hypot(p2.x - p1.x, p2.y - p1.y);
50068
+ if (rectsOverlap(from.box, to.box))
50069
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50070
+ const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
50071
+ const cum = cumulative(points);
50072
+ const length = cum[cum.length - 1];
50073
+ const p1 = points[0];
50074
+ const p2 = points[points.length - 1];
49892
50075
  if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
49893
50076
  throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
49894
- const dir = normalize({ x: p2.x - p1.x, y: p2.y - p1.y });
49895
- const back = { x: -dir.x, y: -dir.y };
50077
+ const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
50078
+ const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
50079
+ const back = { x: -dir2.x, y: -dir2.y };
49896
50080
  const arrowHeads = [];
49897
50081
  if (arrow === "end" || arrow === "both")
49898
50082
  arrowHeads.push(arrowHead(p2, back, strokeWidth));
49899
50083
  if (arrow === "start" || arrow === "both")
49900
- arrowHeads.push(arrowHead(p1, dir, strokeWidth));
49901
- const xs = [p1.x, p2.x];
49902
- const ys = [p1.y, p2.y];
50084
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50085
+ const xs = points.map((p) => p.x);
50086
+ const ys = points.map((p) => p.y);
49903
50087
  for (const head of arrowHeads) {
49904
50088
  xs.push(head.tip.x, head.left.x, head.right.x);
49905
50089
  ys.push(head.tip.y, head.left.y, head.right.y);
49906
50090
  }
49907
50091
  const bbox = { x: Math.min(...xs), y: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) };
49908
50092
  const local = (p) => ({ x: p.x - bbox.x, y: p.y - bbox.y });
49909
- const at = (t) => ({ x: p1.x + (p2.x - p1.x) * t, y: p1.y + (p2.y - p1.y) * t });
49910
50093
  const parts = [];
49911
50094
  for (const [start, end] of dashRanges(length, opts.dash)) {
49912
- const a = local(at(start / length));
49913
- const b = local(at(end / length));
49914
- parts.push(`M${n(a.x)} ${n(a.y)}L${n(b.x)} ${n(b.y)}`);
50095
+ const run = [pointAt(points, cum, start)];
50096
+ for (let i = 1;i < points.length - 1; i++)
50097
+ if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
50098
+ run.push(points[i]);
50099
+ run.push(pointAt(points, cum, end));
50100
+ const traced = run.length > 2 ? [...run, ...run.slice(0, -1).reverse()] : run;
50101
+ parts.push(traced.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
49915
50102
  }
49916
50103
  for (const head of arrowHeads) {
49917
50104
  const t = local(head.tip);
@@ -49919,7 +50106,7 @@ function connectorGeometry(from, to, opts = {}) {
49919
50106
  const r = local(head.right);
49920
50107
  parts.push(`M${n(t.x)} ${n(t.y)}L${n(l.x)} ${n(l.y)}L${n(r.x)} ${n(r.y)}Z`);
49921
50108
  }
49922
- return { points: [p1, p2], arrowHeads, bbox, labelCenter: at(labelPos), geometry: parts.join("") };
50109
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
49923
50110
  }
49924
50111
  // ../../packages/canvas/document/src/expand.ts
49925
50112
  function defaultTheme(themes) {
@@ -50198,10 +50385,476 @@ function checkLiveNode(node2) {
50198
50385
  return { warnings };
50199
50386
  }
50200
50387
 
50388
+ // ../../packages/canvas/document/src/kit.ts
50389
+ function kitStampOf(node2) {
50390
+ const meta = node2?.metadata;
50391
+ const stamp = meta?.kit;
50392
+ if (!stamp || typeof stamp.key !== "string" || typeof stamp.version !== "number" || typeof stamp.name !== "string")
50393
+ return;
50394
+ return { name: stamp.name, version: stamp.version, key: stamp.key };
50395
+ }
50396
+ function remapRefs(node2, refId) {
50397
+ const { children, ...rest } = node2;
50398
+ const out = { ...rest };
50399
+ if (typeof out.ref === "string")
50400
+ out.ref = refId.get(out.ref) ?? out.ref;
50401
+ const descendants = out.descendants;
50402
+ if (descendants && typeof descendants === "object" && !Array.isArray(descendants)) {
50403
+ const mapped = {};
50404
+ for (const [path, value] of Object.entries(descendants)) {
50405
+ const rewritten = path.split("/").map((seg) => refId.get(seg) ?? seg).join("/");
50406
+ mapped[rewritten] = value;
50407
+ }
50408
+ out.descendants = mapped;
50409
+ }
50410
+ if (Array.isArray(children))
50411
+ out.children = children.map((c) => remapRefs(c, refId));
50412
+ return out;
50413
+ }
50414
+ function planKit(existing, kit) {
50415
+ const canvasId = new Map;
50416
+ const haveVersion = new Map;
50417
+ for (const node2 of existing) {
50418
+ if (canvasId.has(node2.key))
50419
+ continue;
50420
+ canvasId.set(node2.key, node2.id);
50421
+ haveVersion.set(node2.key, node2.version);
50422
+ }
50423
+ const refId = new Map;
50424
+ const keys2 = new Set;
50425
+ for (const component of kit.components) {
50426
+ const stamp = kitStampOf(component);
50427
+ if (!stamp)
50428
+ throw new Error(`kit ${kit.name}: component ${component.id} carries no metadata.kit stamp`);
50429
+ if (keys2.has(stamp.key))
50430
+ throw new Error(`kit ${kit.name}: duplicate component key ${stamp.key}`);
50431
+ keys2.add(stamp.key);
50432
+ refId.set(component.id, canvasId.get(stamp.key) ?? component.id);
50433
+ }
50434
+ const plan = { add: [], update: [], unchanged: 0, variables: Object.keys(kit.variables).length };
50435
+ for (const component of kit.components) {
50436
+ const stamp = kitStampOf(component);
50437
+ const id = refId.get(component.id);
50438
+ const node2 = id === component.id ? remapRefs(component, refId) : { ...remapRefs(component, refId), id };
50439
+ const version = haveVersion.get(stamp.key);
50440
+ if (version === undefined)
50441
+ plan.add.push(node2);
50442
+ else if (version >= kit.version)
50443
+ plan.unchanged++;
50444
+ else
50445
+ plan.update.push({ id, node: node2 });
50446
+ }
50447
+ return plan;
50448
+ }
50449
+ function existingKitNodesIn(store, kitName) {
50450
+ const out = [];
50451
+ const walk = (id) => {
50452
+ const row = store.get(id);
50453
+ if (!row)
50454
+ return;
50455
+ const stamp = kitStampOf(row.props);
50456
+ if (stamp && (kitName === undefined || stamp.name === kitName))
50457
+ out.push({ key: stamp.key, version: stamp.version, id });
50458
+ for (const child of store.children(id))
50459
+ walk(child);
50460
+ };
50461
+ for (const top of store.children(null))
50462
+ walk(top);
50463
+ return out;
50464
+ }
50465
+ function kitFrameIn(store, frame) {
50466
+ return store.children(null).find((id) => {
50467
+ const props = store.get(id)?.props;
50468
+ return props?.type === "frame" && props.name === frame;
50469
+ });
50470
+ }
50471
+ var componentName = (node2) => {
50472
+ const name = node2.name;
50473
+ return typeof name === "string" && name !== "" ? name : kitStampOf(node2).key;
50474
+ };
50475
+ function kitPlanNames(plan) {
50476
+ return { added: plan.add.map(componentName), updated: plan.update.map((u) => componentName(u.node)) };
50477
+ }
50478
+ function planRefs(plan) {
50479
+ const ids = new Set;
50480
+ const refs = [];
50481
+ const visit2 = (node2, collectIds) => {
50482
+ if (collectIds)
50483
+ ids.add(node2.id);
50484
+ if (node2.type === "ref" && typeof node2.ref === "string")
50485
+ refs.push(node2.ref);
50486
+ for (const child of Array.isArray(node2.children) ? node2.children : [])
50487
+ visit2(child, collectIds);
50488
+ };
50489
+ for (const node2 of plan.add)
50490
+ visit2(node2, true);
50491
+ for (const entry of plan.update)
50492
+ visit2(entry.node, false);
50493
+ return { refs, ids };
50494
+ }
50495
+
50496
+ // ../../packages/canvas/document/src/kit-builders.ts
50497
+ var PRAXIS_UI_LITERALS = {
50498
+ "v3-surface-2": "#F1F3F2",
50499
+ "v3-border": "#E3E7E4",
50500
+ "v3-border-strong": "#CDD3CF",
50501
+ "v3-fg": "#0D1310",
50502
+ "v3-fg-2": "#4A5550",
50503
+ "v3-fg-3": "#6E7872",
50504
+ "v3-green-50": "#EEFBF3",
50505
+ "v3-green-700": "#167A43",
50506
+ "v3-code-bg": "#0F1512",
50507
+ "v3-code-fg": "#D6E2DB",
50508
+ "v3-danger": "#D92D20",
50509
+ "v3-danger-soft": "#FEF0EE",
50510
+ "v3-warning": "#C76A00",
50511
+ "v3-warning-soft": "#FFF6E5",
50512
+ "v3-info": "#2563EB",
50513
+ "v3-info-soft": "#EEF4FF",
50514
+ "v3-font": "Geist",
50515
+ "v3-mono": "Geist Mono",
50516
+ "r-md": 8
50517
+ };
50518
+ function token(ctx, name) {
50519
+ return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
50520
+ }
50521
+ var KIT_LIMITS = {
50522
+ tableRows: 200,
50523
+ codeLines: 200,
50524
+ keyWidth: 240,
50525
+ minColumn: 24
50526
+ };
50527
+ var COLUMN_GAP = 12;
50528
+ var ROW_PADDING = 10;
50529
+ var BODY_SIZE = 13;
50530
+ var HEADER_SIZE = 12;
50531
+ function invalid(property, reason) {
50532
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50533
+ }
50534
+ function optionKeys(value, allowed, name) {
50535
+ if (value === undefined || value === null)
50536
+ return {};
50537
+ if (typeof value !== "object" || Array.isArray(value))
50538
+ return invalid(name, "expected an options object");
50539
+ for (const key of Object.keys(value))
50540
+ if (!allowed.includes(key))
50541
+ return invalid(key, `${name} does not take ${key}`);
50542
+ return value;
50543
+ }
50544
+ function requiredString(value, property) {
50545
+ if (typeof value !== "string" || value === "")
50546
+ return invalid(property, "expected a non-empty string");
50547
+ return value;
50548
+ }
50549
+ function optionalString(value, property) {
50550
+ if (value === undefined || value === null)
50551
+ return;
50552
+ return requiredString(value, property);
50553
+ }
50554
+ function containerWidth(value, property) {
50555
+ if (value === undefined || value === null || value === "fill_container")
50556
+ return "fill_container";
50557
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
50558
+ return value;
50559
+ return invalid(property, 'expected a positive number or "fill_container"');
50560
+ }
50561
+ var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
50562
+ var COLUMN_KEYS = ["key", "title", "width", "align"];
50563
+ var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
50564
+ function planColumns(columns, total, gap = COLUMN_GAP) {
50565
+ const fills = columns.filter((c) => typeof c.width !== "number").length;
50566
+ if (total === null)
50567
+ return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
50568
+ const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
50569
+ const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
50570
+ const leftover = available - pinned;
50571
+ if (leftover > 0) {
50572
+ if (!fills)
50573
+ return columns.map((c) => c.width);
50574
+ const share = round2(leftover / fills);
50575
+ return columns.map((c) => typeof c.width === "number" ? c.width : share);
50576
+ }
50577
+ const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
50578
+ const scale = requested > 0 ? available / requested : 1;
50579
+ return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
50580
+ }
50581
+ var round2 = (n2) => Math.round(n2 * 100) / 100;
50582
+ function cellRow(name, cells) {
50583
+ return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
50584
+ }
50585
+ function planTable(options, ctx) {
50586
+ const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
50587
+ if (!Array.isArray(o.columns) || o.columns.length === 0)
50588
+ invalid("columns", "expected a non-empty array of { key, title }");
50589
+ const rows = o.rows;
50590
+ if (!Array.isArray(rows))
50591
+ invalid("rows", "expected an array of row objects");
50592
+ if (rows.length > KIT_LIMITS.tableRows)
50593
+ invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
50594
+ const columns = o.columns.map((raw, i) => {
50595
+ const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
50596
+ const width2 = c.width;
50597
+ if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
50598
+ invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
50599
+ const align = c.align;
50600
+ if (align !== undefined && align !== null && align !== "left" && align !== "right")
50601
+ invalid(`columns[${i}].align`, 'expected "left" or "right"');
50602
+ return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
50603
+ });
50604
+ const width = containerWidth(o.width, "width");
50605
+ const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
50606
+ const font = token(ctx, "v3-font");
50607
+ const headerCell = (title, w, align) => ({
50608
+ type: "text",
50609
+ name: title,
50610
+ content: title,
50611
+ width: w,
50612
+ textGrowth: "fixed-width",
50613
+ fontFamily: font,
50614
+ fontSize: HEADER_SIZE,
50615
+ fontWeight: 600,
50616
+ fill: token(ctx, "v3-fg-2"),
50617
+ ...align === "right" ? { textAlign: "right" } : {}
50618
+ });
50619
+ const dataCell = (title, content, w, align) => ({
50620
+ type: "text",
50621
+ name: title,
50622
+ content,
50623
+ width: w,
50624
+ textGrowth: "fixed-width",
50625
+ fontFamily: font,
50626
+ fontSize: BODY_SIZE,
50627
+ fill: token(ctx, "v3-fg"),
50628
+ ...align === "right" ? { textAlign: "right" } : {}
50629
+ });
50630
+ const children = [
50631
+ {
50632
+ type: "frame",
50633
+ name: "Header",
50634
+ layout: "vertical",
50635
+ gap: 0,
50636
+ width: "fill_container",
50637
+ stroke: token(ctx, "v3-border-strong"),
50638
+ strokeWidth: { bottom: 1 },
50639
+ strokeAlignment: "inner",
50640
+ children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
50641
+ }
50642
+ ];
50643
+ rows.forEach((row, i) => {
50644
+ const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
50645
+ children.push({
50646
+ type: "frame",
50647
+ name: "Row",
50648
+ layout: "vertical",
50649
+ gap: 0,
50650
+ width: "fill_container",
50651
+ stroke: token(ctx, "v3-border"),
50652
+ strokeWidth: { bottom: 1 },
50653
+ strokeAlignment: "inner",
50654
+ ...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
50655
+ children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
50656
+ });
50657
+ });
50658
+ return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
50659
+ }
50660
+ function textOf(value) {
50661
+ if (value === undefined || value === null)
50662
+ return "";
50663
+ return typeof value === "string" ? value : String(value);
50664
+ }
50665
+ function requiredText(value, property) {
50666
+ if (typeof value !== "string" && typeof value !== "number")
50667
+ return invalid(property, "expected a string or number");
50668
+ return String(value);
50669
+ }
50670
+ var CALLOUT_KEYS = ["tone", "title", "body"];
50671
+ var CALLOUT_TONES = {
50672
+ info: { soft: "v3-info-soft", ink: "v3-info" },
50673
+ success: { soft: "v3-green-50", ink: "v3-green-700" },
50674
+ warning: { soft: "v3-warning-soft", ink: "v3-warning" },
50675
+ danger: { soft: "v3-danger-soft", ink: "v3-danger" }
50676
+ };
50677
+ function planCallout(options, ctx) {
50678
+ const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
50679
+ const tone = o.tone;
50680
+ if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
50681
+ invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
50682
+ const body = requiredString(o.body, "body");
50683
+ const title = optionalString(o.title, "title");
50684
+ const pair = CALLOUT_TONES[tone];
50685
+ const font = token(ctx, "v3-font");
50686
+ const bodyChildren = [];
50687
+ if (title !== undefined)
50688
+ bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
50689
+ bodyChildren.push({
50690
+ type: "text",
50691
+ name: "Body",
50692
+ content: body,
50693
+ fontFamily: font,
50694
+ fontSize: BODY_SIZE,
50695
+ lineHeight: 1.5,
50696
+ width: "fill_container",
50697
+ textGrowth: "fixed-width",
50698
+ fill: token(ctx, "v3-fg")
50699
+ });
50700
+ return {
50701
+ type: "frame",
50702
+ name: "Callout",
50703
+ layout: "horizontal",
50704
+ gap: 0,
50705
+ width: "fill_container",
50706
+ fill: token(ctx, pair.soft),
50707
+ cornerRadius: token(ctx, "r-md"),
50708
+ clip: true,
50709
+ children: [
50710
+ { type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
50711
+ { type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
50712
+ ]
50713
+ };
50714
+ }
50715
+ var CODE_KEYS = ["lang", "text"];
50716
+ function planCode(options, ctx) {
50717
+ const o = optionKeys(options, CODE_KEYS, "Kit.Code");
50718
+ const lang = optionalString(o.lang, "lang");
50719
+ const text = requiredString(o.text, "text");
50720
+ const lines = text.split(`
50721
+ `);
50722
+ const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
50723
+ const children = [];
50724
+ if (lang !== undefined)
50725
+ children.push({
50726
+ type: "text",
50727
+ name: "Lang",
50728
+ content: lang,
50729
+ width: "fill_container",
50730
+ textGrowth: "fixed-width",
50731
+ textAlign: "right",
50732
+ fontFamily: token(ctx, "v3-mono"),
50733
+ fontSize: 11,
50734
+ fill: token(ctx, "v3-fg-3")
50735
+ });
50736
+ children.push({
50737
+ type: "text",
50738
+ name: "Lines",
50739
+ content: shown.join(`
50740
+ `),
50741
+ fontFamily: token(ctx, "v3-mono"),
50742
+ fontSize: 12,
50743
+ lineHeight: 1.5,
50744
+ width: "fill_container",
50745
+ textGrowth: "fixed-width",
50746
+ fill: token(ctx, "v3-code-fg")
50747
+ });
50748
+ return {
50749
+ type: "frame",
50750
+ name: "Code",
50751
+ layout: "vertical",
50752
+ gap: 6,
50753
+ width: "fill_container",
50754
+ fill: token(ctx, "v3-code-bg"),
50755
+ cornerRadius: token(ctx, "r-md"),
50756
+ padding: 12,
50757
+ clip: true,
50758
+ children
50759
+ };
50760
+ }
50761
+ function indexed(index) {
50762
+ return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
50763
+ }
50764
+ var SECTION_KEYS = ["index", "title", "subtitle"];
50765
+ function planSection(options, ctx) {
50766
+ const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
50767
+ const title = requiredString(o.title, "title");
50768
+ const subtitle = optionalString(o.subtitle, "subtitle");
50769
+ const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
50770
+ if (index !== undefined && index === "")
50771
+ invalid("index", "expected a non-empty string or number");
50772
+ const font = token(ctx, "v3-font");
50773
+ const heading = {
50774
+ type: "frame",
50775
+ name: "Heading",
50776
+ layout: "horizontal",
50777
+ gap: 8,
50778
+ alignItems: "center",
50779
+ width: "fill_container",
50780
+ children: [
50781
+ ...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
50782
+ { type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50783
+ ]
50784
+ };
50785
+ const children = [heading];
50786
+ if (subtitle !== undefined)
50787
+ children.push({ type: "text", name: "Subtitle", content: subtitle, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-2"), width: "fill_container", textGrowth: "fixed-width" });
50788
+ return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
50789
+ }
50790
+ function planKeyValue(rows, ctx) {
50791
+ if (!Array.isArray(rows) || rows.length === 0)
50792
+ invalid("rows", "expected a non-empty array of { key, value }");
50793
+ const font = token(ctx, "v3-font");
50794
+ const parsed = rows.map((raw, i) => {
50795
+ const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
50796
+ return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
50797
+ });
50798
+ const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
50799
+ const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
50800
+ return {
50801
+ type: "frame",
50802
+ name: "KeyValue",
50803
+ layout: "vertical",
50804
+ gap: 0,
50805
+ width: "fill_container",
50806
+ children: parsed.map((r) => ({
50807
+ type: "frame",
50808
+ name: "KeyValueRow",
50809
+ layout: "horizontal",
50810
+ gap: 12,
50811
+ padding: [6, 0],
50812
+ width: "fill_container",
50813
+ children: [
50814
+ { type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
50815
+ { type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50816
+ ]
50817
+ }))
50818
+ };
50819
+ }
50820
+ var KIT_BUILDERS = {
50821
+ table: planTable,
50822
+ callout: planCallout,
50823
+ code: planCode,
50824
+ section: planSection,
50825
+ "key-value": planKeyValue
50826
+ };
50827
+ function planKitNode(kind, options, ctx) {
50828
+ const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
50829
+ if (!build)
50830
+ return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
50831
+ return build(options, ctx);
50832
+ }
50833
+
50201
50834
  // ../../packages/canvas/document/src/execute-api.ts
50835
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
50202
50836
  var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
50837
+ function connectorMetaOf(props) {
50838
+ const meta = props?.metadata?.connector;
50839
+ if (!meta || typeof meta !== "object")
50840
+ return null;
50841
+ const m = meta;
50842
+ if (typeof m.from !== "string" || typeof m.to !== "string")
50843
+ return null;
50844
+ return {
50845
+ from: m.from,
50846
+ to: m.to,
50847
+ fromMagnet: m.fromMagnet ?? "auto",
50848
+ toMagnet: m.toMagnet ?? "auto",
50849
+ route: m.route ?? "straight",
50850
+ arrow: m.arrow ?? "end",
50851
+ labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
50852
+ ...Array.isArray(m.dash) ? { dash: m.dash } : {},
50853
+ ...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
50854
+ };
50855
+ }
50203
50856
  var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
50204
- function invalid(property, reason) {
50857
+ function invalid2(property, reason) {
50205
50858
  throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50206
50859
  }
50207
50860
  function pickOption(value, allowed, property, fallback) {
@@ -50209,33 +50862,37 @@ function pickOption(value, allowed, property, fallback) {
50209
50862
  return fallback;
50210
50863
  if (typeof value === "string" && allowed.includes(value))
50211
50864
  return value;
50212
- return invalid(property, `expected one of ${allowed.join(", ")}`);
50865
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
50213
50866
  }
50214
50867
  function numberOption(value, property, fallback, positive = false) {
50215
50868
  if (value === undefined || value === null)
50216
50869
  return fallback;
50217
50870
  if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
50218
- return invalid(property, positive ? "expected a positive number" : "expected a number");
50871
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
50219
50872
  return value;
50220
50873
  }
50221
- function optionKeys(value, allowed, name) {
50874
+ function optionKeys2(value, allowed, name) {
50222
50875
  if (value === undefined || value === null)
50223
50876
  return {};
50224
50877
  if (typeof value !== "object" || Array.isArray(value))
50225
- return invalid(name, "expected an options object");
50878
+ return invalid2(name, "expected an options object");
50226
50879
  for (const key of Object.keys(value))
50227
50880
  if (!allowed.has(key))
50228
- return invalid(key, `${name} does not take ${key}`);
50881
+ return invalid2(key, `${name} does not take ${key}`);
50229
50882
  return value;
50230
50883
  }
50231
50884
  function dashOption(value) {
50232
50885
  if (value === undefined || value === null)
50233
50886
  return;
50234
50887
  if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
50235
- invalid("dash", "expected an array of positive numbers");
50888
+ invalid2("dash", "expected an array of positive numbers");
50236
50889
  return value;
50237
50890
  }
50238
- var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4 };
50891
+ var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
50892
+ var VECTORIZE_MODES = ["auto", "mono", "flat"];
50893
+ var VECTORIZE_KEYS = new Set(["mode", "maxColors", "allowComplex"]);
50894
+ var KIT_FRAME_GAP = 24;
50895
+ var KIT_FRAME_PADDING = 24;
50239
50896
  var ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
50240
50897
  function undeclared(node2, key) {
50241
50898
  return node2[key] === undefined || node2[key] === null;
@@ -50278,16 +50935,20 @@ class ExecuteApi {
50278
50935
  rev;
50279
50936
  random;
50280
50937
  measureText;
50938
+ kits;
50281
50939
  document = "document";
50282
50940
  layoutCache = new Map;
50283
50941
  defaults = {};
50284
- constructor(store, rec, bounds, rev, random = Math.random, measureText) {
50942
+ connectors = new Map;
50943
+ connectorsIndexed = false;
50944
+ constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50285
50945
  this.store = store;
50286
50946
  this.rec = rec;
50287
50947
  this.bounds = bounds;
50288
50948
  this.rev = rev;
50289
50949
  this.random = random;
50290
50950
  this.measureText = measureText;
50951
+ this.kits = kits;
50291
50952
  }
50292
50953
  setDefaults(value) {
50293
50954
  const raw = value;
@@ -50541,6 +51202,8 @@ class ExecuteApi {
50541
51202
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50542
51203
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50543
51204
  this.commit({ op: "update", id: row.id, patch });
51205
+ if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
51206
+ this.finalizeConnectors();
50544
51207
  }
50545
51208
  Replace(path, nodeData) {
50546
51209
  const inst = this.splitInstancePath(path);
@@ -50578,6 +51241,7 @@ class ExecuteApi {
50578
51241
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50579
51242
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50580
51243
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51244
+ this.finalizeConnectors();
50581
51245
  }
50582
51246
  Delete(path) {
50583
51247
  if (path === "document")
@@ -50587,6 +51251,7 @@ class ExecuteApi {
50587
51251
  if (!this.store.get(path))
50588
51252
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50589
51253
  this.commit({ op: "delete", id: path });
51254
+ this.finalizeConnectors();
50590
51255
  }
50591
51256
  MoveToBack(path) {
50592
51257
  this.Move(path, undefined, 0);
@@ -50827,14 +51492,14 @@ class ExecuteApi {
50827
51492
  }
50828
51493
  MeasureText(content, options) {
50829
51494
  if (typeof content !== "string")
50830
- invalid("content", "expected a string");
51495
+ invalid2("content", "expected a string");
50831
51496
  if (!this.measureText)
50832
- invalid("MeasureText", "this host has no font set, so text cannot be measured");
50833
- const o = optionKeys(options, MEASURE_KEYS, "MeasureText");
51497
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51498
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
50834
51499
  if (typeof o.fontFamily !== "string" || o.fontFamily === "")
50835
- invalid("fontFamily", "expected a font family name");
51500
+ invalid2("fontFamily", "expected a font family name");
50836
51501
  if (o.fontSize === undefined || o.fontSize === null)
50837
- invalid("fontSize", "expected a positive number");
51502
+ invalid2("fontSize", "expected a positive number");
50838
51503
  return this.measureText({
50839
51504
  content,
50840
51505
  fontFamily: o.fontFamily,
@@ -50850,59 +51515,45 @@ class ExecuteApi {
50850
51515
  }
50851
51516
  Connect(from, to, options) {
50852
51517
  if (typeof from !== "string" || typeof to !== "string")
50853
- invalid("from", "expected a node id");
51518
+ invalid2("from", "expected a node id");
50854
51519
  if (from === to)
50855
- invalid("to", "a node cannot be connected to itself");
51520
+ invalid2("to", "a node cannot be connected to itself");
50856
51521
  this.rowOf(from);
50857
51522
  this.rowOf(to);
50858
- const o = optionKeys(options, CONNECT_KEYS, "Connect");
50859
- if (o.route === "elbow")
50860
- invalid("route", "elbow routing is not available yet");
51523
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
50861
51524
  const route = pickOption(o.route, ROUTES, "route", "straight");
50862
51525
  const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
50863
51526
  const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
50864
51527
  const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
50865
51528
  const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
50866
51529
  if (labelPos < 0 || labelPos > 1)
50867
- invalid("labelPos", "expected a number between 0 and 1");
51530
+ invalid2("labelPos", "expected a number between 0 and 1");
50868
51531
  const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
50869
51532
  const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
50870
51533
  if (typeof stroke !== "string")
50871
- invalid("stroke", "expected a colour string");
51534
+ invalid2("stroke", "expected a colour string");
50872
51535
  const dash = dashOption(o.dash);
50873
51536
  const behind = o.behind === undefined || o.behind === null ? true : o.behind;
50874
51537
  if (typeof behind !== "boolean")
50875
- invalid("behind", "expected a boolean");
51538
+ invalid2("behind", "expected a boolean");
50876
51539
  const name = o.name === undefined || o.name === null ? "Connector" : o.name;
50877
51540
  if (typeof name !== "string")
50878
- invalid("name", "expected a string");
51541
+ invalid2("name", "expected a string");
50879
51542
  if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
50880
- invalid("label", "expected a string");
50881
- const geom = connectorGeometry(this.connectorEnd(from, "from"), this.connectorEnd(to, "to"), { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51543
+ invalid2("label", "expected a string");
51544
+ const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
51545
+ const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
50882
51546
  const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
50883
51547
  const target = parent ?? "document";
50884
51548
  const origin = this.originOf(parent);
50885
51549
  const absolute = this.inFlow(parent);
50886
51550
  const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
50887
- const id = this.Insert(target, {
50888
- id: "",
50889
- type: "path",
50890
- name,
50891
- ...place(geom.bbox),
50892
- viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
50893
- geometry: geom.geometry,
50894
- fill: stroke,
50895
- stroke,
50896
- strokeWidth,
50897
- metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos } }
50898
- });
50899
- if (behind)
50900
- this.Move(id, target, 0);
51551
+ let labelId;
50901
51552
  if (typeof o.label === "string" && o.label !== "") {
50902
51553
  const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
50903
51554
  const width = size.width + 8;
50904
51555
  const height = size.height + 4;
50905
- this.Insert(target, {
51556
+ labelId = this.Insert(target, {
50906
51557
  id: "",
50907
51558
  type: "frame",
50908
51559
  name: `${name}-label`,
@@ -50913,8 +51564,139 @@ class ExecuteApi {
50913
51564
  children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
50914
51565
  });
50915
51566
  }
51567
+ const id = this.Insert(target, {
51568
+ id: "",
51569
+ type: "path",
51570
+ name,
51571
+ ...place(geom.bbox),
51572
+ viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51573
+ geometry: geom.geometry,
51574
+ fill: stroke,
51575
+ stroke,
51576
+ strokeWidth,
51577
+ metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
51578
+ });
51579
+ this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
51580
+ if (behind)
51581
+ this.Move(id, target, 0);
51582
+ this.warnConnector(id, geom);
50916
51583
  return id;
50917
51584
  }
51585
+ finalizeConnectors() {
51586
+ if (!this.mutations)
51587
+ return;
51588
+ for (const id of this.knownConnectors())
51589
+ this.redrawConnector(id);
51590
+ }
51591
+ knownConnectors() {
51592
+ if (!this.connectorsIndexed) {
51593
+ this.connectorsIndexed = true;
51594
+ const walk = (parent) => {
51595
+ for (const id of this.store.children(parent)) {
51596
+ const props = this.store.get(id)?.props;
51597
+ if (!props)
51598
+ continue;
51599
+ const meta = connectorMetaOf(props);
51600
+ if (meta && !this.connectors.has(id))
51601
+ this.connectors.set(id, meta);
51602
+ walk(id);
51603
+ }
51604
+ };
51605
+ walk(null);
51606
+ }
51607
+ return [...this.connectors.keys()];
51608
+ }
51609
+ redrawConnector(id) {
51610
+ const row = this.store.get(id);
51611
+ const meta = row ? connectorMetaOf(row.props) : null;
51612
+ if (!row || !meta) {
51613
+ this.connectors.delete(id);
51614
+ return;
51615
+ }
51616
+ const from = this.absoluteOf(meta.from);
51617
+ const to = this.absoluteOf(meta.to);
51618
+ if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
51619
+ this.warnOnce("CONNECTOR_ENDPOINT_GONE", id, `connector ${String(row.props.name ?? id)}: ${meta.from} or ${meta.to} is gone or has no laid-out box; the line was left where it was`);
51620
+ return;
51621
+ }
51622
+ const end = (box2, path) => {
51623
+ const props = this.store.get(path).props;
51624
+ return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
51625
+ };
51626
+ const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
51627
+ route: meta.route,
51628
+ fromMagnet: meta.fromMagnet,
51629
+ toMagnet: meta.toMagnet,
51630
+ arrow: meta.arrow,
51631
+ labelPos: meta.labelPos,
51632
+ dash: meta.dash,
51633
+ strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
51634
+ });
51635
+ const origin = this.originOf(row.parent);
51636
+ const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
51637
+ const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
51638
+ const patch = {};
51639
+ for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
51640
+ if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
51641
+ patch[key] = value;
51642
+ if (Object.keys(patch).length)
51643
+ this.commit({ op: "update", id, patch });
51644
+ if (meta.labelId) {
51645
+ const label = this.store.get(meta.labelId);
51646
+ const labelBox = this.absoluteOf(meta.labelId);
51647
+ if (label && labelBox) {
51648
+ const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
51649
+ const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
51650
+ const labelPatch = {};
51651
+ if (label.props.x !== x)
51652
+ labelPatch.x = x;
51653
+ if (label.props.y !== y)
51654
+ labelPatch.y = y;
51655
+ if (Object.keys(labelPatch).length)
51656
+ this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
51657
+ }
51658
+ }
51659
+ this.warnConnector(id, geom);
51660
+ }
51661
+ warnOnce(code, nodeId, message) {
51662
+ if (this.rec.warnings.length >= 20)
51663
+ return;
51664
+ if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
51665
+ return;
51666
+ this.rec.warnings.push({ code, nodeId, message });
51667
+ }
51668
+ warnConnector(id, geom) {
51669
+ const row = this.store.get(id);
51670
+ if (!row)
51671
+ return;
51672
+ const meta = connectorMetaOf(row.props);
51673
+ const labelIds = new Set;
51674
+ for (const m of this.connectors.values())
51675
+ if (m.labelId)
51676
+ labelIds.add(m.labelId);
51677
+ let labelBox = null;
51678
+ for (const sibling of this.store.children(row.parent)) {
51679
+ const props = this.store.get(sibling)?.props;
51680
+ if (!props || sibling === id)
51681
+ continue;
51682
+ const box = this.absoluteOf(sibling);
51683
+ if (!box || box.width === 0 && box.height === 0)
51684
+ continue;
51685
+ if (sibling === meta?.labelId) {
51686
+ labelBox = box;
51687
+ continue;
51688
+ }
51689
+ if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
51690
+ for (let i = 1;i < geom.polyline.length; i++)
51691
+ if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
51692
+ this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
51693
+ break;
51694
+ }
51695
+ }
51696
+ if (labelBox && rectsOverlap(labelBox, box))
51697
+ this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
51698
+ }
51699
+ }
50918
51700
  absoluteOf(path) {
50919
51701
  if (path === null || path === "")
50920
51702
  return { x: 0, y: 0, width: 0, height: 0 };
@@ -50929,14 +51711,14 @@ class ExecuteApi {
50929
51711
  return { x: 0, y: 0 };
50930
51712
  const box = this.absoluteOf(parent);
50931
51713
  if (!box)
50932
- invalid("parent", `${parent} has no laid-out box`);
51714
+ invalid2("parent", `${parent} has no laid-out box`);
50933
51715
  return { x: box.x, y: box.y };
50934
51716
  }
50935
51717
  connectorEnd(id, property) {
50936
51718
  const row = this.rowOf(id);
50937
51719
  const box = this.absoluteOf(id);
50938
51720
  if (!box || box.width === 0 && box.height === 0)
50939
- invalid(property, `${id} has no laid-out box to attach to`);
51721
+ invalid2(property, `${id} has no laid-out box to attach to`);
50940
51722
  return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
50941
51723
  }
50942
51724
  commonParent(a, b) {
@@ -50983,6 +51765,69 @@ class ExecuteApi {
50983
51765
  return { x: minX, y: maxY + pad };
50984
51766
  return { x: minX, y: minY - pad - input.height };
50985
51767
  }
51768
+ KitPlan(kind, options) {
51769
+ const variables = this.store.variables();
51770
+ return planKitNode(kind, options, {
51771
+ variables: new Set(Object.keys(variables)),
51772
+ measure: (request) => {
51773
+ const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
51774
+ const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
51775
+ return this.MeasureText(content, options2);
51776
+ }
51777
+ });
51778
+ }
51779
+ ListKits() {
51780
+ return this.kits?.list() ?? [];
51781
+ }
51782
+ UseKit(name) {
51783
+ if (typeof name !== "string" || name === "")
51784
+ invalid2("name", "expected a kit name");
51785
+ const entry = this.kits?.get(name);
51786
+ if (!entry)
51787
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51788
+ const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51789
+ const { refs, ids } = planRefs(plan);
51790
+ for (const ref of refs)
51791
+ if (!ids.has(ref) && !this.store.get(ref))
51792
+ throw new OpRejectedError({ code: "UNKNOWN_REF", ref });
51793
+ this.SetVariables(entry.kit.variables, false);
51794
+ const frame = kitFrameIn(this.store, entry.frame) ?? this.createKitFrame(entry.frame);
51795
+ for (const node2 of plan.add)
51796
+ this.insertKitComponent(frame, null, node2);
51797
+ for (const { id, node: node2 } of plan.update) {
51798
+ const row = this.rowOf(id);
51799
+ this.commit({ op: "delete", id });
51800
+ this.insertKitComponent(row.parent, row.ord, node2);
51801
+ }
51802
+ const names = kitPlanNames(plan);
51803
+ return { version: entry.kit.version, added: names.added, updated: names.updated, unchanged: plan.unchanged, variables: plan.variables };
51804
+ }
51805
+ createKitFrame(name) {
51806
+ const at = this.FindEmptySpace({ width: 0, height: 0, direction: "right", padding: KIT_FRAME_GAP });
51807
+ return this.Insert("document", {
51808
+ id: "",
51809
+ type: "frame",
51810
+ name,
51811
+ x: at.x,
51812
+ y: at.y,
51813
+ layout: "vertical",
51814
+ gap: KIT_FRAME_GAP,
51815
+ padding: KIT_FRAME_PADDING
51816
+ });
51817
+ }
51818
+ insertKitComponent(parent, ord, node2) {
51819
+ const tree = applyTextDefaults(migrateLegacyProps(node2), this.defaults.text);
51820
+ const seen = new Set;
51821
+ const check = (n2) => {
51822
+ if (seen.has(n2.id) || this.store.get(n2.id))
51823
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "id", reason: `kit component id ${n2.id} is already taken on this canvas` });
51824
+ seen.add(n2.id);
51825
+ for (const child of Array.isArray(n2.children) ? n2.children : [])
51826
+ check(child);
51827
+ };
51828
+ check(tree);
51829
+ this.commit({ op: "insert", parent, ord: ord ?? between(this.lastOrd(parent), null), node: tree });
51830
+ }
50986
51831
  Print(...values) {
50987
51832
  const line = values.map((v) => typeof v === "string" ? v : JSON.stringify(v)).join(" ");
50988
51833
  this.rec.printBytes += line.length;
@@ -50995,6 +51840,35 @@ class ExecuteApi {
50995
51840
  if (this.rec.screenshots.length < LIMITS.screenshots)
50996
51841
  this.rec.screenshots.push(id);
50997
51842
  }
51843
+ Vectorize(frameId, fileId, opts) {
51844
+ if (typeof frameId !== "string" || frameId === "")
51845
+ invalid2("frameId", "expected a frame id");
51846
+ if (typeof fileId !== "string" || fileId === "")
51847
+ invalid2("fileId", "expected a file id");
51848
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51849
+ const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51850
+ const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
51851
+ if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
51852
+ invalid2("maxColors", "expected a positive integer");
51853
+ const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
51854
+ if (allowComplex !== undefined && typeof allowComplex !== "boolean")
51855
+ invalid2("allowComplex", "expected a boolean");
51856
+ if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
51857
+ throw new Error(`SCRIPT_LIMIT: at most ${LIMITS.vectorize} Vectorize calls in one execute — ask for one image per execute, or trace one combined image`);
51858
+ const requestId = this.newRequestId();
51859
+ const carried = { ...mode === undefined ? {} : { mode }, ...maxColors === undefined ? {} : { maxColors }, ...allowComplex === undefined ? {} : { allowComplex } };
51860
+ this.rec.pendingVectorize.push({ requestId, frameId, fileId, ...Object.keys(carried).length ? { opts: carried } : {} });
51861
+ return { requestId };
51862
+ }
51863
+ newRequestId() {
51864
+ for (;; ) {
51865
+ let id = "vz-";
51866
+ for (let i = 0;i < 10; i++)
51867
+ id += ID_CHARS[Math.floor(this.random() * ID_CHARS.length)];
51868
+ if (!this.rec.pendingVectorize.some((p) => p.requestId === id))
51869
+ return id;
51870
+ }
51871
+ }
50998
51872
  }
50999
51873
  function toPen(e, depth, _resolved, _instances, shallow = false) {
51000
51874
  const node2 = { ...e.props, id: e.path, type: e.type };
@@ -51947,7 +52821,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
51947
52821
  }
51948
52822
 
51949
52823
  // src/main.ts
51950
- var version = "0.3.0-dev.6da4327";
52824
+ var version = "0.3.0-dev.9bfcf33";
51951
52825
  var commands = commandTree(operations);
51952
52826
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
51953
52827
  function route(argv) {
@@ -52201,16 +53075,16 @@ Examples:
52201
53075
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
52202
53076
  if (typeof cursor === "string" && cursor)
52203
53077
  ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
52204
- const pageToken = pageTokenField(op), token = pageToken?.sdkName ?? pageToken?.name;
52205
- const firstPage = flags.all && !(result instanceof Page) && token ? pageOf(result) : undefined;
52206
- if (flags.all && !(result instanceof Page) && token && !firstPage)
52207
- throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token.replace(/_/g, "-")} instead`);
53078
+ const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
53079
+ const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
53080
+ if (flags.all && !(result instanceof Page) && token2 && !firstPage)
53081
+ throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
52208
53082
  if (firstPage) {
52209
53083
  const items = [...firstPage.items];
52210
53084
  const seen = new Set;
52211
53085
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
52212
53086
  seen.add(next);
52213
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53087
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
52214
53088
  items.push(...pageOf(result)?.items ?? []);
52215
53089
  }
52216
53090
  ctx.nextCommand = undefined;