@tocca-systems/twp-cli 0.136.0 → 0.137.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.
@@ -11,6 +11,10 @@
11
11
  `CHANGELOG.md` に残してあります。顧客向けの履歴は public 公開以降を対象とします。
12
12
  -->
13
13
 
14
+ ## 0.137.0
15
+
16
+ `twp sns post --quote` で X の投稿を引用して投稿できるようになりました。
17
+
14
18
  ## 0.136.0
15
19
 
16
20
  プロジェクトの概要説明を `twp project overview list` / `get` / `update` で読み書きできるようになりました。`update --upload-images` は本文中のローカル画像を上げて画面と同じ形で保存し、既に記入されている見出しを上書きするときは `--yes` を求めます。
package/README.md CHANGED
@@ -2379,6 +2379,7 @@ twp sns list --channel instagram [--all] # Instagram のメデ
2379
2379
  twp sns list --channel <チャネル> --status <draft|scheduled|publishing|published|failed|all> [--all] # TWP の下書き・予約
2380
2380
  twp sns post --channel <チャネル> [--channel …] (--text <文字列> | --text-file <パス>) [--media <画像|動画> …] [--at <日時>] --yes
2381
2381
  twp sns post --channel x --text <1件目> --thread <2件目> [--thread <3件目> …] [--at <日時>] --yes # X のスレッド(--thread-file <パス> でも可)
2382
+ twp sns post --channel x [--account <ID|@名前>] --text <本文> --quote <投稿ID|投稿URL> [--at <日時>] --yes # X の引用投稿
2382
2383
  twp sns edit --channel <チャネル> <UUID> [--text <文字列> | --text-file <パス>] [--media <パス> … | --clear-media] --yes # TWP の下書き・予約を編集
2383
2384
  twp sns delete --channel <チャネル> <ID> --yes # SNS 上の投稿の ID / UUID = TWP の下書き・予約(LinkedIn は UUID だけ)
2384
2385
  twp sns repost --channel x [--account <ID|@名前>] <投稿ID|投稿URL> [--undo] --yes # 連携のアカウントとしてリポスト(--undo で取り消し)
@@ -2398,6 +2399,7 @@ twp sns draft --channel <x|linkedin|facebook|instagram> [--channel …] (--from
2398
2399
  | Facebookページ | 画像(JPEG・PNG・GIF)10枚まで(10MB)か、動画(MP4・MOV)1本(512MB)。混在は不可 | 63,206 文字 |
2399
2400
  | Instagram | **必須。** JPEG の画像(8MB)・MP4/MOV の動画を合わせて10件まで。1件の動画はリール(300MB)、2件以上はカルーセル(動画は 100MB) | 2,200 文字・ハッシュタグ30個 |
2400
2401
  - `post --thread`(または `--thread-file`)を繰り返すと、2件目以降を返信としてつなげた **X のスレッド**にします(予約でも使えます)。1件目を含めて25件まで・各件 X の上限(280。日本語は1字2)まで・続きの空は不可で、超えるものは送らずに止めます。**費用は件ごと**で、URL を含む件だけがリンク付きの単価です(URL を2件目以降に置けば1件目は通常の単価)。送る前に件ごとの費用と合計を表示します。画像は1件目にだけ付きます。途中で失敗すると、それまでの件は X に出たまま残ります(再送はしません)。何件目まで出たかを `list --status all` と `list` で確かめてから打ち直してください
2402
+ - `post --quote` は X の**引用投稿**にします(個人アカウントの告知を会社アカウントで引用する運用向け)。投稿は数字の ID か URL(`https://x.com/<ユーザー名>/status/<ID>`)で指定でき、予約(`--at`)でも引用先を保ちます。**引用投稿はリンク付き投稿の単価**です(X の価格表に引用の区分が無いため、他の投稿へのリンクを持つ投稿として扱います。スレッドでは引用になる1件目だけ)。引用は X だけで使えます。接続先のサーバが引用に対応していなければ、引用の無い投稿として出さずに止めます。X の契約によっては引用を拒否されることがあり、そのときは X の理由を表示して止めます
2401
2403
  - `list` はチャネルで出すものが変わります。X は TWP のキャッシュから返し、キャッシュが6時間より古いとサーバが新着だけを取りに行き、その読み取りもクレジットを消費します(画面で開いたときと同じ。送る前に注記し、実際に読み取ったら知らせます)。まだ一度も取得していない連携は `--fetch --yes` で取得するまで空です。LinkedIn は LinkedIn 上の投稿を読めないため、TWP から投稿した記録を出します。Facebookページ・Instagram は毎回 SNS から読みます(`--all` で続きを辿れます。Instagram は `--limit` を使えません)
2402
2404
  - `repost` は `--account` の連携(例: 会社アカウント)として、他のアカウントの投稿をリポストします(個人アカウントで告知し、会社アカウントでリポストする運用向け)。投稿は数字の ID か URL(`https://x.com/<ユーザー名>/status/<ID>`)で指定でき、`--undo` で取り消します。リポストも取り消しもクレジットを消費し、送る前に操作するアカウント・対象・費用を表示します
2403
2405
  - `edit` は TWP の下書き・予約中の投稿(`list --status draft|scheduled` の id)の本文と画像を書き換えます。送る前に変更前後の本文と画像の枚数を表示します(`--dry-run` で確かめられます)。`--media` は画像・動画を置き換え(いまのものは外れます。条件はチャネルごと)、`--clear-media` はすべて外します(Instagram はメディアが必須なので使えません)。予約日時とスレッドの続きは変えません。取得してから送るまでに画面など他で更新されていたら、上書きせずに止めます(終了コード 3)。投稿済みの X の投稿は X に編集の API が無いため編集できません
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-4UVHLNUA.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-G6QQFB2J.js";import"./chunk-MY5QCWCS.js";import{evaluateQuery}from"./chunk-LXFLA3PZ.js";import{renderOutput}from"./chunk-P4QSPSOQ.js";import"./chunk-Q3B65OFC.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-3EFJQDC4.js";
3
+ import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-4UVHLNUA.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-XZVP3FUE.js";import"./chunk-CAJZZF7M.js";import{evaluateQuery}from"./chunk-LXFLA3PZ.js";import{renderOutput}from"./chunk-P4QSPSOQ.js";import"./chunk-Q3B65OFC.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-3EFJQDC4.js";
4
4
  import{readBody}from"./chunk-V5WDGX4S.js";import{ALLOW_REDACTED_FLAG,NO_REDACT_FLAG,NO_REDACT_NOTICE}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs,repeatedValues}from"./chunk-6NHLWYI2.js";import"./chunk-UZVBQV4W.js";import{ApiError,RepeatedQueryValue,TwpApiClient,appendQuery,appendRepeatable,isArrayQueryKey}from"./chunk-SH2YLLVL.js";import"./chunk-CJFIIGSH.js";import"./chunk-HVZUXLQ4.js";
5
5
  import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,isPageNumberEnvelope,pageRangeNotes,positiveInteger,readEnvelopeCursor,readPageNumberCursor,shellQuote}from"./chunk-DYT22FTA.js";import"./chunk-HCTPCUST.js";import{ApiResponseError,EXIT_OK,EXIT_WAIT_TIMEOUT,NetworkError,UsageError}from"./chunk-STILP3Z6.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{AuthSession,NotLoggedInError,SessionExpiredError}from"./chunk-ITFO5GPX.js";
6
6
  import{loadCredentials}from"./chunk-GWVREACM.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{HELP_TOKEN}from"./chunk-ZN7AEXEI.js";import"./chunk-OKATZ4SN.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";var MIN_SEGMENT_CHARS=3;var parsedCache=new WeakMap;function splitSegments(path){return path.split("/").filter(segment=>segment!=="")}function parseRoutes(routes){const cached=parsedCache.get(routes);if(cached!==void 0)return cached;const parsed=[];for(const[key,domain]of Object.entries(routes.routes)){const space=key.indexOf(" ");if(space<=0)continue;const template=key.slice(space+1);parsed.push({method:key.slice(0,space),template,domain,segments:splitSegments(template).map(segment=>/^\{[^/{}]+\}$/.
@@ -1212,7 +1212,7 @@ cwd()){const listed=await gitListFiles(cwd2);const raw=listed??await walkFiles(c
1212
1212
  1;const after=/^[^\s]*/.exec(text.slice(cursor))?.[0]??"";return{query,start,end:cursor+after.length}}var TWP_SLASH_ROUTES={"/tasks":{domain:"task",operation:"list"},"/task":{domain:"task",operation:"get"},"/projects":{domain:"project",operation:"list"}};function isTwpSlashCommand(name){return Object.hasOwn(TWP_SLASH_ROUTES,name)}async function runTwpSlashCommand(name,args,deps){const route=TWP_SLASH_ROUTES[name];if(!Object.hasOwn(TWP_SLASH_ROUTES,name)||route===void 0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u30B3\u30DE\u30F3\u30C9: ${name}
1213
1213
  `}}const parsed=parseArgv([route.domain,route.operation,...args]);if(parsed.command!=="domain"||parsed.domain!==route.domain){return{code:2,out:"",err:`${name}: \u3053\u306E\u5F15\u6570\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08${args.join(" ")}\uFF09
1214
1214
  `}}if(parsed.unknown.length>0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(parsed.unknown)}
1215
- `}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-LEJKFFSA.js");try{const code=await runDomain({domain:route.domain,...parsed.operation!==void 0?{operation:parsed.operation}:
1215
+ `}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-AHV37JBZ.js");try{const code=await runDomain({domain:route.domain,...parsed.operation!==void 0?{operation:parsed.operation}:
1216
1216
  {},argv:parsed.domainArgv,help:parsed.domainHelp,globals,version:deps.version,io,...deps.fetchImpl!==void 0?{fetchImpl:deps.fetchImpl}:{}});return{code,out,err}}catch(e){return{code:1,out,err:`${err}${e.message}
1217
1217
  `}}}var GIT_LOG_OUTPUT=["9f3c1a2 feat(ui): \u4E00\u89A7\u306E\u30D5\u30A3\u30EB\u30BF\u3092 URL \u30AF\u30A8\u30EA\u3068\u540C\u671F\u3059\u308B","4b8e0d7 fix(ui): \u4EEE\u60F3\u30B9\u30AF\u30ED\u30FC\u30EB\u306E\u884C\u9AD8\u3055\u3092\u5B9F\u6E2C\u5024\u306B\u5408\u308F\u305B\u308B","c15a99e refactor(api): \u4E00\u89A7\u53D6\u5F97\u306E\u30DA\u30FC\u30B8\u30F3\u30B0\u51E6\u7406\u3092\u5171\u901A\u5316\u3059\u308B","2d70f4b test: \u4E00\u89A7\u30D5\u30A3\u30EB\u30BF\u306E\u56DE\u5E30\u30C6\u30B9\u30C8\u3092\u8FFD\u52A0\u3059\u308B",
1218
1218
  "a6e2b38 fix(api): \u7A7A\u306E\u691C\u7D22\u6761\u4EF6\u3067\u5168\u4EF6\u8FD4\u3089\u306A\u3044\u3088\u3046\u306B\u3059\u308B","7c40d51 chore(deps): \u958B\u767A\u4F9D\u5B58\u3092\u6700\u65B0\u3078\u66F4\u65B0\u3059\u308B","e83b1c6 docs: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u624B\u9806\u306B Node 22 \u306E\u524D\u63D0\u3092\u8FFD\u8A18\u3059\u308B","b91f7a4 fix(ui): \u30E2\u30FC\u30C0\u30EB\u306E\u91CD\u306A\u308A\u9806\u3092\u6307\u5B9A\u3059\u308B","5a2c8e0 perf(api): \u4E00\u89A7\u306E N+1 \u3092\u89E3\u6D88\u3059\u308B",
@@ -5,10 +5,10 @@ attendanceDomainWithRecords,"audit-log":async()=>(await import("./audit-log-DLRQ
5
5
  company:async()=>(await import("./company-QLJ2IIJZ.js")).companyDomain,content:async()=>(await import("./content-ZC3O7XXZ.js")).contentDomain,contract:async()=>(await import("./contract-TO7G4MI3.js")).contractDomain,corporate:async()=>(await import("./corporate-VRU5NXIJ.js")).corporateDomain,customer:async()=>(await import("./company-QLJ2IIJZ.js")).customerDomain,department:async()=>(await import("./department-ILF3UVH6.js")).departmentDomain,deposit:async()=>(await import("./deposit-OXXZTOJ2.js")).
6
6
  depositDomain,estimate:async()=>(await import("./estimate-YN4JKFJ2.js")).estimateDomain,evaluation:async()=>(await import("./evaluation-7N52GMJE.js")).evaluationDomain,expense:async()=>(await import("./expense-BG5K4MZV.js")).expenseDomain,faq:async()=>(await import("./faq-6SJJUW7K.js")).faqDomain,"fiscal-year":async()=>(await import("./fiscal-year-WXUZ3PFZ.js")).fiscalYearDomain,github:async()=>(await import("./github-NYUKDMA7.js")).githubDomain,holiday:async()=>(await import("./holiday-D2ZM5PCX.js")).
7
7
  holidayDomain,"goal-sheet":async()=>(await import("./evaluation-7N52GMJE.js")).goalSheetDomain,inquiry:async()=>(await import("./inquiry-4RVYKSRI.js")).inquiryDomain,invoice:async()=>(await import("./invoice-LOM6EYMA.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-V72OVSVN.js")).jobTitleDomain,journal:async()=>(await import("./journal-DCKH6PAR.js")).journalDomain,knowledge:async()=>(await import("./domain-knowledge-OXULU7MG.js")).knowledgeDomain,leave:async()=>(await import("./leave-2PH6MAPU.js")).
8
- leaveDomain,license:async()=>(await import("./license-NEEKNJBY.js")).licenseDomain,"login-history":async()=>(await import("./login-history-NVMX2UAZ.js")).loginHistoryDomain,media:async()=>(await import("./media-NRLQ7C4C.js")).mediaDomain,meeting:async()=>(await import("./knowledge-UUTQOVQX.js")).meetingDomain,note:async()=>(await import("./note-ZG6PFBKY.js")).noteDomain,notification:async()=>(await import("./notification-CALNSJ3C.js")).notificationDomain,ojt:async()=>(await import("./ojt-KIBELG5D.js")).
8
+ leaveDomain,license:async()=>(await import("./license-NEEKNJBY.js")).licenseDomain,"login-history":async()=>(await import("./login-history-NVMX2UAZ.js")).loginHistoryDomain,media:async()=>(await import("./media-XD7PWQNT.js")).mediaDomain,meeting:async()=>(await import("./knowledge-UUTQOVQX.js")).meetingDomain,note:async()=>(await import("./note-ZG6PFBKY.js")).noteDomain,notification:async()=>(await import("./notification-CALNSJ3C.js")).notificationDomain,ojt:async()=>(await import("./ojt-KIBELG5D.js")).
9
9
  ojtDomain,onedrive:async()=>(await import("./onedrive-NYRDUBIQ.js")).onedriveDomain,outlook:async()=>(await import("./outlook-OE7CUTAJ.js")).outlookDomain,payee:async()=>(await import("./sales-master-HROKFBDJ.js")).payeeDomain,position:async()=>(await import("./position-OG6O2OX5.js")).positionDomain,project:async()=>(await import("./project-OFJOODDU.js")).projectDomain,prospect:async()=>(await import("./prospect-ECQEHHXJ.js")).prospectDomain,purchase:async()=>(await import("./purchase-KUIKNVP7.js")).
10
10
  purchaseDomain,qualification:async()=>(await import("./skill-PQBRALUW.js")).qualificationDomain,receivable:async()=>(await import("./receivable-7EH4HZKF.js")).receivableDomain,redmine:async()=>(await import("./redmine-HYXBVLBI.js")).redmineDomain,report:async()=>(await import("./report-TU5CHEQB.js")).reportDomain,"role-template":async()=>(await import("./evaluation-7N52GMJE.js")).roleTemplateDomain,"rounding-setting":async()=>(await import("./sales-numbering-R4SEUE5Q.js")).roundingSettingDomain,
11
11
  "seal-impression":async()=>(await import("./sales-master-HROKFBDJ.js")).sealImpressionDomain,search:async()=>(await import("./search-C3V45WZ7.js")).searchDomain,secret:async()=>(await import("./secret-57ZPEBCJ.js")).secretDomain,segment:async()=>(await import("./segment-5SZUWKND.js")).segmentDomain,shift:async()=>(await import("./attendance-lists-34VZSGKG.js")).shiftDomain,skill:async()=>(await import("./skill-PQBRALUW.js")).skillDomain,slack:async()=>(await import("./slack-PS5ACRYL.js")).
12
- slackDomain,sns:async()=>(await import("./sns-2YRL6A6J.js")).snsDomain,"staffing-board":async()=>(await import("./staffing-board-QHMO4JCU.js")).staffingBoardDomain,storage:async()=>(await import("./storage-LJH2J7GU.js")).storageDomain,"supplier-payment":async()=>(await import("./supplier-payment-UCGCVGO2.js")).supplierPaymentDomain,support:async()=>(await import("./support-2FPYYMBI.js")).supportDomain,task:async()=>(await import("./task-7VN5I6XX.js")).taskDomain,teams:async()=>(await import("./teams-WMKWQCLH.js")).
12
+ slackDomain,sns:async()=>(await import("./sns-ING5W2OI.js")).snsDomain,"staffing-board":async()=>(await import("./staffing-board-QHMO4JCU.js")).staffingBoardDomain,storage:async()=>(await import("./storage-LJH2J7GU.js")).storageDomain,"supplier-payment":async()=>(await import("./supplier-payment-UCGCVGO2.js")).supplierPaymentDomain,support:async()=>(await import("./support-2FPYYMBI.js")).supportDomain,task:async()=>(await import("./task-7VN5I6XX.js")).taskDomain,teams:async()=>(await import("./teams-WMKWQCLH.js")).
13
13
  teamsDomain,user:async()=>(await import("./user-77JTTQWR.js")).userDomain,"user-contract-type":async()=>(await import("./user-contract-type-N7U3IODP.js")).userContractTypeDomain,"user-group":async()=>(await import("./user-group-3SZHZKQS.js")).userGroupDomain,wiki:async()=>(await import("./knowledge-UUTQOVQX.js")).wikiDomain,workchange:async()=>(await import("./attendance-lists-34VZSGKG.js")).workchangeDomain,"worker-agent":async()=>(await import("./worker-agent-427IM4GL.js")).workerAgentDomain,workflow:async()=>(await import("./workflow-IMYQZ3KD.js")).
14
14
  workflowDomain};async function loadDomain(name){return LOADERS[name]()}export{loadDomain};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{loadDomain}from"./chunk-MY5QCWCS.js";import{evaluateQuery}from"./chunk-LXFLA3PZ.js";import{renderDocument,renderOutput}from"./chunk-P4QSPSOQ.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{NO_REDACT_NOTICE,withCommonFlags}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs}from"./chunk-6NHLWYI2.js";import{Resolver,requireDefaultProject}from"./chunk-UZVBQV4W.js";
3
+ import{loadDomain}from"./chunk-CAJZZF7M.js";import{evaluateQuery}from"./chunk-LXFLA3PZ.js";import{renderDocument,renderOutput}from"./chunk-P4QSPSOQ.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{NO_REDACT_NOTICE,withCommonFlags}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs}from"./chunk-6NHLWYI2.js";import{Resolver,requireDefaultProject}from"./chunk-UZVBQV4W.js";
4
4
  import{ApiError,MultipartBody,TwpApiClient,appendQuery}from"./chunk-SH2YLLVL.js";import{ResolveError}from"./chunk-HVZUXLQ4.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-DYT22FTA.js";import{isRecord}from"./chunk-HCTPCUST.js";import{ApiRejectedError,ApiResponseError,ConflictError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_CONFLICT,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,EXIT_WAIT_TIMEOUT,NetworkError,UsageError,WaitTimeoutError}from"./chunk-STILP3Z6.js";
5
5
  import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{AuthSession,NotLoggedInError,SessionExpiredError}from"./chunk-ITFO5GPX.js";import{loadCredentials}from"./chunk-GWVREACM.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredBacklogSpace,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import{HELP_TOKEN}from"./chunk-ZN7AEXEI.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";
6
6
  import{stringWidth}from"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs from"fs";import path from"path";function alignedList(entries,indent=" "){const width=entries.reduce((max,[left])=>Math.max(max,stringWidth(left)),0);return entries.map(([left,right])=>`${indent}${left}${" ".repeat(Math.max(0,width-stringWidth(left)))} ${right}`).join("\n")}function subresourcesOf(resource){return resource.subresources??[]}function renderResourceHelp(resource,path2){const subresources=subresourcesOf(resource);const operationSection=resource.operations.length===0?"":`
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __twpCreateRequire } from 'node:module';
3
3
  const require = __twpCreateRequire(import.meta.url);
4
- import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{parseArgv,quietFromEnv}from"./chunk-4W6ZC7GV.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-ZN7AEXEI.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.136.0":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
4
+ import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{parseArgv,quietFromEnv}from"./chunk-4W6ZC7GV.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-ZN7AEXEI.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.137.0":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
5
5
 
6
6
  \u4F7F\u3044\u65B9:
7
7
  twp \u5BFE\u8A71 TUI \u3092\u8D77\u52D5
@@ -857,6 +857,7 @@ import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{parseArgv,quietFromE
857
857
  twp sns list --channel x [--fetch --yes | --status <\u72B6\u614B>]
858
858
  X \u4E0A\u306E\u81EA\u5206\u306E\u6295\u7A3F\uFF08\u6307\u6A19\u3064\u304D\uFF09\u304B\u3001TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\uFF08--status\uFF09\u3092\u4E00\u89A7\u3059\u308B
859
859
  twp sns post --channel x --text-file <\u30D1\u30B9> [--thread-file <\u30D1\u30B9> \u2026] [--media <\u753B\u50CF>] [--at <\u65E5\u6642>] --yes
860
+ twp sns post --channel x --text <\u672C\u6587> --quote <\u6295\u7A3FID|\u6295\u7A3FURL> [--at <\u65E5\u6642>] --yes
860
861
  X \u3078\u6295\u7A3F\u3059\u308B\u30FB\u4E88\u7D04\u3059\u308B\uFF08\u8CBB\u7528\u3092\u8868\u793A\u3057\u3066\u304B\u3089\u9001\u308B\u30FB--yes \u304C\u5FC5\u8981\uFF09
861
862
  twp sns edit --channel x <UUID> [--text-file <\u30D1\u30B9>] [--media <\u753B\u50CF> | --clear-media] --yes
862
863
  TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\u4E2D\u306E\u6295\u7A3F\u306E\u672C\u6587\u30FB\u753B\u50CF\u3092\u7DE8\u96C6\u3059\u308B\uFF08\u5909\u66F4\u524D\u5F8C\u3092\u8868\u793A\u3057\u3066\u304B\u3089\u9001\u308B\uFF09
@@ -1877,17 +1878,17 @@ TUI \u5185:
1877
1878
  \u4F1A\u8A71\u30FB\u30ED\u30FC\u30AB\u30EB\u30C4\u30FC\u30EB\uFF08\u30D5\u30A1\u30A4\u30EB\u30FB\u30B3\u30DE\u30F3\u30C9\u30FBgit\uFF09\u306F\u30C6\u30CA\u30F3\u30C8\u306E\u30AF\u30EC\u30B8\u30C3\u30C8\u3067\u5B9F\u969B\u306B\u52D5\u304D\u307E\u3059\u3002
1878
1879
  `;function ignoreEpipe(stream){stream.on("error",err=>{if(err.code==="EPIPE")process.exit(0);throw err})}async function main(){const nodeMajor=Number(process.versions.node.split(".")[0]);if(nodeMajor<22){process.stderr.write(`twp-cli \u306B\u306F Node.js 22 \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728: ${process.versions.node}\uFF09
1879
1880
  `);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);if(process.env["TWP_AUTO_UPDATE_WORKER"]==="1"){const{runAutoUpdateWorker}=await import("./auto-update-worker-CB52KUTF.js");await runAutoUpdateWorker().catch(()=>void 0);return}const[first,...rest]=process.argv.slice(2);if(first==="__complete"||first==="completion"){const completion=await import("./completion-VJF5W2L6.js");if(first==="completion"){process.exitCode=completion.runCompletion(rest,process.stdout,process.stderr);return}
1880
- const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-JEOUYMGG.js"),import("./config-XYWRBIC6.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="local-loop"){process.env["TWP_NO_AUTO_UPDATE"]="1";const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();const{runLocalLoopCommand}=await import("./commands-N2MWYHCZ.js");process.
1881
- exitCode=await runLocalLoopCommand(rest);return}if(first==="github"&&(rest[0]==="git-credential"||rest[0]==="git-remote")){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();const{runGithubGit}=await import("./github-git-F6EOFNQ7.js");process.exitCode=await runGithubGit(rest[0],rest.slice(1),{version:VERSION});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);
1881
+ const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-7H5U7QUD.js"),import("./config-XYWRBIC6.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="local-loop"){process.env["TWP_NO_AUTO_UPDATE"]="1";const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();const{runLocalLoopCommand}=await import("./commands-JWBG4N2N.js");process.
1882
+ exitCode=await runLocalLoopCommand(rest);return}if(first==="github"&&(rest[0]==="git-credential"||rest[0]==="git-remote")){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();const{runGithubGit}=await import("./github-git-NX4IRTDU.js");process.exitCode=await runGithubGit(rest[0],rest.slice(1),{version:VERSION});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);
1882
1883
  const{runConfigure}=await import("./configure-BJGPASNG.js");process.exitCode=await runConfigure(rest);return}const args=parseArgv(process.argv.slice(2));if(args.command==="version"){process.stdout.write(`${VERSION}
1883
1884
  `);return}if(args.command==="help"){process.stdout.write(HELP);return}if(args.movedCommand!==void 0){const{MOVED_QUEUE_COMMAND_MESSAGE}=await import("./dispatch-ZWCEVLKZ.js");process.stderr.write(MOVED_QUEUE_COMMAND_MESSAGE);process.exitCode=2;return}if(args.unknown.length>0){process.stderr.write(`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(args.unknown)}
1884
1885
 
1885
- ${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-LEJKFFSA.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
1886
- {},argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,refresh:args.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-7OCXXISL.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1886
+ ${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-AHV37JBZ.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
1887
+ {},argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,refresh:args.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-ZRZWEURH.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1887
1888
  globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-MQPXAW2C.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.
1888
1889
  command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-OKU5OXD5.js");const options={profile:args.profile,method:args.loginMethod,tenant:args.tenant,noBrowser:args.loginNoBrowser,cliVersion:VERSION,force:args.logoutForce,...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{}};const runner=args.command==="login"?runLogin:args.command==="logout"?runLogout:runWhoami;process.exitCode=await runner(options);return}
1889
1890
  if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-VAY4M4MI.js");process.exitCode=await runTaskLoop({action:args.taskLoopAction??"run",project:args.project,profile:args.profile,safe:args.safe,daemon:args.daemon,interval:args.interval,maxCycles:args.maxCycles,forceRunner:args.forceRunner,force:args.stopForce,drain:args.stopDrain,engine:args.engine,version:VERSION,verbose:args.verbose,scheduleNow:args.scheduleNow,scheduleCounts:args.scheduleCounts,scheduleGate:args.scheduleGate,
1890
1891
  scheduleOp:args.scheduleOp,scheduleConfigOp:args.scheduleConfigOp,scheduleId:args.scheduleId,charterOp:args.charterOp,charterInput:args.charterFile,charterOutput:args.charterOut,charterRevision:args.charterRevision,settingsOp:args.settingsOp,orientationOp:args.orientationOp,orientationArgs:args.orientationArgs,skillOp:args.skillOp,skillName:args.skillName,skillAll:args.skillAll,skillDir:args.skillDir,skillConfig:args.skillConfig,output:args.output,query:args.query,revisionFrom:args.revisionFrom,
1891
1892
  revisionTo:args.revisionTo,planOp:args.planOp,capacityOp:args.capacityOp,includeStopped:args.includeStopped,runnerOp:args.runnerOp,runnerId:args.runnerTargetId,triggerOp:args.triggerOp,triggerId:args.triggerId,triggerKey:args.triggerKey,triggerLimit:args.triggerLimit,planEmpty:args.planEmpty,planCheck:args.planCheck,yes:args.yes,ais:args.ais,workspace:args.workspace,aiConfigFile:args.aiConfigFile,noAiConfigFile:args.noAiConfigFile});return}if(args.command==="print"){const{runOneShot}=await import("./oneshot-CGOYLWED.js");
1892
- process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-VJSPABPJ.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1893
+ process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-RD6R2BFB.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1893
1894
  allowedTools,disallowedTools:args.disallowedTools,model:args.model,profile:args.profile,noTui:args.noTui||!process.stdout.isTTY,doctor:args.doctor,version:VERSION})}await main();
@@ -304,7 +304,7 @@ flags}}function numberFlag(p,name){const v=p.flags.get(name);if(v===void 0)retur
304
304
  \u3066\u304F\u3060\u3055\u3044"}return n}async function buildPublicOptions(p,env){const str=n=>{const v=p.flags.get(n);return typeof v==="string"?v:void 0};const publicUrl=str("--public-url");if(publicUrl===void 0)return"\u516C\u958B\u30E2\u30FC\u30C9\u306B\u306F --public-url\uFF08\u5916\u304B\u3089\u958B\u304F https:// \u306E URL\uFF09\u304C\u5FC5\u8981\u3067\u3059";const certPath=str("--tls-cert");const keyPath=str("--tls-key");if(certPath===void 0!==(keyPath===void 0))return"--tls-cert \u3068 --tl\
305
305
  s-key \u306F\u4E21\u65B9\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044";let tls;if(certPath!==void 0&&keyPath!==void 0){try{tls={cert:fs5.readFileSync(certPath,"utf8"),key:fs5.readFileSync(keyPath,"utf8")}}catch(e){return`\u8A3C\u660E\u66F8\u30FB\u9375\u3092\u8AAD\u3081\u307E\u305B\u3093\uFF08${e.message}\uFF09`}}const reauthRaw=str("--reauth-minutes");const reauth=reauthRaw===void 0?null:Number(reauthRaw);if(reauth!==null&&(!/^\d+$/.test(reauthRaw??"")||reauth<1||reauth>720))return"--reauth-m\
306
306
  inutes \u306F 1\u301C720 \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044";const allow=str("--allow-ip");const profile=str("--profile");const bind=str("--bind");const allowIps=allow!==void 0?allow.split(",").map(x=>x.trim()).filter(x=>x!==""):void 0;if(allowIps!==void 0&&allowIps.length===0)return"--allow-ip \u306B IP \u30A2\u30C9\u30EC\u30B9\u304C1\u3064\u3082\u3042\u308A\u307E\u305B\u3093";const opts={publicUrl,...tls?{tls}:{},behindTlsProxy:p.flags.get("--behind-tls-pr\
307
- oxy")===true,trustedProxy:p.flags.get("--trusted-proxy")===true,...allowIps!==void 0?{allowIps}:{},...bind!==void 0?{bindHost:bind}:{},...profile!==void 0?{profile}:{},...reauth!==null?{reauthWindowMs:reauth*6e4}:{},env,cliVersion:true?"0.136.0":"0.0.0-dev"};const{validatePublicOptions}=await import("./console-public-K5CP7KZJ.js");return validatePublicOptions(opts)??opts}function waitForSignal(){return new Promise(resolve=>{const done=()=>{process.removeListener("SIGINT",done);process.removeListener(
307
+ oxy")===true,trustedProxy:p.flags.get("--trusted-proxy")===true,...allowIps!==void 0?{allowIps}:{},...bind!==void 0?{bindHost:bind}:{},...profile!==void 0?{profile}:{},...reauth!==null?{reauthWindowMs:reauth*6e4}:{},env,cliVersion:true?"0.137.0":"0.0.0-dev"};const{validatePublicOptions}=await import("./console-public-K5CP7KZJ.js");return validatePublicOptions(opts)??opts}function waitForSignal(){return new Promise(resolve=>{const done=()=>{process.removeListener("SIGINT",done);process.removeListener(
308
308
  "SIGTERM",done);resolve()};process.once("SIGINT",done);process.once("SIGTERM",done)})}function lockDirOf(dir){return path5.join(dir,"lock")}function runningPid2(dir,isLoop){let pid;try{pid=Number.parseInt(fs5.readFileSync(path5.join(lockDirOf(dir),"pid"),"utf8").trim(),10)}catch{return null}if(!Number.isInteger(pid)||pid<=0)return null;return isLoop(pid)?pid:null}function protectedDeny(twpHome,cwd,home=os.homedir(),claudeConfigDir){const readWrite=[absPathRule(twpHome),absPathRule(path5.join(home,
309
309
  ".ssh")),absPathRule(path5.join(home,".claude")),absPathRule(path5.join(home,".claude.json"),""),...claudeConfigDir!==void 0&&claudeConfigDir.trim()!==""?[absPathRule(claudeConfigDir)]:[]];const writeOnly=[...cwd!==void 0?[absPathRule(path5.join(cwd,".claude")),absPathRule(path5.join(cwd,".git")),absPathRule(path5.join(cwd,".git"),""),absPathRule(path5.join(cwd,".mcp.json"),"")]:[],...SHELL_RC_FILES.map(f=>absPathRule(path5.join(home,f),""))];return[...readWrite.flatMap(p=>[`Read(${p})`,`Edit(${p}\
310
310
  )`]),...writeOnly.map(p=>`Edit(${p})`)]}var SHELL_RC_FILES=[".bashrc",".bash_profile",".bash_login",".bash_logout",".profile",".zshrc",".zprofile",".zshenv",".zlogin",".zlogout"];function unscopedWriteRules(allow){return allow.filter(r=>r==="Edit"||r==="Write"||r==="MultiEdit"||r==="Edit(*)"||r==="Edit(**)")}var STRIPPED_ENV_KEYS=["TWP_TOKEN","TWP_API_KEY","TWP_API_KEY_VALUE","TWP_LOOP_PLAN_TOKEN"];function aiEnv(env){const out={...env};for(const k of STRIPPED_ENV_KEYS)delete out[k];return out}async function defaultEngine(config,log,env){
@@ -37,4 +37,4 @@ REMOTE_USAGE)}const account=args.account!==void 0?await resolver.githubAccount(a
37
37
  `);if(deps.hint??process.stderr.isTTY===true){const origin=new URL(ctx.apiUrl).origin;err(`\u8A8D\u8A3C\u306F credential helper \u3067\u6E21\u3057\u307E\u3059\uFF08\u672A\u8A2D\u5B9A\u306A\u30891\u56DE\u3060\u3051\u30021\u884C\u76EE\u306F\u65E2\u5B58\u306E\u6C4E\u7528 helper \u3092\u5916\u3059\uFF09:
38
38
  git config --global credential.${origin}.helper ''
39
39
  git config --global --add credential.${origin}.helper '!twp github git-credential${args.profile!==void 0?` --profile ${args.profile}`:""}'
40
- `)}return EXIT_OK}async function runGithubGit(sub,argv,deps={}){try{return sub==="git-remote"?await runRemote(argv,deps):await runCredential(argv,deps)}catch(e){const{exitCodeFor,reportError}=await import("./run-LEJKFFSA.js");const code=exitCodeFor(e);reportError(e,null,code,deps.err??writeStderr);return code}}export{GIT_TOKEN_MARGIN_MS,GIT_USERNAME,isRelayTarget,parseCredentialInput,runGithubGit};
40
+ `)}return EXIT_OK}async function runGithubGit(sub,argv,deps={}){try{return sub==="git-remote"?await runRemote(argv,deps):await runCredential(argv,deps)}catch(e){const{exitCodeFor,reportError}=await import("./run-AHV37JBZ.js");const code=exitCodeFor(e);reportError(e,null,code,deps.err??writeStderr);return code}}export{GIT_TOKEN_MARGIN_MS,GIT_USERNAME,isRelayTarget,parseCredentialInput,runGithubGit};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{checkOutTarget}from"./chunk-G6QQFB2J.js";import"./chunk-MY5QCWCS.js";import"./chunk-LXFLA3PZ.js";import"./chunk-P4QSPSOQ.js";import{contentTypeFor,inspectLocalFile}from"./chunk-D3RGSH6B.js";import{checkUploadQuota}from"./chunk-GNSZOYBQ.js";import"./chunk-Q3B65OFC.js";import{parseWaitOptions,waitUntilTerminal}from"./chunk-3EFJQDC4.js";import"./chunk-RMFLTSOV.js";import{readBody}from"./chunk-V5WDGX4S.js";import"./chunk-W4NLJ2YK.js";
3
+ import{checkOutTarget}from"./chunk-XZVP3FUE.js";import"./chunk-CAJZZF7M.js";import"./chunk-LXFLA3PZ.js";import"./chunk-P4QSPSOQ.js";import{contentTypeFor,inspectLocalFile}from"./chunk-D3RGSH6B.js";import{checkUploadQuota}from"./chunk-GNSZOYBQ.js";import"./chunk-Q3B65OFC.js";import{parseWaitOptions,waitUntilTerminal}from"./chunk-3EFJQDC4.js";import"./chunk-RMFLTSOV.js";import{readBody}from"./chunk-V5WDGX4S.js";import"./chunk-W4NLJ2YK.js";
4
4
  import"./chunk-BD7O73GK.js";import{repeatedValues}from"./chunk-6NHLWYI2.js";import"./chunk-UZVBQV4W.js";import{ApiError}from"./chunk-SH2YLLVL.js";import"./chunk-CJFIIGSH.js";import{collapsesInUrlPath,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger,readEnvelopeCursor,shellQuote}from"./chunk-DYT22FTA.js";import{requireResolved,
5
5
  singleRef,withResolved}from"./chunk-7DCWZ2NF.js";import{acknowledgement,isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiRejectedError,ApiResponseError,NetworkError,UsageError,WaitTimeoutError}from"./chunk-STILP3Z6.js";import"./chunk-TZL2342W.js";import"./chunk-ITFO5GPX.js";import"./chunk-GWVREACM.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-ZN7AEXEI.js";import"./chunk-OKATZ4SN.js";
6
6
  import"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import crypto2 from"crypto";import fs2 from"fs";import path from"path";var SCOPE_PERSONAL="personal";var SCOPE_PROJECT="project";var UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var FORBIDDEN_NAME=/[/\\:*?"<>|]/;var NAME_MAX=255;var ROW_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","updated_at"];var TRASH_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","deleted_at"];function folderRows(raw){return raw.map(row=>{const id=row["id"];const name=row["name"];const parentId=row["parent_id"];if(typeof id!==
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{loadDomain}from"./chunk-MY5QCWCS.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
3
+ import{loadDomain}from"./chunk-CAJZZF7M.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-G6QQFB2J.js";import"./chunk-MY5QCWCS.js";import"./chunk-LXFLA3PZ.js";import"./chunk-P4QSPSOQ.js";import"./chunk-Q3B65OFC.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-6NHLWYI2.js";import"./chunk-UZVBQV4W.js";import"./chunk-SH2YLLVL.js";import"./chunk-CJFIIGSH.js";
3
+ import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-XZVP3FUE.js";import"./chunk-CAJZZF7M.js";import"./chunk-LXFLA3PZ.js";import"./chunk-P4QSPSOQ.js";import"./chunk-Q3B65OFC.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-6NHLWYI2.js";import"./chunk-UZVBQV4W.js";import"./chunk-SH2YLLVL.js";import"./chunk-CJFIIGSH.js";
4
4
  import"./chunk-HVZUXLQ4.js";import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import"./chunk-DYT22FTA.js";import"./chunk-HCTPCUST.js";import"./chunk-STILP3Z6.js";import"./chunk-TZL2342W.js";import"./chunk-ITFO5GPX.js";import"./chunk-GWVREACM.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-ZN7AEXEI.js";import"./chunk-OKATZ4SN.js";import"./chunk-RKBUJKI5.js";
5
5
  import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};
@@ -14,13 +14,14 @@ return`\u30B9\u30EC\u30C3\u30C9\u306F${X_MAX_THREAD_PARTS}\u4EF6\u307E\u3067\u30
14
14
  --channel",summary:"\u30C1\u30E3\u30CD\u30EB\uFF08x / linkedin / facebook / instagram\uFF09",takesValue:true,placeholder:"<\u30C1\u30E3\u30CD\u30EB>"};var X_CHANNEL_FLAG={...CHANNEL_FLAG,summary:"\u30C1\u30E3\u30CD\u30EB\uFF08x\uFF09"};var CHANNELS_FLAG={name:"--channel",summary:"\u30C1\u30E3\u30CD\u30EB\uFF08\u7E70\u308A\u8FD4\u3057\u3067\u8907\u6570\uFF09",takesValue:true,placeholder:"<\u30C1\u30E3\u30CD\u30EB>",repeatable:true};var ACCOUNT_FLAG={name:"--account",summary:"\u6295\u7A3F\u5148\u30A2\u30AB\u30A6\u30F3\u30C8\uFF08\u9023\u643AID \u304B @\u30E6\u30FC\u30B6\u30FC\
15
15
  \u540D\u3002\u9023\u643A\u304C1\u4EF6\u306A\u3089\u7701\u7565\u53EF\uFF09",takesValue:true,placeholder:"<ID|@\u540D\u524D>"};var TEXT_FLAG={name:"--text",summary:"\u672C\u6587\u3092\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08\u4E00\u884C\u5411\u3051\uFF09",takesValue:true,placeholder:"<\u6587\u5B57\u5217>"};var TEXT_FILE_FLAG={name:"--text-file",summary:"\u672C\u6587\u3092\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u8AAD\u3080\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9|\
16
16
  ->"};var THREAD_FLAG={name:"--thread",summary:"X \u306E\u30B9\u30EC\u30C3\u30C9\u306E\u7D9A\u304D\uFF082\u4EF6\u76EE\u4EE5\u964D\uFF09\u3092\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08\u7E70\u308A\u8FD4\u3057\u3067\u9806\u306B\u30FB--thread-file \u3068\u4F75\u7528\u4E0D\u53EF\uFF09",takesValue:true,placeholder:"<\u6587\u5B57\u5217>",repeatable:true};var THREAD_FILE_FLAG={name:"--thread-file",summary:"X \u306E\u30B9\u30EC\u30C3\u30C9\u306E\u7D9A\u304D\uFF082\u4EF6\u76EE\u4EE5\u964D\uFF09\u3092\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u8AAD\u3080\uFF08\u7E70\u308A\u8FD4\u3057\u3067\u9806\u306B\uFF09",
17
- takesValue:true,placeholder:"<\u30D1\u30B9>",repeatable:true};function str(value){return typeof value==="string"&&value!==""?value:null}function oneLine(value,max=40){const text=value.replace(/[\r\n\t]+/g," ").replace(/[\p{Cc}\p{Cf}]/gu,"").trim();const chars=[...text];return chars.length>max?`${chars.slice(0,max).join("")}\u2026`:text}function accountHandle(row){const username=oneLine(String(row["account_username"]??""));return username!==""?`@${username}`:oneLine(String(row["account_name"]??""))}
18
- function channelName(channel){return CHANNEL_LABELS[channel]??channel}function checkChannel(raw,allowed,usage){const channel=raw.trim().toLowerCase();if(CHANNEL_LABELS[channel]===void 0){throw new UsageError(`--channel ${raw} \u306F\u77E5\u3089\u306A\u3044\u30C1\u30E3\u30CD\u30EB\u3067\u3059\uFF08x / linkedin / facebook / instagram\uFF09`,usage)}if(!allowed.includes(channel)){throw new UsageError(`${channelName(channel)} \u3067\u306F\u3053\u306E\u64CD\u4F5C\u3092\u4F7F\u3048\u307E\u305B\u3093\uFF08\u4F7F\u3048\u308B\u306E\u306F ${allowed.
19
- map(channelName).join("\u30FB")} \u3067\u3059\uFF09`,usage)}return channel}function oneChannel(input,usage,allowed=POSTABLE_CHANNELS){const raw=input.flags.get("--channel");if(raw===void 0||raw.trim()==="")throw new UsageError("--channel \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: --channel x\uFF09",usage);return checkChannel(raw,allowed,usage)}function manyChannels(input,allowed,usage){const raws=repeatedValues(input,"--channel");if(raws.length===0)throw new UsageError("\
20
- --channel \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: --channel x\uFF09",usage);const channels=raws.map(raw=>checkChannel(raw,allowed,usage));const dup=channels.find((c,i)=>channels.indexOf(c)!==i);if(dup!==void 0)throw new UsageError(`--channel ${dup} \u304C2\u56DE\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`,usage);return channels}function dataRecord(body,label){const data=isRecord(body)?body["data"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(data)){
21
- throw new ApiResponseError(`${label}\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return data}function items(body,label){const list=isRecord(body)?body["items"]:void 0;if(!Array.isArray(list))throw new ApiResponseError(`${label}\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
22
- return list.filter(isRecord)}function segment(value,label){if(!isSafePathSegment(value))throw new ApiResponseError(`${label}\u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${value}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return encodeURIComponent(value)}async function resolveAccount(input,ctx,channel,usage,options={}){const rows=options.rows??(await ctx.resolver.snsConnections()).filter(row2=>row2["provider"]===channel);const label=channelName(
23
- channel);if(rows.length===0){if(ORGANIZATION_CHANNELS.includes(channel)){throw new UsageError(`${label} \u306E\u9023\u643A\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3059\uFF09`,`${label} \u306F\u5E83\u5831\u306E\u7BA1\u7406\u8005\u304C\u7D44\u7E54\u3068\u3057\u3066\u9023\u643A\u3057\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u3092\u6301\u3064\u4EBA\u304C\u4F7F\u3048\u307E\u3059\u3002\u9023\u643A\u6E08\u307F\u306E\u306F\u305A\u306A\u3089\u3001\u5E83\u5831\u306E\u6A29\u9650\u3092\u30C6\u30CA\u30F3\u30C8\u306E\u7BA1\u7406\u8005\u306B\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u672A\u9023\u643A\u306A\u3089\u3001\u5E83\u5831\u306E\u7BA1\u7406\u8005\u304C${connectScreen(
17
+ takesValue:true,placeholder:"<\u30D1\u30B9>",repeatable:true};var QUOTE_FLAG={name:"--quote",summary:"X \u3067\u5F15\u7528\u3059\u308B\u6295\u7A3F\uFF08\u6570\u5B57\u306E ID \u304B\u6295\u7A3F URL\u3002\u30B9\u30EC\u30C3\u30C9\u3067\u306F1\u4EF6\u76EE\u304C\u5F15\u7528\u306B\u306A\u308B\uFF09",takesValue:true,placeholder:"<\u6295\u7A3FID|\u6295\u7A3FURL>"};function str(value){return typeof value==="string"&&value!==""?value:null}function oneLine(value,max=40){const text=value.replace(/[\r\n\t]+/g,
18
+ " ").replace(/[\p{Cc}\p{Cf}]/gu,"").trim();const chars=[...text];return chars.length>max?`${chars.slice(0,max).join("")}\u2026`:text}function accountHandle(row){const username=oneLine(String(row["account_username"]??""));return username!==""?`@${username}`:oneLine(String(row["account_name"]??""))}function channelName(channel){return CHANNEL_LABELS[channel]??channel}function checkChannel(raw,allowed,usage){const channel=raw.trim().toLowerCase();if(CHANNEL_LABELS[channel]===void 0){throw new UsageError(
19
+ `--channel ${raw} \u306F\u77E5\u3089\u306A\u3044\u30C1\u30E3\u30CD\u30EB\u3067\u3059\uFF08x / linkedin / facebook / instagram\uFF09`,usage)}if(!allowed.includes(channel)){throw new UsageError(`${channelName(channel)} \u3067\u306F\u3053\u306E\u64CD\u4F5C\u3092\u4F7F\u3048\u307E\u305B\u3093\uFF08\u4F7F\u3048\u308B\u306E\u306F ${allowed.map(channelName).join("\u30FB")} \u3067\u3059\uFF09`,usage)}return channel}function oneChannel(input,usage,allowed=POSTABLE_CHANNELS){const raw=input.flags.get("--c\
20
+ hannel");if(raw===void 0||raw.trim()==="")throw new UsageError("--channel \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: --channel x\uFF09",usage);return checkChannel(raw,allowed,usage)}function manyChannels(input,allowed,usage){const raws=repeatedValues(input,"--channel");if(raws.length===0)throw new UsageError("--channel \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: --channel x\uFF09",usage);const channels=raws.map(raw=>checkChannel(raw,allowed,usage));
21
+ const dup=channels.find((c,i)=>channels.indexOf(c)!==i);if(dup!==void 0)throw new UsageError(`--channel ${dup} \u304C2\u56DE\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`,usage);return channels}function dataRecord(body,label){const data=isRecord(body)?body["data"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(data)){throw new ApiResponseError(`${label}\u306E\u5FDC\u7B54\u306B data \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}
22
+ return data}function items(body,label){const list=isRecord(body)?body["items"]:void 0;if(!Array.isArray(list))throw new ApiResponseError(`${label}\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return list.filter(isRecord)}function segment(value,label){if(!isSafePathSegment(value))throw new ApiResponseError(`${label}\u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${value}\
23
+ \u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);return encodeURIComponent(value)}async function resolveAccount(input,ctx,channel,usage,options={}){const rows=options.rows??(await ctx.resolver.snsConnections()).filter(row2=>row2["provider"]===channel);const label=channelName(channel);if(rows.length===0){if(ORGANIZATION_CHANNELS.includes(channel)){throw new UsageError(`${label} \u306E\u9023\u643A\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3059\uFF09`,
24
+ `${label} \u306F\u5E83\u5831\u306E\u7BA1\u7406\u8005\u304C\u7D44\u7E54\u3068\u3057\u3066\u9023\u643A\u3057\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u3092\u6301\u3064\u4EBA\u304C\u4F7F\u3048\u307E\u3059\u3002\u9023\u643A\u6E08\u307F\u306E\u306F\u305A\u306A\u3089\u3001\u5E83\u5831\u306E\u6A29\u9650\u3092\u30C6\u30CA\u30F3\u30C8\u306E\u7BA1\u7406\u8005\u306B\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u672A\u9023\u643A\u306A\u3089\u3001\u5E83\u5831\u306E\u7BA1\u7406\u8005\u304C${connectScreen(
24
25
  channel)}\u3067\u9023\u643A\u3057\u307E\u3059\uFF08\u30D6\u30E9\u30A6\u30B6\u3067\u884C\u3044\u307E\u3059\uFF09\u3002`+(channel==="facebook"?"Facebook\u30DA\u30FC\u30B8\u306F\u3001\u63D0\u4F9B\u3092\u59CB\u3081\u3066\u3044\u306A\u3044\u30C6\u30CA\u30F3\u30C8\u3067\u306F\u307E\u3060\u4F7F\u3048\u307E\u305B\u3093\uFF08twp sns accounts \u306B Facebook\u30DA\u30FC\u30B8\u306E\u6848\u5185\u304C\u51FA\u306A\u3044\u3068\u304D\u306F\u3053\u308C\u306B\u5F53\u305F\u308A\u307E\u3059\uFF09\u3002":""))}throw new UsageError(
25
26
  `${label} \u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u9023\u643A\u3055\u308C\u3066\u3044\u307E\u305B\u3093`,`${connectScreen(channel)}\u3092\u958B\u304D\u300C\u9023\u643A\u3059\u308B\u300D\u304B\u3089\u9023\u643A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u9023\u643A\u306F\u30D6\u30E9\u30A6\u30B6\u3067\u884C\u3044\u307E\u3059\uFF09\u3002twp sns accounts \u3067\u9023\u643A\u306E\u72B6\u614B\u3092\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002`)}const ref=input.flags.get("--account")?.trim();let row;if(ref===
26
27
  void 0||ref===""){if(rows.length>1){const names=rows.map(r=>`${String(r["id"])}\uFF08${accountHandle(r)}\uFF09`).join("\u3001");throw new UsageError(`${label} \u306E\u9023\u643A\u304C ${rows.length} \u4EF6\u3042\u308A\u307E\u3059\u3002--account \u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044: ${names}`,usage)}row=rows[0]}else{const name=ref.replace(/^@/,"").toLowerCase();const hits=rows.filter(r=>r["id"]===ref||String(r["account_username"]??"").toLowerCase()===name||String(r["account_name"]??"").
@@ -63,52 +64,57 @@ connection_id"]!==wanted)){throw new ApiResponseError("\u63A5\u7D9A\u5148\u304C\
63
64
  body))return facebookData(body)["posts"].filter(isRecord).map(facebookRow);if(listModeOf(body)==="instagram")return items(body,"Instagram \u306E\u30E1\u30C7\u30A3\u30A2\u4E00\u89A7").map(instagramRow);const names=isRecord(body)&&isRecord(body[ACCOUNT_NAMES_KEY])?body[ACCOUNT_NAMES_KEY]:{};return items(body,"SNS\u6295\u7A3F\u306E\u4E00\u89A7").map(row=>postRow(row,names))},raw:body=>isTimeline(body)?timelineData(body):isFacebookFeed(body)?facebookData(body):items(body,"SNS\u6295\u7A3F\u306E\u4E00\u89A7"),
64
65
  notes(body,input){if(isFacebookFeed(body)){const page=facebookData(body)["page"];const name=isRecord(page)?str(page["name"]):null;return name===null?[]:[`Facebook\u30DA\u30FC\u30B8: ${oneLine(name)}`]}if(!isTimeline(body))return[];const data=timelineData(body);const notes=[];const fetchedAt=Date.parse(String(data["fetched_at"]??""));if(input.resolved?.["mode"]==="timeline"&&Number.isFinite(fetchedAt)&&Date.now()-fetchedAt<2*60*1e3){notes.push("\u26A0 \u30AD\u30E3\u30C3\u30B7\u30E5\u304C\u53E4\u304B\u3063\u305F\u305F\u3081\u3001\u30B5\u30FC\u30D0\u304C X \u304B\u3089\u65B0\u7740\u3092\u8AAD\u307F\u53D6\u308A\u307E\u3057\u305F\uFF08\u8AAD\u307F\u53D6\u3063\u305F\u4EF6\u6570\u3076\u3093\u306E\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\
65
66
  \u8CBB\u3057\u3066\u3044\u307E\u3059\uFF09\u3002")}if(data["cached"]!==true){notes.push("\u3053\u306E\u9023\u643A\u306E\u6295\u7A3F\u306F\u307E\u3060\u4E00\u5EA6\u3082\u53D6\u5F97\u3057\u3066\u3044\u307E\u305B\u3093\u3002--fetch --yes \u3067\u53D6\u5F97\u3057\u307E\u3059\uFF08\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF09\u3002")}else{notes.push(`\u53D6\u5F97: ${String(data["fetched_at"]??"\u4E0D\u660E")} / \u6307\u6A19\u306E\u66F4\u65B0: ${String(data["metrics_refreshe\
66
- d_at"]??"\u306A\u3057")}`)}const error=str(data["refresh_error"]);if(error!==null)notes.push(`\u26A0 X \u304B\u3089\u306E\u65B0\u7740\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08\u4E00\u89A7\u306F\u624B\u5143\u306E\u30AD\u30E3\u30C3\u30B7\u30E5\u3067\u3059\uFF09: ${error}`);return notes}};var POST_USAGE="twp sns post --channel <\u30C1\u30E3\u30CD\u30EB> [--channel \u2026] [--account <ID|@\u540D\u524D>] (--text <\u6587\u5B57\u5217> | --text-file <\u30D1\u30B9>) [--thread <\u6587\u5B57\u5217> \u2026 | --thread-file <\u30D1\u30B9> \u2026] [--media <\u753B\u50CF|\u52D5\u753B> \u2026] [--at <\u65E5\u6642>] \
67
- --yes";function parseAt(raw,now=new Date){const m=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(Z|[+-]\d{2}:\d{2})?$/.exec(raw.trim());const bad=()=>{throw new UsageError(`--at \u306F YYYY-MM-DDTHH:MM\uFF08\u65E5\u672C\u6642\u9593\uFF09\u304B\u3001\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u4ED8\u304D\u306E\u65E5\u6642\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`,"\u4F8B: --at 2026-11-04T09:30 \uFF0F --at 2026-11-04T00:30Z")};
68
- if(m===null)return bad();const[,y,mo,d,h,mi,s="00",zone]=m;const parts=[Number(y),Number(mo),Number(d),Number(h),Number(mi),Number(s)];const check=new Date(Date.UTC(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]));if(check.getUTCFullYear()!==parts[0]||check.getUTCMonth()!==parts[1]-1||check.getUTCDate()!==parts[2]||check.getUTCHours()!==parts[3]||check.getUTCMinutes()!==parts[4]||check.getUTCSeconds()!==parts[5]){return bad()}const offset=zone??"+09:00";const iso=`${y}-${mo}-${d}T${h}:${mi}\
69
- :${s}${offset==="Z"?"Z":offset}`;const at=new Date(iso);if(Number.isNaN(at.getTime()))return bad();if(at.getTime()<=now.getTime()){throw new UsageError(`--at \u306E\u65E5\u6642\uFF08${iso}\uFF09\u304C\u904E\u304E\u3066\u3044\u307E\u3059\u3002\u4E88\u7D04\u306F\u73FE\u5728\u3088\u308A\u5F8C\u306E\u65E5\u6642\u306B\u3057\u3066\u304F\u3060\u3055\u3044`,POST_USAGE)}return{iso,assumedJst:zone===void 0}}function mediaFiles(input,channels,usage=POST_USAGE){const raws=repeatedValues(input,"--media");const files=raws.
70
- map(raw=>{const{file,size}=inspectLocalFile(raw,"--media",usage);const name=path.basename(file);return{file,name,size,contentType:snsContentType(name)}});for(const channel of channels){const violation=mediaViolation(channel,files);if(violation!==null)throw new UsageError(violation,usage)}return files}var VIDEO_EXTENSIONS={".mp4":"video/mp4",".mov":"video/quicktime"};function snsContentType(name){return VIDEO_EXTENSIONS[path.extname(name).toLowerCase()]??contentTypeFor(name)}function mediaViolation(channel,files){
71
- const rule=MEDIA_RULES[channel];if(rule===void 0)return null;const label=channelName(channel);if(files.length===0){return rule.required?`${label} \u306B\u306F\u753B\u50CF\u304B\u52D5\u753B\u304C1\u4EF6\u4EE5\u4E0A\u5FC5\u8981\u3067\u3059\uFF08--media \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF09`:null}if(files.length>rule.maxItems)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u30E1\u30C7\u30A3\u30A2\u306F ${rule.maxItems} \u4EF6\u307E\u3067\u3067\u3059\uFF08${files.length} \
72
- \u4EF6\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\uFF09`;const videos=files.filter(f=>rule.videoTypes.includes(f.contentType)).length;if(!rule.mixed&&videos>0&&videos<files.length)return`${label} \u306E\u6295\u7A3F\u306B\u306F\u753B\u50CF\u3068\u52D5\u753B\u3092\u540C\u6642\u306B\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093`;if(videos>rule.maxVideos&&rule.maxVideos>0)return`${label} \u306E\u6295\u7A3F\u306B\u4ED8\u3051\u3089\u308C\u308B\u52D5\u753B\u306F ${rule.maxVideos} \u672C\u307E\u3067\u3067\u3059`;
73
- for(const f of files){if(rule.imageTypes.includes(f.contentType)){const max=channel==="x"&&f.contentType==="image/gif"?X_MAX_GIF_BYTES:rule.maxImageBytes;if(f.size>max)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u753B\u50CF\u306F ${max/MB}MB \u307E\u3067\u3067\u3059: ${f.file}`}else if(rule.videoTypes.includes(f.contentType)){const max=rule.maxVideoBytes(files.length);if(f.size>max)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u52D5\u753B\u306F ${max/MB}MB \u307E\u3067\u3067\u3059${channel===
74
- "instagram"?files.length>=2?"\uFF08\u30AB\u30EB\u30FC\u30BB\u30EB\uFF09":"\uFF08\u30EA\u30FC\u30EB\uFF09":""}: ${f.file}`}else{return`${label} \u306B\u306F${rule.typesText}\u3060\u3051\u3092\u4ED8\u3051\u3089\u308C\u307E\u3059: ${f.file}`}}return null}function textViolation(channel,text){const limit=TEXT_LIMITS[channel];if(limit===void 0)return null;const count=charCount(text);if(count>limit)return`${channelName(channel)} \u306E\u672C\u6587\u306F ${limit} \u6587\u5B57\u307E\u3067\u3067\u3059\uFF08${count}\
75
- \u6587\u5B57\uFF09`;if(channel==="instagram"){const tags=(text.replace(URL_PATTERN_ALL," ").match(/[##][^\s##。、,.!?「」()()]+/gu)??[]).length;if(tags>INSTAGRAM_MAX_HASHTAGS)return`Instagram \u306E\u30CF\u30C3\u30B7\u30E5\u30BF\u30B0\u306F ${INSTAGRAM_MAX_HASHTAGS} \u500B\u307E\u3067\u3067\u3059\uFF08${tags} \u500B\uFF09`}return null}async function readText(input,usage,required){const text=await readBody(input,{flag:"--text",fileFlag:"--text-file",label:"\u672C\u6587",maxChars:BODY_MAX_CHARS,
76
- usage});if(required&&(text===void 0||text.trim()===""))throw new UsageError("\u672C\u6587\uFF08--text \u304B --text-file\uFF09\u304B\u753B\u50CF\uFF08--media\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usage);return text}async function readThread(input){const inline=repeatedValues(input,THREAD_FLAG.name);const files=repeatedValues(input,THREAD_FILE_FLAG.name);if(inline.length>0&&files.length>0){throw new UsageError("--thread \u3068 --thread-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\uFF08\u4EF6\u306E\u9806\u5E8F\u304C\u6C7A\u307E\u3089\u306A\u3044\u305F\u3081\uFF09",
77
- POST_USAGE)}const[flag,values]=inline.length>0?[THREAD_FLAG.name,inline]:[THREAD_FILE_FLAG.name,files];const parts=[];for(const[i,value]of values.entries()){if(flag===THREAD_FILE_FLAG.name&&value==="-"){throw new UsageError("--thread-file \u306B\u6A19\u6E96\u5165\u529B\uFF08-\uFF09\u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044",POST_USAGE)}const flags=new Map([...input.flags].filter(([name])=>name!=="--text"&&name!==
78
- "--text-file"));flags.set(flag,value);const text=await readBody({args:[],flags},{flag:THREAD_FLAG.name,fileFlag:THREAD_FILE_FLAG.name,label:`\u30B9\u30EC\u30C3\u30C9\u306E${i+2}\u4EF6\u76EE`,maxChars:BODY_MAX_CHARS,usage:POST_USAGE});parts.push(text??"")}return parts}function postThread(input){const raw=input.resolved?.["thread"];return raw===void 0?[]:JSON.parse(raw)}function partCredits(price,text){return URL_PATTERN.test(text)?price.postWithLink:price.post}function postTargets(input){return JSON.
79
- parse(requireResolved(input,"targets"))}function postText(input){return JSON.parse(requireResolved(input,"text"))}function draftPlan(input){const thread=postThread(input);return{method:"POST",path:POSTS_PATH,body:{body:postText(input),targets:postTargets(input).map(t=>({channel:t.channel,connection_id:t.connectionId,...thread.length>0?{thread_bodies:thread}:{}}))}}}function postId(row){const id=str(row["id"]);if(id===null||!UUID.test(id))throw new ApiResponseError("SNS\u6295\u7A3F\u306E\u5FDC\u7B54\u306B id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\
80
- \u3055\u3044\u3002");return id}async function discardDraft(ctx,row){const channel=str(row["channel"])??"x";try{await ctx.send({method:"DELETE",path:`${POSTS_PATH}/${postId(row)}`,body:{expected_updated_at:row["updated_at"]??null}});ctx.warn(`\u4F5C\u6210\u9014\u4E2D\u306E\u4E0B\u66F8\u304D\uFF08${String(row["id"])}\uFF09\u3092\u524A\u9664\u3057\u307E\u3057\u305F\u3002`)}catch(error){ctx.warn(`\u4F5C\u6210\u9014\u4E2D\u306E\u4E0B\u66F8\u304D\uFF08${String(row["id"])}\uFF09\u3092\u524A\u9664\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08${error.
81
- message}\uFF09\u3002twp sns list --channel ${channel} --status draft \u3067\u78BA\u304B\u3081\u3001twp sns delete --channel ${channel} ${String(row["id"])} --yes \u3067\u6D88\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}}var postOperation={name:"post",summary:"SNS \u3078\u6295\u7A3F\u3059\u308B\u30FB\u4E88\u7D04\u3059\u308B\uFF08--yes \u304C\u5FC5\u8981\uFF09",usage:POST_USAGE,description:"\u26A0 \u5916\u90E8\u3078\u516C\u958B\u3059\u308B\u64CD\u4F5C\u3067\u3059\u3002--yes \u304C\u7121\u3051\u308C\u3070\u5B9F\u884C\u3057\u307E\u305B\u3093\u3002--dry-run \u3067\u6295\u7A3F\u5148\u30FB\u8CBB\u7528\u30FB\u672C\u6587\u3092\u78BA\u304B\u3081\u3066\u304B\u3089\n --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08--dry-run \u3067\u3082\u6599\u91D1\u306E\u78BA\u8A8D\u306E\u305F\u3081 GET \u30921\u672C\u9001\u308A\u307E\
82
- \u3059\uFF09\u3002\n\u26A0 X \u3078\u306E\u6295\u7A3F\u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\u3002\u672C\u6587\u306B URL \u3092\u542B\u3080\u300C\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u300D\u306F\u5358\u4FA1\u304C\u5927\u304D\u304F\u4E0A\u304C\u308A\u307E\u3059\n \uFF08\u9001\u308B\u524D\u306B\u5358\u4FA1\u3092\u8868\u793A\u3057\u307E\u3059\uFF09\u3002LinkedIn\u30FBFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u3078\u306E\u6295\u7A3F\u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u305B\u3093\u3002\n\n--at \u3092\u4ED8\u3051\u308B\u3068\u4E88\u7D04\u3057\u307E\u3059\uFF08\u6307\u5B9A\u306E\u6642\u523B\u306B TWP \u304C\u6295\u7A3F\u3057\u307E\u3059\uFF09\u3002\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u3092\u4ED8\u3051\u306A\u3044\u65E5\u6642\u306F\u65E5\u672C\u6642\u9593\u3067\u3059\u3002\n\u4E88\u7D04\u306E\u53D6\u308A\u6D88\u3057\u306F twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status scheduled \u306E id \u3092 twp sns delete \u306B\u6E21\u3057\u307E\u3059\u3002\n--channel \u306F\u7E70\u308A\u8FD4\u3057\u3066\u8907\u6570\u306E\u30C1\u30E3\u30CD\u30EB\u3078\u540C\u3058\u672C\u6587\u30FB\u540C\u3058\u30E1\u30C7\u30A3\u30A2\u3092\u51FA\u305B\u307E\u3059\u3002\u7D50\u679C\u306F\u30C1\u30E3\u30CD\u30EB\u3054\u3068\u306B\u51FA\u3057\u307E\u3059\n\uFF081\u3064\u304C\u5931\u6557\u3057\u3066\u3082\u3001\u4ED6\u306E\u30C1\u30E3\u30CD\u30EB\u306E\u6295\u7A3F\u306F\u53D6\u308A\u6D88\u3057\u307E\u305B\u3093\uFF09\u3002\n--media\uFF08\u7E70\u308A\u8FD4\u3057\u6307\u5B9A\uFF09\u3067\u4ED8\u3051\u3089\u308C\u308B\u3082\u306E\uFF08\u6307\u5B9A\u3057\u305F\u5168\u30C1\u30E3\u30CD\u30EB\u306E\u6761\u4EF6\u3067\u9001\u308B\u524D\u306B\u78BA\u304B\u3081\u307E\u3059\uFF09:\n x \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBWEBP\u30FBGIF\uFF094\u679A\u307E\u3067\u3002\u52D5\u753B\u306F\u4E0D\u53EF\n linkedin \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBGIF\uFF0910\u679A\u307E\u3067\u3002\u52D5\u753B\u306F\u4E0D\u53EF\n faceb\
83
- ook \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBGIF\uFF0910\u679A\u307E\u3067 \u304B \u52D5\u753B\uFF08MP4\u30FBMOV\uFF091\u672C\u3002\u753B\u50CF\u3068\u52D5\u753B\u306F\u6DF7\u305C\u3089\u308C\u306A\u3044\n instagram \u2026 \u5FC5\u9808\u3002JPEG \u306E\u753B\u50CF\u30FBMP4/MOV \u306E\u52D5\u753B\u3092\u5408\u308F\u305B\u306610\u4EF6\u307E\u3067\uFF081\u4EF6\u306E\u52D5\u753B\u306F\u30EA\u30FC\u30EB\u30012\u4EF6\u4EE5\u4E0A\u306F\u30AB\u30EB\u30FC\u30BB\u30EB\uFF09\n\u672C\u6587\u306E\u4E0A\u9650\u306F X \u304C\u9023\u643A\u306E\u30D7\u30E9\u30F3\u3067 280 \u304B 25,000\uFF08\u65E5\u672C\u8A9E\u306F1\u5B572\uFF09\u3001LinkedIn 3,000\u3001Facebook\u30DA\u30FC\u30B8 63,206\u3001\nInstagram 2,200 \u6587\u5B57\uFF08\u30CF\u30C3\u30B7\u30E5\u30BF\u30B030\u500B\u307E\u3067\uFF09\u3067\u3059\u3002\nFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u306F\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u3002\n\n--thread / --thread-file \u3092\u4ED8\u3051\u308B\u3068 X \u306E\u30B9\u30EC\u30C3\u30C9\u306B\u3057\u307E\u3059\uFF08--text \u304C1\u4EF6\u76EE\u3001\u7D9A\u304D\u3092\u6307\u5B9A\u3057\u305F\u9806\u306B\u8FD4\u4FE1\u3068\u3057\u3066\u3064\u306A\u3052\u308B\uFF09\u3002\n 1\u4EF6\u76EE\u3092\u542B\u3081\u306625\u4EF6\u307E\u3067\u30FB\u5404\u4EF6 X \u306E\u4E0A\u9650\uFF08\u9023\u643A\u306E\u30D7\u30E9\u30F3\u3067 280 \u304B 25,000\u3002\u65E5\u672C\u8A9E\u306F1\u5B572\u3002\u7D9A\u304D\u306F2000\u5B57\u307E\u3067\uFF09\u307E\u3067\u30FB\u7D9A\u304D\u306E\u7A7A\u306F\u4E0D\u53EF\uFF08\u9001\u308B\u524D\u306B\u6B62\u3081\u307E\u3059\uFF09\u3002\n \u8CBB\u7528\u306F\u4EF6\u3054\u3068\u3067\u3001URL \u3092\u542B\u3080\u4EF6\u3060\u3051\u304C\u30EA\u30F3\u30AF\u4ED8\u304D\u306E\u5358\u4FA1\u3067\u3059\u3002URL \u30922\u4EF6\u76EE\u4EE5\u964D\u3078\u7F6E\u304F\u3068\
84
- 1\u4EF6\u76EE\u306E\u5358\u4FA1\u306F\u901A\u5E38\u306E\u307E\u307E\u3067\u3059\u3002\n \u753B\u50CF\uFF08--media\uFF09\u306F1\u4EF6\u76EE\u306B\u3060\u3051\u4ED8\u304D\u307E\u3059\u3002\u30B9\u30EC\u30C3\u30C9\u306F X \u3060\u3051\u3067\u4F7F\u3048\u307E\u3059\u3002\n \u9014\u4E2D\u3067\u5931\u6557\u3059\u308B\u3068\u305D\u308C\u307E\u3067\u306E\u4EF6\u306F X \u306B\u51FA\u305F\u307E\u307E\u6B8B\u308A\u307E\u3059\uFF08\u518D\u9001\u306F\u3057\u307E\u305B\u3093\uFF09\u3002\u4F55\u4EF6\u76EE\u307E\u3067\u51FA\u305F\u304B\u3092\n twp sns list --channel x --status all \u3067\u78BA\u304B\u3081\u3066\u304B\u3089\u6253\u3061\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n\n\u9806\u306B\u3001\u4E0B\u66F8\u304D\u306E\u4F5C\u6210 \u2192 \u753B\u50CF\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3068\u7D10\u3065\u3051 \u2192 \u6295\u7A3F\uFF08--at \u306A\u3089\u4E88\u7D04\uFF09\u3092\u9001\u308A\u307E\u3059\u3002\u9014\u4E2D\u3067\u6B62\u307E\u3063\u305F\u3089\n\u4F5C\u3063\u305F\u4E0B\u66F8\u304D\u3092\u6D88\u3057\u307E\u3059\u3002\u7D42\u4E86\u30B3\u30FC\u30C9 4\uFF08\u901A\u4FE1\u306E\u5931\u6557\uFF09\u3067\u3082 SNS \u5074\u3067\u306F\u6295\u7A3F\u6E08\u307F\u306E\u3053\u3068\u304C\u3042\u308B\u306E\u3067\u3001\u6253\u3061\u76F4\u3059\u524D\u306B\ntwp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status all \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002",
85
- destructive:true,confirmation:"\u5916\u90E8\u306E SNS \u3078\u516C\u958B\u6295\u7A3F\u3059\u308B\u64CD\u4F5C\uFF08X \u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF09",flags:[CHANNELS_FLAG,ACCOUNT_FLAG,TEXT_FLAG,TEXT_FILE_FLAG,THREAD_FLAG,THREAD_FILE_FLAG,{name:"--media",summary:"\u4ED8\u3051\u308B\u753B\u50CF\u30FB\u52D5\u753B\u306E\u30D1\u30B9\uFF08\u7E70\u308A\u8FD4\u3057\u6307\u5B9A\u30FBInstagram \u306F\u5FC5\u9808\u30FB\u30B9\u30EC\u30C3\u30C9\u3067\u306F1\u4EF6\u76EE\u306B\u3060\u3051\u4ED8\u304F\uFF09",
67
+ d_at"]??"\u306A\u3057")}`)}const error=str(data["refresh_error"]);if(error!==null)notes.push(`\u26A0 X \u304B\u3089\u306E\u65B0\u7740\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08\u4E00\u89A7\u306F\u624B\u5143\u306E\u30AD\u30E3\u30C3\u30B7\u30E5\u3067\u3059\uFF09: ${error}`);return notes}};var POST_USAGE="twp sns post --channel <\u30C1\u30E3\u30CD\u30EB> [--channel \u2026] [--account <ID|@\u540D\u524D>] (--text <\u6587\u5B57\u5217> | --text-file <\u30D1\u30B9>) [--thread <\u6587\u5B57\u5217> \u2026 | --thread-file <\u30D1\u30B9> \u2026] [--quote <\u6295\u7A3FID|\u6295\u7A3FURL>] [--media \
68
+ <\u753B\u50CF|\u52D5\u753B> \u2026] [--at <\u65E5\u6642>] --yes";function parseAt(raw,now=new Date){const m=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(Z|[+-]\d{2}:\d{2})?$/.exec(raw.trim());const bad=()=>{throw new UsageError(`--at \u306F YYYY-MM-DDTHH:MM\uFF08\u65E5\u672C\u6642\u9593\uFF09\u304B\u3001\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u4ED8\u304D\u306E\u65E5\u6642\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`,"\u4F8B: \
69
+ --at 2026-11-04T09:30 \uFF0F --at 2026-11-04T00:30Z")};if(m===null)return bad();const[,y,mo,d,h,mi,s="00",zone]=m;const parts=[Number(y),Number(mo),Number(d),Number(h),Number(mi),Number(s)];const check=new Date(Date.UTC(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]));if(check.getUTCFullYear()!==parts[0]||check.getUTCMonth()!==parts[1]-1||check.getUTCDate()!==parts[2]||check.getUTCHours()!==parts[3]||check.getUTCMinutes()!==parts[4]||check.getUTCSeconds()!==parts[5]){return bad()}const offset=zone??
70
+ "+09:00";const iso=`${y}-${mo}-${d}T${h}:${mi}:${s}${offset==="Z"?"Z":offset}`;const at=new Date(iso);if(Number.isNaN(at.getTime()))return bad();if(at.getTime()<=now.getTime()){throw new UsageError(`--at \u306E\u65E5\u6642\uFF08${iso}\uFF09\u304C\u904E\u304E\u3066\u3044\u307E\u3059\u3002\u4E88\u7D04\u306F\u73FE\u5728\u3088\u308A\u5F8C\u306E\u65E5\u6642\u306B\u3057\u3066\u304F\u3060\u3055\u3044`,POST_USAGE)}return{iso,assumedJst:zone===void 0}}function mediaFiles(input,channels,usage=POST_USAGE){
71
+ const raws=repeatedValues(input,"--media");const files=raws.map(raw=>{const{file,size}=inspectLocalFile(raw,"--media",usage);const name=path.basename(file);return{file,name,size,contentType:snsContentType(name)}});for(const channel of channels){const violation=mediaViolation(channel,files);if(violation!==null)throw new UsageError(violation,usage)}return files}var VIDEO_EXTENSIONS={".mp4":"video/mp4",".mov":"video/quicktime"};function snsContentType(name){return VIDEO_EXTENSIONS[path.extname(name).
72
+ toLowerCase()]??contentTypeFor(name)}function mediaViolation(channel,files){const rule=MEDIA_RULES[channel];if(rule===void 0)return null;const label=channelName(channel);if(files.length===0){return rule.required?`${label} \u306B\u306F\u753B\u50CF\u304B\u52D5\u753B\u304C1\u4EF6\u4EE5\u4E0A\u5FC5\u8981\u3067\u3059\uFF08--media \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF09`:null}if(files.length>rule.maxItems)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u30E1\u30C7\u30A3\u30A2\u306F ${rule.
73
+ maxItems} \u4EF6\u307E\u3067\u3067\u3059\uFF08${files.length} \u4EF6\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\uFF09`;const videos=files.filter(f=>rule.videoTypes.includes(f.contentType)).length;if(!rule.mixed&&videos>0&&videos<files.length)return`${label} \u306E\u6295\u7A3F\u306B\u306F\u753B\u50CF\u3068\u52D5\u753B\u3092\u540C\u6642\u306B\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093`;if(videos>rule.maxVideos&&rule.maxVideos>0)return`${label} \u306E\u6295\u7A3F\u306B\u4ED8\u3051\u3089\u308C\u308B\u52D5\u753B\u306F ${rule.
74
+ maxVideos} \u672C\u307E\u3067\u3067\u3059`;for(const f of files){if(rule.imageTypes.includes(f.contentType)){const max=channel==="x"&&f.contentType==="image/gif"?X_MAX_GIF_BYTES:rule.maxImageBytes;if(f.size>max)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u753B\u50CF\u306F ${max/MB}MB \u307E\u3067\u3067\u3059: ${f.file}`}else if(rule.videoTypes.includes(f.contentType)){const max=rule.maxVideoBytes(files.length);if(f.size>max)return`${label} \u306B\u4ED8\u3051\u3089\u308C\u308B\u52D5\u753B\u306F ${max/
75
+ MB}MB \u307E\u3067\u3067\u3059${channel==="instagram"?files.length>=2?"\uFF08\u30AB\u30EB\u30FC\u30BB\u30EB\uFF09":"\uFF08\u30EA\u30FC\u30EB\uFF09":""}: ${f.file}`}else{return`${label} \u306B\u306F${rule.typesText}\u3060\u3051\u3092\u4ED8\u3051\u3089\u308C\u307E\u3059: ${f.file}`}}return null}function textViolation(channel,text){const limit=TEXT_LIMITS[channel];if(limit===void 0)return null;const count=charCount(text);if(count>limit)return`${channelName(channel)} \u306E\u672C\u6587\u306F ${limit}\
76
+ \u6587\u5B57\u307E\u3067\u3067\u3059\uFF08${count} \u6587\u5B57\uFF09`;if(channel==="instagram"){const tags=(text.replace(URL_PATTERN_ALL," ").match(/[##][^\s##。、,.!?「」()()]+/gu)??[]).length;if(tags>INSTAGRAM_MAX_HASHTAGS)return`Instagram \u306E\u30CF\u30C3\u30B7\u30E5\u30BF\u30B0\u306F ${INSTAGRAM_MAX_HASHTAGS} \u500B\u307E\u3067\u3067\u3059\uFF08${tags} \u500B\uFF09`}return null}async function readText(input,usage,required){const text=await readBody(input,{flag:"--text",
77
+ fileFlag:"--text-file",label:"\u672C\u6587",maxChars:BODY_MAX_CHARS,usage});if(required&&(text===void 0||text.trim()===""))throw new UsageError("\u672C\u6587\uFF08--text \u304B --text-file\uFF09\u304B\u753B\u50CF\uFF08--media\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usage);return text}async function readThread(input){const inline=repeatedValues(input,THREAD_FLAG.name);const files=repeatedValues(input,THREAD_FILE_FLAG.name);if(inline.length>0&&files.length>0){throw new UsageError(
78
+ "--thread \u3068 --thread-file \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\uFF08\u4EF6\u306E\u9806\u5E8F\u304C\u6C7A\u307E\u3089\u306A\u3044\u305F\u3081\uFF09",POST_USAGE)}const[flag,values]=inline.length>0?[THREAD_FLAG.name,inline]:[THREAD_FILE_FLAG.name,files];const parts=[];for(const[i,value]of values.entries()){if(flag===THREAD_FILE_FLAG.name&&value==="-"){throw new UsageError("--thread-file \u306B\u6A19\u6E96\u5165\u529B\uFF08-\uFF09\u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044",
79
+ POST_USAGE)}const flags=new Map([...input.flags].filter(([name])=>name!=="--text"&&name!=="--text-file"));flags.set(flag,value);const text=await readBody({args:[],flags},{flag:THREAD_FLAG.name,fileFlag:THREAD_FILE_FLAG.name,label:`\u30B9\u30EC\u30C3\u30C9\u306E${i+2}\u4EF6\u76EE`,maxChars:BODY_MAX_CHARS,usage:POST_USAGE});parts.push(text??"")}return parts}function postThread(input){const raw=input.resolved?.["thread"];return raw===void 0?[]:JSON.parse(raw)}function postQuote(input){return input.
80
+ resolved?.["quote"]??null}function partCredits(price,text,quoted=false){return quoted||URL_PATTERN.test(text)?price.postWithLink:price.post}function postTargets(input){return JSON.parse(requireResolved(input,"targets"))}function postText(input){return JSON.parse(requireResolved(input,"text"))}function draftPlan(input){const thread=postThread(input);const quote=postQuote(input);return{method:"POST",path:POSTS_PATH,body:{body:postText(input),targets:postTargets(input).map(t=>({channel:t.channel,connection_id:t.
81
+ connectionId,...thread.length>0?{thread_bodies:thread}:{},...quote!==null?{quote_tweet_id:quote}:{}}))}}}function postId(row){const id=str(row["id"]);if(id===null||!UUID.test(id))throw new ApiResponseError("SNS\u6295\u7A3F\u306E\u5FDC\u7B54\u306B id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return id}async function discardDraft(ctx,row){const channel=str(row["channel"])??"x";try{await ctx.send({method:"DELETE",path:`${POSTS_PATH}\
82
+ /${postId(row)}`,body:{expected_updated_at:row["updated_at"]??null}});ctx.warn(`\u4F5C\u6210\u9014\u4E2D\u306E\u4E0B\u66F8\u304D\uFF08${String(row["id"])}\uFF09\u3092\u524A\u9664\u3057\u307E\u3057\u305F\u3002`)}catch(error){ctx.warn(`\u4F5C\u6210\u9014\u4E2D\u306E\u4E0B\u66F8\u304D\uFF08${String(row["id"])}\uFF09\u3092\u524A\u9664\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08${error.message}\uFF09\u3002twp sns list --channel ${channel} --status draft \u3067\u78BA\u304B\u3081\u3001twp sns delete --channel ${channel}\
83
+ ${String(row["id"])} --yes \u3067\u6D88\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}}var postOperation={name:"post",summary:"SNS \u3078\u6295\u7A3F\u3059\u308B\u30FB\u4E88\u7D04\u3059\u308B\uFF08--yes \u304C\u5FC5\u8981\uFF09",usage:POST_USAGE,description:"\u26A0 \u5916\u90E8\u3078\u516C\u958B\u3059\u308B\u64CD\u4F5C\u3067\u3059\u3002--yes \u304C\u7121\u3051\u308C\u3070\u5B9F\u884C\u3057\u307E\u305B\u3093\u3002--dry-run \u3067\u6295\u7A3F\u5148\u30FB\u8CBB\u7528\u30FB\u672C\u6587\u3092\u78BA\u304B\u3081\u3066\u304B\u3089\n --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08--dry-run \u3067\u3082\u6599\u91D1\u306E\u78BA\u8A8D\u306E\u305F\u3081 GET \u30921\u672C\u9001\u308A\u307E\u3059\uFF09\u3002\n\u26A0 X \u3078\u306E\u6295\u7A3F\u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\u3002\u672C\u6587\u306B URL \u3092\u542B\u3080\u300C\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u300D\u306F\u5358\u4FA1\u304C\u5927\u304D\u304F\u4E0A\u304C\u308A\u307E\u3059\n \uFF08\u9001\u308B\u524D\u306B\u5358\u4FA1\u3092\u8868\u793A\u3057\u307E\u3059\uFF09\u3002LinkedIn\u30FBFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u3078\u306E\u6295\u7A3F\u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u305B\u3093\u3002\n\n--at \u3092\u4ED8\u3051\
84
+ \u308B\u3068\u4E88\u7D04\u3057\u307E\u3059\uFF08\u6307\u5B9A\u306E\u6642\u523B\u306B TWP \u304C\u6295\u7A3F\u3057\u307E\u3059\uFF09\u3002\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u3092\u4ED8\u3051\u306A\u3044\u65E5\u6642\u306F\u65E5\u672C\u6642\u9593\u3067\u3059\u3002\n\u4E88\u7D04\u306E\u53D6\u308A\u6D88\u3057\u306F twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status scheduled \u306E id \u3092 twp sns delete \u306B\u6E21\u3057\u307E\u3059\u3002\n--channel \u306F\u7E70\u308A\u8FD4\u3057\u3066\u8907\u6570\u306E\u30C1\u30E3\u30CD\u30EB\u3078\u540C\u3058\u672C\u6587\u30FB\u540C\u3058\u30E1\u30C7\u30A3\u30A2\u3092\u51FA\u305B\u307E\u3059\u3002\u7D50\u679C\u306F\u30C1\u30E3\u30CD\u30EB\u3054\u3068\u306B\u51FA\u3057\u307E\u3059\n\uFF081\u3064\u304C\u5931\u6557\u3057\u3066\u3082\u3001\u4ED6\u306E\u30C1\u30E3\u30CD\u30EB\u306E\u6295\u7A3F\u306F\u53D6\u308A\u6D88\u3057\u307E\u305B\u3093\uFF09\u3002\n--media\uFF08\u7E70\u308A\u8FD4\u3057\u6307\u5B9A\uFF09\u3067\u4ED8\u3051\u3089\u308C\u308B\u3082\u306E\uFF08\u6307\u5B9A\u3057\u305F\u5168\u30C1\u30E3\u30CD\u30EB\u306E\u6761\u4EF6\u3067\u9001\u308B\u524D\u306B\u78BA\u304B\u3081\u307E\u3059\uFF09:\n x \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBWEBP\u30FBGIF\uFF094\u679A\u307E\u3067\u3002\u52D5\u753B\u306F\u4E0D\u53EF\n linkedin \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBGIF\uFF0910\u679A\u307E\u3067\u3002\u52D5\u753B\u306F\u4E0D\u53EF\n facebook \u2026 \u753B\u50CF\uFF08JPEG\u30FBPNG\u30FBGIF\uFF0910\u679A\u307E\u3067 \u304B \u52D5\u753B\uFF08MP4\u30FBMOV\uFF091\u672C\u3002\u753B\u50CF\u3068\u52D5\u753B\u306F\u6DF7\u305C\u3089\u308C\u306A\u3044\n instagram \u2026 \u5FC5\u9808\u3002JPEG \u306E\u753B\u50CF\u30FBMP4/MOV \u306E\u52D5\u753B\u3092\u5408\u308F\u305B\u306610\u4EF6\u307E\u3067\uFF081\u4EF6\u306E\u52D5\u753B\u306F\u30EA\u30FC\u30EB\u30012\u4EF6\u4EE5\u4E0A\u306F\u30AB\u30EB\u30FC\u30BB\u30EB\uFF09\n\u672C\u6587\u306E\u4E0A\u9650\u306F\
85
+ X \u304C\u9023\u643A\u306E\u30D7\u30E9\u30F3\u3067 280 \u304B 25,000\uFF08\u65E5\u672C\u8A9E\u306F1\u5B572\uFF09\u3001LinkedIn 3,000\u3001Facebook\u30DA\u30FC\u30B8 63,206\u3001\nInstagram 2,200 \u6587\u5B57\uFF08\u30CF\u30C3\u30B7\u30E5\u30BF\u30B030\u500B\u307E\u3067\uFF09\u3067\u3059\u3002\nFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u306F\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u3002\n\n--thread / --thread-file \u3092\u4ED8\u3051\u308B\u3068 X \u306E\u30B9\u30EC\u30C3\u30C9\u306B\u3057\u307E\u3059\uFF08--text \u304C1\u4EF6\u76EE\u3001\u7D9A\u304D\u3092\u6307\u5B9A\u3057\u305F\u9806\u306B\u8FD4\u4FE1\u3068\u3057\u3066\u3064\u306A\u3052\u308B\uFF09\u3002\n 1\u4EF6\u76EE\u3092\u542B\u3081\u306625\u4EF6\u307E\u3067\u30FB\u5404\u4EF6 X \u306E\u4E0A\u9650\uFF08\u9023\u643A\u306E\u30D7\u30E9\u30F3\u3067 280 \u304B 25,000\u3002\u65E5\u672C\u8A9E\u306F1\u5B572\u3002\u7D9A\u304D\u306F2000\u5B57\u307E\u3067\uFF09\u307E\u3067\u30FB\u7D9A\u304D\u306E\u7A7A\u306F\u4E0D\u53EF\uFF08\u9001\u308B\u524D\u306B\u6B62\u3081\u307E\u3059\uFF09\u3002\n \u8CBB\u7528\u306F\u4EF6\u3054\u3068\u3067\u3001URL \u3092\u542B\u3080\u4EF6\u3060\u3051\u304C\u30EA\u30F3\u30AF\u4ED8\u304D\u306E\u5358\u4FA1\u3067\u3059\u3002URL \u30922\u4EF6\u76EE\u4EE5\u964D\u3078\u7F6E\u304F\u30681\u4EF6\u76EE\u306E\u5358\u4FA1\u306F\u901A\u5E38\u306E\u307E\u307E\u3067\u3059\u3002\n \u753B\u50CF\uFF08--media\uFF09\u306F1\u4EF6\u76EE\u306B\u3060\u3051\u4ED8\u304D\u307E\u3059\u3002\u30B9\u30EC\u30C3\u30C9\u306F X \u3060\u3051\u3067\u4F7F\u3048\u307E\u3059\u3002\n \u9014\u4E2D\u3067\u5931\u6557\u3059\u308B\u3068\u305D\u308C\u307E\u3067\u306E\u4EF6\u306F X \u306B\u51FA\u305F\u307E\u307E\u6B8B\u308A\u307E\u3059\uFF08\u518D\u9001\u306F\u3057\u307E\u305B\u3093\uFF09\u3002\u4F55\u4EF6\u76EE\u307E\u3067\u51FA\u305F\u304B\u3092\n twp sns list --channel x \
86
+ --status all \u3067\u78BA\u304B\u3081\u3066\u304B\u3089\u6253\u3061\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n\n--quote \u3092\u4ED8\u3051\u308B\u3068 X \u306E\u5F15\u7528\u6295\u7A3F\u306B\u3057\u307E\u3059\uFF08\u6570\u5B57\u306E\u6295\u7A3F ID \u304B https://x.com/<\u30E6\u30FC\u30B6\u30FC\u540D>/status/<ID>\uFF09\u3002\n \u5F15\u7528\u6295\u7A3F\u306F\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u306E\u5358\u4FA1\u3067\u3059\uFF08\u30B9\u30EC\u30C3\u30C9\u3067\u306F\u5F15\u7528\u306B\u306A\u308B1\u4EF6\u76EE\u3060\u3051\uFF09\u3002\u4E88\u7D04\u3067\u3082\u5F15\u7528\u5148\u3092\u4FDD\u3061\u307E\u3059\u3002\n \u5F15\u7528\u306F X \u3060\u3051\u3067\u4F7F\u3048\u307E\u3059\u3002X \u306E\u5951\u7D04\u306B\u3088\u3063\u3066\u306F\u5F15\u7528\u3092\u62D2\u5426\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u3001\u305D\u306E\u3068\u304D\u306F X \u306E\u7406\u7531\u3092\u8868\u793A\u3057\u3066\u6B62\u3081\u307E\u3059\u3002\n\n\u9806\u306B\u3001\u4E0B\u66F8\u304D\u306E\u4F5C\u6210 \u2192 \u753B\u50CF\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3068\u7D10\u3065\u3051 \u2192 \u6295\u7A3F\uFF08--at \u306A\u3089\u4E88\u7D04\uFF09\u3092\u9001\u308A\u307E\u3059\u3002\u9014\u4E2D\u3067\u6B62\u307E\u3063\u305F\u3089\n\u4F5C\u3063\u305F\u4E0B\u66F8\u304D\u3092\u6D88\u3057\u307E\u3059\u3002\u7D42\u4E86\u30B3\u30FC\u30C9 4\uFF08\u901A\u4FE1\u306E\u5931\u6557\uFF09\u3067\u3082 SNS \u5074\u3067\u306F\u6295\u7A3F\u6E08\u307F\u306E\u3053\u3068\u304C\u3042\u308B\u306E\u3067\u3001\u6253\u3061\u76F4\u3059\u524D\u306B\ntwp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status all \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002",
87
+ destructive:true,confirmation:"\u5916\u90E8\u306E SNS \u3078\u516C\u958B\u6295\u7A3F\u3059\u308B\u64CD\u4F5C\uFF08X \u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF09",flags:[CHANNELS_FLAG,ACCOUNT_FLAG,TEXT_FLAG,TEXT_FILE_FLAG,THREAD_FLAG,THREAD_FILE_FLAG,QUOTE_FLAG,{name:"--media",summary:"\u4ED8\u3051\u308B\u753B\u50CF\u30FB\u52D5\u753B\u306E\u30D1\u30B9\uFF08\u7E70\u308A\u8FD4\u3057\u6307\u5B9A\u30FBInstagram \u306F\u5FC5\u9808\u30FB\u30B9\u30EC\u30C3\u30C9\u3067\u306F1\u4EF6\u76EE\u306B\u3060\u3051\u4ED8\u304F\uFF09",
86
88
  takesValue:true,placeholder:"<\u30D1\u30B9>",repeatable:true},{name:"--at",summary:"\u4E88\u7D04\u3059\u308B\u65E5\u6642\uFF08YYYY-MM-DDTHH:MM \u306F\u65E5\u672C\u6642\u9593\uFF09",takesValue:true,placeholder:"<\u65E5\u6642>"}],async prepare(input,ctx){if(input.args.length>0)throw new UsageError(`\u4F4D\u7F6E\u5F15\u6570\u306F\u53D7\u3051\u4ED8\u3051\u307E\u305B\u3093: ${input.args.join(" ")}`,POST_USAGE);const threaded=repeatedValues(input,THREAD_FLAG.name).length+repeatedValues(input,THREAD_FILE_FLAG.
87
- name).length>0;if(threaded&&repeatedValues(input,"--channel").some(c=>c.trim().toLowerCase()!=="x")){throw new UsageError("\u30B9\u30EC\u30C3\u30C9\uFF08--thread / --thread-file\uFF09\u306F X \u306E\u6295\u7A3F\u3060\u3051\u3067\u4F7F\u3048\u307E\u3059",POST_USAGE)}const channels=manyChannels(input,POSTABLE_CHANNELS,POST_USAGE);const media=mediaFiles(input,channels);const text=await readText(input,POST_USAGE,media.length===0)??"";for(const channel of channels){const violation=textViolation(channel,
88
- text);if(violation!==null)throw new UsageError(`${violation}\u3002`,POST_USAGE)}const thread=await readThread(input);if(channels.includes("x")){const violation=xPartsViolation([text,...thread],X_LONG_POST_LIMIT);if(violation!==null)throw new UsageError(`${violation}\u3002`,POST_USAGE)}const rawAt=input.flags.get("--at");const at=rawAt===void 0?void 0:parseAt(rawAt);const targets=[];for(const channel of channels){const account=await resolveAccount(input,ctx,channel,POST_USAGE);let limit;if(channel===
89
- "x"){limit=xLimitOf(account);const violation=xPartsViolation([text,...thread],limit);if(violation!==null){throw new UsageError(`${violation}\u3002`,limit<X_LONG_POST_LIMIT?`${account["accountText"]} \u306E\u4E0A\u9650\u306F ${limit} \u3067\u3059\u3002X \u306E\u6709\u6599\u30D7\u30E9\u30F3\uFF08Basic\u30FBPremium\uFF09\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u306A\u3089\u9577\u6587\u6295\u7A3F\uFF08${X_LONG_POST_LIMIT}\uFF09\u307E\u3067\u51FA\u305B\u307E\u3059\u3002\u30D7\u30E9\u30F3\u3092\u5951\u7D04\u6E08\u307F\u306A\u3089 ${connectScreen(
90
- "x")}\u3067\u9023\u643A\u3057\u76F4\u3059\u3068\u4E0A\u9650\u304C\u8AAD\u307F\u76F4\u3055\u308C\u307E\u3059\u3002`:POST_USAGE)}}targets.push({channel,connectionId:account["connectionId"],accountText:account["accountText"],defaulted:account["accountDefaulted"],limit})}return withResolved(input,{text:JSON.stringify(text),...thread.length>0?{thread:JSON.stringify(thread)}:{},targets:JSON.stringify(targets),media:JSON.stringify(media),...at!==void 0?{at:at.iso,atAssumedJst:at.assumedJst?"1":"0"}:{}})},
91
- plan:draftPlan,plannedNotes(input){const targets=JSON.parse(requireResolved(input,"targets"));const media=JSON.parse(requireResolved(input,"media"));const at=input.resolved?.["at"];const text=postText(input);const notes=targets.map(t=>`\u6295\u7A3F\u5148: ${t.accountText}${t.defaulted==="1"?"\uFF08\u9023\u643A\u304C1\u4EF6\u306E\u305F\u3081\u81EA\u52D5\u3067\u9078\u3073\u307E\u3057\u305F\uFF09":""}`);const thread=postThread(input);const xLimit=targets.find(t=>t.channel==="x")?.limit;const images=media.
92
- length===0?"\u306A\u3057":media.map(m=>m.name).join("\u3001");if(thread.length===0){notes.push(xLimit===void 0?`\u672C\u6587: ${charCount(text)} \u6587\u5B57\u300C${oneLine(text)}\u300D / \u753B\u50CF: ${images}`:`\u672C\u6587: ${countX(text)}/${xLimit}\uFF08X \u306E\u6570\u3048\u65B9\u30FB\u65E5\u672C\u8A9E\u306F1\u5B572\uFF09\u300C${oneLine(text)}\u300D / \u753B\u50CF: ${images}`)}else{notes.push(`\u30B9\u30EC\u30C3\u30C9: ${thread.length+1} \u4EF6\uFF08\u6587\u5B57\u6570\u306F X \u306E\u6570\u3048\u65B9\u30FB\u4E0A\u9650 ${xLimit??
93
- X_TEXT_LIMIT}\uFF09 / \u753B\u50CF\uFF081\u4EF6\u76EE\uFF09: ${images}`);for(const[i,part]of[text,...thread].entries())notes.push(` ${i+1}\u4EF6\u76EE: ${countX(part)}/${xLimit??X_TEXT_LIMIT}\u300C${oneLine(part)}\u300D`)}notes.push(at===void 0?"\u3053\u306E\u3042\u3068: \u4E0B\u66F8\u304D\u3092\u4F5C\u308A"+(media.length>0?"\u3001\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u7D10\u3065\u3051":"")+"\u3001\u3059\u3050\u306B\u6295\u7A3F\u3057\u307E\u3059\uFF08POST .../publish\uFF09\u3002":
94
- `\u3053\u306E\u3042\u3068: \u4E0B\u66F8\u304D\u3092\u4F5C\u308A${media.length>0?"\u3001\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u7D10\u3065\u3051":""}\u3001${at} \u306B\u4E88\u7D04\u3057\u307E\u3059\uFF08POST .../schedule\uFF09${input.resolved?.["atAssumedJst"]==="1"?"\u3002\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u306E\u7121\u3044 --at \u306F\u65E5\u672C\u6642\u9593\u3068\u3057\u3066\u6271\u3044\u307E\u3057\u305F":""}\u3002`);return notes},async preview(input,ctx){const count=postTargets(
95
- input).filter(t=>t.channel==="x").length;if(count===0)return{notes:[],warnings:[]};const price=await xPricing(ctx);const text=postText(input);const withLink=URL_PATTERN.test(text);const thread=postThread(input);if(thread.length>0){const parts=[text,...thread];const each=parts.map(part=>partCredits(price,part));const total=each.reduce((sum,v)=>sum+v,0)*count;const notes2=[`X \u3078\u306E\u30B9\u30EC\u30C3\u30C9\u6295\u7A3F\uFF08${parts.length} \u4EF6${count>1?`\u30FB\u6295\u7A3F\u5148 ${count} \u4EF6`:
96
- ""}\uFF09\u3067\u5408\u8A08 ${credits(total)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\u3002`,...parts.map((part,i)=>` ${i+1}\u4EF6\u76EE: ${credits(each[i])}${URL_PATTERN.test(part)?"\uFF08\u26A0 URL \u304C\u3042\u308B\u305F\u3081\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u306E\u5358\u4FA1\uFF09":""}`)];if(URL_PATTERN.test(text))notes2.push("\u26A0 1\u4EF6\u76EE\u306B URL \u304C\u3042\u308A\u307E\u3059\u3002URL \u30922\u4EF6\u76EE\u4EE5\u964D\u3078\u79FB\u3059\u30681\u4EF6\u76EE\u306F\u901A\u5E38\u306E\u5358\u4FA1\u306B\u306A\u308A\u307E\u3059\u3002");
97
- return{notes:notes2,warnings:[]}}const notes=[withLink?`\u26A0 \u672C\u6587\u306B URL \u304C\u3042\u308B\u305F\u3081\u300C\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u300D\u3068\u3057\u3066 ${credits(price.postWithLink*count)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF08\u30EA\u30F3\u30AF\u7121\u3057\u306A\u3089 ${credits(price.post*count)}\uFF09\u3002`:`X \u3078\u306E\u6295\u7A3F\u3067 ${credits(price.post*count)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF08\u672C\u6587\u306B URL \u3092\u5165\u308C\u308B\u3068 ${credits(
98
- price.postWithLink*count)}\uFF09\u3002`];return{notes,warnings:[]}},async execute(input,ctx){const created=items(await ctx.send(draftPlan(input)),"SNS\u6295\u7A3F\u306E\u4F5C\u6210");if(created.length!==postTargets(input).length){for(const row of created)await discardDraft(ctx,row);throw new ApiResponseError("SNS\u6295\u7A3F\u306E\u4F5C\u6210\u306E\u5FDC\u7B54\u306E\u4EF6\u6570\u304C\u6295\u7A3F\u5148\u306E\u6570\u3068\u5408\u3044\u307E\u305B\u3093\u3002twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status draft \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002")}
99
- const latest=new Map(created.map(row=>[postId(row),row]));let rows=created;const at=input.resolved?.["at"];try{const media=JSON.parse(requireResolved(input,"media"));if(media.length>0){const ids=[];for(const m of media){const{id,uploadUrl}=issued(await ctx.send({method:"POST",path:"/api/v2/sns/media/upload-url",body:{file_name:m.name,content_type:m.contentType,file_size:m.size}}));const bytes=new Uint8Array(fs.readFileSync(m.file));if(bytes.byteLength!==m.size)throw new UsageError(`\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D\u306B\u30D5\u30A1\u30A4\u30EB\u306E\
100
- \u5927\u304D\u3055\u304C\u5909\u308F\u308A\u307E\u3057\u305F\uFF08${m.size} \u2192 ${bytes.byteLength} \u30D0\u30A4\u30C8\uFF09: ${m.file}`);await ctx.putSigned(uploadUrl,bytes,m.contentType);ids.push(id)}rows=[];for(const row of created){const updated=dataRecord(await ctx.send({method:"PUT",path:`${POSTS_PATH}/${postId(row)}/media`,body:{attachment_ids:ids,expected_updated_at:row["updated_at"]??null}}),"\u753B\u50CF\u306E\u7D10\u3065\u3051");const next={...row,updated_at:updated["updated_at"]??
101
- row["updated_at"]};latest.set(postId(row),next);rows.push(next)}}}catch(error){for(const row of latest.values())await discardDraft(ctx,row);throw error}const results=[];for(const row of rows){const id=postId(row);try{const sent=dataRecord(await ctx.send(at===void 0?{method:"POST",path:`${POSTS_PATH}/${id}/publish`,body:{expected_updated_at:row["updated_at"]??null}}:{method:"POST",path:`${POSTS_PATH}/${id}/schedule`,body:{scheduled_at:at,expected_updated_at:row["updated_at"]??null}}),at===void 0?
102
- "\u6295\u7A3F":"\u4E88\u7D04");results.push(sent)}catch(error){const rejected=error instanceof ApiError&&error.status>=400&&error.status<500;if(rejected)await discardDraft(ctx,row);const failed={...row,status:"error",failure_reason:error.message,unsent:rejected};Object.defineProperty(failed,ERROR_KEY,{value:error,enumerable:false});results.push(failed)}}return{items:results,scheduled:at!==void 0,thread:postThread(input).length>0}},summarize:body=>items(body,"SNS\u6295\u7A3F").map(row=>postRow(row)),
103
- raw:body=>items(body,"SNS\u6295\u7A3F"),failures(body){return items(body,"SNS\u6295\u7A3F").filter(row=>row["status"]==="failed"||row["status"]==="error").map(row=>({target:`${channelName(String(row["channel"]??""))}\uFF08${String(row["id"]??"")}\uFF09`,error:row[ERROR_KEY]??new ApiRejectedError(`\u6295\u7A3F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${String(row["failure_reason"]??"\u7406\u7531\u4E0D\u660E")}`)}))},notes(body){const rows=items(body,"SNS\u6295\u7A3F");const notes=[];const multi=rows.
104
- length>1;for(const row of rows){const status=row["status"];const channel=str(row["channel"])??"x";const label=channelName(channel);const head=multi?`${label}: `:"";if(status==="published")notes.push(`${head}\u6295\u7A3F\u3057\u307E\u3057\u305F: ${String(row["external_post_url"]??row["external_post_id"]??"")}`);else if(status==="scheduled"&&isRecord(body)&&body["scheduled"]===true)notes.push(`${head}${String(row["scheduled_at"])} \u306B\u4E88\u7D04\u3057\u307E\u3057\u305F\uFF08id: ${String(row["i\
105
- d"])}\uFF09\u3002`);else if(status==="scheduled"){notes.push(`\u26A0 ${head}\u4E00\u6642\u7684\u306A\u5931\u6557\u306E\u305F\u3081\u3001TWP \u304C ${String(row["scheduled_at"])} \u306B\u9001\u308A\u76F4\u3057\u307E\u3059\uFF08id: ${String(row["id"])}\uFF09\u3002twp sns list --channel ${channel} --status scheduled \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`)}else if(status==="failed"||status==="error"&&row["unsent"]===true){if(multi)notes.push(`\u26A0 ${head}\u6295\u7A3F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${String(
106
- row["failure_reason"]??"\u7406\u7531\u4E0D\u660E")}`)}else if(status==="error"){notes.push(isRecord(body)&&body["scheduled"]===true?`\u26A0 ${head}\u4E88\u7D04\u306E\u9001\u4FE1\u3067\u6B62\u307E\u308A\u307E\u3057\u305F\uFF08id: ${String(row["id"])}\uFF09\u3002\u4E88\u7D04\u304C\u6210\u7ACB\u3057\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u6253\u3061\u76F4\u3059\u524D\u306B twp sns list --channel ${channel} --status scheduled \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`:
107
- `\u26A0 ${head}\u6295\u7A3F\u306E\u9001\u4FE1\u3067\u6B62\u307E\u308A\u307E\u3057\u305F\uFF08id: ${String(row["id"])}\uFF09\u3002${label} \u5074\u3067\u6295\u7A3F\u3055\u308C\u3066\u3044\u306A\u3044\u304B twp sns list --channel ${channel}${channel==="linkedin"?" --status all":""} \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`)}const maybePartial=status==="failed"||status==="error"&&row["unsent"]!==true;if(maybePartial&&isRecord(body)&&body["thread"]===true&&body["scheduled"]!==true){
108
- notes.push(`\u26A0 \u30B9\u30EC\u30C3\u30C9\u304C\u9014\u4E2D\u3067\u6B62\u307E\u3063\u305F\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\uFF08id: ${String(row["id"])}\uFF09\u3002\u4F55\u4EF6\u76EE\u307E\u3067 X \u306B\u51FA\u305F\u304B\u3092 twp sns list --channel x --status all\uFF08TWP \u306E\u8A18\u9332\uFF09\u3068 twp sns list --channel x\uFF08X \u4E0A\u306E\u6295\u7A3F\uFF09\u3067\u78BA\u304B\u3081\u3066\u304B\u3089\u6253\u3061\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u305D\u306E\u307E\u307E\u6253\u3061\u76F4\u3059\u3068\u3001\u51FA\u305F\u5206\u304C\u4E8C\u91CD\u306B\u6295\u7A3F\u3055\u308C\u307E\u3059\uFF09\u3002`)}}
109
- return notes}};var DELETE_USAGE="twp sns delete --channel <x|linkedin|facebook|instagram> <ID> [--account <ID|@\u540D\u524D>] --yes";var FACEBOOK_POST_ID=/^[0-9]{1,30}(_[0-9]{1,30})?$/;var INSTAGRAM_MEDIA_ID=/^[0-9]{1,30}$/;var EXTERNAL_ID={x:TWEET_ID,facebook:FACEBOOK_POST_ID,instagram:INSTAGRAM_MEDIA_ID};function externalDeletePath(input){const connection=segment(requireResolved(input,"connectionId"),"\u9023\u643AID");const id=segment(requireResolved(input,"id"),"\u6295\u7A3FID");switch(requireResolved(
110
- input,"kind")){case"facebook":return`${FACEBOOK_PATH}/connections/${connection}/posts/${id}`;case"instagram":return`${INSTAGRAM_PATH}/connections/${connection}/media/${id}`;default:return`${X_PATH}/connections/${connection}/tweets/${id}`}}var deleteOperation={name:"delete",summary:"SNS \u4E0A\u306E\u6295\u7A3F\u304B\u3001TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\u3092\u524A\u9664\u3059\u308B\uFF08--yes \u304C\u5FC5\u8981\uFF09",usage:DELETE_USAGE,description:"ID \u306E\u5F62\u3067\u6D88\u3059\u3082\u306E\u304C\u5909\u308F\u308A\u307E\u3059\u3002\n SNS \u4E0A\u306E\u6295\u7A3F\u306E I\
111
- D\uFF08twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> \u306E id\uFF09\u2026 SNS \u4E0A\u306E\u6295\u7A3F\u3092\u524A\u9664\u3057\u307E\u3059\uFF08\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\uFF09\n x \u306F\u6570\u5B57\uFF08\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\uFF09\u3001facebook \u306F\u300C\u30DA\u30FC\u30B8ID_\u6295\u7A3FID\u300D\u304B\u6570\u5B57\u3001instagram \u306F\u6570\u5B57\u3067\u3059\u3002\n UUID\uFF08twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status \u2026 \u306E id\uFF09\u2026 TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\u30FB\u5931\u6557\u3057\u305F\u6295\u7A3F\u3092\u524A\u9664\u3057\u307E\u3059\uFF08\u4E88\u7D04\u306E\u53D6\u308A\u6D88\u3057\uFF09\nLinkedIn \u306F SNS \u4E0A\u306E ID \u3092\u4F7F\u308F\u305A\u3001TWP \u306E\u6295\u7A3FID\uFF08UUID\uFF09\u3067\u6D88\u3057\u307E\u3059\u3002\u6295\u7A3F\u6E08\u307F\u306A\u3089 LinkedIn \u4E0A\u306E\u6295\u7A3F\u3068 TWP \u306E\u8A18\u9332\u306E\u4E21\u65B9\u3092\u6D88\u3057\u307E\u3059\n\uFF08TWP \u304B\u3089\u6295\u7A3F\u3057\u305F\u81EA\u5206\u306E\u6295\u7A3F\u3060\u3051\uFF09\u3002\nX\u30FBFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u3067 TWP \u304B\u3089\u6295\u7A3F\u6E08\u307F\u306E\u8A18\u9332\uFF08status=published\uFF09\u306F TWP \u5074\u3067\u306F\u6D88\u305B\u307E\u305B\u3093\u3002SNS \u4E0A\u306E\u6295\u7A3F\n\uFF08external_post_id\uFF09\u3092\u6D88\u3057\u3066\u304F\u3060\u3055\u3044\uFF08TWP \u306E\u8A18\u9332\u3082\u4E00\u7DD2\u306B\u5916\u308C\u307E\u3059\uFF09\u3002\nFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u306F\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u3002",
89
+ name).length>0;if(threaded&&repeatedValues(input,"--channel").some(c=>c.trim().toLowerCase()!=="x")){throw new UsageError("\u30B9\u30EC\u30C3\u30C9\uFF08--thread / --thread-file\uFF09\u306F X \u306E\u6295\u7A3F\u3060\u3051\u3067\u4F7F\u3048\u307E\u3059",POST_USAGE)}const rawQuote=input.flags.get(QUOTE_FLAG.name);let quote=null;if(rawQuote!==void 0){if(repeatedValues(input,"--channel").some(c=>c.trim().toLowerCase()!=="x")){throw new UsageError("\u5F15\u7528\uFF08--quote\uFF09\u306F X \u306E\u6295\u7A3F\u3060\u3051\u3067\u4F7F\u3048\u307E\u3059",
90
+ POST_USAGE)}quote=tweetIdOf(rawQuote);if(quote===null){throw new UsageError(`--quote \u306B\u306F X \u306E\u6295\u7A3F ID\uFF08\u6570\u5B57\uFF09\u304B\u6295\u7A3F URL\uFF08https://x.com/<\u30E6\u30FC\u30B6\u30FC\u540D>/status/<ID>\uFF09\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${oneLine(rawQuote)}\uFF09`,POST_USAGE)}}const channels=manyChannels(input,POSTABLE_CHANNELS,POST_USAGE);const media=mediaFiles(input,channels);const text=await readText(input,
91
+ POST_USAGE,media.length===0)??"";for(const channel of channels){const violation=textViolation(channel,text);if(violation!==null)throw new UsageError(`${violation}\u3002`,POST_USAGE)}const thread=await readThread(input);if(channels.includes("x")){const violation=xPartsViolation([text,...thread],X_LONG_POST_LIMIT);if(violation!==null)throw new UsageError(`${violation}\u3002`,POST_USAGE)}const rawAt=input.flags.get("--at");const at=rawAt===void 0?void 0:parseAt(rawAt);const targets=[];for(const channel of channels){
92
+ const account=await resolveAccount(input,ctx,channel,POST_USAGE);let limit;if(channel==="x"){limit=xLimitOf(account);const violation=xPartsViolation([text,...thread],limit);if(violation!==null){throw new UsageError(`${violation}\u3002`,limit<X_LONG_POST_LIMIT?`${account["accountText"]} \u306E\u4E0A\u9650\u306F ${limit} \u3067\u3059\u3002X \u306E\u6709\u6599\u30D7\u30E9\u30F3\uFF08Basic\u30FBPremium\uFF09\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u306A\u3089\u9577\u6587\u6295\u7A3F\uFF08${X_LONG_POST_LIMIT}\
93
+ \uFF09\u307E\u3067\u51FA\u305B\u307E\u3059\u3002\u30D7\u30E9\u30F3\u3092\u5951\u7D04\u6E08\u307F\u306A\u3089 ${connectScreen("x")}\u3067\u9023\u643A\u3057\u76F4\u3059\u3068\u4E0A\u9650\u304C\u8AAD\u307F\u76F4\u3055\u308C\u307E\u3059\u3002`:POST_USAGE)}}targets.push({channel,connectionId:account["connectionId"],accountText:account["accountText"],defaulted:account["accountDefaulted"],limit})}return withResolved(input,{text:JSON.stringify(text),...thread.length>0?{thread:JSON.stringify(thread)}:{},
94
+ ...quote!==null?{quote}:{},targets:JSON.stringify(targets),media:JSON.stringify(media),...at!==void 0?{at:at.iso,atAssumedJst:at.assumedJst?"1":"0"}:{}})},plan:draftPlan,plannedNotes(input){const targets=JSON.parse(requireResolved(input,"targets"));const media=JSON.parse(requireResolved(input,"media"));const at=input.resolved?.["at"];const text=postText(input);const notes=targets.map(t=>`\u6295\u7A3F\u5148: ${t.accountText}${t.defaulted==="1"?"\uFF08\u9023\u643A\u304C1\u4EF6\u306E\u305F\u3081\u81EA\u52D5\u3067\u9078\u3073\u307E\u3057\u305F\uFF09":
95
+ ""}`);const thread=postThread(input);const xLimit=targets.find(t=>t.channel==="x")?.limit;const images=media.length===0?"\u306A\u3057":media.map(m=>m.name).join("\u3001");if(thread.length===0){notes.push(xLimit===void 0?`\u672C\u6587: ${charCount(text)} \u6587\u5B57\u300C${oneLine(text)}\u300D / \u753B\u50CF: ${images}`:`\u672C\u6587: ${countX(text)}/${xLimit}\uFF08X \u306E\u6570\u3048\u65B9\u30FB\u65E5\u672C\u8A9E\u306F1\u5B572\uFF09\u300C${oneLine(text)}\u300D / \u753B\u50CF: ${images}`)}else{
96
+ notes.push(`\u30B9\u30EC\u30C3\u30C9: ${thread.length+1} \u4EF6\uFF08\u6587\u5B57\u6570\u306F X \u306E\u6570\u3048\u65B9\u30FB\u4E0A\u9650 ${xLimit??X_TEXT_LIMIT}\uFF09 / \u753B\u50CF\uFF081\u4EF6\u76EE\uFF09: ${images}`);for(const[i,part]of[text,...thread].entries())notes.push(` ${i+1}\u4EF6\u76EE: ${countX(part)}/${xLimit??X_TEXT_LIMIT}\u300C${oneLine(part)}\u300D`)}const quote=postQuote(input);if(quote!==null)notes.push(`\u5F15\u7528\u3059\u308B\u6295\u7A3F: https://x.com/i/web/status/${quote}${thread.
97
+ length>0?"\uFF081\u4EF6\u76EE\u304C\u5F15\u7528\u306B\u306A\u308A\u307E\u3059\uFF09":""}`);notes.push(at===void 0?"\u3053\u306E\u3042\u3068: \u4E0B\u66F8\u304D\u3092\u4F5C\u308A"+(media.length>0?"\u3001\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u7D10\u3065\u3051":"")+"\u3001\u3059\u3050\u306B\u6295\u7A3F\u3057\u307E\u3059\uFF08POST .../publish\uFF09\u3002":`\u3053\u306E\u3042\u3068: \u4E0B\u66F8\u304D\u3092\u4F5C\u308A${media.length>0?"\u3001\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u7D10\u3065\u3051":
98
+ ""}\u3001${at} \u306B\u4E88\u7D04\u3057\u307E\u3059\uFF08POST .../schedule\uFF09${input.resolved?.["atAssumedJst"]==="1"?"\u3002\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\u306E\u7121\u3044 --at \u306F\u65E5\u672C\u6642\u9593\u3068\u3057\u3066\u6271\u3044\u307E\u3057\u305F":""}\u3002`);return notes},async preview(input,ctx){const count=postTargets(input).filter(t=>t.channel==="x").length;if(count===0)return{notes:[],warnings:[]};const price=await xPricing(ctx);const text=postText(input);const quoted=postQuote(
99
+ input)!==null;const withLink=URL_PATTERN.test(text);const thread=postThread(input);if(thread.length>0){const parts=[text,...thread];const each=parts.map((part,i)=>partCredits(price,part,quoted&&i===0));const total=each.reduce((sum,v)=>sum+v,0)*count;const notes2=[`X \u3078\u306E\u30B9\u30EC\u30C3\u30C9\u6295\u7A3F\uFF08${parts.length} \u4EF6${count>1?`\u30FB\u6295\u7A3F\u5148 ${count} \u4EF6`:""}\uFF09\u3067\u5408\u8A08 ${credits(total)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\u3002`,...parts.map((part,i)=>`\
100
+ ${i+1}\u4EF6\u76EE: ${credits(each[i])}${quoted&&i===0?"\uFF08\u26A0 \u5F15\u7528\u6295\u7A3F\u306E\u305F\u3081\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u306E\u5358\u4FA1\uFF09":URL_PATTERN.test(part)?"\uFF08\u26A0 URL \u304C\u3042\u308B\u305F\u3081\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u306E\u5358\u4FA1\uFF09":""}`)];if(URL_PATTERN.test(text)&&!quoted)notes2.push("\u26A0 1\u4EF6\u76EE\u306B URL \u304C\u3042\u308A\u307E\u3059\u3002URL \u30922\u4EF6\u76EE\u4EE5\u964D\u3078\u79FB\u3059\u30681\u4EF6\u76EE\u306F\u901A\u5E38\u306E\u5358\u4FA1\u306B\u306A\u308A\u307E\u3059\u3002");
101
+ return{notes:notes2,warnings:[]}}if(quoted){return{notes:[`\u26A0 \u5F15\u7528\u6295\u7A3F\u306F\u300C\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u300D\u306E\u5358\u4FA1\u3067 ${credits(price.postWithLink*count)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF08\u5F15\u7528\u3057\u306A\u3044\u901A\u5E38\u306E\u6295\u7A3F\u306A\u3089 ${credits(price.post*count)}\uFF09\u3002`],warnings:[]}}const notes=[withLink?`\u26A0 \u672C\u6587\u306B URL \u304C\u3042\u308B\u305F\u3081\u300C\u30EA\u30F3\u30AF\u4ED8\u304D\u6295\u7A3F\u300D\u3068\u3057\u3066 ${credits(
102
+ price.postWithLink*count)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF08\u30EA\u30F3\u30AF\u7121\u3057\u306A\u3089 ${credits(price.post*count)}\uFF09\u3002`:`X \u3078\u306E\u6295\u7A3F\u3067 ${credits(price.post*count)} \u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF08\u672C\u6587\u306B URL \u3092\u5165\u308C\u308B\u3068 ${credits(price.postWithLink*count)}\uFF09\u3002`];return{notes,warnings:[]}},async execute(input,ctx){const created=items(await ctx.send(draftPlan(input)),"SNS\u6295\u7A3F\u306E\u4F5C\u6210");
103
+ if(created.length!==postTargets(input).length){for(const row of created)await discardDraft(ctx,row);throw new ApiResponseError("SNS\u6295\u7A3F\u306E\u4F5C\u6210\u306E\u5FDC\u7B54\u306E\u4EF6\u6570\u304C\u6295\u7A3F\u5148\u306E\u6570\u3068\u5408\u3044\u307E\u305B\u3093\u3002twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status draft \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002")}const quote=postQuote(input);if(quote!==null&&created.some(row=>row["quote_tweet_id"]!==quote)){for(const row of created)
104
+ await discardDraft(ctx,row);throw new ApiResponseError("\u63A5\u7D9A\u5148\u306E\u30B5\u30FC\u30D0\u304C\u5F15\u7528\u6295\u7A3F\uFF08--quote\uFF09\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u6295\u7A3F\u305B\u305A\u306B\u6B62\u3081\u307E\u3057\u305F\u3002")}const latest=new Map(created.map(row=>[postId(row),row]));let rows=created;const at=input.resolved?.["at"];try{const media=JSON.parse(requireResolved(input,"media"));if(media.length>0){const ids=[];for(const m of media){
105
+ const{id,uploadUrl}=issued(await ctx.send({method:"POST",path:"/api/v2/sns/media/upload-url",body:{file_name:m.name,content_type:m.contentType,file_size:m.size}}));const bytes=new Uint8Array(fs.readFileSync(m.file));if(bytes.byteLength!==m.size)throw new UsageError(`\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D\u306B\u30D5\u30A1\u30A4\u30EB\u306E\u5927\u304D\u3055\u304C\u5909\u308F\u308A\u307E\u3057\u305F\uFF08${m.size} \u2192 ${bytes.byteLength} \u30D0\u30A4\u30C8\uFF09: ${m.file}`);await ctx.putSigned(
106
+ uploadUrl,bytes,m.contentType);ids.push(id)}rows=[];for(const row of created){const updated=dataRecord(await ctx.send({method:"PUT",path:`${POSTS_PATH}/${postId(row)}/media`,body:{attachment_ids:ids,expected_updated_at:row["updated_at"]??null}}),"\u753B\u50CF\u306E\u7D10\u3065\u3051");const next={...row,updated_at:updated["updated_at"]??row["updated_at"]};latest.set(postId(row),next);rows.push(next)}}}catch(error){for(const row of latest.values())await discardDraft(ctx,row);throw error}const results=[];
107
+ for(const row of rows){const id=postId(row);try{const sent=dataRecord(await ctx.send(at===void 0?{method:"POST",path:`${POSTS_PATH}/${id}/publish`,body:{expected_updated_at:row["updated_at"]??null}}:{method:"POST",path:`${POSTS_PATH}/${id}/schedule`,body:{scheduled_at:at,expected_updated_at:row["updated_at"]??null}}),at===void 0?"\u6295\u7A3F":"\u4E88\u7D04");results.push(sent)}catch(error){const rejected=error instanceof ApiError&&error.status>=400&&error.status<500;if(rejected)await discardDraft(
108
+ ctx,row);const failed={...row,status:"error",failure_reason:error.message,unsent:rejected};Object.defineProperty(failed,ERROR_KEY,{value:error,enumerable:false});results.push(failed)}}return{items:results,scheduled:at!==void 0,thread:postThread(input).length>0}},summarize:body=>items(body,"SNS\u6295\u7A3F").map(row=>postRow(row)),raw:body=>items(body,"SNS\u6295\u7A3F"),failures(body){return items(body,"SNS\u6295\u7A3F").filter(row=>row["status"]==="failed"||row["status"]==="error").map(row=>({target:`${channelName(
109
+ String(row["channel"]??""))}\uFF08${String(row["id"]??"")}\uFF09`,error:row[ERROR_KEY]??new ApiRejectedError(`\u6295\u7A3F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${String(row["failure_reason"]??"\u7406\u7531\u4E0D\u660E")}`)}))},notes(body){const rows=items(body,"SNS\u6295\u7A3F");const notes=[];const multi=rows.length>1;for(const row of rows){const status=row["status"];const channel=str(row["channel"])??"x";const label=channelName(channel);const head=multi?`${label}: `:"";if(status===
110
+ "published")notes.push(`${head}\u6295\u7A3F\u3057\u307E\u3057\u305F: ${String(row["external_post_url"]??row["external_post_id"]??"")}`);else if(status==="scheduled"&&isRecord(body)&&body["scheduled"]===true)notes.push(`${head}${String(row["scheduled_at"])} \u306B\u4E88\u7D04\u3057\u307E\u3057\u305F\uFF08id: ${String(row["id"])}\uFF09\u3002`);else if(status==="scheduled"){notes.push(`\u26A0 ${head}\u4E00\u6642\u7684\u306A\u5931\u6557\u306E\u305F\u3081\u3001TWP \u304C ${String(row["scheduled_at"])}\
111
+ \u306B\u9001\u308A\u76F4\u3057\u307E\u3059\uFF08id: ${String(row["id"])}\uFF09\u3002twp sns list --channel ${channel} --status scheduled \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`)}else if(status==="failed"||status==="error"&&row["unsent"]===true){if(multi)notes.push(`\u26A0 ${head}\u6295\u7A3F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${String(row["failure_reason"]??"\u7406\u7531\u4E0D\u660E")}`)}else if(status==="error"){notes.push(isRecord(body)&&body["scheduled"]===
112
+ true?`\u26A0 ${head}\u4E88\u7D04\u306E\u9001\u4FE1\u3067\u6B62\u307E\u308A\u307E\u3057\u305F\uFF08id: ${String(row["id"])}\uFF09\u3002\u4E88\u7D04\u304C\u6210\u7ACB\u3057\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u6253\u3061\u76F4\u3059\u524D\u306B twp sns list --channel ${channel} --status scheduled \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`:`\u26A0 ${head}\u6295\u7A3F\u306E\u9001\u4FE1\u3067\u6B62\u307E\u308A\u307E\u3057\u305F\uFF08id: ${String(
113
+ row["id"])}\uFF09\u3002${label} \u5074\u3067\u6295\u7A3F\u3055\u308C\u3066\u3044\u306A\u3044\u304B twp sns list --channel ${channel}${channel==="linkedin"?" --status all":""} \u3067\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\u3002`)}const maybePartial=status==="failed"||status==="error"&&row["unsent"]!==true;if(maybePartial&&isRecord(body)&&body["thread"]===true&&body["scheduled"]!==true){notes.push(`\u26A0 \u30B9\u30EC\u30C3\u30C9\u304C\u9014\u4E2D\u3067\u6B62\u307E\u3063\u305F\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\uFF08id: ${String(
114
+ row["id"])}\uFF09\u3002\u4F55\u4EF6\u76EE\u307E\u3067 X \u306B\u51FA\u305F\u304B\u3092 twp sns list --channel x --status all\uFF08TWP \u306E\u8A18\u9332\uFF09\u3068 twp sns list --channel x\uFF08X \u4E0A\u306E\u6295\u7A3F\uFF09\u3067\u78BA\u304B\u3081\u3066\u304B\u3089\u6253\u3061\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u305D\u306E\u307E\u307E\u6253\u3061\u76F4\u3059\u3068\u3001\u51FA\u305F\u5206\u304C\u4E8C\u91CD\u306B\u6295\u7A3F\u3055\u308C\u307E\u3059\uFF09\u3002`)}}return notes}};var DELETE_USAGE="\
115
+ twp sns delete --channel <x|linkedin|facebook|instagram> <ID> [--account <ID|@\u540D\u524D>] --yes";var FACEBOOK_POST_ID=/^[0-9]{1,30}(_[0-9]{1,30})?$/;var INSTAGRAM_MEDIA_ID=/^[0-9]{1,30}$/;var EXTERNAL_ID={x:TWEET_ID,facebook:FACEBOOK_POST_ID,instagram:INSTAGRAM_MEDIA_ID};function externalDeletePath(input){const connection=segment(requireResolved(input,"connectionId"),"\u9023\u643AID");const id=segment(requireResolved(input,"id"),"\u6295\u7A3FID");switch(requireResolved(input,"kind")){case"fac\
116
+ ebook":return`${FACEBOOK_PATH}/connections/${connection}/posts/${id}`;case"instagram":return`${INSTAGRAM_PATH}/connections/${connection}/media/${id}`;default:return`${X_PATH}/connections/${connection}/tweets/${id}`}}var deleteOperation={name:"delete",summary:"SNS \u4E0A\u306E\u6295\u7A3F\u304B\u3001TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\u3092\u524A\u9664\u3059\u308B\uFF08--yes \u304C\u5FC5\u8981\uFF09",usage:DELETE_USAGE,description:"ID \u306E\u5F62\u3067\u6D88\u3059\u3082\u306E\u304C\u5909\u308F\u308A\u307E\u3059\u3002\n SNS \u4E0A\u306E\u6295\u7A3F\u306E ID\uFF08twp sns list --channe\
117
+ l <\u30C1\u30E3\u30CD\u30EB> \u306E id\uFF09\u2026 SNS \u4E0A\u306E\u6295\u7A3F\u3092\u524A\u9664\u3057\u307E\u3059\uFF08\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\uFF09\n x \u306F\u6570\u5B57\uFF08\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\uFF09\u3001facebook \u306F\u300C\u30DA\u30FC\u30B8ID_\u6295\u7A3FID\u300D\u304B\u6570\u5B57\u3001instagram \u306F\u6570\u5B57\u3067\u3059\u3002\n UUID\uFF08twp sns list --channel <\u30C1\u30E3\u30CD\u30EB> --status \u2026 \u306E id\uFF09\u2026 TWP \u306E\u4E0B\u66F8\u304D\u30FB\u4E88\u7D04\u30FB\u5931\u6557\u3057\u305F\u6295\u7A3F\u3092\u524A\u9664\u3057\u307E\u3059\uFF08\u4E88\u7D04\u306E\u53D6\u308A\u6D88\u3057\uFF09\nLinkedIn \u306F SNS \u4E0A\u306E ID \u3092\u4F7F\u308F\u305A\u3001TWP \u306E\u6295\u7A3FID\uFF08UUID\uFF09\u3067\u6D88\u3057\u307E\u3059\u3002\u6295\u7A3F\u6E08\u307F\u306A\u3089 LinkedIn \u4E0A\u306E\u6295\u7A3F\u3068 TWP \u306E\u8A18\u9332\u306E\u4E21\u65B9\u3092\u6D88\u3057\u307E\u3059\n\uFF08TWP \u304B\u3089\u6295\u7A3F\u3057\u305F\u81EA\u5206\u306E\u6295\u7A3F\u3060\u3051\uFF09\u3002\nX\u30FBFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u3067 TWP \u304B\u3089\u6295\u7A3F\u6E08\u307F\u306E\u8A18\u9332\uFF08status=published\uFF09\u306F TWP \u5074\u3067\u306F\u6D88\u305B\u307E\u305B\u3093\u3002SNS \u4E0A\u306E\u6295\u7A3F\n\uFF08external_post_id\uFF09\u3092\u6D88\u3057\u3066\u304F\u3060\u3055\u3044\uFF08TWP \u306E\u8A18\u9332\u3082\u4E00\u7DD2\u306B\u5916\u308C\u307E\u3059\uFF09\u3002\nFacebook\u30DA\u30FC\u30B8\u30FBInstagram \u306F\u7D44\u7E54\u3067\u5171\u6709\u3059\u308B\u9023\u643A\u3067\u3001\u5E83\u5831\u306E\u30E1\u30F3\u30D0\u30FC\u4EE5\u4E0A\u306E\u6A29\u9650\u304C\u8981\u308A\u307E\u3059\u3002",
112
118
  destructive:true,confirmation:"\u6295\u7A3F\u3092\u524A\u9664\u3059\u308B\u64CD\u4F5C\uFF08SNS \u4E0A\u306E\u6295\u7A3F\u306F\u53D6\u308A\u6D88\u305B\u305A\u3001X \u306F\u30AF\u30EC\u30B8\u30C3\u30C8\u3092\u6D88\u8CBB\u3057\u307E\u3059\uFF09",flags:[CHANNEL_FLAG,ACCOUNT_FLAG,{name:"--id",summary:"\u6295\u7A3FID\uFF08\u4F4D\u7F6E\u5F15\u6570\u3068\u540C\u3058\u610F\u5473\uFF09",takesValue:true,placeholder:"<ID>"}],async prepare(input,ctx){const ref=singleRef(input,{flag:"--id",label:"\u6295\u7A3FID",
113
119
  usage:DELETE_USAGE});const channel=oneChannel(input,DELETE_USAGE);const external=EXTERNAL_ID[channel];if(!UUID.test(ref)){if(external===void 0){throw new UsageError(`${channelName(channel)} \u306E\u6295\u7A3F\u306F TWP \u306E\u6295\u7A3FID\uFF08UUID\uFF09\u3067\u524A\u9664\u3057\u307E\u3059\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${ref}\uFF09`,`twp sns list --channel ${channel} \u306E id \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}if(!external.test(ref)){throw new UsageError(`\u6295\u7A3FI\
114
120
  D ${ref} \u306F ${channelName(channel)} \u306E\u6295\u7A3FID \u3067\u3082 TWP \u306E\u6295\u7A3FID\uFF08UUID\uFF09\u3067\u3082\u3042\u308A\u307E\u305B\u3093`,DELETE_USAGE)}return withResolved(input,{kind:channel,id:ref,channel,...await resolveAccount(input,ctx,channel,DELETE_USAGE)})}if(input.flags.has("--account"))throw new UsageError("TWP \u306E\u6295\u7A3F\uFF08UUID\uFF09\u306E\u524A\u9664\u306B --account \u306F\u8981\u308A\u307E\u305B\u3093",DELETE_USAGE);const post=await ctx.resolver.snsJson(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tocca-systems/twp-cli",
3
- "version": "0.136.0",
3
+ "version": "0.137.0",
4
4
  "description": "TWP CLI — Tocca Working Platform の CLI 型統合インターフェース(AIエージェントハーネス)",
5
5
  "type": "module",
6
6
  "bin": {