@deepraxis/cli 0.3.0-dev.7bbb3d7 → 0.3.0-dev.877a000

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 +1508 -96
  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: {
@@ -48176,8 +48360,33 @@ Enter code: ${code.user_code}` });
48176
48360
  if (ports.json)
48177
48361
  ports.emit({ kind: "object", data: { env: config.env, ...shadowedBy ? { shadowed_by: shadowedBy } : {} } });
48178
48362
  }
48363
+ function jwtClaims(token) {
48364
+ const part = token.split(".")[1];
48365
+ if (!part)
48366
+ return null;
48367
+ try {
48368
+ const claims = JSON.parse(Buffer.from(part, "base64url").toString("utf8"));
48369
+ return claims && typeof claims === "object" ? claims : null;
48370
+ } catch {
48371
+ return null;
48372
+ }
48373
+ }
48179
48374
  async function whoami(auth, env, org) {
48180
48375
  const credential = await auth.get(org);
48376
+ if (credential.source === "machine-token" || credential.source === "managed-login") {
48377
+ const claims = jwtClaims(credential.token);
48378
+ const exp = typeof claims?.exp === "number" ? claims.exp * 1000 : credential.expiresAt;
48379
+ const str = (v) => typeof v === "string" && v ? v : null;
48380
+ return {
48381
+ subject: str(claims?.sub),
48382
+ organization: str(claims?.org) ?? credential.organizationId ?? null,
48383
+ env,
48384
+ source: credential.source,
48385
+ ...credential.storedIn ? { "stored in": credential.storedIn } : {},
48386
+ expires_at: exp ? new Date(exp).toISOString() : null,
48387
+ note: credential.source === "machine-token" ? "The machine token determines the organization." : "The managed login determines the organization; the platform renews it."
48388
+ };
48389
+ }
48181
48390
  const me = await auth.rpc("identity.me.get", {}, org);
48182
48391
  return {
48183
48392
  email: me.user.email,
@@ -48186,7 +48395,7 @@ async function whoami(auth, env, org) {
48186
48395
  source: credential.source,
48187
48396
  ...credential.storedIn ? { "stored in": credential.storedIn } : {},
48188
48397
  expires_at: credential.expiresAt ? new Date(credential.expiresAt).toISOString() : null,
48189
- ...credential.source === "api-key" ? { note: "The API key determines the organization." } : credential.source === "machine-token" ? { note: "The machine token determines the organization." } : credential.source === "managed-login" ? { note: "The managed login determines the organization; the platform renews it." } : {}
48398
+ ...credential.source === "api-key" ? { note: "The API key determines the organization." } : {}
48190
48399
  };
48191
48400
  }
48192
48401
 
@@ -49741,6 +49950,251 @@ function retop(store, id, top, rev) {
49741
49950
  retop(store, c, top, rev);
49742
49951
  }
49743
49952
  }
49953
+ // ../../packages/canvas/document/src/connector.ts
49954
+ var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
49955
+ var ARROWS = ["end", "start", "both", "none"];
49956
+ var ROUTES = ["straight", "elbow"];
49957
+ var ARROW_LENGTH_FACTOR = 6;
49958
+ var ARROW_HALF_ANGLE_DEG = 25;
49959
+ var EPSILON = 0.000000001;
49960
+ function centerOf(box) {
49961
+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
49962
+ }
49963
+ function inside(p, box) {
49964
+ return p.x > box.x && p.x < box.x + box.width && p.y > box.y && p.y < box.y + box.height;
49965
+ }
49966
+ function magnetPoint(box, magnet) {
49967
+ const c = centerOf(box);
49968
+ switch (magnet) {
49969
+ case "center":
49970
+ return c;
49971
+ case "top":
49972
+ return { x: c.x, y: box.y };
49973
+ case "bottom":
49974
+ return { x: c.x, y: box.y + box.height };
49975
+ case "left":
49976
+ return { x: box.x, y: c.y };
49977
+ case "right":
49978
+ return { x: box.x + box.width, y: c.y };
49979
+ }
49980
+ }
49981
+ function intersectBorder(box, shape, cornerRadius, toward) {
49982
+ const c = centerOf(box);
49983
+ const dx = toward.x - c.x;
49984
+ const dy = toward.y - c.y;
49985
+ if (dx === 0 && dy === 0)
49986
+ return c;
49987
+ const hw = box.width / 2;
49988
+ const hh = box.height / 2;
49989
+ if (hw <= 0 || hh <= 0)
49990
+ return c;
49991
+ if (shape === "ellipse") {
49992
+ const t2 = 1 / Math.hypot(dx / hw, dy / hh);
49993
+ return { x: c.x + dx * t2, y: c.y + dy * t2 };
49994
+ }
49995
+ const r = Math.max(0, Math.min(cornerRadius, Math.min(hw, hh)));
49996
+ const a = hw - r;
49997
+ const b = hh - r;
49998
+ let t = Infinity;
49999
+ if (dx !== 0) {
50000
+ const candidate = (a + r) / Math.abs(dx);
50001
+ if (Math.abs(dy) * candidate <= b + EPSILON)
50002
+ t = Math.min(t, candidate);
50003
+ }
50004
+ if (dy !== 0) {
50005
+ const candidate = (b + r) / Math.abs(dy);
50006
+ if (Math.abs(dx) * candidate <= a + EPSILON)
50007
+ t = Math.min(t, candidate);
50008
+ }
50009
+ if (!Number.isFinite(t)) {
50010
+ const ex = Math.sign(dx) * a;
50011
+ const ey = Math.sign(dy) * b;
50012
+ const qa = dx * dx + dy * dy;
50013
+ const qb = -2 * (dx * ex + dy * ey);
50014
+ const qc = ex * ex + ey * ey - r * r;
50015
+ const disc = Math.max(0, qb * qb - 4 * qa * qc);
50016
+ t = (-qb + Math.sqrt(disc)) / (2 * qa);
50017
+ }
50018
+ return { x: c.x + dx * t, y: c.y + dy * t };
50019
+ }
50020
+ function endPoint(end, magnet, toward) {
50021
+ if (magnet === "center")
50022
+ return centerOf(end.box);
50023
+ if (magnet === "auto")
50024
+ return intersectBorder(end.box, end.shape, end.cornerRadius, toward);
50025
+ return magnetPoint(end.box, magnet);
50026
+ }
50027
+ function arrowHead(tip, into, strokeWidth) {
50028
+ const length = strokeWidth * ARROW_LENGTH_FACTOR;
50029
+ const half = Math.tan(ARROW_HALF_ANGLE_DEG * Math.PI / 180) * length;
50030
+ const baseX = tip.x + into.x * length;
50031
+ const baseY = tip.y + into.y * length;
50032
+ const px = -into.y;
50033
+ const py = into.x;
50034
+ return {
50035
+ tip,
50036
+ left: { x: baseX + px * half, y: baseY + py * half },
50037
+ right: { x: baseX - px * half, y: baseY - py * half }
50038
+ };
50039
+ }
50040
+ function normalize(p) {
50041
+ const l = Math.hypot(p.x, p.y);
50042
+ return { x: p.x / l, y: p.y / l };
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
+ }
50068
+ function dashRanges(length, dash) {
50069
+ const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
50070
+ if (!pattern.length)
50071
+ return [[0, length]];
50072
+ const cycle = pattern.length % 2 ? [...pattern, ...pattern] : pattern;
50073
+ const out = [];
50074
+ let pos = 0;
50075
+ for (let i = 0;pos < length; i += 2) {
50076
+ const on = cycle[i % cycle.length];
50077
+ const off = cycle[(i + 1) % cycle.length];
50078
+ const end = Math.min(pos + on, length);
50079
+ if (end > pos)
50080
+ out.push([pos, end]);
50081
+ pos = end + off;
50082
+ }
50083
+ return out;
50084
+ }
50085
+ function n(value) {
50086
+ const rounded = Math.round(value * 100) / 100;
50087
+ return String(Object.is(rounded, -0) ? 0 : rounded);
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
+ }
50149
+ function connectorGeometry(from, to, opts = {}) {
50150
+ const arrow = opts.arrow ?? "end";
50151
+ const strokeWidth = opts.strokeWidth ?? 1.5;
50152
+ const labelPos = opts.labelPos ?? 0.5;
50153
+ const fromMagnet = opts.fromMagnet ?? "auto";
50154
+ const toMagnet = opts.toMagnet ?? "auto";
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];
50162
+ if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
50163
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
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 };
50167
+ const arrowHeads = [];
50168
+ if (arrow === "end" || arrow === "both")
50169
+ arrowHeads.push(arrowHead(p2, back, strokeWidth));
50170
+ if (arrow === "start" || arrow === "both")
50171
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50172
+ const xs = points.map((p) => p.x);
50173
+ const ys = points.map((p) => p.y);
50174
+ for (const head of arrowHeads) {
50175
+ xs.push(head.tip.x, head.left.x, head.right.x);
50176
+ ys.push(head.tip.y, head.left.y, head.right.y);
50177
+ }
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) };
50179
+ const local = (p) => ({ x: p.x - bbox.x, y: p.y - bbox.y });
50180
+ const parts = [];
50181
+ for (const [start, end] of dashRanges(length, opts.dash)) {
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(""));
50189
+ }
50190
+ for (const head of arrowHeads) {
50191
+ const t = local(head.tip);
50192
+ const l = local(head.left);
50193
+ const r = local(head.right);
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`);
50195
+ }
50196
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
50197
+ }
49744
50198
  // ../../packages/canvas/document/src/expand.ts
49745
50199
  function defaultTheme(themes) {
49746
50200
  const t = {};
@@ -49895,7 +50349,8 @@ var KNOWN_PROPS = {
49895
50349
  context: keys(`${SIZE} ${TEXT} content`),
49896
50350
  icon: keys(`${SIZE} ${EFFECTS} library icon weight fill`),
49897
50351
  script: keys(`${SIZE} clip scriptUri inputs`),
49898
- browser: keys(`${SIZE} ${EFFECTS} ${STROKE} url deviceId zoom scrollX scrollY cornerRadius`),
50352
+ browser: keys(`${SIZE} ${GRAPHICS} url deviceId zoom scrollX scrollY cornerRadius`),
50353
+ html: keys(`${SIZE} ${GRAPHICS} html cornerRadius`),
49899
50354
  ref: keys("ref descendants")
49900
50355
  };
49901
50356
  function unknownProperties(node2, type) {
@@ -49996,23 +50451,613 @@ function pathLineBounds(geometry) {
49996
50451
  return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
49997
50452
  }
49998
50453
 
50454
+ // ../../packages/canvas/document/src/live-node.ts
50455
+ var HTML_MAX_BYTES = 256 * 1024;
50456
+ var drawsNothing = (value) => value === undefined || value === null || typeof value === "number" && !(value > 0);
50457
+ function checkLiveNode(node2) {
50458
+ const warnings = [];
50459
+ if (!node2 || typeof node2 !== "object" || node2.type !== "html")
50460
+ return { warnings };
50461
+ const html = node2.html;
50462
+ if (typeof html !== "string")
50463
+ return { reject: { property: "html", reason: "html must be a string" }, warnings };
50464
+ const bytes = new TextEncoder().encode(html).length;
50465
+ if (bytes > HTML_MAX_BYTES)
50466
+ return {
50467
+ reject: { property: "html", reason: `html is ${bytes} bytes of UTF-8; the limit is ${HTML_MAX_BYTES}` },
50468
+ warnings
50469
+ };
50470
+ if (drawsNothing(node2.width) || drawsNothing(node2.height))
50471
+ warnings.push({ code: "HTML_NODE_NO_SIZE", message: "html node has no width and height: set both, or it paints at zero size" });
50472
+ return { warnings };
50473
+ }
50474
+
50475
+ // ../../packages/canvas/document/src/kit.ts
50476
+ function kitStampOf(node2) {
50477
+ const meta = node2?.metadata;
50478
+ const stamp = meta?.kit;
50479
+ if (!stamp || typeof stamp.key !== "string" || typeof stamp.version !== "number" || typeof stamp.name !== "string")
50480
+ return;
50481
+ return { name: stamp.name, version: stamp.version, key: stamp.key };
50482
+ }
50483
+ function remapRefs(node2, refId) {
50484
+ const { children, ...rest } = node2;
50485
+ const out = { ...rest };
50486
+ if (typeof out.ref === "string")
50487
+ out.ref = refId.get(out.ref) ?? out.ref;
50488
+ const descendants = out.descendants;
50489
+ if (descendants && typeof descendants === "object" && !Array.isArray(descendants)) {
50490
+ const mapped = {};
50491
+ for (const [path, value] of Object.entries(descendants)) {
50492
+ const rewritten = path.split("/").map((seg) => refId.get(seg) ?? seg).join("/");
50493
+ mapped[rewritten] = value;
50494
+ }
50495
+ out.descendants = mapped;
50496
+ }
50497
+ if (Array.isArray(children))
50498
+ out.children = children.map((c) => remapRefs(c, refId));
50499
+ return out;
50500
+ }
50501
+ function planKit(existing, kit) {
50502
+ const canvasId = new Map;
50503
+ const haveVersion = new Map;
50504
+ for (const node2 of existing) {
50505
+ if (canvasId.has(node2.key))
50506
+ continue;
50507
+ canvasId.set(node2.key, node2.id);
50508
+ haveVersion.set(node2.key, node2.version);
50509
+ }
50510
+ const refId = new Map;
50511
+ const keys2 = new Set;
50512
+ for (const component of kit.components) {
50513
+ const stamp = kitStampOf(component);
50514
+ if (!stamp)
50515
+ throw new Error(`kit ${kit.name}: component ${component.id} carries no metadata.kit stamp`);
50516
+ if (keys2.has(stamp.key))
50517
+ throw new Error(`kit ${kit.name}: duplicate component key ${stamp.key}`);
50518
+ keys2.add(stamp.key);
50519
+ refId.set(component.id, canvasId.get(stamp.key) ?? component.id);
50520
+ }
50521
+ const plan = { add: [], update: [], unchanged: 0, variables: Object.keys(kit.variables).length };
50522
+ for (const component of kit.components) {
50523
+ const stamp = kitStampOf(component);
50524
+ const id = refId.get(component.id);
50525
+ const node2 = id === component.id ? remapRefs(component, refId) : { ...remapRefs(component, refId), id };
50526
+ const version = haveVersion.get(stamp.key);
50527
+ if (version === undefined)
50528
+ plan.add.push(node2);
50529
+ else if (version >= kit.version)
50530
+ plan.unchanged++;
50531
+ else
50532
+ plan.update.push({ id, node: node2 });
50533
+ }
50534
+ return plan;
50535
+ }
50536
+ function existingKitNodesIn(store, kitName) {
50537
+ const out = [];
50538
+ const walk = (id) => {
50539
+ const row = store.get(id);
50540
+ if (!row)
50541
+ return;
50542
+ const stamp = kitStampOf(row.props);
50543
+ if (stamp && (kitName === undefined || stamp.name === kitName))
50544
+ out.push({ key: stamp.key, version: stamp.version, id });
50545
+ for (const child of store.children(id))
50546
+ walk(child);
50547
+ };
50548
+ for (const top of store.children(null))
50549
+ walk(top);
50550
+ return out;
50551
+ }
50552
+ function kitFrameIn(store, frame) {
50553
+ return store.children(null).find((id) => {
50554
+ const props = store.get(id)?.props;
50555
+ return props?.type === "frame" && props.name === frame;
50556
+ });
50557
+ }
50558
+ var componentName = (node2) => {
50559
+ const name = node2.name;
50560
+ return typeof name === "string" && name !== "" ? name : kitStampOf(node2).key;
50561
+ };
50562
+ function kitPlanNames(plan) {
50563
+ return { added: plan.add.map(componentName), updated: plan.update.map((u) => componentName(u.node)) };
50564
+ }
50565
+ function planRefs(plan) {
50566
+ const ids = new Set;
50567
+ const refs = [];
50568
+ const visit2 = (node2, collectIds) => {
50569
+ if (collectIds)
50570
+ ids.add(node2.id);
50571
+ if (node2.type === "ref" && typeof node2.ref === "string")
50572
+ refs.push(node2.ref);
50573
+ for (const child of Array.isArray(node2.children) ? node2.children : [])
50574
+ visit2(child, collectIds);
50575
+ };
50576
+ for (const node2 of plan.add)
50577
+ visit2(node2, true);
50578
+ for (const entry of plan.update)
50579
+ visit2(entry.node, false);
50580
+ return { refs, ids };
50581
+ }
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
+
49999
50921
  // ../../packages/canvas/document/src/execute-api.ts
50000
- var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4 };
50922
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
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
+ }
50943
+ var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
50944
+ function invalid2(property, reason) {
50945
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50946
+ }
50947
+ function pickOption(value, allowed, property, fallback) {
50948
+ if (value === undefined || value === null)
50949
+ return fallback;
50950
+ if (typeof value === "string" && allowed.includes(value))
50951
+ return value;
50952
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
50953
+ }
50954
+ function numberOption(value, property, fallback, positive = false) {
50955
+ if (value === undefined || value === null)
50956
+ return fallback;
50957
+ if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
50958
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
50959
+ return value;
50960
+ }
50961
+ function optionKeys2(value, allowed, name) {
50962
+ if (value === undefined || value === null)
50963
+ return {};
50964
+ if (typeof value !== "object" || Array.isArray(value))
50965
+ return invalid2(name, "expected an options object");
50966
+ for (const key of Object.keys(value))
50967
+ if (!allowed.has(key))
50968
+ return invalid2(key, `${name} does not take ${key}`);
50969
+ return value;
50970
+ }
50971
+ function dashOption(value) {
50972
+ if (value === undefined || value === null)
50973
+ return;
50974
+ if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
50975
+ invalid2("dash", "expected an array of positive numbers");
50976
+ return value;
50977
+ }
50978
+ var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
50979
+ var VECTORIZE_MODES = ["auto", "mono", "flat"];
50980
+ var VECTORIZE_KEYS = new Set(["mode", "maxColors", "allowComplex"]);
50981
+ var KIT_FRAME_GAP = 24;
50982
+ var KIT_FRAME_PADDING = 24;
50001
50983
  var ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
50984
+ function undeclared(node2, key) {
50985
+ return node2[key] === undefined || node2[key] === null;
50986
+ }
50987
+ var TEXT_DEFAULT_KEYS = ["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "fill"];
50988
+ var TEXT_DEFAULTS_BYTES = 4 * 1024;
50989
+ function normalizeDefaults(value) {
50990
+ const raw = value ?? {};
50991
+ const text = raw.text;
50992
+ if (!text || typeof text !== "object" || Array.isArray(text))
50993
+ return {};
50994
+ const out = {};
50995
+ for (const k of TEXT_DEFAULT_KEYS)
50996
+ if (!undeclared(text, k))
50997
+ out[k] = text[k];
50998
+ if (!Object.keys(out).length)
50999
+ return {};
51000
+ if (new TextEncoder().encode(JSON.stringify(out)).byteLength > TEXT_DEFAULTS_BYTES)
51001
+ return {};
51002
+ return { text: out };
51003
+ }
51004
+ function applyTextDefaults(node2, defaults) {
51005
+ const keys2 = defaults ? TEXT_DEFAULT_KEYS.filter((k) => !undeclared(defaults, k)) : [];
51006
+ let out = node2;
51007
+ if (keys2.length && node2.type === "text") {
51008
+ const filled = { ...node2 };
51009
+ for (const k of keys2)
51010
+ if (undeclared(filled, k))
51011
+ filled[k] = defaults[k];
51012
+ out = filled;
51013
+ }
51014
+ if (Array.isArray(out.children))
51015
+ out = { ...out, children: out.children.map((c) => applyTextDefaults(c, defaults)) };
51016
+ return out;
51017
+ }
50002
51018
  class ExecuteApi {
50003
51019
  store;
50004
51020
  rec;
50005
51021
  bounds;
50006
51022
  rev;
50007
51023
  random;
51024
+ measureText;
51025
+ kits;
50008
51026
  document = "document";
50009
51027
  layoutCache = new Map;
50010
- constructor(store, rec, bounds, rev, random = Math.random) {
51028
+ defaults = {};
51029
+ connectors = new Map;
51030
+ connectorsIndexed = false;
51031
+ constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50011
51032
  this.store = store;
50012
51033
  this.rec = rec;
50013
51034
  this.bounds = bounds;
50014
51035
  this.rev = rev;
50015
51036
  this.random = random;
51037
+ this.measureText = measureText;
51038
+ this.kits = kits;
51039
+ }
51040
+ setDefaults(value) {
51041
+ const raw = value;
51042
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw))
51043
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "SetDefaults", reason: "expected { text: { … } } or { text: null }" });
51044
+ for (const key of Object.keys(raw))
51045
+ if (key !== "text")
51046
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: key, reason: "SetDefaults only accepts text" });
51047
+ const text = raw.text;
51048
+ if (text !== null && text !== undefined) {
51049
+ if (typeof text !== "object" || Array.isArray(text))
51050
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "text", reason: "expected an object of text properties" });
51051
+ for (const key of Object.keys(text))
51052
+ if (!TEXT_DEFAULT_KEYS.includes(key))
51053
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: `text.${key}`, reason: `not a default text property; use ${TEXT_DEFAULT_KEYS.join(", ")}` });
51054
+ if (new TextEncoder().encode(JSON.stringify(text)).byteLength > TEXT_DEFAULTS_BYTES)
51055
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "text", reason: `defaults over ${TEXT_DEFAULTS_BYTES} bytes` });
51056
+ }
51057
+ return this.defaults = normalizeDefaults(value);
51058
+ }
51059
+ getDefaults() {
51060
+ return this.defaults;
50016
51061
  }
50017
51062
  mint() {
50018
51063
  for (;; ) {
@@ -50038,6 +51083,12 @@ class ExecuteApi {
50038
51083
  if (op.op === "setVariables")
50039
51084
  this.layoutCache.clear();
50040
51085
  }
51086
+ rowOf(path) {
51087
+ const row = this.store.get(path);
51088
+ if (!row)
51089
+ throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
51090
+ return row;
51091
+ }
50041
51092
  parentId(parent) {
50042
51093
  if (parent === "document" || parent === "" || parent == null)
50043
51094
  return null;
@@ -50069,6 +51120,9 @@ class ExecuteApi {
50069
51120
  if (typeof v === "string" && /%|vh|vw|calc/.test(v))
50070
51121
  throw new OpRejectedError({ code: "INVALID_VALUE", property: k, reason: "percentage and viewport sizes are not supported" });
50071
51122
  }
51123
+ const live = checkLiveNode(node2);
51124
+ if (live.reject)
51125
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: live.reject.property, reason: live.reject.reason });
50072
51126
  const id = this.mint();
50073
51127
  const out = { ...node2, id };
50074
51128
  if (typeof node2.name === "string") {
@@ -50082,11 +51136,18 @@ class ExecuteApi {
50082
51136
  }
50083
51137
  return out;
50084
51138
  }
50085
- warnProps(data, type, nodeId) {
51139
+ warnProps(data, type, nodeId, declared = false) {
50086
51140
  if (hasUnsupportedImageUrl(data) && this.rec.warnings.length < 20 && !this.rec.warnings.some((w) => w.code === "UNSUPPORTED_IMAGE_URL" && w.nodeId === nodeId))
50087
51141
  this.rec.warnings.push({ code: "UNSUPPORTED_IMAGE_URL", nodeId, message: "image fill url must be a file id (file-…)" });
51142
+ if (declared && data.type === "text" && undeclared(data, "fill") && !this.defaults.text?.fill && this.rec.warnings.length < 20 && !this.rec.warnings.some((w) => w.code === "TEXT_NO_FILL" && w.nodeId === nodeId))
51143
+ this.rec.warnings.push({ code: "TEXT_NO_FILL", nodeId, message: `text node has no fill and paints nothing — or call SetDefaults({ text: { fill: "#111827" } }) once to give every text node this session a default fill` });
50088
51144
  if (data.type === "icon" && !iconNameOf(data) && this.rec.warnings.length < 20 && !this.rec.warnings.some((w) => w.code === "ICON_NAME_MISSING" && w.nodeId === nodeId))
50089
51145
  this.rec.warnings.push({ code: "ICON_NAME_MISSING", nodeId, message: "icon node has no icon: set icon to a lucide name (name is the node's name, not the icon)" });
51146
+ if (data.type === "html") {
51147
+ for (const w of checkLiveNode(data).warnings)
51148
+ if (this.rec.warnings.length < 20 && !this.rec.warnings.some((x) => x.code === w.code && x.nodeId === nodeId))
51149
+ this.rec.warnings.push({ code: w.code, nodeId, message: w.message });
51150
+ }
50090
51151
  for (const prop of unknownProperties(data, type)) {
50091
51152
  const message = `${prop} is not a .pen property`;
50092
51153
  if (this.rec.warnings.length >= 20)
@@ -50097,7 +51158,7 @@ class ExecuteApi {
50097
51158
  if (type === "path")
50098
51159
  this.warnPathBox(data, nodeId);
50099
51160
  for (const child of Array.isArray(data.children) ? data.children : [])
50100
- this.warnProps(child, child.type, child.id ?? nodeId);
51161
+ this.warnProps(child, child.type, child.id ?? nodeId, declared);
50101
51162
  if (data.descendants && typeof data.descendants === "object") {
50102
51163
  const descendants = typeof data.ref === "string" ? this.resolveDescendantKeys(data.ref, data.descendants) : data.descendants;
50103
51164
  for (const [key, value] of Object.entries(descendants)) {
@@ -50127,7 +51188,7 @@ class ExecuteApi {
50127
51188
  return;
50128
51189
  if (this.rec.warnings.length >= 20 || this.rec.warnings.some((w) => w.code === "PATH_BOX_MISMATCH" && w.nodeId === nodeId))
50129
51190
  return;
50130
- const round = (n) => Number(n.toFixed(2));
51191
+ const round = (n2) => Number(n2.toFixed(2));
50131
51192
  this.rec.warnings.push({
50132
51193
  code: "PATH_BOX_MISMATCH",
50133
51194
  nodeId,
@@ -50144,9 +51205,9 @@ class ExecuteApi {
50144
51205
  const byName = new Map;
50145
51206
  const walk = (id) => {
50146
51207
  for (const c of this.store.children(id)) {
50147
- const n = this.store.get(c).props;
50148
- if (n.name)
50149
- byName.set(n.name, [...byName.get(n.name) ?? [], c]);
51208
+ const n2 = this.store.get(c).props;
51209
+ if (n2.name)
51210
+ byName.set(n2.name, [...byName.get(n2.name) ?? [], c]);
50150
51211
  walk(c);
50151
51212
  }
50152
51213
  };
@@ -50165,10 +51226,10 @@ class ExecuteApi {
50165
51226
  }
50166
51227
  Insert(parent, nodeData) {
50167
51228
  const p = this.parentId(parent);
50168
- let node2 = this.withIds(migrateLegacyProps(nodeData));
51229
+ let node2 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
50169
51230
  if (node2.type === "ref" && node2.descendants && typeof node2.descendants === "object")
50170
51231
  node2 = { ...node2, descendants: this.resolveDescendantKeys(node2.ref, node2.descendants) };
50171
- this.warnProps(node2, node2.type, node2.id);
51232
+ this.warnProps(node2, node2.type, node2.id, true);
50172
51233
  this.commit({ op: "insert", parent: p, ord: between(this.lastOrd(p), null), node: node2 });
50173
51234
  return node2.id;
50174
51235
  }
@@ -50189,16 +51250,16 @@ class ExecuteApi {
50189
51250
  } else {
50190
51251
  const tree = subtree(this.store, src.id);
50191
51252
  const descMap = descendants ? this.resolveDescendantKeys(src.id, descendants) : {};
50192
- const apply = (n) => {
50193
- const d = descMap[n.id];
50194
- let out = d && typeof d.type === "string" ? { ...d } : { ...n, ...d ?? {} };
50195
- if (Array.isArray(n.children) && !(d && typeof d.type === "string"))
50196
- out = { ...out, children: n.children.map(apply) };
51253
+ const apply = (n2) => {
51254
+ const d = descMap[n2.id];
51255
+ let out = d && typeof d.type === "string" ? { ...d } : { ...n2, ...d ?? {} };
51256
+ if (Array.isArray(n2.children) && !(d && typeof d.type === "string"))
51257
+ out = { ...out, children: n2.children.map(apply) };
50197
51258
  return out;
50198
51259
  };
50199
51260
  node2 = this.withIds({ ...apply(tree), ...over });
50200
51261
  }
50201
- this.warnProps(node2, node2.type, node2.id);
51262
+ this.warnProps(node2, node2.type, node2.id, true);
50202
51263
  this.commit({ op: "insert", parent: p, ord: between(this.lastOrd(p), null), node: node2 });
50203
51264
  return node2.id;
50204
51265
  }
@@ -50228,6 +51289,8 @@ class ExecuteApi {
50228
51289
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50229
51290
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50230
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();
50231
51294
  }
50232
51295
  Replace(path, nodeData) {
50233
51296
  const inst = this.splitInstancePath(path);
@@ -50235,8 +51298,8 @@ class ExecuteApi {
50235
51298
  const owner = this.store.get(inst.owner);
50236
51299
  if (!owner || owner.props.type !== "ref")
50237
51300
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50238
- const node3 = this.withIds(migrateLegacyProps(nodeData));
50239
- this.warnProps(node3, node3.type, node3.id);
51301
+ const node3 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
51302
+ this.warnProps(node3, node3.type, node3.id, true);
50240
51303
  const desc = { ...owner.props.descendants ?? {}, [inst.rest]: node3 };
50241
51304
  this.commit({ op: "update", id: owner.id, patch: { descendants: desc } });
50242
51305
  return node3.id;
@@ -50244,8 +51307,8 @@ class ExecuteApi {
50244
51307
  const row = this.store.get(path);
50245
51308
  if (!row)
50246
51309
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50247
- const node2 = this.withIds(migrateLegacyProps(nodeData));
50248
- this.warnProps(node2, node2.type, node2.id);
51310
+ const node2 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
51311
+ this.warnProps(node2, node2.type, node2.id, true);
50249
51312
  this.commit({ op: "delete", id: row.id });
50250
51313
  this.commit({ op: "insert", parent: row.parent, ord: row.ord, node: node2 });
50251
51314
  return node2.id;
@@ -50265,6 +51328,7 @@ class ExecuteApi {
50265
51328
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50266
51329
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50267
51330
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51331
+ this.finalizeConnectors();
50268
51332
  }
50269
51333
  Delete(path) {
50270
51334
  if (path === "document")
@@ -50274,6 +51338,14 @@ class ExecuteApi {
50274
51338
  if (!this.store.get(path))
50275
51339
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50276
51340
  this.commit({ op: "delete", id: path });
51341
+ this.finalizeConnectors();
51342
+ }
51343
+ MoveToBack(path) {
51344
+ this.Move(path, undefined, 0);
51345
+ }
51346
+ MoveToFront(path) {
51347
+ const row = this.rowOf(path);
51348
+ this.Move(path, undefined, this.store.children(row.parent).length);
50277
51349
  }
50278
51350
  SetVariables(variables, replace = false) {
50279
51351
  const themes = {};
@@ -50394,9 +51466,9 @@ class ExecuteApi {
50394
51466
  if (!tree)
50395
51467
  return null;
50396
51468
  const index = new Map;
50397
- const walk = (n) => {
50398
- index.set(n.path, n);
50399
- n.children.forEach(walk);
51469
+ const walk = (n2) => {
51470
+ index.set(n2.path, n2);
51471
+ n2.children.forEach(walk);
50400
51472
  };
50401
51473
  walk(tree);
50402
51474
  hit = { rev: this.mutations, index };
@@ -50505,6 +51577,254 @@ class ExecuteApi {
50505
51577
  problems: p ? p.code === "FULLY_CLIPPED" ? "fully clipped" : "partially clipped" : undefined
50506
51578
  };
50507
51579
  }
51580
+ MeasureText(content, options) {
51581
+ if (typeof content !== "string")
51582
+ invalid2("content", "expected a string");
51583
+ if (!this.measureText)
51584
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51585
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
51586
+ if (typeof o.fontFamily !== "string" || o.fontFamily === "")
51587
+ invalid2("fontFamily", "expected a font family name");
51588
+ if (o.fontSize === undefined || o.fontSize === null)
51589
+ invalid2("fontSize", "expected a positive number");
51590
+ return this.measureText({
51591
+ content,
51592
+ fontFamily: o.fontFamily,
51593
+ fontSize: numberOption(o.fontSize, "fontSize", 14, true),
51594
+ fontWeight: o.fontWeight,
51595
+ lineHeight: o.lineHeight === undefined || o.lineHeight === null ? undefined : numberOption(o.lineHeight, "lineHeight", 0, true),
51596
+ letterSpacing: o.letterSpacing === undefined || o.letterSpacing === null ? undefined : numberOption(o.letterSpacing, "letterSpacing", 0),
51597
+ width: o.width === undefined || o.width === null ? undefined : numberOption(o.width, "width", 0, true)
51598
+ });
51599
+ }
51600
+ absoluteBounds(path) {
51601
+ return this.absoluteOf(path) ?? { x: 0, y: 0, width: 0, height: 0 };
51602
+ }
51603
+ Connect(from, to, options) {
51604
+ if (typeof from !== "string" || typeof to !== "string")
51605
+ invalid2("from", "expected a node id");
51606
+ if (from === to)
51607
+ invalid2("to", "a node cannot be connected to itself");
51608
+ this.rowOf(from);
51609
+ this.rowOf(to);
51610
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
51611
+ const route = pickOption(o.route, ROUTES, "route", "straight");
51612
+ const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
51613
+ const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
51614
+ const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
51615
+ const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
51616
+ if (labelPos < 0 || labelPos > 1)
51617
+ invalid2("labelPos", "expected a number between 0 and 1");
51618
+ const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
51619
+ const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
51620
+ if (typeof stroke !== "string")
51621
+ invalid2("stroke", "expected a colour string");
51622
+ const dash = dashOption(o.dash);
51623
+ const behind = o.behind === undefined || o.behind === null ? true : o.behind;
51624
+ if (typeof behind !== "boolean")
51625
+ invalid2("behind", "expected a boolean");
51626
+ const name = o.name === undefined || o.name === null ? "Connector" : o.name;
51627
+ if (typeof name !== "string")
51628
+ invalid2("name", "expected a string");
51629
+ if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
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 });
51633
+ const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
51634
+ const target = parent ?? "document";
51635
+ const origin = this.originOf(parent);
51636
+ const absolute = this.inFlow(parent);
51637
+ const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
51638
+ let labelId;
51639
+ if (typeof o.label === "string" && o.label !== "") {
51640
+ const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
51641
+ const width = size.width + 8;
51642
+ const height = size.height + 4;
51643
+ labelId = this.Insert(target, {
51644
+ id: "",
51645
+ type: "frame",
51646
+ name: `${name}-label`,
51647
+ ...place({ x: geom.labelCenter.x - width / 2, y: geom.labelCenter.y - height / 2, width, height }),
51648
+ fill: "#FFFFFF",
51649
+ padding: [2, 4],
51650
+ layout: "none",
51651
+ children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
51652
+ });
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);
51670
+ return id;
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
+ }
51787
+ absoluteOf(path) {
51788
+ if (path === null || path === "")
51789
+ return { x: 0, y: 0, width: 0, height: 0 };
51790
+ const row = this.store.get(path.split("/")[0]);
51791
+ if (!row)
51792
+ return null;
51793
+ const b = this.layoutOf(row.top).boxes.get(path);
51794
+ return b ? { x: b.wx, y: b.wy, width: b.width, height: b.height } : null;
51795
+ }
51796
+ originOf(parent) {
51797
+ if (parent === null)
51798
+ return { x: 0, y: 0 };
51799
+ const box = this.absoluteOf(parent);
51800
+ if (!box)
51801
+ invalid2("parent", `${parent} has no laid-out box`);
51802
+ return { x: box.x, y: box.y };
51803
+ }
51804
+ connectorEnd(id, property) {
51805
+ const row = this.rowOf(id);
51806
+ const box = this.absoluteOf(id);
51807
+ if (!box || box.width === 0 && box.height === 0)
51808
+ invalid2(property, `${id} has no laid-out box to attach to`);
51809
+ return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
51810
+ }
51811
+ commonParent(a, b) {
51812
+ this.rowOf(a);
51813
+ this.rowOf(b);
51814
+ const ancestors = new Set;
51815
+ for (let cur = this.store.get(a).parent;cur !== null; cur = this.store.get(cur)?.parent ?? null)
51816
+ ancestors.add(cur);
51817
+ for (let cur = this.store.get(b).parent;cur !== null; cur = this.store.get(cur)?.parent ?? null)
51818
+ if (ancestors.has(cur))
51819
+ return cur;
51820
+ return null;
51821
+ }
51822
+ inFlow(parent) {
51823
+ if (parent === null)
51824
+ return false;
51825
+ const props = this.store.get(parent)?.props;
51826
+ return props?.type === "frame" && props.layout !== "none";
51827
+ }
50508
51828
  FindEmptySpace(input) {
50509
51829
  const dir = input.direction ?? "right";
50510
51830
  const pad = input.padding ?? 0;
@@ -50532,6 +51852,69 @@ class ExecuteApi {
50532
51852
  return { x: minX, y: maxY + pad };
50533
51853
  return { x: minX, y: minY - pad - input.height };
50534
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
+ }
51866
+ ListKits() {
51867
+ return this.kits?.list() ?? [];
51868
+ }
51869
+ UseKit(name) {
51870
+ if (typeof name !== "string" || name === "")
51871
+ invalid2("name", "expected a kit name");
51872
+ const entry = this.kits?.get(name);
51873
+ if (!entry)
51874
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51875
+ const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51876
+ const { refs, ids } = planRefs(plan);
51877
+ for (const ref of refs)
51878
+ if (!ids.has(ref) && !this.store.get(ref))
51879
+ throw new OpRejectedError({ code: "UNKNOWN_REF", ref });
51880
+ this.SetVariables(entry.kit.variables, false);
51881
+ const frame = kitFrameIn(this.store, entry.frame) ?? this.createKitFrame(entry.frame);
51882
+ for (const node2 of plan.add)
51883
+ this.insertKitComponent(frame, null, node2);
51884
+ for (const { id, node: node2 } of plan.update) {
51885
+ const row = this.rowOf(id);
51886
+ this.commit({ op: "delete", id });
51887
+ this.insertKitComponent(row.parent, row.ord, node2);
51888
+ }
51889
+ const names = kitPlanNames(plan);
51890
+ return { version: entry.kit.version, added: names.added, updated: names.updated, unchanged: plan.unchanged, variables: plan.variables };
51891
+ }
51892
+ createKitFrame(name) {
51893
+ const at = this.FindEmptySpace({ width: 0, height: 0, direction: "right", padding: KIT_FRAME_GAP });
51894
+ return this.Insert("document", {
51895
+ id: "",
51896
+ type: "frame",
51897
+ name,
51898
+ x: at.x,
51899
+ y: at.y,
51900
+ layout: "vertical",
51901
+ gap: KIT_FRAME_GAP,
51902
+ padding: KIT_FRAME_PADDING
51903
+ });
51904
+ }
51905
+ insertKitComponent(parent, ord, node2) {
51906
+ const tree = applyTextDefaults(migrateLegacyProps(node2), this.defaults.text);
51907
+ const seen = new Set;
51908
+ const check = (n2) => {
51909
+ if (seen.has(n2.id) || this.store.get(n2.id))
51910
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "id", reason: `kit component id ${n2.id} is already taken on this canvas` });
51911
+ seen.add(n2.id);
51912
+ for (const child of Array.isArray(n2.children) ? n2.children : [])
51913
+ check(child);
51914
+ };
51915
+ check(tree);
51916
+ this.commit({ op: "insert", parent, ord: ord ?? between(this.lastOrd(parent), null), node: tree });
51917
+ }
50535
51918
  Print(...values) {
50536
51919
  const line = values.map((v) => typeof v === "string" ? v : JSON.stringify(v)).join(" ");
50537
51920
  this.rec.printBytes += line.length;
@@ -50544,6 +51927,35 @@ class ExecuteApi {
50544
51927
  if (this.rec.screenshots.length < LIMITS.screenshots)
50545
51928
  this.rec.screenshots.push(id);
50546
51929
  }
51930
+ Vectorize(frameId, fileId, opts) {
51931
+ if (typeof frameId !== "string" || frameId === "")
51932
+ invalid2("frameId", "expected a frame id");
51933
+ if (typeof fileId !== "string" || fileId === "")
51934
+ invalid2("fileId", "expected a file id");
51935
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51936
+ const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51937
+ const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
51938
+ if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
51939
+ invalid2("maxColors", "expected a positive integer");
51940
+ const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
51941
+ if (allowComplex !== undefined && typeof allowComplex !== "boolean")
51942
+ invalid2("allowComplex", "expected a boolean");
51943
+ if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
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`);
51945
+ const requestId = this.newRequestId();
51946
+ const carried = { ...mode === undefined ? {} : { mode }, ...maxColors === undefined ? {} : { maxColors }, ...allowComplex === undefined ? {} : { allowComplex } };
51947
+ this.rec.pendingVectorize.push({ requestId, frameId, fileId, ...Object.keys(carried).length ? { opts: carried } : {} });
51948
+ return { requestId };
51949
+ }
51950
+ newRequestId() {
51951
+ for (;; ) {
51952
+ let id = "vz-";
51953
+ for (let i = 0;i < 10; i++)
51954
+ id += ID_CHARS[Math.floor(this.random() * ID_CHARS.length)];
51955
+ if (!this.rec.pendingVectorize.some((p) => p.requestId === id))
51956
+ return id;
51957
+ }
51958
+ }
50547
51959
  }
50548
51960
  function toPen(e, depth, _resolved, _instances, shallow = false) {
50549
51961
  const node2 = { ...e.props, id: e.path, type: e.type };
@@ -50941,8 +52353,8 @@ function relative(iso, now) {
50941
52353
  const delta = now - Date.parse(iso), seconds = Math.floor(Math.abs(delta) / 1000);
50942
52354
  if (Math.abs(delta) < 60000)
50943
52355
  return "just now";
50944
- const [n, unit] = seconds < 60 ? [seconds, "s"] : seconds < 3600 ? [Math.floor(seconds / 60), "m"] : seconds < 86400 ? [Math.floor(seconds / 3600), "h"] : [Math.floor(seconds / 86400), "d"];
50945
- return delta < 0 ? `in ${n}${unit}` : `${n}${unit} ago`;
52356
+ const [n2, unit] = seconds < 60 ? [seconds, "s"] : seconds < 3600 ? [Math.floor(seconds / 60), "m"] : seconds < 86400 ? [Math.floor(seconds / 3600), "h"] : [Math.floor(seconds / 86400), "d"];
52357
+ return delta < 0 ? `in ${n2}${unit}` : `${n2}${unit} ago`;
50946
52358
  }
50947
52359
  function scalar(value) {
50948
52360
  return value === undefined ? "" : value === null ? "null" : typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -51034,7 +52446,7 @@ function projectList(items, op) {
51034
52446
  }
51035
52447
 
51036
52448
  // src/output/human.ts
51037
- var count2 = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
52449
+ var count2 = (n2, noun) => `${n2} ${noun}${n2 === 1 ? "" : "s"}`;
51038
52450
  function identity2(result, ctx) {
51039
52451
  const op = "op" in result ? result.op : undefined;
51040
52452
  const split = op?.lastIndexOf(".") ?? -1;
@@ -51496,7 +52908,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
51496
52908
  }
51497
52909
 
51498
52910
  // src/main.ts
51499
- var version = "0.3.0-dev.7bbb3d7";
52911
+ var version = "0.3.0-dev.877a000";
51500
52912
  var commands = commandTree(operations);
51501
52913
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
51502
52914
  function route(argv) {
@@ -51516,10 +52928,10 @@ function route(argv) {
51516
52928
  words.push(arg);
51517
52929
  if (words.length === 1 && words[0] === API_WORD && HTTP_METHOD.test(argv[i + 1] ?? ""))
51518
52930
  return { words, args: [...args, ...argv.slice(i + 1)] };
51519
- const command = commands.find((c) => c.words.length === words.length && c.words.every((w, n) => w === words[n]));
52931
+ const command = commands.find((c) => c.words.length === words.length && c.words.every((w, n2) => w === words[n2]));
51520
52932
  if (words.length === 1 && words[0] === API_WORD && argv[i + 1] !== undefined && !argv[i + 1].startsWith("-"))
51521
52933
  continue;
51522
- if (command || manual.some((c) => c.length === words.length && c.every((w, n) => w === words[n])))
52934
+ if (command || manual.some((c) => c.length === words.length && c.every((w, n2) => w === words[n2])))
51523
52935
  return { words, args: [...args, ...argv.slice(i + 1)], command };
51524
52936
  }
51525
52937
  return { words, args };
@@ -51750,16 +53162,16 @@ Examples:
51750
53162
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
51751
53163
  if (typeof cursor === "string" && cursor)
51752
53164
  ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
51753
- const pageToken = pageTokenField(op), token = pageToken?.sdkName ?? pageToken?.name;
51754
- const firstPage = flags.all && !(result instanceof Page) && token ? pageOf(result) : undefined;
51755
- if (flags.all && !(result instanceof Page) && token && !firstPage)
51756
- 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`);
51757
53169
  if (firstPage) {
51758
53170
  const items = [...firstPage.items];
51759
53171
  const seen = new Set;
51760
53172
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
51761
53173
  seen.add(next);
51762
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53174
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
51763
53175
  items.push(...pageOf(result)?.items ?? []);
51764
53176
  }
51765
53177
  ctx.nextCommand = undefined;