@imgly/codesign-mcp 0.7.2 → 0.7.3-next.20261125135902.gfdc6ee3
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.
- package/README.md +35 -17
- package/dist/cli/license.js +1 -1
- package/dist/runtime/cli/commands.d.ts +2 -0
- package/dist/runtime/cli/commands.d.ts.map +1 -1
- package/dist/runtime/cli/commands.js +56 -1
- package/dist/runtime/cli/commands.js.map +1 -1
- package/dist/runtime/cli/main.d.ts.map +1 -1
- package/dist/runtime/cli/main.js +5 -0
- package/dist/runtime/cli/main.js.map +1 -1
- package/dist/runtime/codesign-shim/codesign-router/protocol/types.mjs +1 -0
- package/dist/runtime/codesign-shim/codesign-router/release-build.generated.mjs +1 -1
- package/dist/server-client-types/protocol/types.d.ts +25 -3
- package/dist/server-client.mjs +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/node_modules/@imgly/codesign-billing/README.md +138 -0
- package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/charge.d.ts +30 -5
- package/node_modules/@imgly/codesign-billing/dist/charge.d.ts.map +1 -0
- package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/charge.js +16 -1
- package/node_modules/@imgly/codesign-billing/dist/charge.js.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/charges.d.ts +71 -0
- package/node_modules/@imgly/codesign-billing/dist/charges.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/charges.js +198 -0
- package/node_modules/@imgly/codesign-billing/dist/charges.js.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/index.d.ts +6 -0
- package/node_modules/@imgly/codesign-billing/dist/index.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/index.js +6 -0
- package/node_modules/@imgly/codesign-billing/dist/index.js.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/ledger.d.ts +55 -0
- package/node_modules/@imgly/codesign-billing/dist/ledger.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/ledger.js +80 -0
- package/node_modules/@imgly/codesign-billing/dist/ledger.js.map +1 -0
- package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/metering.d.ts +9 -1
- package/node_modules/@imgly/codesign-billing/dist/metering.d.ts.map +1 -0
- package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/metering.js +77 -21
- package/node_modules/@imgly/codesign-billing/dist/metering.js.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/refusal.d.ts +20 -0
- package/node_modules/@imgly/codesign-billing/dist/refusal.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-billing/dist/refusal.js +13 -0
- package/node_modules/@imgly/codesign-billing/dist/refusal.js.map +1 -0
- package/node_modules/@imgly/codesign-billing/package.json +30 -0
- package/node_modules/@imgly/codesign-router/dist/config/unit-config.d.ts +13 -5
- package/node_modules/@imgly/codesign-router/dist/config/unit-config.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/config/unit-config.js +18 -12
- package/node_modules/@imgly/codesign-router/dist/config/unit-config.js.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/consent.d.ts +6 -2
- package/node_modules/@imgly/codesign-router/dist/consent.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/consent.js +65 -9
- package/node_modules/@imgly/codesign-router/dist/consent.js.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/protocol/types.d.ts +25 -3
- package/node_modules/@imgly/codesign-router/dist/protocol/types.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/protocol/types.js +1 -0
- package/node_modules/@imgly/codesign-router/dist/protocol/types.js.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/release-build.generated.d.ts +1 -1
- package/node_modules/@imgly/codesign-router/dist/release-build.generated.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/release-build.generated.js +1 -1
- package/node_modules/@imgly/codesign-router/dist/release-build.generated.js.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/router/channels-v2.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/router/channels-v2.js +14 -4
- package/node_modules/@imgly/codesign-router/dist/router/channels-v2.js.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/router/main.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-router/dist/router/main.js +9 -1
- package/node_modules/@imgly/codesign-router/dist/router/main.js.map +1 -1
- package/node_modules/@imgly/codesign-sdk/CHANGELOG.md +24 -0
- package/node_modules/@imgly/codesign-sdk/README.md +8 -7
- package/node_modules/@imgly/codesign-sdk/dist/abort.d.ts +1 -0
- package/node_modules/@imgly/codesign-sdk/dist/abort.js +18 -0
- package/node_modules/@imgly/codesign-sdk/dist/assets/inline.generated.js +12 -12
- package/node_modules/@imgly/codesign-sdk/dist/browser/index.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/browser/worker.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/browser/worker.js +15 -8
- package/node_modules/@imgly/codesign-sdk/dist/cesdk-utils/index.js +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/codesign-error.d.ts +38 -1
- package/node_modules/@imgly/codesign-sdk/dist/codesign-error.js +9 -0
- package/node_modules/@imgly/codesign-sdk/dist/codesign.d.ts +19 -12
- package/node_modules/@imgly/codesign-sdk/dist/codesign.js +268 -43
- package/node_modules/@imgly/codesign-sdk/dist/design/animatable.generated.js +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/capabilities.generated.js +1 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/facade.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/design/facade.js +128 -36
- package/node_modules/@imgly/codesign-sdk/dist/design/keyframes.js +2 -1
- package/node_modules/@imgly/codesign-sdk/dist/design/lint.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/design/lint.js +82 -5
- package/node_modules/@imgly/codesign-sdk/dist/design/props.generated.js +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/run-offsets.d.ts +10 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/run-offsets.js +26 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/scene-lint.d.ts +23 -1
- package/node_modules/@imgly/codesign-sdk/dist/design/scene-lint.js +194 -3
- package/node_modules/@imgly/codesign-sdk/dist/design/timeline-poses.d.ts +8 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/timeline-poses.js +53 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/variables.d.ts +14 -0
- package/node_modules/@imgly/codesign-sdk/dist/design/variables.js +250 -37
- package/node_modules/@imgly/codesign-sdk/dist/designs/s3-presigner.d.ts +50 -0
- package/node_modules/@imgly/codesign-sdk/dist/designs/s3-presigner.js +116 -0
- package/node_modules/@imgly/codesign-sdk/dist/designs/types.d.ts +79 -3
- package/node_modules/@imgly/codesign-sdk/dist/engine/audio-extract.d.ts +12 -1
- package/node_modules/@imgly/codesign-sdk/dist/engine/audio-extract.js +20 -4
- package/node_modules/@imgly/codesign-sdk/dist/engine/engine-capacity.d.ts +20 -7
- package/node_modules/@imgly/codesign-sdk/dist/engine/engine-capacity.js +31 -14
- package/node_modules/@imgly/codesign-sdk/dist/engine/headless.d.ts +4 -0
- package/node_modules/@imgly/codesign-sdk/dist/engine/headless.js +20 -0
- package/node_modules/@imgly/codesign-sdk/dist/executor/billing/check.d.ts +1 -14
- package/node_modules/@imgly/codesign-sdk/dist/executor/billing/check.js +2 -7
- package/node_modules/@imgly/codesign-sdk/dist/executor/billing/metered.d.ts +1 -2
- package/node_modules/@imgly/codesign-sdk/dist/executor/billing/metered.js +120 -91
- package/node_modules/@imgly/codesign-sdk/dist/executor/encode-watchdog.d.ts +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/executor/encode-watchdog.js +10 -4
- package/node_modules/@imgly/codesign-sdk/dist/executor/engine-protocol.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/executor/engine-protocol.js +13 -3
- package/node_modules/@imgly/codesign-sdk/dist/executor/executor-options.d.ts +6 -7
- package/node_modules/@imgly/codesign-sdk/dist/executor/executor-options.js +14 -7
- package/node_modules/@imgly/codesign-sdk/dist/executor/handler.d.ts +47 -2
- package/node_modules/@imgly/codesign-sdk/dist/executor/handler.js +519 -8
- package/node_modules/@imgly/codesign-sdk/dist/executor/node.d.ts +42 -6
- package/node_modules/@imgly/codesign-sdk/dist/executor/node.js +231 -9
- package/node_modules/@imgly/codesign-sdk/dist/exporters/fig.d.ts +13 -0
- package/node_modules/@imgly/codesign-sdk/dist/exporters/fig.js +28 -0
- package/node_modules/@imgly/codesign-sdk/dist/exporters/html.d.ts +18 -2
- package/node_modules/@imgly/codesign-sdk/dist/exporters/html.js +129 -15
- package/node_modules/@imgly/codesign-sdk/dist/exporters/index.d.ts +5 -2
- package/node_modules/@imgly/codesign-sdk/dist/exporters/index.js +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/exporters/node.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/exporters/node.js +4 -3
- package/node_modules/@imgly/codesign-sdk/dist/exporters/psd.js +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/formats/av-limit.d.ts +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/av-limit.js +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/formats/design-sniff.d.ts +3 -1
- package/node_modules/@imgly/codesign-sdk/dist/formats/design-sniff.js +7 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/import-registry.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/formats/import-registry.js +4 -2
- package/node_modules/@imgly/codesign-sdk/dist/formats/import-warnings.d.ts +5 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/import-warnings.js +31 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/media-facts.d.ts +15 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/media-facts.js +26 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/mime.d.ts +6 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/mime.js +37 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/refuse-media.d.ts +7 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/refuse-media.js +46 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/svg-export.d.ts +6 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/svg-export.js +20 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/svg-import.d.ts +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/svg-import.js +25 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/zip-entries.d.ts +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/formats/zip-entries.js +1 -0
- package/node_modules/@imgly/codesign-sdk/dist/gateway/asset-generate.d.ts +10 -4
- package/node_modules/@imgly/codesign-sdk/dist/gateway/asset-generate.js +205 -79
- package/node_modules/@imgly/codesign-sdk/dist/gateway/client.d.ts +23 -2
- package/node_modules/@imgly/codesign-sdk/dist/gateway/client.js +40 -41
- package/node_modules/@imgly/codesign-sdk/dist/gateway/index.d.ts +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/gateway/index.js +4 -0
- package/node_modules/@imgly/codesign-sdk/dist/gateway/types.d.ts +18 -3
- package/node_modules/@imgly/codesign-sdk/dist/gateway/upload-origin.d.ts +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/gateway/upload-origin.js +5 -0
- package/node_modules/@imgly/codesign-sdk/dist/host/edit-code.d.ts +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/host/edit-code.js +8 -1
- package/node_modules/@imgly/codesign-sdk/dist/host/preview-size.d.ts +4 -2
- package/node_modules/@imgly/codesign-sdk/dist/host/preview-size.js +7 -4
- package/node_modules/@imgly/codesign-sdk/dist/host.d.ts +34 -5
- package/node_modules/@imgly/codesign-sdk/dist/host.js +6 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/fig.d.ts +4 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/fig.js +57 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/index.d.ts +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/importers/index.js +38 -25
- package/node_modules/@imgly/codesign-sdk/dist/importers/node.d.ts +5 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/node.js +8 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/pdf-fonts.d.ts +20 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/pdf-fonts.js +76 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/shared.d.ts +14 -0
- package/node_modules/@imgly/codesign-sdk/dist/importers/shared.js +18 -0
- package/node_modules/@imgly/codesign-sdk/dist/index.d.ts +5 -4
- package/node_modules/@imgly/codesign-sdk/dist/index.js +2 -1
- package/node_modules/@imgly/codesign-sdk/dist/internal/index.d.ts +24 -17
- package/node_modules/@imgly/codesign-sdk/dist/internal/index.js +19 -10
- package/node_modules/@imgly/codesign-sdk/dist/node/edit-renders.d.ts +5 -0
- package/node_modules/@imgly/codesign-sdk/dist/node/edit-renders.js +73 -0
- package/node_modules/@imgly/codesign-sdk/dist/node/engine-child.js +18 -2
- package/node_modules/@imgly/codesign-sdk/dist/node/engine-http.js +8 -2
- package/node_modules/@imgly/codesign-sdk/dist/node/index.d.ts +1 -0
- package/node_modules/@imgly/codesign-sdk/dist/node/index.js +1 -0
- package/node_modules/@imgly/codesign-sdk/dist/node/media-probe.js +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/sdk-version.generated.js +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/session/engine-session.d.ts +59 -13
- package/node_modules/@imgly/codesign-sdk/dist/session/engine-session.js +19 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/export-facts.d.ts +1 -14
- package/node_modules/@imgly/codesign-sdk/dist/session/export-facts.js +15 -4
- package/node_modules/@imgly/codesign-sdk/dist/session/file-formats.d.ts +5 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/guarded-engine-session.d.ts +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/guarded-engine-session.js +18 -7
- package/node_modules/@imgly/codesign-sdk/dist/session/local-engine-session.js +247 -68
- package/node_modules/@imgly/codesign-sdk/dist/session/local-engine.js +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/session/multipart.js +10 -2
- package/node_modules/@imgly/codesign-sdk/dist/session/pending-video.js +2 -3
- package/node_modules/@imgly/codesign-sdk/dist/session/read-resolved.js +93 -6
- package/node_modules/@imgly/codesign-sdk/dist/session/remote.d.ts +34 -10
- package/node_modules/@imgly/codesign-sdk/dist/session/remote.js +377 -87
- package/node_modules/@imgly/codesign-sdk/dist/session/render-id.js +11 -2
- package/node_modules/@imgly/codesign-sdk/dist/session/session.d.ts +67 -6
- package/node_modules/@imgly/codesign-sdk/dist/session/session.js +213 -32
- package/node_modules/@imgly/codesign-sdk/dist/session/silent-audio.d.ts +18 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/silent-audio.js +47 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/transfers.d.ts +85 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/transfers.js +80 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/url-guard.d.ts +30 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/url-guard.js +187 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/url-source.d.ts +21 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/url-source.js +163 -0
- package/node_modules/@imgly/codesign-sdk/dist/session/wire.d.ts +8 -1
- package/node_modules/@imgly/codesign-sdk/dist/session/wire.js +2 -1
- package/node_modules/@imgly/codesign-sdk/dist/session-instructions.js +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/sessions/state.d.ts +3 -1
- package/node_modules/@imgly/codesign-sdk/dist/sessions/state.js +5 -1
- package/node_modules/@imgly/codesign-sdk/dist/signed-urls.d.ts +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/signed-urls.js +30 -0
- package/node_modules/@imgly/codesign-sdk/dist/skill-tool.js +12 -12
- package/node_modules/@imgly/codesign-sdk/dist/sources/handshake.d.ts +2 -0
- package/node_modules/@imgly/codesign-sdk/dist/sources/mime.js +0 -1
- package/node_modules/@imgly/codesign-sdk/dist/sources/route.d.ts +8 -1
- package/node_modules/@imgly/codesign-sdk/dist/sources/route.js +17 -2
- package/node_modules/@imgly/codesign-sdk/dist/sources/search.js +9 -2
- package/node_modules/@imgly/codesign-sdk/dist/sources/types.d.ts +8 -1
- package/node_modules/@imgly/codesign-sdk/dist/testing/conformance.js +11 -6
- package/node_modules/@imgly/codesign-sdk/dist/testing/fake-engine.d.ts +1 -1
- package/node_modules/@imgly/codesign-sdk/dist/testing/fake-engine.js +11 -4
- package/node_modules/@imgly/codesign-sdk/dist/tools/edit.js +11 -4
- package/node_modules/@imgly/codesign-sdk/dist/tools/errors.js +2 -2
- package/node_modules/@imgly/codesign-sdk/dist/tools/export-formats/table.d.ts +4 -4
- package/node_modules/@imgly/codesign-sdk/dist/tools/export-formats/table.js +8 -0
- package/node_modules/@imgly/codesign-sdk/dist/tools/export.d.ts +3 -1
- package/node_modules/@imgly/codesign-sdk/dist/tools/export.js +75 -12
- package/node_modules/@imgly/codesign-sdk/dist/tools/omit-defaults.d.ts +3 -0
- package/node_modules/@imgly/codesign-sdk/dist/tools/omit-defaults.js +7 -0
- package/node_modules/@imgly/codesign-sdk/dist/tools/preview.js +42 -19
- package/node_modules/@imgly/codesign-sdk/dist/tools/source-tools.js +11 -4
- package/node_modules/@imgly/codesign-sdk/package.json +18 -10
- package/node_modules/@imgly/codesign-server/assets/ai-plugins/apps.mjs +5 -5
- package/node_modules/@imgly/codesign-server/assets/ai-plugins/image-gateway.mjs +5 -5
- package/node_modules/@imgly/codesign-server/assets/ai-plugins/version.json +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/link.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/link.js +2 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/link.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/local-server.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/local-server.js +1 -0
- package/node_modules/@imgly/codesign-server/dist/catalog/local-server.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.d.ts +59 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.js +127 -23
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.d.ts +7 -0
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.js +65 -15
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.d.ts +2 -0
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.js +15 -5
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.d.ts +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.js +7 -6
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.d.ts +2 -2
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.js +14 -4
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.d.ts +10 -0
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.js +106 -22
- package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/connectors.js +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/connectors.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/doctor/checks/mcp-servers.js +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/doctor/checks/mcp-servers.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/pack.d.ts +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/pack.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/cli/pack.js +24 -18
- package/node_modules/@imgly/codesign-server/dist/cli/pack.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/instructions.js +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/instructions.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/main.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/main.js +4 -3
- package/node_modules/@imgly/codesign-server/dist/conversation/main.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/stage.d.ts +4 -0
- package/node_modules/@imgly/codesign-server/dist/conversation/stage.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/conversation/stage.js +13 -0
- package/node_modules/@imgly/codesign-server/dist/conversation/stage.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.d.ts +0 -6
- package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.js +0 -58
- package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/credentials/keychain.d.ts +10 -0
- package/node_modules/@imgly/codesign-server/dist/credentials/keychain.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/credentials/keychain.js +84 -0
- package/node_modules/@imgly/codesign-server/dist/credentials/keychain.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/credentials/token-store.d.ts +1 -3
- package/node_modules/@imgly/codesign-server/dist/credentials/token-store.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/credentials/token-store.js +3 -23
- package/node_modules/@imgly/codesign-server/dist/credentials/token-store.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.d.ts +59 -8
- package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.js +317 -40
- package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/engine.js +4 -9
- package/node_modules/@imgly/codesign-server/dist/design/engine.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/engines.d.ts +5 -0
- package/node_modules/@imgly/codesign-server/dist/design/engines.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/engines.js +49 -0
- package/node_modules/@imgly/codesign-server/dist/design/engines.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/host.d.ts +2 -0
- package/node_modules/@imgly/codesign-server/dist/design/host.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/host.js +10 -6
- package/node_modules/@imgly/codesign-server/dist/design/host.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.js +34 -5
- package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/local-design.d.ts +42 -5
- package/node_modules/@imgly/codesign-server/dist/design/local-design.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/local-design.js +175 -38
- package/node_modules/@imgly/codesign-server/dist/design/local-design.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/local-tools.d.ts +27 -1
- package/node_modules/@imgly/codesign-server/dist/design/local-tools.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/local-tools.js +65 -7
- package/node_modules/@imgly/codesign-server/dist/design/local-tools.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/main.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/main.js +23 -10
- package/node_modules/@imgly/codesign-server/dist/design/main.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/node-exporters.d.ts +4 -0
- package/node_modules/@imgly/codesign-server/dist/design/node-exporters.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/design/node-exporters.js +13 -0
- package/node_modules/@imgly/codesign-server/dist/design/node-exporters.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/design/probe-media.d.ts +2 -0
- package/node_modules/@imgly/codesign-server/dist/design/probe-media.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/design/probe-media.js +16 -0
- package/node_modules/@imgly/codesign-server/dist/design/probe-media.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/design/remote-resources.d.ts +22 -3
- package/node_modules/@imgly/codesign-server/dist/design/remote-resources.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/remote-resources.js +123 -32
- package/node_modules/@imgly/codesign-server/dist/design/remote-resources.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/save.d.ts +5 -0
- package/node_modules/@imgly/codesign-server/dist/design/save.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/save.js +9 -0
- package/node_modules/@imgly/codesign-server/dist/design/save.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/sessions/store.d.ts +33 -4
- package/node_modules/@imgly/codesign-server/dist/design/sessions/store.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/sessions/store.js +121 -43
- package/node_modules/@imgly/codesign-server/dist/design/sessions/store.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/workspace-files.d.ts +8 -0
- package/node_modules/@imgly/codesign-server/dist/design/workspace-files.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/workspace-files.js +50 -61
- package/node_modules/@imgly/codesign-server/dist/design/workspace-files.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/workspace-library.d.ts +24 -2
- package/node_modules/@imgly/codesign-server/dist/design/workspace-library.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/design/workspace-library.js +132 -17
- package/node_modules/@imgly/codesign-server/dist/design/workspace-library.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/create.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/create.js +19 -6
- package/node_modules/@imgly/codesign-server/dist/services/archives/create.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.js +10 -7
- package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/pack.d.ts +3 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/pack.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/pack.js +5 -4
- package/node_modules/@imgly/codesign-server/dist/services/archives/pack.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.d.ts +56 -0
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.js +218 -0
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed.js +33 -124
- package/node_modules/@imgly/codesign-server/dist/services/archives/seed.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/template.d.ts +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/archives/template.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/template.js +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/archives/template.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.js +2 -1
- package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.d.ts +9 -5
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.js +14 -19
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.d.ts +2 -0
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.js +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.js +4 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.d.ts +5 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.js +67 -6
- package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/flags/manifest.js +2 -2
- package/node_modules/@imgly/codesign-server/dist/services/flags/manifest.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.d.ts +3 -3
- package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.js +3 -3
- package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.d.ts +15 -0
- package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.js +14 -0
- package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.js +36 -0
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.d.ts +2 -2
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.js +3 -5
- package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.js +5 -4
- package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.js +0 -64
- package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.d.ts +4 -0
- package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.js +4 -0
- package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.js +2 -24
- package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.d.ts +4 -2
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.js +15 -14
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.d.ts +12 -2
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.js +42 -12
- package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.js +1 -2
- package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.js +24 -2
- package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.d.ts +47 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.js +167 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.d.ts +2 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.js +2 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.d.ts +32 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.js +79 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.d.ts +35 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.js +185 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.d.ts +74 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.d.ts.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.js +82 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.js.map +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/types.d.ts +10 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/types.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/types.js +1 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/types.js.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.d.ts.map +1 -1
- package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.js +5 -0
- package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.js.map +1 -1
- package/node_modules/@imgly/codesign-server/package.json +13 -11
- package/node_modules/@imgly/design-lint/dist/rules/text-legibility.d.ts +2 -1
- package/node_modules/@imgly/design-lint/dist/rules/text-legibility.d.ts.map +1 -1
- package/node_modules/@imgly/design-lint/dist/rules/text-legibility.js +5 -1
- package/node_modules/@imgly/design-lint/dist/rules/text-legibility.js.map +1 -1
- package/node_modules/@imgly/design-lint/package.json +2 -2
- package/node_modules/@imgly/figma-exporter/CHANGELOG.md +79 -0
- package/node_modules/@imgly/figma-exporter/LICENSE.md +137 -0
- package/node_modules/@imgly/figma-exporter/README.md +201 -0
- package/node_modules/@imgly/figma-exporter/THIRD_PARTY_NOTICES.md +475 -0
- package/node_modules/@imgly/figma-exporter/dist/index.cjs +1 -0
- package/node_modules/@imgly/figma-exporter/dist/index.d.cts +8833 -0
- package/node_modules/@imgly/figma-exporter/dist/index.d.ts +8833 -0
- package/node_modules/@imgly/figma-exporter/dist/index.js +1 -0
- package/node_modules/@imgly/figma-exporter/package.json +92 -0
- package/node_modules/@imgly/figma-importer/CHANGELOG.md +84 -0
- package/node_modules/@imgly/figma-importer/LICENSE.md +137 -0
- package/node_modules/@imgly/figma-importer/README.md +256 -0
- package/node_modules/@imgly/figma-importer/THIRD_PARTY_NOTICES.md +446 -0
- package/node_modules/@imgly/figma-importer/dist/index.cjs +2 -0
- package/node_modules/@imgly/figma-importer/dist/index.d.cts +12831 -0
- package/node_modules/@imgly/figma-importer/dist/index.d.ts +12831 -0
- package/node_modules/@imgly/figma-importer/dist/index.js +2 -0
- package/node_modules/@imgly/figma-importer/package.json +85 -0
- package/node_modules/@imgly/html-exporter/CHANGELOG.md +35 -0
- package/node_modules/@imgly/html-exporter/README.md +45 -4
- package/node_modules/@imgly/html-exporter/dist/index.cjs +610 -493
- package/node_modules/@imgly/html-exporter/dist/index.d.cts +235 -216
- package/node_modules/@imgly/html-exporter/dist/index.d.ts +235 -216
- package/node_modules/@imgly/html-exporter/dist/index.js +610 -493
- package/node_modules/@imgly/html-exporter/package.json +15 -10
- package/node_modules/@imgly/idml-exporter/CHANGELOG.md +10 -0
- package/node_modules/@imgly/idml-exporter/README.md +17 -18
- package/node_modules/@imgly/idml-exporter/dist/harfbuzz.browser.js +1 -1
- package/node_modules/@imgly/idml-exporter/dist/index.cjs +8 -11
- package/node_modules/@imgly/idml-exporter/dist/index.d.cts +14480 -10275
- package/node_modules/@imgly/idml-exporter/dist/index.d.ts +14480 -10275
- package/node_modules/@imgly/idml-exporter/dist/index.js +8 -10
- package/node_modules/@imgly/idml-exporter/dist/woff2.browser.js +14 -14
- package/node_modules/@imgly/idml-exporter/package.json +17 -12
- package/node_modules/@imgly/idml-importer/CHANGELOG.md +37 -0
- package/node_modules/@imgly/idml-importer/README.md +148 -17
- package/node_modules/@imgly/idml-importer/dist/index.cjs +6 -5
- package/node_modules/@imgly/idml-importer/dist/index.d.cts +1003 -632
- package/node_modules/@imgly/idml-importer/dist/index.d.ts +1003 -632
- package/node_modules/@imgly/idml-importer/dist/index.js +6 -5
- package/node_modules/@imgly/idml-importer/package.json +9 -9
- package/node_modules/@imgly/pdf-importer/CHANGELOG.md +59 -0
- package/node_modules/@imgly/pdf-importer/README.md +71 -7
- package/node_modules/@imgly/pdf-importer/dist/browser.d.ts +940 -788
- package/node_modules/@imgly/pdf-importer/dist/browser.js +17 -15
- package/node_modules/@imgly/pdf-importer/dist/node.cjs +17 -16
- package/node_modules/@imgly/pdf-importer/dist/node.d.cts +940 -788
- package/node_modules/@imgly/pdf-importer/dist/node.d.ts +940 -788
- package/node_modules/@imgly/pdf-importer/dist/node.js +17 -15
- package/node_modules/@imgly/pdf-importer/dist/pdf.worker.mjs +80265 -61990
- package/node_modules/@imgly/pdf-importer/package.json +13 -13
- package/node_modules/@imgly/psd-exporter/CHANGELOG.md +12 -0
- package/node_modules/@imgly/psd-exporter/README.md +50 -7
- package/node_modules/@imgly/psd-exporter/dist/index.cjs +5 -7
- package/node_modules/@imgly/psd-exporter/dist/index.d.cts +14332 -10063
- package/node_modules/@imgly/psd-exporter/dist/index.d.ts +14332 -10063
- package/node_modules/@imgly/psd-exporter/dist/index.js +5 -6
- package/node_modules/@imgly/psd-exporter/dist/wawoff2-LICENSE.txt +19 -0
- package/node_modules/@imgly/psd-exporter/dist/woff2.browser.js +19 -0
- package/node_modules/@imgly/psd-exporter/package.json +26 -9
- package/node_modules/@imgly/psd-importer/CHANGELOG.md +29 -1
- package/node_modules/@imgly/psd-importer/README.md +22 -30
- package/node_modules/@imgly/psd-importer/dist/index.cjs +11 -11
- package/node_modules/@imgly/psd-importer/dist/index.d.cts +10479 -12978
- package/node_modules/@imgly/psd-importer/dist/index.d.ts +10479 -12978
- package/node_modules/@imgly/psd-importer/dist/index.js +11 -11
- package/node_modules/@imgly/psd-importer/package.json +8 -11
- package/package.json +28 -17
- package/node_modules/@imgly/pdf-importer/dist/browser.d.cts +0 -941
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
// `import` — load a design file into the current session, replacing it and unbinding the session from its saved design.
|
|
2
|
-
import { engineErrorCode, isAbsolutePath, isCodesignError, isProductFailure, titleArg } from '@imgly/codesign-sdk/internal';
|
|
2
|
+
import { engineErrorCode, FIG_CANVAS_MESSAGE, isAbsolutePath, isCodesignError, isProductFailure, titleArg } from '@imgly/codesign-sdk/internal';
|
|
3
3
|
import { errorAnswer } from '@imgly/codesign-sdk/internal';
|
|
4
|
+
import { checkUpload, uploadSchema } from './asset-add.js';
|
|
4
5
|
/** The source keys, as one list — the "exactly one of" check counts these. */
|
|
5
|
-
const SOURCE_KEYS = ['url', 'path', 'demo', 'uri'];
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const SOURCE_KEYS = ['url', 'path', 'demo', 'uri', 'upload'];
|
|
7
|
+
/** The file names the upload arm signs, by the format the load then sniffs from the bytes: every format `import` opens. */
|
|
8
|
+
const UPLOAD_EXTENSIONS = {
|
|
9
|
+
archive: ['imgly', 'zip'],
|
|
10
|
+
scene: ['scene'],
|
|
11
|
+
image: ['png', 'jpg', 'jpeg', 'webp', 'gif'],
|
|
12
|
+
svg: ['svg'],
|
|
13
|
+
psd: ['psd', 'psb'],
|
|
14
|
+
idml: ['idml'],
|
|
15
|
+
pptx: ['pptx'],
|
|
16
|
+
pdf: ['pdf'],
|
|
17
|
+
lottie: ['json', 'lottie'],
|
|
18
|
+
fig: ['fig']
|
|
19
|
+
};
|
|
20
|
+
export const DESIGN_UPLOAD_EXTENSIONS = new Set(Object.values(UPLOAD_EXTENSIONS).flat());
|
|
21
|
+
/** A MIME type's shape: the arm signs it as the PUT's Content-Type. */
|
|
22
|
+
const MIME_TYPE = /^[A-Za-z0-9][\w.+-]*\/[A-Za-z0-9][\w.+-]*$/;
|
|
23
|
+
const UPLOAD_ADVICE = "Or `{ upload: { name, type, size, sha256 } }` for a design file on your side: it imports nothing yet and answers `{ uri, url, headers, expiresAt }`; PUT the file's bytes to `url` with exactly `headers` before `expiresAt`, then import `{ uri }`, once: a successful import removes the upload.";
|
|
24
|
+
const buildDescription = (demoIds, mediaAdvice, allowPath, upload = false) => [
|
|
25
|
+
'Import a design FILE into the design you are working on — a native CE.SDK `.imgly` design file (also the legacy `.scene` and `.zip` forms); a foreign design file: Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`), or PDF; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; a Figma file (`.fig`), whose first canvas becomes the design, a page for each top-level frame and one more for what lies outside the frames (the warnings name any other canvases); or a plain image (PNG/JPEG/WebP/GIF) or SVG, which becomes a one-page design sized to the image (`format`: `"image"`/`"svg"`). The inverse of `export({ format: \'imgly\' })`.' +
|
|
8
26
|
// Only a deployment with a media path advertises one.
|
|
9
27
|
(mediaAdvice === undefined
|
|
10
28
|
? ''
|
|
11
29
|
: ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),
|
|
12
30
|
'',
|
|
13
31
|
`Source: \`{ url }\` (http/https), \`{ uri }\` (a \`uri\` an earlier save returned)${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\`"${id}"\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}. Archives are ingested: their bundled asset bytes are stored through this server's asset store, so the loaded design is durable and behaves exactly like a natively-built one.`,
|
|
32
|
+
...(upload ? [UPLOAD_ADVICE] : []),
|
|
14
33
|
'',
|
|
15
34
|
'REPLACES what you are working on: whatever was on the canvas is discarded, and the imported file becomes the current design — continue with `edit`. Importing also detaches you from any design you had saved, so the next `export({ format: "imgly" })` writes a NEW design rather than overwriting the file you imported. That is what makes "save the original, import it back, edit, save the variant" safe. The one exception is `{ uri }` of the design you are saving into: that reloads its saved version — someone else\'s changes included — and you keep saving into it.',
|
|
16
35
|
'',
|
|
17
36
|
'Returns JSON `{ title, format }`. Foreign-format imports may add `warnings` (importer notes about what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`. (Where replacement fonts come from is a deployment question — see `recipes.md` in the `api` skill, "Fonts".)'
|
|
18
37
|
].join('\n');
|
|
19
38
|
/** For a session whose imports each start a new design (the design library's). */
|
|
20
|
-
const buildNewDesignDescription = (demoIds, mediaAdvice, allowURL, allowPath, addressed = false, templates = false) => [
|
|
21
|
-
'Import a design FILE as a NEW design — a CE.SDK `.imgly` design file; a Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`) or PDF file; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; or a plain image or SVG, which becomes a one-page design sized to the image.' +
|
|
39
|
+
const buildNewDesignDescription = (demoIds, mediaAdvice, allowURL, allowPath, addressed = false, templates = false, upload = false) => [
|
|
40
|
+
'Import a design FILE as a NEW design — a CE.SDK `.imgly` design file; a Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`) or PDF file; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; a Figma file (`.fig`), whose first canvas becomes the design, a page for each top-level frame and one more for what lies outside the frames (the warnings name any other canvases); or a plain image or SVG, which becomes a one-page design sized to the image.' +
|
|
22
41
|
(mediaAdvice === undefined
|
|
23
42
|
? ''
|
|
24
43
|
: ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),
|
|
25
44
|
'',
|
|
26
45
|
`Source: ${allowURL ? '`{ url }` (http/https), ' : ''}\`{ uri }\` (a saved design — you get a copy of it — or a file you were given${templates ? ', or a template `asset_search` lists from an installed pack: the new design starts as that template' : ''})${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\`"${id}"\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}.`,
|
|
46
|
+
...(upload ? [UPLOAD_ADVICE] : []),
|
|
27
47
|
'',
|
|
28
48
|
addressed
|
|
29
49
|
? "Every import starts a NEW design; the design you were on is left as it is. To work on a saved design itself rather than a copy, pass its `uri` as `design` to the other tools. With only a `title` and no `source` (`import({ title: 'Poster' })`), it starts an empty design."
|
|
@@ -34,12 +54,13 @@ const buildNewDesignDescription = (demoIds, mediaAdvice, allowURL, allowPath, ad
|
|
|
34
54
|
: 'Returns JSON `{ uri, title, format }` — the new design, saved after every change; to continue it later, `open` this `uri`.') +
|
|
35
55
|
' Foreign-format imports may add `warnings` (what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`.'
|
|
36
56
|
].join('\n');
|
|
37
|
-
const SUPPORTED_FORMATS_HINT = 'Supported: a CE.SDK `.imgly` design file (or legacy `.scene` / `.zip` archive), a Photoshop `.psd`/`.psb`, InDesign `.idml`, PowerPoint `.pptx`, or PDF (`.pdf`) file, a Lottie animation (`.json`/`.lottie`), or a plain image (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`) or SVG (`.svg`).';
|
|
57
|
+
const SUPPORTED_FORMATS_HINT = 'Supported: a CE.SDK `.imgly` design file (or legacy `.scene` / `.zip` archive), a Photoshop `.psd`/`.psb`, InDesign `.idml`, PowerPoint `.pptx`, or PDF (`.pdf`) file, a Lottie animation (`.json`/`.lottie`), a Figma `.fig` file, or a plain image (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`) or SVG (`.svg`).';
|
|
38
58
|
// Recognized but not a design: says what the file is; the remedy is the host's `mediaAdvice`.
|
|
39
59
|
const UNSUPPORTED_FORMATS = {
|
|
40
|
-
pack: "This is an asset pack (`.imglypack`), not a design:
|
|
60
|
+
pack: "This is an asset pack (`.imglypack`), not a design: the user adds it by opening it in the CoDesign app, or with `cdsn pack install <file>`. Its templates then become the workspace's own designs and its styles saved styles.",
|
|
41
61
|
sketch: 'Sketch (`.sketch`) files are not supported.',
|
|
42
62
|
xd: 'Adobe XD (`.xd`) files are not supported.',
|
|
63
|
+
'fig-canvas': FIG_CANVAS_MESSAGE,
|
|
43
64
|
font: 'This is a font file — a font cannot become a design.',
|
|
44
65
|
audio: 'This is an audio file — it cannot become a design.',
|
|
45
66
|
video: "This is a video file — video designs aren't supported yet.",
|
|
@@ -63,7 +84,7 @@ function imageAsDesignWarning(mediaAdvice) {
|
|
|
63
84
|
: `Created a one-page design from an image. If you meant to make this image available for use inside a design instead: ${mediaAdvice}`;
|
|
64
85
|
}
|
|
65
86
|
// `source` is a flat object, not a `oneOf`: strict tool calling and weaker models break on unions.
|
|
66
|
-
function buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, templates) {
|
|
87
|
+
function buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, templates, upload) {
|
|
67
88
|
const sourceProperties = {};
|
|
68
89
|
if (allowURL) {
|
|
69
90
|
sourceProperties.url = {
|
|
@@ -90,10 +111,14 @@ function buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, templat
|
|
|
90
111
|
description: 'Id of a demo design bundled with this server — a finished design to demonstrate on, with no file and no build required.'
|
|
91
112
|
};
|
|
92
113
|
}
|
|
114
|
+
if (upload) {
|
|
115
|
+
sourceProperties.upload = uploadSchema('A design file you PUT yourself, to the url this answers; then import its `uri`.', 'Its MIME type, e.g. `image/vnd.adobe.photoshop`; `application/octet-stream` when you do not know it.');
|
|
116
|
+
}
|
|
93
117
|
const variants = (allowURL ? ['`url` (http/https)'] : [])
|
|
94
118
|
.concat(['`uri` (a saved design)'])
|
|
95
119
|
.concat(demoIds.length > 0 ? ['`demo` (a bundled demo design)'] : [])
|
|
96
|
-
.concat(allowPath ? ['`path` (absolute local file path; Local only)'] : [])
|
|
120
|
+
.concat(allowPath ? ['`path` (absolute local file path; Local only)'] : [])
|
|
121
|
+
.concat(upload ? ['`upload` (a file you send: signs its PUT)'] : []);
|
|
97
122
|
return {
|
|
98
123
|
type: 'object',
|
|
99
124
|
properties: {
|
|
@@ -114,6 +139,23 @@ function buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, templat
|
|
|
114
139
|
additionalProperties: false
|
|
115
140
|
};
|
|
116
141
|
}
|
|
142
|
+
/** The upload arm: checks what the client declared, then signs its PUT; it imports nothing. */
|
|
143
|
+
async function signDesignUpload(sign, upload, mediaAdvice) {
|
|
144
|
+
const checked = checkUpload('import', upload);
|
|
145
|
+
if ('refused' in checked)
|
|
146
|
+
return checked.refused;
|
|
147
|
+
const { name, size, sha256, type } = checked;
|
|
148
|
+
const dot = name.lastIndexOf('.');
|
|
149
|
+
const ext = dot > 0 ? name.slice(dot + 1).toLowerCase() : '';
|
|
150
|
+
if (!DESIGN_UPLOAD_EXTENSIONS.has(ext))
|
|
151
|
+
return errorAnswer(`import: "${name}" is not a design file by its name; \`source.upload.name\` must end in the extension of one. ${SUPPORTED_FORMATS_HINT}${mediaAdvice !== undefined ? ` To make a media file available for use INSIDE a design: ${mediaAdvice}` : ''}`, 'unknown_format', 'source.upload.name');
|
|
152
|
+
if (typeof type !== 'string' || !MIME_TYPE.test(type))
|
|
153
|
+
return errorAnswer(`import: \`source.upload.type\` must be the file's MIME type, such as \`application/pdf\`, or \`application/octet-stream\` (got ${JSON.stringify(type)}).`, 'bad_args', 'source.upload.type');
|
|
154
|
+
const signed = await sign({ ext, size, sha256, name, type });
|
|
155
|
+
return {
|
|
156
|
+
content: [{ type: 'text', text: JSON.stringify(signed) }]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
117
159
|
/** A local path as a `file:` URI, escaped as `pathToFileURL` does; Windows drive paths get a leading slash. */
|
|
118
160
|
function filePathToUri(path) {
|
|
119
161
|
const normalized = path.replace(/\\/g, '/');
|
|
@@ -123,6 +165,19 @@ function filePathToUri(path) {
|
|
|
123
165
|
.replace(/#/g, '%23')
|
|
124
166
|
.replace(/\?/g, '%3F')}`;
|
|
125
167
|
}
|
|
168
|
+
/** A refused source (or path) as its refusal names it: one line of about 100 characters, as a `data:` uri may be megabytes. */
|
|
169
|
+
export function oneLine(source) {
|
|
170
|
+
const chars = Array.from(source.slice(0, 400).replace(/[\s\p{Cc}\p{Cf}]+/gu, ' '));
|
|
171
|
+
return chars.length > 100 || source.length > 400
|
|
172
|
+
? `${chars.slice(0, 100).join('')}…`
|
|
173
|
+
: chars.join('');
|
|
174
|
+
}
|
|
175
|
+
/** The executor's url guard's refusal (`urlRefused` in the SDK's `url-guard.ts`), its reason captured. */
|
|
176
|
+
const URL_REFUSED = / is not fetched: only a public http\(s\) url is \((.*)\)\.$/s;
|
|
177
|
+
/** A host the guard could not look up: a typo or a lookup that failed, said as the failed fetch it is. */
|
|
178
|
+
const UNRESOLVED = /did not resolve|cannot be resolved/;
|
|
179
|
+
/** Why the cloud refuses a source its executor cannot fetch, and the upload that works instead where there is one. */
|
|
180
|
+
export const remoteSourceRefusal = (upload, url = 'an http(s) url') => `this CoDesign server runs in the cloud and takes only ${url}, a demo id or a uri an earlier call answered.${upload ? ' For a design file on your machine, pass `source.upload`: `{ upload: { name, type, size, sha256 } }` answers a url and headers to PUT its bytes to, then import the `uri` it answers.' : ''}`;
|
|
126
181
|
export function createImportTool(opts) {
|
|
127
182
|
const { host, session, state, allowPath = false, demos = {} } = opts;
|
|
128
183
|
const { mediaAdvice } = opts;
|
|
@@ -130,11 +185,25 @@ export function createImportTool(opts) {
|
|
|
130
185
|
const newDesign = opts.newDesign === true;
|
|
131
186
|
const demoIds = Object.keys(demos).sort((a, b) => a.localeCompare(b));
|
|
132
187
|
const imageWarning = imageAsDesignWarning(mediaAdvice);
|
|
188
|
+
const { signUpload } = opts;
|
|
189
|
+
const upload = signUpload !== undefined;
|
|
190
|
+
const sourceKeys = SOURCE_KEYS.filter((key) => key !== 'upload' || upload);
|
|
191
|
+
const arms = [
|
|
192
|
+
...(allowURL ? ['`{ url }`'] : []),
|
|
193
|
+
'`{ uri }`',
|
|
194
|
+
...(allowPath ? ['`{ path }`'] : []),
|
|
195
|
+
...(demoIds.length > 0 ? ['`{ demo }`'] : []),
|
|
196
|
+
...(upload ? ['`{ upload }`'] : [])
|
|
197
|
+
];
|
|
198
|
+
const armList = arms.length === 1
|
|
199
|
+
? arms[0]
|
|
200
|
+
: `${arms.slice(0, -1).join(', ')} or ${arms.at(-1)}`;
|
|
133
201
|
return {
|
|
134
202
|
name: 'import',
|
|
203
|
+
...(demoIds.length > 0 ? { provides: ['import.demo'] } : {}),
|
|
135
204
|
description: newDesign
|
|
136
|
-
? buildNewDesignDescription(demoIds, mediaAdvice, allowURL, allowPath, opts.addressed === true, opts.templates === true)
|
|
137
|
-
: buildDescription(demoIds, mediaAdvice, allowPath),
|
|
205
|
+
? buildNewDesignDescription(demoIds, mediaAdvice, allowURL, allowPath, opts.addressed === true, opts.templates === true, upload)
|
|
206
|
+
: buildDescription(demoIds, mediaAdvice, allowPath, upload),
|
|
138
207
|
// `source` is the argument's key (present on failures); `format` comes from the result JSON.
|
|
139
208
|
telemetryFields: (args, result) => {
|
|
140
209
|
const fields = {};
|
|
@@ -158,28 +227,31 @@ export function createImportTool(opts) {
|
|
|
158
227
|
}
|
|
159
228
|
return Object.keys(fields).length > 0 ? fields : undefined;
|
|
160
229
|
},
|
|
161
|
-
inputSchema: buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, opts.templates === true),
|
|
230
|
+
inputSchema: buildImportInputSchema(allowPath, demoIds, allowURL, newDesign, opts.templates === true, upload),
|
|
162
231
|
call: async (rawArgs, ctx) => {
|
|
163
232
|
const args = (rawArgs ?? {});
|
|
164
233
|
const source = args.source;
|
|
165
234
|
if (source === undefined ||
|
|
166
235
|
typeof source !== 'object' ||
|
|
167
|
-
|
|
168
|
-
return errorAnswer(
|
|
236
|
+
sourceKeys.filter((key) => key in source).length !== 1) {
|
|
237
|
+
return errorAnswer(`import: \`source\` is required — exactly one of ${armList}.` +
|
|
169
238
|
(newDesign
|
|
170
239
|
? ' For an empty design, pass no `source`: `import({ title })`.'
|
|
171
240
|
: ''), 'bad_args', 'source.count');
|
|
172
241
|
}
|
|
242
|
+
if (signUpload !== undefined && 'upload' in source) {
|
|
243
|
+
return signDesignUpload(signUpload, source.upload, mediaAdvice);
|
|
244
|
+
}
|
|
173
245
|
if ('url' in source && !allowURL) {
|
|
174
246
|
return errorAnswer('import: `source.url` is not supported here. Pass the `uri` of a saved design.', 'feature_disabled', 'source.url');
|
|
175
247
|
}
|
|
176
248
|
if ('path' in source && !allowPath) {
|
|
177
249
|
return errorAnswer(`import: \`source.path\` is not supported here — this server cannot read your disk. ${allowURL ? 'Pass a `{ url }` source instead.' : 'Pass the `uri` of a saved design.'}`, 'feature_disabled', 'source.path');
|
|
178
250
|
}
|
|
179
|
-
if ('demo' in source && demos
|
|
251
|
+
if ('demo' in source && !Object.hasOwn(demos, source.demo)) {
|
|
180
252
|
return errorAnswer(demoIds.length === 0
|
|
181
253
|
? 'import: no demo designs are bundled with this server.'
|
|
182
|
-
: `import: unknown demo "${source.demo}". Available: ${demoIds.join(', ')}.`, 'bad_args', 'source.demo');
|
|
254
|
+
: `import: unknown demo "${oneLine(String(source.demo))}". Available: ${demoIds.join(', ')}.`, 'bad_args', 'source.demo');
|
|
183
255
|
}
|
|
184
256
|
// A malformed url is an argument mistake, answered without the host.
|
|
185
257
|
let uri;
|
|
@@ -189,7 +261,7 @@ export function createImportTool(opts) {
|
|
|
189
261
|
parsed = new URL(source.url);
|
|
190
262
|
}
|
|
191
263
|
catch {
|
|
192
|
-
return errorAnswer(`import: invalid URL "${source.url}".`, 'bad_args', 'source.url');
|
|
264
|
+
return errorAnswer(`import: invalid URL "${oneLine(String(source.url))}".`, 'bad_args', 'source.url');
|
|
193
265
|
}
|
|
194
266
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
195
267
|
return errorAnswer('import: `source.url` must be http(s).', 'bad_args', 'source.url.protocol');
|
|
@@ -206,6 +278,8 @@ export function createImportTool(opts) {
|
|
|
206
278
|
uri = `demo:${source.demo}`;
|
|
207
279
|
}
|
|
208
280
|
else {
|
|
281
|
+
if (opts.remote === true)
|
|
282
|
+
return errorAnswer(`import: \`source.path\` is not read here — ${remoteSourceRefusal(upload)}`, 'bad_args', 'source.path.remote');
|
|
209
283
|
if (!isAbsolutePath(source.path)) {
|
|
210
284
|
return errorAnswer(`import: \`source.path\` must be an absolute path (got "${source.path}").`, 'bad_args', 'source.path.relative');
|
|
211
285
|
}
|
|
@@ -223,10 +297,18 @@ export function createImportTool(opts) {
|
|
|
223
297
|
throw err;
|
|
224
298
|
const f = err.failure;
|
|
225
299
|
switch (f.kind) {
|
|
226
|
-
case 'fetch_failed':
|
|
227
|
-
|
|
300
|
+
case 'fetch_failed': {
|
|
301
|
+
const cause = err.cause instanceof Error
|
|
228
302
|
? err.cause.message
|
|
229
|
-
: String(err.cause)
|
|
303
|
+
: String(err.cause);
|
|
304
|
+
// The executor's url guard refused it before any request: not a network failure to retry.
|
|
305
|
+
const why = URL_REFUSED.exec(cause)?.[1];
|
|
306
|
+
if (why !== undefined && !UNRESOLVED.test(why))
|
|
307
|
+
return errorAnswer(`import: "${oneLine(f.source)}" was refused and not fetched: only a public http(s) url is fetched (${why}). ${opts.remote === true
|
|
308
|
+
? `T${remoteSourceRefusal(upload, 'a public http(s) url').slice(1)}`
|
|
309
|
+
: 'Pass a public url instead.'}`, 'bad_args', 'source.refused');
|
|
310
|
+
return errorAnswer(`import: fetching "${f.source}" failed — ${cause}`, 'bad_args', 'source.fetch');
|
|
311
|
+
}
|
|
230
312
|
case 'http_status':
|
|
231
313
|
return errorAnswer(`import: fetching "${f.source}" failed with HTTP ${f.status}.`, 'bad_args', `source.http.${f.status}`);
|
|
232
314
|
case 'response_read_failed':
|
|
@@ -241,6 +323,8 @@ export function createImportTool(opts) {
|
|
|
241
323
|
return errorAnswer(`import: ${unsupportedFormatMessage(f.format, mediaAdvice)}${f.format === 'pack' ? '' : ` ${SUPPORTED_FORMATS_HINT}`}`, 'unknown_format', `format.${f.format}`);
|
|
242
324
|
case 'engine_unsupported_format':
|
|
243
325
|
return errorAnswer(`import: ${f.message}`, 'engine_unsupported', `format.${f.format}`);
|
|
326
|
+
case 'refused':
|
|
327
|
+
return errorAnswer(`import: ${f.text}`, 'bad_args', 'refused');
|
|
244
328
|
case 'not_loadable':
|
|
245
329
|
return errorAnswer(`import: the file is not a loadable design (${f.detail}). ${SUPPORTED_FORMATS_HINT}`, 'unknown_format', 'not_loadable');
|
|
246
330
|
case 'load_failed':
|
|
@@ -261,7 +345,7 @@ export function createImportTool(opts) {
|
|
|
261
345
|
];
|
|
262
346
|
const title = titleArg(args.title) ?? loaded.title;
|
|
263
347
|
if (state !== undefined) {
|
|
264
|
-
state.
|
|
348
|
+
state.designChanged();
|
|
265
349
|
state.title = title;
|
|
266
350
|
}
|
|
267
351
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/catalog/tools/import.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAMhB,QAAQ,EACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAQ3D,8EAA8E;AAC9E,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAO5D,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;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// `import` — load a design file into the current session, replacing it and unbinding the session from its saved design.\n\nimport {\n engineErrorCode,\n isAbsolutePath,\n isCodesignError,\n isProductFailure,\n type DesignHost,\n type HostTool,\n type JSONSchema,\n type SessionId,\n type SessionState,\n titleArg\n} from '@imgly/codesign-sdk/internal';\nimport { errorAnswer } from '@imgly/codesign-sdk/internal';\n\ntype ImportSource =\n | { url: string }\n | { path: string }\n | { demo: string }\n | { uri: string };\n\n/** The source keys, as one list — the \"exactly one of\" check counts these. */\nconst SOURCE_KEYS = ['url', 'path', 'demo', 'uri'] as const;\n\ninterface ImportArgs {\n source: ImportSource;\n title?: string;\n}\n\nconst buildDescription = (\n demoIds: readonly string[],\n mediaAdvice: string | undefined,\n allowPath: boolean\n) =>\n [\n 'Import a design FILE into the design you are working on — a native CE.SDK `.imgly` design file (also the legacy `.scene` and `.zip` forms); a foreign design file: Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`), or PDF; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; or a plain image (PNG/JPEG/WebP/GIF) or SVG, which becomes a one-page design sized to the image (`format`: `\"image\"`/`\"svg\"`). The inverse of `export({ format: \\'imgly\\' })`.' +\n // Only a deployment with a media path advertises one.\n (mediaAdvice === undefined\n ? ''\n : ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),\n '',\n `Source: \\`{ url }\\` (http/https), \\`{ uri }\\` (a \\`uri\\` an earlier save returned)${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\\`\"${id}\"\\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}. Archives are ingested: their bundled asset bytes are stored through this server's asset store, so the loaded design is durable and behaves exactly like a natively-built one.`,\n '',\n 'REPLACES what you are working on: whatever was on the canvas is discarded, and the imported file becomes the current design — continue with `edit`. Importing also detaches you from any design you had saved, so the next `export({ format: \"imgly\" })` writes a NEW design rather than overwriting the file you imported. That is what makes \"save the original, import it back, edit, save the variant\" safe. The one exception is `{ uri }` of the design you are saving into: that reloads its saved version — someone else\\'s changes included — and you keep saving into it.',\n '',\n 'Returns JSON `{ title, format }`. Foreign-format imports may add `warnings` (importer notes about what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`. (Where replacement fonts come from is a deployment question — see `recipes.md` in the `api` skill, \"Fonts\".)'\n ].join('\\n');\n\n/** For a session whose imports each start a new design (the design library's). */\nconst buildNewDesignDescription = (\n demoIds: readonly string[],\n mediaAdvice: string | undefined,\n allowURL: boolean,\n allowPath: boolean,\n addressed = false,\n templates = false\n) =>\n [\n 'Import a design FILE as a NEW design — a CE.SDK `.imgly` design file; a Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`) or PDF file; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; or a plain image or SVG, which becomes a one-page design sized to the image.' +\n (mediaAdvice === undefined\n ? ''\n : ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),\n '',\n `Source: ${allowURL ? '`{ url }` (http/https), ' : ''}\\`{ uri }\\` (a saved design — you get a copy of it — or a file you were given${templates ? ', or a template `asset_search` lists from an installed pack: the new design starts as that template' : ''})${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\\`\"${id}\"\\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}.`,\n '',\n addressed\n ? \"Every import starts a NEW design; the design you were on is left as it is. To work on a saved design itself rather than a copy, pass its `uri` as `design` to the other tools. With only a `title` and no `source` (`import({ title: 'Poster' })`), it starts an empty design.\"\n : \"Every import starts a NEW design, and you work on it from then on: the design you were on is left as it is. To keep working on a saved design itself rather than a copy, use `open` with its `uri`. With only a `title` and no `source` (`import({ title: 'Poster' })`), it starts an empty design: do that for every new design, before you name it or build it.\",\n '',\n (addressed\n ? 'Returns JSON `{ design, version, title, format }` — the new design and its version: pass both to `edit`.'\n : 'Returns JSON `{ uri, title, format }` — the new design, saved after every change; to continue it later, `open` this `uri`.') +\n ' Foreign-format imports may add `warnings` (what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`.'\n ].join('\\n');\n\nconst SUPPORTED_FORMATS_HINT =\n 'Supported: a CE.SDK `.imgly` design file (or legacy `.scene` / `.zip` archive), a Photoshop `.psd`/`.psb`, InDesign `.idml`, PowerPoint `.pptx`, or PDF (`.pdf`) file, a Lottie animation (`.json`/`.lottie`), or a plain image (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`) or SVG (`.svg`).';\n\n// Recognized but not a design: says what the file is; the remedy is the host's `mediaAdvice`.\nconst UNSUPPORTED_FORMATS: Record<\n 'pack' | 'sketch' | 'xd' | 'font' | 'audio' | 'video' | 'unknown',\n string\n> = {\n pack: \"This is an asset pack (`.imglypack`), not a design: install it with `cdsn pack install <file>` or by opening it in the CoDesign app. Its templates then show in `asset_search`, and `import` with a template's `uri` starts a design from it.\",\n sketch: 'Sketch (`.sketch`) files are not supported.',\n xd: 'Adobe XD (`.xd`) files are not supported.',\n font: 'This is a font file — a font cannot become a design.',\n audio: 'This is an audio file — it cannot become a design.',\n video: \"This is a video file — video designs aren't supported yet.\",\n unknown: 'This file is not a design or image this server reads.'\n};\n\n/** Which formats take the deployment's \"bring media in another way\" advice. */\nconst MEDIA_FORMATS: ReadonlySet<string> = new Set(['font', 'audio', 'video']);\n\n/** The message for a format the host refused; an unlisted one gets the neutral sentence. */\nfunction unsupportedFormatMessage(\n format: string,\n mediaAdvice?: string\n): string {\n const base = Object.prototype.hasOwnProperty.call(UNSUPPORTED_FORMATS, format)\n ? UNSUPPORTED_FORMATS[format as keyof typeof UNSUPPORTED_FORMATS]\n : `\\`${format}\\` files cannot become a design.`;\n return mediaAdvice !== undefined && MEDIA_FORMATS.has(format)\n ? `${base} ${mediaAdvice}`\n : base;\n}\n\n// An image may have been meant as media; the warning names the alternative only when the host has one.\nfunction imageAsDesignWarning(mediaAdvice?: string): string | undefined {\n return mediaAdvice === undefined\n ? undefined\n : `Created a one-page design from an image. If you meant to make this image available for use inside a design instead: ${mediaAdvice}`;\n}\n\n// `source` is a flat object, not a `oneOf`: strict tool calling and weaker models break on unions.\nfunction buildImportInputSchema(\n allowPath: boolean,\n demoIds: readonly string[],\n allowURL: boolean,\n newDesign: boolean,\n templates: boolean\n) {\n const sourceProperties: Record<string, JSONSchema> = {};\n if (allowURL) {\n sourceProperties.url = {\n type: 'string' as const,\n description: 'http(s) URL of the design file to load.'\n };\n }\n if (allowPath) {\n sourceProperties.path = {\n type: 'string' as const,\n description: 'Absolute local file path of the design file. Local-only.'\n };\n }\n sourceProperties.uri = {\n type: 'string' as const,\n description: newDesign\n ? `The \\`uri\\` of a saved design (you get a new design that starts as a copy of it)${templates ? ', of a template `asset_search` lists' : ''} or of a file you were given.`\n : 'A `uri` an earlier save returned. The design you are saving into reloads its saved version and you keep saving into it — which discards unsaved edits.'\n };\n if (demoIds.length > 0) {\n sourceProperties.demo = {\n type: 'string' as const,\n enum: [...demoIds],\n description:\n 'Id of a demo design bundled with this server — a finished design to demonstrate on, with no file and no build required.'\n };\n }\n const variants = (allowURL ? ['`url` (http/https)'] : [])\n .concat(['`uri` (a saved design)'])\n .concat(demoIds.length > 0 ? ['`demo` (a bundled demo design)'] : [])\n .concat(allowPath ? ['`path` (absolute local file path; Local only)'] : []);\n return {\n type: 'object' as const,\n properties: {\n source: {\n type: 'object' as const,\n description:\n variants.length === 1\n ? `The design to load. Provide ${variants[0]}.`\n : `The design to load. Provide exactly one of ${variants.join(', ')}.`,\n properties: sourceProperties,\n additionalProperties: false\n },\n title: {\n type: 'string' as const,\n description:\n \"Display name for the design once you save it. Defaults to the source file's basename. Without a `source`, starts an empty design under it.\"\n }\n },\n required: ['source'],\n additionalProperties: false\n };\n}\n\n/** A local path as a `file:` URI, escaped as `pathToFileURL` does; Windows drive paths get a leading slash. */\nfunction filePathToUri(path: string): string {\n const normalized = path.replace(/\\\\/g, '/');\n const rooted = normalized.startsWith('/') ? normalized : `/${normalized}`;\n return `file://${rooted\n .replace(/%/g, '%25')\n .replace(/#/g, '%23')\n .replace(/\\?/g, '%3F')}`;\n}\n\nexport interface CreateImportToolOptions {\n /** The host that resolves the source and owns the engine. */\n host: Pick<DesignHost, 'load'>;\n /** The session this tool set serves, opened once and shared. */\n session: () => Promise<SessionId>;\n /** Judge verdict and title; a successful import clears the verdict and sets the title. */\n state?: SessionState;\n /** Honour a `{ path }` source: the process shares the caller's disk. */\n allowPath?: boolean;\n /** The demo designs, keyed by id; only the ids are read. Omitted or empty: no `demo` arm. */\n demos?: Record<string, unknown>;\n /** How this deployment brings in a non-design file, as one full sentence; omitted ⇒ no advice. */\n mediaAdvice?: string;\n /** Whether to take a `{ url }` source. Default true. */\n allowURL?: boolean;\n /** Every import starts a new design, whose `uri` the host returns. Default false. */\n newDesign?: boolean;\n /** Tools name designs and versions (the stateless tools): the result's `design` and `version` are what to pass on. */\n addressed?: boolean;\n /** A `{ uri }` of an installed pack's template starts a new design from it. */\n templates?: boolean;\n}\n\nexport function createImportTool(opts: CreateImportToolOptions): HostTool {\n const { host, session, state, allowPath = false, demos = {} } = opts;\n const { mediaAdvice } = opts;\n const allowURL = opts.allowURL !== false;\n const newDesign = opts.newDesign === true;\n const demoIds = Object.keys(demos).sort((a, b) => a.localeCompare(b));\n const imageWarning = imageAsDesignWarning(mediaAdvice);\n return {\n name: 'import',\n description: newDesign\n ? buildNewDesignDescription(\n demoIds,\n mediaAdvice,\n allowURL,\n allowPath,\n opts.addressed === true,\n opts.templates === true\n )\n : buildDescription(demoIds, mediaAdvice, allowPath),\n // `source` is the argument's key (present on failures); `format` comes from the result JSON.\n telemetryFields: (args, result) => {\n const fields: Record<string, string> = {};\n const source = (args as { source?: unknown } | null | undefined)?.source;\n if (source && typeof source === 'object') {\n const kind = SOURCE_KEYS.find((key) => key in source);\n if (kind) fields.source = kind;\n }\n try {\n const content = (\n result as { content?: Array<{ text?: unknown }> } | undefined\n )?.content;\n const text = content?.[0]?.text;\n if (typeof text === 'string') {\n const format = (JSON.parse(text) as { format?: unknown }).format;\n if (typeof format === 'string') fields.format = format;\n }\n } catch {\n // an error result is prose, not JSON — `source` still stands alone\n }\n return Object.keys(fields).length > 0 ? fields : undefined;\n },\n inputSchema: buildImportInputSchema(\n allowPath,\n demoIds,\n allowURL,\n newDesign,\n opts.templates === true\n ),\n call: async (rawArgs, ctx) => {\n const args = (rawArgs ?? {}) as Partial<ImportArgs>;\n const source = args.source;\n if (\n source === undefined ||\n typeof source !== 'object' ||\n SOURCE_KEYS.filter((key) => key in source).length !== 1\n ) {\n return errorAnswer(\n 'import: `source` is required — exactly one of `{ url }`, `{ uri }`, `{ path }` or `{ demo }`.' +\n (newDesign\n ? ' For an empty design, pass no `source`: `import({ title })`.'\n : ''),\n 'bad_args',\n 'source.count'\n );\n }\n if ('url' in source && !allowURL) {\n return errorAnswer(\n 'import: `source.url` is not supported here. Pass the `uri` of a saved design.',\n 'feature_disabled',\n 'source.url'\n );\n }\n if ('path' in source && !allowPath) {\n return errorAnswer(\n `import: \\`source.path\\` is not supported here — this server cannot read your disk. ${allowURL ? 'Pass a `{ url }` source instead.' : 'Pass the `uri` of a saved design.'}`,\n 'feature_disabled',\n 'source.path'\n );\n }\n if ('demo' in source && demos[source.demo] === undefined) {\n return errorAnswer(\n demoIds.length === 0\n ? 'import: no demo designs are bundled with this server.'\n : `import: unknown demo \"${source.demo}\". Available: ${demoIds.join(', ')}.`,\n 'bad_args',\n 'source.demo'\n );\n }\n // A malformed url is an argument mistake, answered without the host.\n let uri: string;\n if ('url' in source) {\n let parsed: URL;\n try {\n parsed = new URL(source.url);\n } catch {\n return errorAnswer(\n `import: invalid URL \"${source.url}\".`,\n 'bad_args',\n 'source.url'\n );\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return errorAnswer(\n 'import: `source.url` must be http(s).',\n 'bad_args',\n 'source.url.protocol'\n );\n }\n uri = source.url;\n } else if ('uri' in source) {\n if (typeof source.uri !== 'string' || source.uri === '') {\n return errorAnswer(\n 'import: `source.uri` must be a non-empty string.',\n 'bad_args',\n 'source.uri'\n );\n }\n uri = source.uri;\n } else if ('demo' in source) {\n uri = `demo:${source.demo}`;\n } else {\n if (!isAbsolutePath(source.path)) {\n return errorAnswer(\n `import: \\`source.path\\` must be an absolute path (got \"${source.path}\").`,\n 'bad_args',\n 'source.path.relative'\n );\n }\n uri = filePathToUri(source.path);\n }\n\n const sessionId = await session();\n let loaded;\n try {\n loaded = await (ctx?.signal !== undefined\n ? host.load(sessionId, uri, undefined, ctx.signal)\n : host.load(sessionId, uri));\n } catch (err) {\n if (!isCodesignError(err) || isProductFailure(err)) throw err;\n const f = err.failure;\n switch (f.kind) {\n case 'fetch_failed':\n return errorAnswer(\n `import: fetching \"${f.source}\" failed — ${\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause)\n }`,\n 'bad_args',\n 'source.fetch'\n );\n case 'http_status':\n return errorAnswer(\n `import: fetching \"${f.source}\" failed with HTTP ${f.status}.`,\n 'bad_args',\n `source.http.${f.status}`\n );\n case 'response_read_failed':\n return errorAnswer(\n `import: reading the response body of \"${f.source}\" failed — ${\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause)\n }`,\n 'bad_args',\n 'source.response_read'\n );\n case 'read_failed':\n return errorAnswer(\n `import: reading \"${f.source}\" failed — ${\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause)\n }`,\n 'bad_args',\n 'source.read'\n );\n case 'unsupported_format':\n return errorAnswer(\n `import: ${unsupportedFormatMessage(f.format, mediaAdvice)}${f.format === 'pack' ? '' : ` ${SUPPORTED_FORMATS_HINT}`}`,\n 'unknown_format',\n `format.${f.format}`\n );\n case 'engine_unsupported_format':\n return errorAnswer(\n `import: ${f.message}`,\n 'engine_unsupported',\n `format.${f.format}`\n );\n case 'not_loadable':\n return errorAnswer(\n `import: the file is not a loadable design (${f.detail}). ${SUPPORTED_FORMATS_HINT}`,\n 'unknown_format',\n 'not_loadable'\n );\n case 'load_failed':\n return errorAnswer(\n `import: ${err.detail}`,\n 'internal_error',\n engineErrorCode(err.cause) ?? 'load_failed',\n err\n );\n case 'checkpoint_failed':\n return errorAnswer(\n `import: the file loaded but could not be stored as a design, so nothing was imported and you are still on the design you were on. ${err.detail}`,\n 'internal_error',\n 'checkpoint_failed',\n err\n );\n default:\n throw err;\n }\n }\n\n // An image import still succeeds; the warning keeps a media-meant call from passing silently.\n const warnings = [\n ...(imageWarning !== undefined &&\n (loaded.format === 'image' || loaded.format === 'svg')\n ? [imageWarning]\n : []),\n ...(loaded.warnings ?? [])\n ];\n const title = titleArg(args.title) ?? loaded.title;\n if (state !== undefined) {\n state.contentChanged();\n state.title = title;\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n ...(loaded.uri !== undefined ? { uri: loaded.uri } : {}),\n title: title ?? 'Untitled',\n format: loaded.format,\n ...(warnings.length > 0 ? { warnings } : {})\n })\n }\n ]\n };\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/catalog/tools/import.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAOhB,QAAQ,EACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAQxB,8EAA8E;AAC9E,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAC;AAEtE,2HAA2H;AAC3H,MAAM,iBAAiB,GAAG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wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;4BACnB,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;4BACxD,KAAK,EAAE,KAAK,IAAI,UAAU;4BAC1B,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC7C,CAAC;qBACH;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// `import` — load a design file into the current session, replacing it and unbinding the session from its saved design.\n\nimport {\n engineErrorCode,\n FIG_CANVAS_MESSAGE,\n isAbsolutePath,\n isCodesignError,\n isProductFailure,\n type DesignHost,\n type HostTool,\n type ImportFormat,\n type JSONSchema,\n type SessionId,\n type SessionState,\n titleArg\n} from '@imgly/codesign-sdk/internal';\nimport { errorAnswer } from '@imgly/codesign-sdk/internal';\nimport {\n checkUpload,\n uploadSchema,\n type AssetUploadSigner\n} from './asset-add.js';\n\ntype ImportSource =\n | { url: string }\n | { path: string }\n | { demo: string }\n | { uri: string };\n\n/** The source keys, as one list — the \"exactly one of\" check counts these. */\nconst SOURCE_KEYS = ['url', 'path', 'demo', 'uri', 'upload'] as const;\n\n/** The file names the upload arm signs, by the format the load then sniffs from the bytes: every format `import` opens. */\nconst UPLOAD_EXTENSIONS = {\n archive: ['imgly', 'zip'],\n scene: ['scene'],\n image: ['png', 'jpg', 'jpeg', 'webp', 'gif'],\n svg: ['svg'],\n psd: ['psd', 'psb'],\n idml: ['idml'],\n pptx: ['pptx'],\n pdf: ['pdf'],\n lottie: ['json', 'lottie'],\n fig: ['fig']\n} satisfies Record<ImportFormat, readonly string[]>;\n\nexport const DESIGN_UPLOAD_EXTENSIONS: ReadonlySet<string> = new Set(\n Object.values(UPLOAD_EXTENSIONS).flat()\n);\n\n/** A MIME type's shape: the arm signs it as the PUT's Content-Type. */\nconst MIME_TYPE = /^[A-Za-z0-9][\\w.+-]*\\/[A-Za-z0-9][\\w.+-]*$/;\n\nconst UPLOAD_ADVICE =\n \"Or `{ upload: { name, type, size, sha256 } }` for a design file on your side: it imports nothing yet and answers `{ uri, url, headers, expiresAt }`; PUT the file's bytes to `url` with exactly `headers` before `expiresAt`, then import `{ uri }`, once: a successful import removes the upload.\";\n\ninterface ImportArgs {\n source: ImportSource;\n title?: string;\n}\n\nconst buildDescription = (\n demoIds: readonly string[],\n mediaAdvice: string | undefined,\n allowPath: boolean,\n upload = false\n) =>\n [\n 'Import a design FILE into the design you are working on — a native CE.SDK `.imgly` design file (also the legacy `.scene` and `.zip` forms); a foreign design file: Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`), or PDF; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; a Figma file (`.fig`), whose first canvas becomes the design, a page for each top-level frame and one more for what lies outside the frames (the warnings name any other canvases); or a plain image (PNG/JPEG/WebP/GIF) or SVG, which becomes a one-page design sized to the image (`format`: `\"image\"`/`\"svg\"`). The inverse of `export({ format: \\'imgly\\' })`.' +\n // Only a deployment with a media path advertises one.\n (mediaAdvice === undefined\n ? ''\n : ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),\n '',\n `Source: \\`{ url }\\` (http/https), \\`{ uri }\\` (a \\`uri\\` an earlier save returned)${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\\`\"${id}\"\\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}. Archives are ingested: their bundled asset bytes are stored through this server's asset store, so the loaded design is durable and behaves exactly like a natively-built one.`,\n ...(upload ? [UPLOAD_ADVICE] : []),\n '',\n 'REPLACES what you are working on: whatever was on the canvas is discarded, and the imported file becomes the current design — continue with `edit`. Importing also detaches you from any design you had saved, so the next `export({ format: \"imgly\" })` writes a NEW design rather than overwriting the file you imported. That is what makes \"save the original, import it back, edit, save the variant\" safe. The one exception is `{ uri }` of the design you are saving into: that reloads its saved version — someone else\\'s changes included — and you keep saving into it.',\n '',\n 'Returns JSON `{ title, format }`. Foreign-format imports may add `warnings` (importer notes about what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`. (Where replacement fonts come from is a deployment question — see `recipes.md` in the `api` skill, \"Fonts\".)'\n ].join('\\n');\n\n/** For a session whose imports each start a new design (the design library's). */\nconst buildNewDesignDescription = (\n demoIds: readonly string[],\n mediaAdvice: string | undefined,\n allowURL: boolean,\n allowPath: boolean,\n addressed = false,\n templates = false,\n upload = false\n) =>\n [\n 'Import a design FILE as a NEW design — a CE.SDK `.imgly` design file; a Photoshop (`.psd`/`.psb`), InDesign (`.idml`), PowerPoint (`.pptx`) or PDF file; a Lottie animation (`.json`/`.lottie`), which becomes a one-page video design with editable, keyframed layers; a Figma file (`.fig`), whose first canvas becomes the design, a page for each top-level frame and one more for what lies outside the frames (the warnings name any other canvases); or a plain image or SVG, which becomes a one-page design sized to the image.' +\n (mediaAdvice === undefined\n ? ''\n : ` To make a media file (image/font/video/audio) available for use INSIDE a design instead of becoming one: ${mediaAdvice}`),\n '',\n `Source: ${allowURL ? '`{ url }` (http/https), ' : ''}\\`{ uri }\\` (a saved design — you get a copy of it — or a file you were given${templates ? ', or a template `asset_search` lists from an installed pack: the new design starts as that template' : ''})${demoIds.length > 0 ? ', `{ demo }` (a design bundled with this server — ids: ' + demoIds.map((id) => `\\`\"${id}\"\\``).join(', ') + ')' : ''}${allowPath ? ' or `{ path }` (absolute local file path)' : ''}.`,\n ...(upload ? [UPLOAD_ADVICE] : []),\n '',\n addressed\n ? \"Every import starts a NEW design; the design you were on is left as it is. To work on a saved design itself rather than a copy, pass its `uri` as `design` to the other tools. With only a `title` and no `source` (`import({ title: 'Poster' })`), it starts an empty design.\"\n : \"Every import starts a NEW design, and you work on it from then on: the design you were on is left as it is. To keep working on a saved design itself rather than a copy, use `open` with its `uri`. With only a `title` and no `source` (`import({ title: 'Poster' })`), it starts an empty design: do that for every new design, before you name it or build it.\",\n '',\n (addressed\n ? 'Returns JSON `{ design, version, title, format }` — the new design and its version: pass both to `edit`.'\n : 'Returns JSON `{ uri, title, format }` — the new design, saved after every change; to continue it later, `open` this `uri`.') +\n ' Foreign-format imports may add `warnings` (what did not survive — substituted fonts, unsupported features): treat them as your touch-up list — `preview` the pages, then repair with `edit`.'\n ].join('\\n');\n\nconst SUPPORTED_FORMATS_HINT =\n 'Supported: a CE.SDK `.imgly` design file (or legacy `.scene` / `.zip` archive), a Photoshop `.psd`/`.psb`, InDesign `.idml`, PowerPoint `.pptx`, or PDF (`.pdf`) file, a Lottie animation (`.json`/`.lottie`), a Figma `.fig` file, or a plain image (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`) or SVG (`.svg`).';\n\n// Recognized but not a design: says what the file is; the remedy is the host's `mediaAdvice`.\nconst UNSUPPORTED_FORMATS: Record<\n | 'pack'\n | 'sketch'\n | 'xd'\n | 'fig-canvas'\n | 'font'\n | 'audio'\n | 'video'\n | 'unknown',\n string\n> = {\n pack: \"This is an asset pack (`.imglypack`), not a design: the user adds it by opening it in the CoDesign app, or with `cdsn pack install <file>`. Its templates then become the workspace's own designs and its styles saved styles.\",\n sketch: 'Sketch (`.sketch`) files are not supported.',\n xd: 'Adobe XD (`.xd`) files are not supported.',\n 'fig-canvas': FIG_CANVAS_MESSAGE,\n font: 'This is a font file — a font cannot become a design.',\n audio: 'This is an audio file — it cannot become a design.',\n video: \"This is a video file — video designs aren't supported yet.\",\n unknown: 'This file is not a design or image this server reads.'\n};\n\n/** Which formats take the deployment's \"bring media in another way\" advice. */\nconst MEDIA_FORMATS: ReadonlySet<string> = new Set(['font', 'audio', 'video']);\n\n/** The message for a format the host refused; an unlisted one gets the neutral sentence. */\nfunction unsupportedFormatMessage(\n format: string,\n mediaAdvice?: string\n): string {\n const base = Object.prototype.hasOwnProperty.call(UNSUPPORTED_FORMATS, format)\n ? UNSUPPORTED_FORMATS[format as keyof typeof UNSUPPORTED_FORMATS]\n : `\\`${format}\\` files cannot become a design.`;\n return mediaAdvice !== undefined && MEDIA_FORMATS.has(format)\n ? `${base} ${mediaAdvice}`\n : base;\n}\n\n// An image may have been meant as media; the warning names the alternative only when the host has one.\nfunction imageAsDesignWarning(mediaAdvice?: string): string | undefined {\n return mediaAdvice === undefined\n ? undefined\n : `Created a one-page design from an image. If you meant to make this image available for use inside a design instead: ${mediaAdvice}`;\n}\n\n// `source` is a flat object, not a `oneOf`: strict tool calling and weaker models break on unions.\nfunction buildImportInputSchema(\n allowPath: boolean,\n demoIds: readonly string[],\n allowURL: boolean,\n newDesign: boolean,\n templates: boolean,\n upload: boolean\n) {\n const sourceProperties: Record<string, JSONSchema> = {};\n if (allowURL) {\n sourceProperties.url = {\n type: 'string' as const,\n description: 'http(s) URL of the design file to load.'\n };\n }\n if (allowPath) {\n sourceProperties.path = {\n type: 'string' as const,\n description: 'Absolute local file path of the design file. Local-only.'\n };\n }\n sourceProperties.uri = {\n type: 'string' as const,\n description: newDesign\n ? `The \\`uri\\` of a saved design (you get a new design that starts as a copy of it)${templates ? ', of a template `asset_search` lists' : ''} or of a file you were given.`\n : 'A `uri` an earlier save returned. The design you are saving into reloads its saved version and you keep saving into it — which discards unsaved edits.'\n };\n if (demoIds.length > 0) {\n sourceProperties.demo = {\n type: 'string' as const,\n enum: [...demoIds],\n description:\n 'Id of a demo design bundled with this server — a finished design to demonstrate on, with no file and no build required.'\n };\n }\n if (upload) {\n sourceProperties.upload = uploadSchema(\n 'A design file you PUT yourself, to the url this answers; then import its `uri`.',\n 'Its MIME type, e.g. `image/vnd.adobe.photoshop`; `application/octet-stream` when you do not know it.'\n );\n }\n const variants = (allowURL ? ['`url` (http/https)'] : [])\n .concat(['`uri` (a saved design)'])\n .concat(demoIds.length > 0 ? ['`demo` (a bundled demo design)'] : [])\n .concat(allowPath ? ['`path` (absolute local file path; Local only)'] : [])\n .concat(upload ? ['`upload` (a file you send: signs its PUT)'] : []);\n return {\n type: 'object' as const,\n properties: {\n source: {\n type: 'object' as const,\n description:\n variants.length === 1\n ? `The design to load. Provide ${variants[0]}.`\n : `The design to load. Provide exactly one of ${variants.join(', ')}.`,\n properties: sourceProperties,\n additionalProperties: false\n },\n title: {\n type: 'string' as const,\n description:\n \"Display name for the design once you save it. Defaults to the source file's basename. Without a `source`, starts an empty design under it.\"\n }\n },\n required: ['source'],\n additionalProperties: false\n };\n}\n\n/** The upload arm: checks what the client declared, then signs its PUT; it imports nothing. */\nasync function signDesignUpload(\n sign: AssetUploadSigner,\n upload: unknown,\n mediaAdvice: string | undefined\n) {\n const checked = checkUpload('import', upload);\n if ('refused' in checked) return checked.refused;\n const { name, size, sha256, type } = checked;\n const dot = name.lastIndexOf('.');\n const ext = dot > 0 ? name.slice(dot + 1).toLowerCase() : '';\n if (!DESIGN_UPLOAD_EXTENSIONS.has(ext))\n return errorAnswer(\n `import: \"${name}\" is not a design file by its name; \\`source.upload.name\\` must end in the extension of one. ${SUPPORTED_FORMATS_HINT}${mediaAdvice !== undefined ? ` To make a media file available for use INSIDE a design: ${mediaAdvice}` : ''}`,\n 'unknown_format',\n 'source.upload.name'\n );\n if (typeof type !== 'string' || !MIME_TYPE.test(type))\n return errorAnswer(\n `import: \\`source.upload.type\\` must be the file's MIME type, such as \\`application/pdf\\`, or \\`application/octet-stream\\` (got ${JSON.stringify(type)}).`,\n 'bad_args',\n 'source.upload.type'\n );\n const signed = await sign({ ext, size, sha256, name, type });\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(signed) }]\n };\n}\n\n/** A local path as a `file:` URI, escaped as `pathToFileURL` does; Windows drive paths get a leading slash. */\nfunction filePathToUri(path: string): string {\n const normalized = path.replace(/\\\\/g, '/');\n const rooted = normalized.startsWith('/') ? normalized : `/${normalized}`;\n return `file://${rooted\n .replace(/%/g, '%25')\n .replace(/#/g, '%23')\n .replace(/\\?/g, '%3F')}`;\n}\n\nexport interface CreateImportToolOptions {\n /** The host that resolves the source and owns the engine. */\n host: Pick<DesignHost, 'load'>;\n /** The session this tool set serves, opened once and shared. */\n session: () => Promise<SessionId>;\n /** Judge verdict and title; a successful import clears the verdict and sets the title. */\n state?: SessionState;\n /** Honour a `{ path }` source: the process shares the caller's disk. */\n allowPath?: boolean;\n /** Runs away from the caller's machine (CoDesign Cloud): `{ path }` is refused, whatever it names. */\n remote?: boolean;\n /** The demo designs, keyed by id; only the ids are read. Omitted or empty: no `demo` arm. */\n demos?: Record<string, unknown>;\n /** How this deployment brings in a non-design file, as one full sentence; omitted ⇒ no advice. */\n mediaAdvice?: string;\n /** Whether to take a `{ url }` source. Default true. */\n allowURL?: boolean;\n /** Every import starts a new design, whose `uri` the host returns. Default false. */\n newDesign?: boolean;\n /** Tools name designs and versions (the stateless tools): the result's `design` and `version` are what to pass on. */\n addressed?: boolean;\n /** A `{ uri }` of an installed pack's template starts a new design from it. */\n templates?: boolean;\n /** The cloud's: the `upload` arm, a presigned PUT of a design file into the workspace, which `{ uri }` then imports. */\n signUpload?: AssetUploadSigner;\n}\n\n/** A refused source (or path) as its refusal names it: one line of about 100 characters, as a `data:` uri may be megabytes. */\nexport function oneLine(source: string): string {\n const chars = Array.from(\n source.slice(0, 400).replace(/[\\s\\p{Cc}\\p{Cf}]+/gu, ' ')\n );\n return chars.length > 100 || source.length > 400\n ? `${chars.slice(0, 100).join('')}…`\n : chars.join('');\n}\n\n/** The executor's url guard's refusal (`urlRefused` in the SDK's `url-guard.ts`), its reason captured. */\nconst URL_REFUSED =\n / is not fetched: only a public http\\(s\\) url is \\((.*)\\)\\.$/s;\n/** A host the guard could not look up: a typo or a lookup that failed, said as the failed fetch it is. */\nconst UNRESOLVED = /did not resolve|cannot be resolved/;\n\n/** Why the cloud refuses a source its executor cannot fetch, and the upload that works instead where there is one. */\nexport const remoteSourceRefusal = (\n upload: boolean,\n url = 'an http(s) url'\n): string =>\n `this CoDesign server runs in the cloud and takes only ${url}, a demo id or a uri an earlier call answered.${upload ? ' For a design file on your machine, pass `source.upload`: `{ upload: { name, type, size, sha256 } }` answers a url and headers to PUT its bytes to, then import the `uri` it answers.' : ''}`;\n\nexport function createImportTool(opts: CreateImportToolOptions): HostTool {\n const { host, session, state, allowPath = false, demos = {} } = opts;\n const { mediaAdvice } = opts;\n const allowURL = opts.allowURL !== false;\n const newDesign = opts.newDesign === true;\n const demoIds = Object.keys(demos).sort((a, b) => a.localeCompare(b));\n const imageWarning = imageAsDesignWarning(mediaAdvice);\n const { signUpload } = opts;\n const upload = signUpload !== undefined;\n const sourceKeys = SOURCE_KEYS.filter((key) => key !== 'upload' || upload);\n const arms = [\n ...(allowURL ? ['`{ url }`'] : []),\n '`{ uri }`',\n ...(allowPath ? ['`{ path }`'] : []),\n ...(demoIds.length > 0 ? ['`{ demo }`'] : []),\n ...(upload ? ['`{ upload }`'] : [])\n ];\n const armList =\n arms.length === 1\n ? arms[0]!\n : `${arms.slice(0, -1).join(', ')} or ${arms.at(-1)!}`;\n return {\n name: 'import',\n ...(demoIds.length > 0 ? { provides: ['import.demo'] } : {}),\n description: newDesign\n ? buildNewDesignDescription(\n demoIds,\n mediaAdvice,\n allowURL,\n allowPath,\n opts.addressed === true,\n opts.templates === true,\n upload\n )\n : buildDescription(demoIds, mediaAdvice, allowPath, upload),\n // `source` is the argument's key (present on failures); `format` comes from the result JSON.\n telemetryFields: (args, result) => {\n const fields: Record<string, string> = {};\n const source = (args as { source?: unknown } | null | undefined)?.source;\n if (source && typeof source === 'object') {\n const kind = SOURCE_KEYS.find((key) => key in source);\n if (kind) fields.source = kind;\n }\n try {\n const content = (\n result as { content?: Array<{ text?: unknown }> } | undefined\n )?.content;\n const text = content?.[0]?.text;\n if (typeof text === 'string') {\n const format = (JSON.parse(text) as { format?: unknown }).format;\n if (typeof format === 'string') fields.format = format;\n }\n } catch {\n // an error result is prose, not JSON — `source` still stands alone\n }\n return Object.keys(fields).length > 0 ? fields : undefined;\n },\n inputSchema: buildImportInputSchema(\n allowPath,\n demoIds,\n allowURL,\n newDesign,\n opts.templates === true,\n upload\n ),\n call: async (rawArgs, ctx) => {\n const args = (rawArgs ?? {}) as Partial<ImportArgs>;\n const source = args.source;\n if (\n source === undefined ||\n typeof source !== 'object' ||\n sourceKeys.filter((key) => key in source).length !== 1\n ) {\n return errorAnswer(\n `import: \\`source\\` is required — exactly one of ${armList}.` +\n (newDesign\n ? ' For an empty design, pass no `source`: `import({ title })`.'\n : ''),\n 'bad_args',\n 'source.count'\n );\n }\n if (signUpload !== undefined && 'upload' in source) {\n return signDesignUpload(signUpload, source.upload, mediaAdvice);\n }\n if ('url' in source && !allowURL) {\n return errorAnswer(\n 'import: `source.url` is not supported here. Pass the `uri` of a saved design.',\n 'feature_disabled',\n 'source.url'\n );\n }\n if ('path' in source && !allowPath) {\n return errorAnswer(\n `import: \\`source.path\\` is not supported here — this server cannot read your disk. ${allowURL ? 'Pass a `{ url }` source instead.' : 'Pass the `uri` of a saved design.'}`,\n 'feature_disabled',\n 'source.path'\n );\n }\n if ('demo' in source && !Object.hasOwn(demos, source.demo)) {\n return errorAnswer(\n demoIds.length === 0\n ? 'import: no demo designs are bundled with this server.'\n : `import: unknown demo \"${oneLine(String(source.demo))}\". Available: ${demoIds.join(', ')}.`,\n 'bad_args',\n 'source.demo'\n );\n }\n // A malformed url is an argument mistake, answered without the host.\n let uri: string;\n if ('url' in source) {\n let parsed: URL;\n try {\n parsed = new URL(source.url);\n } catch {\n return errorAnswer(\n `import: invalid URL \"${oneLine(String(source.url))}\".`,\n 'bad_args',\n 'source.url'\n );\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return errorAnswer(\n 'import: `source.url` must be http(s).',\n 'bad_args',\n 'source.url.protocol'\n );\n }\n uri = source.url;\n } else if ('uri' in source) {\n if (typeof source.uri !== 'string' || source.uri === '') {\n return errorAnswer(\n 'import: `source.uri` must be a non-empty string.',\n 'bad_args',\n 'source.uri'\n );\n }\n uri = source.uri;\n } else if ('demo' in source) {\n uri = `demo:${source.demo}`;\n } else {\n if (opts.remote === true)\n return errorAnswer(\n `import: \\`source.path\\` is not read here — ${remoteSourceRefusal(upload)}`,\n 'bad_args',\n 'source.path.remote'\n );\n if (!isAbsolutePath(source.path)) {\n return errorAnswer(\n `import: \\`source.path\\` must be an absolute path (got \"${source.path}\").`,\n 'bad_args',\n 'source.path.relative'\n );\n }\n uri = filePathToUri(source.path);\n }\n\n const sessionId = await session();\n let loaded;\n try {\n loaded = await (ctx?.signal !== undefined\n ? host.load(sessionId, uri, undefined, ctx.signal)\n : host.load(sessionId, uri));\n } catch (err) {\n if (!isCodesignError(err) || isProductFailure(err)) throw err;\n const f = err.failure;\n switch (f.kind) {\n case 'fetch_failed': {\n const cause =\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause);\n // The executor's url guard refused it before any request: not a network failure to retry.\n const why = URL_REFUSED.exec(cause)?.[1];\n if (why !== undefined && !UNRESOLVED.test(why))\n return errorAnswer(\n `import: \"${oneLine(f.source)}\" was refused and not fetched: only a public http(s) url is fetched (${why}). ${\n opts.remote === true\n ? `T${remoteSourceRefusal(upload, 'a public http(s) url').slice(1)}`\n : 'Pass a public url instead.'\n }`,\n 'bad_args',\n 'source.refused'\n );\n return errorAnswer(\n `import: fetching \"${f.source}\" failed — ${cause}`,\n 'bad_args',\n 'source.fetch'\n );\n }\n case 'http_status':\n return errorAnswer(\n `import: fetching \"${f.source}\" failed with HTTP ${f.status}.`,\n 'bad_args',\n `source.http.${f.status}`\n );\n case 'response_read_failed':\n return errorAnswer(\n `import: reading the response body of \"${f.source}\" failed — ${\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause)\n }`,\n 'bad_args',\n 'source.response_read'\n );\n case 'read_failed':\n return errorAnswer(\n `import: reading \"${f.source}\" failed — ${\n err.cause instanceof Error\n ? err.cause.message\n : String(err.cause)\n }`,\n 'bad_args',\n 'source.read'\n );\n case 'unsupported_format':\n return errorAnswer(\n `import: ${unsupportedFormatMessage(f.format, mediaAdvice)}${f.format === 'pack' ? '' : ` ${SUPPORTED_FORMATS_HINT}`}`,\n 'unknown_format',\n `format.${f.format}`\n );\n case 'engine_unsupported_format':\n return errorAnswer(\n `import: ${f.message}`,\n 'engine_unsupported',\n `format.${f.format}`\n );\n case 'refused':\n return errorAnswer(`import: ${f.text}`, 'bad_args', 'refused');\n case 'not_loadable':\n return errorAnswer(\n `import: the file is not a loadable design (${f.detail}). ${SUPPORTED_FORMATS_HINT}`,\n 'unknown_format',\n 'not_loadable'\n );\n case 'load_failed':\n return errorAnswer(\n `import: ${err.detail}`,\n 'internal_error',\n engineErrorCode(err.cause) ?? 'load_failed',\n err\n );\n case 'checkpoint_failed':\n return errorAnswer(\n `import: the file loaded but could not be stored as a design, so nothing was imported and you are still on the design you were on. ${err.detail}`,\n 'internal_error',\n 'checkpoint_failed',\n err\n );\n default:\n throw err;\n }\n }\n\n // An image import still succeeds; the warning keeps a media-meant call from passing silently.\n const warnings = [\n ...(imageWarning !== undefined &&\n (loaded.format === 'image' || loaded.format === 'svg')\n ? [imageWarning]\n : []),\n ...(loaded.warnings ?? [])\n ];\n const title = titleArg(args.title) ?? loaded.title;\n if (state !== undefined) {\n state.designChanged();\n state.title = title;\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n ...(loaded.uri !== undefined ? { uri: loaded.uri } : {}),\n title: title ?? 'Untitled',\n format: loaded.format,\n ...(warnings.length > 0 ? { warnings } : {})\n })\n }\n ]\n };\n }\n };\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { runtimeHome, runtimePaths } from '@imgly/codesign-router/paths.js';
|
|
4
4
|
import { addServer, listServers, removeServer, setServer } from '../connectors/config.js';
|
|
5
5
|
import { startSignIn } from '../connectors/oauth.js';
|
|
6
|
-
import { credentialStoreFor } from '../credentials/
|
|
6
|
+
import { credentialStoreFor } from '../credentials/keychain.js';
|
|
7
7
|
import { openBrowser } from '../services/auth/browser.js';
|
|
8
8
|
export const summary = 'your MCP servers in chats: list, add, remove, enable, disable, signin';
|
|
9
9
|
const USAGE = `Usage: cdsn connectors <command>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../../src/cli/connectors.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,2FAA2F;AAE3F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAM5E,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,CAAC,MAAM,OAAO,GAClB,uEAAuE,CAAC;AAE1E,MAAM,KAAK,GAAG;;;;;;;;;;CAUb,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,GAAG,MAAM,CAAC;AASlC,MAAM,UAAW,SAAQ,KAAK;CAAG;AAEjC,qEAAqE;AACrE,SAAS,KAAK,CAAC,IAAc;IAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,IAAI,GAAG,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CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxE,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","sourcesContent":["// `cdsn connectors`: the user's MCP servers in ~/.codesign/mcp.json, which chats offer the agent through the\n// server's gate. A file edit in this process: a chat reads the file when its agent starts.\n\nimport { runtimeHome, runtimePaths } from '@imgly/codesign-router/paths.js';\nimport type {\n UserServerAddParams,\n UserServerInfo\n} from '@imgly/codesign-router/protocol/types.js';\n\nimport {\n addServer,\n listServers,\n removeServer,\n setServer\n} from '../connectors/config.js';\nimport { startSignIn } from '../connectors/oauth.js';\nimport { credentialStoreFor } from '../credentials/token-store.js';\nimport { openBrowser } from '../services/auth/browser.js';\n\nexport const summary =\n 'your MCP servers in chats: list, add, remove, enable, disable, signin';\n\nconst USAGE = `Usage: cdsn connectors <command>\n list [--json] your MCP servers and their state\n add <name> [--env NAME=value]… -- <command> [args…]\n a server that runs a command, with your permissions\n add <name> --url <url> [--header 'Name: value']… [--sign-in now|when-needed]\n [--client-id <id> [--client-secret <secret>]]\n a remote server; header and env values go to the keychain\n remove <name>\n enable <name> | disable <name>\n signin <name> [--no-browser] sign in to a server that uses OAuth\n`;\n\nconst SIGNIN_WAIT_MS = 5 * 60_000;\n\nexport interface ConnectorsDeps {\n home?: string;\n stdout?: (text: string) => void;\n stderr?: (text: string) => void;\n openBrowser?: (url: string) => Promise<boolean>;\n}\n\nclass UsageError extends Error {}\n\n/** `--flag value` pairs before `--`, the repeated ones collected. */\nfunction parse(args: string[]) {\n const end = args.indexOf('--');\n const head = end === -1 ? args : args.slice(0, end);\n const command = end === -1 ? undefined : args.slice(end + 1);\n const flags = new Map<string, string[]>();\n const positional: string[] = [];\n for (let i = 0; i < head.length; i++) {\n const arg = head[i]!;\n if (!arg.startsWith('--')) positional.push(arg);\n else if (arg === '--json' || arg === '--no-browser') flags.set(arg, ['']);\n else {\n const value = head[++i];\n if (value === undefined) throw new UsageError(`${arg} needs a value`);\n flags.set(arg, [...(flags.get(arg) ?? []), value]);\n }\n }\n return { positional, command, flags, one: (f: string) => flags.get(f)?.[0] };\n}\n\nfunction pairs(values: string[] | undefined, sep: string) {\n const out: Record<string, string> = {};\n for (const v of values ?? []) {\n const at = v.indexOf(sep);\n if (at <= 0) throw new UsageError(`${v} is not NAME${sep.trim()}value`);\n out[v.slice(0, at).trim()] = v.slice(at + sep.length).trim();\n }\n return out;\n}\n\nfunction addParams(\n name: string,\n p: ReturnType<typeof parse>\n): Omit<UserServerAddParams, 'channel'> {\n const url = p.one('--url');\n const signIn = p.one('--sign-in');\n if (signIn !== undefined && signIn !== 'now' && signIn !== 'when-needed')\n throw new UsageError('--sign-in is now or when-needed');\n const clientId = p.one('--client-id');\n const clientSecret = p.one('--client-secret');\n if (url !== undefined) {\n return {\n name,\n server: { type: 'http', url },\n secrets: pairs(p.flags.get('--header'), ':'),\n ...(signIn !== undefined && { signIn }),\n ...(clientId !== undefined && {\n oauthClient: {\n clientId,\n ...(clientSecret !== undefined && { clientSecret })\n }\n })\n };\n }\n const [command, ...args] = p.command ?? [];\n if (command === undefined)\n throw new UsageError('add needs --url or -- <command>');\n return {\n name,\n server: { type: 'stdio', command, ...(args.length > 0 && { args }) },\n secrets: pairs(p.flags.get('--env'), '=')\n };\n}\n\nconst where = (s: UserServerInfo) =>\n s.server.type === 'http'\n ? s.server.url\n : [s.server.command, ...(s.server.args ?? [])].join(' ');\n\nconst STATE = {\n ready: 'on',\n disabled: 'off',\n needs_signin: 'needs sign-in'\n} as const;\n\nexport async function run(\n argv: string[],\n deps: ConnectorsDeps = {}\n): Promise<number> {\n const out = deps.stdout ?? ((text) => void process.stdout.write(text));\n const err = deps.stderr ?? ((text) => void process.stderr.write(text));\n const paths = runtimePaths(deps.home ?? runtimeHome());\n const files = { mcpJson: paths.mcpJson, credentials: paths.credentials };\n const store = credentialStoreFor(paths.credentials);\n const browse = deps.openBrowser ?? openBrowser;\n\n const signIn = async (name: string, browser: boolean) => {\n const { url, done } = await startSignIn(files, store, name);\n out(`Sign in to ${name} in your browser:\\n ${url}\\n`);\n if (browser) await browse(url);\n let timer: NodeJS.Timeout | undefined;\n await Promise.race([\n done,\n new Promise((_, reject) => {\n timer = setTimeout(\n () => reject(new Error('the sign-in timed out')),\n SIGNIN_WAIT_MS\n );\n })\n ]).finally(() => clearTimeout(timer));\n out(`Signed in to ${name}.\\n`);\n };\n\n try {\n const [command, ...rest] = argv;\n const p = parse(rest);\n const name = p.positional[0];\n switch (command) {\n case 'list': {\n const servers = await listServers(files, store);\n if (p.flags.has('--json')) out(`${JSON.stringify(servers)}\\n`);\n else if (servers.length === 0) out('No MCP servers.\\n');\n else\n for (const s of servers)\n out(\n `${s.name.padEnd(20)}${STATE[s.state].padEnd(15)}${where(s)}\\n`\n );\n return 0;\n }\n case 'add': {\n if (name === undefined) throw new UsageError('add needs a name');\n const info = await addServer(files, store, addParams(name, p));\n out(`Added ${name}.\\n`);\n if (info.server.type === 'stdio')\n out(\n `Chats start \\`${where(info)}\\` with your permissions while ${name} is on.\\n`\n );\n if (info.signIn === 'now') await signIn(name, true);\n return 0;\n }\n case 'remove':\n if (name === undefined) throw new UsageError('remove needs a name');\n await removeServer(files, store, name);\n out(`Removed ${name}.\\n`);\n return 0;\n case 'enable':\n case 'disable':\n if (name === undefined) throw new UsageError(`${command} needs a name`);\n await setServer(files, store, name, {\n enabled: command === 'enable'\n });\n out(`${name} is ${command === 'enable' ? 'on' : 'off'}.\\n`);\n return 0;\n case 'signin':\n if (name === undefined) throw new UsageError('signin needs a name');\n await signIn(name, !p.flags.has('--no-browser'));\n return 0;\n default:\n throw new UsageError('');\n }\n } catch (e) {\n if (e instanceof UsageError) {\n err(`${e.message ? `cdsn connectors: ${e.message}\\n` : ''}${USAGE}`);\n return 2;\n }\n err(`cdsn connectors: ${e instanceof Error ? e.message : String(e)}\\n`);\n return 1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../../src/cli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KAAK,SAAS;oBAAE,MAAM,IAAI,UAAU,CAAC,GAAG,OAAO,eAAe,CAAC,CAAC;gBACxE,MAAM,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;oBAClC,OAAO,EAAE,OAAO,KAAK,QAAQ;iBAC9B,CAAC,CAAC;gBACH,GAAG,CAAC,GAAG,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;gBAC5D,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,UAAU,CAAC,qBAAqB,CAAC,CAAC;gBACpE,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;gBACjD,OAAO,CAAC,CAAC;YACX;gBACE,MAAM,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,UAAU,EAAE,CAAC;YAC5B,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,CAAC;QACX,CAAC;QACD,GAAG,CAAC,oBAAoB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxE,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","sourcesContent":["// `cdsn connectors`: the user's MCP servers in ~/.codesign/mcp.json, which chats offer the agent through the\n// server's gate. A file edit in this process: a chat reads the file when its agent starts.\n\nimport { runtimeHome, runtimePaths } from '@imgly/codesign-router/paths.js';\nimport type {\n UserServerAddParams,\n UserServerInfo\n} from '@imgly/codesign-router/protocol/types.js';\n\nimport {\n addServer,\n listServers,\n removeServer,\n setServer\n} from '../connectors/config.js';\nimport { startSignIn } from '../connectors/oauth.js';\nimport { credentialStoreFor } from '../credentials/keychain.js';\nimport { openBrowser } from '../services/auth/browser.js';\n\nexport const summary =\n 'your MCP servers in chats: list, add, remove, enable, disable, signin';\n\nconst USAGE = `Usage: cdsn connectors <command>\n list [--json] your MCP servers and their state\n add <name> [--env NAME=value]… -- <command> [args…]\n a server that runs a command, with your permissions\n add <name> --url <url> [--header 'Name: value']… [--sign-in now|when-needed]\n [--client-id <id> [--client-secret <secret>]]\n a remote server; header and env values go to the keychain\n remove <name>\n enable <name> | disable <name>\n signin <name> [--no-browser] sign in to a server that uses OAuth\n`;\n\nconst SIGNIN_WAIT_MS = 5 * 60_000;\n\nexport interface ConnectorsDeps {\n home?: string;\n stdout?: (text: string) => void;\n stderr?: (text: string) => void;\n openBrowser?: (url: string) => Promise<boolean>;\n}\n\nclass UsageError extends Error {}\n\n/** `--flag value` pairs before `--`, the repeated ones collected. */\nfunction parse(args: string[]) {\n const end = args.indexOf('--');\n const head = end === -1 ? args : args.slice(0, end);\n const command = end === -1 ? undefined : args.slice(end + 1);\n const flags = new Map<string, string[]>();\n const positional: string[] = [];\n for (let i = 0; i < head.length; i++) {\n const arg = head[i]!;\n if (!arg.startsWith('--')) positional.push(arg);\n else if (arg === '--json' || arg === '--no-browser') flags.set(arg, ['']);\n else {\n const value = head[++i];\n if (value === undefined) throw new UsageError(`${arg} needs a value`);\n flags.set(arg, [...(flags.get(arg) ?? []), value]);\n }\n }\n return { positional, command, flags, one: (f: string) => flags.get(f)?.[0] };\n}\n\nfunction pairs(values: string[] | undefined, sep: string) {\n const out: Record<string, string> = {};\n for (const v of values ?? []) {\n const at = v.indexOf(sep);\n if (at <= 0) throw new UsageError(`${v} is not NAME${sep.trim()}value`);\n out[v.slice(0, at).trim()] = v.slice(at + sep.length).trim();\n }\n return out;\n}\n\nfunction addParams(\n name: string,\n p: ReturnType<typeof parse>\n): Omit<UserServerAddParams, 'channel'> {\n const url = p.one('--url');\n const signIn = p.one('--sign-in');\n if (signIn !== undefined && signIn !== 'now' && signIn !== 'when-needed')\n throw new UsageError('--sign-in is now or when-needed');\n const clientId = p.one('--client-id');\n const clientSecret = p.one('--client-secret');\n if (url !== undefined) {\n return {\n name,\n server: { type: 'http', url },\n secrets: pairs(p.flags.get('--header'), ':'),\n ...(signIn !== undefined && { signIn }),\n ...(clientId !== undefined && {\n oauthClient: {\n clientId,\n ...(clientSecret !== undefined && { clientSecret })\n }\n })\n };\n }\n const [command, ...args] = p.command ?? [];\n if (command === undefined)\n throw new UsageError('add needs --url or -- <command>');\n return {\n name,\n server: { type: 'stdio', command, ...(args.length > 0 && { args }) },\n secrets: pairs(p.flags.get('--env'), '=')\n };\n}\n\nconst where = (s: UserServerInfo) =>\n s.server.type === 'http'\n ? s.server.url\n : [s.server.command, ...(s.server.args ?? [])].join(' ');\n\nconst STATE = {\n ready: 'on',\n disabled: 'off',\n needs_signin: 'needs sign-in'\n} as const;\n\nexport async function run(\n argv: string[],\n deps: ConnectorsDeps = {}\n): Promise<number> {\n const out = deps.stdout ?? ((text) => void process.stdout.write(text));\n const err = deps.stderr ?? ((text) => void process.stderr.write(text));\n const paths = runtimePaths(deps.home ?? runtimeHome());\n const files = { mcpJson: paths.mcpJson, credentials: paths.credentials };\n const store = credentialStoreFor(paths.credentials);\n const browse = deps.openBrowser ?? openBrowser;\n\n const signIn = async (name: string, browser: boolean) => {\n const { url, done } = await startSignIn(files, store, name);\n out(`Sign in to ${name} in your browser:\\n ${url}\\n`);\n if (browser) await browse(url);\n let timer: NodeJS.Timeout | undefined;\n await Promise.race([\n done,\n new Promise((_, reject) => {\n timer = setTimeout(\n () => reject(new Error('the sign-in timed out')),\n SIGNIN_WAIT_MS\n );\n })\n ]).finally(() => clearTimeout(timer));\n out(`Signed in to ${name}.\\n`);\n };\n\n try {\n const [command, ...rest] = argv;\n const p = parse(rest);\n const name = p.positional[0];\n switch (command) {\n case 'list': {\n const servers = await listServers(files, store);\n if (p.flags.has('--json')) out(`${JSON.stringify(servers)}\\n`);\n else if (servers.length === 0) out('No MCP servers.\\n');\n else\n for (const s of servers)\n out(\n `${s.name.padEnd(20)}${STATE[s.state].padEnd(15)}${where(s)}\\n`\n );\n return 0;\n }\n case 'add': {\n if (name === undefined) throw new UsageError('add needs a name');\n const info = await addServer(files, store, addParams(name, p));\n out(`Added ${name}.\\n`);\n if (info.server.type === 'stdio')\n out(\n `Chats start \\`${where(info)}\\` with your permissions while ${name} is on.\\n`\n );\n if (info.signIn === 'now') await signIn(name, true);\n return 0;\n }\n case 'remove':\n if (name === undefined) throw new UsageError('remove needs a name');\n await removeServer(files, store, name);\n out(`Removed ${name}.\\n`);\n return 0;\n case 'enable':\n case 'disable':\n if (name === undefined) throw new UsageError(`${command} needs a name`);\n await setServer(files, store, name, {\n enabled: command === 'enable'\n });\n out(`${name} is ${command === 'enable' ? 'on' : 'off'}.\\n`);\n return 0;\n case 'signin':\n if (name === undefined) throw new UsageError('signin needs a name');\n await signIn(name, !p.flags.has('--no-browser'));\n return 0;\n default:\n throw new UsageError('');\n }\n } catch (e) {\n if (e instanceof UsageError) {\n err(`${e.message ? `cdsn connectors: ${e.message}\\n` : ''}${USAGE}`);\n return 2;\n }\n err(`cdsn connectors: ${e instanceof Error ? e.message : String(e)}\\n`);\n return 1;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { isRecord } from '../read.js';
|
|
4
|
-
import { credentialStoreFor } from '../../../credentials/
|
|
4
|
+
import { credentialStoreFor } from '../../../credentials/keychain.js';
|
|
5
5
|
/** Why mcp.json is not usable, never quoting it: it may hold a token. */
|
|
6
6
|
function invalid(text) {
|
|
7
7
|
let json;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-servers.js","sourceRoot":"","sources":["../../../../src/cli/doctor/checks/mcp-servers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mcp-servers.js","sourceRoot":"","sources":["../../../../src/cli/doctor/checks/mcp-servers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,yEAAyE;AACzE,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/C,OAAO,+BAA+B,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,IACE,CAAC,QAAQ,CAAC,MAAM,CAAC;YACjB,CAAC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC;YAEtE,OAAO,eAAe,IAAI,mCAAmC,CAAC;IAClE,CAAC;IACD,OAA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GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,KAAK,SAAS;YAChE,SAAS;QACX,QAAQ,CAAC,IAAI,CAAC;YACZ,EAAE,EAAE,OAAO,IAAI,EAAE;YACjB,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,mBAAmB,IAAI,kBAAkB;YAClD,GAAG,EAAE,2DAA2D;YAChE,GAAG,EAAE,0DAA0D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG;SACxG,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { readFileSync } from 'node:fs';\nimport type { Check, Problem } from '../types.js';\nimport { isRecord } from '../read.js';\nimport { credentialStoreFor } from '../../../credentials/keychain.js';\n\n/** Why mcp.json is not usable, never quoting it: it may hold a token. */\nfunction invalid(text: string): string | Record<string, unknown> {\n let json: unknown;\n try {\n json = JSON.parse(text);\n } catch {\n return 'it is not JSON';\n }\n if (!isRecord(json) || !isRecord(json.mcpServers))\n return 'it has no \"mcpServers\" object';\n for (const [name, server] of Object.entries(json.mcpServers)) {\n if (\n !isRecord(server) ||\n (typeof server.command !== 'string' && typeof server.url !== 'string')\n )\n return `the server \"${name}\" has neither a command nor a url`;\n }\n return json.mcpServers;\n}\n\nexport const mcpServers: Check = async ({ home }) => {\n const file = join(home, 'mcp.json');\n let text: string;\n try {\n text = readFileSync(file, 'utf8');\n } catch {\n return [];\n }\n const servers = invalid(text);\n if (typeof servers === 'string')\n return [\n {\n id: 'mcp-json',\n severity: 'fail',\n message: `${file} is not valid: ${servers}.`,\n why: 'None of your MCP servers is offered in chats.',\n fix: 'Correct the file, or move it away and add the servers again in Settings.'\n }\n ];\n const store = credentialStoreFor(join(home, '.credentials.json'));\n const problems: Problem[] = [];\n for (const [name, server] of Object.entries(servers)) {\n const own =\n isRecord(server) && isRecord(server.codesign) ? server.codesign : {};\n if (own.enabled === false) continue;\n if (own.signIn !== 'now' && own.signIn !== 'when-needed') continue;\n if ((await store.get(`mcp/${String(own.id)}/oauth`)) !== undefined)\n continue;\n problems.push({\n id: `mcp-${name}`,\n severity: 'warn',\n message: `The MCP server \"${name}\" needs sign-in.`,\n why: 'Its tools are not offered to the agent until you sign in.',\n fix: `Sign in on its card in CoDesign's Settings; its log is ${join(home, 'logs', `mcp-${name}.log`)}.`\n });\n }\n return problems;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const summary = "packs: install <file|https url
|
|
1
|
+
export declare const summary = "packs: install <file|https url> (adds its templates and styles), list, remove <id>, create <out.imglypack>";
|
|
2
2
|
export interface PackDeps {
|
|
3
3
|
home?: string;
|
|
4
4
|
/** What a relative path is relative to; default this process's. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/cli/pack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/cli/pack.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,OAAO,+GAC0F,CAAC;AAS/G,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AA8FD,wBAAsB,GAAG,CACvB,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE,QAAa,GAClB,OAAO,CAAC,MAAM,CAAC,CAoFjB"}
|