@deepraxis/cli 0.3.0-dev.2efda8a → 0.3.0-dev.3266b68

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 +13 -9
  2. package/dist/praxis.js +895 -129
  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."
@@ -26981,6 +27007,50 @@ for more details.`
26981
27007
  }
26982
27008
  ]
26983
27009
  },
27010
+ {
27011
+ resource: "sandbox.events.sandboxes",
27012
+ method: "retrieve",
27013
+ summary: "Get sandbox events",
27014
+ description: "Read one sandbox's lifecycle events, newest first by default. Unlike every other read on this face, it answers for a sandbox whose machine has ENDED (killed or failed) — a sandbox's cause of death is readable here even after its files are gone. The killed event carries eventData.terminationReason (the platform's own reason: requested, lease_expired, max_running, provider_lost, start_failed, retention, admin, unknown) and eventData.kill_reason (the E2B-shaped bucket: request, timeout, admin, orphaned, unknown); the updated event carries expiresAt. Page with offset, limit (1–100, default 10), orderAsc and repeatable types. An ended sandbox that is never going to come back also answers SANDBOX_EXPIRED (410) with terminationReason on its files and commands.",
27015
+ http: "GET",
27016
+ path: "/sandbox/v1/events/sandboxes/{sandboxID}",
27017
+ streaming: "no",
27018
+ pagination: false,
27019
+ pathParams: [
27020
+ {
27021
+ name: "sandboxID",
27022
+ sdkName: "sandboxID",
27023
+ description: "Id of the sandbox, the `sandboxID` returned by the create call (or listed by listSandboxes). Another team's sandbox and an unknown id both answer 404."
27024
+ }
27025
+ ],
27026
+ query: [
27027
+ {
27028
+ name: "offset",
27029
+ type: "integer",
27030
+ required: false,
27031
+ description: "Number of the newest events to skip before collecting the page; omit to start at the first one. Use it with limit to walk pages: the next page is offset + limit."
27032
+ },
27033
+ {
27034
+ name: "limit",
27035
+ type: "integer",
27036
+ required: false,
27037
+ description: "Page size from 1 to 100; defaults to 10. A larger value returns INVALID_PARAMS rather than being clipped."
27038
+ },
27039
+ {
27040
+ name: "orderAsc",
27041
+ type: "boolean",
27042
+ required: false,
27043
+ description: "true returns the oldest event first, false or omitted returns the newest first. Only the literal spellings true and false are accepted."
27044
+ },
27045
+ {
27046
+ name: "types",
27047
+ type: "array",
27048
+ itemType: "string",
27049
+ required: false,
27050
+ description: "Filter events to the provided event types"
27051
+ }
27052
+ ]
27053
+ },
26984
27054
  {
26985
27055
  resource: "sandbox.sandboxes",
26986
27056
  method: "list",
@@ -27674,6 +27744,12 @@ for more details.`
27674
27744
  type: "integer",
27675
27745
  required: false,
27676
27746
  description: "Execution timeout in milliseconds, from 1 to 3600000 (1 hour); defaults to 600000 (10 minutes). In background mode this limits process runtime; expiry records exit code 124."
27747
+ },
27748
+ {
27749
+ name: "progressTimeoutMs",
27750
+ type: "integer",
27751
+ required: false,
27752
+ description: "Foreground commands only, off by default: end this command once it goes this many milliseconds (1000 to 3600000) without writing a single byte to stdout or stderr, and answer COMMAND_NO_PROGRESS (504) with the output received so far and lastOutputAt. The sandbox itself keeps running, so decide afterwards whether to read what it produced or stop it with DELETE. A slow command that keeps producing output is never ended by it; if the program buffers its output, turn buffering off first, for example PYTHONUNBUFFERED=1 or stdbuf -oL. Passing it together with background true is refused with INVALID_PARAMS."
27677
27753
  }
27678
27754
  ]
27679
27755
  }
@@ -29193,6 +29269,12 @@ for more details.`
29193
29269
  required: true,
29194
29270
  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
29271
  },
29272
+ {
29273
+ name: "group",
29274
+ type: "string",
29275
+ required: false,
29276
+ 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."
29277
+ },
29196
29278
  {
29197
29279
  name: "aliases",
29198
29280
  type: "array",
@@ -29364,6 +29446,12 @@ for more details.`
29364
29446
  required: false,
29365
29447
  description: "New name for this entry, which also changes what the text has to mention for detection to find it."
29366
29448
  },
29449
+ {
29450
+ name: "group",
29451
+ type: "string",
29452
+ required: false,
29453
+ 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."
29454
+ },
29367
29455
  {
29368
29456
  name: "aliases",
29369
29457
  type: "array",
@@ -32261,6 +32349,31 @@ for more details.`
32261
32349
  }
32262
32350
  ]
32263
32351
  },
32352
+ {
32353
+ resource: "ticket.repositories",
32354
+ method: "update",
32355
+ summary: "Update repositories",
32356
+ 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.",
32357
+ http: "PATCH",
32358
+ path: "/ticket/v1/repositories/{id}",
32359
+ streaming: "no",
32360
+ pagination: false,
32361
+ pathParams: [
32362
+ {
32363
+ name: "id",
32364
+ sdkName: "id",
32365
+ description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
32366
+ }
32367
+ ],
32368
+ query: [
32369
+ {
32370
+ name: "repository",
32371
+ type: "string",
32372
+ required: false,
32373
+ description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
32374
+ }
32375
+ ]
32376
+ },
32264
32377
  {
32265
32378
  resource: "ticket.tickets",
32266
32379
  method: "list",
@@ -35680,6 +35793,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
35680
35793
  ...options.headers
35681
35794
  }
35682
35795
  });
35796
+ var browserGetSessionFrame = (options) => (options.client ?? client).get({
35797
+ security: [{
35798
+ key: "BrowserBearer",
35799
+ scheme: "bearer",
35800
+ type: "http"
35801
+ }],
35802
+ url: "/browser/v1/sessions/{sessionId}/frame",
35803
+ ...options
35804
+ });
35683
35805
  var browserListContexts = (options) => (options?.client ?? client).get({
35684
35806
  security: [{
35685
35807
  key: "BrowserBearer",
@@ -35768,6 +35890,15 @@ var browserStreamSession = (options) => (options.client ?? client).sse.get({
35768
35890
  url: "/browser/v1/sessions/{sessionId}/stream",
35769
35891
  ...options
35770
35892
  });
35893
+ var browserStreamSessionFrames = (options) => (options.client ?? client).sse.get({
35894
+ security: [{
35895
+ key: "BrowserBearer",
35896
+ scheme: "bearer",
35897
+ type: "http"
35898
+ }],
35899
+ url: "/browser/v1/sessions/{sessionId}/frames",
35900
+ ...options
35901
+ });
35771
35902
  var browserSeleniumUnsupported = (options) => (options?.client ?? client).get({
35772
35903
  security: [{
35773
35904
  key: "BrowserBearer",
@@ -42060,6 +42191,38 @@ var getSandboxV1SandboxesBySandboxIdLogs = (options) => (options.client ?? clien
42060
42191
  url: "/sandbox/v1/sandboxes/{sandboxID}/logs",
42061
42192
  ...options
42062
42193
  });
42194
+ var getSandboxEvents = (options) => (options.client ?? client).get({
42195
+ security: [
42196
+ {
42197
+ key: "sandbox-ApiKeyAuth",
42198
+ name: "X-API-Key",
42199
+ type: "apiKey"
42200
+ },
42201
+ {
42202
+ key: "sandbox-AuthProviderBearerAuth",
42203
+ scheme: "bearer",
42204
+ type: "http"
42205
+ },
42206
+ {
42207
+ key: "sandbox-AuthProviderTeamAuth",
42208
+ name: "X-Team-ID",
42209
+ type: "apiKey"
42210
+ },
42211
+ { name: "X-Admin-Token", type: "apiKey" },
42212
+ {
42213
+ key: "sandbox-AdminTeamAuth",
42214
+ name: "X-Team-ID",
42215
+ type: "apiKey"
42216
+ },
42217
+ {
42218
+ key: "sandbox-AdminJWTAuth",
42219
+ scheme: "bearer",
42220
+ type: "http"
42221
+ }
42222
+ ],
42223
+ url: "/sandbox/v1/events/sandboxes/{sandboxID}",
42224
+ ...options
42225
+ });
42063
42226
  var startTemplateBuild = (options) => (options.client ?? client).post({
42064
42227
  security: [
42065
42228
  {
@@ -44187,6 +44350,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
44187
44350
  url: "/ticket/v1/repositories",
44188
44351
  ...options
44189
44352
  });
44353
+ var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
44354
+ security: [{
44355
+ key: "BearerAuth",
44356
+ scheme: "bearer",
44357
+ type: "http"
44358
+ }, {
44359
+ key: "ApiKeyAuth",
44360
+ name: "X-API-Key",
44361
+ type: "apiKey"
44362
+ }],
44363
+ url: "/ticket/v1/repositories/{id}",
44364
+ ...options
44365
+ });
44190
44366
 
44191
44367
  // ../../packages/sdk/typescript/src/core/pagination.ts
44192
44368
  class Page {
@@ -44634,6 +44810,7 @@ function createBrowser(transport) {
44634
44810
  events: {
44635
44811
  list: bind(transport, browserListEvents)
44636
44812
  },
44813
+ frames: bindStream(transport, browserStreamSessionFrames),
44637
44814
  handoff: {
44638
44815
  complete: bind(transport, browserCompleteHandoff),
44639
44816
  create: bind(transport, browserRequestHandoff)
@@ -44641,6 +44818,7 @@ function createBrowser(transport) {
44641
44818
  list: bind(transport, browserListSessions),
44642
44819
  retrieve: bind(transport, browserGetSession),
44643
44820
  retrieveDebug: bind(transport, browserGetDebug),
44821
+ retrieveFrame: bind(transport, browserGetSessionFrame),
44644
44822
  stream: bindStream(transport, browserStreamSession),
44645
44823
  update: bind(transport, browserCloseSession),
44646
44824
  viewer: {
@@ -45256,6 +45434,11 @@ function createOrganization(transport) {
45256
45434
  }
45257
45435
  function createSandbox(transport) {
45258
45436
  return {
45437
+ events: {
45438
+ sandboxes: {
45439
+ retrieve: bind(transport, getSandboxEvents)
45440
+ }
45441
+ },
45259
45442
  sandboxes: {
45260
45443
  commands: {
45261
45444
  run: bind(transport, runSandboxCommand)
@@ -45480,7 +45663,8 @@ function createTicket(transport) {
45480
45663
  update: bind(transport, ticketPatchMilestonesNumber)
45481
45664
  },
45482
45665
  repositories: {
45483
- list: bind(transport, ticketGetRepositories)
45666
+ list: bind(transport, ticketGetRepositories),
45667
+ update: bind(transport, ticketPatchRepositoriesId)
45484
45668
  },
45485
45669
  tickets: {
45486
45670
  comments: {
@@ -49769,7 +49953,7 @@ function retop(store, id, top, rev) {
49769
49953
  // ../../packages/canvas/document/src/connector.ts
49770
49954
  var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
49771
49955
  var ARROWS = ["end", "start", "both", "none"];
49772
- var ROUTES = ["straight"];
49956
+ var ROUTES = ["straight", "elbow"];
49773
49957
  var ARROW_LENGTH_FACTOR = 6;
49774
49958
  var ARROW_HALF_ANGLE_DEG = 25;
49775
49959
  var EPSILON = 0.000000001;
@@ -49857,6 +50041,30 @@ function normalize(p) {
49857
50041
  const l = Math.hypot(p.x, p.y);
49858
50042
  return { x: p.x / l, y: p.y / l };
49859
50043
  }
50044
+ function rectsOverlap(a, b) {
50045
+ 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;
50046
+ }
50047
+ function segmentCrossesBox(a, b, box) {
50048
+ const shrink = 0.000001;
50049
+ const dx = b.x - a.x;
50050
+ const dy = b.y - a.y;
50051
+ let t0 = 0;
50052
+ let t1 = 1;
50053
+ const slab = (start, delta, min, max) => {
50054
+ if (Math.abs(delta) < 0.000000000001)
50055
+ return start > min && start < max;
50056
+ const ta = (min - start) / delta;
50057
+ const tb = (max - start) / delta;
50058
+ t0 = Math.max(t0, Math.min(ta, tb));
50059
+ t1 = Math.min(t1, Math.max(ta, tb));
50060
+ return t0 <= t1;
50061
+ };
50062
+ if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
50063
+ return false;
50064
+ if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
50065
+ return false;
50066
+ return t1 > t0;
50067
+ }
49860
50068
  function dashRanges(length, dash) {
49861
50069
  const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
49862
50070
  if (!pattern.length)
@@ -49878,40 +50086,106 @@ function n(value) {
49878
50086
  const rounded = Math.round(value * 100) / 100;
49879
50087
  return String(Object.is(rounded, -0) ? 0 : rounded);
49880
50088
  }
50089
+ var isHorizontal = (side) => side === "left" || side === "right";
50090
+ function elbowPath(from, to, fromMagnet, toMagnet) {
50091
+ if (fromMagnet === "center" || toMagnet === "center")
50092
+ throw new OpRejectedError({
50093
+ code: "INVALID_VALUE",
50094
+ property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
50095
+ reason: "elbow routing needs an edge, not the centre"
50096
+ });
50097
+ const dx = centerOf(to.box).x - centerOf(from.box).x;
50098
+ const dy = centerOf(to.box).y - centerOf(from.box).y;
50099
+ const across = Math.abs(dx) > Math.abs(dy);
50100
+ const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
50101
+ const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
50102
+ const p1 = magnetPoint(from.box, fromSide);
50103
+ const p2 = magnetPoint(to.box, toSide);
50104
+ const out = [p1];
50105
+ if (isHorizontal(fromSide) === isHorizontal(toSide)) {
50106
+ if (isHorizontal(fromSide)) {
50107
+ const midX = (p1.x + p2.x) / 2;
50108
+ out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
50109
+ } else {
50110
+ const midY = (p1.y + p2.y) / 2;
50111
+ out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
50112
+ }
50113
+ } else {
50114
+ out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
50115
+ }
50116
+ out.push(p2);
50117
+ const kept = [];
50118
+ for (const p of out) {
50119
+ const last = kept[kept.length - 1];
50120
+ if (last && last.x === p.x && last.y === p.y)
50121
+ continue;
50122
+ if (last && kept.length >= 2) {
50123
+ const before = kept[kept.length - 2];
50124
+ if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
50125
+ kept.pop();
50126
+ }
50127
+ kept.push(p);
50128
+ }
50129
+ return kept;
50130
+ }
50131
+ function cumulative(points) {
50132
+ const cum = [0];
50133
+ for (let i = 1;i < points.length; i++)
50134
+ cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
50135
+ return cum;
50136
+ }
50137
+ function pointAt(points, cum, s) {
50138
+ const total = cum[cum.length - 1];
50139
+ const at = Math.max(0, Math.min(s, total));
50140
+ let i = 0;
50141
+ while (i < points.length - 2 && cum[i + 1] < at)
50142
+ i++;
50143
+ const span = cum[i + 1] - cum[i];
50144
+ const f = span < EPSILON ? 0 : (at - cum[i]) / span;
50145
+ const a = points[i];
50146
+ const b = points[i + 1];
50147
+ return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
50148
+ }
49881
50149
  function connectorGeometry(from, to, opts = {}) {
49882
50150
  const arrow = opts.arrow ?? "end";
49883
50151
  const strokeWidth = opts.strokeWidth ?? 1.5;
49884
50152
  const labelPos = opts.labelPos ?? 0.5;
49885
50153
  const fromMagnet = opts.fromMagnet ?? "auto";
49886
50154
  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);
50155
+ if (rectsOverlap(from.box, to.box))
50156
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50157
+ const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
50158
+ const cum = cumulative(points);
50159
+ const length = cum[cum.length - 1];
50160
+ const p1 = points[0];
50161
+ const p2 = points[points.length - 1];
49892
50162
  if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
49893
50163
  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 };
50164
+ const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
50165
+ const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
50166
+ const back = { x: -dir2.x, y: -dir2.y };
49896
50167
  const arrowHeads = [];
49897
50168
  if (arrow === "end" || arrow === "both")
49898
50169
  arrowHeads.push(arrowHead(p2, back, strokeWidth));
49899
50170
  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];
50171
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50172
+ const xs = points.map((p) => p.x);
50173
+ const ys = points.map((p) => p.y);
49903
50174
  for (const head of arrowHeads) {
49904
50175
  xs.push(head.tip.x, head.left.x, head.right.x);
49905
50176
  ys.push(head.tip.y, head.left.y, head.right.y);
49906
50177
  }
49907
50178
  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
50179
  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
50180
  const parts = [];
49911
50181
  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)}`);
50182
+ const run = [pointAt(points, cum, start)];
50183
+ for (let i = 1;i < points.length - 1; i++)
50184
+ if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
50185
+ run.push(points[i]);
50186
+ run.push(pointAt(points, cum, end));
50187
+ const traced = run.length > 2 ? [...run, ...run.slice(0, -1).reverse()] : run;
50188
+ parts.push(traced.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
49915
50189
  }
49916
50190
  for (const head of arrowHeads) {
49917
50191
  const t = local(head.tip);
@@ -49919,7 +50193,7 @@ function connectorGeometry(from, to, opts = {}) {
49919
50193
  const r = local(head.right);
49920
50194
  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
50195
  }
49922
- return { points: [p1, p2], arrowHeads, bbox, labelCenter: at(labelPos), geometry: parts.join("") };
50196
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
49923
50197
  }
49924
50198
  // ../../packages/canvas/document/src/expand.ts
49925
50199
  function defaultTheme(themes) {
@@ -50306,10 +50580,368 @@ function planRefs(plan) {
50306
50580
  return { refs, ids };
50307
50581
  }
50308
50582
 
50583
+ // ../../packages/canvas/document/src/kit-builders.ts
50584
+ var PRAXIS_UI_LITERALS = {
50585
+ "v3-surface-2": "#F1F3F2",
50586
+ "v3-border": "#E3E7E4",
50587
+ "v3-border-strong": "#CDD3CF",
50588
+ "v3-fg": "#0D1310",
50589
+ "v3-fg-2": "#4A5550",
50590
+ "v3-fg-3": "#6E7872",
50591
+ "v3-green-50": "#EEFBF3",
50592
+ "v3-green-700": "#167A43",
50593
+ "v3-code-bg": "#0F1512",
50594
+ "v3-code-fg": "#D6E2DB",
50595
+ "v3-danger": "#D92D20",
50596
+ "v3-danger-soft": "#FEF0EE",
50597
+ "v3-warning": "#C76A00",
50598
+ "v3-warning-soft": "#FFF6E5",
50599
+ "v3-info": "#2563EB",
50600
+ "v3-info-soft": "#EEF4FF",
50601
+ "v3-font": "Geist",
50602
+ "v3-mono": "Geist Mono",
50603
+ "r-md": 8
50604
+ };
50605
+ function token(ctx, name) {
50606
+ return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
50607
+ }
50608
+ var KIT_LIMITS = {
50609
+ tableRows: 200,
50610
+ codeLines: 200,
50611
+ keyWidth: 240,
50612
+ minColumn: 24
50613
+ };
50614
+ var COLUMN_GAP = 12;
50615
+ var ROW_PADDING = 10;
50616
+ var BODY_SIZE = 13;
50617
+ var HEADER_SIZE = 12;
50618
+ function invalid(property, reason) {
50619
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50620
+ }
50621
+ function optionKeys(value, allowed, name) {
50622
+ if (value === undefined || value === null)
50623
+ return {};
50624
+ if (typeof value !== "object" || Array.isArray(value))
50625
+ return invalid(name, "expected an options object");
50626
+ for (const key of Object.keys(value))
50627
+ if (!allowed.includes(key))
50628
+ return invalid(key, `${name} does not take ${key}`);
50629
+ return value;
50630
+ }
50631
+ function requiredString(value, property) {
50632
+ if (typeof value !== "string" || value === "")
50633
+ return invalid(property, "expected a non-empty string");
50634
+ return value;
50635
+ }
50636
+ function optionalString(value, property) {
50637
+ if (value === undefined || value === null)
50638
+ return;
50639
+ return requiredString(value, property);
50640
+ }
50641
+ function containerWidth(value, property) {
50642
+ if (value === undefined || value === null || value === "fill_container")
50643
+ return "fill_container";
50644
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
50645
+ return value;
50646
+ return invalid(property, 'expected a positive number or "fill_container"');
50647
+ }
50648
+ var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
50649
+ var COLUMN_KEYS = ["key", "title", "width", "align"];
50650
+ var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
50651
+ function planColumns(columns, total, gap = COLUMN_GAP) {
50652
+ const fills = columns.filter((c) => typeof c.width !== "number").length;
50653
+ if (total === null)
50654
+ return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
50655
+ const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
50656
+ const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
50657
+ const leftover = available - pinned;
50658
+ if (leftover > 0) {
50659
+ if (!fills)
50660
+ return columns.map((c) => c.width);
50661
+ const share = round2(leftover / fills);
50662
+ return columns.map((c) => typeof c.width === "number" ? c.width : share);
50663
+ }
50664
+ const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
50665
+ const scale = requested > 0 ? available / requested : 1;
50666
+ return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
50667
+ }
50668
+ var round2 = (n2) => Math.round(n2 * 100) / 100;
50669
+ function cellRow(name, cells) {
50670
+ return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
50671
+ }
50672
+ function planTable(options, ctx) {
50673
+ const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
50674
+ if (!Array.isArray(o.columns) || o.columns.length === 0)
50675
+ invalid("columns", "expected a non-empty array of { key, title }");
50676
+ const rows = o.rows;
50677
+ if (!Array.isArray(rows))
50678
+ invalid("rows", "expected an array of row objects");
50679
+ if (rows.length > KIT_LIMITS.tableRows)
50680
+ invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
50681
+ const columns = o.columns.map((raw, i) => {
50682
+ const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
50683
+ const width2 = c.width;
50684
+ if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
50685
+ invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
50686
+ const align = c.align;
50687
+ if (align !== undefined && align !== null && align !== "left" && align !== "right")
50688
+ invalid(`columns[${i}].align`, 'expected "left" or "right"');
50689
+ return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
50690
+ });
50691
+ const width = containerWidth(o.width, "width");
50692
+ const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
50693
+ const font = token(ctx, "v3-font");
50694
+ const headerCell = (title, w, align) => ({
50695
+ type: "text",
50696
+ name: title,
50697
+ content: title,
50698
+ width: w,
50699
+ textGrowth: "fixed-width",
50700
+ fontFamily: font,
50701
+ fontSize: HEADER_SIZE,
50702
+ fontWeight: 600,
50703
+ fill: token(ctx, "v3-fg-2"),
50704
+ ...align === "right" ? { textAlign: "right" } : {}
50705
+ });
50706
+ const dataCell = (title, content, w, align) => ({
50707
+ type: "text",
50708
+ name: title,
50709
+ content,
50710
+ width: w,
50711
+ textGrowth: "fixed-width",
50712
+ fontFamily: font,
50713
+ fontSize: BODY_SIZE,
50714
+ fill: token(ctx, "v3-fg"),
50715
+ ...align === "right" ? { textAlign: "right" } : {}
50716
+ });
50717
+ const children = [
50718
+ {
50719
+ type: "frame",
50720
+ name: "Header",
50721
+ layout: "vertical",
50722
+ gap: 0,
50723
+ width: "fill_container",
50724
+ stroke: token(ctx, "v3-border-strong"),
50725
+ strokeWidth: { bottom: 1 },
50726
+ strokeAlignment: "inner",
50727
+ children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
50728
+ }
50729
+ ];
50730
+ rows.forEach((row, i) => {
50731
+ const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
50732
+ children.push({
50733
+ type: "frame",
50734
+ name: "Row",
50735
+ layout: "vertical",
50736
+ gap: 0,
50737
+ width: "fill_container",
50738
+ stroke: token(ctx, "v3-border"),
50739
+ strokeWidth: { bottom: 1 },
50740
+ strokeAlignment: "inner",
50741
+ ...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
50742
+ children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
50743
+ });
50744
+ });
50745
+ return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
50746
+ }
50747
+ function textOf(value) {
50748
+ if (value === undefined || value === null)
50749
+ return "";
50750
+ return typeof value === "string" ? value : String(value);
50751
+ }
50752
+ function requiredText(value, property) {
50753
+ if (typeof value !== "string" && typeof value !== "number")
50754
+ return invalid(property, "expected a string or number");
50755
+ return String(value);
50756
+ }
50757
+ var CALLOUT_KEYS = ["tone", "title", "body"];
50758
+ var CALLOUT_TONES = {
50759
+ info: { soft: "v3-info-soft", ink: "v3-info" },
50760
+ success: { soft: "v3-green-50", ink: "v3-green-700" },
50761
+ warning: { soft: "v3-warning-soft", ink: "v3-warning" },
50762
+ danger: { soft: "v3-danger-soft", ink: "v3-danger" }
50763
+ };
50764
+ function planCallout(options, ctx) {
50765
+ const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
50766
+ const tone = o.tone;
50767
+ if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
50768
+ invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
50769
+ const body = requiredString(o.body, "body");
50770
+ const title = optionalString(o.title, "title");
50771
+ const pair = CALLOUT_TONES[tone];
50772
+ const font = token(ctx, "v3-font");
50773
+ const bodyChildren = [];
50774
+ if (title !== undefined)
50775
+ bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
50776
+ bodyChildren.push({
50777
+ type: "text",
50778
+ name: "Body",
50779
+ content: body,
50780
+ fontFamily: font,
50781
+ fontSize: BODY_SIZE,
50782
+ lineHeight: 1.5,
50783
+ width: "fill_container",
50784
+ textGrowth: "fixed-width",
50785
+ fill: token(ctx, "v3-fg")
50786
+ });
50787
+ return {
50788
+ type: "frame",
50789
+ name: "Callout",
50790
+ layout: "horizontal",
50791
+ gap: 0,
50792
+ width: "fill_container",
50793
+ fill: token(ctx, pair.soft),
50794
+ cornerRadius: token(ctx, "r-md"),
50795
+ clip: true,
50796
+ children: [
50797
+ { type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
50798
+ { type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
50799
+ ]
50800
+ };
50801
+ }
50802
+ var CODE_KEYS = ["lang", "text"];
50803
+ function planCode(options, ctx) {
50804
+ const o = optionKeys(options, CODE_KEYS, "Kit.Code");
50805
+ const lang = optionalString(o.lang, "lang");
50806
+ const text = requiredString(o.text, "text");
50807
+ const lines = text.split(`
50808
+ `);
50809
+ const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
50810
+ const children = [];
50811
+ if (lang !== undefined)
50812
+ children.push({
50813
+ type: "text",
50814
+ name: "Lang",
50815
+ content: lang,
50816
+ width: "fill_container",
50817
+ textGrowth: "fixed-width",
50818
+ textAlign: "right",
50819
+ fontFamily: token(ctx, "v3-mono"),
50820
+ fontSize: 11,
50821
+ fill: token(ctx, "v3-fg-3")
50822
+ });
50823
+ children.push({
50824
+ type: "text",
50825
+ name: "Lines",
50826
+ content: shown.join(`
50827
+ `),
50828
+ fontFamily: token(ctx, "v3-mono"),
50829
+ fontSize: 12,
50830
+ lineHeight: 1.5,
50831
+ width: "fill_container",
50832
+ textGrowth: "fixed-width",
50833
+ fill: token(ctx, "v3-code-fg")
50834
+ });
50835
+ return {
50836
+ type: "frame",
50837
+ name: "Code",
50838
+ layout: "vertical",
50839
+ gap: 6,
50840
+ width: "fill_container",
50841
+ fill: token(ctx, "v3-code-bg"),
50842
+ cornerRadius: token(ctx, "r-md"),
50843
+ padding: 12,
50844
+ clip: true,
50845
+ children
50846
+ };
50847
+ }
50848
+ function indexed(index) {
50849
+ return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
50850
+ }
50851
+ var SECTION_KEYS = ["index", "title", "subtitle"];
50852
+ function planSection(options, ctx) {
50853
+ const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
50854
+ const title = requiredString(o.title, "title");
50855
+ const subtitle = optionalString(o.subtitle, "subtitle");
50856
+ const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
50857
+ if (index !== undefined && index === "")
50858
+ invalid("index", "expected a non-empty string or number");
50859
+ const font = token(ctx, "v3-font");
50860
+ const heading = {
50861
+ type: "frame",
50862
+ name: "Heading",
50863
+ layout: "horizontal",
50864
+ gap: 8,
50865
+ alignItems: "center",
50866
+ width: "fill_container",
50867
+ children: [
50868
+ ...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
50869
+ { type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50870
+ ]
50871
+ };
50872
+ const children = [heading];
50873
+ if (subtitle !== undefined)
50874
+ 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" });
50875
+ return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
50876
+ }
50877
+ function planKeyValue(rows, ctx) {
50878
+ if (!Array.isArray(rows) || rows.length === 0)
50879
+ invalid("rows", "expected a non-empty array of { key, value }");
50880
+ const font = token(ctx, "v3-font");
50881
+ const parsed = rows.map((raw, i) => {
50882
+ const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
50883
+ return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
50884
+ });
50885
+ const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
50886
+ const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
50887
+ return {
50888
+ type: "frame",
50889
+ name: "KeyValue",
50890
+ layout: "vertical",
50891
+ gap: 0,
50892
+ width: "fill_container",
50893
+ children: parsed.map((r) => ({
50894
+ type: "frame",
50895
+ name: "KeyValueRow",
50896
+ layout: "horizontal",
50897
+ gap: 12,
50898
+ padding: [6, 0],
50899
+ width: "fill_container",
50900
+ children: [
50901
+ { type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
50902
+ { type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50903
+ ]
50904
+ }))
50905
+ };
50906
+ }
50907
+ var KIT_BUILDERS = {
50908
+ table: planTable,
50909
+ callout: planCallout,
50910
+ code: planCode,
50911
+ section: planSection,
50912
+ "key-value": planKeyValue
50913
+ };
50914
+ function planKitNode(kind, options, ctx) {
50915
+ const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
50916
+ if (!build)
50917
+ return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
50918
+ return build(options, ctx);
50919
+ }
50920
+
50309
50921
  // ../../packages/canvas/document/src/execute-api.ts
50922
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
50310
50923
  var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
50924
+ function connectorMetaOf(props) {
50925
+ const meta = props?.metadata?.connector;
50926
+ if (!meta || typeof meta !== "object")
50927
+ return null;
50928
+ const m = meta;
50929
+ if (typeof m.from !== "string" || typeof m.to !== "string")
50930
+ return null;
50931
+ return {
50932
+ from: m.from,
50933
+ to: m.to,
50934
+ fromMagnet: m.fromMagnet ?? "auto",
50935
+ toMagnet: m.toMagnet ?? "auto",
50936
+ route: m.route ?? "straight",
50937
+ arrow: m.arrow ?? "end",
50938
+ labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
50939
+ ...Array.isArray(m.dash) ? { dash: m.dash } : {},
50940
+ ...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
50941
+ };
50942
+ }
50311
50943
  var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
50312
- function invalid(property, reason) {
50944
+ function invalid2(property, reason) {
50313
50945
  throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50314
50946
  }
50315
50947
  function pickOption(value, allowed, property, fallback) {
@@ -50317,30 +50949,30 @@ function pickOption(value, allowed, property, fallback) {
50317
50949
  return fallback;
50318
50950
  if (typeof value === "string" && allowed.includes(value))
50319
50951
  return value;
50320
- return invalid(property, `expected one of ${allowed.join(", ")}`);
50952
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
50321
50953
  }
50322
50954
  function numberOption(value, property, fallback, positive = false) {
50323
50955
  if (value === undefined || value === null)
50324
50956
  return fallback;
50325
50957
  if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
50326
- return invalid(property, positive ? "expected a positive number" : "expected a number");
50958
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
50327
50959
  return value;
50328
50960
  }
50329
- function optionKeys(value, allowed, name) {
50961
+ function optionKeys2(value, allowed, name) {
50330
50962
  if (value === undefined || value === null)
50331
50963
  return {};
50332
50964
  if (typeof value !== "object" || Array.isArray(value))
50333
- return invalid(name, "expected an options object");
50965
+ return invalid2(name, "expected an options object");
50334
50966
  for (const key of Object.keys(value))
50335
50967
  if (!allowed.has(key))
50336
- return invalid(key, `${name} does not take ${key}`);
50968
+ return invalid2(key, `${name} does not take ${key}`);
50337
50969
  return value;
50338
50970
  }
50339
50971
  function dashOption(value) {
50340
50972
  if (value === undefined || value === null)
50341
50973
  return;
50342
50974
  if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
50343
- invalid("dash", "expected an array of positive numbers");
50975
+ invalid2("dash", "expected an array of positive numbers");
50344
50976
  return value;
50345
50977
  }
50346
50978
  var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
@@ -50394,6 +51026,8 @@ class ExecuteApi {
50394
51026
  document = "document";
50395
51027
  layoutCache = new Map;
50396
51028
  defaults = {};
51029
+ connectors = new Map;
51030
+ connectorsIndexed = false;
50397
51031
  constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50398
51032
  this.store = store;
50399
51033
  this.rec = rec;
@@ -50655,6 +51289,8 @@ class ExecuteApi {
50655
51289
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50656
51290
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50657
51291
  this.commit({ op: "update", id: row.id, patch });
51292
+ if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
51293
+ this.finalizeConnectors();
50658
51294
  }
50659
51295
  Replace(path, nodeData) {
50660
51296
  const inst = this.splitInstancePath(path);
@@ -50692,6 +51328,7 @@ class ExecuteApi {
50692
51328
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50693
51329
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50694
51330
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51331
+ this.finalizeConnectors();
50695
51332
  }
50696
51333
  Delete(path) {
50697
51334
  if (path === "document")
@@ -50701,6 +51338,7 @@ class ExecuteApi {
50701
51338
  if (!this.store.get(path))
50702
51339
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50703
51340
  this.commit({ op: "delete", id: path });
51341
+ this.finalizeConnectors();
50704
51342
  }
50705
51343
  MoveToBack(path) {
50706
51344
  this.Move(path, undefined, 0);
@@ -50941,14 +51579,14 @@ class ExecuteApi {
50941
51579
  }
50942
51580
  MeasureText(content, options) {
50943
51581
  if (typeof content !== "string")
50944
- invalid("content", "expected a string");
51582
+ invalid2("content", "expected a string");
50945
51583
  if (!this.measureText)
50946
- invalid("MeasureText", "this host has no font set, so text cannot be measured");
50947
- const o = optionKeys(options, MEASURE_KEYS, "MeasureText");
51584
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51585
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
50948
51586
  if (typeof o.fontFamily !== "string" || o.fontFamily === "")
50949
- invalid("fontFamily", "expected a font family name");
51587
+ invalid2("fontFamily", "expected a font family name");
50950
51588
  if (o.fontSize === undefined || o.fontSize === null)
50951
- invalid("fontSize", "expected a positive number");
51589
+ invalid2("fontSize", "expected a positive number");
50952
51590
  return this.measureText({
50953
51591
  content,
50954
51592
  fontFamily: o.fontFamily,
@@ -50964,59 +51602,45 @@ class ExecuteApi {
50964
51602
  }
50965
51603
  Connect(from, to, options) {
50966
51604
  if (typeof from !== "string" || typeof to !== "string")
50967
- invalid("from", "expected a node id");
51605
+ invalid2("from", "expected a node id");
50968
51606
  if (from === to)
50969
- invalid("to", "a node cannot be connected to itself");
51607
+ invalid2("to", "a node cannot be connected to itself");
50970
51608
  this.rowOf(from);
50971
51609
  this.rowOf(to);
50972
- const o = optionKeys(options, CONNECT_KEYS, "Connect");
50973
- if (o.route === "elbow")
50974
- invalid("route", "elbow routing is not available yet");
51610
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
50975
51611
  const route = pickOption(o.route, ROUTES, "route", "straight");
50976
51612
  const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
50977
51613
  const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
50978
51614
  const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
50979
51615
  const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
50980
51616
  if (labelPos < 0 || labelPos > 1)
50981
- invalid("labelPos", "expected a number between 0 and 1");
51617
+ invalid2("labelPos", "expected a number between 0 and 1");
50982
51618
  const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
50983
51619
  const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
50984
51620
  if (typeof stroke !== "string")
50985
- invalid("stroke", "expected a colour string");
51621
+ invalid2("stroke", "expected a colour string");
50986
51622
  const dash = dashOption(o.dash);
50987
51623
  const behind = o.behind === undefined || o.behind === null ? true : o.behind;
50988
51624
  if (typeof behind !== "boolean")
50989
- invalid("behind", "expected a boolean");
51625
+ invalid2("behind", "expected a boolean");
50990
51626
  const name = o.name === undefined || o.name === null ? "Connector" : o.name;
50991
51627
  if (typeof name !== "string")
50992
- invalid("name", "expected a string");
51628
+ invalid2("name", "expected a string");
50993
51629
  if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
50994
- invalid("label", "expected a string");
50995
- const geom = connectorGeometry(this.connectorEnd(from, "from"), this.connectorEnd(to, "to"), { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51630
+ invalid2("label", "expected a string");
51631
+ const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
51632
+ const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
50996
51633
  const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
50997
51634
  const target = parent ?? "document";
50998
51635
  const origin = this.originOf(parent);
50999
51636
  const absolute = this.inFlow(parent);
51000
51637
  const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
51001
- const id = this.Insert(target, {
51002
- id: "",
51003
- type: "path",
51004
- name,
51005
- ...place(geom.bbox),
51006
- viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51007
- geometry: geom.geometry,
51008
- fill: stroke,
51009
- stroke,
51010
- strokeWidth,
51011
- metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos } }
51012
- });
51013
- if (behind)
51014
- this.Move(id, target, 0);
51638
+ let labelId;
51015
51639
  if (typeof o.label === "string" && o.label !== "") {
51016
51640
  const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
51017
51641
  const width = size.width + 8;
51018
51642
  const height = size.height + 4;
51019
- this.Insert(target, {
51643
+ labelId = this.Insert(target, {
51020
51644
  id: "",
51021
51645
  type: "frame",
51022
51646
  name: `${name}-label`,
@@ -51027,8 +51651,139 @@ class ExecuteApi {
51027
51651
  children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
51028
51652
  });
51029
51653
  }
51654
+ const id = this.Insert(target, {
51655
+ id: "",
51656
+ type: "path",
51657
+ name,
51658
+ ...place(geom.bbox),
51659
+ viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51660
+ geometry: geom.geometry,
51661
+ fill: stroke,
51662
+ stroke,
51663
+ strokeWidth,
51664
+ metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
51665
+ });
51666
+ this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
51667
+ if (behind)
51668
+ this.Move(id, target, 0);
51669
+ this.warnConnector(id, geom);
51030
51670
  return id;
51031
51671
  }
51672
+ finalizeConnectors() {
51673
+ if (!this.mutations)
51674
+ return;
51675
+ for (const id of this.knownConnectors())
51676
+ this.redrawConnector(id);
51677
+ }
51678
+ knownConnectors() {
51679
+ if (!this.connectorsIndexed) {
51680
+ this.connectorsIndexed = true;
51681
+ const walk = (parent) => {
51682
+ for (const id of this.store.children(parent)) {
51683
+ const props = this.store.get(id)?.props;
51684
+ if (!props)
51685
+ continue;
51686
+ const meta = connectorMetaOf(props);
51687
+ if (meta && !this.connectors.has(id))
51688
+ this.connectors.set(id, meta);
51689
+ walk(id);
51690
+ }
51691
+ };
51692
+ walk(null);
51693
+ }
51694
+ return [...this.connectors.keys()];
51695
+ }
51696
+ redrawConnector(id) {
51697
+ const row = this.store.get(id);
51698
+ const meta = row ? connectorMetaOf(row.props) : null;
51699
+ if (!row || !meta) {
51700
+ this.connectors.delete(id);
51701
+ return;
51702
+ }
51703
+ const from = this.absoluteOf(meta.from);
51704
+ const to = this.absoluteOf(meta.to);
51705
+ if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
51706
+ 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`);
51707
+ return;
51708
+ }
51709
+ const end = (box2, path) => {
51710
+ const props = this.store.get(path).props;
51711
+ return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
51712
+ };
51713
+ const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
51714
+ route: meta.route,
51715
+ fromMagnet: meta.fromMagnet,
51716
+ toMagnet: meta.toMagnet,
51717
+ arrow: meta.arrow,
51718
+ labelPos: meta.labelPos,
51719
+ dash: meta.dash,
51720
+ strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
51721
+ });
51722
+ const origin = this.originOf(row.parent);
51723
+ const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
51724
+ const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
51725
+ const patch = {};
51726
+ for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
51727
+ if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
51728
+ patch[key] = value;
51729
+ if (Object.keys(patch).length)
51730
+ this.commit({ op: "update", id, patch });
51731
+ if (meta.labelId) {
51732
+ const label = this.store.get(meta.labelId);
51733
+ const labelBox = this.absoluteOf(meta.labelId);
51734
+ if (label && labelBox) {
51735
+ const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
51736
+ const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
51737
+ const labelPatch = {};
51738
+ if (label.props.x !== x)
51739
+ labelPatch.x = x;
51740
+ if (label.props.y !== y)
51741
+ labelPatch.y = y;
51742
+ if (Object.keys(labelPatch).length)
51743
+ this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
51744
+ }
51745
+ }
51746
+ this.warnConnector(id, geom);
51747
+ }
51748
+ warnOnce(code, nodeId, message) {
51749
+ if (this.rec.warnings.length >= 20)
51750
+ return;
51751
+ if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
51752
+ return;
51753
+ this.rec.warnings.push({ code, nodeId, message });
51754
+ }
51755
+ warnConnector(id, geom) {
51756
+ const row = this.store.get(id);
51757
+ if (!row)
51758
+ return;
51759
+ const meta = connectorMetaOf(row.props);
51760
+ const labelIds = new Set;
51761
+ for (const m of this.connectors.values())
51762
+ if (m.labelId)
51763
+ labelIds.add(m.labelId);
51764
+ let labelBox = null;
51765
+ for (const sibling of this.store.children(row.parent)) {
51766
+ const props = this.store.get(sibling)?.props;
51767
+ if (!props || sibling === id)
51768
+ continue;
51769
+ const box = this.absoluteOf(sibling);
51770
+ if (!box || box.width === 0 && box.height === 0)
51771
+ continue;
51772
+ if (sibling === meta?.labelId) {
51773
+ labelBox = box;
51774
+ continue;
51775
+ }
51776
+ if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
51777
+ for (let i = 1;i < geom.polyline.length; i++)
51778
+ if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
51779
+ this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
51780
+ break;
51781
+ }
51782
+ }
51783
+ if (labelBox && rectsOverlap(labelBox, box))
51784
+ this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
51785
+ }
51786
+ }
51032
51787
  absoluteOf(path) {
51033
51788
  if (path === null || path === "")
51034
51789
  return { x: 0, y: 0, width: 0, height: 0 };
@@ -51043,14 +51798,14 @@ class ExecuteApi {
51043
51798
  return { x: 0, y: 0 };
51044
51799
  const box = this.absoluteOf(parent);
51045
51800
  if (!box)
51046
- invalid("parent", `${parent} has no laid-out box`);
51801
+ invalid2("parent", `${parent} has no laid-out box`);
51047
51802
  return { x: box.x, y: box.y };
51048
51803
  }
51049
51804
  connectorEnd(id, property) {
51050
51805
  const row = this.rowOf(id);
51051
51806
  const box = this.absoluteOf(id);
51052
51807
  if (!box || box.width === 0 && box.height === 0)
51053
- invalid(property, `${id} has no laid-out box to attach to`);
51808
+ invalid2(property, `${id} has no laid-out box to attach to`);
51054
51809
  return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
51055
51810
  }
51056
51811
  commonParent(a, b) {
@@ -51097,15 +51852,26 @@ class ExecuteApi {
51097
51852
  return { x: minX, y: maxY + pad };
51098
51853
  return { x: minX, y: minY - pad - input.height };
51099
51854
  }
51855
+ KitPlan(kind, options) {
51856
+ const variables = this.store.variables();
51857
+ return planKitNode(kind, options, {
51858
+ variables: new Set(Object.keys(variables)),
51859
+ measure: (request) => {
51860
+ const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
51861
+ const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
51862
+ return this.MeasureText(content, options2);
51863
+ }
51864
+ });
51865
+ }
51100
51866
  ListKits() {
51101
51867
  return this.kits?.list() ?? [];
51102
51868
  }
51103
51869
  UseKit(name) {
51104
51870
  if (typeof name !== "string" || name === "")
51105
- invalid("name", "expected a kit name");
51871
+ invalid2("name", "expected a kit name");
51106
51872
  const entry = this.kits?.get(name);
51107
51873
  if (!entry)
51108
- invalid("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51874
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51109
51875
  const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51110
51876
  const { refs, ids } = planRefs(plan);
51111
51877
  for (const ref of refs)
@@ -51163,17 +51929,17 @@ class ExecuteApi {
51163
51929
  }
51164
51930
  Vectorize(frameId, fileId, opts) {
51165
51931
  if (typeof frameId !== "string" || frameId === "")
51166
- invalid("frameId", "expected a frame id");
51932
+ invalid2("frameId", "expected a frame id");
51167
51933
  if (typeof fileId !== "string" || fileId === "")
51168
- invalid("fileId", "expected a file id");
51169
- const options = optionKeys(opts, VECTORIZE_KEYS, "Vectorize");
51934
+ invalid2("fileId", "expected a file id");
51935
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51170
51936
  const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51171
51937
  const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
51172
51938
  if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
51173
- invalid("maxColors", "expected a positive integer");
51939
+ invalid2("maxColors", "expected a positive integer");
51174
51940
  const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
51175
51941
  if (allowComplex !== undefined && typeof allowComplex !== "boolean")
51176
- invalid("allowComplex", "expected a boolean");
51942
+ invalid2("allowComplex", "expected a boolean");
51177
51943
  if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
51178
51944
  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`);
51179
51945
  const requestId = this.newRequestId();
@@ -52142,7 +52908,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
52142
52908
  }
52143
52909
 
52144
52910
  // src/main.ts
52145
- var version = "0.3.0-dev.2efda8a";
52911
+ var version = "0.3.0-dev.3266b68";
52146
52912
  var commands = commandTree(operations);
52147
52913
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
52148
52914
  function route(argv) {
@@ -52396,16 +53162,16 @@ Examples:
52396
53162
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
52397
53163
  if (typeof cursor === "string" && cursor)
52398
53164
  ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
52399
- const pageToken = pageTokenField(op), token = pageToken?.sdkName ?? pageToken?.name;
52400
- const firstPage = flags.all && !(result instanceof Page) && token ? pageOf(result) : undefined;
52401
- if (flags.all && !(result instanceof Page) && token && !firstPage)
52402
- throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token.replace(/_/g, "-")} instead`);
53165
+ const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
53166
+ const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
53167
+ if (flags.all && !(result instanceof Page) && token2 && !firstPage)
53168
+ throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
52403
53169
  if (firstPage) {
52404
53170
  const items = [...firstPage.items];
52405
53171
  const seen = new Set;
52406
53172
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
52407
53173
  seen.add(next);
52408
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53174
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
52409
53175
  items.push(...pageOf(result)?.items ?? []);
52410
53176
  }
52411
53177
  ctx.nextCommand = undefined;