@dinoxx/dinox-cli 2.19.0 → 2.20.0
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/LICENSE +15 -0
- package/README.md +17 -17
- package/dist/chunks/applePodcast-V4FSJOC5.js +169 -0
- package/dist/chunks/bbc-NTMRPYRF.js +570 -0
- package/dist/chunks/bilibili-UA3MBSPH.js +835 -0
- package/dist/chunks/bohaishibei-B7UVXH4Y.js +246 -0
- package/dist/chunks/chunk-224ML7QC.js +21 -0
- package/dist/chunks/chunk-2LW76QIL.js +32 -0
- package/dist/chunks/chunk-2M7RJATW.js +60 -0
- package/dist/chunks/chunk-3EKNTO6G.js +61 -0
- package/dist/chunks/chunk-3VZNZWDG.js +437 -0
- package/dist/chunks/chunk-5JF7J5MP.js +114 -0
- package/dist/chunks/chunk-5KU25TMX.js +26 -0
- package/dist/chunks/chunk-67RXND3H.js +65 -0
- package/dist/chunks/chunk-6AZT4ARG.js +1491 -0
- package/dist/chunks/chunk-6D3QLMRM.js +421 -0
- package/dist/chunks/chunk-6VMHHE5Y.js +235 -0
- package/dist/chunks/chunk-77UP745T.js +143 -0
- package/dist/chunks/chunk-7A5QISPG.js +19 -0
- package/dist/chunks/chunk-7ODU7LXP.js +31 -0
- package/dist/chunks/chunk-A6WF7CZL.js +904 -0
- package/dist/chunks/chunk-ABYPGMDC.js +100 -0
- package/dist/chunks/chunk-AHRCI2RW.js +141 -0
- package/dist/chunks/chunk-BDLS5EEP.js +49 -0
- package/dist/chunks/chunk-BKCNERPB.js +246 -0
- package/dist/chunks/chunk-BZQYECIH.js +54 -0
- package/dist/chunks/chunk-D5SBKLDX.js +71 -0
- package/dist/chunks/chunk-DR6BGSZM.js +865 -0
- package/dist/chunks/chunk-F7BDWXBG.js +57 -0
- package/dist/chunks/chunk-FGQRYB7F.js +34 -0
- package/dist/chunks/chunk-FIQYJ6KZ.js +19 -0
- package/dist/chunks/chunk-FKLZZGEX.js +116 -0
- package/dist/chunks/chunk-FZGEWY5L.js +37 -0
- package/dist/chunks/chunk-GTDX2LIJ.js +265 -0
- package/dist/chunks/chunk-HIJXC3RT.js +194 -0
- package/dist/chunks/chunk-HQJUJYUM.js +36 -0
- package/dist/chunks/chunk-IAEJG5NI.js +50 -0
- package/dist/chunks/chunk-KCHHY6QB.js +65 -0
- package/dist/chunks/chunk-KL75BFYJ.js +71 -0
- package/dist/chunks/chunk-KOAKG2QU.js +45 -0
- package/dist/chunks/chunk-MCFXD2LS.js +66 -0
- package/dist/chunks/chunk-MLOITAK6.js +29 -0
- package/dist/chunks/chunk-N44NRKDJ.js +101 -0
- package/dist/chunks/chunk-N6ALWINB.js +14115 -0
- package/dist/chunks/chunk-NGIIELO4.js +61 -0
- package/dist/chunks/chunk-OG6MBAGC.js +95 -0
- package/dist/chunks/chunk-P4LG4DIO.js +108 -0
- package/dist/chunks/chunk-PJDD4R46.js +77 -0
- package/dist/chunks/chunk-PK5AOVLU.js +107 -0
- package/dist/chunks/chunk-PTFGE4KS.js +66 -0
- package/dist/chunks/chunk-Q6G7VO5G.js +67 -0
- package/dist/chunks/chunk-QFUD3I7W.js +185 -0
- package/dist/chunks/chunk-QNIYFLJT.js +39 -0
- package/dist/chunks/chunk-QZQRG3JY.js +86 -0
- package/dist/chunks/chunk-RKJYKUQD.js +91 -0
- package/dist/chunks/chunk-TAENC45D.js +160 -0
- package/dist/chunks/chunk-TILRKKRN.js +20481 -0
- package/dist/chunks/chunk-TIXOORAP.js +60 -0
- package/dist/chunks/chunk-ULKGDBAJ.js +80 -0
- package/dist/chunks/chunk-URYABAYN.js +72 -0
- package/dist/chunks/chunk-VNB4ZFLN.js +86 -0
- package/dist/chunks/chunk-W7R5JTSA.js +42 -0
- package/dist/chunks/chunk-WC3GSQBC.js +25699 -0
- package/dist/chunks/chunk-WMJXAF3X.js +55 -0
- package/dist/chunks/chunk-X36EIV25.js +93 -0
- package/dist/chunks/chunk-X7IZXCSL.js +60 -0
- package/dist/chunks/chunk-XEPDFQYD.js +215 -0
- package/dist/chunks/chunk-XFVLNCOW.js +171 -0
- package/dist/chunks/chunk-XMMTGPZ6.js +1332 -0
- package/dist/chunks/chunk-XQZUX7OT.js +39 -0
- package/dist/chunks/chunk-XZLFMJOG.js +72 -0
- package/dist/chunks/chunk-ZGF3OEWR.js +84 -0
- package/dist/chunks/chunk-ZHKS4R4P.js +1215 -0
- package/dist/chunks/cookies-6QQHSM26.js +34 -0
- package/dist/chunks/dedaoNote-KJ32ZQLS.js +418 -0
- package/dist/chunks/doubanGroup-HR4K2KMY.js +429 -0
- package/dist/chunks/doubao-MXUHPLUB.js +462 -0
- package/dist/chunks/douyin-UU2FSQPS.js +566 -0
- package/dist/chunks/ensure-MLNCD2SD.js +18 -0
- package/dist/chunks/execute-57M65KKK.js +17 -0
- package/dist/chunks/facebook-SZFOVE7R.js +878 -0
- package/dist/chunks/feishu-ISWRJ7HI.js +877 -0
- package/dist/chunks/ima-D7CX5WR4.js +202 -0
- package/dist/chunks/instagram-HNDPO37H.js +939 -0
- package/dist/chunks/install-IIMVFNAT.js +303 -0
- package/dist/chunks/jike-H7L4LJTN.js +445 -0
- package/dist/chunks/mcp-PZBHAYXQ.js +297 -0
- package/dist/chunks/mcpServer-T4DNYR7R.js +436 -0
- package/dist/chunks/metaso-ZVZW5UBB.js +194 -0
- package/dist/chunks/run-GCMWLTIV.js +1464 -0
- package/dist/chunks/runCli-SBQE2VQJ.js +464 -0
- package/dist/chunks/setup-EEU6GSWX.js +378 -0
- package/dist/chunks/threads-ADW6IANQ.js +657 -0
- package/dist/chunks/twitter-NAGCB3NI.js +1148 -0
- package/dist/chunks/web-QFKZCM4F.js +31 -0
- package/dist/chunks/wechat-OXNNLT4J.js +1551 -0
- package/dist/chunks/weibo-PMVGDNQU.js +641 -0
- package/dist/chunks/workbuddy-NNAXIIIZ.js +426 -0
- package/dist/chunks/xiaoheihe-WFQJRBAD.js +316 -0
- package/dist/chunks/xiaohongshu-5CXBELGW.js +1833 -0
- package/dist/chunks/xiaoyuzhou-6L6IB46Y.js +322 -0
- package/dist/chunks/youtube-52NGBTQC.js +58 -0
- package/dist/chunks/zcool-HDSWK4KD.js +755 -0
- package/dist/chunks/zhihu-EX2VRJYY.js +1024 -0
- package/dist/dinox.js +137 -51
- package/dist/dsh-plugin/lib/client.js +265 -252
- package/dist/dsh-plugin/package.json +1 -1
- package/dist/dsh-plugin/runtime.json +3 -3
- package/dist/editor-ui/mcp-app.html +293 -280
- package/package.json +81 -63
- package/dist/ai/ragxClient.d.ts +0 -15
- package/dist/ai/ragxClient.js +0 -71
- package/dist/auth/devicePair.d.ts +0 -62
- package/dist/auth/devicePair.js +0 -377
- package/dist/auth/userInfo.d.ts +0 -26
- package/dist/auth/userInfo.js +0 -224
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -130
- package/dist/cliTypes.d.ts +0 -7
- package/dist/cliTypes.js +0 -1
- package/dist/commands/auth/index.d.ts +0 -34
- package/dist/commands/auth/index.js +0 -605
- package/dist/commands/batch.d.ts +0 -35
- package/dist/commands/batch.js +0 -202
- package/dist/commands/boxes/index.d.ts +0 -4
- package/dist/commands/boxes/index.js +0 -382
- package/dist/commands/boxes/model.d.ts +0 -37
- package/dist/commands/boxes/model.js +0 -93
- package/dist/commands/boxes/operations.d.ts +0 -86
- package/dist/commands/boxes/operations.js +0 -448
- package/dist/commands/boxes/repo.d.ts +0 -36
- package/dist/commands/boxes/repo.js +0 -320
- package/dist/commands/boxes/store.d.ts +0 -22
- package/dist/commands/boxes/store.js +0 -143
- package/dist/commands/config/index.d.ts +0 -5
- package/dist/commands/config/index.js +0 -105
- package/dist/commands/descriptor/register.d.ts +0 -8
- package/dist/commands/descriptor/register.js +0 -122
- package/dist/commands/descriptor/types.d.ts +0 -37
- package/dist/commands/descriptor/types.js +0 -17
- package/dist/commands/doctor.d.ts +0 -126
- package/dist/commands/doctor.js +0 -558
- package/dist/commands/domain/options.d.ts +0 -10
- package/dist/commands/domain/options.js +0 -75
- package/dist/commands/domain/run.d.ts +0 -24
- package/dist/commands/domain/run.js +0 -137
- package/dist/commands/editor/index.d.ts +0 -4
- package/dist/commands/editor/index.js +0 -155
- package/dist/commands/gateway/index.d.ts +0 -4
- package/dist/commands/gateway/index.js +0 -340
- package/dist/commands/graph/index.d.ts +0 -4
- package/dist/commands/graph/index.js +0 -173
- package/dist/commands/graph/repo.d.ts +0 -40
- package/dist/commands/graph/repo.js +0 -201
- package/dist/commands/info/index.d.ts +0 -4
- package/dist/commands/info/index.js +0 -75
- package/dist/commands/mcp.d.ts +0 -6
- package/dist/commands/mcp.js +0 -47
- package/dist/commands/meta/index.d.ts +0 -4
- package/dist/commands/meta/index.js +0 -60
- package/dist/commands/meta/repo.d.ts +0 -30
- package/dist/commands/meta/repo.js +0 -76
- package/dist/commands/notes/actions.d.ts +0 -12
- package/dist/commands/notes/actions.js +0 -591
- package/dist/commands/notes/bulk.d.ts +0 -35
- package/dist/commands/notes/bulk.js +0 -195
- package/dist/commands/notes/contentEngine.d.ts +0 -95
- package/dist/commands/notes/contentEngine.js +0 -714
- package/dist/commands/notes/contentPatch.d.ts +0 -114
- package/dist/commands/notes/contentPatch.js +0 -450
- package/dist/commands/notes/contentPatchCommand.d.ts +0 -6
- package/dist/commands/notes/contentPatchCommand.js +0 -164
- package/dist/commands/notes/createFromTemplate.d.ts +0 -35
- package/dist/commands/notes/createFromTemplate.js +0 -58
- package/dist/commands/notes/descriptors.d.ts +0 -4
- package/dist/commands/notes/descriptors.js +0 -548
- package/dist/commands/notes/detailContent.d.ts +0 -19
- package/dist/commands/notes/detailContent.js +0 -62
- package/dist/commands/notes/dryRun.d.ts +0 -33
- package/dist/commands/notes/dryRun.js +0 -133
- package/dist/commands/notes/export.d.ts +0 -27
- package/dist/commands/notes/export.js +0 -252
- package/dist/commands/notes/index.d.ts +0 -2
- package/dist/commands/notes/index.js +0 -2
- package/dist/commands/notes/metadataMutation.d.ts +0 -29
- package/dist/commands/notes/metadataMutation.js +0 -138
- package/dist/commands/notes/repo/read.d.ts +0 -8
- package/dist/commands/notes/repo/read.js +0 -302
- package/dist/commands/notes/repo/resolve.d.ts +0 -8
- package/dist/commands/notes/repo/resolve.js +0 -187
- package/dist/commands/notes/repo/search.d.ts +0 -43
- package/dist/commands/notes/repo/search.js +0 -513
- package/dist/commands/notes/repo/semantic.d.ts +0 -14
- package/dist/commands/notes/repo/semantic.js +0 -31
- package/dist/commands/notes/repo/shared.d.ts +0 -192
- package/dist/commands/notes/repo/shared.js +0 -102
- package/dist/commands/notes/repo/write.d.ts +0 -27
- package/dist/commands/notes/repo/write.js +0 -262
- package/dist/commands/notes/repo.d.ts +0 -7
- package/dist/commands/notes/repo.js +0 -7
- package/dist/commands/notes/runtime.d.ts +0 -20
- package/dist/commands/notes/runtime.js +0 -175
- package/dist/commands/notes/searchOutput.d.ts +0 -15
- package/dist/commands/notes/searchOutput.js +0 -54
- package/dist/commands/notes/searchResponse.d.ts +0 -54
- package/dist/commands/notes/searchResponse.js +0 -57
- package/dist/commands/notes/searchSql.d.ts +0 -11
- package/dist/commands/notes/searchSql.js +0 -614
- package/dist/commands/notes/searchTime.d.ts +0 -9
- package/dist/commands/notes/searchTime.js +0 -85
- package/dist/commands/notes/semantic.d.ts +0 -116
- package/dist/commands/notes/semantic.js +0 -332
- package/dist/commands/notes/writeReceipt.d.ts +0 -20
- package/dist/commands/notes/writeReceipt.js +0 -82
- package/dist/commands/prompt/index.d.ts +0 -5
- package/dist/commands/prompt/index.js +0 -132
- package/dist/commands/prompt/repo.d.ts +0 -28
- package/dist/commands/prompt/repo.js +0 -220
- package/dist/commands/properties/index.d.ts +0 -16
- package/dist/commands/properties/index.js +0 -640
- package/dist/commands/properties/repo.d.ts +0 -150
- package/dist/commands/properties/repo.js +0 -272
- package/dist/commands/runtime.d.ts +0 -54
- package/dist/commands/runtime.js +0 -228
- package/dist/commands/savedViews/fields.d.ts +0 -28
- package/dist/commands/savedViews/fields.js +0 -87
- package/dist/commands/savedViews/index.d.ts +0 -7
- package/dist/commands/savedViews/index.js +0 -506
- package/dist/commands/savedViews/model.d.ts +0 -45
- package/dist/commands/savedViews/model.js +0 -90
- package/dist/commands/savedViews/repo.d.ts +0 -125
- package/dist/commands/savedViews/repo.js +0 -393
- package/dist/commands/schema/commandMetadata.d.ts +0 -2
- package/dist/commands/schema/commandMetadata.js +0 -18
- package/dist/commands/schema/globalOptions.d.ts +0 -11
- package/dist/commands/schema/globalOptions.js +0 -11
- package/dist/commands/schema/index.d.ts +0 -5
- package/dist/commands/schema/index.js +0 -130
- package/dist/commands/schema/renderSkills.d.ts +0 -12
- package/dist/commands/schema/renderSkills.js +0 -366
- package/dist/commands/schema/spec.d.ts +0 -5
- package/dist/commands/schema/spec.js +0 -74
- package/dist/commands/schema/types.d.ts +0 -34
- package/dist/commands/schema/types.js +0 -1
- package/dist/commands/skills/index.d.ts +0 -80
- package/dist/commands/skills/index.js +0 -572
- package/dist/commands/storage/index.d.ts +0 -4
- package/dist/commands/storage/index.js +0 -270
- package/dist/commands/storage/repo/configs.d.ts +0 -30
- package/dist/commands/storage/repo/configs.js +0 -259
- package/dist/commands/storage/repo/operations.d.ts +0 -25
- package/dist/commands/storage/repo/operations.js +0 -339
- package/dist/commands/storage/repo/remote.d.ts +0 -32
- package/dist/commands/storage/repo/remote.js +0 -132
- package/dist/commands/storage/repo/resources.d.ts +0 -12
- package/dist/commands/storage/repo/resources.js +0 -134
- package/dist/commands/storage/repo/shared.d.ts +0 -181
- package/dist/commands/storage/repo/shared.js +0 -36
- package/dist/commands/storage/repo/targets.d.ts +0 -12
- package/dist/commands/storage/repo/targets.js +0 -178
- package/dist/commands/storage/repo.d.ts +0 -3
- package/dist/commands/storage/repo.js +0 -4
- package/dist/commands/sync.d.ts +0 -27
- package/dist/commands/sync.js +0 -153
- package/dist/commands/tags/content.d.ts +0 -32
- package/dist/commands/tags/content.js +0 -252
- package/dist/commands/tags/index.d.ts +0 -4
- package/dist/commands/tags/index.js +0 -404
- package/dist/commands/tags/model.d.ts +0 -38
- package/dist/commands/tags/model.js +0 -100
- package/dist/commands/tags/operations.d.ts +0 -105
- package/dist/commands/tags/operations.js +0 -468
- package/dist/commands/tags/repo.d.ts +0 -27
- package/dist/commands/tags/repo.js +0 -236
- package/dist/commands/tags/store.d.ts +0 -28
- package/dist/commands/tags/store.js +0 -166
- package/dist/commands/templates/index.d.ts +0 -4
- package/dist/commands/templates/index.js +0 -290
- package/dist/commands/templates/model.d.ts +0 -28
- package/dist/commands/templates/model.js +0 -195
- package/dist/commands/templates/repo.d.ts +0 -53
- package/dist/commands/templates/repo.js +0 -78
- package/dist/commands/todo/contentModel.d.ts +0 -33
- package/dist/commands/todo/contentModel.js +0 -377
- package/dist/commands/todo/dryRun.d.ts +0 -26
- package/dist/commands/todo/dryRun.js +0 -150
- package/dist/commands/todo/index.d.ts +0 -10
- package/dist/commands/todo/index.js +0 -631
- package/dist/commands/todo/repo.d.ts +0 -257
- package/dist/commands/todo/repo.js +0 -772
- package/dist/commands/todo/taskIdentity.d.ts +0 -2
- package/dist/commands/todo/taskIdentity.js +0 -64
- package/dist/commands/todo/taskModel.d.ts +0 -56
- package/dist/commands/todo/taskModel.js +0 -492
- package/dist/commands/todo/taskPatch.d.ts +0 -119
- package/dist/commands/todo/taskPatch.js +0 -502
- package/dist/commands/todo/taskText.d.ts +0 -26
- package/dist/commands/todo/taskText.js +0 -221
- package/dist/commands/update.d.ts +0 -46
- package/dist/commands/update.js +0 -326
- package/dist/commands/writeConfirmation.d.ts +0 -13
- package/dist/commands/writeConfirmation.js +0 -54
- package/dist/commands/writeDryRun.d.ts +0 -88
- package/dist/commands/writeDryRun.js +0 -162
- package/dist/commands/writeDurability.d.ts +0 -5
- package/dist/commands/writeDurability.js +0 -22
- package/dist/commands/writeReceipt.d.ts +0 -13
- package/dist/commands/writeReceipt.js +0 -12
- package/dist/config/keys.d.ts +0 -9
- package/dist/config/keys.js +0 -14
- package/dist/config/paths.d.ts +0 -6
- package/dist/config/paths.js +0 -55
- package/dist/config/resolve.d.ts +0 -4
- package/dist/config/resolve.js +0 -68
- package/dist/config/serviceEndpoints.d.ts +0 -5
- package/dist/config/serviceEndpoints.js +0 -5
- package/dist/config/store.d.ts +0 -8
- package/dist/config/store.js +0 -149
- package/dist/config/types.d.ts +0 -55
- package/dist/config/types.js +0 -1
- package/dist/constants/links.d.ts +0 -18
- package/dist/constants/links.js +0 -26
- package/dist/contract/snapshot.d.ts +0 -30
- package/dist/contract/snapshot.js +0 -114
- package/dist/daemon/autoInstall.d.ts +0 -32
- package/dist/daemon/autoInstall.js +0 -106
- package/dist/daemon/client.d.ts +0 -29
- package/dist/daemon/client.js +0 -418
- package/dist/daemon/connectivity.d.ts +0 -20
- package/dist/daemon/connectivity.js +0 -42
- package/dist/daemon/ensure.d.ts +0 -1
- package/dist/daemon/ensure.js +0 -120
- package/dist/daemon/env.d.ts +0 -8
- package/dist/daemon/env.js +0 -81
- package/dist/daemon/forward.d.ts +0 -37
- package/dist/daemon/forward.js +0 -155
- package/dist/daemon/fresh.d.ts +0 -4
- package/dist/daemon/fresh.js +0 -10
- package/dist/daemon/index.d.ts +0 -80
- package/dist/daemon/index.js +0 -727
- package/dist/daemon/launch.d.ts +0 -43
- package/dist/daemon/launch.js +0 -124
- package/dist/daemon/lifecycle.d.ts +0 -51
- package/dist/daemon/lifecycle.js +0 -182
- package/dist/daemon/log.d.ts +0 -14
- package/dist/daemon/log.js +0 -57
- package/dist/daemon/pid.d.ts +0 -31
- package/dist/daemon/pid.js +0 -212
- package/dist/daemon/route.d.ts +0 -14
- package/dist/daemon/route.js +0 -43
- package/dist/daemon/server.d.ts +0 -67
- package/dist/daemon/server.js +0 -563
- package/dist/daemon/supervise.d.ts +0 -29
- package/dist/daemon/supervise.js +0 -100
- package/dist/daemon/supervisor.d.ts +0 -91
- package/dist/daemon/supervisor.js +0 -612
- package/dist/daemon/types.d.ts +0 -71
- package/dist/daemon/types.js +0 -2
- package/dist/dinox.d.ts +0 -2
- package/dist/editor/anchor.d.ts +0 -46
- package/dist/editor/anchor.js +0 -129
- package/dist/editor/blockIds.d.ts +0 -21
- package/dist/editor/blockIds.js +0 -51
- package/dist/editor/blocks.d.ts +0 -47
- package/dist/editor/blocks.js +0 -236
- package/dist/editor/compat.d.ts +0 -38
- package/dist/editor/compat.js +0 -410
- package/dist/editor/daemon.d.ts +0 -10
- package/dist/editor/daemon.js +0 -83
- package/dist/editor/document.d.ts +0 -74
- package/dist/editor/document.js +0 -88
- package/dist/editor/i18n.d.ts +0 -23
- package/dist/editor/i18n.js +0 -61
- package/dist/editor/install.d.ts +0 -90
- package/dist/editor/install.js +0 -335
- package/dist/editor/mcp.d.ts +0 -22
- package/dist/editor/mcp.js +0 -319
- package/dist/editor/meta.d.ts +0 -70
- package/dist/editor/meta.js +0 -163
- package/dist/editor/paths.d.ts +0 -2
- package/dist/editor/paths.js +0 -13
- package/dist/editor/persistence.d.ts +0 -4
- package/dist/editor/persistence.js +0 -35
- package/dist/editor/saveGuard.d.ts +0 -9
- package/dist/editor/saveGuard.js +0 -38
- package/dist/editor/schema.d.ts +0 -14
- package/dist/editor/schema.js +0 -38
- package/dist/editor/service.d.ts +0 -382
- package/dist/editor/service.js +0 -1174
- package/dist/editor/todos.d.ts +0 -67
- package/dist/editor/todos.js +0 -293
- package/dist/gateway/adapters/acp.d.ts +0 -75
- package/dist/gateway/adapters/acp.js +0 -431
- package/dist/gateway/adapters/codexImages.d.ts +0 -4
- package/dist/gateway/adapters/codexImages.js +0 -34
- package/dist/gateway/adapters/echo.d.ts +0 -12
- package/dist/gateway/adapters/echo.js +0 -54
- package/dist/gateway/adapters/index.d.ts +0 -13
- package/dist/gateway/adapters/index.js +0 -42
- package/dist/gateway/agentTaskHost.d.ts +0 -135
- package/dist/gateway/agentTaskHost.js +0 -410
- package/dist/gateway/assistantProjection.d.ts +0 -36
- package/dist/gateway/assistantProjection.js +0 -230
- package/dist/gateway/config.d.ts +0 -56
- package/dist/gateway/config.js +0 -312
- package/dist/gateway/conversationContext.d.ts +0 -44
- package/dist/gateway/conversationContext.js +0 -75
- package/dist/gateway/detect.d.ts +0 -63
- package/dist/gateway/detect.js +0 -281
- package/dist/gateway/deviceHost.d.ts +0 -100
- package/dist/gateway/deviceHost.js +0 -735
- package/dist/gateway/fileUpload.d.ts +0 -12
- package/dist/gateway/fileUpload.js +0 -154
- package/dist/gateway/keepAwake.d.ts +0 -24
- package/dist/gateway/keepAwake.js +0 -64
- package/dist/gateway/mcpCommandTools.d.ts +0 -62
- package/dist/gateway/mcpCommandTools.js +0 -220
- package/dist/gateway/mcpEnv.d.ts +0 -11
- package/dist/gateway/mcpEnv.js +0 -11
- package/dist/gateway/mcpGroups.d.ts +0 -3
- package/dist/gateway/mcpGroups.js +0 -4
- package/dist/gateway/mcpServer.d.ts +0 -25
- package/dist/gateway/mcpServer.js +0 -214
- package/dist/gateway/processTree.d.ts +0 -15
- package/dist/gateway/processTree.js +0 -60
- package/dist/gateway/protocol.d.ts +0 -145
- package/dist/gateway/protocol.js +0 -195
- package/dist/gateway/runExecutor.d.ts +0 -104
- package/dist/gateway/runExecutor.js +0 -480
- package/dist/gateway/service.d.ts +0 -35
- package/dist/gateway/service.js +0 -147
- package/dist/gateway/spawnAgent.d.ts +0 -12
- package/dist/gateway/spawnAgent.js +0 -32
- package/dist/gateway/streamPublisher.d.ts +0 -33
- package/dist/gateway/streamPublisher.js +0 -93
- package/dist/gateway/taskJournal.d.ts +0 -14
- package/dist/gateway/taskJournal.js +0 -47
- package/dist/gateway/threadStore.d.ts +0 -230
- package/dist/gateway/threadStore.js +0 -621
- package/dist/gateway/types.d.ts +0 -168
- package/dist/gateway/types.js +0 -12
- package/dist/gateway/workspace.d.ts +0 -5
- package/dist/gateway/workspace.js +0 -30
- package/dist/gateway/workspaceFolders.d.ts +0 -35
- package/dist/gateway/workspaceFolders.js +0 -142
- package/dist/gateway/workspaceListing.d.ts +0 -5
- package/dist/gateway/workspaceListing.js +0 -78
- package/dist/integrations/dsh/host.d.ts +0 -53
- package/dist/integrations/dsh/host.js +0 -245
- package/dist/integrations/dsh/mcpClient.d.ts +0 -66
- package/dist/integrations/dsh/mcpClient.js +0 -192
- package/dist/powersync/connector.d.ts +0 -22
- package/dist/powersync/connector.js +0 -91
- package/dist/powersync/exclusiveRuntime.d.ts +0 -21
- package/dist/powersync/exclusiveRuntime.js +0 -66
- package/dist/powersync/runtime.d.ts +0 -62
- package/dist/powersync/runtime.js +0 -358
- package/dist/powersync/schema/content.d.ts +0 -1
- package/dist/powersync/schema/content.js +0 -1
- package/dist/powersync/schema/electronCanonical.d.ts +0 -1561
- package/dist/powersync/schema/electronCanonical.js +0 -1154
- package/dist/powersync/schema/index.d.ts +0 -844
- package/dist/powersync/schema/index.js +0 -8
- package/dist/powersync/schema/local.d.ts +0 -13
- package/dist/powersync/schema/local.js +0 -24
- package/dist/powersync/schema/note.d.ts +0 -1
- package/dist/powersync/schema/note.js +0 -1
- package/dist/powersync/schema/notesExtras.d.ts +0 -1
- package/dist/powersync/schema/notesExtras.js +0 -1
- package/dist/powersync/schema/projects.d.ts +0 -1
- package/dist/powersync/schema/projects.js +0 -1
- package/dist/powersync/schema/savedViews.d.ts +0 -1
- package/dist/powersync/schema/savedViews.js +0 -1
- package/dist/powersync/schema/storage.d.ts +0 -1
- package/dist/powersync/schema/storage.js +0 -1
- package/dist/powersync/schema/tags.d.ts +0 -1
- package/dist/powersync/schema/tags.js +0 -1
- package/dist/powersync/syncGate.d.ts +0 -45
- package/dist/powersync/syncGate.js +0 -45
- package/dist/powersync/syncPass.d.ts +0 -9
- package/dist/powersync/syncPass.js +0 -33
- package/dist/powersync/tokenIndex.d.ts +0 -32
- package/dist/powersync/tokenIndex.js +0 -382
- package/dist/powersync/uploader.d.ts +0 -22
- package/dist/powersync/uploader.js +0 -231
- package/dist/requests/execute.d.ts +0 -11
- package/dist/requests/execute.js +0 -26
- package/dist/requests/store.d.ts +0 -10
- package/dist/requests/store.js +0 -190
- package/dist/runCli.d.ts +0 -2
- package/dist/runCli.js +0 -64
- package/dist/skills/check.d.ts +0 -7
- package/dist/skills/check.js +0 -747
- package/dist/skills/commandRefs.d.ts +0 -21
- package/dist/skills/commandRefs.js +0 -124
- package/dist/skills/generate.d.ts +0 -13
- package/dist/skills/generate.js +0 -80
- package/dist/skills/registry.d.ts +0 -13
- package/dist/skills/registry.js +0 -65
- package/dist/skills/retired.d.ts +0 -60
- package/dist/skills/retired.js +0 -58
- package/dist/utils/abort.d.ts +0 -6
- package/dist/utils/abort.js +0 -19
- package/dist/utils/argValue.d.ts +0 -1
- package/dist/utils/argValue.js +0 -18
- package/dist/utils/asyncRelease.d.ts +0 -2
- package/dist/utils/asyncRelease.js +0 -25
- package/dist/utils/authToken.d.ts +0 -4
- package/dist/utils/authToken.js +0 -28
- package/dist/utils/bidlinkCanonicalization.d.ts +0 -2
- package/dist/utils/bidlinkCanonicalization.js +0 -164
- package/dist/utils/consoleEncoding.d.ts +0 -5
- package/dist/utils/consoleEncoding.js +0 -27
- package/dist/utils/cursor.d.ts +0 -9
- package/dist/utils/cursor.js +0 -61
- package/dist/utils/deadline.d.ts +0 -8
- package/dist/utils/deadline.js +0 -31
- package/dist/utils/defaultFormat.d.ts +0 -8
- package/dist/utils/defaultFormat.js +0 -38
- package/dist/utils/dryRun.d.ts +0 -32
- package/dist/utils/dryRun.js +0 -88
- package/dist/utils/errorCodes.d.ts +0 -595
- package/dist/utils/errorCodes.js +0 -163
- package/dist/utils/errors.d.ts +0 -54
- package/dist/utils/errors.js +0 -277
- package/dist/utils/id.d.ts +0 -1
- package/dist/utils/id.js +0 -4
- package/dist/utils/nodeRuntime.d.ts +0 -4
- package/dist/utils/nodeRuntime.js +0 -12
- package/dist/utils/output.d.ts +0 -26
- package/dist/utils/output.js +0 -262
- package/dist/utils/processExit.d.ts +0 -1
- package/dist/utils/processExit.js +0 -33
- package/dist/utils/progress.d.ts +0 -25
- package/dist/utils/progress.js +0 -59
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -10
- package/dist/utils/requestContext.d.ts +0 -32
- package/dist/utils/requestContext.js +0 -13
- package/dist/utils/select.d.ts +0 -20
- package/dist/utils/select.js +0 -92
- package/dist/utils/sqliteLease.d.ts +0 -8
- package/dist/utils/sqliteLease.js +0 -59
- package/dist/utils/syncTimeout.d.ts +0 -7
- package/dist/utils/syncTimeout.js +0 -20
- package/dist/utils/terminalSanitization.d.ts +0 -2
- package/dist/utils/terminalSanitization.js +0 -37
- package/dist/utils/text.d.ts +0 -1
- package/dist/utils/text.js +0 -35
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -3
- package/dist/utils/tiptapMarkdown.d.ts +0 -9
- package/dist/utils/tiptapMarkdown.js +0 -381
- package/dist/utils/tiptapMarkdownSchema.d.ts +0 -37
- package/dist/utils/tiptapMarkdownSchema.js +0 -608
- package/dist/utils/tiptapMarkdownSchemaUtils.d.ts +0 -74
- package/dist/utils/tiptapMarkdownSchemaUtils.js +0 -394
- package/dist/utils/tiptapMarkdownSyntax.d.ts +0 -9
- package/dist/utils/tiptapMarkdownSyntax.js +0 -249
- package/dist/utils/tokenize.d.ts +0 -1
- package/dist/utils/tokenize.js +0 -67
- package/dist/utils/updateNotice.d.ts +0 -8
- package/dist/utils/updateNotice.js +0 -112
- package/dist/utils/usageError.d.ts +0 -37
- package/dist/utils/usageError.js +0 -127
- package/dist/utils/version.d.ts +0 -1
- package/dist/utils/version.js +0 -21
- package/dist/vendor/electron/domain/note-templates.d.ts +0 -3
- package/dist/vendor/electron/domain/note-templates.js +0 -232
- package/dist/vendor/electron/domain/properties.d.ts +0 -10
- package/dist/vendor/electron/domain/properties.js +0 -1549
- package/dist/vendor/electron/domain/saved-view-analytics.d.ts +0 -45
- package/dist/vendor/electron/domain/saved-view-analytics.js +0 -365
- package/dist/vendor/electron/domain/saved-view-relative-date.d.ts +0 -21
- package/dist/vendor/electron/domain/saved-view-relative-date.js +0 -153
- package/dist/vendor/electron/domain/saved-views.d.ts +0 -61
- package/dist/vendor/electron/domain/saved-views.js +0 -1120
- package/dist/vendor/electron/rpc.d.ts +0 -22
- package/dist/vendor/electron/rpc.js +0 -27
- package/dist/vendor/electron/shared/ai-errors.d.ts +0 -11
- package/dist/vendor/electron/shared/ai-errors.js +0 -107
- package/dist/vendor/electron/shared/external-types.d.ts +0 -20
- package/dist/vendor/electron/shared/external-types.js +0 -1
- package/dist/vendor/electron/shared/index.d.ts +0 -9
- package/dist/vendor/electron/shared/index.js +0 -7
- package/dist/vendor/electron/shared/note-properties.d.ts +0 -328
- package/dist/vendor/electron/shared/note-properties.js +0 -1027
- package/dist/vendor/electron/shared/note-templates.d.ts +0 -82
- package/dist/vendor/electron/shared/note-templates.js +0 -84
- package/dist/vendor/electron/shared/powersync-read-models.d.ts +0 -1716
- package/dist/vendor/electron/shared/powersync-read-models.js +0 -1
- package/dist/vendor/electron/shared/remote-device-agent.d.ts +0 -375
- package/dist/vendor/electron/shared/remote-device-agent.js +0 -191
- package/dist/vendor/electron/shared/saved-views.d.ts +0 -394
- package/dist/vendor/electron/shared/saved-views.js +0 -981
- package/dist/vendor/electron/shared/task-priority.d.ts +0 -42
- package/dist/vendor/electron/shared/task-priority.js +0 -186
- package/dist/vendor/electron/sql-utils.d.ts +0 -5
- package/dist/vendor/electron/sql-utils.js +0 -32
|
@@ -0,0 +1,1464 @@
|
|
|
1
|
+
import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
2
|
+
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CLIP_COOKIE_GUIDANCE,
|
|
5
|
+
LOCAL_CLIP_PLATFORMS,
|
|
6
|
+
assertCamoufoxInstalled,
|
|
7
|
+
cookieAdvice,
|
|
8
|
+
cookieImportCommands,
|
|
9
|
+
hasExecutable,
|
|
10
|
+
isCamoufoxInstalled,
|
|
11
|
+
localPlatformSpec,
|
|
12
|
+
missingTools,
|
|
13
|
+
requiredTools,
|
|
14
|
+
setClipVerbose,
|
|
15
|
+
toolInstallHint,
|
|
16
|
+
ytDlpAdvisory,
|
|
17
|
+
ytDlpStatus
|
|
18
|
+
} from "./chunk-XEPDFQYD.js";
|
|
19
|
+
import {
|
|
20
|
+
commandStale,
|
|
21
|
+
parseStringListInput,
|
|
22
|
+
printStaleCacheWarning,
|
|
23
|
+
readNoteWriteReceipt,
|
|
24
|
+
resolveWriteDurabilityForRuntime,
|
|
25
|
+
syncBeforeNoteCommand,
|
|
26
|
+
waitForMutationUpload,
|
|
27
|
+
withNoteDatabase
|
|
28
|
+
} from "./chunk-A6WF7CZL.js";
|
|
29
|
+
import {
|
|
30
|
+
reportProgress
|
|
31
|
+
} from "./chunk-BZQYECIH.js";
|
|
32
|
+
import {
|
|
33
|
+
convertMarkdownToNoteContent,
|
|
34
|
+
createNote,
|
|
35
|
+
resolveAuthIdentity,
|
|
36
|
+
resolveZettelBoxIdsForCreate,
|
|
37
|
+
uploadToOfficialStorage,
|
|
38
|
+
validateTagsForCreate
|
|
39
|
+
} from "./chunk-WC3GSQBC.js";
|
|
40
|
+
import {
|
|
41
|
+
isWorkbuddyUrl,
|
|
42
|
+
normalizeWorkbuddyUrl
|
|
43
|
+
} from "./chunk-BDLS5EEP.js";
|
|
44
|
+
import {
|
|
45
|
+
isXiaoheiheUrl,
|
|
46
|
+
normalizeXiaoheiheUrl
|
|
47
|
+
} from "./chunk-3EKNTO6G.js";
|
|
48
|
+
import {
|
|
49
|
+
isXiaohongshuUrl,
|
|
50
|
+
normalizeXiaohongshuUrl
|
|
51
|
+
} from "./chunk-XFVLNCOW.js";
|
|
52
|
+
import {
|
|
53
|
+
isXiaoyuzhouUrl,
|
|
54
|
+
normalizeXiaoyuzhouUrl
|
|
55
|
+
} from "./chunk-KL75BFYJ.js";
|
|
56
|
+
import {
|
|
57
|
+
isYoutubeHostUrl,
|
|
58
|
+
isYoutubeUrl,
|
|
59
|
+
normalizeYoutubeUrl
|
|
60
|
+
} from "./chunk-PK5AOVLU.js";
|
|
61
|
+
import {
|
|
62
|
+
isZcoolUrl,
|
|
63
|
+
normalizeZcoolUrl
|
|
64
|
+
} from "./chunk-Q6G7VO5G.js";
|
|
65
|
+
import {
|
|
66
|
+
detectZhihuContentType,
|
|
67
|
+
isZhihuUrl,
|
|
68
|
+
normalizeZhihuUrl
|
|
69
|
+
} from "./chunk-P4LG4DIO.js";
|
|
70
|
+
import {
|
|
71
|
+
isImaUrl,
|
|
72
|
+
normalizeImaUrl
|
|
73
|
+
} from "./chunk-2M7RJATW.js";
|
|
74
|
+
import {
|
|
75
|
+
detectInstagramContentType,
|
|
76
|
+
isInstagramUrl,
|
|
77
|
+
normalizeInstagramUrl
|
|
78
|
+
} from "./chunk-VNB4ZFLN.js";
|
|
79
|
+
import {
|
|
80
|
+
isJikeUrl,
|
|
81
|
+
normalizeJikeUrl
|
|
82
|
+
} from "./chunk-67RXND3H.js";
|
|
83
|
+
import {
|
|
84
|
+
isMetasoUrl,
|
|
85
|
+
normalizeMetasoUrl
|
|
86
|
+
} from "./chunk-X7IZXCSL.js";
|
|
87
|
+
import {
|
|
88
|
+
isThreadsUrl,
|
|
89
|
+
normalizeThreadsUrl
|
|
90
|
+
} from "./chunk-ZGF3OEWR.js";
|
|
91
|
+
import {
|
|
92
|
+
detectTwitterContentType,
|
|
93
|
+
isTwitterUrl,
|
|
94
|
+
normalizeTwitterUrl,
|
|
95
|
+
replaceMarkdownMediaUrls
|
|
96
|
+
} from "./chunk-OG6MBAGC.js";
|
|
97
|
+
import {
|
|
98
|
+
isWechatArticleUrl,
|
|
99
|
+
normalizeWechatArticleUrl
|
|
100
|
+
} from "./chunk-FKLZZGEX.js";
|
|
101
|
+
import {
|
|
102
|
+
detectWeiboContentType,
|
|
103
|
+
isWeiboUrl,
|
|
104
|
+
normalizeWeiboUrl
|
|
105
|
+
} from "./chunk-77UP745T.js";
|
|
106
|
+
import {
|
|
107
|
+
isBohaishibeiUrl,
|
|
108
|
+
normalizeBohaishibeiUrl
|
|
109
|
+
} from "./chunk-NGIIELO4.js";
|
|
110
|
+
import {
|
|
111
|
+
isDedaoNoteUrl,
|
|
112
|
+
normalizeDedaoNoteUrl
|
|
113
|
+
} from "./chunk-MCFXD2LS.js";
|
|
114
|
+
import {
|
|
115
|
+
isDoubanGroupTopicUrl,
|
|
116
|
+
isDoubanTopicUrl,
|
|
117
|
+
normalizeDoubanGroupTopicUrl,
|
|
118
|
+
normalizeDoubanTopicUrl
|
|
119
|
+
} from "./chunk-D5SBKLDX.js";
|
|
120
|
+
import {
|
|
121
|
+
isDoubaoUrl,
|
|
122
|
+
normalizeDoubaoUrl
|
|
123
|
+
} from "./chunk-IAEJG5NI.js";
|
|
124
|
+
import {
|
|
125
|
+
isDouyinImagePostUrl,
|
|
126
|
+
isDouyinUrl,
|
|
127
|
+
normalizeDouyinUrl
|
|
128
|
+
} from "./chunk-ABYPGMDC.js";
|
|
129
|
+
import {
|
|
130
|
+
detectFacebookContentType,
|
|
131
|
+
isFacebookUrl,
|
|
132
|
+
normalizeFacebookUrl
|
|
133
|
+
} from "./chunk-HIJXC3RT.js";
|
|
134
|
+
import {
|
|
135
|
+
isFeishuUrl,
|
|
136
|
+
normalizeFeishuUrl
|
|
137
|
+
} from "./chunk-KCHHY6QB.js";
|
|
138
|
+
import {
|
|
139
|
+
AI_SERVICE_URL,
|
|
140
|
+
generateId,
|
|
141
|
+
toAuthorizationHeaderValue
|
|
142
|
+
} from "./chunk-DR6BGSZM.js";
|
|
143
|
+
import "./chunk-BKCNERPB.js";
|
|
144
|
+
import "./chunk-ZHKS4R4P.js";
|
|
145
|
+
import "./chunk-7ODU7LXP.js";
|
|
146
|
+
import "./chunk-WMJXAF3X.js";
|
|
147
|
+
import {
|
|
148
|
+
clipCookiesFile
|
|
149
|
+
} from "./chunk-QFUD3I7W.js";
|
|
150
|
+
import "./chunk-MLOITAK6.js";
|
|
151
|
+
import {
|
|
152
|
+
parseNetscapeCookies,
|
|
153
|
+
selectCookiesForUrl
|
|
154
|
+
} from "./chunk-ULKGDBAJ.js";
|
|
155
|
+
import {
|
|
156
|
+
getRequestedStructuredOutputFormat,
|
|
157
|
+
printHumanReadableLine,
|
|
158
|
+
printSuccess,
|
|
159
|
+
resolveUserPath
|
|
160
|
+
} from "./chunk-6D3QLMRM.js";
|
|
161
|
+
import {
|
|
162
|
+
getDataDir
|
|
163
|
+
} from "./chunk-XZLFMJOG.js";
|
|
164
|
+
import {
|
|
165
|
+
DinoxError
|
|
166
|
+
} from "./chunk-3VZNZWDG.js";
|
|
167
|
+
import {
|
|
168
|
+
isApplePodcastUrl,
|
|
169
|
+
normalizeApplePodcastUrl
|
|
170
|
+
} from "./chunk-TIXOORAP.js";
|
|
171
|
+
import {
|
|
172
|
+
isBbcUrl,
|
|
173
|
+
normalizeBbcUrl
|
|
174
|
+
} from "./chunk-X36EIV25.js";
|
|
175
|
+
import {
|
|
176
|
+
isWebClipUrl,
|
|
177
|
+
normalizeWebUrl
|
|
178
|
+
} from "./chunk-PTFGE4KS.js";
|
|
179
|
+
import "./chunk-W7R5JTSA.js";
|
|
180
|
+
import {
|
|
181
|
+
isBilibiliUrl,
|
|
182
|
+
normalizeBilibiliUrl,
|
|
183
|
+
parseBilibiliPostRef
|
|
184
|
+
} from "./chunk-5JF7J5MP.js";
|
|
185
|
+
import {
|
|
186
|
+
isAbortOrTimeoutError,
|
|
187
|
+
isTransientError
|
|
188
|
+
} from "./chunk-QZQRG3JY.js";
|
|
189
|
+
import {
|
|
190
|
+
unwrapRedirectUrl
|
|
191
|
+
} from "./chunk-URYABAYN.js";
|
|
192
|
+
import {
|
|
193
|
+
clipEngineConfig,
|
|
194
|
+
configureClipEngine
|
|
195
|
+
} from "./chunk-F7BDWXBG.js";
|
|
196
|
+
import {
|
|
197
|
+
collectMarkdownImageRefs,
|
|
198
|
+
escapeMarkdownLinkText,
|
|
199
|
+
escapeMarkdownTitle
|
|
200
|
+
} from "./chunk-6VMHHE5Y.js";
|
|
201
|
+
import "./chunk-KOAKG2QU.js";
|
|
202
|
+
import "./chunk-XQZUX7OT.js";
|
|
203
|
+
|
|
204
|
+
// src/commands/clip/run.ts
|
|
205
|
+
import fs4 from "node:fs/promises";
|
|
206
|
+
import os from "node:os";
|
|
207
|
+
import path4 from "node:path";
|
|
208
|
+
|
|
209
|
+
// ../../packages/clip-engine/src/clip/detect.ts
|
|
210
|
+
function detectArticleClipTarget(inputUrl) {
|
|
211
|
+
const unwrapped = unwrapRedirectUrl(inputUrl.trim());
|
|
212
|
+
const rawUrl = unwrapped === inputUrl.trim() ? inputUrl : unwrapped;
|
|
213
|
+
const applePodcastUrl = normalizeApplePodcastUrl(rawUrl);
|
|
214
|
+
if (isApplePodcastUrl(applePodcastUrl)) {
|
|
215
|
+
return {
|
|
216
|
+
contentType: "audio",
|
|
217
|
+
platform: "apple_podcast",
|
|
218
|
+
url: applePodcastUrl
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const twitterUrl = normalizeTwitterUrl(rawUrl);
|
|
222
|
+
if (isTwitterUrl(twitterUrl)) {
|
|
223
|
+
return {
|
|
224
|
+
contentType: detectTwitterContentType(twitterUrl),
|
|
225
|
+
platform: "twitter",
|
|
226
|
+
url: twitterUrl
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const threadsUrl = normalizeThreadsUrl(rawUrl);
|
|
230
|
+
if (isThreadsUrl(threadsUrl)) {
|
|
231
|
+
return {
|
|
232
|
+
contentType: "post",
|
|
233
|
+
platform: "threads",
|
|
234
|
+
url: threadsUrl
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const instagramUrl = normalizeInstagramUrl(rawUrl);
|
|
238
|
+
if (isInstagramUrl(instagramUrl)) {
|
|
239
|
+
return {
|
|
240
|
+
contentType: detectInstagramContentType(instagramUrl),
|
|
241
|
+
platform: "instagram",
|
|
242
|
+
url: instagramUrl
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const facebookUrl = normalizeFacebookUrl(rawUrl);
|
|
246
|
+
if (isFacebookUrl(facebookUrl)) {
|
|
247
|
+
return {
|
|
248
|
+
contentType: detectFacebookContentType(facebookUrl),
|
|
249
|
+
platform: "facebook",
|
|
250
|
+
url: facebookUrl
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
const zhihuUrl = normalizeZhihuUrl(rawUrl);
|
|
254
|
+
if (isZhihuUrl(zhihuUrl)) {
|
|
255
|
+
return {
|
|
256
|
+
contentType: detectZhihuContentType(zhihuUrl),
|
|
257
|
+
platform: "zhihu",
|
|
258
|
+
url: zhihuUrl
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
const bilibiliUrl = normalizeBilibiliUrl(rawUrl);
|
|
262
|
+
if (isBilibiliUrl(bilibiliUrl)) {
|
|
263
|
+
const postRef = parseBilibiliPostRef(bilibiliUrl);
|
|
264
|
+
return {
|
|
265
|
+
// b23.tv links are only resolved by the runner; they stay 'video' here.
|
|
266
|
+
contentType: postRef ? postRef.kind === "article" ? "article" : "note" : "video",
|
|
267
|
+
platform: "bilibili",
|
|
268
|
+
url: bilibiliUrl
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const douyinUrl = normalizeDouyinUrl(rawUrl);
|
|
272
|
+
if (isDouyinUrl(douyinUrl)) {
|
|
273
|
+
return {
|
|
274
|
+
// Short links are resolved at clip time; only explicit /note|/slides URLs are known image posts.
|
|
275
|
+
contentType: isDouyinImagePostUrl(douyinUrl) ? "note" : "video",
|
|
276
|
+
platform: "douyin",
|
|
277
|
+
url: douyinUrl
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const youtubeUrl = normalizeYoutubeUrl(rawUrl);
|
|
281
|
+
if (isYoutubeUrl(youtubeUrl) || isYoutubeHostUrl(rawUrl) || isYoutubeHostUrl(youtubeUrl)) {
|
|
282
|
+
return {
|
|
283
|
+
contentType: "video",
|
|
284
|
+
platform: "youtube",
|
|
285
|
+
url: isYoutubeUrl(youtubeUrl) ? youtubeUrl : youtubeUrl || rawUrl
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const xiaoyuzhouUrl = normalizeXiaoyuzhouUrl(rawUrl);
|
|
289
|
+
if (isXiaoyuzhouUrl(xiaoyuzhouUrl)) {
|
|
290
|
+
return {
|
|
291
|
+
contentType: "audio",
|
|
292
|
+
platform: "xiaoyuzhou",
|
|
293
|
+
url: xiaoyuzhouUrl
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const wechatUrl = normalizeWechatArticleUrl(rawUrl);
|
|
297
|
+
if (isWechatArticleUrl(wechatUrl)) {
|
|
298
|
+
return {
|
|
299
|
+
contentType: "article",
|
|
300
|
+
platform: "wechat_official_account",
|
|
301
|
+
url: wechatUrl
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const xiaohongshuUrl = normalizeXiaohongshuUrl(rawUrl);
|
|
305
|
+
if (isXiaohongshuUrl(xiaohongshuUrl)) {
|
|
306
|
+
return {
|
|
307
|
+
contentType: "note",
|
|
308
|
+
platform: "xiaohongshu",
|
|
309
|
+
url: xiaohongshuUrl
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const weiboUrl = normalizeWeiboUrl(rawUrl);
|
|
313
|
+
if (isWeiboUrl(weiboUrl)) {
|
|
314
|
+
return {
|
|
315
|
+
contentType: detectWeiboContentType(weiboUrl),
|
|
316
|
+
platform: "weibo",
|
|
317
|
+
url: weiboUrl
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const xiaoheiheUrl = normalizeXiaoheiheUrl(rawUrl);
|
|
321
|
+
if (isXiaoheiheUrl(xiaoheiheUrl)) {
|
|
322
|
+
return {
|
|
323
|
+
contentType: "post",
|
|
324
|
+
platform: "xiaoheihe",
|
|
325
|
+
url: xiaoheiheUrl
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const doubaoUrl = normalizeDoubaoUrl(rawUrl);
|
|
329
|
+
if (isDoubaoUrl(doubaoUrl)) {
|
|
330
|
+
return {
|
|
331
|
+
contentType: "answer",
|
|
332
|
+
platform: "doubao",
|
|
333
|
+
url: doubaoUrl
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const imaUrl = normalizeImaUrl(rawUrl);
|
|
337
|
+
if (isImaUrl(imaUrl)) {
|
|
338
|
+
return {
|
|
339
|
+
contentType: "answer",
|
|
340
|
+
platform: "ima",
|
|
341
|
+
url: imaUrl
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const doubanGroupUrl = normalizeDoubanGroupTopicUrl(rawUrl);
|
|
345
|
+
if (isDoubanGroupTopicUrl(doubanGroupUrl)) {
|
|
346
|
+
return {
|
|
347
|
+
contentType: "post",
|
|
348
|
+
platform: "douban_group",
|
|
349
|
+
url: doubanGroupUrl
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
const doubanTopicUrl = normalizeDoubanTopicUrl(rawUrl);
|
|
353
|
+
if (isDoubanTopicUrl(doubanTopicUrl)) {
|
|
354
|
+
return {
|
|
355
|
+
contentType: "post",
|
|
356
|
+
platform: "douban_topic",
|
|
357
|
+
url: doubanTopicUrl
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const jikeUrl = normalizeJikeUrl(rawUrl);
|
|
361
|
+
if (isJikeUrl(jikeUrl)) {
|
|
362
|
+
return {
|
|
363
|
+
contentType: "post",
|
|
364
|
+
platform: "jike",
|
|
365
|
+
url: jikeUrl
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const metasoUrl = normalizeMetasoUrl(rawUrl);
|
|
369
|
+
if (isMetasoUrl(metasoUrl)) {
|
|
370
|
+
return {
|
|
371
|
+
contentType: "answer",
|
|
372
|
+
platform: "metaso",
|
|
373
|
+
url: metasoUrl
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
const workbuddyUrl = normalizeWorkbuddyUrl(rawUrl);
|
|
377
|
+
if (isWorkbuddyUrl(workbuddyUrl)) {
|
|
378
|
+
return {
|
|
379
|
+
contentType: "answer",
|
|
380
|
+
platform: "workbuddy",
|
|
381
|
+
url: workbuddyUrl
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
const dedaoNoteUrl = normalizeDedaoNoteUrl(rawUrl);
|
|
385
|
+
if (isDedaoNoteUrl(dedaoNoteUrl)) {
|
|
386
|
+
return {
|
|
387
|
+
contentType: "note",
|
|
388
|
+
platform: "dedao_note",
|
|
389
|
+
url: dedaoNoteUrl
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const bohaishibeiUrl = normalizeBohaishibeiUrl(rawUrl);
|
|
393
|
+
if (isBohaishibeiUrl(bohaishibeiUrl)) {
|
|
394
|
+
return {
|
|
395
|
+
contentType: "article",
|
|
396
|
+
platform: "bohaishibei",
|
|
397
|
+
url: bohaishibeiUrl
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const zcoolUrl = normalizeZcoolUrl(rawUrl);
|
|
401
|
+
if (isZcoolUrl(zcoolUrl)) {
|
|
402
|
+
return {
|
|
403
|
+
contentType: "article",
|
|
404
|
+
platform: "zcool",
|
|
405
|
+
url: zcoolUrl
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const bbcUrl = normalizeBbcUrl(rawUrl);
|
|
409
|
+
if (isBbcUrl(bbcUrl)) {
|
|
410
|
+
return {
|
|
411
|
+
contentType: "article",
|
|
412
|
+
platform: "bbc",
|
|
413
|
+
url: bbcUrl
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const feishuUrl = normalizeFeishuUrl(rawUrl);
|
|
417
|
+
if (isFeishuUrl(feishuUrl)) {
|
|
418
|
+
return {
|
|
419
|
+
contentType: "article",
|
|
420
|
+
platform: "feishu",
|
|
421
|
+
url: feishuUrl
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
const webUrl = normalizeWebUrl(rawUrl);
|
|
425
|
+
if (isWebClipUrl(webUrl)) {
|
|
426
|
+
return {
|
|
427
|
+
contentType: "article",
|
|
428
|
+
platform: "web",
|
|
429
|
+
url: webUrl
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
throw new Error("unsupported link clip URL");
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/commands/clip/errors.ts
|
|
436
|
+
function engineCode(error) {
|
|
437
|
+
const code = error && typeof error === "object" ? error.code : void 0;
|
|
438
|
+
return typeof code === "string" ? code : void 0;
|
|
439
|
+
}
|
|
440
|
+
function hostOf(url) {
|
|
441
|
+
try {
|
|
442
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
443
|
+
} catch {
|
|
444
|
+
return url;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function classifyClipError(error, context) {
|
|
448
|
+
if (error instanceof DinoxError) return error;
|
|
449
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
450
|
+
const code = engineCode(error);
|
|
451
|
+
const host = hostOf(context.url);
|
|
452
|
+
const guidance = CLIP_COOKIE_GUIDANCE[context.platform];
|
|
453
|
+
const cookieDomain = guidance?.domain ?? host;
|
|
454
|
+
const base = {
|
|
455
|
+
platform: context.platform,
|
|
456
|
+
url: context.url,
|
|
457
|
+
host,
|
|
458
|
+
engineCode: code ?? null,
|
|
459
|
+
cookiesSent: context.cookiesSent,
|
|
460
|
+
...guidance ? { cookies: { need: guidance.need, domain: guidance.domain, saved: (context.cookiesSent ?? 0) > 0, import: cookieImportCommands(guidance.domain) } } : {}
|
|
461
|
+
};
|
|
462
|
+
if (code && /^INVALID_[A-Z_]+_URL$/.test(code)) {
|
|
463
|
+
return new DinoxError(`Not a clippable URL: ${context.url}`, {
|
|
464
|
+
code: "INVALID_ARGUMENT",
|
|
465
|
+
cause: error,
|
|
466
|
+
details: { ...base, reason: "invalid_url", retryable: false }
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
if (code === "UNSUPPORTED_CONTENT_TYPE") {
|
|
470
|
+
return new DinoxError(`This kind of ${context.platform} link cannot be clipped: ${message}`, {
|
|
471
|
+
code: "CLIP_PLATFORM_UNSUPPORTED",
|
|
472
|
+
cause: error,
|
|
473
|
+
details: { ...base, reason: "content_type_unsupported", retryable: false },
|
|
474
|
+
suggestion: "Tell the user this link type is not clippable; a post/article/video page of the same site may be."
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
if (code === "LOGIN_WALL" || code === "NO_ACCESS" || code === "PASSWORD_PROTECTED") {
|
|
478
|
+
return new DinoxError(`${host} requires login: ${message}`, {
|
|
479
|
+
code: "CLIP_LOGIN_REQUIRED",
|
|
480
|
+
cause: error,
|
|
481
|
+
recoverable: true,
|
|
482
|
+
details: { ...base, reason: "login_required", retryable: false },
|
|
483
|
+
suggestion: context.cookiesSent ? `The saved ${cookieDomain} cookies were rejected (likely expired or logged out). Ask the user to export fresh cookies from a browser where they are logged in to ${cookieDomain}.` : `Ask the user to export ${cookieDomain} cookies from a browser where they are logged in (Netscape cookies.txt, or the Cookie request header from devtools) and import them.`,
|
|
484
|
+
suggestedAction: {
|
|
485
|
+
command: `dino clip cookies-import <cookies.txt> --domain ${cookieDomain} --format json`,
|
|
486
|
+
reason: "Clip with the user's own logged-in session"
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
if (code === "WECHAT_VERIFICATION_BLOCKED") {
|
|
491
|
+
return new DinoxError(`WeChat asked for an environment verification instead of the article: ${message}`, {
|
|
492
|
+
code: "CLIP_BLOCKED",
|
|
493
|
+
cause: error,
|
|
494
|
+
recoverable: true,
|
|
495
|
+
details: { ...base, reason: "wechat_verification", retryable: true },
|
|
496
|
+
suggestion: "WeChat rate-limits this network. Wait a few minutes before retrying, and do not retry in a loop; another network (--proxy) may work sooner.",
|
|
497
|
+
suggestedAction: { command: `dino clip add ${context.url} --format json`, reason: "Retry after a pause of several minutes" }
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
if (code === "RATE_LIMITED" || code === "DOMAIN_PAUSED") {
|
|
501
|
+
return new DinoxError(`${host} is rate-limiting requests: ${message}`, {
|
|
502
|
+
code: "CLIP_BLOCKED",
|
|
503
|
+
cause: error,
|
|
504
|
+
recoverable: true,
|
|
505
|
+
details: { ...base, reason: "rate_limited", retryable: true },
|
|
506
|
+
suggestion: "Wait several minutes before retrying; do not retry in a loop.",
|
|
507
|
+
suggestedAction: { command: `dino clip add ${context.url} --format json`, reason: "Retry after a pause of several minutes" }
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
if (code === "CAPTURE_BLOCKED") {
|
|
511
|
+
return new DinoxError(`${host} blocked the page capture: ${message}`, {
|
|
512
|
+
code: "CLIP_BLOCKED",
|
|
513
|
+
cause: error,
|
|
514
|
+
recoverable: true,
|
|
515
|
+
details: { ...base, reason: "blocked", retryable: true },
|
|
516
|
+
suggestion: context.cookiesSent ? "Retry later, or through another network with --proxy." : `Retry later, through another network with --proxy, or with the user's ${cookieDomain} cookies imported (ask the user to export them).`,
|
|
517
|
+
suggestedAction: { command: `dino clip add ${context.url} --format json`, reason: "Retry after a pause" }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
if (code === "CONTENT_NOT_FOUND" || code === "CONTENT_EXPIRED" || code === "SHARE_EXPIRED" || code === "VIDEO_NOT_FOUND" || code === "AUDIO_NOT_FOUND" || code === "TITLE_NOT_FOUND") {
|
|
521
|
+
return new DinoxError(`No article content found at ${context.url}: ${message}`, {
|
|
522
|
+
code: "CLIP_CONTENT_NOT_FOUND",
|
|
523
|
+
cause: error,
|
|
524
|
+
details: {
|
|
525
|
+
...base,
|
|
526
|
+
reason: code === "CONTENT_EXPIRED" || code === "SHARE_EXPIRED" ? "content_expired" : "content_not_found",
|
|
527
|
+
retryable: false
|
|
528
|
+
},
|
|
529
|
+
suggestion: context.cookiesSent === 0 ? `The page may be deleted, private, or behind a login. If it needs login, ask the user for their ${cookieDomain} cookies and import them.` : "The page may be deleted, private, or not an article."
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
if (isAbortOrTimeoutError(error)) {
|
|
533
|
+
return new DinoxError(`Clipping ${context.url} timed out: ${message}`, {
|
|
534
|
+
code: "CLIP_EXTRACT_FAILED",
|
|
535
|
+
cause: error,
|
|
536
|
+
recoverable: true,
|
|
537
|
+
details: { ...base, reason: "timeout", retryable: true, timeoutMs: context.timeoutMs },
|
|
538
|
+
suggestedAction: {
|
|
539
|
+
command: `dino clip add ${context.url} --timeout ${Math.min(context.timeoutMs * 2, 6e5)} --format json`,
|
|
540
|
+
reason: "Retry with a longer page-capture timeout"
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
if (isTransientError(error)) {
|
|
545
|
+
return new DinoxError(`Network error while clipping ${context.url}: ${message}`, {
|
|
546
|
+
code: "CLIP_EXTRACT_FAILED",
|
|
547
|
+
cause: error,
|
|
548
|
+
recoverable: true,
|
|
549
|
+
details: { ...base, reason: "network", retryable: true },
|
|
550
|
+
suggestion: "Retry; if the site is unreachable from this network, pass --proxy http://host:port.",
|
|
551
|
+
suggestedAction: { command: `dino clip add ${context.url} --format json`, reason: "Retry the clip" }
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
return new DinoxError(`Clipping ${context.url} failed: ${message}`, {
|
|
555
|
+
code: "CLIP_EXTRACT_FAILED",
|
|
556
|
+
cause: error,
|
|
557
|
+
details: { ...base, reason: code ? code.toLowerCase() : "unknown", retryable: false },
|
|
558
|
+
suggestion: "Rerun with --verbose for the engine log on stderr."
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/commands/clip/pacing.ts
|
|
563
|
+
import fs from "node:fs/promises";
|
|
564
|
+
import path from "node:path";
|
|
565
|
+
var PLATFORM_INTERVAL_MS = {
|
|
566
|
+
xiaohongshu: 3e4,
|
|
567
|
+
instagram: 3e4,
|
|
568
|
+
facebook: 3e4,
|
|
569
|
+
threads: 2e4,
|
|
570
|
+
wechat_official_account: 2e4,
|
|
571
|
+
douyin: 2e4,
|
|
572
|
+
douban_group: 2e4,
|
|
573
|
+
douban_topic: 2e4,
|
|
574
|
+
bilibili: 15e3,
|
|
575
|
+
weibo: 15e3,
|
|
576
|
+
zhihu: 15e3,
|
|
577
|
+
jike: 1e4,
|
|
578
|
+
xiaoheihe: 1e4,
|
|
579
|
+
youtube: 1e4,
|
|
580
|
+
twitter: 1e4
|
|
581
|
+
};
|
|
582
|
+
var DEFAULT_INTERVAL_MS = 5e3;
|
|
583
|
+
var MAX_WAIT_MS = 12e4;
|
|
584
|
+
var BLOCK_COOLDOWN_MS = {
|
|
585
|
+
wechat_verification: 30 * 6e4,
|
|
586
|
+
rate_limited: 15 * 6e4,
|
|
587
|
+
blocked: 10 * 6e4
|
|
588
|
+
};
|
|
589
|
+
var LOCK_STALE_MS = 1e4;
|
|
590
|
+
var LOCK_RETRY_MS = 50;
|
|
591
|
+
function pacingKey(platform, url) {
|
|
592
|
+
if (platform !== "web") return platform;
|
|
593
|
+
try {
|
|
594
|
+
return `web:${new URL(url).hostname.replace(/^www\./, "")}`;
|
|
595
|
+
} catch {
|
|
596
|
+
return "web";
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function pacingIntervalMs(platform) {
|
|
600
|
+
return PLATFORM_INTERVAL_MS[platform] ?? DEFAULT_INTERVAL_MS;
|
|
601
|
+
}
|
|
602
|
+
function pacingFile(deps) {
|
|
603
|
+
return deps.file ?? path.join(getDataDir(), "clip-pacing.json");
|
|
604
|
+
}
|
|
605
|
+
async function withLock(file, run) {
|
|
606
|
+
const lock = `${file}.lock`;
|
|
607
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
608
|
+
for (; ; ) {
|
|
609
|
+
try {
|
|
610
|
+
await fs.mkdir(lock);
|
|
611
|
+
break;
|
|
612
|
+
} catch (error) {
|
|
613
|
+
if (error.code !== "EEXIST") throw error;
|
|
614
|
+
const stats = await fs.stat(lock).catch(() => null);
|
|
615
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) await fs.rm(lock, { recursive: true, force: true });
|
|
616
|
+
else await new Promise((resolve) => setTimeout(resolve, LOCK_RETRY_MS));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
return await run();
|
|
621
|
+
} finally {
|
|
622
|
+
await fs.rm(lock, { recursive: true, force: true });
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
async function readState(file) {
|
|
626
|
+
try {
|
|
627
|
+
const parsed = JSON.parse(await fs.readFile(file, "utf8"));
|
|
628
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
629
|
+
} catch {
|
|
630
|
+
return {};
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
async function writeState(file, state, now) {
|
|
634
|
+
for (const [key, entry] of Object.entries(state)) {
|
|
635
|
+
if ((entry.nextAt ?? 0) <= now && (entry.cooldownUntil ?? 0) <= now) delete state[key];
|
|
636
|
+
}
|
|
637
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
638
|
+
await fs.writeFile(tmp, JSON.stringify(state), { mode: 384 });
|
|
639
|
+
await fs.rename(tmp, file);
|
|
640
|
+
}
|
|
641
|
+
function blockedError(input) {
|
|
642
|
+
const retryAfterMs = Math.max(0, input.retryAt - input.now);
|
|
643
|
+
return new DinoxError(input.message, {
|
|
644
|
+
code: "CLIP_BLOCKED",
|
|
645
|
+
recoverable: true,
|
|
646
|
+
details: {
|
|
647
|
+
reason: input.reason,
|
|
648
|
+
retryable: true,
|
|
649
|
+
site: input.key,
|
|
650
|
+
url: input.url,
|
|
651
|
+
retryAfterMs,
|
|
652
|
+
retryAt: new Date(input.retryAt).toISOString(),
|
|
653
|
+
...input.cooldownReason ? { cooldownReason: input.cooldownReason } : {}
|
|
654
|
+
},
|
|
655
|
+
suggestion: input.suggestion,
|
|
656
|
+
suggestedAction: {
|
|
657
|
+
command: `dino clip add ${input.url} --format json`,
|
|
658
|
+
reason: `Retry after ${Math.ceil(retryAfterMs / 1e3)} s (not sooner)`
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
async function awaitClipSlot(input, deps = {}) {
|
|
663
|
+
const file = pacingFile(deps);
|
|
664
|
+
const now = (deps.now ?? Date.now)();
|
|
665
|
+
const key = pacingKey(input.platform, input.url);
|
|
666
|
+
const interval = pacingIntervalMs(input.platform);
|
|
667
|
+
const slot = await withLock(file, async () => {
|
|
668
|
+
const state = await readState(file);
|
|
669
|
+
const entry = state[key] ?? {};
|
|
670
|
+
if (entry.cooldownUntil && entry.cooldownUntil > now) {
|
|
671
|
+
throw blockedError({
|
|
672
|
+
message: `${key} blocked a recent clip; no request is sent until its cooldown ends`,
|
|
673
|
+
reason: "cooldown",
|
|
674
|
+
key,
|
|
675
|
+
url: input.url,
|
|
676
|
+
retryAt: entry.cooldownUntil,
|
|
677
|
+
now,
|
|
678
|
+
...entry.cooldownReason ? { cooldownReason: entry.cooldownReason } : {},
|
|
679
|
+
suggestion: "The site flagged this network (and possibly the logged-in account). Stop clipping this site until retryAt; tell the user. Clipping other sites is fine."
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const at = Math.max(now, entry.nextAt ?? 0);
|
|
683
|
+
if (at - now > MAX_WAIT_MS) {
|
|
684
|
+
throw blockedError({
|
|
685
|
+
message: `Too many ${key} clips queued; clips of one site are spaced ${Math.round(interval / 1e3)} s apart to avoid its risk control`,
|
|
686
|
+
reason: "paced",
|
|
687
|
+
key,
|
|
688
|
+
url: input.url,
|
|
689
|
+
retryAt: at,
|
|
690
|
+
now,
|
|
691
|
+
suggestion: `Clip links of one site one at a time, not in parallel; this one can run at retryAt. Different sites may run meanwhile.`
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
state[key] = { ...entry, nextAt: at + interval };
|
|
695
|
+
await writeState(file, state, now);
|
|
696
|
+
return at;
|
|
697
|
+
});
|
|
698
|
+
const waitMs = slot - now;
|
|
699
|
+
if (waitMs > 0) {
|
|
700
|
+
input.onWait?.(waitMs);
|
|
701
|
+
await (deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
|
|
702
|
+
}
|
|
703
|
+
return { waitedMs: Math.max(0, waitMs) };
|
|
704
|
+
}
|
|
705
|
+
async function recordClipBlock(input, deps = {}) {
|
|
706
|
+
const cooldown = BLOCK_COOLDOWN_MS[input.reason];
|
|
707
|
+
if (!cooldown) return null;
|
|
708
|
+
const file = pacingFile(deps);
|
|
709
|
+
const now = (deps.now ?? Date.now)();
|
|
710
|
+
const key = pacingKey(input.platform, input.url);
|
|
711
|
+
const until = now + cooldown;
|
|
712
|
+
await withLock(file, async () => {
|
|
713
|
+
const state = await readState(file);
|
|
714
|
+
state[key] = { ...state[key], cooldownUntil: until, cooldownReason: input.reason };
|
|
715
|
+
await writeState(file, state, now);
|
|
716
|
+
}).catch(() => void 0);
|
|
717
|
+
return until;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// src/commands/clip/postProcess.ts
|
|
721
|
+
import { spawn } from "node:child_process";
|
|
722
|
+
import fs2 from "node:fs/promises";
|
|
723
|
+
import path2 from "node:path";
|
|
724
|
+
var REQUEST_TIMEOUT_MS = 2e4;
|
|
725
|
+
var SYNC_PENDING_RETRY_DELAYS_MS = [2e3, 4e3, 8e3];
|
|
726
|
+
async function requestClipPostProcessing(deps, input) {
|
|
727
|
+
if (input.primaryResource) {
|
|
728
|
+
return await requestTranscription(deps, { noteId: input.noteId, resourceId: input.primaryResource.resourceId });
|
|
729
|
+
}
|
|
730
|
+
return await requestEnrichment(deps, input.noteId);
|
|
731
|
+
}
|
|
732
|
+
async function requestTranscription(deps, input) {
|
|
733
|
+
const requestKey = `audio_transcription:${input.resourceId}:v1`;
|
|
734
|
+
const body = {
|
|
735
|
+
kind: "audio_transcription",
|
|
736
|
+
resourceId: input.resourceId,
|
|
737
|
+
noteId: input.noteId,
|
|
738
|
+
source: "link_clip",
|
|
739
|
+
executionPolicy: "self_hosted_preferred",
|
|
740
|
+
requestKey
|
|
741
|
+
};
|
|
742
|
+
const delays = deps.retryDelaysMs ?? SYNC_PENDING_RETRY_DELAYS_MS;
|
|
743
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
744
|
+
const response = await postJson(deps, "/api/resource-processing/jobs", body, { "Idempotency-Key": requestKey });
|
|
745
|
+
if (!response.ok) return { kind: "transcription", status: "failed", message: response.message };
|
|
746
|
+
const envelope = response.body;
|
|
747
|
+
if (envelope?.code === "000000") {
|
|
748
|
+
const jobId = envelope.data?.job?.id;
|
|
749
|
+
return { kind: "transcription", status: "queued", ...typeof jobId === "string" ? { jobId } : {} };
|
|
750
|
+
}
|
|
751
|
+
const message = typeof envelope?.msg === "string" ? envelope.msg : `request failed (${response.status})`;
|
|
752
|
+
if (response.status === 425) {
|
|
753
|
+
const delay = delays[attempt];
|
|
754
|
+
if (delay === void 0) return { kind: "transcription", status: "sync_pending", message };
|
|
755
|
+
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
return { kind: "transcription", status: "failed", message };
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
async function requestEnrichment(deps, noteId) {
|
|
762
|
+
const response = await postJson(deps, "/api/note-enrichment", { noteId, wait: false });
|
|
763
|
+
if (!response.ok) return { kind: "enrichment", status: "failed", message: response.message };
|
|
764
|
+
if (response.status === 202 || response.status === 200) {
|
|
765
|
+
const jobId = response.body?.jobId;
|
|
766
|
+
return { kind: "enrichment", status: "queued", ...typeof jobId === "string" ? { jobId } : {} };
|
|
767
|
+
}
|
|
768
|
+
const error = response.body?.error;
|
|
769
|
+
const message = typeof error?.message === "string" ? error.message : `request failed (${response.status})`;
|
|
770
|
+
if (response.status === 404) return { kind: "enrichment", status: "sync_pending", message };
|
|
771
|
+
return { kind: "enrichment", status: "failed", message };
|
|
772
|
+
}
|
|
773
|
+
async function postJson(deps, pathname, body, headers = {}) {
|
|
774
|
+
try {
|
|
775
|
+
const response = await (deps.fetchImpl ?? fetch)(`${deps.baseUrl ?? AI_SERVICE_URL}${pathname}`, {
|
|
776
|
+
method: "POST",
|
|
777
|
+
headers: {
|
|
778
|
+
Authorization: toAuthorizationHeaderValue(deps.authorization),
|
|
779
|
+
Accept: "application/json",
|
|
780
|
+
"Content-Type": "application/json",
|
|
781
|
+
...headers
|
|
782
|
+
},
|
|
783
|
+
body: JSON.stringify(body),
|
|
784
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
785
|
+
});
|
|
786
|
+
return { ok: true, status: response.status, body: await response.json().catch(() => null) };
|
|
787
|
+
} catch (error) {
|
|
788
|
+
return { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
async function extractVideoFrame(videoPath, workDir) {
|
|
792
|
+
if (!hasExecutable("ffmpeg")) return null;
|
|
793
|
+
const framePath = path2.join(workDir, `frame-${path2.basename(videoPath)}.jpg`);
|
|
794
|
+
const grab = async (args) => {
|
|
795
|
+
await fs2.rm(framePath, { force: true });
|
|
796
|
+
if (!await runFfmpeg([...args, "-frames:v", "1", framePath])) return null;
|
|
797
|
+
const frame = await fs2.readFile(framePath).catch(() => null);
|
|
798
|
+
return frame && frame.byteLength > 0 ? frame : null;
|
|
799
|
+
};
|
|
800
|
+
try {
|
|
801
|
+
return await grab(["-ss", "1", "-i", videoPath]) ?? await grab(["-i", videoPath]);
|
|
802
|
+
} finally {
|
|
803
|
+
await fs2.rm(framePath, { force: true });
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function runFfmpeg(args) {
|
|
807
|
+
return new Promise((resolve) => {
|
|
808
|
+
const child = spawn("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", ...args], { stdio: "ignore" });
|
|
809
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), 3e4);
|
|
810
|
+
child.on("error", () => {
|
|
811
|
+
clearTimeout(timer);
|
|
812
|
+
resolve(false);
|
|
813
|
+
});
|
|
814
|
+
child.on("close", (code) => {
|
|
815
|
+
clearTimeout(timer);
|
|
816
|
+
resolve(code === 0);
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// src/commands/clip/publish.ts
|
|
822
|
+
import fs3 from "node:fs/promises";
|
|
823
|
+
import path3 from "node:path";
|
|
824
|
+
var MAX_MEDIA_BYTES = 600 * 1024 * 1024;
|
|
825
|
+
function isLocalSource(source) {
|
|
826
|
+
const value = source.trim();
|
|
827
|
+
return Boolean(value) && !/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(value) && !path3.isAbsolute(value);
|
|
828
|
+
}
|
|
829
|
+
async function resolveWorkDirFile(workDir, source) {
|
|
830
|
+
if (!isLocalSource(source)) return null;
|
|
831
|
+
const bare = source.trim().split("#")[0]?.split("?")[0] ?? "";
|
|
832
|
+
let decoded = bare;
|
|
833
|
+
try {
|
|
834
|
+
decoded = decodeURIComponent(bare);
|
|
835
|
+
} catch {
|
|
836
|
+
}
|
|
837
|
+
const root = await fs3.realpath(workDir);
|
|
838
|
+
const real = await fs3.realpath(path3.resolve(root, decoded)).catch(() => null);
|
|
839
|
+
if (!real || !real.startsWith(`${root}${path3.sep}`)) return null;
|
|
840
|
+
const info = await fs3.stat(real).catch(() => null);
|
|
841
|
+
return info?.isFile() ? real : null;
|
|
842
|
+
}
|
|
843
|
+
async function publishClipContent(document, input) {
|
|
844
|
+
const failedUploads = [];
|
|
845
|
+
const refs = collectMarkdownImageRefs(document.markdown);
|
|
846
|
+
const uploadedBySource = /* @__PURE__ */ new Map();
|
|
847
|
+
for (const ref of refs) {
|
|
848
|
+
if (uploadedBySource.has(ref.source) || !isLocalSource(ref.source)) continue;
|
|
849
|
+
const filePath = await resolveWorkDirFile(input.workDir, ref.source);
|
|
850
|
+
if (!filePath) {
|
|
851
|
+
uploadedBySource.set(ref.source, null);
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
try {
|
|
855
|
+
const uploaded = await input.upload(filePath, { extraData: { noteId: input.noteId } });
|
|
856
|
+
uploadedBySource.set(ref.source, uploaded.url);
|
|
857
|
+
} catch (error) {
|
|
858
|
+
failedUploads.push(`${ref.source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
859
|
+
uploadedBySource.set(ref.source, null);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
let markdown = document.markdown;
|
|
863
|
+
let uploadedImageCount = 0;
|
|
864
|
+
for (const ref of [...refs].reverse()) {
|
|
865
|
+
if (!isLocalSource(ref.source)) continue;
|
|
866
|
+
const url = uploadedBySource.get(ref.source);
|
|
867
|
+
const title = ref.title ? ` "${escapeMarkdownTitle(ref.title)}"` : "";
|
|
868
|
+
const replacement = url ? `` : "";
|
|
869
|
+
if (url) uploadedImageCount += 1;
|
|
870
|
+
markdown = markdown.slice(0, ref.start) + replacement + markdown.slice(ref.end);
|
|
871
|
+
}
|
|
872
|
+
const inlineUrls = /* @__PURE__ */ new Map();
|
|
873
|
+
for (const media of document.inlineMedia ?? []) {
|
|
874
|
+
try {
|
|
875
|
+
const uploaded = await input.upload(path3.join(input.workDir, ...media.localPath.split("/")), {
|
|
876
|
+
maxBytes: MAX_MEDIA_BYTES,
|
|
877
|
+
extraData: { noteId: input.noteId }
|
|
878
|
+
});
|
|
879
|
+
inlineUrls.set(media.remoteUrl, uploaded.url);
|
|
880
|
+
} catch (error) {
|
|
881
|
+
failedUploads.push(`${media.remoteUrl}: ${error instanceof Error ? error.message : String(error)}`);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (inlineUrls.size > 0) markdown = replaceMarkdownMediaUrls(markdown, inlineUrls);
|
|
885
|
+
let primaryResource = null;
|
|
886
|
+
const primary = document.primaryMedia;
|
|
887
|
+
if (primary && primary.type !== "image") {
|
|
888
|
+
try {
|
|
889
|
+
const uploaded = await input.upload(path3.join(input.workDir, ...primary.localPath.split("/")), {
|
|
890
|
+
maxBytes: MAX_MEDIA_BYTES,
|
|
891
|
+
extraData: { noteId: input.noteId },
|
|
892
|
+
...primary.type === "video" ? { videoThumbnail: true } : {}
|
|
893
|
+
});
|
|
894
|
+
primaryResource = {
|
|
895
|
+
...uploaded,
|
|
896
|
+
kind: primary.type,
|
|
897
|
+
...primary.type === "audio" && primary.durationSeconds ? { durationSeconds: primary.durationSeconds } : {}
|
|
898
|
+
};
|
|
899
|
+
} catch (error) {
|
|
900
|
+
failedUploads.push(`${primary.type} ${path3.basename(primary.localPath)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
return {
|
|
904
|
+
markdown,
|
|
905
|
+
imageCount: refs.length,
|
|
906
|
+
uploadedImageCount,
|
|
907
|
+
failedUploads,
|
|
908
|
+
primaryResource
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function buildCrawlExtraData(input) {
|
|
912
|
+
const at = (input.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
913
|
+
const primary = input.published.primaryResource;
|
|
914
|
+
return {
|
|
915
|
+
crawl: {
|
|
916
|
+
version: 1,
|
|
917
|
+
job: {
|
|
918
|
+
jobId: input.jobId,
|
|
919
|
+
status: "completed",
|
|
920
|
+
url: input.url,
|
|
921
|
+
updatedAt: at,
|
|
922
|
+
completedAt: at,
|
|
923
|
+
// Local clips run on the user's machine; the server never saw this job.
|
|
924
|
+
origin: "local",
|
|
925
|
+
clip: {
|
|
926
|
+
author: input.document.author,
|
|
927
|
+
contentType: input.contentType,
|
|
928
|
+
imageCount: input.published.imageCount,
|
|
929
|
+
platform: input.platform,
|
|
930
|
+
primaryResource: primary ? {
|
|
931
|
+
kind: primary.kind,
|
|
932
|
+
mimeType: primary.mediaType,
|
|
933
|
+
resourceId: primary.resourceId,
|
|
934
|
+
sizeBytes: primary.sizeBytes,
|
|
935
|
+
url: primary.url,
|
|
936
|
+
...primary.durationSeconds ? { durationSeconds: primary.durationSeconds } : {}
|
|
937
|
+
} : null,
|
|
938
|
+
publishTime: input.document.publishTime,
|
|
939
|
+
sourceUrl: input.document.sourceUrl,
|
|
940
|
+
title: input.document.title,
|
|
941
|
+
uploadedImageCount: input.published.uploadedImageCount
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function buildClipAudioDetail(primary) {
|
|
948
|
+
if (!primary) return {};
|
|
949
|
+
return {
|
|
950
|
+
type: primary.kind,
|
|
951
|
+
summary: "",
|
|
952
|
+
remote: primary.url,
|
|
953
|
+
resourceId: primary.resourceId,
|
|
954
|
+
...primary.durationSeconds ? { length: primary.durationSeconds } : {}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// src/commands/clip/run.ts
|
|
959
|
+
var MIN_TIMEOUT_MS = 1e4;
|
|
960
|
+
var MAX_TIMEOUT_MS = 6e5;
|
|
961
|
+
var EXCERPT_CHARS = 280;
|
|
962
|
+
function isLocallySupported(platform) {
|
|
963
|
+
return localPlatformSpec(platform) !== void 0;
|
|
964
|
+
}
|
|
965
|
+
function needsBrowser(platform) {
|
|
966
|
+
return localPlatformSpec(platform)?.browser === true;
|
|
967
|
+
}
|
|
968
|
+
function usesCookies(platform) {
|
|
969
|
+
return localPlatformSpec(platform)?.cookies === true;
|
|
970
|
+
}
|
|
971
|
+
function missingToolsFor(target) {
|
|
972
|
+
const spec = localPlatformSpec(target.platform);
|
|
973
|
+
return spec ? missingTools(spec, target.contentType) : [];
|
|
974
|
+
}
|
|
975
|
+
function assertToolsInstalled(target) {
|
|
976
|
+
const missing = missingToolsFor(target);
|
|
977
|
+
if (missing.length === 0) return;
|
|
978
|
+
const install = toolInstallHint(missing);
|
|
979
|
+
throw new DinoxError(`Clipping ${target.platform} links needs ${missing.join(" and ")} on PATH.`, {
|
|
980
|
+
code: "CLIP_TOOL_MISSING",
|
|
981
|
+
recoverable: true,
|
|
982
|
+
details: { platform: target.platform, url: target.url, missing, install, reason: "tool_missing", retryable: false },
|
|
983
|
+
suggestion: `Ask the user to install ${missing.join(" and ")} (${install}), then retry.`,
|
|
984
|
+
suggestedAction: { command: "dino clip setup --check --format json", reason: "Confirm the tools are found after installing them" }
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
function detectTarget(url) {
|
|
988
|
+
try {
|
|
989
|
+
const target = detectArticleClipTarget(url);
|
|
990
|
+
if (!/^https?:\/\//i.test(target.url)) throw new Error("not an http(s) URL");
|
|
991
|
+
return target;
|
|
992
|
+
} catch (error) {
|
|
993
|
+
throw new DinoxError(`Not a clippable URL: ${url}`, {
|
|
994
|
+
code: "INVALID_ARGUMENT",
|
|
995
|
+
cause: error,
|
|
996
|
+
details: { url, reason: "invalid_url", retryable: false }
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function assertSupported(target) {
|
|
1001
|
+
if (isLocallySupported(target.platform)) return;
|
|
1002
|
+
throw new DinoxError(
|
|
1003
|
+
`Local clipping does not support ${target.platform} links yet (supported: ${LOCAL_CLIP_PLATFORMS.join(", ")}).`,
|
|
1004
|
+
{
|
|
1005
|
+
code: "CLIP_PLATFORM_UNSUPPORTED",
|
|
1006
|
+
details: {
|
|
1007
|
+
platform: target.platform,
|
|
1008
|
+
url: target.url,
|
|
1009
|
+
supportedPlatforms: [...LOCAL_CLIP_PLATFORMS],
|
|
1010
|
+
reason: "platform_unsupported",
|
|
1011
|
+
retryable: false
|
|
1012
|
+
},
|
|
1013
|
+
suggestion: "Tell the user this site cannot be clipped from the CLI yet; they can clip it from the Dinox app."
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
function proxyFromEnv() {
|
|
1018
|
+
const env = process.env;
|
|
1019
|
+
return env.HTTPS_PROXY || env.https_proxy || env.ALL_PROXY || env.all_proxy || void 0;
|
|
1020
|
+
}
|
|
1021
|
+
function parseIntegerOption(value, flag, min, max) {
|
|
1022
|
+
if (value === void 0) return void 0;
|
|
1023
|
+
const parsed = Number(value);
|
|
1024
|
+
if (!Number.isInteger(parsed) || parsed < min || parsed > max) {
|
|
1025
|
+
throw new DinoxError(`${flag} must be an integer between ${min} and ${max}`, { code: "INVALID_ARGUMENT" });
|
|
1026
|
+
}
|
|
1027
|
+
return parsed;
|
|
1028
|
+
}
|
|
1029
|
+
async function resolveCookiesFile(option) {
|
|
1030
|
+
const explicit = option?.trim();
|
|
1031
|
+
if (!explicit) return { file: clipCookiesFile(), explicit: false };
|
|
1032
|
+
const file = resolveUserPath(explicit);
|
|
1033
|
+
await fs4.access(file).catch((error) => {
|
|
1034
|
+
throw new DinoxError(`Cookies file not found: ${explicit}`, { code: "INVALID_ARGUMENT", cause: error });
|
|
1035
|
+
});
|
|
1036
|
+
return { file, explicit: true };
|
|
1037
|
+
}
|
|
1038
|
+
async function cookiesForUrl(file, url) {
|
|
1039
|
+
const text = await fs4.readFile(file, "utf8").catch(() => "");
|
|
1040
|
+
if (!text) return [];
|
|
1041
|
+
return selectCookiesForUrl(parseNetscapeCookies(text, /./), url).cookies.map((cookie) => cookie.name);
|
|
1042
|
+
}
|
|
1043
|
+
function sourceCandidates(...urls) {
|
|
1044
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
1045
|
+
for (const raw of urls) {
|
|
1046
|
+
const value = raw?.trim();
|
|
1047
|
+
if (!value) continue;
|
|
1048
|
+
candidates.add(value);
|
|
1049
|
+
try {
|
|
1050
|
+
const parsed = new URL(value);
|
|
1051
|
+
parsed.hash = "";
|
|
1052
|
+
const bare = parsed.toString();
|
|
1053
|
+
candidates.add(bare);
|
|
1054
|
+
candidates.add(bare.endsWith("/") ? bare.slice(0, -1) : `${bare}/`);
|
|
1055
|
+
} catch {
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return [...candidates];
|
|
1059
|
+
}
|
|
1060
|
+
async function findExistingClip(db, sources) {
|
|
1061
|
+
if (sources.length === 0) return null;
|
|
1062
|
+
return db.getOptional(
|
|
1063
|
+
`SELECT id, title, created_at, source FROM c_note
|
|
1064
|
+
WHERE COALESCE(is_del, 0) = 0 AND source IN (${sources.map(() => "?").join(", ")})
|
|
1065
|
+
ORDER BY created_at DESC LIMIT 1`,
|
|
1066
|
+
[...sources]
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
function configureEngine(options, cookiesFile) {
|
|
1070
|
+
const proxy = options.proxy?.trim() || proxyFromEnv() || null;
|
|
1071
|
+
const timeoutMs = parseIntegerOption(options.timeout, "--timeout", MIN_TIMEOUT_MS, MAX_TIMEOUT_MS) ?? clipEngineConfig().captureTimeoutMs;
|
|
1072
|
+
configureClipEngine({
|
|
1073
|
+
captureTimeoutMs: timeoutMs,
|
|
1074
|
+
cookiesFiles: { web: cookiesFile },
|
|
1075
|
+
...proxy ? {
|
|
1076
|
+
proxies: { twitter: proxy, web: proxy },
|
|
1077
|
+
// yt-dlp also honours HTTPS_PROXY itself; an explicit --proxy must reach it too.
|
|
1078
|
+
ytdlp: { applePodcast: { proxy }, bilibili: { proxy }, douyin: { proxy }, weibo: { proxy }, youtube: { proxy } }
|
|
1079
|
+
} : {}
|
|
1080
|
+
});
|
|
1081
|
+
return { timeoutMs, proxy };
|
|
1082
|
+
}
|
|
1083
|
+
async function extract(target, workDir, failure) {
|
|
1084
|
+
const ctx = { workDir };
|
|
1085
|
+
try {
|
|
1086
|
+
const spec = localPlatformSpec(target.platform);
|
|
1087
|
+
if (!spec) throw new Error(`no local extractor for ${target.platform}`);
|
|
1088
|
+
if (spec.browser) assertCamoufoxInstalled();
|
|
1089
|
+
assertToolsInstalled(target);
|
|
1090
|
+
const { waitedMs } = await awaitClipSlot({
|
|
1091
|
+
platform: target.platform,
|
|
1092
|
+
url: target.url,
|
|
1093
|
+
onWait: (waitMs) => reportProgress({ phase: "pace", message: `waiting ${Math.ceil(waitMs / 1e3)} s before the next ${target.platform} request` })
|
|
1094
|
+
});
|
|
1095
|
+
failure.pacedMs = waitedMs;
|
|
1096
|
+
const extractor = await spec.load();
|
|
1097
|
+
return await extractor(target.url, ctx);
|
|
1098
|
+
} catch (error) {
|
|
1099
|
+
const classified = classifyClipError(error, { platform: target.platform, url: target.url, ...failure });
|
|
1100
|
+
const reason = classified.details?.reason;
|
|
1101
|
+
if (classified.code === "CLIP_BLOCKED" && typeof reason === "string") {
|
|
1102
|
+
const until = await recordClipBlock({ platform: target.platform, url: target.url, reason });
|
|
1103
|
+
if (until && classified.details && typeof classified.details === "object") {
|
|
1104
|
+
classified.details.cooldownUntil = new Date(until).toISOString();
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
throw classified;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function documentWarnings(target, document) {
|
|
1111
|
+
const spec = localPlatformSpec(target.platform);
|
|
1112
|
+
const advisory = spec ? ytDlpAdvisory(spec, target.contentType) : null;
|
|
1113
|
+
if (document.primaryMedia || target.contentType !== "video" && target.contentType !== "audio") {
|
|
1114
|
+
return advisory ? [advisory] : [];
|
|
1115
|
+
}
|
|
1116
|
+
const usesYtDlp = spec ? requiredTools(spec, target.contentType).includes("yt-dlp") : false;
|
|
1117
|
+
const reason = advisory ?? (usesYtDlp ? "If it keeps happening, yt-dlp may need an update: " + (ytDlpStatus().update ?? "yt-dlp -U") : "");
|
|
1118
|
+
return [
|
|
1119
|
+
`the ${target.contentType} was not downloaded (too large, unavailable, or blocked); the note keeps its text and link.${reason ? ` ${reason}` : ""}`
|
|
1120
|
+
];
|
|
1121
|
+
}
|
|
1122
|
+
function excerptOf(text) {
|
|
1123
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
1124
|
+
return flat.length > EXCERPT_CHARS ? `${flat.slice(0, EXCERPT_CHARS)}\u2026` : flat;
|
|
1125
|
+
}
|
|
1126
|
+
async function runClipInspect(context) {
|
|
1127
|
+
const url = context.args.url?.trim();
|
|
1128
|
+
if (!url) throw new DinoxError("URL is required. Use `dino clip inspect <url>`.", { code: "USAGE_ERROR" });
|
|
1129
|
+
const options = context.options;
|
|
1130
|
+
const target = detectTarget(url);
|
|
1131
|
+
const supported = isLocallySupported(target.platform);
|
|
1132
|
+
const browserRequired = needsBrowser(target.platform);
|
|
1133
|
+
const browserInstalled = isCamoufoxInstalled();
|
|
1134
|
+
const cookiesUsed = usesCookies(target.platform);
|
|
1135
|
+
const { file } = await resolveCookiesFile(options.cookies);
|
|
1136
|
+
const cookieNames = cookiesUsed ? await cookiesForUrl(file, target.url) : [];
|
|
1137
|
+
const spec = localPlatformSpec(target.platform);
|
|
1138
|
+
const toolsMissing = missingToolsFor(target);
|
|
1139
|
+
const toolsRequired = spec ? requiredTools(spec, target.contentType) : [];
|
|
1140
|
+
const advisory = spec ? ytDlpAdvisory(spec, target.contentType) : null;
|
|
1141
|
+
const yt = ytDlpStatus();
|
|
1142
|
+
const cookieGuidance = CLIP_COOKIE_GUIDANCE[target.platform] ?? null;
|
|
1143
|
+
const cookieHint = cookieAdvice(target.platform, cookieNames.length);
|
|
1144
|
+
const blockers = [];
|
|
1145
|
+
if (!supported) blockers.push("platform_unsupported");
|
|
1146
|
+
if (supported && browserRequired && !browserInstalled) blockers.push("browser_missing");
|
|
1147
|
+
for (const tool of toolsMissing) blockers.push(tool === "yt-dlp" ? "yt_dlp_missing" : "ffmpeg_missing");
|
|
1148
|
+
const nextAction = !supported ? null : browserRequired && !browserInstalled ? { command: "dino clip setup --progress --format json", reason: "Download the clip browser (one time)" } : toolsMissing.length > 0 ? { command: toolInstallHint(toolsMissing), reason: `Install ${toolsMissing.join(" and ")} (ask the user first)` } : cookieHint?.need === "required" ? {
|
|
1149
|
+
command: cookieHint.import[0],
|
|
1150
|
+
reason: `Ask the user for their ${cookieHint.domain} cookies first (they export them; you import the file). ${cookieHint.why}`
|
|
1151
|
+
} : { command: `dino clip add ${target.url} --format json`, reason: "Clip the link" };
|
|
1152
|
+
const payload = {
|
|
1153
|
+
ok: true,
|
|
1154
|
+
url: target.url,
|
|
1155
|
+
platform: target.platform,
|
|
1156
|
+
contentType: target.contentType,
|
|
1157
|
+
supported,
|
|
1158
|
+
ready: blockers.length === 0,
|
|
1159
|
+
blockers,
|
|
1160
|
+
browser: { required: browserRequired, installed: browserInstalled },
|
|
1161
|
+
tools: {
|
|
1162
|
+
ytDlp: {
|
|
1163
|
+
required: toolsRequired.includes("yt-dlp"),
|
|
1164
|
+
installed: yt.installed,
|
|
1165
|
+
version: yt.version,
|
|
1166
|
+
outdated: yt.outdated,
|
|
1167
|
+
update: yt.outdated ? yt.update : null
|
|
1168
|
+
},
|
|
1169
|
+
ffmpeg: { required: toolsRequired.includes("ffmpeg"), installed: hasExecutable("ffmpeg") }
|
|
1170
|
+
},
|
|
1171
|
+
cookies: {
|
|
1172
|
+
used: cookiesUsed,
|
|
1173
|
+
// required / recommended: the site depends on the user's login (see `why`); null: optional.
|
|
1174
|
+
need: cookieGuidance?.need ?? null,
|
|
1175
|
+
domain: cookieGuidance?.domain ?? null,
|
|
1176
|
+
why: cookieGuidance?.why ?? null,
|
|
1177
|
+
count: cookieNames.length,
|
|
1178
|
+
names: cookieNames,
|
|
1179
|
+
import: cookieHint ? cookieHint.import : null
|
|
1180
|
+
},
|
|
1181
|
+
// Not blockers: the clip still runs, but may fail or be incomplete until the user acts.
|
|
1182
|
+
advisories: [...advisory ? [advisory] : [], ...cookieHint ? [cookieHint.message] : []],
|
|
1183
|
+
supportedPlatforms: [...LOCAL_CLIP_PLATFORMS],
|
|
1184
|
+
next_action: nextAction
|
|
1185
|
+
};
|
|
1186
|
+
if (getRequestedStructuredOutputFormat() !== null) {
|
|
1187
|
+
printSuccess(payload);
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
printHumanReadableLine(`${target.url} \u2192 ${target.platform} (${target.contentType})`);
|
|
1191
|
+
printHumanReadableLine(payload.ready ? "Ready to clip." : `Not ready: ${blockers.join(", ")}`);
|
|
1192
|
+
if (advisory) printHumanReadableLine(`Note: ${advisory}`);
|
|
1193
|
+
if (cookieHint) printHumanReadableLine(`Note: ${cookieHint.message}`);
|
|
1194
|
+
if (cookiesUsed) printHumanReadableLine(`Cookies for this site: ${cookieNames.length}`);
|
|
1195
|
+
if (nextAction) printHumanReadableLine(`Next: ${nextAction.command}`);
|
|
1196
|
+
}
|
|
1197
|
+
async function runClipAdd(context) {
|
|
1198
|
+
const url = context.args.url?.trim();
|
|
1199
|
+
if (!url) throw new DinoxError("URL is required. Use `dino clip add <url>`.", { code: "USAGE_ERROR" });
|
|
1200
|
+
const options = context.options;
|
|
1201
|
+
const structuredOutput = getRequestedStructuredOutputFormat() !== null;
|
|
1202
|
+
const startedAt = Date.now();
|
|
1203
|
+
setClipVerbose(context.globals.verbose === true);
|
|
1204
|
+
const maxChars = parseIntegerOption(options.maxChars, "--max-chars", 1, 1e7);
|
|
1205
|
+
const target = detectTarget(url);
|
|
1206
|
+
assertSupported(target);
|
|
1207
|
+
const { file: cookiesFile } = await resolveCookiesFile(options.cookies);
|
|
1208
|
+
const { timeoutMs } = configureEngine(options, cookiesFile);
|
|
1209
|
+
const cookieNames = usesCookies(target.platform) ? await cookiesForUrl(cookiesFile, target.url) : null;
|
|
1210
|
+
const failure = {
|
|
1211
|
+
cookiesSent: cookieNames ? cookieNames.length : null,
|
|
1212
|
+
timeoutMs
|
|
1213
|
+
};
|
|
1214
|
+
const workDir = await fs4.mkdtemp(path4.join(os.tmpdir(), "dino-clip-"));
|
|
1215
|
+
try {
|
|
1216
|
+
if (options.dryRun) {
|
|
1217
|
+
reportProgress({ phase: "fetch", message: target.url });
|
|
1218
|
+
const document = await extract(target, workDir, failure);
|
|
1219
|
+
const title = options.title?.trim() || document.title.trim() || target.url;
|
|
1220
|
+
const markdown = maxChars !== void 0 && document.rawMarkdown.length > maxChars ? document.rawMarkdown.slice(0, maxChars) : document.rawMarkdown;
|
|
1221
|
+
const payload = {
|
|
1222
|
+
ok: true,
|
|
1223
|
+
dryRun: true,
|
|
1224
|
+
platform: target.platform,
|
|
1225
|
+
contentType: target.contentType,
|
|
1226
|
+
url: target.url,
|
|
1227
|
+
sourceUrl: document.sourceUrl || target.url,
|
|
1228
|
+
title,
|
|
1229
|
+
author: document.author,
|
|
1230
|
+
publishTime: document.publishTime,
|
|
1231
|
+
primaryMedia: document.primaryMedia?.type ?? null,
|
|
1232
|
+
inlineMediaCount: document.inlineMedia?.length ?? 0,
|
|
1233
|
+
warnings: [
|
|
1234
|
+
...documentWarnings(target, document),
|
|
1235
|
+
...failure.cookiesSent === 0 ? [cookieAdvice(target.platform, 0)?.message ?? []].flat() : []
|
|
1236
|
+
],
|
|
1237
|
+
cookiesSent: failure.cookiesSent,
|
|
1238
|
+
pacedMs: failure.pacedMs ?? 0,
|
|
1239
|
+
markdownChars: document.rawMarkdown.length,
|
|
1240
|
+
truncated: markdown.length < document.rawMarkdown.length,
|
|
1241
|
+
markdown,
|
|
1242
|
+
elapsedMs: Date.now() - startedAt
|
|
1243
|
+
};
|
|
1244
|
+
if (structuredOutput) {
|
|
1245
|
+
printSuccess(payload);
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
printHumanReadableLine(`# ${title}`);
|
|
1249
|
+
printHumanReadableLine("");
|
|
1250
|
+
printHumanReadableLine(markdown);
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
await withNoteDatabase(context.command, async (runtime) => {
|
|
1254
|
+
const { db, config } = runtime;
|
|
1255
|
+
reportProgress({ phase: "sync" });
|
|
1256
|
+
await syncBeforeNoteCommand(runtime);
|
|
1257
|
+
const durability = resolveWriteDurabilityForRuntime(runtime, options.durability);
|
|
1258
|
+
const identity = await resolveAuthIdentity(config);
|
|
1259
|
+
const authorization = config.auth.authorization;
|
|
1260
|
+
if (!authorization) throw new DinoxError("Not logged in.", { code: "AUTH_REQUIRED" });
|
|
1261
|
+
const tagsInput = typeof options.tags === "string" ? await parseStringListInput(options.tags, "--tags") : [];
|
|
1262
|
+
const boxNames = typeof options.boxes === "string" ? await parseStringListInput(options.boxes, "--boxes") : [];
|
|
1263
|
+
const tags = await validateTagsForCreate(db, tagsInput, identity.userId, "dino clip add");
|
|
1264
|
+
const zettelBoxIds = await resolveZettelBoxIdsForCreate(db, boxNames);
|
|
1265
|
+
const printDuplicate = (existing) => {
|
|
1266
|
+
const payload2 = {
|
|
1267
|
+
ok: true,
|
|
1268
|
+
duplicate: true,
|
|
1269
|
+
id: existing.id,
|
|
1270
|
+
title: existing.title,
|
|
1271
|
+
platform: target.platform,
|
|
1272
|
+
sourceUrl: existing.source,
|
|
1273
|
+
createdAt: existing.created_at,
|
|
1274
|
+
stale: commandStale(runtime),
|
|
1275
|
+
next_action: {
|
|
1276
|
+
command: `dino note detail ${existing.id} --content md --max-chars 2000 --format json`,
|
|
1277
|
+
reason: "This link was already clipped; read the existing note (pass --allow-duplicate to clip again)"
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
if (structuredOutput) printSuccess(payload2);
|
|
1281
|
+
else printHumanReadableLine(`Already clipped: "${existing.title}" \u2192 ${existing.id} (use --allow-duplicate to clip again)`);
|
|
1282
|
+
};
|
|
1283
|
+
if (!options.allowDuplicate) {
|
|
1284
|
+
const existing = await findExistingClip(db, sourceCandidates(url, target.url));
|
|
1285
|
+
if (existing) {
|
|
1286
|
+
printDuplicate(existing);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
reportProgress({ phase: "fetch", message: target.url });
|
|
1291
|
+
const document = await extract(target, workDir, failure);
|
|
1292
|
+
const sourceUrl = document.sourceUrl || target.url;
|
|
1293
|
+
if (!options.allowDuplicate && sourceUrl !== target.url) {
|
|
1294
|
+
const existing = await findExistingClip(db, sourceCandidates(sourceUrl));
|
|
1295
|
+
if (existing) {
|
|
1296
|
+
printDuplicate(existing);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
const title = options.title?.trim() || document.title.trim() || target.url;
|
|
1301
|
+
const noteId = generateId();
|
|
1302
|
+
let uploads = 0;
|
|
1303
|
+
const published = await publishClipContent(document, {
|
|
1304
|
+
workDir,
|
|
1305
|
+
noteId,
|
|
1306
|
+
upload: async (filePath, { videoThumbnail, ...uploadOptions }) => {
|
|
1307
|
+
uploads += 1;
|
|
1308
|
+
reportProgress({ phase: "upload", current: uploads, message: path4.basename(filePath) });
|
|
1309
|
+
const thumbnailSource = videoThumbnail ? await extractVideoFrame(filePath, workDir) : null;
|
|
1310
|
+
const sent = await uploadToOfficialStorage(
|
|
1311
|
+
{ db, userId: identity.userId, authorization },
|
|
1312
|
+
{ kind: "path", path: filePath },
|
|
1313
|
+
{ ...uploadOptions, ...thumbnailSource ? { thumbnailSource } : {} }
|
|
1314
|
+
);
|
|
1315
|
+
return { resourceId: sent.resourceId, url: sent.url, mediaType: sent.mediaType, sizeBytes: sent.sizeBytes };
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
const { contentJson, contentText } = convertMarkdownToNoteContent(published.markdown);
|
|
1319
|
+
reportProgress({ phase: "save" });
|
|
1320
|
+
await createNote(db, {
|
|
1321
|
+
id: noteId,
|
|
1322
|
+
title,
|
|
1323
|
+
noteType: "crawl",
|
|
1324
|
+
contentMd: published.markdown,
|
|
1325
|
+
contentJson,
|
|
1326
|
+
contentText,
|
|
1327
|
+
tags,
|
|
1328
|
+
zettelBoxIds,
|
|
1329
|
+
userId: identity.userId,
|
|
1330
|
+
source: sourceUrl,
|
|
1331
|
+
extraData: buildCrawlExtraData({
|
|
1332
|
+
jobId: generateId(),
|
|
1333
|
+
url: target.url,
|
|
1334
|
+
platform: target.platform,
|
|
1335
|
+
contentType: target.contentType,
|
|
1336
|
+
document,
|
|
1337
|
+
published
|
|
1338
|
+
}),
|
|
1339
|
+
resourceId: published.primaryResource?.resourceId ?? null,
|
|
1340
|
+
audioDetail: buildClipAudioDetail(published.primaryResource)
|
|
1341
|
+
});
|
|
1342
|
+
const upload = await waitForMutationUpload(runtime, { durability });
|
|
1343
|
+
const warnings = [
|
|
1344
|
+
...documentWarnings(target, document),
|
|
1345
|
+
...published.failedUploads.map((entry) => `media not uploaded: ${entry}`)
|
|
1346
|
+
];
|
|
1347
|
+
if (!contentText.trim()) warnings.push("the clipped note has no text; the page may need login (cookies) or have no article body");
|
|
1348
|
+
const cookieHint = failure.cookiesSent === 0 ? cookieAdvice(target.platform, 0) : null;
|
|
1349
|
+
if (cookieHint) {
|
|
1350
|
+
warnings.push(`${cookieHint.message} If this note looks incomplete, import them, then clip again with \`dino clip add ${target.url} --allow-duplicate\` (and delete this note).`);
|
|
1351
|
+
}
|
|
1352
|
+
let postProcessing = null;
|
|
1353
|
+
if (upload.durability === "uploaded") {
|
|
1354
|
+
reportProgress({ phase: "post-process" });
|
|
1355
|
+
postProcessing = await requestClipPostProcessing(
|
|
1356
|
+
{ authorization },
|
|
1357
|
+
{ noteId, primaryResource: published.primaryResource }
|
|
1358
|
+
);
|
|
1359
|
+
if (postProcessing.status !== "queued") {
|
|
1360
|
+
warnings.push(`server ${postProcessing.kind} not queued (${postProcessing.status}${postProcessing.message ? `: ${postProcessing.message}` : ""})`);
|
|
1361
|
+
}
|
|
1362
|
+
} else {
|
|
1363
|
+
warnings.push("the note is not uploaded yet, so server transcription / enrichment was not requested");
|
|
1364
|
+
}
|
|
1365
|
+
const postProcessPending = postProcessing?.status !== "queued";
|
|
1366
|
+
const payload = {
|
|
1367
|
+
ok: true,
|
|
1368
|
+
duplicate: false,
|
|
1369
|
+
id: noteId,
|
|
1370
|
+
title,
|
|
1371
|
+
platform: target.platform,
|
|
1372
|
+
contentType: target.contentType,
|
|
1373
|
+
sourceUrl,
|
|
1374
|
+
author: document.author,
|
|
1375
|
+
publishTime: document.publishTime,
|
|
1376
|
+
excerpt: excerptOf(contentText),
|
|
1377
|
+
markdownChars: published.markdown.length,
|
|
1378
|
+
imageCount: published.imageCount,
|
|
1379
|
+
uploadedImageCount: published.uploadedImageCount,
|
|
1380
|
+
primaryResourceId: published.primaryResource?.resourceId ?? null,
|
|
1381
|
+
failedUploads: published.failedUploads,
|
|
1382
|
+
cookiesSent: failure.cookiesSent,
|
|
1383
|
+
postProcessing,
|
|
1384
|
+
pacedMs: failure.pacedMs ?? 0,
|
|
1385
|
+
warnings,
|
|
1386
|
+
elapsedMs: Date.now() - startedAt,
|
|
1387
|
+
...postProcessPending ? {
|
|
1388
|
+
next_action: {
|
|
1389
|
+
command: `dino clip process ${noteId} --format json`,
|
|
1390
|
+
reason: "Request the server transcription / enrichment again once the note is uploaded"
|
|
1391
|
+
}
|
|
1392
|
+
} : {},
|
|
1393
|
+
...await readNoteWriteReceipt(db, noteId, {
|
|
1394
|
+
changed: ["title", "type", "source", "content_md", "content_json", "content_text", "tags", "boxes", "extra_data"],
|
|
1395
|
+
upload,
|
|
1396
|
+
stale: commandStale(runtime)
|
|
1397
|
+
})
|
|
1398
|
+
};
|
|
1399
|
+
if (structuredOutput) {
|
|
1400
|
+
printSuccess(payload);
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
printHumanReadableLine(`Clipped "${title}" \u2192 ${noteId}`);
|
|
1404
|
+
for (const warning of warnings) printHumanReadableLine(`- warning: ${warning}`);
|
|
1405
|
+
printStaleCacheWarning(runtime);
|
|
1406
|
+
});
|
|
1407
|
+
} finally {
|
|
1408
|
+
await fs4.rm(workDir, { recursive: true, force: true });
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
async function runClipProcess(context) {
|
|
1412
|
+
const noteId = context.args.noteId?.trim();
|
|
1413
|
+
if (!noteId) throw new DinoxError("Note id is required. Use `dino clip process <noteId>`.", { code: "USAGE_ERROR" });
|
|
1414
|
+
const structuredOutput = getRequestedStructuredOutputFormat() !== null;
|
|
1415
|
+
await withNoteDatabase(context.command, async (runtime) => {
|
|
1416
|
+
const { db, config } = runtime;
|
|
1417
|
+
await syncBeforeNoteCommand(runtime);
|
|
1418
|
+
const authorization = config.auth.authorization;
|
|
1419
|
+
if (!authorization) throw new DinoxError("Not logged in.", { code: "AUTH_REQUIRED" });
|
|
1420
|
+
const note = await db.getOptional(
|
|
1421
|
+
`SELECT n.id, n.title, n.resource_id, r.mime_type FROM c_note n
|
|
1422
|
+
LEFT JOIN c_resource r ON r.id = n.resource_id AND COALESCE(r.is_del, 0) = 0
|
|
1423
|
+
WHERE n.id = ? AND COALESCE(n.is_del, 0) = 0`,
|
|
1424
|
+
[noteId]
|
|
1425
|
+
);
|
|
1426
|
+
if (!note) throw new DinoxError(`Note not found: ${noteId}`, { code: "NOTE_NOT_FOUND" });
|
|
1427
|
+
const upload = await waitForMutationUpload(runtime, { durability: "uploaded" });
|
|
1428
|
+
const kind = note.mime_type?.match(/^(audio|video)\//)?.[1];
|
|
1429
|
+
const result = await requestClipPostProcessing(
|
|
1430
|
+
{ authorization },
|
|
1431
|
+
{ noteId, primaryResource: kind && note.resource_id ? { resourceId: note.resource_id, kind } : null }
|
|
1432
|
+
);
|
|
1433
|
+
const payload = {
|
|
1434
|
+
ok: result.status === "queued",
|
|
1435
|
+
id: noteId,
|
|
1436
|
+
title: note.title ?? "",
|
|
1437
|
+
postProcessing: result,
|
|
1438
|
+
upload,
|
|
1439
|
+
...result.status === "queued" ? {
|
|
1440
|
+
next_action: {
|
|
1441
|
+
command: `dino note detail ${noteId} --content md --max-chars 2000 --format json`,
|
|
1442
|
+
reason: result.kind === "transcription" ? "The transcript, title, tags and summary arrive through sync once the server finishes (minutes for long media)" : "The title, tags and summary arrive through sync once the server finishes (seconds)"
|
|
1443
|
+
}
|
|
1444
|
+
} : {
|
|
1445
|
+
next_action: {
|
|
1446
|
+
command: `dino clip process ${noteId} --format json`,
|
|
1447
|
+
reason: result.status === "sync_pending" ? "The server has not seen the synced note yet; retry in a minute" : "Retry later; the request did not go through"
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
if (structuredOutput) {
|
|
1452
|
+
printSuccess(payload);
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
printHumanReadableLine(
|
|
1456
|
+
result.status === "queued" ? `Requested server ${result.kind} for ${noteId}` : `Server ${result.kind} not queued (${result.status}${result.message ? `: ${result.message}` : ""})`
|
|
1457
|
+
);
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
export {
|
|
1461
|
+
runClipAdd,
|
|
1462
|
+
runClipInspect,
|
|
1463
|
+
runClipProcess
|
|
1464
|
+
};
|