@deepraxis/cli 0.3.0-dev.bff6020 → 0.3.0-dev.d38b647

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 +18 -14
  2. package/dist/praxis.js +1587 -113
  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. Voice cloning is not available yet, so voice is a platform voice name of the chosen model. 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
  }
@@ -28975,7 +29051,7 @@ for more details.`
28975
29051
  resource: "studio.codexes",
28976
29052
  method: "list",
28977
29053
  summary: "List the reference libraries of this organization",
28978
- description: "List the reference libraries this API key organization owns, each with how many entries it holds, so you can choose the one a work draws on. Continue with next_page_token until the answer stops carrying one. A library is shared across works, so the list is the whole organization's rather than one work's.",
29054
+ description: "List the reference libraries this API key organization owns, each with how many entries it holds, so you can choose the one a work draws on. Continue with next_page_token until the answer stops carrying one. Pass work to read one work's own library alone; leave it out for every library the organization owns.",
28979
29055
  http: "GET",
28980
29056
  path: "/studio/v1/codexes",
28981
29057
  streaming: "no",
@@ -28993,6 +29069,12 @@ for more details.`
28993
29069
  type: "string",
28994
29070
  required: false,
28995
29071
  description: "Cursor from the previous answer's next_page_token; it is opaque, so pass it back unchanged and never build one from an id or an offset."
29072
+ },
29073
+ {
29074
+ name: "work",
29075
+ type: "string",
29076
+ required: false,
29077
+ description: "Narrow the list to what belongs to one work, by its wk_ identifier, which is how one work's own setting is told apart from the organization's shared material; omit it to list everything this organization owns."
28996
29078
  }
28997
29079
  ]
28998
29080
  },
@@ -29000,7 +29082,7 @@ for more details.`
29000
29082
  resource: "studio.codexes",
29001
29083
  method: "create",
29002
29084
  summary: "Create a reference library",
29003
- description: "Create a reference library: a shared store of the people, places, products and facts a piece draws on, reusable across works. Attach it to a work with the work update call, and the entries it holds then reach the context packs of that work's units. A library is not private to one work, so the same brand facts can serve every piece that mentions them.",
29085
+ description: "Create a reference library: a store of the people, places, products and facts a piece draws on. Attach it to a work with the work update call, and the entries it holds then reach the context packs of that work's units. A library made this way is shared across works, which suits brand facts several pieces mention; the library a work needs for its own setting is created with the work itself, and the work list call finds it by filtering on work.",
29004
29086
  http: "POST",
29005
29087
  path: "/studio/v1/codexes",
29006
29088
  streaming: "no",
@@ -29150,7 +29232,7 @@ for more details.`
29150
29232
  resource: "studio.codexes.entries",
29151
29233
  method: "create",
29152
29234
  summary: "Add an entry to a reference library",
29153
- description: "Add one entry: a character, a place, a product, a source of facts. Give it the type the genre uses, the name the text will mention, and the description and facts that should reach a writer when it is mentioned. Aliases and excluded phrases keep detection honest, so a common word inside an idiom is not mistaken for the entry. A name already used in the library is refused.",
29235
+ description: "Add one entry: a character, a place, a product, a source of facts. Give it the type the genre uses, the name the text will mention, and the description, notes, facts and story time that should reach a writer when it is mentioned. Attach a picture gallery when the entry should be looked at as well as read. Aliases and excluded phrases keep detection honest, so a common word inside an idiom is not mistaken for the entry. A name already used in the library is refused.",
29154
29236
  http: "POST",
29155
29237
  path: "/studio/v1/codexes/{codex}/entries",
29156
29238
  streaming: "no",
@@ -29193,6 +29275,12 @@ for more details.`
29193
29275
  required: true,
29194
29276
  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
29277
  },
29278
+ {
29279
+ name: "group",
29280
+ type: "string",
29281
+ required: false,
29282
+ 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."
29283
+ },
29196
29284
  {
29197
29285
  name: "aliases",
29198
29286
  type: "array",
@@ -29229,7 +29317,13 @@ for more details.`
29229
29317
  name: "notes",
29230
29318
  type: "string",
29231
29319
  required: false,
29232
- description: "Notes for people only, which never reach a writer's context pack."
29320
+ description: "Notes on this entry, which reach the writer's context pack on the line after the description and the facts; an empty string adds no line. Write here what the text must respect, not a private remark."
29321
+ },
29322
+ {
29323
+ name: "time",
29324
+ type: "string",
29325
+ required: false,
29326
+ description: "When this entry happens in the story, such as 2037 or 民国二十四年冬; at most 40 characters, and an empty string records no time. It is shown beside the entry and reaches the writer with it."
29233
29327
  },
29234
29328
  {
29235
29329
  name: "tracking",
@@ -29252,9 +29346,9 @@ for more details.`
29252
29346
  {
29253
29347
  name: "images",
29254
29348
  type: "array",
29255
- itemType: "string",
29349
+ itemType: "object",
29256
29350
  required: false,
29257
- description: "Images to attach, referenced by file identifiers that belong to this organization."
29351
+ description: "Picture gallery of this entry, in write order: send pictures with a name and a description, or send a bare file identifier when the picture has no name yet and it is stored with both empty."
29258
29352
  }
29259
29353
  ]
29260
29354
  }
@@ -29286,7 +29380,7 @@ for more details.`
29286
29380
  resource: "studio.codexes.entries",
29287
29381
  method: "retrieve",
29288
29382
  summary: "Read one reference entry",
29289
- description: "Read one entry in full: its description, its fact ledger, its relations to other entries, its detection settings and its images. Read it before changing it, because an update replaces the fields it names rather than merging them. The entry is addressed by its name in this library, or by its ent_ identifier.",
29383
+ description: "Read one entry in full: its description, its notes, its fact ledger, its relations to other entries, its story time, its detection settings and its picture gallery. Read it before changing it, because an update replaces the fields it names rather than merging them. The entry is addressed by its name in this library, or by its ent_ identifier.",
29290
29384
  http: "GET",
29291
29385
  path: "/studio/v1/codexes/{codex}/entries/{entry}",
29292
29386
  streaming: "no",
@@ -29309,7 +29403,7 @@ for more details.`
29309
29403
  resource: "studio.codexes.entries",
29310
29404
  method: "update",
29311
29405
  summary: "Change what a reference entry says",
29312
- description: "Change one entry: its type, its name, its aliases, its description, its facts, its notes, its tracking setting, its images or its relations. Send update_mask naming exactly the fields you change, because a field the mask leaves out keeps its value while a list field the mask names is replaced whole. Renaming an entry changes what the text has to mention for detection to find it.",
29406
+ description: "Change one entry: its type, its name, its aliases, its description, its facts, its notes, its story time, its tracking setting, its picture gallery or its relations. Send update_mask naming exactly the fields you change, because a field the mask leaves out keeps its value while a list field the mask names is replaced whole. Renaming an entry changes what the text has to mention for detection to find it.",
29313
29407
  http: "PATCH",
29314
29408
  path: "/studio/v1/codexes/{codex}/entries/{entry}",
29315
29409
  streaming: "no",
@@ -29364,6 +29458,12 @@ for more details.`
29364
29458
  required: false,
29365
29459
  description: "New name for this entry, which also changes what the text has to mention for detection to find it."
29366
29460
  },
29461
+ {
29462
+ name: "group",
29463
+ type: "string",
29464
+ required: false,
29465
+ 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."
29466
+ },
29367
29467
  {
29368
29468
  name: "aliases",
29369
29469
  type: "array",
@@ -29400,7 +29500,13 @@ for more details.`
29400
29500
  name: "notes",
29401
29501
  type: "string",
29402
29502
  required: false,
29403
- description: "New notes for people only, which never reach a writer's context pack."
29503
+ description: "New notes on this entry, replacing the previous ones; they reach the writer's context pack on the line after the description and the facts, and an empty string removes that line."
29504
+ },
29505
+ {
29506
+ name: "time",
29507
+ type: "string",
29508
+ required: false,
29509
+ description: "New story time for this entry, replacing the previous one; at most 40 characters, and an empty string removes the time."
29404
29510
  },
29405
29511
  {
29406
29512
  name: "tracking",
@@ -29423,9 +29529,9 @@ for more details.`
29423
29529
  {
29424
29530
  name: "images",
29425
29531
  type: "array",
29426
- itemType: "string",
29532
+ itemType: "object",
29427
29533
  required: false,
29428
- description: "Complete set of images, replacing the previous ones."
29534
+ description: "Complete picture gallery for this entry, replacing the previous one and keeping the order you send; a picture left out stops being shown beside the entry."
29429
29535
  }
29430
29536
  ]
29431
29537
  }
@@ -29590,6 +29696,12 @@ for more details.`
29590
29696
  type: "string",
29591
29697
  required: false,
29592
29698
  description: "Cursor from the previous answer's next_page_token; it is opaque, so pass it back unchanged and never build one from an id or an offset."
29699
+ },
29700
+ {
29701
+ name: "work",
29702
+ type: "string",
29703
+ required: false,
29704
+ description: "Narrow the list to what belongs to one work, by its wk_ identifier, which is how one work's own setting is told apart from the organization's shared material; omit it to list everything this organization owns."
29593
29705
  }
29594
29706
  ]
29595
29707
  },
@@ -29597,7 +29709,7 @@ for more details.`
29597
29709
  resource: "studio.styles",
29598
29710
  method: "create",
29599
29711
  summary: "Create a writing style",
29600
- description: "Create a style: the voice a piece is written in, held as samples rather than as adjectives. Samples matter more than a description, so paste one to five paragraphs of writing the piece should sound like, and put the words to avoid into avoid so the banned-word check uses them. Attach a style to a work, or to one draft of it, and its samples then reach every context pack.",
29712
+ description: "Create a style: the voice a piece is written in, held as samples rather than as adjectives. Samples matter more than a description, so paste one to five paragraphs of writing the piece should sound like, and put the words to avoid into avoid so the banned-word check uses them. A style belongs to the work you name in work, and a work may only attach its own styles, so create the style with the work it will be used in. Attach a style to a work, or to one draft of it, and its samples then reach every context pack.",
29601
29713
  http: "POST",
29602
29714
  path: "/studio/v1/styles",
29603
29715
  streaming: "no",
@@ -29626,6 +29738,19 @@ for more details.`
29626
29738
  required: false,
29627
29739
  description: "One to five paragraphs of writing in the intended voice; these paragraphs are what reach a writer, so choose them carefully."
29628
29740
  },
29741
+ {
29742
+ name: "pictures",
29743
+ type: "array",
29744
+ itemType: "object",
29745
+ required: false,
29746
+ description: "Picture samples to store with the style, in the order you send them; a bare file identifier is stored as a picture with no name and no description."
29747
+ },
29748
+ {
29749
+ name: "work",
29750
+ type: "string",
29751
+ required: false,
29752
+ description: "Work this style should belong to, by its wk_ identifier; pass it so the work can attach the style later, since a work may only use its own styles. Omit it for a style that belongs to no single work."
29753
+ },
29629
29754
  {
29630
29755
  name: "use",
29631
29756
  type: "array",
@@ -29689,7 +29814,7 @@ for more details.`
29689
29814
  resource: "studio.styles",
29690
29815
  method: "update",
29691
29816
  summary: "Change a writing style",
29692
- description: "Change a style: its name, its description, its samples, its use and avoid lists, or its glossary. Send update_mask naming exactly the fields you change; a list the mask names is replaced whole. Adding a term to the glossary or to avoid also changes what the deterministic checks flag, so a work that uses this style sees new findings on its next check.",
29817
+ description: "Change a style: its name, its description, its samples, its picture samples, its use and avoid lists, or its glossary. Send update_mask naming exactly the fields you change; a list the mask names is replaced whole. Adding a term to the glossary or to avoid also changes what the deterministic checks flag, so a work that uses this style sees new findings on its next check.",
29693
29818
  http: "PATCH",
29694
29819
  path: "/studio/v1/styles/{style}",
29695
29820
  streaming: "no",
@@ -29731,6 +29856,13 @@ for more details.`
29731
29856
  required: false,
29732
29857
  description: "Complete set of sample paragraphs, replacing the previous ones; removing a sample removes it from every later context pack."
29733
29858
  },
29859
+ {
29860
+ name: "pictures",
29861
+ type: "array",
29862
+ itemType: "object",
29863
+ required: false,
29864
+ description: "Complete picture gallery for this style, replacing the previous one and keeping the order you send; a picture left out stops being shown."
29865
+ },
29734
29866
  {
29735
29867
  name: "use",
29736
29868
  type: "array",
@@ -30102,7 +30234,7 @@ for more details.`
30102
30234
  resource: "studio.works",
30103
30235
  method: "create",
30104
30236
  summary: "Create a work with its goal",
30105
- description: "Create a work: one deliverable piece plus everything around it. Pass the goal the writing serves — the reader, what that reader should get or do, the one-sentence message and the constraints — and the original brief the person gave in their own words. A slug is derived from the title unless you pass one. The work starts with no drafts; create the first one with the drafts create call, because the genre decides the structure.",
30237
+ description: "Create a work: one deliverable piece plus everything around it. Pass the goal the writing serves — the reader, what that reader should get or do, the one-sentence message and the constraints — and the original brief the person gave in their own words. A slug is derived from the title unless you pass one. The work starts with no drafts; create the first one with the drafts create call, because the genre decides the structure. A reference library belongs to the work and is created with it, so the setting written later stays this work's own; pass based_on to start from another work and have its setting and styles copied in as your own.",
30106
30238
  http: "POST",
30107
30239
  path: "/studio/v1/works",
30108
30240
  streaming: "no",
@@ -30141,13 +30273,25 @@ for more details.`
30141
30273
  type: "array",
30142
30274
  itemType: "string",
30143
30275
  required: false,
30144
- description: "Reference libraries to attach at creation; a library owned by another organization is refused rather than attached."
30276
+ description: "Shared reference libraries to attach at creation, on top of the work's own library, which is always created with it; a library owned by another organization is refused rather than attached."
30145
30277
  },
30146
30278
  {
30147
30279
  name: "style",
30148
30280
  type: "string",
30149
30281
  required: false,
30150
- description: "Style to attach to the work, whose samples and glossary then reach every context pack unless a draft overrides it."
30282
+ description: "Style to attach to the work, whose samples and glossary then reach every context pack unless a draft overrides it. A new work has no styles of its own yet, so leave this out and attach one after creating a style with work set to this work."
30283
+ },
30284
+ {
30285
+ name: "cover",
30286
+ type: "string",
30287
+ required: false,
30288
+ description: "Cover image for the work, by a file identifier that belongs to this organization; leave it out for a work with no cover."
30289
+ },
30290
+ {
30291
+ name: "based_on",
30292
+ type: "string",
30293
+ required: false,
30294
+ description: "Work to copy at creation, by its wk_ identifier or its slug: its own library's entries, its styles and the style it uses come into this new work as its own copies, and the source is recorded as this work's baseline. The two works are independent afterwards, and drafts are not copied. Use it to start a sequel or a variant from an existing setting instead of rebuilding the setting; a source work this organization does not own answers BASELINE_NOT_FOUND."
30151
30295
  },
30152
30296
  {
30153
30297
  name: "labels",
@@ -30270,7 +30414,13 @@ for more details.`
30270
30414
  name: "style",
30271
30415
  type: "string",
30272
30416
  required: false,
30273
- description: "Style to attach to the work, replacing the previous one; send an empty value to detach the style entirely."
30417
+ description: "Style to attach to the work, replacing the previous one; send an empty value to detach the style entirely. It must be one of this work's own styles — name a style created with work set to this work — and the style of another work is refused with STYLE_NOT_IN_WORK."
30418
+ },
30419
+ {
30420
+ name: "cover",
30421
+ type: "string",
30422
+ required: false,
30423
+ description: "Cover image to set, by a file identifier that belongs to this organization, replacing the previous cover; send null with cover named in the update mask to clear the cover."
30274
30424
  },
30275
30425
  {
30276
30426
  name: "labels",
@@ -32261,6 +32411,31 @@ for more details.`
32261
32411
  }
32262
32412
  ]
32263
32413
  },
32414
+ {
32415
+ resource: "ticket.repositories",
32416
+ method: "update",
32417
+ summary: "Update repositories",
32418
+ 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.",
32419
+ http: "PATCH",
32420
+ path: "/ticket/v1/repositories/{id}",
32421
+ streaming: "no",
32422
+ pagination: false,
32423
+ pathParams: [
32424
+ {
32425
+ name: "id",
32426
+ sdkName: "id",
32427
+ description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
32428
+ }
32429
+ ],
32430
+ query: [
32431
+ {
32432
+ name: "repository",
32433
+ type: "string",
32434
+ required: false,
32435
+ description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
32436
+ }
32437
+ ]
32438
+ },
32264
32439
  {
32265
32440
  resource: "ticket.tickets",
32266
32441
  method: "list",
@@ -35680,6 +35855,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
35680
35855
  ...options.headers
35681
35856
  }
35682
35857
  });
35858
+ var browserGetSessionFrame = (options) => (options.client ?? client).get({
35859
+ security: [{
35860
+ key: "BrowserBearer",
35861
+ scheme: "bearer",
35862
+ type: "http"
35863
+ }],
35864
+ url: "/browser/v1/sessions/{sessionId}/frame",
35865
+ ...options
35866
+ });
35683
35867
  var browserListContexts = (options) => (options?.client ?? client).get({
35684
35868
  security: [{
35685
35869
  key: "BrowserBearer",
@@ -35768,6 +35952,15 @@ var browserStreamSession = (options) => (options.client ?? client).sse.get({
35768
35952
  url: "/browser/v1/sessions/{sessionId}/stream",
35769
35953
  ...options
35770
35954
  });
35955
+ var browserStreamSessionFrames = (options) => (options.client ?? client).sse.get({
35956
+ security: [{
35957
+ key: "BrowserBearer",
35958
+ scheme: "bearer",
35959
+ type: "http"
35960
+ }],
35961
+ url: "/browser/v1/sessions/{sessionId}/frames",
35962
+ ...options
35963
+ });
35771
35964
  var browserSeleniumUnsupported = (options) => (options?.client ?? client).get({
35772
35965
  security: [{
35773
35966
  key: "BrowserBearer",
@@ -42060,6 +42253,38 @@ var getSandboxV1SandboxesBySandboxIdLogs = (options) => (options.client ?? clien
42060
42253
  url: "/sandbox/v1/sandboxes/{sandboxID}/logs",
42061
42254
  ...options
42062
42255
  });
42256
+ var getSandboxEvents = (options) => (options.client ?? client).get({
42257
+ security: [
42258
+ {
42259
+ key: "sandbox-ApiKeyAuth",
42260
+ name: "X-API-Key",
42261
+ type: "apiKey"
42262
+ },
42263
+ {
42264
+ key: "sandbox-AuthProviderBearerAuth",
42265
+ scheme: "bearer",
42266
+ type: "http"
42267
+ },
42268
+ {
42269
+ key: "sandbox-AuthProviderTeamAuth",
42270
+ name: "X-Team-ID",
42271
+ type: "apiKey"
42272
+ },
42273
+ { name: "X-Admin-Token", type: "apiKey" },
42274
+ {
42275
+ key: "sandbox-AdminTeamAuth",
42276
+ name: "X-Team-ID",
42277
+ type: "apiKey"
42278
+ },
42279
+ {
42280
+ key: "sandbox-AdminJWTAuth",
42281
+ scheme: "bearer",
42282
+ type: "http"
42283
+ }
42284
+ ],
42285
+ url: "/sandbox/v1/events/sandboxes/{sandboxID}",
42286
+ ...options
42287
+ });
42063
42288
  var startTemplateBuild = (options) => (options.client ?? client).post({
42064
42289
  security: [
42065
42290
  {
@@ -44187,6 +44412,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
44187
44412
  url: "/ticket/v1/repositories",
44188
44413
  ...options
44189
44414
  });
44415
+ var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
44416
+ security: [{
44417
+ key: "BearerAuth",
44418
+ scheme: "bearer",
44419
+ type: "http"
44420
+ }, {
44421
+ key: "ApiKeyAuth",
44422
+ name: "X-API-Key",
44423
+ type: "apiKey"
44424
+ }],
44425
+ url: "/ticket/v1/repositories/{id}",
44426
+ ...options
44427
+ });
44190
44428
 
44191
44429
  // ../../packages/sdk/typescript/src/core/pagination.ts
44192
44430
  class Page {
@@ -44634,6 +44872,7 @@ function createBrowser(transport) {
44634
44872
  events: {
44635
44873
  list: bind(transport, browserListEvents)
44636
44874
  },
44875
+ frames: bindStream(transport, browserStreamSessionFrames),
44637
44876
  handoff: {
44638
44877
  complete: bind(transport, browserCompleteHandoff),
44639
44878
  create: bind(transport, browserRequestHandoff)
@@ -44641,6 +44880,7 @@ function createBrowser(transport) {
44641
44880
  list: bind(transport, browserListSessions),
44642
44881
  retrieve: bind(transport, browserGetSession),
44643
44882
  retrieveDebug: bind(transport, browserGetDebug),
44883
+ retrieveFrame: bind(transport, browserGetSessionFrame),
44644
44884
  stream: bindStream(transport, browserStreamSession),
44645
44885
  update: bind(transport, browserCloseSession),
44646
44886
  viewer: {
@@ -45256,6 +45496,11 @@ function createOrganization(transport) {
45256
45496
  }
45257
45497
  function createSandbox(transport) {
45258
45498
  return {
45499
+ events: {
45500
+ sandboxes: {
45501
+ retrieve: bind(transport, getSandboxEvents)
45502
+ }
45503
+ },
45259
45504
  sandboxes: {
45260
45505
  commands: {
45261
45506
  run: bind(transport, runSandboxCommand)
@@ -45480,7 +45725,8 @@ function createTicket(transport) {
45480
45725
  update: bind(transport, ticketPatchMilestonesNumber)
45481
45726
  },
45482
45727
  repositories: {
45483
- list: bind(transport, ticketGetRepositories)
45728
+ list: bind(transport, ticketGetRepositories),
45729
+ update: bind(transport, ticketPatchRepositoriesId)
45484
45730
  },
45485
45731
  tickets: {
45486
45732
  comments: {
@@ -48176,8 +48422,33 @@ Enter code: ${code.user_code}` });
48176
48422
  if (ports.json)
48177
48423
  ports.emit({ kind: "object", data: { env: config.env, ...shadowedBy ? { shadowed_by: shadowedBy } : {} } });
48178
48424
  }
48425
+ function jwtClaims(token) {
48426
+ const part = token.split(".")[1];
48427
+ if (!part)
48428
+ return null;
48429
+ try {
48430
+ const claims = JSON.parse(Buffer.from(part, "base64url").toString("utf8"));
48431
+ return claims && typeof claims === "object" ? claims : null;
48432
+ } catch {
48433
+ return null;
48434
+ }
48435
+ }
48179
48436
  async function whoami(auth, env, org) {
48180
48437
  const credential = await auth.get(org);
48438
+ if (credential.source === "machine-token" || credential.source === "managed-login") {
48439
+ const claims = jwtClaims(credential.token);
48440
+ const exp = typeof claims?.exp === "number" ? claims.exp * 1000 : credential.expiresAt;
48441
+ const str = (v) => typeof v === "string" && v ? v : null;
48442
+ return {
48443
+ subject: str(claims?.sub),
48444
+ organization: str(claims?.org) ?? credential.organizationId ?? null,
48445
+ env,
48446
+ source: credential.source,
48447
+ ...credential.storedIn ? { "stored in": credential.storedIn } : {},
48448
+ expires_at: exp ? new Date(exp).toISOString() : null,
48449
+ note: credential.source === "machine-token" ? "The machine token determines the organization." : "The managed login determines the organization; the platform renews it."
48450
+ };
48451
+ }
48181
48452
  const me = await auth.rpc("identity.me.get", {}, org);
48182
48453
  return {
48183
48454
  email: me.user.email,
@@ -48186,7 +48457,7 @@ async function whoami(auth, env, org) {
48186
48457
  source: credential.source,
48187
48458
  ...credential.storedIn ? { "stored in": credential.storedIn } : {},
48188
48459
  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." } : {}
48460
+ ...credential.source === "api-key" ? { note: "The API key determines the organization." } : {}
48190
48461
  };
48191
48462
  }
48192
48463
 
@@ -49741,6 +50012,251 @@ function retop(store, id, top, rev) {
49741
50012
  retop(store, c, top, rev);
49742
50013
  }
49743
50014
  }
50015
+ // ../../packages/canvas/document/src/connector.ts
50016
+ var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
50017
+ var ARROWS = ["end", "start", "both", "none"];
50018
+ var ROUTES = ["straight", "elbow"];
50019
+ var ARROW_LENGTH_FACTOR = 6;
50020
+ var ARROW_HALF_ANGLE_DEG = 25;
50021
+ var EPSILON = 0.000000001;
50022
+ function centerOf(box) {
50023
+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
50024
+ }
50025
+ function inside(p, box) {
50026
+ return p.x > box.x && p.x < box.x + box.width && p.y > box.y && p.y < box.y + box.height;
50027
+ }
50028
+ function magnetPoint(box, magnet) {
50029
+ const c = centerOf(box);
50030
+ switch (magnet) {
50031
+ case "center":
50032
+ return c;
50033
+ case "top":
50034
+ return { x: c.x, y: box.y };
50035
+ case "bottom":
50036
+ return { x: c.x, y: box.y + box.height };
50037
+ case "left":
50038
+ return { x: box.x, y: c.y };
50039
+ case "right":
50040
+ return { x: box.x + box.width, y: c.y };
50041
+ }
50042
+ }
50043
+ function intersectBorder(box, shape, cornerRadius, toward) {
50044
+ const c = centerOf(box);
50045
+ const dx = toward.x - c.x;
50046
+ const dy = toward.y - c.y;
50047
+ if (dx === 0 && dy === 0)
50048
+ return c;
50049
+ const hw = box.width / 2;
50050
+ const hh = box.height / 2;
50051
+ if (hw <= 0 || hh <= 0)
50052
+ return c;
50053
+ if (shape === "ellipse") {
50054
+ const t2 = 1 / Math.hypot(dx / hw, dy / hh);
50055
+ return { x: c.x + dx * t2, y: c.y + dy * t2 };
50056
+ }
50057
+ const r = Math.max(0, Math.min(cornerRadius, Math.min(hw, hh)));
50058
+ const a = hw - r;
50059
+ const b = hh - r;
50060
+ let t = Infinity;
50061
+ if (dx !== 0) {
50062
+ const candidate = (a + r) / Math.abs(dx);
50063
+ if (Math.abs(dy) * candidate <= b + EPSILON)
50064
+ t = Math.min(t, candidate);
50065
+ }
50066
+ if (dy !== 0) {
50067
+ const candidate = (b + r) / Math.abs(dy);
50068
+ if (Math.abs(dx) * candidate <= a + EPSILON)
50069
+ t = Math.min(t, candidate);
50070
+ }
50071
+ if (!Number.isFinite(t)) {
50072
+ const ex = Math.sign(dx) * a;
50073
+ const ey = Math.sign(dy) * b;
50074
+ const qa = dx * dx + dy * dy;
50075
+ const qb = -2 * (dx * ex + dy * ey);
50076
+ const qc = ex * ex + ey * ey - r * r;
50077
+ const disc = Math.max(0, qb * qb - 4 * qa * qc);
50078
+ t = (-qb + Math.sqrt(disc)) / (2 * qa);
50079
+ }
50080
+ return { x: c.x + dx * t, y: c.y + dy * t };
50081
+ }
50082
+ function endPoint(end, magnet, toward) {
50083
+ if (magnet === "center")
50084
+ return centerOf(end.box);
50085
+ if (magnet === "auto")
50086
+ return intersectBorder(end.box, end.shape, end.cornerRadius, toward);
50087
+ return magnetPoint(end.box, magnet);
50088
+ }
50089
+ function arrowHead(tip, into, strokeWidth) {
50090
+ const length = strokeWidth * ARROW_LENGTH_FACTOR;
50091
+ const half = Math.tan(ARROW_HALF_ANGLE_DEG * Math.PI / 180) * length;
50092
+ const baseX = tip.x + into.x * length;
50093
+ const baseY = tip.y + into.y * length;
50094
+ const px = -into.y;
50095
+ const py = into.x;
50096
+ return {
50097
+ tip,
50098
+ left: { x: baseX + px * half, y: baseY + py * half },
50099
+ right: { x: baseX - px * half, y: baseY - py * half }
50100
+ };
50101
+ }
50102
+ function normalize(p) {
50103
+ const l = Math.hypot(p.x, p.y);
50104
+ return { x: p.x / l, y: p.y / l };
50105
+ }
50106
+ function rectsOverlap(a, b) {
50107
+ 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;
50108
+ }
50109
+ function segmentCrossesBox(a, b, box) {
50110
+ const shrink = 0.000001;
50111
+ const dx = b.x - a.x;
50112
+ const dy = b.y - a.y;
50113
+ let t0 = 0;
50114
+ let t1 = 1;
50115
+ const slab = (start, delta, min, max) => {
50116
+ if (Math.abs(delta) < 0.000000000001)
50117
+ return start > min && start < max;
50118
+ const ta = (min - start) / delta;
50119
+ const tb = (max - start) / delta;
50120
+ t0 = Math.max(t0, Math.min(ta, tb));
50121
+ t1 = Math.min(t1, Math.max(ta, tb));
50122
+ return t0 <= t1;
50123
+ };
50124
+ if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
50125
+ return false;
50126
+ if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
50127
+ return false;
50128
+ return t1 > t0;
50129
+ }
50130
+ function dashRanges(length, dash) {
50131
+ const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
50132
+ if (!pattern.length)
50133
+ return [[0, length]];
50134
+ const cycle = pattern.length % 2 ? [...pattern, ...pattern] : pattern;
50135
+ const out = [];
50136
+ let pos = 0;
50137
+ for (let i = 0;pos < length; i += 2) {
50138
+ const on = cycle[i % cycle.length];
50139
+ const off = cycle[(i + 1) % cycle.length];
50140
+ const end = Math.min(pos + on, length);
50141
+ if (end > pos)
50142
+ out.push([pos, end]);
50143
+ pos = end + off;
50144
+ }
50145
+ return out;
50146
+ }
50147
+ function n(value) {
50148
+ const rounded = Math.round(value * 100) / 100;
50149
+ return String(Object.is(rounded, -0) ? 0 : rounded);
50150
+ }
50151
+ var isHorizontal = (side) => side === "left" || side === "right";
50152
+ function elbowPath(from, to, fromMagnet, toMagnet) {
50153
+ if (fromMagnet === "center" || toMagnet === "center")
50154
+ throw new OpRejectedError({
50155
+ code: "INVALID_VALUE",
50156
+ property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
50157
+ reason: "elbow routing needs an edge, not the centre"
50158
+ });
50159
+ const dx = centerOf(to.box).x - centerOf(from.box).x;
50160
+ const dy = centerOf(to.box).y - centerOf(from.box).y;
50161
+ const across = Math.abs(dx) > Math.abs(dy);
50162
+ const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
50163
+ const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
50164
+ const p1 = magnetPoint(from.box, fromSide);
50165
+ const p2 = magnetPoint(to.box, toSide);
50166
+ const out = [p1];
50167
+ if (isHorizontal(fromSide) === isHorizontal(toSide)) {
50168
+ if (isHorizontal(fromSide)) {
50169
+ const midX = (p1.x + p2.x) / 2;
50170
+ out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
50171
+ } else {
50172
+ const midY = (p1.y + p2.y) / 2;
50173
+ out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
50174
+ }
50175
+ } else {
50176
+ out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
50177
+ }
50178
+ out.push(p2);
50179
+ const kept = [];
50180
+ for (const p of out) {
50181
+ const last = kept[kept.length - 1];
50182
+ if (last && last.x === p.x && last.y === p.y)
50183
+ continue;
50184
+ if (last && kept.length >= 2) {
50185
+ const before = kept[kept.length - 2];
50186
+ if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
50187
+ kept.pop();
50188
+ }
50189
+ kept.push(p);
50190
+ }
50191
+ return kept;
50192
+ }
50193
+ function cumulative(points) {
50194
+ const cum = [0];
50195
+ for (let i = 1;i < points.length; i++)
50196
+ cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
50197
+ return cum;
50198
+ }
50199
+ function pointAt(points, cum, s) {
50200
+ const total = cum[cum.length - 1];
50201
+ const at = Math.max(0, Math.min(s, total));
50202
+ let i = 0;
50203
+ while (i < points.length - 2 && cum[i + 1] < at)
50204
+ i++;
50205
+ const span = cum[i + 1] - cum[i];
50206
+ const f = span < EPSILON ? 0 : (at - cum[i]) / span;
50207
+ const a = points[i];
50208
+ const b = points[i + 1];
50209
+ return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
50210
+ }
50211
+ function connectorGeometry(from, to, opts = {}) {
50212
+ const arrow = opts.arrow ?? "end";
50213
+ const strokeWidth = opts.strokeWidth ?? 1.5;
50214
+ const labelPos = opts.labelPos ?? 0.5;
50215
+ const fromMagnet = opts.fromMagnet ?? "auto";
50216
+ const toMagnet = opts.toMagnet ?? "auto";
50217
+ if (rectsOverlap(from.box, to.box))
50218
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50219
+ const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
50220
+ const cum = cumulative(points);
50221
+ const length = cum[cum.length - 1];
50222
+ const p1 = points[0];
50223
+ const p2 = points[points.length - 1];
50224
+ if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
50225
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
50226
+ const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
50227
+ const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
50228
+ const back = { x: -dir2.x, y: -dir2.y };
50229
+ const arrowHeads = [];
50230
+ if (arrow === "end" || arrow === "both")
50231
+ arrowHeads.push(arrowHead(p2, back, strokeWidth));
50232
+ if (arrow === "start" || arrow === "both")
50233
+ arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
50234
+ const xs = points.map((p) => p.x);
50235
+ const ys = points.map((p) => p.y);
50236
+ for (const head of arrowHeads) {
50237
+ xs.push(head.tip.x, head.left.x, head.right.x);
50238
+ ys.push(head.tip.y, head.left.y, head.right.y);
50239
+ }
50240
+ const bbox = { x: Math.min(...xs), y: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) };
50241
+ const local = (p) => ({ x: p.x - bbox.x, y: p.y - bbox.y });
50242
+ const parts = [];
50243
+ for (const [start, end] of dashRanges(length, opts.dash)) {
50244
+ const run = [pointAt(points, cum, start)];
50245
+ for (let i = 1;i < points.length - 1; i++)
50246
+ if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
50247
+ run.push(points[i]);
50248
+ run.push(pointAt(points, cum, end));
50249
+ const traced = run.length > 2 ? [...run, ...run.slice(0, -1).reverse()] : run;
50250
+ parts.push(traced.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
50251
+ }
50252
+ for (const head of arrowHeads) {
50253
+ const t = local(head.tip);
50254
+ const l = local(head.left);
50255
+ const r = local(head.right);
50256
+ parts.push(`M${n(t.x)} ${n(t.y)}L${n(l.x)} ${n(l.y)}L${n(r.x)} ${n(r.y)}Z`);
50257
+ }
50258
+ return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
50259
+ }
49744
50260
  // ../../packages/canvas/document/src/expand.ts
49745
50261
  function defaultTheme(themes) {
49746
50262
  const t = {};
@@ -49895,7 +50411,8 @@ var KNOWN_PROPS = {
49895
50411
  context: keys(`${SIZE} ${TEXT} content`),
49896
50412
  icon: keys(`${SIZE} ${EFFECTS} library icon weight fill`),
49897
50413
  script: keys(`${SIZE} clip scriptUri inputs`),
49898
- browser: keys(`${SIZE} ${EFFECTS} ${STROKE} url deviceId zoom scrollX scrollY cornerRadius`),
50414
+ browser: keys(`${SIZE} ${GRAPHICS} url deviceId zoom scrollX scrollY cornerRadius`),
50415
+ html: keys(`${SIZE} ${GRAPHICS} html cornerRadius`),
49899
50416
  ref: keys("ref descendants")
49900
50417
  };
49901
50418
  function unknownProperties(node2, type) {
@@ -49996,23 +50513,613 @@ function pathLineBounds(geometry) {
49996
50513
  return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
49997
50514
  }
49998
50515
 
50516
+ // ../../packages/canvas/document/src/live-node.ts
50517
+ var HTML_MAX_BYTES = 256 * 1024;
50518
+ var drawsNothing = (value) => value === undefined || value === null || typeof value === "number" && !(value > 0);
50519
+ function checkLiveNode(node2) {
50520
+ const warnings = [];
50521
+ if (!node2 || typeof node2 !== "object" || node2.type !== "html")
50522
+ return { warnings };
50523
+ const html = node2.html;
50524
+ if (typeof html !== "string")
50525
+ return { reject: { property: "html", reason: "html must be a string" }, warnings };
50526
+ const bytes = new TextEncoder().encode(html).length;
50527
+ if (bytes > HTML_MAX_BYTES)
50528
+ return {
50529
+ reject: { property: "html", reason: `html is ${bytes} bytes of UTF-8; the limit is ${HTML_MAX_BYTES}` },
50530
+ warnings
50531
+ };
50532
+ if (drawsNothing(node2.width) || drawsNothing(node2.height))
50533
+ warnings.push({ code: "HTML_NODE_NO_SIZE", message: "html node has no width and height: set both, or it paints at zero size" });
50534
+ return { warnings };
50535
+ }
50536
+
50537
+ // ../../packages/canvas/document/src/kit.ts
50538
+ function kitStampOf(node2) {
50539
+ const meta = node2?.metadata;
50540
+ const stamp = meta?.kit;
50541
+ if (!stamp || typeof stamp.key !== "string" || typeof stamp.version !== "number" || typeof stamp.name !== "string")
50542
+ return;
50543
+ return { name: stamp.name, version: stamp.version, key: stamp.key };
50544
+ }
50545
+ function remapRefs(node2, refId) {
50546
+ const { children, ...rest } = node2;
50547
+ const out = { ...rest };
50548
+ if (typeof out.ref === "string")
50549
+ out.ref = refId.get(out.ref) ?? out.ref;
50550
+ const descendants = out.descendants;
50551
+ if (descendants && typeof descendants === "object" && !Array.isArray(descendants)) {
50552
+ const mapped = {};
50553
+ for (const [path, value] of Object.entries(descendants)) {
50554
+ const rewritten = path.split("/").map((seg) => refId.get(seg) ?? seg).join("/");
50555
+ mapped[rewritten] = value;
50556
+ }
50557
+ out.descendants = mapped;
50558
+ }
50559
+ if (Array.isArray(children))
50560
+ out.children = children.map((c) => remapRefs(c, refId));
50561
+ return out;
50562
+ }
50563
+ function planKit(existing, kit) {
50564
+ const canvasId = new Map;
50565
+ const haveVersion = new Map;
50566
+ for (const node2 of existing) {
50567
+ if (canvasId.has(node2.key))
50568
+ continue;
50569
+ canvasId.set(node2.key, node2.id);
50570
+ haveVersion.set(node2.key, node2.version);
50571
+ }
50572
+ const refId = new Map;
50573
+ const keys2 = new Set;
50574
+ for (const component of kit.components) {
50575
+ const stamp = kitStampOf(component);
50576
+ if (!stamp)
50577
+ throw new Error(`kit ${kit.name}: component ${component.id} carries no metadata.kit stamp`);
50578
+ if (keys2.has(stamp.key))
50579
+ throw new Error(`kit ${kit.name}: duplicate component key ${stamp.key}`);
50580
+ keys2.add(stamp.key);
50581
+ refId.set(component.id, canvasId.get(stamp.key) ?? component.id);
50582
+ }
50583
+ const plan = { add: [], update: [], unchanged: 0, variables: Object.keys(kit.variables).length };
50584
+ for (const component of kit.components) {
50585
+ const stamp = kitStampOf(component);
50586
+ const id = refId.get(component.id);
50587
+ const node2 = id === component.id ? remapRefs(component, refId) : { ...remapRefs(component, refId), id };
50588
+ const version = haveVersion.get(stamp.key);
50589
+ if (version === undefined)
50590
+ plan.add.push(node2);
50591
+ else if (version >= kit.version)
50592
+ plan.unchanged++;
50593
+ else
50594
+ plan.update.push({ id, node: node2 });
50595
+ }
50596
+ return plan;
50597
+ }
50598
+ function existingKitNodesIn(store, kitName) {
50599
+ const out = [];
50600
+ const walk = (id) => {
50601
+ const row = store.get(id);
50602
+ if (!row)
50603
+ return;
50604
+ const stamp = kitStampOf(row.props);
50605
+ if (stamp && (kitName === undefined || stamp.name === kitName))
50606
+ out.push({ key: stamp.key, version: stamp.version, id });
50607
+ for (const child of store.children(id))
50608
+ walk(child);
50609
+ };
50610
+ for (const top of store.children(null))
50611
+ walk(top);
50612
+ return out;
50613
+ }
50614
+ function kitFrameIn(store, frame) {
50615
+ return store.children(null).find((id) => {
50616
+ const props = store.get(id)?.props;
50617
+ return props?.type === "frame" && props.name === frame;
50618
+ });
50619
+ }
50620
+ var componentName = (node2) => {
50621
+ const name = node2.name;
50622
+ return typeof name === "string" && name !== "" ? name : kitStampOf(node2).key;
50623
+ };
50624
+ function kitPlanNames(plan) {
50625
+ return { added: plan.add.map(componentName), updated: plan.update.map((u) => componentName(u.node)) };
50626
+ }
50627
+ function planRefs(plan) {
50628
+ const ids = new Set;
50629
+ const refs = [];
50630
+ const visit2 = (node2, collectIds) => {
50631
+ if (collectIds)
50632
+ ids.add(node2.id);
50633
+ if (node2.type === "ref" && typeof node2.ref === "string")
50634
+ refs.push(node2.ref);
50635
+ for (const child of Array.isArray(node2.children) ? node2.children : [])
50636
+ visit2(child, collectIds);
50637
+ };
50638
+ for (const node2 of plan.add)
50639
+ visit2(node2, true);
50640
+ for (const entry of plan.update)
50641
+ visit2(entry.node, false);
50642
+ return { refs, ids };
50643
+ }
50644
+
50645
+ // ../../packages/canvas/document/src/kit-builders.ts
50646
+ var PRAXIS_UI_LITERALS = {
50647
+ "v3-surface-2": "#F1F3F2",
50648
+ "v3-border": "#E3E7E4",
50649
+ "v3-border-strong": "#CDD3CF",
50650
+ "v3-fg": "#0D1310",
50651
+ "v3-fg-2": "#4A5550",
50652
+ "v3-fg-3": "#6E7872",
50653
+ "v3-green-50": "#EEFBF3",
50654
+ "v3-green-700": "#167A43",
50655
+ "v3-code-bg": "#0F1512",
50656
+ "v3-code-fg": "#D6E2DB",
50657
+ "v3-danger": "#D92D20",
50658
+ "v3-danger-soft": "#FEF0EE",
50659
+ "v3-warning": "#C76A00",
50660
+ "v3-warning-soft": "#FFF6E5",
50661
+ "v3-info": "#2563EB",
50662
+ "v3-info-soft": "#EEF4FF",
50663
+ "v3-font": "Geist",
50664
+ "v3-mono": "Geist Mono",
50665
+ "r-md": 8
50666
+ };
50667
+ function token(ctx, name) {
50668
+ return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
50669
+ }
50670
+ var KIT_LIMITS = {
50671
+ tableRows: 200,
50672
+ codeLines: 200,
50673
+ keyWidth: 240,
50674
+ minColumn: 24
50675
+ };
50676
+ var COLUMN_GAP = 12;
50677
+ var ROW_PADDING = 10;
50678
+ var BODY_SIZE = 13;
50679
+ var HEADER_SIZE = 12;
50680
+ function invalid(property, reason) {
50681
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
50682
+ }
50683
+ function optionKeys(value, allowed, name) {
50684
+ if (value === undefined || value === null)
50685
+ return {};
50686
+ if (typeof value !== "object" || Array.isArray(value))
50687
+ return invalid(name, "expected an options object");
50688
+ for (const key of Object.keys(value))
50689
+ if (!allowed.includes(key))
50690
+ return invalid(key, `${name} does not take ${key}`);
50691
+ return value;
50692
+ }
50693
+ function requiredString(value, property) {
50694
+ if (typeof value !== "string" || value === "")
50695
+ return invalid(property, "expected a non-empty string");
50696
+ return value;
50697
+ }
50698
+ function optionalString(value, property) {
50699
+ if (value === undefined || value === null)
50700
+ return;
50701
+ return requiredString(value, property);
50702
+ }
50703
+ function containerWidth(value, property) {
50704
+ if (value === undefined || value === null || value === "fill_container")
50705
+ return "fill_container";
50706
+ if (typeof value === "number" && Number.isFinite(value) && value > 0)
50707
+ return value;
50708
+ return invalid(property, 'expected a positive number or "fill_container"');
50709
+ }
50710
+ var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
50711
+ var COLUMN_KEYS = ["key", "title", "width", "align"];
50712
+ var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
50713
+ function planColumns(columns, total, gap = COLUMN_GAP) {
50714
+ const fills = columns.filter((c) => typeof c.width !== "number").length;
50715
+ if (total === null)
50716
+ return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
50717
+ const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
50718
+ const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
50719
+ const leftover = available - pinned;
50720
+ if (leftover > 0) {
50721
+ if (!fills)
50722
+ return columns.map((c) => c.width);
50723
+ const share = round2(leftover / fills);
50724
+ return columns.map((c) => typeof c.width === "number" ? c.width : share);
50725
+ }
50726
+ const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
50727
+ const scale = requested > 0 ? available / requested : 1;
50728
+ return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
50729
+ }
50730
+ var round2 = (n2) => Math.round(n2 * 100) / 100;
50731
+ function cellRow(name, cells) {
50732
+ return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
50733
+ }
50734
+ function planTable(options, ctx) {
50735
+ const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
50736
+ if (!Array.isArray(o.columns) || o.columns.length === 0)
50737
+ invalid("columns", "expected a non-empty array of { key, title }");
50738
+ const rows = o.rows;
50739
+ if (!Array.isArray(rows))
50740
+ invalid("rows", "expected an array of row objects");
50741
+ if (rows.length > KIT_LIMITS.tableRows)
50742
+ invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
50743
+ const columns = o.columns.map((raw, i) => {
50744
+ const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
50745
+ const width2 = c.width;
50746
+ if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
50747
+ invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
50748
+ const align = c.align;
50749
+ if (align !== undefined && align !== null && align !== "left" && align !== "right")
50750
+ invalid(`columns[${i}].align`, 'expected "left" or "right"');
50751
+ return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
50752
+ });
50753
+ const width = containerWidth(o.width, "width");
50754
+ const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
50755
+ const font = token(ctx, "v3-font");
50756
+ const headerCell = (title, w, align) => ({
50757
+ type: "text",
50758
+ name: title,
50759
+ content: title,
50760
+ width: w,
50761
+ textGrowth: "fixed-width",
50762
+ fontFamily: font,
50763
+ fontSize: HEADER_SIZE,
50764
+ fontWeight: 600,
50765
+ fill: token(ctx, "v3-fg-2"),
50766
+ ...align === "right" ? { textAlign: "right" } : {}
50767
+ });
50768
+ const dataCell = (title, content, w, align) => ({
50769
+ type: "text",
50770
+ name: title,
50771
+ content,
50772
+ width: w,
50773
+ textGrowth: "fixed-width",
50774
+ fontFamily: font,
50775
+ fontSize: BODY_SIZE,
50776
+ fill: token(ctx, "v3-fg"),
50777
+ ...align === "right" ? { textAlign: "right" } : {}
50778
+ });
50779
+ const children = [
50780
+ {
50781
+ type: "frame",
50782
+ name: "Header",
50783
+ layout: "vertical",
50784
+ gap: 0,
50785
+ width: "fill_container",
50786
+ stroke: token(ctx, "v3-border-strong"),
50787
+ strokeWidth: { bottom: 1 },
50788
+ strokeAlignment: "inner",
50789
+ children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
50790
+ }
50791
+ ];
50792
+ rows.forEach((row, i) => {
50793
+ const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
50794
+ children.push({
50795
+ type: "frame",
50796
+ name: "Row",
50797
+ layout: "vertical",
50798
+ gap: 0,
50799
+ width: "fill_container",
50800
+ stroke: token(ctx, "v3-border"),
50801
+ strokeWidth: { bottom: 1 },
50802
+ strokeAlignment: "inner",
50803
+ ...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
50804
+ children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
50805
+ });
50806
+ });
50807
+ return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
50808
+ }
50809
+ function textOf(value) {
50810
+ if (value === undefined || value === null)
50811
+ return "";
50812
+ return typeof value === "string" ? value : String(value);
50813
+ }
50814
+ function requiredText(value, property) {
50815
+ if (typeof value !== "string" && typeof value !== "number")
50816
+ return invalid(property, "expected a string or number");
50817
+ return String(value);
50818
+ }
50819
+ var CALLOUT_KEYS = ["tone", "title", "body"];
50820
+ var CALLOUT_TONES = {
50821
+ info: { soft: "v3-info-soft", ink: "v3-info" },
50822
+ success: { soft: "v3-green-50", ink: "v3-green-700" },
50823
+ warning: { soft: "v3-warning-soft", ink: "v3-warning" },
50824
+ danger: { soft: "v3-danger-soft", ink: "v3-danger" }
50825
+ };
50826
+ function planCallout(options, ctx) {
50827
+ const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
50828
+ const tone = o.tone;
50829
+ if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
50830
+ invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
50831
+ const body = requiredString(o.body, "body");
50832
+ const title = optionalString(o.title, "title");
50833
+ const pair = CALLOUT_TONES[tone];
50834
+ const font = token(ctx, "v3-font");
50835
+ const bodyChildren = [];
50836
+ if (title !== undefined)
50837
+ bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
50838
+ bodyChildren.push({
50839
+ type: "text",
50840
+ name: "Body",
50841
+ content: body,
50842
+ fontFamily: font,
50843
+ fontSize: BODY_SIZE,
50844
+ lineHeight: 1.5,
50845
+ width: "fill_container",
50846
+ textGrowth: "fixed-width",
50847
+ fill: token(ctx, "v3-fg")
50848
+ });
50849
+ return {
50850
+ type: "frame",
50851
+ name: "Callout",
50852
+ layout: "horizontal",
50853
+ gap: 0,
50854
+ width: "fill_container",
50855
+ fill: token(ctx, pair.soft),
50856
+ cornerRadius: token(ctx, "r-md"),
50857
+ clip: true,
50858
+ children: [
50859
+ { type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
50860
+ { type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
50861
+ ]
50862
+ };
50863
+ }
50864
+ var CODE_KEYS = ["lang", "text"];
50865
+ function planCode(options, ctx) {
50866
+ const o = optionKeys(options, CODE_KEYS, "Kit.Code");
50867
+ const lang = optionalString(o.lang, "lang");
50868
+ const text = requiredString(o.text, "text");
50869
+ const lines = text.split(`
50870
+ `);
50871
+ const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
50872
+ const children = [];
50873
+ if (lang !== undefined)
50874
+ children.push({
50875
+ type: "text",
50876
+ name: "Lang",
50877
+ content: lang,
50878
+ width: "fill_container",
50879
+ textGrowth: "fixed-width",
50880
+ textAlign: "right",
50881
+ fontFamily: token(ctx, "v3-mono"),
50882
+ fontSize: 11,
50883
+ fill: token(ctx, "v3-fg-3")
50884
+ });
50885
+ children.push({
50886
+ type: "text",
50887
+ name: "Lines",
50888
+ content: shown.join(`
50889
+ `),
50890
+ fontFamily: token(ctx, "v3-mono"),
50891
+ fontSize: 12,
50892
+ lineHeight: 1.5,
50893
+ width: "fill_container",
50894
+ textGrowth: "fixed-width",
50895
+ fill: token(ctx, "v3-code-fg")
50896
+ });
50897
+ return {
50898
+ type: "frame",
50899
+ name: "Code",
50900
+ layout: "vertical",
50901
+ gap: 6,
50902
+ width: "fill_container",
50903
+ fill: token(ctx, "v3-code-bg"),
50904
+ cornerRadius: token(ctx, "r-md"),
50905
+ padding: 12,
50906
+ clip: true,
50907
+ children
50908
+ };
50909
+ }
50910
+ function indexed(index) {
50911
+ return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
50912
+ }
50913
+ var SECTION_KEYS = ["index", "title", "subtitle"];
50914
+ function planSection(options, ctx) {
50915
+ const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
50916
+ const title = requiredString(o.title, "title");
50917
+ const subtitle = optionalString(o.subtitle, "subtitle");
50918
+ const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
50919
+ if (index !== undefined && index === "")
50920
+ invalid("index", "expected a non-empty string or number");
50921
+ const font = token(ctx, "v3-font");
50922
+ const heading = {
50923
+ type: "frame",
50924
+ name: "Heading",
50925
+ layout: "horizontal",
50926
+ gap: 8,
50927
+ alignItems: "center",
50928
+ width: "fill_container",
50929
+ children: [
50930
+ ...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
50931
+ { type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50932
+ ]
50933
+ };
50934
+ const children = [heading];
50935
+ if (subtitle !== undefined)
50936
+ 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" });
50937
+ return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
50938
+ }
50939
+ function planKeyValue(rows, ctx) {
50940
+ if (!Array.isArray(rows) || rows.length === 0)
50941
+ invalid("rows", "expected a non-empty array of { key, value }");
50942
+ const font = token(ctx, "v3-font");
50943
+ const parsed = rows.map((raw, i) => {
50944
+ const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
50945
+ return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
50946
+ });
50947
+ const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
50948
+ const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
50949
+ return {
50950
+ type: "frame",
50951
+ name: "KeyValue",
50952
+ layout: "vertical",
50953
+ gap: 0,
50954
+ width: "fill_container",
50955
+ children: parsed.map((r) => ({
50956
+ type: "frame",
50957
+ name: "KeyValueRow",
50958
+ layout: "horizontal",
50959
+ gap: 12,
50960
+ padding: [6, 0],
50961
+ width: "fill_container",
50962
+ children: [
50963
+ { type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
50964
+ { type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
50965
+ ]
50966
+ }))
50967
+ };
50968
+ }
50969
+ var KIT_BUILDERS = {
50970
+ table: planTable,
50971
+ callout: planCallout,
50972
+ code: planCode,
50973
+ section: planSection,
50974
+ "key-value": planKeyValue
50975
+ };
50976
+ function planKitNode(kind, options, ctx) {
50977
+ const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
50978
+ if (!build)
50979
+ return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
50980
+ return build(options, ctx);
50981
+ }
50982
+
49999
50983
  // ../../packages/canvas/document/src/execute-api.ts
50000
- var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4 };
50984
+ var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
50985
+ var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
50986
+ function connectorMetaOf(props) {
50987
+ const meta = props?.metadata?.connector;
50988
+ if (!meta || typeof meta !== "object")
50989
+ return null;
50990
+ const m = meta;
50991
+ if (typeof m.from !== "string" || typeof m.to !== "string")
50992
+ return null;
50993
+ return {
50994
+ from: m.from,
50995
+ to: m.to,
50996
+ fromMagnet: m.fromMagnet ?? "auto",
50997
+ toMagnet: m.toMagnet ?? "auto",
50998
+ route: m.route ?? "straight",
50999
+ arrow: m.arrow ?? "end",
51000
+ labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
51001
+ ...Array.isArray(m.dash) ? { dash: m.dash } : {},
51002
+ ...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
51003
+ };
51004
+ }
51005
+ var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
51006
+ function invalid2(property, reason) {
51007
+ throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
51008
+ }
51009
+ function pickOption(value, allowed, property, fallback) {
51010
+ if (value === undefined || value === null)
51011
+ return fallback;
51012
+ if (typeof value === "string" && allowed.includes(value))
51013
+ return value;
51014
+ return invalid2(property, `expected one of ${allowed.join(", ")}`);
51015
+ }
51016
+ function numberOption(value, property, fallback, positive = false) {
51017
+ if (value === undefined || value === null)
51018
+ return fallback;
51019
+ if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
51020
+ return invalid2(property, positive ? "expected a positive number" : "expected a number");
51021
+ return value;
51022
+ }
51023
+ function optionKeys2(value, allowed, name) {
51024
+ if (value === undefined || value === null)
51025
+ return {};
51026
+ if (typeof value !== "object" || Array.isArray(value))
51027
+ return invalid2(name, "expected an options object");
51028
+ for (const key of Object.keys(value))
51029
+ if (!allowed.has(key))
51030
+ return invalid2(key, `${name} does not take ${key}`);
51031
+ return value;
51032
+ }
51033
+ function dashOption(value) {
51034
+ if (value === undefined || value === null)
51035
+ return;
51036
+ if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
51037
+ invalid2("dash", "expected an array of positive numbers");
51038
+ return value;
51039
+ }
51040
+ var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
51041
+ var VECTORIZE_MODES = ["auto", "mono", "flat"];
51042
+ var VECTORIZE_KEYS = new Set(["mode", "maxColors", "allowComplex"]);
51043
+ var KIT_FRAME_GAP = 24;
51044
+ var KIT_FRAME_PADDING = 24;
50001
51045
  var ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
51046
+ function undeclared(node2, key) {
51047
+ return node2[key] === undefined || node2[key] === null;
51048
+ }
51049
+ var TEXT_DEFAULT_KEYS = ["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "fill"];
51050
+ var TEXT_DEFAULTS_BYTES = 4 * 1024;
51051
+ function normalizeDefaults(value) {
51052
+ const raw = value ?? {};
51053
+ const text = raw.text;
51054
+ if (!text || typeof text !== "object" || Array.isArray(text))
51055
+ return {};
51056
+ const out = {};
51057
+ for (const k of TEXT_DEFAULT_KEYS)
51058
+ if (!undeclared(text, k))
51059
+ out[k] = text[k];
51060
+ if (!Object.keys(out).length)
51061
+ return {};
51062
+ if (new TextEncoder().encode(JSON.stringify(out)).byteLength > TEXT_DEFAULTS_BYTES)
51063
+ return {};
51064
+ return { text: out };
51065
+ }
51066
+ function applyTextDefaults(node2, defaults) {
51067
+ const keys2 = defaults ? TEXT_DEFAULT_KEYS.filter((k) => !undeclared(defaults, k)) : [];
51068
+ let out = node2;
51069
+ if (keys2.length && node2.type === "text") {
51070
+ const filled = { ...node2 };
51071
+ for (const k of keys2)
51072
+ if (undeclared(filled, k))
51073
+ filled[k] = defaults[k];
51074
+ out = filled;
51075
+ }
51076
+ if (Array.isArray(out.children))
51077
+ out = { ...out, children: out.children.map((c) => applyTextDefaults(c, defaults)) };
51078
+ return out;
51079
+ }
50002
51080
  class ExecuteApi {
50003
51081
  store;
50004
51082
  rec;
50005
51083
  bounds;
50006
51084
  rev;
50007
51085
  random;
51086
+ measureText;
51087
+ kits;
50008
51088
  document = "document";
50009
51089
  layoutCache = new Map;
50010
- constructor(store, rec, bounds, rev, random = Math.random) {
51090
+ defaults = {};
51091
+ connectors = new Map;
51092
+ connectorsIndexed = false;
51093
+ constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
50011
51094
  this.store = store;
50012
51095
  this.rec = rec;
50013
51096
  this.bounds = bounds;
50014
51097
  this.rev = rev;
50015
51098
  this.random = random;
51099
+ this.measureText = measureText;
51100
+ this.kits = kits;
51101
+ }
51102
+ setDefaults(value) {
51103
+ const raw = value;
51104
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw))
51105
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "SetDefaults", reason: "expected { text: { … } } or { text: null }" });
51106
+ for (const key of Object.keys(raw))
51107
+ if (key !== "text")
51108
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: key, reason: "SetDefaults only accepts text" });
51109
+ const text = raw.text;
51110
+ if (text !== null && text !== undefined) {
51111
+ if (typeof text !== "object" || Array.isArray(text))
51112
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "text", reason: "expected an object of text properties" });
51113
+ for (const key of Object.keys(text))
51114
+ if (!TEXT_DEFAULT_KEYS.includes(key))
51115
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: `text.${key}`, reason: `not a default text property; use ${TEXT_DEFAULT_KEYS.join(", ")}` });
51116
+ if (new TextEncoder().encode(JSON.stringify(text)).byteLength > TEXT_DEFAULTS_BYTES)
51117
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "text", reason: `defaults over ${TEXT_DEFAULTS_BYTES} bytes` });
51118
+ }
51119
+ return this.defaults = normalizeDefaults(value);
51120
+ }
51121
+ getDefaults() {
51122
+ return this.defaults;
50016
51123
  }
50017
51124
  mint() {
50018
51125
  for (;; ) {
@@ -50038,6 +51145,12 @@ class ExecuteApi {
50038
51145
  if (op.op === "setVariables")
50039
51146
  this.layoutCache.clear();
50040
51147
  }
51148
+ rowOf(path) {
51149
+ const row = this.store.get(path);
51150
+ if (!row)
51151
+ throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
51152
+ return row;
51153
+ }
50041
51154
  parentId(parent) {
50042
51155
  if (parent === "document" || parent === "" || parent == null)
50043
51156
  return null;
@@ -50069,6 +51182,9 @@ class ExecuteApi {
50069
51182
  if (typeof v === "string" && /%|vh|vw|calc/.test(v))
50070
51183
  throw new OpRejectedError({ code: "INVALID_VALUE", property: k, reason: "percentage and viewport sizes are not supported" });
50071
51184
  }
51185
+ const live = checkLiveNode(node2);
51186
+ if (live.reject)
51187
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: live.reject.property, reason: live.reject.reason });
50072
51188
  const id = this.mint();
50073
51189
  const out = { ...node2, id };
50074
51190
  if (typeof node2.name === "string") {
@@ -50082,11 +51198,18 @@ class ExecuteApi {
50082
51198
  }
50083
51199
  return out;
50084
51200
  }
50085
- warnProps(data, type, nodeId) {
51201
+ warnProps(data, type, nodeId, declared = false) {
50086
51202
  if (hasUnsupportedImageUrl(data) && this.rec.warnings.length < 20 && !this.rec.warnings.some((w) => w.code === "UNSUPPORTED_IMAGE_URL" && w.nodeId === nodeId))
50087
51203
  this.rec.warnings.push({ code: "UNSUPPORTED_IMAGE_URL", nodeId, message: "image fill url must be a file id (file-…)" });
51204
+ 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))
51205
+ 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
51206
  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
51207
  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)" });
51208
+ if (data.type === "html") {
51209
+ for (const w of checkLiveNode(data).warnings)
51210
+ if (this.rec.warnings.length < 20 && !this.rec.warnings.some((x) => x.code === w.code && x.nodeId === nodeId))
51211
+ this.rec.warnings.push({ code: w.code, nodeId, message: w.message });
51212
+ }
50090
51213
  for (const prop of unknownProperties(data, type)) {
50091
51214
  const message = `${prop} is not a .pen property`;
50092
51215
  if (this.rec.warnings.length >= 20)
@@ -50097,7 +51220,7 @@ class ExecuteApi {
50097
51220
  if (type === "path")
50098
51221
  this.warnPathBox(data, nodeId);
50099
51222
  for (const child of Array.isArray(data.children) ? data.children : [])
50100
- this.warnProps(child, child.type, child.id ?? nodeId);
51223
+ this.warnProps(child, child.type, child.id ?? nodeId, declared);
50101
51224
  if (data.descendants && typeof data.descendants === "object") {
50102
51225
  const descendants = typeof data.ref === "string" ? this.resolveDescendantKeys(data.ref, data.descendants) : data.descendants;
50103
51226
  for (const [key, value] of Object.entries(descendants)) {
@@ -50127,7 +51250,7 @@ class ExecuteApi {
50127
51250
  return;
50128
51251
  if (this.rec.warnings.length >= 20 || this.rec.warnings.some((w) => w.code === "PATH_BOX_MISMATCH" && w.nodeId === nodeId))
50129
51252
  return;
50130
- const round = (n) => Number(n.toFixed(2));
51253
+ const round = (n2) => Number(n2.toFixed(2));
50131
51254
  this.rec.warnings.push({
50132
51255
  code: "PATH_BOX_MISMATCH",
50133
51256
  nodeId,
@@ -50144,9 +51267,9 @@ class ExecuteApi {
50144
51267
  const byName = new Map;
50145
51268
  const walk = (id) => {
50146
51269
  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]);
51270
+ const n2 = this.store.get(c).props;
51271
+ if (n2.name)
51272
+ byName.set(n2.name, [...byName.get(n2.name) ?? [], c]);
50150
51273
  walk(c);
50151
51274
  }
50152
51275
  };
@@ -50165,10 +51288,10 @@ class ExecuteApi {
50165
51288
  }
50166
51289
  Insert(parent, nodeData) {
50167
51290
  const p = this.parentId(parent);
50168
- let node2 = this.withIds(migrateLegacyProps(nodeData));
51291
+ let node2 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
50169
51292
  if (node2.type === "ref" && node2.descendants && typeof node2.descendants === "object")
50170
51293
  node2 = { ...node2, descendants: this.resolveDescendantKeys(node2.ref, node2.descendants) };
50171
- this.warnProps(node2, node2.type, node2.id);
51294
+ this.warnProps(node2, node2.type, node2.id, true);
50172
51295
  this.commit({ op: "insert", parent: p, ord: between(this.lastOrd(p), null), node: node2 });
50173
51296
  return node2.id;
50174
51297
  }
@@ -50189,16 +51312,16 @@ class ExecuteApi {
50189
51312
  } else {
50190
51313
  const tree = subtree(this.store, src.id);
50191
51314
  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) };
51315
+ const apply = (n2) => {
51316
+ const d = descMap[n2.id];
51317
+ let out = d && typeof d.type === "string" ? { ...d } : { ...n2, ...d ?? {} };
51318
+ if (Array.isArray(n2.children) && !(d && typeof d.type === "string"))
51319
+ out = { ...out, children: n2.children.map(apply) };
50197
51320
  return out;
50198
51321
  };
50199
51322
  node2 = this.withIds({ ...apply(tree), ...over });
50200
51323
  }
50201
- this.warnProps(node2, node2.type, node2.id);
51324
+ this.warnProps(node2, node2.type, node2.id, true);
50202
51325
  this.commit({ op: "insert", parent: p, ord: between(this.lastOrd(p), null), node: node2 });
50203
51326
  return node2.id;
50204
51327
  }
@@ -50228,6 +51351,8 @@ class ExecuteApi {
50228
51351
  patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
50229
51352
  this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
50230
51353
  this.commit({ op: "update", id: row.id, patch });
51354
+ if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
51355
+ this.finalizeConnectors();
50231
51356
  }
50232
51357
  Replace(path, nodeData) {
50233
51358
  const inst = this.splitInstancePath(path);
@@ -50235,8 +51360,8 @@ class ExecuteApi {
50235
51360
  const owner = this.store.get(inst.owner);
50236
51361
  if (!owner || owner.props.type !== "ref")
50237
51362
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50238
- const node3 = this.withIds(migrateLegacyProps(nodeData));
50239
- this.warnProps(node3, node3.type, node3.id);
51363
+ const node3 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
51364
+ this.warnProps(node3, node3.type, node3.id, true);
50240
51365
  const desc = { ...owner.props.descendants ?? {}, [inst.rest]: node3 };
50241
51366
  this.commit({ op: "update", id: owner.id, patch: { descendants: desc } });
50242
51367
  return node3.id;
@@ -50244,8 +51369,8 @@ class ExecuteApi {
50244
51369
  const row = this.store.get(path);
50245
51370
  if (!row)
50246
51371
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50247
- const node2 = this.withIds(migrateLegacyProps(nodeData));
50248
- this.warnProps(node2, node2.type, node2.id);
51372
+ const node2 = this.withIds(applyTextDefaults(migrateLegacyProps(nodeData), this.defaults.text));
51373
+ this.warnProps(node2, node2.type, node2.id, true);
50249
51374
  this.commit({ op: "delete", id: row.id });
50250
51375
  this.commit({ op: "insert", parent: row.parent, ord: row.ord, node: node2 });
50251
51376
  return node2.id;
@@ -50265,6 +51390,7 @@ class ExecuteApi {
50265
51390
  const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
50266
51391
  const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
50267
51392
  this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
51393
+ this.finalizeConnectors();
50268
51394
  }
50269
51395
  Delete(path) {
50270
51396
  if (path === "document")
@@ -50274,6 +51400,14 @@ class ExecuteApi {
50274
51400
  if (!this.store.get(path))
50275
51401
  throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
50276
51402
  this.commit({ op: "delete", id: path });
51403
+ this.finalizeConnectors();
51404
+ }
51405
+ MoveToBack(path) {
51406
+ this.Move(path, undefined, 0);
51407
+ }
51408
+ MoveToFront(path) {
51409
+ const row = this.rowOf(path);
51410
+ this.Move(path, undefined, this.store.children(row.parent).length);
50277
51411
  }
50278
51412
  SetVariables(variables, replace = false) {
50279
51413
  const themes = {};
@@ -50394,9 +51528,9 @@ class ExecuteApi {
50394
51528
  if (!tree)
50395
51529
  return null;
50396
51530
  const index = new Map;
50397
- const walk = (n) => {
50398
- index.set(n.path, n);
50399
- n.children.forEach(walk);
51531
+ const walk = (n2) => {
51532
+ index.set(n2.path, n2);
51533
+ n2.children.forEach(walk);
50400
51534
  };
50401
51535
  walk(tree);
50402
51536
  hit = { rev: this.mutations, index };
@@ -50505,6 +51639,254 @@ class ExecuteApi {
50505
51639
  problems: p ? p.code === "FULLY_CLIPPED" ? "fully clipped" : "partially clipped" : undefined
50506
51640
  };
50507
51641
  }
51642
+ MeasureText(content, options) {
51643
+ if (typeof content !== "string")
51644
+ invalid2("content", "expected a string");
51645
+ if (!this.measureText)
51646
+ invalid2("MeasureText", "this host has no font set, so text cannot be measured");
51647
+ const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
51648
+ if (typeof o.fontFamily !== "string" || o.fontFamily === "")
51649
+ invalid2("fontFamily", "expected a font family name");
51650
+ if (o.fontSize === undefined || o.fontSize === null)
51651
+ invalid2("fontSize", "expected a positive number");
51652
+ return this.measureText({
51653
+ content,
51654
+ fontFamily: o.fontFamily,
51655
+ fontSize: numberOption(o.fontSize, "fontSize", 14, true),
51656
+ fontWeight: o.fontWeight,
51657
+ lineHeight: o.lineHeight === undefined || o.lineHeight === null ? undefined : numberOption(o.lineHeight, "lineHeight", 0, true),
51658
+ letterSpacing: o.letterSpacing === undefined || o.letterSpacing === null ? undefined : numberOption(o.letterSpacing, "letterSpacing", 0),
51659
+ width: o.width === undefined || o.width === null ? undefined : numberOption(o.width, "width", 0, true)
51660
+ });
51661
+ }
51662
+ absoluteBounds(path) {
51663
+ return this.absoluteOf(path) ?? { x: 0, y: 0, width: 0, height: 0 };
51664
+ }
51665
+ Connect(from, to, options) {
51666
+ if (typeof from !== "string" || typeof to !== "string")
51667
+ invalid2("from", "expected a node id");
51668
+ if (from === to)
51669
+ invalid2("to", "a node cannot be connected to itself");
51670
+ this.rowOf(from);
51671
+ this.rowOf(to);
51672
+ const o = optionKeys2(options, CONNECT_KEYS, "Connect");
51673
+ const route = pickOption(o.route, ROUTES, "route", "straight");
51674
+ const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
51675
+ const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
51676
+ const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
51677
+ const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
51678
+ if (labelPos < 0 || labelPos > 1)
51679
+ invalid2("labelPos", "expected a number between 0 and 1");
51680
+ const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
51681
+ const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
51682
+ if (typeof stroke !== "string")
51683
+ invalid2("stroke", "expected a colour string");
51684
+ const dash = dashOption(o.dash);
51685
+ const behind = o.behind === undefined || o.behind === null ? true : o.behind;
51686
+ if (typeof behind !== "boolean")
51687
+ invalid2("behind", "expected a boolean");
51688
+ const name = o.name === undefined || o.name === null ? "Connector" : o.name;
51689
+ if (typeof name !== "string")
51690
+ invalid2("name", "expected a string");
51691
+ if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
51692
+ invalid2("label", "expected a string");
51693
+ const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
51694
+ const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
51695
+ const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
51696
+ const target = parent ?? "document";
51697
+ const origin = this.originOf(parent);
51698
+ const absolute = this.inFlow(parent);
51699
+ const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
51700
+ let labelId;
51701
+ if (typeof o.label === "string" && o.label !== "") {
51702
+ const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
51703
+ const width = size.width + 8;
51704
+ const height = size.height + 4;
51705
+ labelId = this.Insert(target, {
51706
+ id: "",
51707
+ type: "frame",
51708
+ name: `${name}-label`,
51709
+ ...place({ x: geom.labelCenter.x - width / 2, y: geom.labelCenter.y - height / 2, width, height }),
51710
+ fill: "#FFFFFF",
51711
+ padding: [2, 4],
51712
+ layout: "none",
51713
+ children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
51714
+ });
51715
+ }
51716
+ const id = this.Insert(target, {
51717
+ id: "",
51718
+ type: "path",
51719
+ name,
51720
+ ...place(geom.bbox),
51721
+ viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
51722
+ geometry: geom.geometry,
51723
+ fill: stroke,
51724
+ stroke,
51725
+ strokeWidth,
51726
+ metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
51727
+ });
51728
+ this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
51729
+ if (behind)
51730
+ this.Move(id, target, 0);
51731
+ this.warnConnector(id, geom);
51732
+ return id;
51733
+ }
51734
+ finalizeConnectors() {
51735
+ if (!this.mutations)
51736
+ return;
51737
+ for (const id of this.knownConnectors())
51738
+ this.redrawConnector(id);
51739
+ }
51740
+ knownConnectors() {
51741
+ if (!this.connectorsIndexed) {
51742
+ this.connectorsIndexed = true;
51743
+ const walk = (parent) => {
51744
+ for (const id of this.store.children(parent)) {
51745
+ const props = this.store.get(id)?.props;
51746
+ if (!props)
51747
+ continue;
51748
+ const meta = connectorMetaOf(props);
51749
+ if (meta && !this.connectors.has(id))
51750
+ this.connectors.set(id, meta);
51751
+ walk(id);
51752
+ }
51753
+ };
51754
+ walk(null);
51755
+ }
51756
+ return [...this.connectors.keys()];
51757
+ }
51758
+ redrawConnector(id) {
51759
+ const row = this.store.get(id);
51760
+ const meta = row ? connectorMetaOf(row.props) : null;
51761
+ if (!row || !meta) {
51762
+ this.connectors.delete(id);
51763
+ return;
51764
+ }
51765
+ const from = this.absoluteOf(meta.from);
51766
+ const to = this.absoluteOf(meta.to);
51767
+ if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
51768
+ 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`);
51769
+ return;
51770
+ }
51771
+ const end = (box2, path) => {
51772
+ const props = this.store.get(path).props;
51773
+ return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
51774
+ };
51775
+ const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
51776
+ route: meta.route,
51777
+ fromMagnet: meta.fromMagnet,
51778
+ toMagnet: meta.toMagnet,
51779
+ arrow: meta.arrow,
51780
+ labelPos: meta.labelPos,
51781
+ dash: meta.dash,
51782
+ strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
51783
+ });
51784
+ const origin = this.originOf(row.parent);
51785
+ const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
51786
+ const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
51787
+ const patch = {};
51788
+ for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
51789
+ if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
51790
+ patch[key] = value;
51791
+ if (Object.keys(patch).length)
51792
+ this.commit({ op: "update", id, patch });
51793
+ if (meta.labelId) {
51794
+ const label = this.store.get(meta.labelId);
51795
+ const labelBox = this.absoluteOf(meta.labelId);
51796
+ if (label && labelBox) {
51797
+ const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
51798
+ const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
51799
+ const labelPatch = {};
51800
+ if (label.props.x !== x)
51801
+ labelPatch.x = x;
51802
+ if (label.props.y !== y)
51803
+ labelPatch.y = y;
51804
+ if (Object.keys(labelPatch).length)
51805
+ this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
51806
+ }
51807
+ }
51808
+ this.warnConnector(id, geom);
51809
+ }
51810
+ warnOnce(code, nodeId, message) {
51811
+ if (this.rec.warnings.length >= 20)
51812
+ return;
51813
+ if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
51814
+ return;
51815
+ this.rec.warnings.push({ code, nodeId, message });
51816
+ }
51817
+ warnConnector(id, geom) {
51818
+ const row = this.store.get(id);
51819
+ if (!row)
51820
+ return;
51821
+ const meta = connectorMetaOf(row.props);
51822
+ const labelIds = new Set;
51823
+ for (const m of this.connectors.values())
51824
+ if (m.labelId)
51825
+ labelIds.add(m.labelId);
51826
+ let labelBox = null;
51827
+ for (const sibling of this.store.children(row.parent)) {
51828
+ const props = this.store.get(sibling)?.props;
51829
+ if (!props || sibling === id)
51830
+ continue;
51831
+ const box = this.absoluteOf(sibling);
51832
+ if (!box || box.width === 0 && box.height === 0)
51833
+ continue;
51834
+ if (sibling === meta?.labelId) {
51835
+ labelBox = box;
51836
+ continue;
51837
+ }
51838
+ if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
51839
+ for (let i = 1;i < geom.polyline.length; i++)
51840
+ if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
51841
+ this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
51842
+ break;
51843
+ }
51844
+ }
51845
+ if (labelBox && rectsOverlap(labelBox, box))
51846
+ this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
51847
+ }
51848
+ }
51849
+ absoluteOf(path) {
51850
+ if (path === null || path === "")
51851
+ return { x: 0, y: 0, width: 0, height: 0 };
51852
+ const row = this.store.get(path.split("/")[0]);
51853
+ if (!row)
51854
+ return null;
51855
+ const b = this.layoutOf(row.top).boxes.get(path);
51856
+ return b ? { x: b.wx, y: b.wy, width: b.width, height: b.height } : null;
51857
+ }
51858
+ originOf(parent) {
51859
+ if (parent === null)
51860
+ return { x: 0, y: 0 };
51861
+ const box = this.absoluteOf(parent);
51862
+ if (!box)
51863
+ invalid2("parent", `${parent} has no laid-out box`);
51864
+ return { x: box.x, y: box.y };
51865
+ }
51866
+ connectorEnd(id, property) {
51867
+ const row = this.rowOf(id);
51868
+ const box = this.absoluteOf(id);
51869
+ if (!box || box.width === 0 && box.height === 0)
51870
+ invalid2(property, `${id} has no laid-out box to attach to`);
51871
+ return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
51872
+ }
51873
+ commonParent(a, b) {
51874
+ this.rowOf(a);
51875
+ this.rowOf(b);
51876
+ const ancestors = new Set;
51877
+ for (let cur = this.store.get(a).parent;cur !== null; cur = this.store.get(cur)?.parent ?? null)
51878
+ ancestors.add(cur);
51879
+ for (let cur = this.store.get(b).parent;cur !== null; cur = this.store.get(cur)?.parent ?? null)
51880
+ if (ancestors.has(cur))
51881
+ return cur;
51882
+ return null;
51883
+ }
51884
+ inFlow(parent) {
51885
+ if (parent === null)
51886
+ return false;
51887
+ const props = this.store.get(parent)?.props;
51888
+ return props?.type === "frame" && props.layout !== "none";
51889
+ }
50508
51890
  FindEmptySpace(input) {
50509
51891
  const dir = input.direction ?? "right";
50510
51892
  const pad = input.padding ?? 0;
@@ -50532,6 +51914,69 @@ class ExecuteApi {
50532
51914
  return { x: minX, y: maxY + pad };
50533
51915
  return { x: minX, y: minY - pad - input.height };
50534
51916
  }
51917
+ KitPlan(kind, options) {
51918
+ const variables = this.store.variables();
51919
+ return planKitNode(kind, options, {
51920
+ variables: new Set(Object.keys(variables)),
51921
+ measure: (request) => {
51922
+ const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
51923
+ const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
51924
+ return this.MeasureText(content, options2);
51925
+ }
51926
+ });
51927
+ }
51928
+ ListKits() {
51929
+ return this.kits?.list() ?? [];
51930
+ }
51931
+ UseKit(name) {
51932
+ if (typeof name !== "string" || name === "")
51933
+ invalid2("name", "expected a kit name");
51934
+ const entry = this.kits?.get(name);
51935
+ if (!entry)
51936
+ invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
51937
+ const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
51938
+ const { refs, ids } = planRefs(plan);
51939
+ for (const ref of refs)
51940
+ if (!ids.has(ref) && !this.store.get(ref))
51941
+ throw new OpRejectedError({ code: "UNKNOWN_REF", ref });
51942
+ this.SetVariables(entry.kit.variables, false);
51943
+ const frame = kitFrameIn(this.store, entry.frame) ?? this.createKitFrame(entry.frame);
51944
+ for (const node2 of plan.add)
51945
+ this.insertKitComponent(frame, null, node2);
51946
+ for (const { id, node: node2 } of plan.update) {
51947
+ const row = this.rowOf(id);
51948
+ this.commit({ op: "delete", id });
51949
+ this.insertKitComponent(row.parent, row.ord, node2);
51950
+ }
51951
+ const names = kitPlanNames(plan);
51952
+ return { version: entry.kit.version, added: names.added, updated: names.updated, unchanged: plan.unchanged, variables: plan.variables };
51953
+ }
51954
+ createKitFrame(name) {
51955
+ const at = this.FindEmptySpace({ width: 0, height: 0, direction: "right", padding: KIT_FRAME_GAP });
51956
+ return this.Insert("document", {
51957
+ id: "",
51958
+ type: "frame",
51959
+ name,
51960
+ x: at.x,
51961
+ y: at.y,
51962
+ layout: "vertical",
51963
+ gap: KIT_FRAME_GAP,
51964
+ padding: KIT_FRAME_PADDING
51965
+ });
51966
+ }
51967
+ insertKitComponent(parent, ord, node2) {
51968
+ const tree = applyTextDefaults(migrateLegacyProps(node2), this.defaults.text);
51969
+ const seen = new Set;
51970
+ const check = (n2) => {
51971
+ if (seen.has(n2.id) || this.store.get(n2.id))
51972
+ throw new OpRejectedError({ code: "INVALID_VALUE", property: "id", reason: `kit component id ${n2.id} is already taken on this canvas` });
51973
+ seen.add(n2.id);
51974
+ for (const child of Array.isArray(n2.children) ? n2.children : [])
51975
+ check(child);
51976
+ };
51977
+ check(tree);
51978
+ this.commit({ op: "insert", parent, ord: ord ?? between(this.lastOrd(parent), null), node: tree });
51979
+ }
50535
51980
  Print(...values) {
50536
51981
  const line = values.map((v) => typeof v === "string" ? v : JSON.stringify(v)).join(" ");
50537
51982
  this.rec.printBytes += line.length;
@@ -50544,6 +51989,35 @@ class ExecuteApi {
50544
51989
  if (this.rec.screenshots.length < LIMITS.screenshots)
50545
51990
  this.rec.screenshots.push(id);
50546
51991
  }
51992
+ Vectorize(frameId, fileId, opts) {
51993
+ if (typeof frameId !== "string" || frameId === "")
51994
+ invalid2("frameId", "expected a frame id");
51995
+ if (typeof fileId !== "string" || fileId === "")
51996
+ invalid2("fileId", "expected a file id");
51997
+ const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
51998
+ const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
51999
+ const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
52000
+ if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
52001
+ invalid2("maxColors", "expected a positive integer");
52002
+ const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
52003
+ if (allowComplex !== undefined && typeof allowComplex !== "boolean")
52004
+ invalid2("allowComplex", "expected a boolean");
52005
+ if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
52006
+ 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`);
52007
+ const requestId = this.newRequestId();
52008
+ const carried = { ...mode === undefined ? {} : { mode }, ...maxColors === undefined ? {} : { maxColors }, ...allowComplex === undefined ? {} : { allowComplex } };
52009
+ this.rec.pendingVectorize.push({ requestId, frameId, fileId, ...Object.keys(carried).length ? { opts: carried } : {} });
52010
+ return { requestId };
52011
+ }
52012
+ newRequestId() {
52013
+ for (;; ) {
52014
+ let id = "vz-";
52015
+ for (let i = 0;i < 10; i++)
52016
+ id += ID_CHARS[Math.floor(this.random() * ID_CHARS.length)];
52017
+ if (!this.rec.pendingVectorize.some((p) => p.requestId === id))
52018
+ return id;
52019
+ }
52020
+ }
50547
52021
  }
50548
52022
  function toPen(e, depth, _resolved, _instances, shallow = false) {
50549
52023
  const node2 = { ...e.props, id: e.path, type: e.type };
@@ -50941,8 +52415,8 @@ function relative(iso, now) {
50941
52415
  const delta = now - Date.parse(iso), seconds = Math.floor(Math.abs(delta) / 1000);
50942
52416
  if (Math.abs(delta) < 60000)
50943
52417
  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`;
52418
+ 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"];
52419
+ return delta < 0 ? `in ${n2}${unit}` : `${n2}${unit} ago`;
50946
52420
  }
50947
52421
  function scalar(value) {
50948
52422
  return value === undefined ? "" : value === null ? "null" : typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -51034,7 +52508,7 @@ function projectList(items, op) {
51034
52508
  }
51035
52509
 
51036
52510
  // src/output/human.ts
51037
- var count2 = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
52511
+ var count2 = (n2, noun) => `${n2} ${noun}${n2 === 1 ? "" : "s"}`;
51038
52512
  function identity2(result, ctx) {
51039
52513
  const op = "op" in result ? result.op : undefined;
51040
52514
  const split = op?.lastIndexOf(".") ?? -1;
@@ -51496,7 +52970,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
51496
52970
  }
51497
52971
 
51498
52972
  // src/main.ts
51499
- var version = "0.3.0-dev.bff6020";
52973
+ var version = "0.3.0-dev.d38b647";
51500
52974
  var commands = commandTree(operations);
51501
52975
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
51502
52976
  function route(argv) {
@@ -51516,10 +52990,10 @@ function route(argv) {
51516
52990
  words.push(arg);
51517
52991
  if (words.length === 1 && words[0] === API_WORD && HTTP_METHOD.test(argv[i + 1] ?? ""))
51518
52992
  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]));
52993
+ const command = commands.find((c) => c.words.length === words.length && c.words.every((w, n2) => w === words[n2]));
51520
52994
  if (words.length === 1 && words[0] === API_WORD && argv[i + 1] !== undefined && !argv[i + 1].startsWith("-"))
51521
52995
  continue;
51522
- if (command || manual.some((c) => c.length === words.length && c.every((w, n) => w === words[n])))
52996
+ if (command || manual.some((c) => c.length === words.length && c.every((w, n2) => w === words[n2])))
51523
52997
  return { words, args: [...args, ...argv.slice(i + 1)], command };
51524
52998
  }
51525
52999
  return { words, args };
@@ -51750,16 +53224,16 @@ Examples:
51750
53224
  const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
51751
53225
  if (typeof cursor === "string" && cursor)
51752
53226
  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`);
53227
+ const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
53228
+ const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
53229
+ if (flags.all && !(result instanceof Page) && token2 && !firstPage)
53230
+ throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
51757
53231
  if (firstPage) {
51758
53232
  const items = [...firstPage.items];
51759
53233
  const seen = new Set;
51760
53234
  for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
51761
53235
  seen.add(next);
51762
- result = await owner[op.method]({ ...opts, query: { ...opts.query, [token]: next } });
53236
+ result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
51763
53237
  items.push(...pageOf(result)?.items ?? []);
51764
53238
  }
51765
53239
  ctx.nextCommand = undefined;