@tocca-systems/twp-cli 0.138.0 → 0.139.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.
Files changed (26) hide show
  1. package/CHANGELOG.public.md +4 -0
  2. package/dist/THIRD-PARTY-NOTICES.md +1 -1
  3. package/dist/{api-command-YT33DV4C.js → api-command-KNDQLV36.js} +1 -1
  4. package/dist/{app-OAWMTXZ3.js → app-Q2Q3YTZI.js} +1 -1
  5. package/dist/{capacity-list-command-W6SYFB77.js → capacity-list-command-FMHDYKA6.js} +1 -1
  6. package/dist/{chunk-VLTRRD4T.js → chunk-4OB22XRI.js} +1 -1
  7. package/dist/{chunk-K54OB2BX.js → chunk-HNW2JWHQ.js} +2 -2
  8. package/dist/{chunk-KOL4P7LC.js → chunk-L6FXTX6Q.js} +1 -1
  9. package/dist/{chunk-LXFLA3PZ.js → chunk-PAJAEUPA.js} +1 -1
  10. package/dist/cli.js +10 -8
  11. package/dist/{commands-VAY4M4MI.js → commands-JHGKEP65.js} +5 -5
  12. package/dist/{commands-OKU5OXD5.js → commands-QEUDLNBW.js} +1 -1
  13. package/dist/{commands-VAXOJGSE.js → commands-UDICRSBR.js} +1 -1
  14. package/dist/{corporate-VRU5NXIJ.js → corporate-24WCD6ID.js} +42 -27
  15. package/dist/dist-6JBU3TAO.js +118 -0
  16. package/dist/{github-git-ATC7VIW6.js → github-git-KJY6M3L4.js} +1 -1
  17. package/dist/{media-2COUCISC.js → media-2LVPBLNL.js} +1 -1
  18. package/dist/{query-E22FS2XX.js → query-NHJP3NF2.js} +1 -1
  19. package/dist/{registry-MDZXZUVK.js → registry-IHABQAQY.js} +1 -1
  20. package/dist/{run-5VFEV3BR.js → run-AZ6XEIXF.js} +1 -1
  21. package/dist/{runner-command-BQJ3WONI.js → runner-command-LUVEXFEQ.js} +1 -1
  22. package/dist/{skill-manage-command-5EPL2VZA.js → skill-manage-command-2QW3BA5K.js} +2 -2
  23. package/dist/{status-command-5HBUAGWX.js → status-command-XC7KWLLW.js} +2 -2
  24. package/dist/{trigger-command-JXPPZBKT.js → trigger-command-2TOL2G7C.js} +1 -1
  25. package/package.json +1 -1
  26. package/dist/dist-B4FAEXU4.js +0 -120
@@ -11,6 +11,10 @@
11
11
  `CHANGELOG.md` に残してあります。顧客向けの履歴は public 公開以降を対象とします。
12
12
  -->
13
13
 
14
+ ## 0.139.0
15
+
16
+ `twp corporate meeting` で書面決議(みなし決議)を扱えるようになりました。`create` / `update` の `--resolution-method written` と `--proposed-on` で登録し、`consent` で決議権者ごとの同意日を記録すると、全員の同意が揃った時点で `confirm` により確定できます。
17
+
14
18
  ## 0.138.0
15
19
 
16
20
  `twp outlook mail send` で Bcc(`--bcc`)を、返信・全員返信・転送(`reply` / `reply-all` / `forward`)で Cc・Bcc(`--cc` / `--bcc`)を指定できるようになりました。宛先はメールアドレスで指定します。全員返信の Cc は元のメールの Cc に足されます。`--dry-run` と送信前の表示に Cc・Bcc も出ます。
@@ -46,7 +46,7 @@ SOFTWARE.
46
46
 
47
47
  ## @jmespath-community/jmespath
48
48
 
49
- バージョン: 1.4.1 / ライセンス: MPL-2.0 / 作者: JMESPath Community
49
+ バージョン: 1.5.0 / ライセンス: MPL-2.0 / 作者: JMESPath Community
50
50
 
51
51
  ```
52
52
  Mozilla Public License Version 2.0
@@ -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-VLTRRD4T.js";import"./chunk-K54OB2BX.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-4OB22XRI.js";import"./chunk-HNW2JWHQ.js";import{evaluateQuery}from"./chunk-PAJAEUPA.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-5VFEV3BR.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-AZ6XEIXF.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",
@@ -16,7 +16,7 @@ includes(format)){const e=new UsageError(`capacity list \u306E --output \u306B\u
16
16
  ${e.hint?`${e.hint}
17
17
  `:""}`);return EXIT_USAGE}const res=await deps.get();if(!res.ok){err(`\u26D4 \u5B9F\u884C\u6A5F\u306E\u72B6\u614B\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\uFF08${errorDetail(res)}\uFF09
18
18
  `);return apiExit(res)}const overview=parseOverview(res,opts,(deps.now??Date.now)());if(overview===null){err(`\u26D4 \u5B9F\u884C\u6A5F\u306E\u72B6\u614B\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09
19
- `);return EXIT_API_SERVER}const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");if(format==="json"){const selected2=opts.query===void 0?overview:await evaluateQuery(opts.query,overview);const text2=renderOutput(selected2,"json");out(text2.endsWith("\n")?text2:`${text2}
19
+ `);return EXIT_API_SERVER}const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");if(format==="json"){const selected2=opts.query===void 0?overview:await evaluateQuery(opts.query,overview);const text2=renderOutput(selected2,"json");out(text2.endsWith("\n")?text2:`${text2}
20
20
  `);return EXIT_OK}const runnerCount=overview.projects.reduce((n,p)=>n+p.runners.length,0);const hiddenNote=overview.hidden_stopped>0?`\u30FB\u505C\u6B62\u4E2D ${overview.hidden_stopped}\u53F0\u306F\u975E\u8868\u793A\uFF08--include-stopped \u3067\u8868\u793A\uFF09`:"";const serverHidden=overview.projects.filter(p=>(p.hidden_count??0)>0).map(p=>`${projectLabel(p)}: ${p.hide_after_days??"?"}\u65E5\u4EE5\u4E0A\u5FDC\u7B54\u306E\u306A\u3044${p.hidden_count}\u53F0`).join("\u3001");err(`\u5B9F\u884C\u6A5F ${runnerCount}\
21
21
  \u53F0\uFF08${overview.projects.length}\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\uFF09${hiddenNote}\u30FB\u53D6\u5F97 ${overview.generated_at||"\u4E0D\u660E"}
22
22
  `);if(serverHidden!=="")err(`\u30B5\u30FC\u30D0\u5074\u3067\u4E00\u89A7\u304B\u3089\u5916\u308C\u3066\u3044\u308B\u6A5F: ${serverHidden}
@@ -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-K54OB2BX.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-HNW2JWHQ.js";import{evaluateQuery}from"./chunk-PAJAEUPA.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?"":`
@@ -2,10 +2,10 @@ import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
3
  var LOADERS={agent:async()=>(await import("./agent-YX3LZM4C.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-JJUNRUK3.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-7T4IUOQS.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-7FRIHGYL.js")).analysisDomain,announcement:async()=>(await import("./announcement-LD5GYBDF.js")).announcementDomain,"api-key":async()=>(await import("./api-key-TRKGA3AK.js")).apiKeyDomain,attendance:async()=>(await import("./attendance-correct-MM2FNL7H.js")).
4
4
  attendanceDomainWithRecords,"audit-log":async()=>(await import("./audit-log-DLRQGPIX.js")).auditLogDomain,backlog:async()=>(await import("./backlog-GXWI4TBK.js")).backlogDomain,brief:async()=>(await import("./brief-CG74AOQD.js")).briefDomain,budget:async()=>(await import("./budget-JFNAK6EF.js")).budgetDomain,"business-hours":async()=>(await import("./business-hours-QL763KSA.js")).businessHoursDomain,"business-place":async()=>(await import("./sales-master-HROKFBDJ.js")).businessPlaceDomain,
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")).
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-24WCD6ID.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-RF4VPQX3.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-WD2VND3X.js")).licenseDomain,"login-history":async()=>(await import("./login-history-3ZLCYSBI.js")).loginHistoryDomain,media:async()=>(await import("./media-2COUCISC.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-WD2VND3X.js")).licenseDomain,"login-history":async()=>(await import("./login-history-3ZLCYSBI.js")).loginHistoryDomain,media:async()=>(await import("./media-2LVPBLNL.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-IKZR2BEU.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-MOMCYET5.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-MOMCYET5.js")).skillDomain,slack:async()=>(await import("./slack-PS5ACRYL.js")).
@@ -7,7 +7,7 @@ body,"hidden_count"),removed_count:pickNumber(body,"removed_count"),hide_after_d
7
7
  r["version"])}}async function listRunners(api,opts,io){const{resolveOutputFormat}=await import("./format-X65HXAAU.js");const format=resolveOutputFormat({...opts.output!==void 0?{flag:opts.output}:{},isTty:io.isTty});if(format===null||!LIST_FORMATS.includes(format)){throw new UsageError(`runner list \u306E --output \u306B\u300C${opts.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${LIST_FORMATS.join(" / ")} \u3067\u3059`)}const res=await api.
8
8
  request("GET","/runners");if(!res.ok){io.err(`\u26D4 \u30E9\u30F3\u30CA\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\uFF08${errorDetail(res)}\uFF09
9
9
  `);return apiExit(res)}const parsed=parseRunners(res);if(parsed===null){io.err(`\u26D4 \u30E9\u30F3\u30CA\u30FC\u4E00\u89A7\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09
10
- `);return EXIT_API_SERVER}const{entries,summary}=parsed;const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");if(format==="json"){const value={...summary,runners:entries};const selected2=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text2=renderOutput(selected2,"json");io.out(text2.endsWith("\n")?text2:`${text2}
10
+ `);return EXIT_API_SERVER}const{entries,summary}=parsed;const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");if(format==="json"){const value={...summary,runners:entries};const selected2=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text2=renderOutput(selected2,"json");io.out(text2.endsWith("\n")?text2:`${text2}
11
11
  `);return EXIT_OK}io.err(summaryLine(summary));const selected=opts.query===void 0?entries:await evaluateQuery(opts.query,entries);if(opts.query===void 0&&entries.length===0){io.err("\u4E00\u89A7\u306B\u8868\u793A\u3055\u308C\u308B\u767B\u9332\u306F\u3042\u308A\u307E\u305B\u3093\n");return EXIT_OK}const text=renderOutput(selected,format);io.out(text.endsWith("\n")?text:`${text}
12
12
  `);if(opts.query===void 0&&entries.some(e=>e.state==="stale")){io.err(`${removeHint(opts)}
13
13
  `)}return EXIT_OK}function summaryLine(s){const n=v=>v===null?"?":String(v);const parts=[`\u7A3C\u50CD ${n(s.live_count)} / ${n(s.max_runners)}\uFF08\u6B7B\u6D3B\u3057\u304D\u3044\u5024 ${n(s.heartbeat_timeout)}\u79D2\uFF09`];parts.push(`${n(s.hide_after_days)}\u65E5\u4EE5\u4E0A\u5FDC\u7B54\u306A\u3057\u3067\u975E\u8868\u793A ${n(s.hidden_count)}\u53F0`);if(s.removed_count!==null)parts.push(`\u624B\u52D5\u3067\u5916\u3057\u305F\u767B\u9332 ${s.removed_count}\u53F0`);return`\u30E9\u30F3\u30CA\u30FC: ${parts.
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{UsageError}from"./chunk-STILP3Z6.js";async function evaluateQuery(expression,value){if(expression.trim()===""){throw new UsageError("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093")}const{search}=await import("./dist-B4FAEXU4.js");try{return search(value??null,expression)}catch(err){throw new UsageError(`--query \u306E\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}export{evaluateQuery};
3
+ import{UsageError}from"./chunk-STILP3Z6.js";async function evaluateQuery(expression,value){if(expression.trim()===""){throw new UsageError("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093")}const{search}=await import("./dist-6JBU3TAO.js");try{return search(value??null,expression)}catch(err){throw new UsageError(`--query \u306E\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}export{evaluateQuery};
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.138.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.139.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
@@ -1564,6 +1564,8 @@ import{GLOBAL_OPTIONS_HELP}from"./chunk-TZL2342W.js";import{parseArgv,quietFromE
1564
1564
  \u6761\u4EF6\u4ED8\u304D\u306E\u8B70\u6848\u306B\u767B\u8A18\u304C\u5FC5\u8981\u304B\u3092\u7B54\u3048\u308B
1565
1565
  twp corporate meeting resolve <\u4F1A\u8B70ID> --resolution <\u8B70\u6848ID>=<\u6C7A\u8B70>
1566
1566
  \u78BA\u5B9A\u524D\u306E\u6C7A\u8B70\u7D50\u679C\u3092\u5165\u308C\u308B\uFF08--resolved-on / --effective-on\uFF09
1567
+ twp corporate meeting consent <\u4F1A\u8B70ID> --consent <\u51FA\u5E2D\u8005ID>=<\u65E5\u4ED8>
1568
+ \u66F8\u9762\u6C7A\u8B70\u306E\u6C7A\u8B70\u6A29\u8005\u3054\u3068\u306E\u540C\u610F\u65E5\u3092\u8A18\u9332\u3059\u308B
1567
1569
  twp corporate meeting confirm <\u4F1A\u8B70ID> --yes
1568
1570
  \u6C7A\u8B70\u7D50\u679C\u3092\u78BA\u5B9A\u3059\u308B\uFF08\u4EE5\u5F8C\u306F correct \u3067\u7248\u3092\u5897\u3084\u3057\u3066\u8A02\u6B63\uFF09
1569
1571
  twp corporate meeting correct <\u4F1A\u8B70ID> --reason <\u7406\u7531> --yes
@@ -1878,17 +1880,17 @@ TUI \u5185:
1878
1880
  \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
1879
1881
  `;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
1880
1882
  `);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}
1881
- const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-MDZXZUVK.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-VAXOJGSE.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-ATC7VIW6.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);
1883
+ const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-IHABQAQY.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-UDICRSBR.js");process.
1884
+ 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-KJY6M3L4.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);
1883
1885
  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}
1884
1886
  `);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)}
1885
1887
 
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-5VFEV3BR.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-YT33DV4C.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1888
+ ${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-AZ6XEIXF.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
1889
+ {},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-KNDQLV36.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1888
1890
  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.
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}
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,
1891
+ command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-QEUDLNBW.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}
1892
+ if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-JHGKEP65.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,
1891
1893
  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,
1892
1894
  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");
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-OAWMTXZ3.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1895
+ 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-Q2Q3YTZI.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1894
1896
  allowedTools,disallowedTools:args.disallowedTools,model:args.model,profile:args.profile,noTui:args.noTui||!process.stdout.isTTY,doctor:args.doctor,version:VERSION})}await main();
@@ -321,20 +321,20 @@ claudeLauncher,...extraHosts.length>0?{preflightHosts:[...DEFAULT_PREFLIGHT_HOST
321
321
  action==="stop")return await stopLoop(opts);if(opts.action==="plan"){if(opts.planOp!=="submit"){process.stderr.write("plan \u306B\u306F submit \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runPlanSubmit}=await import("./plan-submit-26YXUKLU.js");return runPlanSubmit({file:opts.charterInput,empty:opts.planEmpty===true,check:opts.planCheck===true},{env:process.env,readStdin:()=>fs9.readFileSync(0,"utf8"),stdout:s=>process.stdout.write(s),stderr:s=>process.stderr.write(s)})}
322
322
  const profile=resolveProfile(opts.profile);let creds;try{creds=new AuthSession(profile.name,profile.apiUrl).loadOrThrow()}catch(err){process.stderr.write(`${err.message}
323
323
  `);return 1}const apiUrl=effectiveApiUrl(profile,creds.api_url);const session=new AuthSession(profile.name,apiUrl);if(opts.action==="capacity"&&opts.capacityOp==="list"){let filterId;if(opts.project!==void 0&&opts.project!==""){try{filterId=(await new ProjectApi(apiUrl,session).resolve(opts.project)).id}catch(err){process.stderr.write(`${err.message}
324
- `);return 1}}const api2=new AgentLoopApi({apiUrl,projectId:filterId??"",session});const{runCapacityList}=await import("./capacity-list-command-W6SYFB77.js");return runCapacityList({get:()=>api2.runnersOverview()},{output:opts.output,query:opts.query,includeStopped:opts.includeStopped===true,projectId:filterId})}const projectRef=opts.project??process.env.TWP_PROJECT??"";if(projectRef===""){process.stderr.write("--project <\u30AD\u30FC|UUID> \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08TWP_PROJECT \u3067\u3082\u53EF\uFF09\n");
324
+ `);return 1}}const api2=new AgentLoopApi({apiUrl,projectId:filterId??"",session});const{runCapacityList}=await import("./capacity-list-command-FMHDYKA6.js");return runCapacityList({get:()=>api2.runnersOverview()},{output:opts.output,query:opts.query,includeStopped:opts.includeStopped===true,projectId:filterId})}const projectRef=opts.project??process.env.TWP_PROJECT??"";if(projectRef===""){process.stderr.write("--project <\u30AD\u30FC|UUID> \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08TWP_PROJECT \u3067\u3082\u53EF\uFF09\n");
325
325
  return 2}const projectApi=new ProjectApi(apiUrl,session);let project;try{project=await projectApi.resolve(projectRef)}catch(err){process.stderr.write(`${err.message}
326
326
  `);return 1}const projectId=project.id;if(opts.action==="setup"){const{runSetup,parseAiList}=await import("./setup-2KNJ6KCX.js");let ais;if(opts.ais!==void 0&&opts.ais.length>0){const parsed=parseAiList(opts.ais.join(","));if(parsed.unknown.length>0){process.stderr.write(`--ai \u306B\u672A\u77E5\u306E\u5024\u304C\u3042\u308A\u307E\u3059: ${parsed.unknown.join(" / ")}
327
327
  `);return 2}ais=parsed.ais}return runSetup({projectId,projectRef,projectName:project.name===project.id?projectRef:`${project.code} / ${project.name}`,apiUrl,yes:opts.yes===true,...ais!==void 0?{ais}:{},...opts.workspace!==void 0?{workspace:opts.workspace}:{},...opts.aiConfigFile!==void 0?{aiConfigFile:opts.aiConfigFile}:{},...opts.noAiConfigFile===true?{noAiConfigFile:true}:{},...opts.profile!==void 0?{profile:opts.profile}:{}})}if(opts.action==="charter"){if(opts.charterOp===void 0){process.stderr.
328
328
  write("charter \u306B\u306F push / pull / history / diff / revert \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}if(isPrivateProjectId(projectId)){process.stderr.write("\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30E5\u30FC\uFF08--project __private__\uFF09\u306B\u306F\u61B2\u7AE0\u306E\u8A2D\u5B9A\u304C\u3042\u308A\u307E\u305B\u3093\n");return 2}if(opts.charterOp!=="push"&&opts.charterOp!=="pull"){const{runRevisionCommand}=await import("./revision-command-ASMYJBZU.js");
329
329
  return runRevisionCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{target:"charter",op:opts.charterOp,from:opts.revisionFrom,to:opts.revisionTo,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}const{runCharterCommand}=await import("./charter-command-CBCJQGIY.js");return runCharterCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.charterOp,file:opts.charterInput,out:opts.charterOutput,revision:opts.charterRevision,yes:opts.yes===true,projectRef,
330
- profile:opts.profile})}if(opts.action==="runner"){if(opts.runnerOp===void 0){process.stderr.write("runner \u306B\u306F list / remove \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runRunnerCommand}=await import("./runner-command-BQJ3WONI.js");return runRunnerCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.runnerOp,runnerId:opts.runnerId,output:opts.output,query:opts.query,yes:opts.yes===true,projectRef,profile:opts.profile})}
331
- if(opts.action==="trigger"){if(opts.triggerOp===void 0){process.stderr.write("trigger \u306B\u306F list / show / push / delete / history / release \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runTriggerCommand}=await import("./trigger-command-JXPPZBKT.js");return runTriggerCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.triggerOp,id:opts.triggerId,file:opts.charterInput,taskKey:opts.triggerKey,limit:opts.triggerLimit,revision:opts.
330
+ profile:opts.profile})}if(opts.action==="runner"){if(opts.runnerOp===void 0){process.stderr.write("runner \u306B\u306F list / remove \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runRunnerCommand}=await import("./runner-command-LUVEXFEQ.js");return runRunnerCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.runnerOp,runnerId:opts.runnerId,output:opts.output,query:opts.query,yes:opts.yes===true,projectRef,profile:opts.profile})}
331
+ if(opts.action==="trigger"){if(opts.triggerOp===void 0){process.stderr.write("trigger \u306B\u306F list / show / push / delete / history / release \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runTriggerCommand}=await import("./trigger-command-2TOL2G7C.js");return runTriggerCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.triggerOp,id:opts.triggerId,file:opts.charterInput,taskKey:opts.triggerKey,limit:opts.triggerLimit,revision:opts.
332
332
  charterRevision,output:opts.output,query:opts.query,yes:opts.yes===true,projectRef,profile:opts.profile})}if(opts.action==="schedule"&&opts.scheduleOp!==void 0){const{runScheduleDefCommand}=await import("./schedule-def-command-GOBV2HBH.js");return runScheduleDefCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.scheduleOp,configOp:opts.scheduleConfigOp,id:opts.scheduleId,file:opts.charterInput,out:opts.charterOutput,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.
333
333
  profile})}if(opts.action==="settings"){if(opts.settingsOp===void 0){process.stderr.write("settings \u306B\u306F push / pull \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}if(isPrivateProjectId(projectId)){process.stderr.write("\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30E5\u30FC\uFF08--project __private__\uFF09\u306B\u306F\u30EB\u30FC\u30D7\u8A2D\u5B9A\u304C\u3042\u308A\u307E\u305B\u3093\n");return 2}const{runSettingsCommand}=await import("./settings-command-NHJWW33Q.js");
334
334
  return runSettingsCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.settingsOp,file:opts.charterInput,out:opts.charterOutput,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}if(opts.action==="orientation"){if(opts.orientationOp===void 0){process.stderr.write("orientation \u306B\u306F show / set / on / off / add / remove \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runOrientationCommand}=await import("./orientation-command-35UWDVEJ.js");
335
335
  return runOrientationCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.orientationOp,args:opts.orientationArgs??[],revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}if(opts.action==="skill"){if(opts.skillOp===void 0){process.stderr.write("skill \u306B\u306F push / pull / list / show / delete / history / diff / revert / check \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}if(isPrivateProjectId(projectId)){
336
336
  process.stderr.write("\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30E5\u30FC\uFF08--project __private__\uFF09\u306B\u306F\u30B9\u30AD\u30EB\u5B9A\u7FA9\u306E\u8A2D\u5B9A\u304C\u3042\u308A\u307E\u305B\u3093\n");return 2}if(opts.skillOp==="check"){const{runSkillCheck}=await import("./skill-check-GRJAEOGD.js");return runSkillCheck({api:new AgentLoopApi({apiUrl,projectId,session})},{configPath:opts.skillConfig,defaultConfigPath:localConfigPath(projectId),output:opts.output})}if(opts.skillOp==="list"||
337
- opts.skillOp==="show"||opts.skillOp==="delete"){const{runSkillManageCommand}=await import("./skill-manage-command-5EPL2VZA.js");return runSkillManageCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.skillOp,name:opts.skillName,output:opts.output,query:opts.query,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}if(opts.skillOp!=="push"&&opts.skillOp!=="pull"){const{runRevisionCommand}=await import("./revision-command-ASMYJBZU.js");return runRevisionCommand({
337
+ opts.skillOp==="show"||opts.skillOp==="delete"){const{runSkillManageCommand}=await import("./skill-manage-command-2QW3BA5K.js");return runSkillManageCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.skillOp,name:opts.skillName,output:opts.output,query:opts.query,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}if(opts.skillOp!=="push"&&opts.skillOp!=="pull"){const{runRevisionCommand}=await import("./revision-command-ASMYJBZU.js");return runRevisionCommand({
338
338
  api:new AgentLoopApi({apiUrl,projectId,session})},{target:"skill",op:opts.skillOp,name:opts.skillName,from:opts.revisionFrom,to:opts.revisionTo,revision:opts.charterRevision,yes:opts.yes===true,projectRef,profile:opts.profile})}const{runSkillCommand}=await import("./skill-command-7RIHA2M6.js");return runSkillCommand({api:new AgentLoopApi({apiUrl,projectId,session})},{op:opts.skillOp,name:opts.skillName,all:opts.skillAll===true,dir:opts.skillDir,revision:opts.charterRevision,yes:opts.yes===true,projectRef,
339
339
  profile:opts.profile})}const config=buildLoopConfig({projectId,projectRef,apiUrl,safeMode:opts.safe,daemon:opts.daemon,...opts.maxCycles!==void 0?{maxCycles:opts.maxCycles}:{},...opts.interval!==void 0?{intervalSec:opts.interval}:{},forceRunner:opts.forceRunner,...opts.engine!==void 0?{engine:opts.engine}:{},version:opts.version});const api=new AgentLoopApi({apiUrl,projectId,session});if(opts.action==="capacity"){if(opts.capacityOp!=="report"){process.stderr.write("capacity \u306B\u306F report / list \u306E\u3044\u305A\u308C\
340
340
  \u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}for(const warning of config.warnings)process.stderr.write(`\u26A0\uFE0F ${warning}
@@ -359,7 +359,7 @@ void shutdown().catch(()=>void 0).then(()=>process.exit(130))};process.once("SIG
359
359
  \uFF09\u3002\u518D\u8D77\u52D5\u306F systemd\uFF08Restart=always\uFF09\u304C\u884C\u3044\u307E\u3059`);const reason=`\u7248\u30C9\u30EA\u30D5\u30C8 ${from} \u2192 ${to} \u306B\u3088\u308B\u81EA\u52D5\u518D\u8D77\u52D5`;if(loop===null)pendingDrain.value={reason,exitCode:EXIT_VERSION_DRIFT};else loop.requestDrain(reason,EXIT_VERSION_DRIFT)}});driftWatcher=watch.stop}try{const{LoopSettingsApplier:LoopSettingsApplier2}=await import("./server-settings-FXLXYHD6.js");const settings=new LoopSettingsApplier2(
360
360
  {api,config,log:m=>log.log(m)});await settings.apply();const{ServerSkillCatalog:ServerSkillCatalog2}=await import("./server-skills-X6AKHGMB.js");const skills=new ServerSkillCatalog2({api,config,log:m=>log.log(m)});await skills.refresh();await runner.checkHeartbeatInterval();await runner.registerOrThrow();runner.startHeartbeatWorker();log.log(` heartbeat: ${config.heartbeatIntervalSec}\u79D2\u3054\u3068\u306B\u9001\u4FE1${runner.heartbeatTimeoutServer?`\uFF08\u30B5\u30FC\u30D0\u306E\u6B7B\u6D3B\u3057\u304D\u3044\u5024 ${runner.
361
361
  heartbeatTimeoutServer}\u79D2\uFF09`:""}`);loop=new TaskLoop({api,projectApi,config,log,runner,engine:await buildEngine(config,m=>log.log(m)),settings,skills});if(pendingDrain.value!==null){loop.requestDrain(pendingDrain.value.reason,pendingDrain.value.exitCode)}exitCode=await loop.run()}catch(err){if(err instanceof RunnerRegistrationError){exitCode=1}else{log.log(`\u26D4 \u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC\u3067\u7D42\u4E86\u3057\u307E\u3059: ${err.message}`);exitCode=1}}finally{await shutdown(
362
- nextRunInOnExit({exitCode,loopStarted:loop!==null,drainRequested:(loop?.drainRequested??false)||pendingDrain.value!==null,endedAbnormally:loop?.endedAbnormallyWithZero??false,nextRunInSec:config.nextRunInSec}))}return exitCode}async function showStatus(api,config,opts){const{runStatusCommand}=await import("./status-command-5HBUAGWX.js");const lock=lockDir(config);return runStatusCommand(api,{projectRef:config.projectRef,projectId:config.projectId,apiUrl:config.apiUrl,lockPath:lock,lockHeld:fs9.existsSync(
362
+ nextRunInOnExit({exitCode,loopStarted:loop!==null,drainRequested:(loop?.drainRequested??false)||pendingDrain.value!==null,endedAbnormally:loop?.endedAbnormallyWithZero??false,nextRunInSec:config.nextRunInSec}))}return exitCode}async function showStatus(api,config,opts){const{runStatusCommand}=await import("./status-command-XC7KWLLW.js");const lock=lockDir(config);return runStatusCommand(api,{projectRef:config.projectRef,projectId:config.projectId,apiUrl:config.apiUrl,lockPath:lock,lockHeld:fs9.existsSync(
363
363
  lock),profile:opts.profile},{output:opts.output,query:opts.query},{out:s=>process.stdout.write(s),err:s=>process.stderr.write(s)})}var STOP_WAIT_MS=18e4;var STOP_POLL_MS=250;function defaultIsAlive(pid){try{process.kill(pid,0);return true}catch(err){return err.code==="EPERM"}}async function stopLoop(opts,deps={}){const platform=deps.platform??process.platform;const isLoopProcess=deps.isLoopProcess??defaultIsLoopProcess;const isAlive=deps.isAlive??defaultIsAlive;const waitMs=deps.waitMs??STOP_WAIT_MS;
364
364
  const pollMs=deps.pollMs??STOP_POLL_MS;const now=deps.now??Date.now;const nap=deps.sleep??(ms=>new Promise(r=>setTimeout(r,ms)));const request=deps.requestMarkerFn??requestMarker;const out=m=>void process.stdout.write(m);const err=m=>void process.stderr.write(m);if(opts.force&&opts.drain){err("\u26A0\uFE0F --force \u3068 --drain \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\uFF08\u8981\u6C42\u304C\u6B63\u53CD\u5BFE\u3067\u3059\uFF09\u3002\u3069\u3061\u3089\u3082\u5B9F\u884C\u3057\u307E\u305B\u3093\n");
365
365
  return 2}const stateDir=deps.stateDir??loopStateDir();let dirs;try{dirs=fs9.readdirSync(stateDir).filter(d=>/^task-loop-.*\.lock\.d$/.test(d))}catch{dirs=[]}if(opts.project){if(/^[0-9a-f-]{36}$/i.test(opts.project)||ULID_RE.test(opts.project)){dirs=dirs.filter(d=>d===`task-loop-${opts.project}.lock.d`)}else if(isPrivateProjectRef(opts.project)){dirs=dirs.filter(d=>d.startsWith("task-loop-private-"))}else{err(`\u26A0\uFE0F --project \u306F ID\uFF08UUID / ULID\uFF09\u6307\u5B9A\u306E\u3068\u304D\u3060\u3051\u7D5E\u308A\u8FBC\u3081\u307E\u3059\uFF08${safe(
@@ -12,7 +12,7 @@ ation/json",Authorization:`Bearer ${creds.token}`}}).then(res=>res.ok,()=>false)
12
12
  `);if(!revoked){writeOut("\u26A0 \u30B5\u30FC\u30D0\u5074\u306E\u30C8\u30FC\u30AF\u30F3\u5931\u52B9\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08\u30AA\u30D5\u30E9\u30A4\u30F3\u7B49\uFF09\u3002TWP \u306E\u300C\u8A2D\u5B9A > CLI\u7AEF\u672B\u300D\u304B\u3089\u3082\u5931\u52B9\u3067\u304D\u307E\u3059\u3002\n")}})}async function runWhoami(options){return run(async()=>{const profile=resolveProfile(options.profile);const structured=options.output!==void 0||options.query!==void 0;let format=null;if(structured){
13
13
  const{resolveOutputFormat,OUTPUT_FORMATS}=await import("./format-X65HXAAU.js");format=resolveOutputFormat({...options.output!==void 0?{flag:options.output}:{},isTty:process.stdout.isTTY===true});if(format===null){throw new UsageError(`--output \u306B\u300C${options.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${OUTPUT_FORMATS.join(" / ")} \u3067\u3059`)}}const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(
14
14
  profile,stored?.api_url);const session=new AuthSession(profile.name,apiUrl);const client=new TwpApiClient(apiUrl,session,httpFetch,options.cliVersion);const me=await client.get("/api/v2/user");const user=me.user;const creds=loadCredentials(profile.name);if(format!==null){const value={id:user?.id??null,name:user?.name??null,email:user?.email??null,tenant_code:user?.tenant_code??null,role:user?.role??null,is_admin:user?.is_admin??null,profile:profile.name,api_url:apiUrl,expires_at:creds?.token_expires_at??
15
- null};const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=options.query===void 0?value:await evaluateQuery(options.query,value);const text=renderOutput(selected,format);process.stdout.write(text.endsWith("\n")?text:`${text}
15
+ null};const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=options.query===void 0?value:await evaluateQuery(options.query,value);const text=renderOutput(selected,format);process.stdout.write(text.endsWith("\n")?text:`${text}
16
16
  `);return}writeOut(`\u30E6\u30FC\u30B6\u30FC: ${user?.name??"?"}\uFF08${user?.email??"?"}\uFF09
17
17
  `);writeOut(`ID: ${user?.id??"?"}
18
18
  `);writeOut(`\u30C6\u30CA\u30F3\u30C8: ${user?.tenant_code??"?"}
@@ -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.138.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.139.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){
@@ -4,36 +4,41 @@ import{FORCE_FLAG,OUT_FLAG}from"./chunk-WMHAJNKY.js";import"./chunk-SOLVG2XL.js"
4
4
  import"./chunk-CJFIIGSH.js";import"./chunk-HVZUXLQ4.js";import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import{nonEmpty}from"./chunk-DYT22FTA.js";import{requireResolved,withResolved}from"./chunk-7DCWZ2NF.js";import{isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";import"./chunk-ITFO5GPX.js";import"./chunk-GWVREACM.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";
5
5
  import"./chunk-RZVI6PMW.js";import"./chunk-OKATZ4SN.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import fs2 from"fs";import path2 from"path";var text=max=>(value,flag)=>{if(Array.from(value).length>max)throw new UsageError(`${flag} \u306F ${max} \u6587\u5B57\u307E\u3067\u3067\u3059\uFF08${Array.from(value).length} \u6587\u5B57\uFF09`);return value};function date(value,flag){const m=/^(\d{4})-(\d{2})-(\d{2})$/.exec(value);const d=new Date(0);if(m!==null)d.setUTCFullYear(Number(m[1]),Number(m[2])-1,Number(m[3]));if(m===null||d.getUTCFullYear()!==Number(m[1])||d.getUTCMonth()!==Number(m[2])-1||d.getUTCDate()!==Number(m[3])){throw new UsageError(
6
6
  `${flag} \u306F YYYY-MM-DD \u306E\u5B9F\u5728\u3059\u308B\u65E5\u4ED8\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${value}\uFF09`)}return value}var integer=(min,max)=>(value,flag)=>{const trimmed=value.trim();if(!/^[0-9]+$/.test(trimmed)||String(Number(trimmed))!==trimmed||Number(trimmed)<min||Number(trimmed)>max){throw new UsageError(`${flag} \u306B\u306F ${min}\u301C${max} \u306E\u6574\u6570\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${value}\
7
- \uFF09`)}return trimmed};var ID_MAX=Number.MAX_SAFE_INTEGER;var MEETINGS_PATH="/api/v2/corporate/meetings";var AGENDA_TYPES_PATH="/api/v2/corporate/agenda-types";var TYPES=["ordinary_shareholders","extraordinary_shareholders","board"];var STATUSES=["scheduled","held","cancelled"];var RESOLUTIONS=["approved","rejected","continued"];var MAX_RESOLUTIONS=100;var MAX_ATTENDEES=200;var TYPE_HELP="\u7A2E\u985E\u306F ordinary_shareholders\uFF08\u5B9A\u6642\u682A\u4E3B\u7DCF\u4F1A\uFF09/ extraordinary_shareholders\uFF08\u81E8\u6642\u682A\u4E3B\u7DCF\u4F1A\uFF09/ board\uFF08\u53D6\u7DE0\u5F79\u4F1A\uFF09\u3067\u3059\u3002";
8
- var STATUS_HELP="\u72B6\u614B\u306F scheduled\uFF08\u4E88\u5B9A\uFF09/ held\uFF08\u958B\u50AC\u6E08\u307F\uFF09/ cancelled\uFF08\u4E2D\u6B62\uFF09\u3067\u3059\u3002\u4F1A\u8B70\u306F\u524A\u9664\u3067\u304D\u306A\u3044\u306E\u3067\u3001\u53D6\u308A\u3084\u3081\u306F --status cancelled \u306B\u3057\u307E\u3059\u3002";var RESOLUTION_HELP="\u6C7A\u8B70\u306F approved\uFF08\u53EF\u6C7A\uFF09/ rejected\uFF08\u5426\u6C7A\uFF09/ continued\uFF08\u7D99\u7D9A\uFF09\u3067\u3059\u3002\u6C7A\u8B70\u7D50\u679C\u306F\u300C\u78BA\u5B9A\u300D\u3059\u308B\u307E\u3067\u4E0B\u66F8\u304D\u3067\u3001\u78BA\u5B9A\u5F8C\u306F\u76F4\u63A5\u5909\u3048\u3089\u308C\u307E\u305B\u3093\uFF08\u8A02\u6B63\u306F correct \u3067\u7248\u3092\u5897\u3084\u3057\u307E\u3059\uFF09\u3002";
7
+ \uFF09`)}return trimmed};var ID_MAX=Number.MAX_SAFE_INTEGER;var MEETINGS_PATH="/api/v2/corporate/meetings";var AGENDA_TYPES_PATH="/api/v2/corporate/agenda-types";var TYPES=["ordinary_shareholders","extraordinary_shareholders","board"];var STATUSES=["scheduled","held","cancelled"];var RESOLUTIONS=["approved","rejected","continued"];var METHODS=["meeting","written"];var MAX_RESOLUTIONS=100;var MAX_ATTENDEES=200;var TYPE_HELP="\u7A2E\u985E\u306F ordinary_shareholders\uFF08\u5B9A\u6642\u682A\u4E3B\u7DCF\u4F1A\uFF09/ extraordinary_shareholders\uFF08\u81E8\u6642\u682A\u4E3B\u7DCF\u4F1A\uFF09/ board\uFF08\u53D6\u7DE0\u5F79\u4F1A\uFF09\u3067\u3059\u3002";
8
+ var STATUS_HELP="\u72B6\u614B\u306F scheduled\uFF08\u4E88\u5B9A\uFF09/ held\uFF08\u958B\u50AC\u6E08\u307F\uFF09/ cancelled\uFF08\u4E2D\u6B62\uFF09\u3067\u3059\u3002\u4F1A\u8B70\u306F\u524A\u9664\u3067\u304D\u306A\u3044\u306E\u3067\u3001\u53D6\u308A\u3084\u3081\u306F --status cancelled \u306B\u3057\u307E\u3059\u3002";var METHOD_HELP="\u6C7A\u8B70\u306E\u65B9\u6CD5\u306F meeting\uFF08\u4F1A\u8B70\u3092\u958B\u3044\u3066\u6C7A\u8B70\u30FB\u65E2\u5B9A\uFF09/ written\uFF08\u66F8\u9762\u6C7A\u8B70\uFF1D\u6C7A\u8B70\u6A29\u8005\u5168\u54E1\u306E\u540C\u610F\u3067\u6C7A\u8B70\u304C\u3042\u3063\u305F\u3082\u306E\u3068\u307F\u306A\u3059\u3002\u4F1A\u793E\u6CD5319\u6761\u30FB370\u6761\uFF09\u3067\u3059\u3002\u66F8\u9762\u6C7A\u8B70\u306F --proposed-on\uFF08\u63D0\u6848\u65E5\uFF09\u304C\u5FC5\u9808\u3067\u3001\u53D6\u7DE0\u5F79\u4F1A\u3067\u306F\u5B9A\u6B3E\u306B\u5B9A\u3081\u304C\u3042\u308B\u3053\u3068\u3092\u78BA\u8A8D\u3057\u3066 --articles-confirmed yes \u3092\u4ED8\u3051\u307E\u3059\uFF08\u7121\u3044\
9
+ \u3068\u30B5\u30FC\u30D0\u304C 422 \u3067\u65AD\u308A\u307E\u3059\uFF09\u3002\u540C\u610F\u65E5\u306F consent \u3067\u8A18\u9332\u3057\u307E\u3059\u3002";var RESOLUTION_HELP="\u6C7A\u8B70\u306F approved\uFF08\u53EF\u6C7A\uFF09/ rejected\uFF08\u5426\u6C7A\uFF09/ continued\uFF08\u7D99\u7D9A\uFF09\u3067\u3059\u3002\u6C7A\u8B70\u7D50\u679C\u306F\u300C\u78BA\u5B9A\u300D\u3059\u308B\u307E\u3067\u4E0B\u66F8\u304D\u3067\u3001\u78BA\u5B9A\u5F8C\u306F\u76F4\u63A5\u5909\u3048\u3089\u308C\u307E\u305B\u3093\uFF08\u8A02\u6B63\u306F correct \u3067\u7248\u3092\u5897\u3084\u3057\u307E\u3059\uFF09\u3002";
9
10
  var LIST_COLUMNS=["id","meeting_type","title","scheduled_at","location","status","resolution_status","resolution_version","agendas"];var AGENDA_COLUMNS=["id","sort_order","agenda_type","summary","resolution","resolved_on","effective_on"];var HISTORY_COLUMNS=["id","action","changes","changed_at","changed_by_name"];var VERSION_COLUMNS=["id","version","kind","reason","resolutions","created_at","created_by_name"];function usageOf(op){return`twp corporate meeting ${op} help`}function oneOf(allowed){return(value,flag)=>{
10
11
  const v=value.trim();if(!allowed.includes(v))throw new UsageError(`${flag} \u306B\u306F ${allowed.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${value}\uFF09`);return v}}function dateTime(value,flag){const v=value.trim();const m=/^(\d{4}-\d{2}-\d{2})(?:[T ]([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:[01]\d|2[0-3]):?[0-5]\d)?)?$/.exec(v);if(m===null){throw new UsageError(`${flag} \u306F YYYY-M\
11
12
  M-DD \u304B YYYY-MM-DDTHH:MM\uFF08\u4F8B: 2026-11-20T10:00+09:00\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${value}\uFF09`)}date(m[1],flag);return v}var agendaType=(value,flag)=>{const v=text(50)(value.trim(),flag);if(!/^[a-z0-9_]+$/.test(v))throw new UsageError(`${flag} \u306F\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB_ \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: other\uFF09: ${value}`);return v};var MEETING_FIELDS=[
12
13
  {flag:{name:"--type",summary:"\u7A2E\u985E\uFF08ordinary_shareholders / extraordinary_shareholders / board\uFF09",takesValue:true,placeholder:"<\u7A2E\u985E>"},key:"meeting_type",check:oneOf(TYPES)},{flag:{name:"--scheduled-at",summary:"\u958B\u50AC\u65E5\u6642\uFF08YYYY-MM-DD \u304B YYYY-MM-DDTHH:MM[+09:00]\uFF09",takesValue:true,placeholder:"<\u65E5\u6642>"},key:"scheduled_at",check:dateTime},{flag:{name:"--title",summary:"\u540D\u79F0\uFF08255\u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"\
13
14
  <\u540D\u79F0>"},key:"title",check:text(255)},{flag:{name:"--location",summary:"\u5834\u6240\uFF08500\u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u5834\u6240>"},key:"location",check:text(500)},{flag:{name:"--status",summary:"\u72B6\u614B\uFF08scheduled / held / cancelled\uFF09",takesValue:true,placeholder:"<\u72B6\u614B>"},key:"status",check:oneOf(STATUSES)},{flag:{name:"--note",summary:"\u30E1\u30E2\uFF082000\u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u30E1\u30E2>"},
14
- key:"note",check:text(2e3)}];var OFFICER_FLAG={name:"--attendee-officer",summary:"\u51FA\u5E2D\u8005\uFF08\u5F79\u54E1ID\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u5F79\u54E1ID>",repeatable:true};var ATTENDEE_FLAG={name:"--attendee",summary:"\u51FA\u5E2D\u8005\uFF08\u682A\u4E3B\u7DCF\u4F1A\u306E\u682A\u4E3B\u306A\u3069\u5F79\u54E1\u4EE5\u5916\u306E\u6C0F\u540D\u3002\u53D6\u7DE0\u5F79\u4F1A\u306F\u5F79\u54E1\u3060\u3051\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",
15
+ key:"note",check:text(2e3)},{flag:{name:"--resolution-method",summary:"\u6C7A\u8B70\u306E\u65B9\u6CD5\uFF08meeting / written=\u66F8\u9762\u6C7A\u8B70\uFF09",takesValue:true,placeholder:"<\u65B9\u6CD5>"},key:"resolution_method",check:oneOf(METHODS)},{flag:{name:"--proposed-on",summary:"\u66F8\u9762\u6C7A\u8B70\u306E\u63D0\u6848\u65E5\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<\u65E5\u4ED8>"},key:"proposed_on",check:date}];var ARTICLES_FLAG={name:"--articles-confirmed",summary:"\u53D6\u7DE0\u5F79\u4F1A\u306E\u66F8\u9762\u6C7A\u8B70\
16
+ \u3067\u3001\u5B9A\u6B3E\u306B\u5B9A\u3081\uFF08\u4F1A\u793E\u6CD5370\u6761\uFF09\u304C\u3042\u308B\u3053\u3068\u3092\u78BA\u8A8D\u3057\u305F\uFF08yes / no\uFF09",takesValue:true,placeholder:"<yes|no>"};var CONSENT_FLAG={name:"--consent",summary:"\u6C7A\u8B70\u6A29\u8005\u306E\u540C\u610F\u65E5\uFF08<\u51FA\u5E2D\u8005ID>=YYYY-MM-DD|none\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u51FA\u5E2D\u8005ID>=<\u65E5\u4ED8>",repeatable:true};var ATTENDEE_ID_HINT="\
17
+ twp corporate meeting get <\u4F1A\u8B70ID> --output json \u306E attendees[].id \u306E\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002";var OFFICER_FLAG={name:"--attendee-officer",summary:"\u51FA\u5E2D\u8005\uFF08\u5F79\u54E1ID\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u5F79\u54E1ID>",repeatable:true};var ATTENDEE_FLAG={name:"--attendee",summary:"\u51FA\u5E2D\u8005\uFF08\u682A\u4E3B\u7DCF\u4F1A\u306E\u682A\u4E3B\u306A\u3069\u5F79\u54E1\u4EE5\u5916\u306E\u6C0F\u540D\u3002\u53D6\u7DE0\u5F79\u4F1A\u306F\u5F79\u54E1\u3060\u3051\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",
15
18
  takesValue:true,placeholder:"<\u6C0F\u540D>",repeatable:true};var CLEAR_ATTENDEES_FLAG={name:"--clear-attendees",summary:"\u51FA\u5E2D\u8005\u3092\u5168\u54E1\u5916\u3059",takesValue:false};var AGENDA_FLAG={name:"--agenda",summary:"\u8B70\u6848\u306E\u8981\u65E8\uFF082000\u6587\u5B57\u307E\u3067\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u3001\u6253\u3063\u305F\u9806\u306B\u4E26\u3076\uFF09",takesValue:true,placeholder:"<\u8981\u65E8>",repeatable:true};var SUMMARY_FLAG={name:"--summary",summary:"\
16
19
  \u8B70\u6848\u306E\u8981\u65E8\uFF082000\u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u8981\u65E8>"};var AGENDA_TYPE_FLAG={name:"--agenda-type",summary:"\u8B70\u6848\u7A2E\u5225\uFF08twp corporate meeting agenda-types \u306E procedure_code\u3002\u4F8B: officer_reappointment\uFF09",takesValue:true,placeholder:"<\u7A2E\u5225>"};var ANSWER_FLAG={name:"--answer",summary:"\u767B\u8A18\u304C\u5FC5\u8981\u304B\uFF08required=\u5FC5\u8981 / not_required=\u4E0D\u8981\uFF09",takesValue:true,
17
20
  placeholder:"<\u56DE\u7B54>"};var ANSWERS=["required","not_required"];var AGENDA_TYPE_COLUMNS=["procedure_code","name","registration","start_date_label","note"];var RESOLUTION_FLAG={name:"--resolution",summary:"\u8B70\u6848\u306E\u6C7A\u8B70\uFF08<\u8B70\u6848ID>=approved|rejected|continued|none\u3002\u8907\u6570\u56DE\u6307\u5B9A\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u8B70\u6848ID>=<\u6C7A\u8B70>",repeatable:true};var RESOLVED_ON_FLAG={name:"--resolved-on",summary:"\u6C7A\u8B70\u65E5\uFF08<\u8B70\u6848ID>=\
18
21
  YYYY-MM-DD|none\uFF09",takesValue:true,placeholder:"<\u8B70\u6848ID>=<\u65E5\u4ED8>",repeatable:true};var EFFECTIVE_ON_FLAG={name:"--effective-on",summary:"\u52B9\u529B\u767A\u751F\u65E5\uFF08<\u8B70\u6848ID>=YYYY-MM-DD|none\uFF09",takesValue:true,placeholder:"<\u8B70\u6848ID>=<\u65E5\u4ED8>",repeatable:true};var REASON_FLAG={name:"--reason",summary:"\u8A02\u6B63\u306E\u7406\u7531\uFF08\u5FC5\u9808\u30FB2000\u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u7406\u7531>"};function noArgs(input,op){
19
22
  if(input.args.length>0)throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,usageOf(op))}function numericId(raw,what,op,hint){if(raw===void 0||raw.trim()==="")throw new UsageError(`${what}\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,usageOf(op));const id=raw.trim();if(!isExactNumericId(id)||id==="0"||Number(id)>ID_MAX)throw new UsageError(`${what}\u306F1\u4EE5\u4E0A\u306E\u6570\u5B57\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${id}`,
20
23
  hint);return id}var MEETING_HINT="twp corporate meeting list \u306E id \u5217\u306E\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002";var AGENDA_HINT="twp corporate meeting get <\u4F1A\u8B70ID> --output json \u306E agendas[].id \u306E\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002";function positional(input,op,count){if(input.args.length>count)throw new UsageError(`\u53D7\u3051\u53D6\u308C\u308B\u4F4D\u7F6E\u5F15\u6570\u306F ${count} \u500B\u3067\u3059: ${input.
21
- args.slice(count).join(" ")}`,usageOf(op));return input.args}function meetingId(input,op){return numericId(positional(input,op,1)[0],"\u4F1A\u8B70\u306E ID ",op,MEETING_HINT)}var NULLABLE_KEYS=["title","location","note"];function fieldsOf(input,allowNone){const body={};for(const field of MEETING_FIELDS){const raw=nonEmpty(input.flags,field.flag.name);if(raw===void 0)continue;body[field.key]=allowNone&&NULLABLE_KEYS.includes(field.key)&&raw.trim()==="none"?null:field.check(raw,field.flag.name)}return body}
22
- function attendeesOf(input){const officers=repeatedValues(input,OFFICER_FLAG.name).map(raw=>({officer_id:Number(integer(1,ID_MAX)(raw,OFFICER_FLAG.name))}));const names=repeatedValues(input,ATTENDEE_FLAG.name).map(raw=>{if(raw.trim()==="")throw new UsageError(`${ATTENDEE_FLAG.name} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`);return{name:text(255)(raw.trim(),ATTENDEE_FLAG.name)}});const clear=input.flags.has(CLEAR_ATTENDEES_FLAG.name);if(clear&&officers.length+names.
23
- length>0){throw new UsageError(`${CLEAR_ATTENDEES_FLAG.name} \u3068 ${OFFICER_FLAG.name} / ${ATTENDEE_FLAG.name} \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`)}if(!clear&&officers.length+names.length===0)return void 0;const all=[...officers,...names];if(all.length>MAX_ATTENDEES)throw new UsageError(`\u51FA\u5E2D\u8005\u306F ${MAX_ATTENDEES} \u4EBA\u307E\u3067\u3067\u3059\uFF08${all.length} \u4EBA\uFF09`);return all}function createBody(input){const body=fieldsOf(input,false);
24
- if(body["meeting_type"]===void 0)throw new UsageError(`--type \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002${TYPE_HELP}`,usageOf("create"));if(body["scheduled_at"]===void 0)throw new UsageError("--scheduled-at\uFF08\u958B\u50AC\u65E5\u6642\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("create"));const attendees=attendeesOf(input);if(attendees!==void 0)body["attendees"]=attendees;const agendas=repeatedValues(input,AGENDA_FLAG.name).map(raw=>{if(raw.trim()==="")
25
- throw new UsageError(`${AGENDA_FLAG.name} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`);return{summary:text(2e3)(raw,AGENDA_FLAG.name)}});if(agendas.length>0)body["agendas"]=agendas;return body}function updateBody(input){const body=fieldsOf(input,true);const attendees=attendeesOf(input);if(attendees!==void 0)body["attendees"]=attendees;if(Object.keys(body).length===0)throw new UsageError("\u5909\u3048\u308B\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
26
- usageOf("update"));return body}function agendaBody(input,op){const body={};const summary2=nonEmpty(input.flags,SUMMARY_FLAG.name);if(summary2!==void 0)body["summary"]=text(2e3)(summary2,SUMMARY_FLAG.name);const type=nonEmpty(input.flags,AGENDA_TYPE_FLAG.name);if(type!==void 0)body["agenda_type"]=agendaType(type,AGENDA_TYPE_FLAG.name);if(op==="agenda-add"&&body["summary"]===void 0)throw new UsageError("--summary\uFF08\u8B70\u6848\u306E\u8981\u65E8\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
27
- usageOf(op));if(Object.keys(body).length===0)throw new UsageError("\u5909\u3048\u308B\u9805\u76EE\uFF08--summary / --agenda-type\uFF09\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf(op));return body}function pair(raw,flag,op,check){const at=raw.indexOf("=");if(at<0)throw new UsageError(`${flag} \u306F <\u8B70\u6848ID>=<\u5024> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`);const id=numericId(raw.
28
- slice(0,at),`${flag} \u306E\u8B70\u6848ID`,op,AGENDA_HINT);const value=raw.slice(at+1).trim();return[id,value==="none"?null:check(value,flag)]}function resolutionsOf(input,op){const rows=new Map;const specs=[[RESOLUTION_FLAG,"resolution",oneOf(RESOLUTIONS)],[RESOLVED_ON_FLAG,"resolved_on",date],[EFFECTIVE_ON_FLAG,"effective_on",date]];for(const[flag,key,check]of specs){for(const raw of repeatedValues(input,flag.name)){const[id,value]=pair(raw,flag.name,op,check);const row=rows.get(id)??{agenda_id:Number(
29
- id)};if(key in row)throw new UsageError(`${flag.name} \u3067\u8B70\u6848 ${id} \u30922\u56DE\u6307\u5B9A\u3057\u3066\u3044\u307E\u3059`,usageOf(op));row[key]=value;rows.set(id,row)}}if(rows.size===0){throw new UsageError(`${RESOLUTION_FLAG.name} / ${RESOLVED_ON_FLAG.name} / ${EFFECTIVE_ON_FLAG.name} \u306E\u3044\u305A\u308C\u304B\u3067\u8B70\u6848\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,usageOf(op))}if(rows.size>MAX_RESOLUTIONS)throw new UsageError(`\u4E00\u5EA6\u306B\u6307\u5B9A\u3067\u304D\u308B\u8B70\u6848\u306F ${MAX_RESOLUTIONS}\
30
- \u4EF6\u307E\u3067\u3067\u3059\uFF08${rows.size} \u4EF6\uFF09`,usageOf(op));return[...rows.values()]}function correctBody(input){const reason=nonEmpty(input.flags,REASON_FLAG.name);if(reason===void 0)throw new UsageError("--reason\uFF08\u8A02\u6B63\u306E\u7406\u7531\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("correct"));return{resolutions:resolutionsOf(input,"correct"),reason:text(2e3)(reason,REASON_FLAG.name)}}function listQuery(input){const query={};const from=nonEmpty(
31
- input.flags,"--from");const to=nonEmpty(input.flags,"--to");if(from!==void 0)query["from"]=date(from.trim(),"--from");if(to!==void 0)query["to"]=date(to.trim(),"--to");if(from!==void 0&&to!==void 0&&to.trim()<from.trim())throw new UsageError("--to \u306F --from \u4EE5\u964D\u306E\u65E5\u4ED8\u306B\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("list"));const type=nonEmpty(input.flags,"--type");if(type!==void 0)query["meeting_type"]=oneOf(TYPES)(type,"--type");const status=nonEmpty(input.flags,"--s\
32
- tatus");if(status!==void 0)query["status"]=oneOf(STATUSES)(status,"--status");return query}function dataOf(body,what,needs=["agendas"]){const data=isRecord(body)?body["data"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(data)||typeof data["id"]!=="string"||needs.some(key=>!Array.isArray(data[key]))){throw new ApiResponseError(`${what}\u306E\u5FDC\u7B54\u306B data.id / data.${needs.join(" / data.")} \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}
33
- return data}function itemsOf(body,what){const items=isRecord(body)?body["items"]:void 0;if(!isRecord(body)||body["result"]!==true||!Array.isArray(items)||!items.every(isRecord)){throw new ApiResponseError(`${what}\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 items}function agendaCell(value){if(!Array.isArray(value))return"";return value.filter(isRecord).map(g=>`#${String(
34
- g["agenda_id"]??g["id"]??"")} ${String(g["resolution_label"]??"\uFF08\u672A\u5165\u529B\uFF09")} ${String(g["summary"]??"")}`).join(" / ")}function agendaTypeRow(row){const rule=isRecord(row["agenda_rule"])?row["agenda_rule"]:{};return pick({...row,registration:rule["registration"]??"",start_date_label:rule["start_date_label"]??"",note:rule["note"]??""},AGENDA_TYPE_COLUMNS)}function answerBody(input){const answer=nonEmpty(input.flags,ANSWER_FLAG.name);if(answer===void 0)throw new UsageError("--a\
35
- nswer\uFF08required / not_required\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("registration-answer"));return{registration_answer:oneOf(ANSWERS)(answer.trim(),ANSWER_FLAG.name)}}function meetingRow(row){return pick({...row,agendas:agendaCell(row["agendas"])},LIST_COLUMNS)}function changesCell(value){if(!Array.isArray(value))return"";return value.filter(isRecord).map(c=>`${String(c["field"])}: ${String(c["before"]??"")} \u2192 ${String(c["after"]??"")}`).join(" / ")}var ID_HELP="\
36
- <\u4F1A\u8B70ID> \u306F twp corporate meeting list \u306E id \u5217\u306E\u5024\u3067\u3059\u3002";var MEETING_RESULT=`--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u51FA\u5E2D\u8005\u30FB\u8B70\u6848\u3068\u5404\u8B70\u6848\u306E id \u3092\u542B\u3080\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002
24
+ args.slice(count).join(" ")}`,usageOf(op));return input.args}function meetingId(input,op){return numericId(positional(input,op,1)[0],"\u4F1A\u8B70\u306E ID ",op,MEETING_HINT)}var NULLABLE_KEYS=["title","location","note","proposed_on"];function fieldsOf(input,allowNone){const body={};for(const field of MEETING_FIELDS){const raw=nonEmpty(input.flags,field.flag.name);if(raw===void 0)continue;body[field.key]=allowNone&&NULLABLE_KEYS.includes(field.key)&&raw.trim()==="none"?null:field.check(raw,field.
25
+ flag.name)}const articles=nonEmpty(input.flags,ARTICLES_FLAG.name);if(articles!==void 0)body["articles_confirmed"]=oneOf(["yes","no"])(articles,ARTICLES_FLAG.name)==="yes";return body}function attendeesOf(input){const officers=repeatedValues(input,OFFICER_FLAG.name).map(raw=>({officer_id:Number(integer(1,ID_MAX)(raw,OFFICER_FLAG.name))}));const names=repeatedValues(input,ATTENDEE_FLAG.name).map(raw=>{if(raw.trim()==="")throw new UsageError(`${ATTENDEE_FLAG.name} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`);
26
+ return{name:text(255)(raw.trim(),ATTENDEE_FLAG.name)}});const clear=input.flags.has(CLEAR_ATTENDEES_FLAG.name);if(clear&&officers.length+names.length>0){throw new UsageError(`${CLEAR_ATTENDEES_FLAG.name} \u3068 ${OFFICER_FLAG.name} / ${ATTENDEE_FLAG.name} \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`)}if(!clear&&officers.length+names.length===0)return void 0;const all=[...officers,...names];if(all.length>MAX_ATTENDEES)throw new UsageError(`\u51FA\u5E2D\u8005\u306F ${MAX_ATTENDEES}\
27
+ \u4EBA\u307E\u3067\u3067\u3059\uFF08${all.length} \u4EBA\uFF09`);return all}function createBody(input){const body=fieldsOf(input,false);if(body["meeting_type"]===void 0)throw new UsageError(`--type \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002${TYPE_HELP}`,usageOf("create"));if(body["scheduled_at"]===void 0)throw new UsageError("--scheduled-at\uFF08\u958B\u50AC\u65E5\u6642\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("create"));const attendees=attendeesOf(
28
+ input);if(attendees!==void 0)body["attendees"]=attendees;const agendas=repeatedValues(input,AGENDA_FLAG.name).map(raw=>{if(raw.trim()==="")throw new UsageError(`${AGENDA_FLAG.name} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`);return{summary:text(2e3)(raw,AGENDA_FLAG.name)}});if(agendas.length>0)body["agendas"]=agendas;return body}function updateBody(input){const body=fieldsOf(input,true);const attendees=attendeesOf(input);if(attendees!==void 0)body["attendees"]=attendees;
29
+ if(Object.keys(body).length===0)throw new UsageError("\u5909\u3048\u308B\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("update"));return body}function agendaBody(input,op){const body={};const summary2=nonEmpty(input.flags,SUMMARY_FLAG.name);if(summary2!==void 0)body["summary"]=text(2e3)(summary2,SUMMARY_FLAG.name);const type=nonEmpty(input.flags,AGENDA_TYPE_FLAG.name);if(type!==void 0)body["agenda_type"]=agendaType(type,AGENDA_TYPE_FLAG.name);if(op===
30
+ "agenda-add"&&body["summary"]===void 0)throw new UsageError("--summary\uFF08\u8B70\u6848\u306E\u8981\u65E8\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf(op));if(Object.keys(body).length===0)throw new UsageError("\u5909\u3048\u308B\u9805\u76EE\uFF08--summary / --agenda-type\uFF09\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf(op));return body}function pair(raw,flag,op,check){const at=raw.indexOf("=");if(at<0)throw new UsageError(`${flag} \u306F\
31
+ <\u8B70\u6848ID>=<\u5024> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`);const id=numericId(raw.slice(0,at),`${flag} \u306E\u8B70\u6848ID`,op,AGENDA_HINT);const value=raw.slice(at+1).trim();return[id,value==="none"?null:check(value,flag)]}function resolutionsOf(input,op){const rows=new Map;const specs=[[RESOLUTION_FLAG,"resolution",oneOf(RESOLUTIONS)],[RESOLVED_ON_FLAG,"resolved_on",date],[EFFECTIVE_ON_FLAG,"effective_on",date]];
32
+ for(const[flag,key,check]of specs){for(const raw of repeatedValues(input,flag.name)){const[id,value]=pair(raw,flag.name,op,check);const row=rows.get(id)??{agenda_id:Number(id)};if(key in row)throw new UsageError(`${flag.name} \u3067\u8B70\u6848 ${id} \u30922\u56DE\u6307\u5B9A\u3057\u3066\u3044\u307E\u3059`,usageOf(op));row[key]=value;rows.set(id,row)}}if(rows.size===0){throw new UsageError(`${RESOLUTION_FLAG.name} / ${RESOLVED_ON_FLAG.name} / ${EFFECTIVE_ON_FLAG.name} \u306E\u3044\u305A\u308C\u304B\u3067\u8B70\u6848\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,
33
+ usageOf(op))}if(rows.size>MAX_RESOLUTIONS)throw new UsageError(`\u4E00\u5EA6\u306B\u6307\u5B9A\u3067\u304D\u308B\u8B70\u6848\u306F ${MAX_RESOLUTIONS} \u4EF6\u307E\u3067\u3067\u3059\uFF08${rows.size} \u4EF6\uFF09`,usageOf(op));return[...rows.values()]}function consentBody(input){const rows=new Map;for(const raw of repeatedValues(input,CONSENT_FLAG.name)){const at=raw.indexOf("=");if(at<0)throw new UsageError(`${CONSENT_FLAG.name} \u306F <\u51FA\u5E2D\u8005ID>=<\u65E5\u4ED8> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\
34
+ \uFF09`);const id=numericId(raw.slice(0,at),`${CONSENT_FLAG.name} \u306E\u51FA\u5E2D\u8005ID`,"consent",ATTENDEE_ID_HINT);if(rows.has(id))throw new UsageError(`${CONSENT_FLAG.name} \u3067\u51FA\u5E2D\u8005 ${id} \u30922\u56DE\u6307\u5B9A\u3057\u3066\u3044\u307E\u3059`,usageOf("consent"));const value=raw.slice(at+1).trim();rows.set(id,{attendee_id:Number(id),consented_on:value==="none"?null:date(value,CONSENT_FLAG.name)})}if(rows.size===0)throw new UsageError(`${CONSENT_FLAG.name} \u3067\u6C7A\u8B70\u6A29\u8005\u30921\u4EBA\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\
35
+ \u3060\u3055\u3044`,usageOf("consent"));if(rows.size>MAX_ATTENDEES)throw new UsageError(`\u4E00\u5EA6\u306B\u6307\u5B9A\u3067\u304D\u308B\u6C7A\u8B70\u6A29\u8005\u306F ${MAX_ATTENDEES} \u4EBA\u307E\u3067\u3067\u3059\uFF08${rows.size} \u4EBA\uFF09`,usageOf("consent"));return{consents:[...rows.values()]}}function correctBody(input){const reason=nonEmpty(input.flags,REASON_FLAG.name);if(reason===void 0)throw new UsageError("--reason\uFF08\u8A02\u6B63\u306E\u7406\u7531\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
36
+ usageOf("correct"));return{resolutions:resolutionsOf(input,"correct"),reason:text(2e3)(reason,REASON_FLAG.name)}}function listQuery(input){const query={};const from=nonEmpty(input.flags,"--from");const to=nonEmpty(input.flags,"--to");if(from!==void 0)query["from"]=date(from.trim(),"--from");if(to!==void 0)query["to"]=date(to.trim(),"--to");if(from!==void 0&&to!==void 0&&to.trim()<from.trim())throw new UsageError("--to \u306F --from \u4EE5\u964D\u306E\u65E5\u4ED8\u306B\u3057\u3066\u304F\u3060\u3055\u3044",
37
+ usageOf("list"));const type=nonEmpty(input.flags,"--type");if(type!==void 0)query["meeting_type"]=oneOf(TYPES)(type,"--type");const status=nonEmpty(input.flags,"--status");if(status!==void 0)query["status"]=oneOf(STATUSES)(status,"--status");return query}function dataOf(body,what,needs=["agendas"]){const data=isRecord(body)?body["data"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(data)||typeof data["id"]!=="string"||needs.some(key=>!Array.isArray(data[key]))){throw new ApiResponseError(
38
+ `${what}\u306E\u5FDC\u7B54\u306B data.id / data.${needs.join(" / data.")} \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return data}function itemsOf(body,what){const items=isRecord(body)?body["items"]:void 0;if(!isRecord(body)||body["result"]!==true||!Array.isArray(items)||!items.every(isRecord)){throw new ApiResponseError(`${what}\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`)}
39
+ return items}function agendaCell(value){if(!Array.isArray(value))return"";return value.filter(isRecord).map(g=>`#${String(g["agenda_id"]??g["id"]??"")} ${String(g["resolution_label"]??"\uFF08\u672A\u5165\u529B\uFF09")} ${String(g["summary"]??"")}`).join(" / ")}function agendaTypeRow(row){const rule=isRecord(row["agenda_rule"])?row["agenda_rule"]:{};return pick({...row,registration:rule["registration"]??"",start_date_label:rule["start_date_label"]??"",note:rule["note"]??""},AGENDA_TYPE_COLUMNS)}function answerBody(input){
40
+ const answer=nonEmpty(input.flags,ANSWER_FLAG.name);if(answer===void 0)throw new UsageError("--answer\uFF08required / not_required\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usageOf("registration-answer"));return{registration_answer:oneOf(ANSWERS)(answer.trim(),ANSWER_FLAG.name)}}function meetingRow(row){return pick({...row,agendas:agendaCell(row["agendas"])},LIST_COLUMNS)}function changesCell(value){if(!Array.isArray(value))return"";return value.filter(isRecord).map(c=>`${String(
41
+ c["field"])}: ${String(c["before"]??"")} \u2192 ${String(c["after"]??"")}`).join(" / ")}var ID_HELP="<\u4F1A\u8B70ID> \u306F twp corporate meeting list \u306E id \u5217\u306E\u5024\u3067\u3059\u3002";var MEETING_RESULT=`--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u51FA\u5E2D\u8005\u30FB\u8B70\u6848\u3068\u5404\u8B70\u6848\u306E id \u3092\u542B\u3080\uFF09\u3092\u51FA\u3057\u307E\u3059\u3002
37
42
  --output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${LIST_COLUMNS.join(" / ")}\uFF09\u3067\u3001agendas \u306F\u300C#\u8B70\u6848ID \u6C7A\u8B70 \u8981\u65E8\u300D\u3092 / \u3067\u533A\u5207\u3063\u305F1\u30BB\u30EB\u3067\u3059\u3002`;var VIEW="\u7D4C\u55B6\u306E\u6A29\u9650\u304C\u300C\u95B2\u89A7\u300D\u4EE5\u4E0A\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\uFF08\u7121\u3051\u308C\u3070\u30B5\u30FC\u30D0\u306E\u6587\u9762\u306E\u307E\u307E\u7D42\u4E86\u30B3\u30FC\u30C9 3 \u3067\u6B62\u307E\u308A\u307E\u3059\uFF09\u3002";
38
43
  var EDIT="\u7D4C\u55B6\u306E\u6A29\u9650\u304C\u300C\u7DE8\u96C6\u300D\u3067\u3042\u308B\u3053\u3068\u304C\u8981\u308A\u307E\u3059\uFF08\u7121\u3051\u308C\u3070\u30B5\u30FC\u30D0\u306E\u6587\u9762\u306E\u307E\u307E\u7D42\u4E86\u30B3\u30FC\u30C9 3 \u3067\u6B62\u307E\u308A\u307E\u3059\uFF09\u3002";var UNSURE=op=>`${op}\u306E\u6210\u5426\u304C\u5206\u304B\u3089\u306A\u3044\u307E\u307E\u7D42\u308F\u3063\u305F\u3068\u304D\u306F\u3001\u6253\u3061\u76F4\u3059\u524D\u306B twp corporate meeting get / list \u3067\u53CD\u6620\u6E08\u307F\u304B\u3092\u78BA\u304B\u3081\u3066\u304F\u3060\u3055\u3044\uFF08\u4E8C\u91CD\u306B\u767B\u9332\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\uFF09\u3002`;
39
44
  function meetingWrite(spec){const{what,validate,...op}=spec;return{...op,prepare(input){validate(input);return Promise.resolve(input)},summarize:body=>meetingRow(dataOf(body,what)),raw:body=>dataOf(body,what)}}var meetingResource={name:"meeting",summary:"\u4F1A\u8B70\u4F53\uFF08\u682A\u4E3B\u7DCF\u4F1A\u30FB\u53D6\u7DE0\u5F79\u4F1A\uFF09\u306E\u4F1A\u8B70\u30FB\u8B70\u6848\u30FB\u6C7A\u8B70\u7D50\u679C\u306E\u8A18\u9332\u3068\u78BA\u5B9A\u30FB\u8A02\u6B63",operations:[{name:"list",summary:"\u4F1A\u8B70\u3092\u4E00\u89A7\
@@ -48,23 +53,25 @@ ${RESOLUTION_HELP}
48
53
  ${VIEW}
49
54
 
50
55
  ${MEETING_RESULT}`,flags:[],prepare(input){meetingId(input,"get");return Promise.resolve(input)},plan:input=>({method:"GET",path:`${MEETINGS_PATH}/${meetingId(input,"get")}`}),summarize:body=>meetingRow(dataOf(body,"\u4F1A\u8B70")),raw:body=>dataOf(body,"\u4F1A\u8B70")},meetingWrite({name:"create",what:"\u4F1A\u8B70\u306E\u767B\u9332",summary:"\u4F1A\u8B70\u3092\u767B\u9332\u3059\u308B\uFF08\u8B70\u6848\u30FB\u51FA\u5E2D\u8005\u3082\u540C\u6642\u306B\u767B\u9332\u3067\u304D\u308B\uFF09",usage:"t\
51
- wp corporate meeting create --type <\u7A2E\u985E> --scheduled-at <\u65E5\u6642> [--title <\u540D\u79F0>] [--location <\u5834\u6240>] [--status <\u72B6\u614B>] [--note <\u30E1\u30E2>] [--agenda <\u8981\u65E8>]... [--attendee-officer <\u5F79\u54E1ID>]... [--attendee <\u6C0F\u540D>]...",description:`--type \u3068 --scheduled-at \u304C\u5FC5\u9808\u3067\u3059\u3002${TYPE_HELP}
56
+ wp corporate meeting create --type <\u7A2E\u985E> --scheduled-at <\u65E5\u6642> [--title <\u540D\u79F0>] [--location <\u5834\u6240>] [--status <\u72B6\u614B>] [--note <\u30E1\u30E2>] [--resolution-method <\u65B9\u6CD5>] [--proposed-on <\u65E5\u4ED8>] [--articles-confirmed <yes|no>] [--agenda <\u8981\u65E8>]... [--attendee-officer <\u5F79\u54E1ID>]... [--attendee <\u6C0F\u540D>]...",description:`--type \u3068 --scheduled-at \u304C\u5FC5\u9808\u3067\u3059\u3002${TYPE_HELP}
52
57
  ${STATUS_HELP}\uFF08\u7701\u7565\u6642\u306F\u30B5\u30FC\u30D0\u306E\u65E2\u5B9A\uFF1D\u4E88\u5B9A\uFF09
58
+ ${METHOD_HELP}
53
59
  --agenda \u306F\u6253\u3063\u305F\u9806\u306B\u8B70\u6848\u3068\u3057\u3066\u4E26\u3073\u307E\u3059\u3002\u51FA\u5E2D\u8005\u306F\u5F79\u54E1\u306A\u3089 --attendee-officer\uFF08\u5F79\u54E1ID\uFF09\u3001\u305D\u308C\u4EE5\u5916\u306F --attendee\uFF08\u6C0F\u540D\uFF09\u3067\u6307\u5B9A\u3057\u307E\u3059\u3002
54
60
 
55
61
  \u753B\u9762\u3068\u540C\u3058 API\uFF08POST /api/v2/corporate/meetings\uFF09\u3078\u9001\u308A\u307E\u3059\uFF08\u9001\u308B\u5185\u5BB9\u306F --dry-run \u3067\u78BA\u304B\u3081\u3089\u308C\u307E\u3059\uFF09\u3002\u4F1A\u8B70\u306F\u524A\u9664\u3067\u304D\u307E\u305B\u3093\u3002
56
62
  ${UNSURE("\u767B\u9332")}
57
63
  ${EDIT}
58
64
 
59
- ${MEETING_RESULT}`,flags:[...MEETING_FIELDS.map(field=>field.flag),AGENDA_FLAG,OFFICER_FLAG,ATTENDEE_FLAG],validate:input=>{noArgs(input,"create");createBody(input)},plan:input=>({method:"POST",path:MEETINGS_PATH,body:createBody(input)})}),meetingWrite({name:"update",what:"\u4F1A\u8B70\u306E\u66F4\u65B0",summary:"\u4F1A\u8B70\u306E\u7A2E\u985E\u30FB\u65E5\u6642\u30FB\u5834\u6240\u30FB\u72B6\u614B\u30FB\u30E1\u30E2\u30FB\u51FA\u5E2D\u8005\u3092\u5909\u3048\u308B\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\uFF09",
60
- usage:"twp corporate meeting update <\u4F1A\u8B70ID> [--type <\u7A2E\u985E>] [--scheduled-at <\u65E5\u6642>] [--title <\u540D\u79F0>] [--location <\u5834\u6240>] [--status <\u72B6\u614B>] [--note <\u30E1\u30E2>] [--attendee-officer <\u5F79\u54E1ID>]... [--attendee <\u6C0F\u540D>]... [--clear-attendees]",description:`${ID_HELP}
61
- \u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u9001\u308A\u307E\u3059\uFF08\u7701\u7565\u3057\u305F\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002--title / --location / --note \u306B none \u3092\u6307\u5B9A\u3059\u308B\u3068\u672A\u5165\u529B\u306B\u623B\u3057\u307E\u3059\u3002${STATUS_HELP}
65
+ ${MEETING_RESULT}`,flags:[...MEETING_FIELDS.map(field=>field.flag),ARTICLES_FLAG,AGENDA_FLAG,OFFICER_FLAG,ATTENDEE_FLAG],validate:input=>{noArgs(input,"create");createBody(input)},plan:input=>({method:"POST",path:MEETINGS_PATH,body:createBody(input)})}),meetingWrite({name:"update",what:"\u4F1A\u8B70\u306E\u66F4\u65B0",summary:"\u4F1A\u8B70\u306E\u7A2E\u985E\u30FB\u65E5\u6642\u30FB\u5834\u6240\u30FB\u72B6\u614B\u30FB\u30E1\u30E2\u30FB\u51FA\u5E2D\u8005\u3092\u5909\u3048\u308B\uFF08\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\uFF09",
66
+ usage:"twp corporate meeting update <\u4F1A\u8B70ID> [--type <\u7A2E\u985E>] [--scheduled-at <\u65E5\u6642>] [--title <\u540D\u79F0>] [--location <\u5834\u6240>] [--status <\u72B6\u614B>] [--note <\u30E1\u30E2>] [--resolution-method <\u65B9\u6CD5>] [--proposed-on <\u65E5\u4ED8>] [--articles-confirmed <yes|no>] [--attendee-officer <\u5F79\u54E1ID>]... [--attendee <\u6C0F\u540D>]... [--clear-attendees]",description:`${ID_HELP}
67
+ \u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u9001\u308A\u307E\u3059\uFF08\u7701\u7565\u3057\u305F\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002--title / --location / --note / --proposed-on \u306B none \u3092\u6307\u5B9A\u3059\u308B\u3068\u672A\u5165\u529B\u306B\u623B\u3057\u307E\u3059\u3002${STATUS_HELP}
68
+ ${METHOD_HELP}
62
69
  \u26A0 \u51FA\u5E2D\u8005\u30921\u4EBA\u3067\u3082\u6307\u5B9A\u3059\u308B\u3068\u3001**\u51FA\u5E2D\u8005\u306F\u6307\u5B9A\u3057\u305F\u4EBA\u3067\u5168\u54E1\u7F6E\u304D\u63DB\u308F\u308A\u307E\u3059**\uFF08\u8FFD\u52A0\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002\u5168\u54E1\u5916\u3059\u3068\u304D\u306F --clear-attendees\u3002
63
70
  \u8B70\u6848\u306F agenda-add / agenda-update \u3067\u5909\u3048\u307E\u3059\u3002
64
71
  ${EDIT}
65
72
 
66
- ${MEETING_RESULT}`,flags:[...MEETING_FIELDS.map(field=>field.flag),OFFICER_FLAG,ATTENDEE_FLAG,CLEAR_ATTENDEES_FLAG],validate:input=>{meetingId(input,"update");updateBody(input)},plan:input=>({method:"PUT",path:`${MEETINGS_PATH}/${meetingId(input,"update")}`,body:updateBody(input)})}),{name:"history",summary:"\u4F1A\u8B70\u306E\u5909\u66F4\u5C65\u6B74\uFF08\u8AB0\u304C\u30FB\u3044\u3064\u30FB\u4F55\u3092\u5909\u3048\u305F\u304B\uFF09\u3092\u8868\u793A\u3059\u308B",usage:"twp corporate meeting his\
67
- tory <\u4F1A\u8B70ID>",description:`${ID_HELP}
73
+ ${MEETING_RESULT}`,flags:[...MEETING_FIELDS.map(field=>field.flag),ARTICLES_FLAG,OFFICER_FLAG,ATTENDEE_FLAG,CLEAR_ATTENDEES_FLAG],validate:input=>{meetingId(input,"update");updateBody(input)},plan:input=>({method:"PUT",path:`${MEETINGS_PATH}/${meetingId(input,"update")}`,body:updateBody(input)})}),{name:"history",summary:"\u4F1A\u8B70\u306E\u5909\u66F4\u5C65\u6B74\uFF08\u8AB0\u304C\u30FB\u3044\u3064\u30FB\u4F55\u3092\u5909\u3048\u305F\u304B\uFF09\u3092\u8868\u793A\u3059\u308B",usage:"twp corpora\
74
+ te meeting history <\u4F1A\u8B70ID>",description:`${ID_HELP}
68
75
  ${VIEW}
69
76
 
70
77
  --output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08${HISTORY_COLUMNS.join(" / ")}\uFF09\u3067\u3001changes \u306F\u300C\u9805\u76EE: \u524D \u2192 \u5F8C\u300D\u3092 / \u3067\u533A\u5207\u3063\u305F1\u30BB\u30EB\u3067\u3059\u3002`,flags:[],prepare(input){meetingId(input,"history");return Promise.resolve(input)},plan:input=>({method:"GET",path:`${MEETINGS_PATH}/${meetingId(input,"history")}/history`}),summarize:body=>itemsOf(body,"\u4F1A\u8B70\u306E\u5909\u66F4\u5C65\u6B74").map(row=>pick(
@@ -87,9 +94,17 @@ ${RESOLUTION_HELP}
87
94
  \u3053\u3053\u3067\u5165\u308C\u305F\u5024\u306F\u307E\u3060\u4E0B\u66F8\u304D\u3067\u3059\u3002\u4E0B\u6D41\uFF08\u767B\u8A18\u306E\u8D77\u7968\u30FB\u53F0\u5E33\u3078\u306E\u53CD\u6620\uFF09\u3092\u52D5\u304B\u3059\u306B\u306F confirm \u3067\u78BA\u5B9A\u3057\u307E\u3059\u3002
88
95
  ${EDIT}
89
96
 
90
- ${MEETING_RESULT}`,flags:[RESOLUTION_FLAG,RESOLVED_ON_FLAG,EFFECTIVE_ON_FLAG],validate:input=>{meetingId(input,"resolve");resolutionsOf(input,"resolve")},plan:input=>({method:"PUT",path:`${MEETINGS_PATH}/${meetingId(input,"resolve")}/resolutions`,body:{resolutions:resolutionsOf(input,"resolve")}})}),meetingWrite({name:"confirm",what:"\u6C7A\u8B70\u7D50\u679C\u306E\u78BA\u5B9A",summary:"\u6C7A\u8B70\u7D50\u679C\u3092\u78BA\u5B9A\u3059\u308B\uFF08\u7248 1 \u304C\u6B8B\u308A\u3001\u4EE5\u5F8C\u306F\u8A02\u6B63\u3067\u3057\u304B\u5909\u3048\u3089\u308C\u306A\u3044\uFF09",
91
- usage:"twp corporate meeting confirm <\u4F1A\u8B70ID> --yes",description:`${ID_HELP}
97
+ ${MEETING_RESULT}`,flags:[RESOLUTION_FLAG,RESOLVED_ON_FLAG,EFFECTIVE_ON_FLAG],validate:input=>{meetingId(input,"resolve");resolutionsOf(input,"resolve")},plan:input=>({method:"PUT",path:`${MEETINGS_PATH}/${meetingId(input,"resolve")}/resolutions`,body:{resolutions:resolutionsOf(input,"resolve")}})}),meetingWrite({name:"consent",what:"\u66F8\u9762\u6C7A\u8B70\u306E\u540C\u610F\u65E5\u306E\u8A18\u9332",summary:"\u66F8\u9762\u6C7A\u8B70\u306E\u6C7A\u8B70\u6A29\u8005\u3054\u3068\u306E\u540C\u610F\u65E5\u3092\u8A18\u9332\u3059\u308B\uFF08\u78BA\u5B9A\u524D\u306E\u307F\uFF09",
98
+ usage:"twp corporate meeting consent <\u4F1A\u8B70ID> --consent <\u51FA\u5E2D\u8005ID>=<\u65E5\u4ED8>...",description:`${ID_HELP}
99
+ \u66F8\u9762\u6C7A\u8B70\uFF08--resolution-method written\uFF09\u306E\u4F1A\u8B70\u3060\u3051\u304C\u5BFE\u8C61\u3067\u3059\u3002\u51FA\u5E2D\u8005\u3068\u3057\u3066\u767B\u9332\u3057\u305F\u6C7A\u8B70\u6A29\u8005\u3054\u3068\u306B\u540C\u610F\u65E5\u3092\u8A18\u9332\u3057\u307E\u3059\uFF08\u4F8B: --consent 12=2026-11-03\uFF09\u3002
100
+ \u6307\u5B9A\u3057\u305F\u6C7A\u8B70\u6A29\u8005\u3060\u3051\u3092\u5909\u3048\u3001none \u3092\u6307\u5B9A\u3059\u308B\u3068\u672A\u540C\u610F\u306B\u623B\u3057\u307E\u3059\u3002\u540C\u610F\u65E5\u306F\u63D0\u6848\u65E5\u4EE5\u964D\u30FB\u4ECA\u65E5\u4EE5\u524D\u3067\u3059\uFF08\u5916\u308C\u308B\u3068\u30B5\u30FC\u30D0\u304C 422\uFF09\u3002
101
+ \u5168\u54E1\u306E\u540C\u610F\u304C\u63C3\u3046\u3068 confirm \u3067\u78BA\u5B9A\u3067\u304D\u3001\u3059\u3079\u3066\u306E\u8B70\u6848\u304C\u53EF\u6C7A\u30FB\u6C7A\u8B70\u65E5\u306F\u6700\u5F8C\u306E\u540C\u610F\u65E5\u306B\u306A\u308A\u307E\u3059\u3002\u78BA\u5B9A\u5F8C\u306F\u5909\u3048\u3089\u308C\u307E\u305B\u3093\uFF08\u30B5\u30FC\u30D0\u304C 409\uFF09\u3002
102
+ ${EDIT}
103
+
104
+ ${MEETING_RESULT}`,flags:[CONSENT_FLAG],validate:input=>{meetingId(input,"consent");consentBody(input)},plan:input=>({method:"PUT",path:`${MEETINGS_PATH}/${meetingId(input,"consent")}/consents`,body:consentBody(input)})}),meetingWrite({name:"confirm",what:"\u6C7A\u8B70\u7D50\u679C\u306E\u78BA\u5B9A",summary:"\u6C7A\u8B70\u7D50\u679C\u3092\u78BA\u5B9A\u3059\u308B\uFF08\u7248 1 \u304C\u6B8B\u308A\u3001\u4EE5\u5F8C\u306F\u8A02\u6B63\u3067\u3057\u304B\u5909\u3048\u3089\u308C\u306A\u3044\uFF09",usage:"\
105
+ twp corporate meeting confirm <\u4F1A\u8B70ID> --yes",description:`${ID_HELP}
92
106
  \u78BA\u5B9A\u3059\u308B\u3068\u6C7A\u8B70\u7D50\u679C\u306E\u7248 1 \u304C\u8A18\u9332\u3055\u308C\u3001\u4E0B\u6D41\uFF08\u767B\u8A18\u306E\u8D77\u7968\u30FB\u53F0\u5E33/\u540D\u7C3F\u3078\u306E\u4E0B\u66F8\u304D\u53CD\u6620\uFF09\u304C\u52D5\u304D\u51FA\u3057\u307E\u3059\u3002
107
+ \u66F8\u9762\u6C7A\u8B70\u306F\u5168\u54E1\u306E\u540C\u610F\u304C\u63C3\u3063\u3066\u3044\u306A\u3044\u3068\u78BA\u5B9A\u3067\u304D\u305A\uFF08\u30B5\u30FC\u30D0\u304C 422\uFF09\u3001\u78BA\u5B9A\u3059\u308B\u3068\u3059\u3079\u3066\u306E\u8B70\u6848\u304C\u53EF\u6C7A\u30FB\u6C7A\u8B70\u65E5\u306F\u6700\u5F8C\u306E\u540C\u610F\u65E5\u306B\u306A\u308A\u307E\u3059\u3002
93
108
  \u78BA\u5B9A\u5F8C\u306F resolve / agenda-add / agenda-update \u3067\u5909\u3048\u3089\u308C\u307E\u305B\u3093\u3002\u5909\u3048\u308B\u3068\u304D\u306F correct \u3067\u7406\u7531\u3092\u6DFB\u3048\u3066\u7248\u3092\u5897\u3084\u3057\u307E\u3059\u3002
94
109
  ${EDIT}
95
110
 
@@ -0,0 +1,118 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ import"./chunk-VSJBJXZO.js";var CHILD_PROPS=["left","right","condition","child","operand","trueExpr","falseExpr","expression"];function pushChildren(node,stack){const n=node;for(const prop of CHILD_PROPS){const val=n[prop];if(val&&typeof val==="object"&&"type"in val){stack.push(val)}}if(Array.isArray(n.children)){for(const item of n.children){if(!item){continue}stack.push(item);if(item.type==="KeyValuePair"&&item.value){stack.push(item.value)}}}if(Array.isArray(n.bindings)){for(const item of n.bindings){if(!item){continue}
4
+ stack.push(item);if(item.reference){stack.push(item.reference)}}}}function forEachNode(root,visitor){const stack=[root];while(stack.length>0){const current=stack.pop();if(!current){break}if(visitor(current)===false){return}pushChildren(current,stack)}}function countNodes(root){let count=0;forEachNode(root,()=>{count+=1;return true});return count}function findDisallowedFunction(root,options){const{allowedFunctions,disallowedFunctions}=options;if(!allowedFunctions&&!disallowedFunctions){return null}
5
+ let violation=null;forEachNode(root,node=>{if(node.type!=="Function"){return true}const name=node.name;if(allowedFunctions&&!allowedFunctions.includes(name)){violation=`Function '${name}' is not allowed`;return false}if(disallowedFunctions&&disallowedFunctions.includes(name)){violation=`Function '${name}' is disallowed`;return false}return true});return violation}var isObject=obj=>{return obj!==null&&Object.prototype.toString.call(obj)==="[object Object]"};var strictDeepEqual=(first,second)=>{if(first===
6
+ second){return true}if(typeof first!==typeof second){return false}if(Array.isArray(first)&&Array.isArray(second)){if(first.length!==second.length){return false}for(let i=0;i<first.length;i+=1){if(!strictDeepEqual(first[i],second[i])){return false}}return true}if(isObject(first)&&isObject(second)){const keys=Object.keys(first);if(keys.length!==Object.keys(second).length){return false}return keys.every(key=>Object.prototype.hasOwnProperty.call(second,key)&&strictDeepEqual(first[key],second[key]))}
7
+ return false};var isFalse=obj=>{if(obj==null||obj===false){return true}if(typeof obj==="string"){return obj===""}if(typeof obj==="object"){return Array.isArray(obj)?obj.length===0:Object.keys(obj).length===0}return false};var isAlpha=ch=>{return ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch==="_"};var isNum=ch=>{return ch>="0"&&ch<="9"||ch==="-"};var isAlphaNum=ch=>{return isAlpha(ch)||ch>="0"&&ch<="9"};var ensureInteger=value=>{if(!(typeof value==="number")||Math.floor(value)!==value){throw new Error(
8
+ "invalid-value: expecting an integer.")}return value};var ensurePositiveInteger=value=>{if(!(typeof value==="number")||value<0||Math.floor(value)!==value){throw new Error("invalid-value: expecting a non-negative integer.")}return value};var ensureNumbers=(...operands)=>{for(let i=0;i<operands.length;i++){if(operands[i]===null||operands[i]===void 0){throw new Error("not-a-number: undefined")}if(typeof operands[i]!=="number"){throw new Error("not-a-number")}}};var notZero=n=>{n=+n;if(!n){throw new Error(
9
+ "not-a-number: divide by zero")}return n};var binOp=fn=>(left,right)=>{ensureNumbers(left,right);return fn(left,right)};var add=binOp((a,b)=>a+b);var sub=binOp((a,b)=>a-b);var mul=binOp((a,b)=>a*b);var divide=binOp((a,b)=>a/notZero(b));var div=binOp((a,b)=>Math.floor(a/notZero(b)));var mod=binOp((a,b)=>a%notZero(b));var basicTokens={"(":"Lparen",")":"Rparen","*":"Star",",":"Comma",".":"Dot",":":"Colon","@":"Current","]":"Rbracket","{":"Lbrace","}":"Rbrace","+":"Plus","%":"Modulo","?":"Question",
10
+ "\u2212":"Minus","\xD7":"Multiply","\xF7":"Divide"};var operatorStartToken={"!":true,"<":true,"=":true,">":true,"&":true,"|":true,"/":true};var skipChars={" ":true,"\n":true,"\r":true," ":true};var StreamLexer=class{_current=0;_enable_legacy_literals=false;tokenize(stream,options){const tokens=[];this._current=0;this._enable_legacy_literals=options?.enable_legacy_literals||false;let start;let identifier;let token;while(this._current<stream.length){if(isAlpha(stream[this._current])){start=this._current;
11
+ identifier=this.consumeUnquotedIdentifier(stream);tokens.push({start,type:"UnquotedIdentifier",value:identifier})}else if(basicTokens[stream[this._current]]!==void 0){tokens.push({start:this._current,type:basicTokens[stream[this._current]],value:stream[this._current]});this._current+=1}else if(stream[this._current]==="$"){start=this._current;if(this._current+1<stream.length&&isAlpha(stream[this._current+1])){this._current+=1;identifier=this.consumeUnquotedIdentifier(stream);tokens.push({start,type:"\
12
+ Variable",value:identifier})}else{tokens.push({start,type:"Root",value:stream[this._current]});this._current+=1}}else if(stream[this._current]==="-"){if(this._current+1<stream.length&&isNum(stream[this._current+1])){const token2=this.consumeNumber(stream);token2&&tokens.push(token2)}else{const token2={start:this._current,type:"Minus",value:"-"};tokens.push(token2);this._current+=1}}else if(isNum(stream[this._current])){token=this.consumeNumber(stream);tokens.push(token)}else if(stream[this._current]===
13
+ "["){token=this.consumeLBracket(stream);tokens.push(token)}else if(stream[this._current]==='"'){start=this._current;identifier=this.consumeQuotedIdentifier(stream);tokens.push({start,type:"QuotedIdentifier",value:identifier})}else if(stream[this._current]===`'`){start=this._current;identifier=this.consumeRawStringLiteral(stream);tokens.push({start,type:"Literal",value:identifier})}else if(stream[this._current]==="`"){start=this._current;const literal=this.consumeLiteral(stream);tokens.push({start,
14
+ type:"Literal",value:literal})}else if(operatorStartToken[stream[this._current]]!==void 0){token=this.consumeOperator(stream);token&&tokens.push(token)}else if(skipChars[stream[this._current]]!==void 0){this._current+=1}else{const error=new Error(`Syntax error: unknown character: ${stream[this._current]}`);error.name="LexerError";throw error}}return tokens}consumeUnquotedIdentifier(stream){const start=this._current;this._current+=1;while(this._current<stream.length&&isAlphaNum(stream[this._current])){
15
+ this._current+=1}return stream.slice(start,this._current)}consumeUntil(stream,delimiter){const start=this._current;this._current+=1;const len=stream.length;while(this._current<len&&stream[this._current]!==delimiter){if(stream[this._current]==="\\"&&(stream[this._current+1]==="\\"||stream[this._current+1]===delimiter)){this._current+=2}else{this._current+=1}}if(this._current<len){this._current+=1}return stream.slice(start,this._current)}consumeQuotedIdentifier(stream){const raw=this.consumeUntil(
16
+ stream,'"');const[value,ok]=this.parseJSON(raw);if(!ok){const error=new Error("syntax: unexpected end of JSON input");error.name="LexerError";throw error}return value}consumeRawStringLiteral(stream){const raw=this.consumeUntil(stream,"'");if(!raw.endsWith("'")||raw.length<2){const error=new Error("Syntax error: unclosed single quote");error.name="LexerError";throw error}const content=raw.slice(1,-1);return content.replace(/\\(['\\])/g,"$1")}consumeNumber(stream){const start=this._current;this._current+=
17
+ 1;const maxLength=stream.length;while(isNum(stream[this._current])&&this._current<maxLength){this._current+=1}const value=parseInt(stream.slice(start,this._current),10);return{start,value,type:"Number"}}consumeLBracket(stream){const start=this._current;this._current+=1;if(stream[this._current]==="?"){this._current+=1;return{start,type:"Filter",value:"[?"}}if(stream[this._current]==="]"){this._current+=1;return{start,type:"Flatten",value:"[]"}}return{start,type:"Lbracket",value:"["}}consumeOrElse(stream,peek,token,orElse){
18
+ const start=this._current;this._current+=1;if(this._current<stream.length&&stream[this._current]===peek){this._current+=1;return{start,type:orElse,value:stream.slice(start,this._current)}}return{start,type:token,value:stream[start]}}consumeOperator(stream){const start=this._current;const startingChar=stream[start];switch(startingChar){case"!":return this.consumeOrElse(stream,"=","Not","NE");case"<":return this.consumeOrElse(stream,"=","LT","LTE");case">":return this.consumeOrElse(stream,"=","GT",
19
+ "GTE");case"=":return this.consumeOrElse(stream,"=","Assign","EQ");case"&":return this.consumeOrElse(stream,"&","Expref","And");case"|":return this.consumeOrElse(stream,"|","Pipe","Or");case"/":return this.consumeOrElse(stream,"/","Divide","Div")}}consumeLiteral(stream){const raw=this.consumeUntil(stream,"`");const inner=raw.endsWith("`")&&raw.length>1?raw.slice(1,-1):raw.slice(1);const literalString=inner.trimStart().replace("\\`","`");let[literal,ok]=this.parseJSON(literalString);if(!ok&&this.
20
+ _enable_legacy_literals){[literal,ok]=this.parseJSON(`"${literalString}"`)}if(!ok){const error=new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current-1]??""}`);error.name="LexerError";throw error}return literal}parseJSON(text){try{const json=JSON.parse(text);return[json,true]}catch{return[null,false]}}};var Lexer=new StreamLexer;var Lexer_default=Lexer;var bindingPower={["EOF"]:0,["Variable"]:0,["UnquotedIdentifier"]:0,["QuotedIdentifie\
21
+ r"]:0,["Rbracket"]:0,["Rparen"]:0,["Comma"]:0,["Rbrace"]:0,["Number"]:0,["Current"]:0,["Expref"]:0,["Root"]:0,["Assign"]:1,["Pipe"]:1,["Question"]:2,["Or"]:3,["And"]:4,["EQ"]:5,["GT"]:5,["LT"]:5,["GTE"]:5,["LTE"]:5,["NE"]:5,["Minus"]:6,["Plus"]:6,["Div"]:7,["Divide"]:7,["Modulo"]:7,["Multiply"]:7,["Flatten"]:9,["Star"]:20,["Filter"]:21,["Dot"]:40,["Not"]:45,["Lbrace"]:50,["Lbracket"]:55,["Lparen"]:60};var DEFAULT_MAX_DEPTH=1e3;var TokenParser=class _TokenParser{index=0;tokens=[];depth=0;maxDepth=DEFAULT_MAX_DEPTH;nodeCount=0;maxNodes;parse(expression,options){
22
+ this.loadTokens(expression,options||{enable_legacy_literals:false});this.index=0;this.depth=0;this.nodeCount=0;this.maxDepth=options?.maxDepth??DEFAULT_MAX_DEPTH;this.maxNodes=options?.maxNodes;const ast=this.expression(0);if(this.lookahead(0)!=="EOF"){const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: unexpected token type: ${token.type}, value: ${token.value}`)}if(this.maxNodes!==void 0&&countNodes(ast)>this.maxNodes){throw new Error(`Expression exceeds maximum allowed nod\
23
+ e count of ${this.maxNodes}`)}return ast}loadTokens(expression,options){this.tokens=Lexer_default.tokenize(expression,options);this.tokens.push({type:"EOF",value:"",start:expression.length})}expression(rbp){if(this.depth>=this.maxDepth){throw new Error(`Expression exceeds maximum allowed depth of ${this.maxDepth}`)}this.depth+=1;this.trackNode();try{const leftToken=this.lookaheadToken(0);this.advance();let left=this.nud(leftToken);let currentTokenType=this.lookahead(0);while(rbp<bindingPower[currentTokenType]){
24
+ this.trackNode();this.advance();left=this.led(currentTokenType,left);currentTokenType=this.lookahead(0)}return left}finally{this.depth-=1}}trackNode(){this.nodeCount+=1;if(this.maxNodes!==void 0&&this.nodeCount>this.maxNodes){throw new Error(`Expression exceeds maximum allowed node count of ${this.maxNodes}`)}}lookahead(offset){return this.tokens[this.index+offset].type}lookaheadToken(offset){return this.tokens[this.index+offset]}advance(){this.index+=1}nud(token){switch(token.type){case"Variabl\
25
+ e":return{type:"Variable",name:token.value};case"Literal":return{type:"Literal",value:token.value};case"UnquotedIdentifier":{if(_TokenParser.isKeyword(token,"let")&&this.lookahead(0)==="Variable"){return this.parseLetExpression()}else{return{type:"Field",name:token.value}}}case"QuotedIdentifier":if(this.lookahead(0)==="Lparen"){throw new Error("Syntax error: quoted identifier not allowed for function names.")}else{return{type:"Field",name:token.value}}case"Not":{const child=this.expression(bindingPower.
26
+ Not);return{type:"NotExpression",child}}case"Minus":{const child=this.expression(bindingPower.Minus);return{type:"Unary",operator:token.type,operand:child}}case"Plus":{const child=this.expression(bindingPower.Plus);return{type:"Unary",operator:token.type,operand:child}}case"Star":{const left={type:"Identity"};return{type:"ValueProjection",left,right:this.parseProjectionRHS(bindingPower.Star)}}case"Filter":return this.led(token.type,{type:"Identity"});case"Lbrace":return this.parseMultiselectHash();case"\
27
+ Flatten":{const left={type:"Flatten",child:{type:"Identity"}};const right=this.parseProjectionRHS(bindingPower.Flatten);return{type:"Projection",left,right}}case"Lbracket":{if(this.lookahead(0)==="Number"||this.lookahead(0)==="Colon"){const right=this.parseIndexExpression();return this.projectIfSlice({type:"Identity"},right)}if(this.lookahead(0)==="Star"&&this.lookahead(1)==="Rbracket"){this.advance();this.advance();const right=this.parseProjectionRHS(bindingPower.Star);return{left:{type:"Identi\
28
+ ty"},right,type:"Projection"}}return this.parseMultiselectList()}case"Current":return{type:"Current"};case"Root":return{type:"Root"};case"Expref":{const child=this.expression(bindingPower.Expref);return{type:"ExpressionReference",child}}case"Lparen":{const expression=this.expression(0);this.match("Rparen");return expression}default:this.errorToken(token)}}led(tokenName,left){switch(tokenName){case"Question":{const trueExpr=this.expression(0);this.match("Colon");const falseExpr=this.expression(0);
29
+ return{type:"Ternary",condition:left,trueExpr,falseExpr}}case"Dot":{const rbp=bindingPower.Dot;if(this.lookahead(0)!=="Star"){const right2=this.parseDotRHS(rbp);return{type:"Subexpression",left,right:right2}}this.advance();const right=this.parseProjectionRHS(rbp);return{type:"ValueProjection",left,right}}case"Pipe":{const right=this.expression(bindingPower.Pipe);return{type:"Pipe",left,right}}case"Or":{const right=this.expression(bindingPower.Or);return{type:"OrExpression",left,right}}case"And":{
30
+ const right=this.expression(bindingPower.And);return{type:"AndExpression",left,right}}case"Lparen":{if(left.type!=="Field"){throw new Error("Syntax error: expected a Field node")}const name=left.name;const args=this.parseCommaSeparatedExpressionsUntilToken("Rparen");const node={name,type:"Function",children:args};return node}case"Filter":{const condition=this.expression(0);this.match("Rbracket");const right=this.lookahead(0)==="Flatten"?{type:"Identity"}:this.parseProjectionRHS(bindingPower.Filter);
31
+ return{type:"FilterProjection",left,right,condition}}case"Flatten":{const leftNode={type:"Flatten",child:left};const right=this.parseProjectionRHS(bindingPower.Flatten);return{type:"Projection",left:leftNode,right}}case"Assign":{const leftNode=left;const right=this.expression(0);return{type:"Binding",variable:leftNode.name,reference:right}}case"EQ":case"NE":case"GT":case"GTE":case"LT":case"LTE":return this.parseComparator(left,tokenName);case"Plus":case"Minus":case"Multiply":case"Star":case"Divi\
32
+ de":case"Modulo":case"Div":return this.parseArithmetic(left,tokenName);case"Lbracket":{const token=this.lookaheadToken(0);if(token.type==="Number"||token.type==="Colon"){const right2=this.parseIndexExpression();return this.projectIfSlice(left,right2)}this.match("Star");this.match("Rbracket");const right=this.parseProjectionRHS(bindingPower.Star);return{type:"Projection",left,right}}default:return this.errorToken(this.lookaheadToken(0))}}static isKeyword(token,keyword){return token.type==="Unquot\
33
+ edIdentifier"&&token.value===keyword}match(tokenType){if(this.lookahead(0)===tokenType){this.advance();return}else{const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: expected ${tokenType}, got: ${token.type}`)}}errorToken(token,message=""){const error=new Error(message||`Syntax error: invalid token (${token.type}): "${token.value}"`);error.name="ParserError";throw error}parseIndexExpression(){if(this.lookahead(0)==="Colon"||this.lookahead(1)==="Colon"){return this.parseSliceExpression()}
34
+ const value=Number(this.lookaheadToken(0).value);this.advance();this.match("Rbracket");return{type:"Index",value}}projectIfSlice(left,right){const indexExpr={type:"IndexExpression",left,right};if(right.type==="Slice"){const rhs=this.parseProjectionRHS(bindingPower.Star);if(rhs.type==="Identity"){return indexExpr}return{left:indexExpr,right:rhs,type:"Projection"}}return indexExpr}parseSliceExpression(){const parts=[null,null,null];let index=0;let current=this.lookaheadToken(0);while(current.type!=
35
+ "Rbracket"&&index<3){if(current.type==="Colon"){index++;if(index===3){this.errorToken(this.lookaheadToken(0),"Syntax error, too many colons in slice expression")}this.advance()}else if(current.type==="Number"&&parts[index]===null){const part=this.lookaheadToken(0).value;parts[index]=part;this.advance()}else{const next=this.lookaheadToken(0);this.errorToken(next,`Syntax error, unexpected token: ${next.value}(${next.type})`)}current=this.lookaheadToken(0)}this.match("Rbracket");const[start,stop,step]=parts;
36
+ return{type:"Slice",start,stop,step}}parseLetExpression(){const separated=this.parseCommaSeparatedExpressionsUntilKeyword("in");const expression=this.expression(0);const bindings=separated.map(binding=>binding);return{type:"LetExpression",bindings,expression}}parseCommaSeparatedExpressionsUntilKeyword(keyword){return this.parseCommaSeparatedExpressionsUntil(()=>{return _TokenParser.isKeyword(this.lookaheadToken(0),keyword)},()=>{this.advance()})}parseCommaSeparatedExpressionsUntilToken(token){return this.
37
+ parseCommaSeparatedExpressionsUntil(()=>{return this.lookahead(0)===token},()=>{return this.match(token)})}parseCommaSeparatedExpressionsUntil(isEndToken,matchEndToken){const args=[];let expression;while(!isEndToken()){expression=this.expression(0);if(this.lookahead(0)==="Comma"){this.match("Comma")}args.push(expression)}matchEndToken();return args}parseComparator(left,comparator){const right=this.expression(bindingPower[comparator]);return{type:"Comparator",name:comparator,left,right}}parseArithmetic(left,operator){
38
+ const right=this.expression(bindingPower[operator]);return{type:"Arithmetic",operator,left,right}}parseDotRHS(rbp){const lookahead=this.lookahead(0);const exprTokens=["UnquotedIdentifier","QuotedIdentifier","Star"];if(exprTokens.includes(lookahead)){return this.expression(rbp)}if(lookahead==="Lbracket"){this.match("Lbracket");return this.parseMultiselectList()}if(lookahead==="Lbrace"){this.match("Lbrace");return this.parseMultiselectHash()}const token=this.lookaheadToken(0);this.errorToken(token,
39
+ `Syntax error, unexpected token: ${token.value}(${token.type})`)}parseProjectionRHS(rbp){if(bindingPower[this.lookahead(0)]<10){return{type:"Identity"}}if(this.lookahead(0)==="Lbracket"){return this.expression(rbp)}if(this.lookahead(0)==="Filter"){return this.expression(rbp)}if(this.lookahead(0)==="Dot"){this.match("Dot");return this.parseDotRHS(rbp)}const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error, unexpected token: ${token.value}(${token.type})`)}parseMultiselectList(){const expressions=[];
40
+ while(this.lookahead(0)!=="Rbracket"){const expression=this.expression(0);expressions.push(expression);if(this.lookahead(0)==="Comma"){this.match("Comma");if(this.lookahead(0)==="Rbracket"){throw new Error("Syntax error: unexpected token Rbracket")}}else if(this.lookahead(0)!=="Rbracket"){const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: unexpected token: ${token.value}(${token.type})`)}}this.match("Rbracket");return{type:"MultiSelectList",children:expressions}}parseMultiselectHash(){
41
+ const pairs=[];const identifierTypes=["UnquotedIdentifier","QuotedIdentifier"];let keyToken;let keyName;let value;for(;;){keyToken=this.lookaheadToken(0);if(!identifierTypes.includes(keyToken.type)){throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`)}keyName=keyToken.value;this.advance();this.match("Colon");value=this.expression(0);pairs.push({value,type:"KeyValuePair",name:keyName});if(this.lookahead(0)==="Comma"){this.match("Comma")}else if(this.lookahead(0)===
42
+ "Rbrace"){this.match("Rbrace");break}else{const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: unexpected token: ${token.value}(${token.type})`)}}return{type:"MultiSelectHash",children:pairs}}};var Parser=new TokenParser;var Parser_default=Parser;var normalizeBounds=(len,start,end)=>{let s2=ensureInteger(start??0);if(s2<0){s2=Math.max(0,len+s2)}let e=ensureInteger(end??len);if(e<0){e=Math.max(0,len+e)}return[s2,Math.min(len,e)]};var findFirst=(subject,sub2,start,end)=>{if(!subject||
43
+ !sub2){return null}const chars=[...subject];const[s2,e]=normalizeBounds(chars.length,start,end);const target=chars.slice(s2,e).join("");const idx=target.indexOf(sub2);return idx===-1?null:[...target.slice(0,idx)].length+s2};var findLast=(subject,sub2,start,end)=>{if(!subject||!sub2){return null}const chars=[...subject];const[s2,e]=normalizeBounds(chars.length,start,end);const target=chars.slice(s2,e).join("");const idx=target.lastIndexOf(sub2);return idx===-1?null:[...target.slice(0,idx)].length+
44
+ s2};var createPad=(isLeft,name)=>(subject,width,padding=" ")=>{if([...padding].length!==1){throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`)}ensurePositiveInteger(width);if(!subject){return""}const padLen=width-[...subject].length;if(padLen<=0){return subject}const pad=padding.repeat(padLen);return isLeft?pad+subject:subject+pad};var padLeft=createPad(true,"pad_left");var padRight=createPad(false,"pad_right");var replace=(subject,string,by,count)=>{
45
+ if(count===0){return subject}const parts=subject.split(string);if(count===null||count===void 0){return parts.join(by)}ensurePositiveInteger(count);const head=parts.slice(0,count+1).join(by);const tail=parts.slice(count+1).join(string);return tail.length>0?head+string+tail:head};var split=(subject,search2,count)=>{if(subject.length===0&&search2.length===0){return[]}if(count!==null&&count!==void 0){ensurePositiveInteger(count);if(count===0){return[subject]}}const parts=search2===""?[...subject]:subject.
46
+ split(search2);if(count===null||count===void 0){return parts}return[...parts.slice(0,count),parts.slice(count).join(search2)]};var trimImpl=(subject,pattern,chars)=>{const charClass=chars?chars.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"):"\\s\x85";return subject.replace(new RegExp(pattern.replace("%s",charClass),"u"),"")};var trimLeft=(subject,chars)=>trimImpl(subject,"^[%s]+",chars);var trimRight=(subject,chars)=>trimImpl(subject,"[%s]+$",chars);var trim=(subject,chars)=>trimLeft(trimRight(subject,
47
+ chars),chars);var compareStrings=(a,b)=>{if(a===b){return 0}const itA=a[Symbol.iterator]();const itB=b[Symbol.iterator]();while(true){const nextA=itA.next();const nextB=itB.next();if(nextA.done||nextB.done){return nextA.done&&nextB.done?0:nextA.done?-1:1}if(nextA.value!==nextB.value){return nextA.value.codePointAt(0)>nextB.value.codePointAt(0)?1:-1}}};var Text=class{constructor(string){this.string=string}get length(){return[...this.string].length}compareTo(other){return compareStrings(this.string,
48
+ other)}static comparer=compareStrings;static compareStrings=compareStrings};var InputArgument=(InputArgument2=>{InputArgument2[InputArgument2["TYPE_NUMBER"]=0]="TYPE_NUMBER";InputArgument2[InputArgument2["TYPE_ANY"]=1]="TYPE_ANY";InputArgument2[InputArgument2["TYPE_STRING"]=2]="TYPE_STRING";InputArgument2[InputArgument2["TYPE_ARRAY"]=3]="TYPE_ARRAY";InputArgument2[InputArgument2["TYPE_OBJECT"]=4]="TYPE_OBJECT";InputArgument2[InputArgument2["TYPE_BOOLEAN"]=5]="TYPE_BOOLEAN";InputArgument2[InputArgument2["\
49
+ TYPE_EXPREF"]=6]="TYPE_EXPREF";InputArgument2[InputArgument2["TYPE_NULL"]=7]="TYPE_NULL";InputArgument2[InputArgument2["TYPE_ARRAY_NUMBER"]=8]="TYPE_ARRAY_NUMBER";InputArgument2[InputArgument2["TYPE_ARRAY_STRING"]=9]="TYPE_ARRAY_STRING";InputArgument2[InputArgument2["TYPE_ARRAY_OBJECT"]=10]="TYPE_ARRAY_OBJECT";InputArgument2[InputArgument2["TYPE_ARRAY_ARRAY"]=11]="TYPE_ARRAY_ARRAY";return InputArgument2})(InputArgument||{});var ARRAY_SUBTYPES={[8]:0,[10]:4,[9]:2,[11]:3};var JSON_NUMBER_REGEX=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
50
+ var s=(...types)=>types.map(t=>({types:Array.isArray(t)?t:[t]}));var opt=(...types)=>types.map(t=>({types:Array.isArray(t)?t:[t],optional:true}));var variadic=(...types)=>types.map(t=>({types:Array.isArray(t)?t:[t],variadic:true}));var optVariadic=(...types)=>types.map(t=>({types:Array.isArray(t)?t:[t],variadic:true,optional:true}));var{TYPE_NUMBER:NUM,TYPE_ANY:ANY,TYPE_STRING:STR,TYPE_ARRAY:ARR,TYPE_OBJECT:OBJ,TYPE_EXPREF:EXP,TYPE_ARRAY_NUMBER:ARR_NUM,TYPE_ARRAY_STRING:ARR_STR,TYPE_ARRAY_ARRAY:ARR_ARR}=InputArgument;
51
+ var Runtime=class{_interpreter;_functionTable;_customFunctions=new Set;TYPE_NAME_TABLE=Object.freeze(["number","any","string","array","object","boolean","expression","null","Array<number>","Array<string>","Array<object>","Array<Array<any>>"]);constructor(interpreter){this._interpreter=interpreter;this._functionTable=this.buildFunctionTable()}buildFunctionTable(){return{abs:{_func:([v])=>Math.abs(v),_signature:s(NUM)},ceil:{_func:([v])=>Math.ceil(v),_signature:s(NUM)},floor:{_func:([v])=>Math.floor(
52
+ v),_signature:s(NUM)},lower:{_func:([s2])=>s2.toLowerCase(),_signature:s(STR)},upper:{_func:([s2])=>s2.toUpperCase(),_signature:s(STR)},keys:{_func:([o])=>Object.keys(o),_signature:s(OBJ)},values:{_func:([o])=>Object.values(o),_signature:s(OBJ)},avg:{_func:([arr])=>arr&&arr.length?arr.reduce((a,b)=>a+b,0)/arr.length:null,_signature:s(ARR_NUM)},contains:{_func:this.functionContains,_signature:s([STR,ARR],ANY)},ends_with:{_func:([str,suf])=>str.endsWith(suf),_signature:s(STR,STR)},find_first:{_func:([
53
+ s2,sub2,st,en])=>findFirst(s2,sub2,st,en),_signature:[...s(STR,STR),...opt(NUM,NUM)]},find_last:{_func:([s2,sub2,st,en])=>findLast(s2,sub2,st,en),_signature:[...s(STR,STR),...opt(NUM,NUM)]},from_items:{_func:this.functionFromItems,_signature:s(ARR_ARR)},group_by:{_func:this.functionGroupBy,_signature:s(ARR,EXP)},items:{_func:([o])=>Object.entries(o),_signature:s(OBJ)},join:{_func:([sep,arr])=>arr.join(sep),_signature:s(STR,ARR_STR)},length:{_func:([v])=>typeof v==="string"?[...v].length:Array.isArray(
54
+ v)?v.length:Object.keys(v).length,_signature:s([STR,ARR,OBJ])},map:{_func:this.functionMap,_signature:s(EXP,ARR)},max:{_func:([v])=>this.findExtreme(v,cmp=>cmp>0,Math.max),_signature:s([ARR_NUM,ARR_STR])},max_by:{_func:args=>this.findExtremeBy(args,cmp=>cmp>0),_signature:s(ARR,EXP)},merge:{_func:args=>Object.assign({},...args),_signature:optVariadic(OBJ)},min:{_func:([v])=>this.findExtreme(v,cmp=>cmp<0,Math.min),_signature:s([ARR_NUM,ARR_STR])},min_by:{_func:args=>this.findExtremeBy(args,cmp=>cmp<
55
+ 0),_signature:s(ARR,EXP)},not_null:{_func:args=>args.find(arg=>arg!==null)??null,_signature:variadic(ANY)},pad_left:{_func:([s2,w,p])=>padLeft(s2,w,p),_signature:[...s(STR,NUM),...opt(STR)]},pad_right:{_func:([s2,w,p])=>padRight(s2,w,p),_signature:[...s(STR,NUM),...opt(STR)]},replace:{_func:([s2,str,by,c])=>replace(s2,str,by,c),_signature:[...s(STR,STR,STR),...opt(NUM)]},reverse:{_func:([v])=>typeof v==="string"?[...v].reverse().join(""):[...v].reverse(),_signature:s([STR,ARR])},sort:{_func:this.
56
+ functionSort,_signature:s([ARR_STR,ARR_NUM])},sort_by:{_func:this.functionSortBy,_signature:s(ARR,EXP)},split:{_func:([s2,sub2,c])=>split(s2,sub2,c),_signature:[...s(STR,STR),...opt(NUM)]},starts_with:{_func:([str,pre])=>str.startsWith(pre),_signature:s(STR,STR)},sum:{_func:([arr])=>arr.reduce((x,y)=>x+y,0),_signature:s(ARR_NUM)},to_array:{_func:([v])=>Array.isArray(v)?v:[v],_signature:s(ANY)},to_number:{_func:this.functionToNumber,_signature:s(ANY)},to_string:{_func:([v])=>typeof v==="string"?v:
57
+ JSON.stringify(v),_signature:s(ANY)},trim:{_func:([s2,c])=>trim(s2,c),_signature:[...s(STR),...opt(STR)]},trim_left:{_func:([s2,c])=>trimLeft(s2,c),_signature:[...s(STR),...opt(STR)]},trim_right:{_func:([s2,c])=>trimRight(s2,c),_signature:[...s(STR),...opt(STR)]},type:{_func:this.functionType,_signature:s(ANY)},zip:{_func:this.functionZip,_signature:variadic(ARR)}}}registerFunction(name,customFunction,signature,options){const result=this._registerInternal(name,customFunction,signature,options);if(!result.
58
+ success){throw new Error(result.message)}}_registerInternal(name,customFunction,signature,options={}){if(!name||typeof name!=="string"||name.trim()===""){return{success:false,reason:"invalid-name",message:"Function name must be a non-empty string"}}try{this.validateInputSignatures(name,signature)}catch(error){return{success:false,reason:"invalid-signature",message:error instanceof Error?error.message:"Invalid function signature"}}const{override=false,warn=false}=options;const exists=name in this.
59
+ _functionTable;if(exists&&!override){return{success:false,reason:"already-exists",message:`Function already defined: ${name}(). Use { override: true } to replace it.`}}if(exists&&override&&warn){console.warn(`Warning: Overriding existing function: ${name}()`)}this._functionTable[name]={_func:customFunction.bind(this),_signature:signature};this._customFunctions.add(name);const message=exists?`Function ${name}() overridden successfully`:`Function ${name}() registered successfully`;return{success:true,
60
+ message}}register(name,customFunction,signature,options={}){return this._registerInternal(name,customFunction,signature,options)}unregister(name){if(!this._customFunctions.has(name)){return false}delete this._functionTable[name];this._customFunctions.delete(name);return true}isRegistered(name){return name in this._functionTable}getRegistered(){return Object.keys(this._functionTable)}getCustomFunctions(){return Array.from(this._customFunctions)}clearCustomFunctions(){for(const name of this._customFunctions){
61
+ delete this._functionTable[name]}this._customFunctions.clear()}callFunction(name,resolvedArgs){const functionEntry=this._functionTable[name];if(functionEntry===void 0){throw new Error(`Unknown function: ${name}()`)}this.validateArgs(name,resolvedArgs,functionEntry._signature);return functionEntry._func.call(this,resolvedArgs)}validateInputSignatures(name,signature){for(let i=0;i<signature.length;i+=1){if("variadic"in signature[i]&&i!==signature.length-1){throw new Error(`Invalid arity: ${name}()\
62
+ 'variadic' argument ${i+1} must occur last`)}}}validateArgs(name,args,signature){this.validateInputSignatures(name,signature);this.validateArity(name,args,signature);this.validateTypes(name,args,signature)}validateArity(name,args,signature){const numberOfRequiredArgs=signature.filter(argSignature=>!(argSignature.optional??false)).length;const lastArgIsVariadic=signature[signature.length-1]?.variadic??false;const tooFewArgs=args.length<numberOfRequiredArgs;const tooManyArgs=args.length>signature.
63
+ length;if(lastArgIsVariadic&&tooFewArgs||!lastArgIsVariadic&&(tooFewArgs||tooManyArgs)){const tooFewModifier=tooFewArgs&&(!lastArgIsVariadic&&numberOfRequiredArgs>1||lastArgIsVariadic)?"at least ":"";const pluralized=signature.length>1;throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized&&"s"||""} but received ${args.length}`)}}validateTypes(name,args,signature){const lastSigIndex=signature.length-1;const isVariadic=signature[lastSigIndex]?.
64
+ variadic??false;for(let i=0;i<args.length;i+=1){const sig=i<signature.length?signature[i]:isVariadic?signature[lastSigIndex]:void 0;if(!sig){continue}const currentSpec=sig.types;const actualType=this.getTypeName(args[i]);if(actualType===void 0){continue}const typeMatched=currentSpec.some(expectedType=>this.typeMatches(actualType,expectedType,args[i]));if(!typeMatched){const expected=currentSpec.map(typeId=>this.TYPE_NAME_TABLE[typeId]).join(" | ");throw new Error(`Invalid type: ${name}() expecte\
65
+ d argument ${i+1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`)}}}typeMatches(actual,expected,argValue){if(expected===1){return true}const subtype=ARRAY_SUBTYPES[expected];if(subtype!==void 0){if(actual!==3){return false}const array=argValue;return array.every(item=>{const typeName=this.getTypeName(item);return typeName===void 0||this.typeMatches(typeName,subtype,item)})}return actual===expected}getTypeName(obj){if(obj===null){return 7}if(typeof obj===
66
+ "string"){return 2}if(typeof obj==="number"){return 0}if(typeof obj==="boolean"){return 5}if(Array.isArray(obj)){return 3}if(typeof obj==="object"){if(obj.expref){return 6}return 4}return}createKeyFunction(exprefNode,allowedTypes){const interpreter=this._interpreter;const keyFunc=x=>{const current=interpreter.visit(exprefNode,x);if(!allowedTypes.includes(this.getTypeName(current))){const msg=`Invalid type: expected one of (${allowedTypes.map(t=>this.TYPE_NAME_TABLE[t]).join(" | ")}), received ${this.
67
+ TYPE_NAME_TABLE[this.getTypeName(current)]}`;throw new Error(msg)}return current};return keyFunc}functionContains=([searchable,searchValue])=>{if(Array.isArray(searchable)){const array=searchable;return array.includes(searchValue)}if(typeof searchable==="string"){const text=searchable;if(typeof searchValue==="string"){return text.includes(searchValue)}return false}return null};functionFromItems=([array])=>{for(const pair of array){if(pair.length!==2||typeof pair[0]!=="string"){throw new Error("i\
68
+ nvalid value, each array must contain two elements, a pair of string and value")}}return Object.fromEntries(array)};functionGroupBy=([array,exprefNode])=>{const interpreter=this._interpreter;if(!interpreter){return{}}const groups=new Map;for(const item of array){const raw=interpreter.visit(exprefNode,item);if(raw===null||raw===void 0){continue}if(typeof raw!=="string"){const type=this.getTypeName(raw);throw new Error(`Invalid type: expected one of (${this.TYPE_NAME_TABLE[2]}), received ${this.TYPE_NAME_TABLE[type]}`)}
69
+ let group=groups.get(raw);if(!group){group=[];groups.set(raw,group)}group.push(item)}return Object.fromEntries(groups)};functionMap=([exprefNode,elements])=>{if(!this._interpreter){return[]}const mapped=[];const interpreter=this._interpreter;for(let i=0;i<elements.length;i+=1){mapped.push(interpreter.visit(exprefNode,elements[i]))}return mapped};findExtreme(inputValue,isBetter,mathFn){if(!inputValue.length){return null}if(this.getTypeName(inputValue[0])===0){return mathFn(...inputValue)}const elements=inputValue;
70
+ let extreme=elements[0];for(let i=1;i<elements.length;i+=1){if(isBetter(Text.comparer(elements[i],extreme))){extreme=elements[i]}}return extreme}findExtremeBy(resolvedArgs,isBetter){const resolvedArray=resolvedArgs[0];if(!resolvedArray.length){return null}const exprefNode=resolvedArgs[1];const interpreter=this._interpreter;if(!interpreter){return null}const firstKey=interpreter.visit(exprefNode,resolvedArray[0]);const firstType=this.getTypeName(firstKey);if(firstType!==0&&firstType!==2){throw new Error(
71
+ `Invalid type: expected one of (${this.TYPE_NAME_TABLE[0]} | ${this.TYPE_NAME_TABLE[2]}), received ${this.TYPE_NAME_TABLE[firstType]}`)}let extremeRecord=resolvedArray[0];let extremeKey=firstKey;for(let i=1;i<resolvedArray.length;i+=1){const currentKey=interpreter.visit(exprefNode,resolvedArray[i]);const currentType=this.getTypeName(currentKey);if(currentType!==firstType){throw new Error(`Invalid type: expected (${this.TYPE_NAME_TABLE[firstType]}), received ${this.TYPE_NAME_TABLE[currentType]}`)}
72
+ const cmp=firstType===0?currentKey-extremeKey:Text.comparer(currentKey,extremeKey);if(isBetter(cmp)){extremeKey=currentKey;extremeRecord=resolvedArray[i]}}return extremeRecord}functionSort=([inputValue])=>inputValue.length<=1?inputValue:typeof inputValue[0]==="string"?[...inputValue].sort(Text.comparer):[...inputValue].sort((a,b)=>a-b);functionSortBy=resolvedArgs=>{const sortedArray=[...resolvedArgs[0]];if(sortedArray.length===0){return sortedArray}const interpreter=this._interpreter;const exprefNode=resolvedArgs[1];
73
+ const requiredType=this.getTypeName(interpreter.visit(exprefNode,sortedArray[0]));if(requiredType===void 0||![0,2].includes(requiredType)){const typeName=requiredType!==void 0?this.TYPE_NAME_TABLE[requiredType]:"undefined";throw new Error(`Invalid type: unexpected type (${typeName})`)}if(sortedArray.length===1){return sortedArray}function throwInvalidTypeError(rt,item){throw new Error(`Invalid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`)}
74
+ return sortedArray.sort((a,b)=>{const exprA=interpreter.visit(exprefNode,a);const exprB=interpreter.visit(exprefNode,b);if(this.getTypeName(exprA)!==requiredType){throwInvalidTypeError(this,exprA)}else if(this.getTypeName(exprB)!==requiredType){throwInvalidTypeError(this,exprB)}if(requiredType===2){return Text.comparer(exprA,exprB)}return exprA-exprB})};functionToNumber=([inputValue])=>{const typeName=this.getTypeName(inputValue);if(typeName===0){return inputValue}if(typeName===2){const str=inputValue;
75
+ if(JSON_NUMBER_REGEX.test(str)){const convertedValue=Number(str);if(!isNaN(convertedValue)){return convertedValue}}}return null};functionType=([inputValue])=>{const type=this.getTypeName(inputValue);const name=type!==void 0?this.TYPE_NAME_TABLE[type]:void 0;if(!name){throw new Error("invalid-type")}return name};functionZip=array=>{const length=Math.min(...array.map(arr=>arr.length));return Array.from({length},(_,index)=>array.map(arr=>arr[index]))}};var ScopeChain=class _ScopeChain{inner=void 0;data={};get currentScopeData(){
76
+ return this.data}withScope(data){const outer=new _ScopeChain;outer.inner=this;outer.data=data;return outer}hasValue(identifier){if(Object.prototype.hasOwnProperty.call(this.data,identifier)){return true}if(this.inner){return this.inner.hasValue(identifier)}return false}getValue(identifier){if(Object.prototype.hasOwnProperty.call(this.data,identifier)){return this.data[identifier]}if(this.inner){return this.inner.getValue(identifier)}return null}};var emptyScopeChain=new ScopeChain;var TreeInterpreter=class _TreeInterpreter{runtime;_rootValue=null;_scope;_options;_depth=0;_maxDepth=DEFAULT_MAX_DEPTH;_deadline=0;constructor(options){
77
+ this.runtime=new Runtime(this);this._scope=new ScopeChain;this._maxDepth=options?.maxDepth??DEFAULT_MAX_DEPTH;if(options){this._options=options;this._deadline=options.timeoutMs!==void 0?Date.now()+options.timeoutMs:0}}withScope(scope){const interpreter=new _TreeInterpreter(this._options);interpreter.runtime=this.runtime;interpreter._rootValue=this._rootValue;interpreter._scope=this._scope.withScope(scope);interpreter._depth=this._depth;interpreter._maxDepth=this._maxDepth;interpreter._deadline=this.
78
+ _deadline;return interpreter}search(node,value,options){if(options?.maxNodes!==void 0&&countNodes(node)>options.maxNodes){throw new Error(`Expression exceeds maximum allowed node count of ${options.maxNodes}`)}this._rootValue=value;this._scope=emptyScopeChain;this._options=options;this._maxDepth=options?.maxDepth??DEFAULT_MAX_DEPTH;this._depth=0;this._deadline=options?.timeoutMs!==void 0?Date.now()+options.timeoutMs:0;const result=this.visit(node,value);this.checkOutputSize(result);return result}checkOutputSize(val){
79
+ const max=this._options?.maxOutputSize;if(max===void 0||val==null){return}const size=Array.isArray(val)||typeof val==="string"?val.length:typeof val==="object"?Object.keys(val).length:0;if(size>max){throw new Error(`Output size exceeds maximum allowed size of ${max}`)}}collect(target,item){target.push(item);if(this._options?.maxOutputSize!==void 0&&target.length>this._options.maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${this._options.maxOutputSize}`)}}evaluateProjectionItems(items,right){
80
+ const collected=[];if(right.type==="Field"){const key=right.name;for(let i=0;i<items.length;i++){if(this._deadline>0&&Date.now()>=this._deadline){throw new Error(`Query execution timed out after ${this._options?.timeoutMs}ms`)}const elem=items[i];if(!elem||typeof elem!=="object"||Array.isArray(elem)){continue}if(!Object.prototype.hasOwnProperty.call(elem,key)){continue}const val=elem[key];if(val!==void 0&&val!==null){this.collect(collected,val)}}return collected}if(right.type==="Identity"){for(let i=0;i<
81
+ items.length;i++){const elem=items[i];if(elem!==null){this.collect(collected,elem)}}return collected}for(const elem of items){const current=this.visit(right,elem);if(current!==null){this.collect(collected,current)}}return collected}visit(node,value){if(this._deadline>0&&Date.now()>=this._deadline){throw new Error(`Query execution timed out after ${this._options?.timeoutMs}ms`)}if(this._depth>=this._maxDepth){throw new Error(`Evaluation exceeds maximum allowed depth of ${this._maxDepth}`)}this._depth+=
82
+ 1;try{return this.evaluateNode(node,value)}finally{this._depth-=1}}evaluateNode(node,value){switch(node.type){case"Ternary":{const condition=this.visit(node.condition,value);if(!isFalse(condition)){return this.visit(node.trueExpr,value)}return this.visit(node.falseExpr,value)}case"Field":const identifier=node.name;if(value===null||typeof value!=="object"||Array.isArray(value)){return null}return Object.prototype.hasOwnProperty.call(value,identifier)?value[identifier]??null:null;case"LetExpressio\
83
+ n":{const scope={};for(const binding of node.bindings){const bound=this.visit(binding,value);for(const key of Object.keys(bound)){Object.defineProperty(scope,key,{value:bound[key],enumerable:true,writable:true,configurable:true})}}return this.withScope(scope).visit(node.expression,value)}case"Binding":{const{variable,reference}=node;const result=this.visit(reference,value);const binding={};Object.defineProperty(binding,variable,{value:result,enumerable:true,writable:true,configurable:true});return binding}case"\
84
+ Variable":{const variable=node.name;if(!this._scope.hasValue(variable)){throw new Error(`Error referencing undefined variable ${variable}`)}return this._scope.getValue(variable)}case"IndexExpression":return this.visit(node.right,this.visit(node.left,value));case"Subexpression":{const result=this.visit(node.left,value);return result!=null?this.visit(node.right,result)??null:null}case"Index":{if(!Array.isArray(value)){return null}const index=node.value<0?value.length+node.value:node.value;return value[index]??
85
+ null}case"Slice":{if(!Array.isArray(value)&&typeof value!=="string"){return null}const target=typeof value==="string"?[...value]:value;const{start,stop,step}=this.computeSliceParams(target.length,node);const sliced=this.slice(target,start,stop,step);const res=typeof value==="string"?sliced.join(""):sliced;this.checkOutputSize(res);return res}case"Projection":{const{left,right}=node;const allowString=left.type==="IndexExpression"&&left.right.type==="Slice";const base=this.visit(left,value);if(allowString&&
86
+ typeof base==="string"){return this.visit(right,base)}return Array.isArray(base)?this.evaluateProjectionItems(base,right):null}case"ValueProjection":{const base=this.visit(node.left,value);if(base===null||typeof base!=="object"||Array.isArray(base)){return null}return this.evaluateProjectionItems(Object.values(base),node.right)}case"FilterProjection":{const{left,right,condition}=node;const base=this.visit(left,value);if(!Array.isArray(base)){return null}const results=[];if(right.type==="Field"){
87
+ const key=right.name;for(let i=0;i<base.length;i++){const elem=base[i];if(isFalse(this.visit(condition,elem))){continue}if(!elem||typeof elem!=="object"||Array.isArray(elem)){continue}if(!Object.prototype.hasOwnProperty.call(elem,key)){continue}const val=elem[key];if(val!==void 0&&val!==null){this.collect(results,val)}}return results}if(right.type==="Identity"){for(let i=0;i<base.length;i++){const elem=base[i];if(isFalse(this.visit(condition,elem))){continue}if(elem!==null){this.collect(results,
88
+ elem)}}return results}for(const elem of base){if(isFalse(this.visit(condition,elem))){continue}const result=this.visit(right,elem);if(result!==null){this.collect(results,result)}}return results}case"Arithmetic":{const first=this.visit(node.left,value);const second=this.visit(node.right,value);switch(node.operator){case"Plus":return add(first,second);case"Minus":return sub(first,second);case"Multiply":case"Star":return mul(first,second);case"Divide":return divide(first,second);case"Modulo":return mod(
89
+ first,second);case"Div":return div(first,second);default:throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`)}}case"Unary":{const operand=this.visit(node.operand,value);switch(node.operator){case"Plus":ensureNumbers(operand);return operand;case"Minus":ensureNumbers(operand);return-operand;default:throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`)}}case"Comparator":{const first=this.visit(node.left,value);const second=this.visit(node.right,value);
90
+ switch(node.name){case"EQ":return strictDeepEqual(first,second);case"NE":return!strictDeepEqual(first,second)}if(typeof first!=="number"||typeof second!=="number"){return null}switch(node.name){case"GT":return first>second;case"GTE":return first>=second;case"LT":return first<second;case"LTE":return first<=second}}case"Flatten":{const original=this.visit(node.child,value);const res=Array.isArray(original)?original.flat():null;this.checkOutputSize(res);return res}case"Root":return this._rootValue;case"\
91
+ MultiSelectList":{const collected=[];for(const child of node.children){collected.push(this.visit(child,value))}this.checkOutputSize(collected);return collected}case"MultiSelectHash":{const collected={};for(const child of node.children){Object.defineProperty(collected,child.name,{value:this.visit(child.value,value),enumerable:true,writable:true,configurable:true})}this.checkOutputSize(collected);return collected}case"OrExpression":{const result=this.visit(node.left,value);if(isFalse(result)){return this.
92
+ visit(node.right,value)}return result}case"AndExpression":{const result=this.visit(node.left,value);if(isFalse(result)){return result}return this.visit(node.right,value)}case"NotExpression":return isFalse(this.visit(node.child,value));case"Literal":return node.value;case"Pipe":return this.visit(node.right,this.visit(node.left,value));case"Function":{if(this._options?.allowedFunctions&&!this._options.allowedFunctions.includes(node.name)){throw new Error(`Function '${node.name}' is not allowed`)}if(this.
93
+ _options?.disallowedFunctions&&this._options.disallowedFunctions.includes(node.name)){throw new Error(`Function '${node.name}' is disallowed`)}const args=[];for(const child of node.children){args.push(this.visit(child,value))}const prevInterpreter=this.runtime._interpreter;this.runtime._interpreter=this;try{const res=this.runtime.callFunction(node.name,args);this.checkOutputSize(res);return res}finally{this.runtime._interpreter=prevInterpreter}}case"ExpressionReference":return{expref:true,...node.
94
+ child};case"Current":case"Identity":return value}}computeSliceParams(arrayLength,sliceNode){let{start,stop,step}=sliceNode;if(step===null){step=1}else if(step===0){const error=new Error("Invalid value: slice step cannot be 0");error.name="RuntimeError";throw error}start=start===null?step<0?arrayLength-1:0:this.capSliceRange(arrayLength,start,step);stop=stop===null?step<0?-1:arrayLength:this.capSliceRange(arrayLength,stop,step);return{start,stop,step}}capSliceRange(arrayLength,actualValue,step){let nextActualValue=actualValue;
95
+ if(nextActualValue<0){nextActualValue+=arrayLength;if(nextActualValue<0){nextActualValue=step<0?-1:0}}else if(nextActualValue>=arrayLength){nextActualValue=step<0?arrayLength-1:arrayLength}return nextActualValue}slice(collection,start,end,step){if(step===1){return collection.slice(start,end)}const len=Math.max(0,Math.ceil((end-start)/step));const result=new Array(len);let idx=0;if(step>0){for(let i=start;i<end;i+=step){result[idx++]=collection[i]}}else{for(let i=start;i>end;i+=step){result[idx++]=
96
+ collection[i]}}return result}};var TreeInterpreterInstance=new TreeInterpreter;var TreeInterpreter_default=TreeInterpreterInstance;async function*toAsyncIterable(source){if(source==null){return}if(typeof source!=="object"&&typeof source!=="function"){throw new TypeError("Invalid stream source: expected AsyncIterable, Iterable, or ReadableStream")}if(Symbol.asyncIterator in source){for await(const chunk of source){yield chunk}return}if(typeof source.getReader==="function"){const reader=source.getReader();
97
+ try{while(true){const{done,value}=await reader.read();if(done){break}yield value}}finally{reader.releaseLock()}return}if(Symbol.iterator in source){for(const chunk of source){yield chunk}return}throw new TypeError("Invalid stream source: expected AsyncIterable, Iterable, or ReadableStream")}function parseItem(str,parseJson){if(parseJson===true){return JSON.parse(str)}if(parseJson==="auto"){try{return JSON.parse(str)}catch{return str}}return str}async function*normalizeSource(source,options){const parseJson=options?.
98
+ parseJson??"auto";const flatten=options?.flattenChunks??true;let buffer="";const textDecoder=typeof TextDecoder!=="undefined"?new TextDecoder:null;for await(const chunk of toAsyncIterable(source)){const str=chunk instanceof Uint8Array&&textDecoder?textDecoder.decode(chunk,{stream:true}):typeof chunk==="string"?chunk:null;if(str!==null){if(parseJson===false&&typeof chunk==="string"){yield chunk}else{buffer+=str;if(buffer.includes("\n")){const lines=buffer.split("\n");buffer=lines.pop()??"";for(const line of lines){
99
+ const trimmed=line.trim();if(trimmed){yield parseItem(trimmed,parseJson)}}}}}else{if(buffer.trim()){yield parseItem(buffer.trim(),parseJson);buffer=""}if(flatten&&Array.isArray(chunk)){for(const item of chunk){yield item}}else{yield chunk}}}if(textDecoder&&buffer){buffer+=textDecoder.decode()}if(buffer.trim()){yield parseItem(buffer.trim(),parseJson)}}function isStreamableNode(node){switch(node.type){case"Projection":if(node.left.type==="Identity"||node.left.type==="Current"){return true}if(node.
100
+ left.type==="IndexExpression"&&node.left.right.type==="Slice"){const slice=node.left.right;return(slice.start===null||slice.start>=0)&&(slice.stop===null||slice.stop>=0)&&(slice.step===null||slice.step>0)}return false;case"FilterProjection":return node.left.type==="Identity"||node.left.type==="Current";case"IndexExpression":if(node.left.type==="Identity"||node.left.type==="Current"){if(node.right.type==="Slice"){const slice=node.right;return(slice.start===null||slice.start>=0)&&(slice.stop===null||
101
+ slice.stop>=0)&&(slice.step===null||slice.step>0)}return false}return isStreamableNode(node.left);case"Field":case"Identity":case"Current":return true;case"Subexpression":return isStreamableNode(node.left)&&isStreamableNode(node.right);case"MultiSelectHash":case"MultiSelectList":case"Ternary":case"Comparator":case"Arithmetic":case"NotExpression":return true;case"Pipe":return isStreamableNode(node.left)&&isStreamableNode(node.right);default:return false}}async function drainStream(source,checkDeadline,maxOutputSize){
102
+ const collected=[];for await(const item of source){checkDeadline();collected.push(item);if(maxOutputSize!==void 0&&collected.length>maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${maxOutputSize}`)}}return collected}async function*drainAndEvaluate(source,node,interpreter,checkDeadline,options){const collected=await drainStream(source,checkDeadline,options?.maxOutputSize);const result=interpreter.search(node,collected,options);if(Array.isArray(result)){for(const item of result){
103
+ yield item}}else if(result!==null&&result!==void 0){yield result}}async function*evaluateStreamNode(source,node,interpreter,options){const deadline=options?.timeoutMs!==void 0?Date.now()+options.timeoutMs:0;function checkDeadline(){if(deadline>0&&Date.now()>=deadline){throw new Error(`Query execution timed out after ${options?.timeoutMs}ms`)}}switch(node.type){case"Projection":{if(!isStreamableNode(node)){yield*drainAndEvaluate(source,node,interpreter,checkDeadline,options);return}const{left,right}=node;
104
+ let streamSource=source;if(left.type==="IndexExpression"&&left.right.type==="Slice"){streamSource=evaluateStreamNode(source,left,interpreter,options)}if(right.type==="Identity"||right.type==="Current"){for await(const item of streamSource){checkDeadline();if(item!==null&&item!==void 0){yield item}}return}if(right.type==="Field"){const key=right.name;for await(const item of streamSource){checkDeadline();if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==
105
+ null){yield val}}}return}for await(const item of streamSource){checkDeadline();const res=interpreter.visit(right,item);if(res!==null&&res!==void 0){yield res}}return}case"IndexExpression":{if(node.left.type==="Identity"||node.left.type==="Current"){if(node.right.type==="Slice"){const slice=node.right;const start=slice.start??0;const stop=slice.stop??Infinity;const step=slice.step??1;if(start>=0&&stop>=0&&step>0){let index=0;for await(const item of source){checkDeadline();if(index>=stop){break}if(index>=
106
+ start&&(index-start)%step===0){yield item}index++;if(index>=stop){break}}return}}yield*drainAndEvaluate(source,node,interpreter,checkDeadline,options);return}for await(const item of source){checkDeadline();const res=interpreter.visit(node,item);if(res!==null&&res!==void 0){yield res}}return}case"FilterProjection":{if(!isStreamableNode(node)){yield*drainAndEvaluate(source,node,interpreter,checkDeadline,options);return}const{condition,right}=node;if(right.type==="Identity"||right.type==="Current"){
107
+ for await(const item of source){checkDeadline();if(!isFalse(interpreter.visit(condition,item))){yield item}}return}if(right.type==="Field"){const key=right.name;for await(const item of source){checkDeadline();if(!isFalse(interpreter.visit(condition,item))){if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==null){yield val}}}}return}for await(const item of source){checkDeadline();if(!isFalse(interpreter.visit(condition,item))){const res=interpreter.visit(
108
+ right,item);if(res!==null&&res!==void 0){yield res}}}return}case"Pipe":{const leftStream=evaluateStreamNode(source,node.left,interpreter,options);if(isStreamableNode(node.right)){for await(const res of evaluateStreamNode(leftStream,node.right,interpreter,options)){yield res}}else{const collected=await drainStream(leftStream,checkDeadline,options?.maxOutputSize);const result=interpreter.search(node.right,collected,options);if(result!==null&&result!==void 0){yield result}}return}case"Identity":case"\
109
+ Current":{for await(const item of source){checkDeadline();yield item}return}case"Field":{const key=node.name;for await(const item of source){checkDeadline();if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==null){yield val}}}return}default:{if(isStreamableNode(node)){for await(const item of source){checkDeadline();const res=interpreter.visit(node,item);if(res!==null&&res!==void 0){yield res}}return}yield*drainAndEvaluate(source,node,interpreter,checkDeadline,
110
+ options);return}}}function isExpressionNode(val){return typeof val==="object"&&val!==null&&"type"in val&&typeof val.type==="string"&&!(Symbol.iterator in val)&&!(Symbol.asyncIterator in val)}async function*searchStream(sourceOrExpression,expressionOrSource,options){let expression;let source;if(typeof sourceOrExpression==="string"||isExpressionNode(sourceOrExpression)){expression=sourceOrExpression;source=expressionOrSource}else{source=sourceOrExpression;expression=expressionOrSource}if(typeof expression!==
111
+ "string"&&!isExpressionNode(expression)){throw new TypeError("Expression must be a string or AST ExpressionNode")}const ast=typeof expression==="string"?Parser_default.parse(expression,options):expression;if(options){const fnError=findDisallowedFunction(ast,options);if(fnError){throw new Error(fnError)}}const interpreter=new TreeInterpreter(options);interpreter.runtime._functionTable=TreeInterpreterInstance.runtime._functionTable;const items=normalizeSource(source,options);const results=evaluateStreamNode(
112
+ items,ast,interpreter,options);const limit=options?.limit;const maxOutputSize=options?.maxOutputSize;let count=0;if(limit!==void 0&&limit<=0){return}for await(const result of results){if(maxOutputSize!==void 0&&count>=maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${maxOutputSize}`)}yield result;count++;if(limit!==void 0&&count>=limit){break}}}var TYPE_ANY=1;var TYPE_ARRAY=3;var TYPE_ARRAY_ARRAY=11;var TYPE_ARRAY_NUMBER=8;var TYPE_ARRAY_OBJECT=10;var TYPE_ARRAY_STRING=9;
113
+ var TYPE_BOOLEAN=5;var TYPE_EXPREF=6;var TYPE_NULL=7;var TYPE_NUMBER=0;var TYPE_OBJECT=4;var TYPE_STRING=2;function compile(expression,options){return Parser_default.parse(expression,options)}function compileQuery(expression,options){const nodeTree=Parser_default.parse(expression,options);const searchFn=data=>TreeInterpreter_default.search(nodeTree,data,options);const fn=searchFn;fn.search=searchFn;fn.searchStream=(source,streamOptions)=>searchStream(source,nodeTree,{...options,...streamOptions});
114
+ fn.ast=nodeTree;return fn}function validate(expression,options){if(typeof expression!=="string"){return{valid:false,error:"Expression must be a string"}}try{const ast=Parser_default.parse(expression,options);if(options){const fnError=findDisallowedFunction(ast,options);if(fnError){return{valid:false,error:fnError}}}return{valid:true,ast}}catch(err){return{valid:false,error:err instanceof Error?err.message:String(err)}}}function tokenize(expression,options){return Lexer_default.tokenize(expression,
115
+ options)}var registerFunction=(functionName,customFunction,signature,options)=>{TreeInterpreter_default.runtime.registerFunction(functionName,customFunction,signature,options)};var register=(name,customFunction,signature,options)=>{return TreeInterpreter_default.runtime.register(name,customFunction,signature,options)};var unregisterFunction=name=>{return TreeInterpreter_default.runtime.unregister(name)};var isRegistered=name=>{return TreeInterpreter_default.runtime.isRegistered(name)};var getRegisteredFunctions=()=>{
116
+ return TreeInterpreter_default.runtime.getRegistered()};var getCustomFunctions=()=>{return TreeInterpreter_default.runtime.getCustomFunctions()};var clearCustomFunctions=()=>{TreeInterpreter_default.runtime.clearCustomFunctions()};var MAX_CACHE_SIZE=1e3;var astCache=new Map;function search(data,expression,options){let nodeTree;if(!options){nodeTree=astCache.get(expression);if(!nodeTree){nodeTree=Parser_default.parse(expression);if(astCache.size>=MAX_CACHE_SIZE){const firstKey=astCache.keys().next().
117
+ value;if(firstKey!==void 0){astCache.delete(firstKey)}}astCache.set(expression,nodeTree)}}else{nodeTree=Parser_default.parse(expression,options)}return TreeInterpreter_default.search(nodeTree,data,options)}function Scope(){return new ScopeChain}var TreeInterpreter2=TreeInterpreter_default;var jmespath={compile,compileQuery,searchStream,validate,registerFunction,register,unregisterFunction,isRegistered,getRegisteredFunctions,getCustomFunctions,clearCustomFunctions,search,tokenize,TreeInterpreter:TreeInterpreter2,
118
+ DEFAULT_MAX_DEPTH,TYPE_ANY,TYPE_ARRAY_NUMBER,TYPE_ARRAY_STRING,TYPE_ARRAY,TYPE_BOOLEAN,TYPE_EXPREF,TYPE_NULL,TYPE_NUMBER,TYPE_OBJECT,TYPE_STRING,TYPE_ARRAY_ARRAY,TYPE_ARRAY_OBJECT,Scope};var index_default=jmespath;export{DEFAULT_MAX_DEPTH,Scope,TYPE_ANY,TYPE_ARRAY,TYPE_ARRAY_ARRAY,TYPE_ARRAY_NUMBER,TYPE_ARRAY_OBJECT,TYPE_ARRAY_STRING,TYPE_BOOLEAN,TYPE_EXPREF,TYPE_NULL,TYPE_NUMBER,TYPE_OBJECT,TYPE_STRING,TreeInterpreter2 as TreeInterpreter,clearCustomFunctions,compile,compileQuery,index_default as default,getCustomFunctions,getRegisteredFunctions,isRegistered,jmespath,register,registerFunction,search,searchStream,tokenize,unregisterFunction,validate};
@@ -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-5VFEV3BR.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-AZ6XEIXF.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-VLTRRD4T.js";import"./chunk-K54OB2BX.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-4OB22XRI.js";import"./chunk-HNW2JWHQ.js";import"./chunk-PAJAEUPA.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{evaluateQuery}from"./chunk-LXFLA3PZ.js";import"./chunk-STILP3Z6.js";import"./chunk-VSJBJXZO.js";export{evaluateQuery};
3
+ import{evaluateQuery}from"./chunk-PAJAEUPA.js";import"./chunk-STILP3Z6.js";import"./chunk-VSJBJXZO.js";export{evaluateQuery};
@@ -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-K54OB2BX.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
3
+ import{loadDomain}from"./chunk-HNW2JWHQ.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-VLTRRD4T.js";import"./chunk-K54OB2BX.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-4OB22XRI.js";import"./chunk-HNW2JWHQ.js";import"./chunk-PAJAEUPA.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};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{hasRemovableRunner,parseRunners,removeHint,runRunnerCommand}from"./chunk-KOL4P7LC.js";import"./chunk-KGKSXGX7.js";import"./chunk-BLDQ6PY3.js";import"./chunk-VRBI2NPI.js";import"./chunk-STILP3Z6.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{hasRemovableRunner,parseRunners,removeHint,runRunnerCommand};
3
+ import{hasRemovableRunner,parseRunners,removeHint,runRunnerCommand}from"./chunk-L6FXTX6Q.js";import"./chunk-KGKSXGX7.js";import"./chunk-BLDQ6PY3.js";import"./chunk-VRBI2NPI.js";import"./chunk-STILP3Z6.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{hasRemovableRunner,parseRunners,removeHint,runRunnerCommand};
@@ -8,11 +8,11 @@ ${e.hint?`${e.hint}
8
8
  const res=await api.request("GET","/settings/skills");if(!res.ok){io.err(`\u26D4 \u30B9\u30AD\u30EB\u5B9A\u7FA9\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\uFF08${errorDetail(res)}\uFF09
9
9
  `);return apiExit(res)}const raw=unwrap(res,"skills")["skills"];if(!Array.isArray(raw)){io.err(`\u26D4 \u30B9\u30AD\u30EB\u5B9A\u7FA9\u306E\u4E00\u89A7\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09
10
10
  `);return EXIT_API_SERVER}const entries=[];for(const item of raw){const r=item&&typeof item==="object"?item:{};const name=str(r["name"]);const revision=pickNumber(r,"revision");const digest=str(r["digest"]);if(!isValidSkillName(name)||revision===null||!/^sha256:[0-9a-f]{64}$/.test(digest)){io.err(`\u26D4 \u30B9\u30AD\u30EB\u5B9A\u7FA9\u306E\u4E00\u89A7\u306B\u5951\u7D04\u5916\u306E\u8981\u7D20\u304C\u3042\u308A\u307E\u3059\uFF08${JSON.stringify(item).slice(0,160)}\uFF09
11
- `);return EXIT_API_SERVER}entries.push({name,revision,updated_by_name:str(r["updated_by_name"]),updated_at:str(r["updated_at"]),bytes:pickNumber(r,"bytes"),digest})}entries.sort((a,b)=>a.name<b.name?-1:a.name>b.name?1:0);const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?entries:await evaluateQuery(opts.query,entries);if(format!=="json"&&opts.query===void 0&&entries.length===0){io.err("\u30B5\u30FC\
11
+ `);return EXIT_API_SERVER}entries.push({name,revision,updated_by_name:str(r["updated_by_name"]),updated_at:str(r["updated_at"]),bytes:pickNumber(r,"bytes"),digest})}entries.sort((a,b)=>a.name<b.name?-1:a.name>b.name?1:0);const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?entries:await evaluateQuery(opts.query,entries);if(format!=="json"&&opts.query===void 0&&entries.length===0){io.err("\u30B5\u30FC\
12
12
  \u30D0\u306B\u30B9\u30AD\u30EB\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08\u30EB\u30FC\u30D7\u306F\u3059\u3079\u3066\u4F5C\u696D\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D5\u30A1\u30A4\u30EB\u7248\u3092\u4F7F\u3044\u307E\u3059\uFF09\n");return EXIT_OK}const text=renderOutput(selected,format);io.out(text.endsWith("\n")?text:`${text}
13
13
  `);return EXIT_OK}async function showSkill(api,opts,name,io){if(opts.output!==void 0&&opts.output!=="json"){throw new UsageError(`skill show \u306E --output \u306B\u300C${opts.output}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,"\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F json \u3060\u3051\u3067\u3059\uFF08\u7701\u7565\u3059\u308B\u3068\u672C\u6587\u3092\u305D\u306E\u307E\u307E\u51FA\u3057\u307E\u3059\uFF09")}const structured=opts.output==="json"||opts.query!==void 0;const current=await fetchSkill(
14
14
  api,name,io.err);if(typeof current==="number")return current;if(current===null){io.err(`\u30B5\u30FC\u30D0\u306B\u30B9\u30AD\u30EB ${name} \u304C\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08\u30EB\u30FC\u30D7\u306F\u4F5C\u696D\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D5\u30A1\u30A4\u30EB\u7248\u3092\u4F7F\u3044\u307E\u3059\uFF09
15
- `);return EXIT_FAILURE}if(structured){const value={name:current.name,revision:current.revision,updated_by_name:current.updatedByName,updated_at:current.updatedAt,bytes:Buffer.byteLength(current.body,"utf8"),digest:skillDigest(current.body),body:current.body};const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text=renderOutput(selected,"jso\
15
+ `);return EXIT_FAILURE}if(structured){const value={name:current.name,revision:current.revision,updated_by_name:current.updatedByName,updated_at:current.updatedAt,bytes:Buffer.byteLength(current.body,"utf8"),digest:skillDigest(current.body),body:current.body};const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text=renderOutput(selected,"jso\
16
16
  n",true);io.out(text.endsWith("\n")?text:`${text}
17
17
  `);return EXIT_OK}if(io.isTty){warnHiddenChars(io.err,current.body,name);io.out(current.body);if(!current.body.endsWith("\n"))io.out("\n");return EXIT_OK}io.rawOut(current.body);return EXIT_OK}async function deleteSkill(api,opts,name,io){let expected;if(opts.revision!==void 0){if(!/^\d{1,15}$/.test(opts.revision)){io.err(`--revision \u306F0\u4EE5\u4E0A\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${opts.revision}
18
18
  `);return EXIT_USAGE}if(!opts.yes){io.err("--revision \u306F --yes \u3068\u4E00\u7DD2\u306B\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08--yes \u306A\u3057\u3067\u306F\u524A\u9664\u3057\u307E\u305B\u3093\uFF09\n");return EXIT_USAGE}expected=opts.revision}else if(opts.yes){io.err("skill delete \u306E\u78BA\u5B9A\u306B\u306F --yes \u3068 --revision <N> \u306E\u4E21\u65B9\u304C\u5FC5\u8981\u3067\u3059\uFF08--yes \u3092\u5916\u3057\u3066\u5B9F\u884C\u3059\u308B\u3068\u3001\u6D88\u3059\u5185\u5BB9\u3068 revision \u3092\u8868\u793A\u3057\u307E\u3059\uFF09\n");
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{hasRemovableRunner,removeHint}from"./chunk-KOL4P7LC.js";import"./chunk-KGKSXGX7.js";import"./chunk-BLDQ6PY3.js";import"./chunk-VRBI2NPI.js";import{describeError,filterByStatus,pick}from"./chunk-GYX2ZXQM.js";import"./chunk-RMFLTSOV.js";import{EXIT_OK,EXIT_USAGE,UsageError}from"./chunk-STILP3Z6.js";import"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";function str(v){return typeof v==="string"&&v!==""?v:null}function num(v){return typeof v==="number"&&Number.isFinite(v)?v:null}function secondsSince(iso,now){if(iso===null)return null;const at=Date.parse(iso);if(Number.isNaN(at))return null;return Math.max(0,Math.floor((now.getTime()-at)/1e3))}async function collectStatus(api,ctx){const now=ctx.now??new Date;const runnersRes=await api.runners();let runners;if(!runnersRes.ok){runners={ok:false,error:describeError(runnersRes)}}else{const raw=pick(
3
+ import{hasRemovableRunner,removeHint}from"./chunk-L6FXTX6Q.js";import"./chunk-KGKSXGX7.js";import"./chunk-BLDQ6PY3.js";import"./chunk-VRBI2NPI.js";import{describeError,filterByStatus,pick}from"./chunk-GYX2ZXQM.js";import"./chunk-RMFLTSOV.js";import{EXIT_OK,EXIT_USAGE,UsageError}from"./chunk-STILP3Z6.js";import"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";function str(v){return typeof v==="string"&&v!==""?v:null}function num(v){return typeof v==="number"&&Number.isFinite(v)?v:null}function secondsSince(iso,now){if(iso===null)return null;const at=Date.parse(iso);if(Number.isNaN(at))return null;return Math.max(0,Math.floor((now.getTime()-at)/1e3))}async function collectStatus(api,ctx){const now=ctx.now??new Date;const runnersRes=await api.runners();let runners;if(!runnersRes.ok){runners={ok:false,error:describeError(runnersRes)}}else{const raw=pick(
4
4
  runnersRes.json,"runners");const list=Array.isArray(raw)?raw:[];runners={ok:true,live_count:num(pick(runnersRes.json,"live_count")),max_runners:num(pick(runnersRes.json,"max_runners")),heartbeat_timeout:num(pick(runnersRes.json,"heartbeat_timeout")),items:list.map(r=>{const lastSeen=str(r?.["last_seen_at"]);return{runner_id:str(r?.["runner_id"]),is_live:r?.["is_live"]===true,is_reporting:r?.["is_reporting"]===true,is_waiting:r?.["is_waiting"]===true,next_run_at:str(r?.["next_run_at"]),kind:str(r?.["\
5
5
  kind"]),phase:str(r?.["phase"]),current_item_id:str(r?.["current_item_id"]),hostname:str(r?.["hostname"]),last_seen_at:lastSeen,seconds_since_last_seen:secondsSince(lastSeen,now)}})}}const queue={};for(const status of["pending","processing"]){const res=await api.list({status,limit:100});if(!res.ok){queue[status]={ok:false,error:describeError(res)};continue}const items=pick(res.json,"items");const more=pick(res.json,"has_more")===true||pick(res.json,"pagination.has_more")===true;const counted=Array.
6
6
  isArray(items)?filterByStatus(items,status).length:null;queue[status]={ok:true,count:counted,has_more:more}}const state=await api.request("GET","/state");const plan_lock=state.ok?{held:pick(state.json,"state.planning")===true,owner_runner_id:str(pick(state.json,"state.plan_owner_runner_id")),expires_at:str(pick(state.json,"state.plan_lock_expires_at"))}:null;return{project:{ref:ctx.projectRef,id:ctx.projectId},api_url:ctx.apiUrl,runners,queue,plan_lock,local_lock:{held:ctx.lockHeld,path:ctx.lockPath}}}
@@ -11,7 +11,7 @@ live_count??"?"} / ${r.max_runners??"?"} \u7A3C\u50CD\uFF08\u6B7B\u6D3B\u3057\u3
11
11
  / \u671F\u9650 ${pl.expires_at??"?"}\uFF09`:"\u7A7A\u304D"}`)}lines.push("",`\u30ED\u30FC\u30AB\u30EB\u30ED\u30C3\u30AF: ${report.local_lock.held?`\u4FDD\u6301\u4E2D\uFF08${report.local_lock.path}\uFF09`:"\u7121\u3057"}`);return`${lines.join("\n")}
12
12
  `}async function runStatusCommand(api,ctx,opts,io){if(opts.output!==void 0&&opts.output!=="json"){io.err(`task-loop status \u306E --output \u306B\u300C${opts.output}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093
13
13
  \u6307\u5B9A\u3067\u304D\u308B\u306E\u306F json \u3060\u3051\u3067\u3059\uFF08\u7701\u7565\u3059\u308B\u3068\u4EBA\u5411\u3051\u306E\u6587\u9762\u3092\u51FA\u3057\u307E\u3059\uFF09
14
- `);return EXIT_USAGE}if(opts.query!==void 0&&opts.query.trim()===""){io.err("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\n");return EXIT_USAGE}const report=await collectStatus(api,ctx);if(opts.output===void 0&&opts.query===void 0){io.out(stripTerminalControls(renderStatusText(report,{profile:ctx.profile})));return EXIT_OK}const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");let selected=report;
14
+ `);return EXIT_USAGE}if(opts.query!==void 0&&opts.query.trim()===""){io.err("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\n");return EXIT_USAGE}const report=await collectStatus(api,ctx);if(opts.output===void 0&&opts.query===void 0){io.out(stripTerminalControls(renderStatusText(report,{profile:ctx.profile})));return EXIT_OK}const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");let selected=report;
15
15
  if(opts.query!==void 0){try{selected=await evaluateQuery(opts.query,report)}catch(e){if(e instanceof UsageError){io.err(`${e.message}
16
16
  `);return EXIT_USAGE}throw e}}const text=renderOutput(selected,"json");io.out(text.endsWith("\n")?text:`${text}
17
17
  `);return EXIT_OK}function runnerStateLabel(x){if(x.is_live)return"live";if(x.is_waiting)return x.next_run_at===null?"waiting":`waiting \u6B21\u56DE ${formatLocalTime(x.next_run_at)}`;return"stale"}export{collectStatus,formatElapsed,formatLocalTime,renderStatusText,runStatusCommand};
@@ -4,7 +4,7 @@ import{stableJson}from"./chunk-FDECUPTW.js";import{reasonOf,unwrap}from"./chunk-
4
4
  deps.api,opts,io);case"show":return await show(deps.api,opts,io);case"push":return await push(deps.api,opts,io);case"delete":return await remove(deps.api,opts,io);case"history":return await history(deps.api,opts,io);case"release":return await release(deps.api,opts,io)}}catch(e){if(e instanceof UsageError){io.err(`${e.message}
5
5
  ${e.hint?`${e.hint}
6
6
  `:""}`);return EXIT_USAGE}throw e}}async function formatOf(opts,io){const{resolveOutputFormat}=await import("./format-X65HXAAU.js");const format=resolveOutputFormat({...opts.output!==void 0?{flag:opts.output}:{},isTty:io.isTty});if(format===null||!FORMATS.includes(format)){throw new UsageError(`trigger ${opts.op} \u306E --output \u306B\u300C${opts.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${FORMATS.join(" / ")} \u3067\u3059`)}
7
- return format}async function emit(value,opts,format,io){const{evaluateQuery}=await import("./query-E22FS2XX.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text2=renderOutput(selected,format);io.out(text2.endsWith("\n")?text2:`${text2}
7
+ return format}async function emit(value,opts,format,io){const{evaluateQuery}=await import("./query-NHJP3NF2.js");const{renderOutput}=await import("./render-I6U5PEYR.js");const selected=opts.query===void 0?value:await evaluateQuery(opts.query,value);const text2=renderOutput(selected,format);io.out(text2.endsWith("\n")?text2:`${text2}
8
8
  `)}async function list(api,opts,io){const format=await formatOf(opts,io);const triggers=await fetchTriggers(api,io.err);if(typeof triggers==="number")return triggers;const sorted=[...triggers].sort((a,b)=>str(a["id"]).localeCompare(str(b["id"])));if(format==="json"){await emit(sorted,opts,format,io);return EXIT_OK}io.err(`\u6761\u4EF6\u30C8\u30EA\u30AC\u30FC ${sorted.length} \u4EF6
9
9
  `);if(opts.query===void 0&&sorted.length===0)return EXIT_OK;await emit(sorted.map(summaryRow),opts,format,io);return EXIT_OK}function summaryRow(t){const match=obj(t["match"]);const threshold=obj(t["threshold"]);const action=obj(t["action"]);const skills=Array.isArray(match["skills"])?match["skills"].map(String).join(","):"";const codes=Array.isArray(match["outcome_codes"])?match["outcome_codes"].map(String).join(","):"";return{id:str(t["id"]),enabled:t["enabled"]===false?"\u7121\u52B9":"\u6709\u52B9",
10
10
  name:str(t["name"]),skills,outcome_codes:codes,condition:`${text(threshold["count"])}\u56DE/${text(threshold["window_hours"])}h${match["require_state_unchanged"]===false?"":"\u30FB\u72B6\u614B\u4E0D\u5909"}`,action:`${str(action["skill"])}${str(action["args"])!==""?` ${str(action["args"])}`:""}\uFF08${str(action["priority"])}\uFF09`,block_source:action["block_source"]===true?"\u3042\u308A":"\u306A\u3057",revision:t["revision"]??""}}async function show(api,opts,io){const id=requireId(opts);const format=await formatOf(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tocca-systems/twp-cli",
3
- "version": "0.138.0",
3
+ "version": "0.139.0",
4
4
  "description": "TWP CLI — Tocca Working Platform の CLI 型統合インターフェース(AIエージェントハーネス)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,120 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import"./chunk-VSJBJXZO.js";var CHILD_PROPS=["left","right","condition","child","operand","trueExpr","falseExpr","expression"];function pushChildren(node,stack){const n=node;for(const prop of CHILD_PROPS){const val=n[prop];if(val&&typeof val==="object"&&"type"in val){stack.push(val)}}if(Array.isArray(n.children)){for(const item of n.children){if(!item){continue}stack.push(item);if(item.type==="KeyValuePair"&&item.value){stack.push(item.value)}}}if(Array.isArray(n.bindings)){for(const item of n.bindings){if(!item){continue}
4
- stack.push(item);if(item.reference){stack.push(item.reference)}}}}function forEachNode(root,visitor){const stack=[root];while(stack.length>0){const current=stack.pop();if(!current){break}if(visitor(current)===false){return}pushChildren(current,stack)}}function countNodes(root){let count=0;forEachNode(root,()=>{count+=1;return true});return count}function findDisallowedFunction(root,options){const{allowedFunctions,disallowedFunctions}=options;if(!allowedFunctions&&!disallowedFunctions){return null}
5
- let violation=null;forEachNode(root,node=>{if(node.type!=="Function"){return true}const name=node.name;if(allowedFunctions&&!allowedFunctions.includes(name)){violation=`Function '${name}' is not allowed`;return false}if(disallowedFunctions&&disallowedFunctions.includes(name)){violation=`Function '${name}' is disallowed`;return false}return true});return violation}var isObject=obj=>{return obj!==null&&Object.prototype.toString.call(obj)==="[object Object]"};var strictDeepEqual=(first,second)=>{if(first===
6
- second){return true}if(typeof first!==typeof second){return false}if(Array.isArray(first)&&Array.isArray(second)){if(first.length!==second.length){return false}for(let i=0;i<first.length;i+=1){if(!strictDeepEqual(first[i],second[i])){return false}}return true}if(isObject(first)&&isObject(second)){const firstEntries=Object.entries(first);const secondKeys=new Set(Object.keys(second));if(firstEntries.length!==secondKeys.size){return false}for(const[key,value]of firstEntries){if(!strictDeepEqual(value,
7
- second[key])){return false}secondKeys.delete(key)}return secondKeys.size===0}return false};var isFalse=obj=>{if(obj===null||obj===void 0||obj===false){return true}if(typeof obj==="string"){return obj===""}if(typeof obj==="object"){if(Array.isArray(obj)){return obj.length===0}return Object.keys(obj).length===0}return false};var isAlpha=ch=>{return ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch==="_"};var isNum=ch=>{return ch>="0"&&ch<="9"||ch==="-"};var isAlphaNum=ch=>{return ch>="a"&&ch<="z"||ch>="A"&&ch<=
8
- "Z"||ch>="0"&&ch<="9"||ch==="_"};var ensureInteger=value=>{if(!(typeof value==="number")||Math.floor(value)!==value){throw new Error("invalid-value: expecting an integer.")}return value};var ensurePositiveInteger=value=>{if(!(typeof value==="number")||value<0||Math.floor(value)!==value){throw new Error("invalid-value: expecting a non-negative integer.")}return value};var ensureNumbers=(...operands)=>{for(let i=0;i<operands.length;i++){if(operands[i]===null||operands[i]===void 0){throw new Error(
9
- "not-a-number: undefined")}if(typeof operands[i]!=="number"){throw new Error("not-a-number")}}};var notZero=n=>{n=+n;if(!n){throw new Error("not-a-number: divide by zero")}return n};var add=(left,right)=>{ensureNumbers(left,right);return left+right};var sub=(left,right)=>{ensureNumbers(left,right);return left-right};var mul=(left,right)=>{ensureNumbers(left,right);return left*right};var divide=(left,right)=>{ensureNumbers(left,right);return left/notZero(right)};var div=(left,right)=>{ensureNumbers(
10
- left,right);return Math.floor(left/notZero(right))};var mod=(left,right)=>{ensureNumbers(left,right);return left%right};var basicTokens={"(":"Lparen",")":"Rparen","*":"Star",",":"Comma",".":"Dot",":":"Colon","@":"Current","]":"Rbracket","{":"Lbrace","}":"Rbrace","+":"Plus","%":"Modulo","?":"Question","\u2212":"Minus","\xD7":"Multiply","\xF7":"Divide"};var operatorStartToken={"!":true,"<":true,"=":true,">":true,"&":true,"|":true,"/":true};var skipChars={" ":true,"\n":true,"\r":true," ":true};var StreamLexer=class{_current=0;_enable_legacy_literals=false;tokenize(stream,options){
11
- const tokens=[];this._current=0;this._enable_legacy_literals=options?.enable_legacy_literals||false;let start;let identifier;let token;while(this._current<stream.length){if(isAlpha(stream[this._current])){start=this._current;identifier=this.consumeUnquotedIdentifier(stream);tokens.push({start,type:"UnquotedIdentifier",value:identifier})}else if(basicTokens[stream[this._current]]!==void 0){tokens.push({start:this._current,type:basicTokens[stream[this._current]],value:stream[this._current]});this.
12
- _current+=1}else if(stream[this._current]==="$"){start=this._current;if(this._current+1<stream.length&&isAlpha(stream[this._current+1])){this._current+=1;identifier=this.consumeUnquotedIdentifier(stream);tokens.push({start,type:"Variable",value:identifier})}else{tokens.push({start,type:"Root",value:stream[this._current]});this._current+=1}}else if(stream[this._current]==="-"){if(this._current+1<stream.length&&isNum(stream[this._current+1])){const token2=this.consumeNumber(stream);token2&&tokens.
13
- push(token2)}else{const token2={start:this._current,type:"Minus",value:"-"};tokens.push(token2);this._current+=1}}else if(isNum(stream[this._current])){token=this.consumeNumber(stream);tokens.push(token)}else if(stream[this._current]==="["){token=this.consumeLBracket(stream);tokens.push(token)}else if(stream[this._current]==='"'){start=this._current;identifier=this.consumeQuotedIdentifier(stream);tokens.push({start,type:"QuotedIdentifier",value:identifier})}else if(stream[this._current]===`'`){start=
14
- this._current;identifier=this.consumeRawStringLiteral(stream);tokens.push({start,type:"Literal",value:identifier})}else if(stream[this._current]==="`"){start=this._current;const literal=this.consumeLiteral(stream);tokens.push({start,type:"Literal",value:literal})}else if(operatorStartToken[stream[this._current]]!==void 0){token=this.consumeOperator(stream);token&&tokens.push(token)}else if(skipChars[stream[this._current]]!==void 0){this._current+=1}else{const error=new Error(`Syntax error: unkno\
15
- wn character: ${stream[this._current]}`);error.name="LexerError";throw error}}return tokens}consumeUnquotedIdentifier(stream){const start=this._current;this._current+=1;while(this._current<stream.length&&isAlphaNum(stream[this._current])){this._current+=1}return stream.slice(start,this._current)}consumeQuotedIdentifier(stream){const start=this._current;this._current+=1;const maxLength=stream.length;while(stream[this._current]!=='"'&&this._current<maxLength){let current=this._current;if(stream[current]===
16
- "\\"&&(stream[current+1]==="\\"||stream[current+1]==='"')){current+=2}else{current+=1}this._current=current}this._current+=1;const[value,ok]=this.parseJSON(stream.slice(start,this._current));if(!ok){const error=new Error(`syntax: unexpected end of JSON input`);error.name="LexerError";throw error}return value}consumeRawStringLiteral(stream){const start=this._current;this._current+=1;const maxLength=stream.length;while(stream[this._current]!==`'`&&this._current<maxLength){let current=this._current;
17
- if(stream[current]==="\\"&&(stream[current+1]==="\\"||stream[current+1]===`'`)){current+=2}else{current+=1}this._current=current}this._current+=1;const literal=stream.slice(start+1,this._current-1);return literal.replace(/\\(['\\])/g,"$1")}consumeNumber(stream){const start=this._current;this._current+=1;const maxLength=stream.length;while(isNum(stream[this._current])&&this._current<maxLength){this._current+=1}const value=parseInt(stream.slice(start,this._current),10);return{start,value,type:"Num\
18
- ber"}}consumeLBracket(stream){const start=this._current;this._current+=1;if(stream[this._current]==="?"){this._current+=1;return{start,type:"Filter",value:"[?"}}if(stream[this._current]==="]"){this._current+=1;return{start,type:"Flatten",value:"[]"}}return{start,type:"Lbracket",value:"["}}consumeOrElse(stream,peek,token,orElse){const start=this._current;this._current+=1;if(this._current<stream.length&&stream[this._current]===peek){this._current+=1;return{start,type:orElse,value:stream.slice(start,
19
- this._current)}}return{start,type:token,value:stream[start]}}consumeOperator(stream){const start=this._current;const startingChar=stream[start];switch(startingChar){case"!":return this.consumeOrElse(stream,"=","Not","NE");case"<":return this.consumeOrElse(stream,"=","LT","LTE");case">":return this.consumeOrElse(stream,"=","GT","GTE");case"=":return this.consumeOrElse(stream,"=","Assign","EQ");case"&":return this.consumeOrElse(stream,"&","Expref","And");case"|":return this.consumeOrElse(stream,"|",
20
- "Pipe","Or");case"/":return this.consumeOrElse(stream,"/","Divide","Div")}}consumeLiteral(stream){this._current+=1;const start=this._current;const maxLength=stream.length;while(stream[this._current]!=="`"&&this._current<maxLength){let current=this._current;if(stream[current]==="\\"&&(stream[current+1]==="\\"||stream[current+1]==="`")){current+=2}else{current+=1}this._current=current}let literalString=stream.slice(start,this._current).trimStart();literalString=literalString.replace("\\`","`");let literal=null;
21
- let ok=false;if(this.looksLikeJSON(literalString)){[literal,ok]=this.parseJSON(literalString)}if(!ok&&this._enable_legacy_literals){[literal,ok]=this.parseJSON(`"${literalString}"`)}if(!ok){const error=new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current]}`);error.name="LexerError";throw error}this._current+=1;return literal}looksLikeJSON(literalString){const startingChars='[{"';const jsonLiterals=["true","false","null"];const numberLooking="\
22
- -0123456789";if(literalString===""){return false}if(startingChars.includes(literalString[0])){return true}if(jsonLiterals.includes(literalString)){return true}if(numberLooking.includes(literalString[0])){const[_,ok]=this.parseJSON(literalString);return ok}return false}parseJSON(text){try{const json=JSON.parse(text);return[json,true]}catch{return[null,false]}}};var Lexer=new StreamLexer;var Lexer_default=Lexer;var bindingPower={["EOF"]:0,["Variable"]:0,["UnquotedIdentifier"]:0,["QuotedIdentifier"]:0,
23
- ["Rbracket"]:0,["Rparen"]:0,["Comma"]:0,["Rbrace"]:0,["Number"]:0,["Current"]:0,["Expref"]:0,["Root"]:0,["Assign"]:1,["Pipe"]:1,["Question"]:2,["Or"]:3,["And"]:4,["EQ"]:5,["GT"]:5,["LT"]:5,["GTE"]:5,["LTE"]:5,["NE"]:5,["Minus"]:6,["Plus"]:6,["Div"]:7,["Divide"]:7,["Modulo"]:7,["Multiply"]:7,["Flatten"]:9,["Star"]:20,["Filter"]:21,["Dot"]:40,["Not"]:45,["Lbrace"]:50,["Lbracket"]:55,["Lparen"]:60};var TokenParser=class _TokenParser{index=0;tokens=[];depth=0;maxDepth;nodeCount=0;maxNodes;parse(expression,options){
24
- this.loadTokens(expression,options||{enable_legacy_literals:false});this.index=0;this.depth=0;this.nodeCount=0;this.maxDepth=options?.maxDepth;this.maxNodes=options?.maxNodes;const ast=this.expression(0);if(this.lookahead(0)!=="EOF"){const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: unexpected token type: ${token.type}, value: ${token.value}`)}if(this.maxNodes!==void 0&&countNodes(ast)>this.maxNodes){throw new Error(`Expression exceeds maximum allowed node count of ${this.maxNodes}`)}
25
- return ast}loadTokens(expression,options){this.tokens=Lexer_default.tokenize(expression,options);this.tokens.push({type:"EOF",value:"",start:expression.length})}expression(rbp){if(this.maxDepth!==void 0&&this.depth>=this.maxDepth){throw new Error(`Expression exceeds maximum allowed depth of ${this.maxDepth}`)}this.depth+=1;this.trackNode();try{const leftToken=this.lookaheadToken(0);this.advance();let left=this.nud(leftToken);let currentTokenType=this.lookahead(0);while(rbp<bindingPower[currentTokenType]){
26
- this.trackNode();this.advance();left=this.led(currentTokenType,left);currentTokenType=this.lookahead(0)}return left}finally{this.depth-=1}}trackNode(){this.nodeCount+=1;if(this.maxNodes!==void 0&&this.nodeCount>this.maxNodes){throw new Error(`Expression exceeds maximum allowed node count of ${this.maxNodes}`)}}lookahead(offset){return this.tokens[this.index+offset].type}lookaheadToken(offset){return this.tokens[this.index+offset]}advance(){this.index+=1}nud(token){switch(token.type){case"Variabl\
27
- e":return{type:"Variable",name:token.value};case"Literal":return{type:"Literal",value:token.value};case"UnquotedIdentifier":{if(_TokenParser.isKeyword(token,"let")&&this.lookahead(0)==="Variable"){return this.parseLetExpression()}else{return{type:"Field",name:token.value}}}case"QuotedIdentifier":if(this.lookahead(0)==="Lparen"){throw new Error("Syntax error: quoted identifier not allowed for function names.")}else{return{type:"Field",name:token.value}}case"Not":{const child=this.expression(bindingPower.
28
- Not);return{type:"NotExpression",child}}case"Minus":{const child=this.expression(bindingPower.Minus);return{type:"Unary",operator:token.type,operand:child}}case"Plus":{const child=this.expression(bindingPower.Plus);return{type:"Unary",operator:token.type,operand:child}}case"Star":{const left={type:"Identity"};return{type:"ValueProjection",left,right:this.parseProjectionRHS(bindingPower.Star)}}case"Filter":return this.led(token.type,{type:"Identity"});case"Lbrace":return this.parseMultiselectHash();case"\
29
- Flatten":{const left={type:"Flatten",child:{type:"Identity"}};const right=this.parseProjectionRHS(bindingPower.Flatten);return{type:"Projection",left,right}}case"Lbracket":{if(this.lookahead(0)==="Number"||this.lookahead(0)==="Colon"){const right=this.parseIndexExpression();return this.projectIfSlice({type:"Identity"},right)}if(this.lookahead(0)==="Star"&&this.lookahead(1)==="Rbracket"){this.advance();this.advance();const right=this.parseProjectionRHS(bindingPower.Star);return{left:{type:"Identi\
30
- ty"},right,type:"Projection"}}return this.parseMultiselectList()}case"Current":return{type:"Current"};case"Root":return{type:"Root"};case"Expref":{const child=this.expression(bindingPower.Expref);return{type:"ExpressionReference",child}}case"Lparen":{const expression=this.expression(0);this.match("Rparen");return expression}default:this.errorToken(token)}}led(tokenName,left){switch(tokenName){case"Question":{const trueExpr=this.expression(0);this.match("Colon");const falseExpr=this.expression(0);
31
- return{type:"Ternary",condition:left,trueExpr,falseExpr}}case"Dot":{const rbp=bindingPower.Dot;if(this.lookahead(0)!=="Star"){const right2=this.parseDotRHS(rbp);return{type:"Subexpression",left,right:right2}}this.advance();const right=this.parseProjectionRHS(rbp);return{type:"ValueProjection",left,right}}case"Pipe":{const right=this.expression(bindingPower.Pipe);return{type:"Pipe",left,right}}case"Or":{const right=this.expression(bindingPower.Or);return{type:"OrExpression",left,right}}case"And":{
32
- const right=this.expression(bindingPower.And);return{type:"AndExpression",left,right}}case"Lparen":{if(left.type!=="Field"){throw new Error("Syntax error: expected a Field node")}const name=left.name;const args=this.parseCommaSeparatedExpressionsUntilToken("Rparen");const node={name,type:"Function",children:args};return node}case"Filter":{const condition=this.expression(0);this.match("Rbracket");const right=this.lookahead(0)==="Flatten"?{type:"Identity"}:this.parseProjectionRHS(bindingPower.Filter);
33
- return{type:"FilterProjection",left,right,condition}}case"Flatten":{const leftNode={type:"Flatten",child:left};const right=this.parseProjectionRHS(bindingPower.Flatten);return{type:"Projection",left:leftNode,right}}case"Assign":{const leftNode=left;const right=this.expression(0);return{type:"Binding",variable:leftNode.name,reference:right}}case"EQ":case"NE":case"GT":case"GTE":case"LT":case"LTE":return this.parseComparator(left,tokenName);case"Plus":case"Minus":case"Multiply":case"Star":case"Divi\
34
- de":case"Modulo":case"Div":return this.parseArithmetic(left,tokenName);case"Lbracket":{const token=this.lookaheadToken(0);if(token.type==="Number"||token.type==="Colon"){const right2=this.parseIndexExpression();return this.projectIfSlice(left,right2)}this.match("Star");this.match("Rbracket");const right=this.parseProjectionRHS(bindingPower.Star);return{type:"Projection",left,right}}default:return this.errorToken(this.lookaheadToken(0))}}static isKeyword(token,keyword){return token.type==="Unquot\
35
- edIdentifier"&&token.value===keyword}match(tokenType){if(this.lookahead(0)===tokenType){this.advance();return}else{const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error: expected ${tokenType}, got: ${token.type}`)}}errorToken(token,message=""){const error=new Error(message||`Syntax error: invalid token (${token.type}): "${token.value}"`);error.name="ParserError";throw error}parseIndexExpression(){if(this.lookahead(0)==="Colon"||this.lookahead(1)==="Colon"){return this.parseSliceExpression()}
36
- const value=Number(this.lookaheadToken(0).value);this.advance();this.match("Rbracket");return{type:"Index",value}}projectIfSlice(left,right){const indexExpr={type:"IndexExpression",left,right};if(right.type==="Slice"){const rhs=this.parseProjectionRHS(bindingPower.Star);if(rhs.type==="Identity"){return indexExpr}return{left:indexExpr,right:rhs,type:"Projection"}}return indexExpr}parseSliceExpression(){const parts=[null,null,null];let index=0;let current=this.lookaheadToken(0);while(current.type!=
37
- "Rbracket"&&index<3){if(current.type==="Colon"){index++;if(index===3){this.errorToken(this.lookaheadToken(0),"Syntax error, too many colons in slice expression")}this.advance()}else if(current.type==="Number"&&parts[index]===null){const part=this.lookaheadToken(0).value;parts[index]=part;this.advance()}else{const next=this.lookaheadToken(0);this.errorToken(next,`Syntax error, unexpected token: ${next.value}(${next.type})`)}current=this.lookaheadToken(0)}this.match("Rbracket");const[start,stop,step]=parts;
38
- return{type:"Slice",start,stop,step}}parseLetExpression(){const separated=this.parseCommaSeparatedExpressionsUntilKeyword("in");const expression=this.expression(0);const bindings=separated.map(binding=>binding);return{type:"LetExpression",bindings,expression}}parseCommaSeparatedExpressionsUntilKeyword(keyword){return this.parseCommaSeparatedExpressionsUntil(()=>{return _TokenParser.isKeyword(this.lookaheadToken(0),keyword)},()=>{this.advance()})}parseCommaSeparatedExpressionsUntilToken(token){return this.
39
- parseCommaSeparatedExpressionsUntil(()=>{return this.lookahead(0)===token},()=>{return this.match(token)})}parseCommaSeparatedExpressionsUntil(isEndToken,matchEndToken){const args=[];let expression;while(!isEndToken()){expression=this.expression(0);if(this.lookahead(0)==="Comma"){this.match("Comma")}args.push(expression)}matchEndToken();return args}parseComparator(left,comparator){const right=this.expression(bindingPower[comparator]);return{type:"Comparator",name:comparator,left,right}}parseArithmetic(left,operator){
40
- const right=this.expression(bindingPower[operator]);return{type:"Arithmetic",operator,left,right}}parseDotRHS(rbp){const lookahead=this.lookahead(0);const exprTokens=["UnquotedIdentifier","QuotedIdentifier","Star"];if(exprTokens.includes(lookahead)){return this.expression(rbp)}if(lookahead==="Lbracket"){this.match("Lbracket");return this.parseMultiselectList()}if(lookahead==="Lbrace"){this.match("Lbrace");return this.parseMultiselectHash()}const token=this.lookaheadToken(0);this.errorToken(token,
41
- `Syntax error, unexpected token: ${token.value}(${token.type})`)}parseProjectionRHS(rbp){if(bindingPower[this.lookahead(0)]<10){return{type:"Identity"}}if(this.lookahead(0)==="Lbracket"){return this.expression(rbp)}if(this.lookahead(0)==="Filter"){return this.expression(rbp)}if(this.lookahead(0)==="Dot"){this.match("Dot");return this.parseDotRHS(rbp)}const token=this.lookaheadToken(0);this.errorToken(token,`Syntax error, unexpected token: ${token.value}(${token.type})`)}parseMultiselectList(){const expressions=[];
42
- while(this.lookahead(0)!=="Rbracket"){const expression=this.expression(0);expressions.push(expression);if(this.lookahead(0)==="Comma"){this.match("Comma");if(this.lookahead(0)==="Rbracket"){throw new Error("Syntax error: unexpected token Rbracket")}}}this.match("Rbracket");return{type:"MultiSelectList",children:expressions}}parseMultiselectHash(){const pairs=[];const identifierTypes=["UnquotedIdentifier","QuotedIdentifier"];let keyToken;let keyName;let value;for(;;){keyToken=this.lookaheadToken(
43
- 0);if(!identifierTypes.includes(keyToken.type)){throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`)}keyName=keyToken.value;this.advance();this.match("Colon");value=this.expression(0);pairs.push({value,type:"KeyValuePair",name:keyName});if(this.lookahead(0)==="Comma"){this.match("Comma")}else if(this.lookahead(0)==="Rbrace"){this.match("Rbrace");break}}return{type:"MultiSelectHash",children:pairs}}};var Parser=new TokenParser;var Parser_default=Parser;var findFirst=(subject,sub2,start,end)=>{
44
- if(!subject||!sub2){return null}const s=Math.max(ensureInteger(start??0),0);const e=Math.min(ensureInteger(end??subject.length),subject.length);const offset=subject.slice(s,e).indexOf(sub2);return offset===-1?null:offset+s};var findLast=(subject,sub2,start,end)=>{if(!subject||!sub2){return null}const s=Math.max(ensureInteger(start??0),0);const e=Math.min(ensureInteger(end??subject.length),subject.length);const offset=subject.slice(s,e).lastIndexOf(sub2);return offset===-1?null:offset+s};var lower=subject=>subject.
45
- toLowerCase();var ensurePadFuncParams=(name,width,padding=" ")=>{if(padding.length>1){throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`)}ensurePositiveInteger(width);return padding};var padLeft=(subject,width,padding)=>{padding=ensurePadFuncParams("pad_left",width,padding);return subject&&subject.padStart(width,padding)||""};var padRight=(subject,width,padding)=>{padding=ensurePadFuncParams("pad_right",width,padding);return subject&&
46
- subject.padEnd(width,padding)||""};var replace=(subject,string,by,count)=>{if(count===0){return subject}if(!count){return subject.split(string).join(by)}ensurePositiveInteger(count);while(count-- >0&&subject.includes(string)){subject=subject.replace(string,by)}return subject};var split=(subject,search2,count)=>{if(subject.length==0&&search2.length===0){return[]}if(count===null||count===void 0){return subject.split(search2)}ensurePositiveInteger(count);if(count===0){return[subject]}const split2=subject.
47
- split(search2);return[...split2.slice(0,count),split2.slice(count).join(search2)]};var trim=(subject,chars)=>{return trimLeft(trimRight(subject,chars),chars)};var trimLeft=(subject,chars)=>{return trimImpl(subject,list=>new RegExp(`^[${list}]*(.*?)`),chars)};var trimRight=(subject,chars)=>{return trimImpl(subject,list=>new RegExp(`(.*?)[${list}]*$`),chars)};var trimImpl=(subject,regExper,chars)=>{const pattern=chars?chars.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"):"\\s\x85";return subject.replace(regExper(
48
- pattern),"$1")};var upper=subject=>subject.toUpperCase();var Text=class _Text{_text;constructor(text){this._text=text}get string(){return this._text}get length(){let count=0;for(const _ of this._text){count+=1}return count}compareTo(other){return _Text.compare(this,new _Text(other))}static get comparer(){const stringComparer=(left,right)=>{return new _Text(left).compareTo(right)};return stringComparer}static compare(left,right){const leftCp=left.codePoints;const rightCp=right.codePoints;for(let index=0;index<
49
- Math.min(leftCp.length,rightCp.length);index++){if(leftCp[index]===rightCp[index]){continue}return leftCp[index]-rightCp[index]>0?1:-1}return leftCp.length-rightCp.length>0?1:-1}reverse(){return String.fromCodePoint(...this.codePoints.reverse())}get codePoints(){const array=[...this._text].map(s=>s.codePointAt(0));return array}};var createMathFunction=mathFn=>([value])=>mathFn(value);var createStringFunction=stringFn=>([subject])=>stringFn(subject);var createObjectFunction=objFn=>([obj])=>objFn(
50
- obj);var ARRAY_SUBTYPES={[8]:0,[10]:4,[9]:2,[11]:3};var Runtime=class{_interpreter;_functionTable;_customFunctions=new Set;TYPE_NAME_TABLE=Object.freeze({[0]:"number",[1]:"any",[2]:"string",[3]:"array",[4]:"object",[5]:"boolean",[6]:"expression",[7]:"null",[8]:"Array<number>",[10]:"Array<object>",[9]:"Array<string>",[11]:"Array<Array<any>>"});constructor(interpreter){this._interpreter=interpreter;this._functionTable=this.buildFunctionTable()}buildFunctionTable(){return{abs:{_func:createMathFunction(
51
- Math.abs),_signature:[{types:[0]}]},ceil:{_func:createMathFunction(Math.ceil),_signature:[{types:[0]}]},floor:{_func:createMathFunction(Math.floor),_signature:[{types:[0]}]},lower:{_func:createStringFunction(lower),_signature:[{types:[2]}]},upper:{_func:createStringFunction(upper),_signature:[{types:[2]}]},keys:{_func:createObjectFunction(Object.keys),_signature:[{types:[4]}]},values:{_func:createObjectFunction(Object.values),_signature:[{types:[4]}]},avg:{_func:this.functionAvg,_signature:[{types:[
52
- 8]}]},contains:{_func:this.functionContains,_signature:[{types:[2,3]},{types:[1]}]},ends_with:{_func:this.functionEndsWith,_signature:[{types:[2]},{types:[2]}]},find_first:{_func:this.functionFindFirst,_signature:[{types:[2]},{types:[2]},{types:[0],optional:true},{types:[0],optional:true}]},find_last:{_func:this.functionFindLast,_signature:[{types:[2]},{types:[2]},{types:[0],optional:true},{types:[0],optional:true}]},from_items:{_func:this.functionFromItems,_signature:[{types:[11]}]},group_by:{_func:this.
53
- functionGroupBy,_signature:[{types:[3]},{types:[6]}]},items:{_func:this.functionItems,_signature:[{types:[4]}]},join:{_func:this.functionJoin,_signature:[{types:[2]},{types:[9]}]},length:{_func:this.functionLength,_signature:[{types:[2,3,4]}]},map:{_func:this.functionMap,_signature:[{types:[6]},{types:[3]}]},max:{_func:this.functionMax,_signature:[{types:[8,9]}]},max_by:{_func:this.functionMaxBy,_signature:[{types:[3]},{types:[6]}]},merge:{_func:this.functionMerge,_signature:[{types:[4],variadic:true}]},
54
- min:{_func:this.functionMin,_signature:[{types:[8,9]}]},min_by:{_func:this.functionMinBy,_signature:[{types:[3]},{types:[6]}]},not_null:{_func:this.functionNotNull,_signature:[{types:[1],variadic:true}]},pad_left:{_func:this.functionPadLeft,_signature:[{types:[2]},{types:[0]},{types:[2],optional:true}]},pad_right:{_func:this.functionPadRight,_signature:[{types:[2]},{types:[0]},{types:[2],optional:true}]},replace:{_func:this.functionReplace,_signature:[{types:[2]},{types:[2]},{types:[2]},{types:[
55
- 0],optional:true}]},reverse:{_func:this.functionReverse,_signature:[{types:[2,3]}]},sort:{_func:this.functionSort,_signature:[{types:[9,8]}]},sort_by:{_func:this.functionSortBy,_signature:[{types:[3]},{types:[6]}]},split:{_func:this.functionSplit,_signature:[{types:[2]},{types:[2]},{types:[0],optional:true}]},starts_with:{_func:this.functionStartsWith,_signature:[{types:[2]},{types:[2]}]},sum:{_func:this.functionSum,_signature:[{types:[8]}]},to_array:{_func:this.functionToArray,_signature:[{types:[
56
- 1]}]},to_number:{_func:this.functionToNumber,_signature:[{types:[1]}]},to_string:{_func:this.functionToString,_signature:[{types:[1]}]},trim:{_func:this.functionTrim,_signature:[{types:[2]},{types:[2],optional:true}]},trim_left:{_func:this.functionTrimLeft,_signature:[{types:[2]},{types:[2],optional:true}]},trim_right:{_func:this.functionTrimRight,_signature:[{types:[2]},{types:[2],optional:true}]},type:{_func:this.functionType,_signature:[{types:[1]}]},zip:{_func:this.functionZip,_signature:[{types:[
57
- 3],variadic:true}]}}}registerFunction(name,customFunction,signature,options){const result=this._registerInternal(name,customFunction,signature,options);if(!result.success){throw new Error(result.message)}}_registerInternal(name,customFunction,signature,options={}){if(!name||typeof name!=="string"||name.trim()===""){return{success:false,reason:"invalid-name",message:"Function name must be a non-empty string"}}try{this.validateInputSignatures(name,signature)}catch(error){return{success:false,reason:"\
58
- invalid-signature",message:error instanceof Error?error.message:"Invalid function signature"}}const{override=false,warn=false}=options;const exists=name in this._functionTable;if(exists&&!override){return{success:false,reason:"already-exists",message:`Function already defined: ${name}(). Use { override: true } to replace it.`}}if(exists&&override&&warn){console.warn(`Warning: Overriding existing function: ${name}()`)}this._functionTable[name]={_func:customFunction.bind(this),_signature:signature};
59
- this._customFunctions.add(name);const message=exists?`Function ${name}() overridden successfully`:`Function ${name}() registered successfully`;return{success:true,message}}register(name,customFunction,signature,options={}){return this._registerInternal(name,customFunction,signature,options)}unregister(name){if(!this._customFunctions.has(name)){return false}delete this._functionTable[name];this._customFunctions.delete(name);return true}isRegistered(name){return name in this._functionTable}getRegistered(){
60
- return Object.keys(this._functionTable)}getCustomFunctions(){return Array.from(this._customFunctions)}clearCustomFunctions(){for(const name of this._customFunctions){delete this._functionTable[name]}this._customFunctions.clear()}callFunction(name,resolvedArgs){const functionEntry=this._functionTable[name];if(functionEntry===void 0){throw new Error(`Unknown function: ${name}()`)}this.validateArgs(name,resolvedArgs,functionEntry._signature);return functionEntry._func.call(this,resolvedArgs)}validateInputSignatures(name,signature){
61
- for(let i=0;i<signature.length;i+=1){if("variadic"in signature[i]&&i!==signature.length-1){throw new Error(`Invalid arity: ${name}() 'variadic' argument ${i+1} must occur last`)}}}validateArgs(name,args,signature){this.validateInputSignatures(name,signature);this.validateArity(name,args,signature);this.validateTypes(name,args,signature)}validateArity(name,args,signature){const numberOfRequiredArgs=signature.filter(argSignature=>!(argSignature.optional??false)).length;const lastArgIsVariadic=signature[signature.
62
- length-1]?.variadic??false;const tooFewArgs=args.length<numberOfRequiredArgs;const tooManyArgs=args.length>signature.length;if(lastArgIsVariadic&&tooFewArgs||!lastArgIsVariadic&&(tooFewArgs||tooManyArgs)){const tooFewModifier=tooFewArgs&&(!lastArgIsVariadic&&numberOfRequiredArgs>1||lastArgIsVariadic)?"at least ":"";const pluralized=signature.length>1;throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized&&"s"||""} but received ${args.length}`)}}validateTypes(name,args,signature){
63
- for(let i=0;i<signature.length;i+=1){const currentSpec=signature[i].types;const actualType=this.getTypeName(args[i]);if(actualType===void 0){continue}const typeMatched=currentSpec.some(expectedType=>this.typeMatches(actualType,expectedType,args[i]));if(!typeMatched){const expected=currentSpec.map(typeId=>this.TYPE_NAME_TABLE[typeId]).join(" | ");throw new Error(`Invalid type: ${name}() expected argument ${i+1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead\
64
- .`)}}}typeMatches(actual,expected,argValue){if(expected===1){return true}const subtype=ARRAY_SUBTYPES[expected];if(subtype!==void 0){if(actual!==3){return false}const array=argValue;return array.every(item=>{const typeName=this.getTypeName(item);return typeName===void 0||this.typeMatches(typeName,subtype,item)})}return actual===expected}getTypeName(obj){if(obj===null){return 7}if(typeof obj==="string"){return 2}if(typeof obj==="number"){return 0}if(typeof obj==="boolean"){return 5}if(Array.isArray(
65
- obj)){return 3}if(typeof obj==="object"){if(obj.expref){return 6}return 4}return}createKeyFunction(exprefNode,allowedTypes){const interpreter=this._interpreter;const keyFunc=x=>{const current=interpreter.visit(exprefNode,x);if(!allowedTypes.includes(this.getTypeName(current))){const msg=`Invalid type: expected one of (${allowedTypes.map(t=>this.TYPE_NAME_TABLE[t]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(current)]}`;throw new Error(msg)}return current};return keyFunc}functionAvg=([
66
- inputArray])=>{if(!inputArray||inputArray.length==0){return null}let sum=0;for(let i=0;i<inputArray.length;i+=1){sum+=inputArray[i]}return sum/inputArray.length};functionContains=([searchable,searchValue])=>{if(Array.isArray(searchable)){const array=searchable;return array.includes(searchValue)}if(typeof searchable==="string"){const text=searchable;if(typeof searchValue==="string"){return text.includes(searchValue)}}return null};functionEndsWith=([searchStr,suffix])=>{return searchStr.endsWith(suffix)};functionFindFirst=this.
67
- createFindFunction(findFirst);functionFindLast=this.createFindFunction(findLast);createFindFunction(findFn){return resolvedArgs=>{const subject=resolvedArgs[0];const search2=resolvedArgs[1];const start=resolvedArgs.length>2?resolvedArgs[2]:void 0;const end=resolvedArgs.length>3?resolvedArgs[3]:void 0;return findFn(subject,search2,start,end)}}functionFromItems=([array])=>{for(const pair of array){if(pair.length!==2||typeof pair[0]!=="string"){throw new Error("invalid value, each array must contai\
68
- n two elements, a pair of string and value")}}return Object.fromEntries(array)};functionGroupBy=([array,exprefNode])=>{const keyFunction=this.createKeyFunction(exprefNode,[2]);const groups={};for(const item of array){const key=keyFunction(item);if(!groups[key]){groups[key]=[]}groups[key].push(item)}return groups};functionItems=([inputValue])=>{return Object.entries(inputValue)};functionJoin=resolvedArgs=>{const[joinChar,listJoin]=resolvedArgs;return listJoin.join(joinChar)};functionLength=([inputValue])=>{
69
- if(typeof inputValue==="string"){return new Text(inputValue).length}if(Array.isArray(inputValue)){return inputValue.length}return Object.keys(inputValue).length};functionMap=([exprefNode,elements])=>{if(!this._interpreter){return[]}const mapped=[];const interpreter=this._interpreter;for(let i=0;i<elements.length;i+=1){mapped.push(interpreter.visit(exprefNode,elements[i]))}return mapped};functionMax=([inputValue])=>{if(!inputValue.length){return null}const typeName=this.getTypeName(inputValue[0]);
70
- if(typeName===0){return Math.max(...inputValue)}const elements=inputValue;let maxElement=elements[0];for(let i=1;i<elements.length;i+=1){if(maxElement.localeCompare(elements[i])<0){maxElement=elements[i]}}return maxElement};functionMaxBy=resolvedArgs=>{const exprefNode=resolvedArgs[1];const resolvedArray=resolvedArgs[0];const keyFunction=this.createKeyFunction(exprefNode,[0,2]);let maxNumber=-Infinity;let maxRecord;let current;for(let i=0;i<resolvedArray.length;i+=1){current=keyFunction&&keyFunction(
71
- resolvedArray[i]);if(current!==void 0&&current>maxNumber){maxNumber=current;maxRecord=resolvedArray[i]}}return maxRecord||null};functionMerge=resolvedArgs=>{return Object.assign({},...resolvedArgs)};functionMin=([inputValue])=>{if(!inputValue.length){return null}const typeName=this.getTypeName(inputValue[0]);if(typeName===0){return Math.min(...inputValue)}const elements=inputValue;let minElement=elements[0];for(let i=1;i<elements.length;i+=1){if(elements[i].localeCompare(minElement)<0){minElement=
72
- elements[i]}}return minElement};functionMinBy=resolvedArgs=>{const exprefNode=resolvedArgs[1];const resolvedArray=resolvedArgs[0];const keyFunction=this.createKeyFunction(exprefNode,[0,2]);let minNumber=Infinity;let minRecord;let current;for(let i=0;i<resolvedArray.length;i+=1){current=keyFunction&&keyFunction(resolvedArray[i]);if(current!==void 0&&current<minNumber){minNumber=current;minRecord=resolvedArray[i]}}return minRecord||null};functionNotNull=resolvedArgs=>{return resolvedArgs.find(arg=>arg!==
73
- null)??null};functionPadLeft=this.createPadFunction(padLeft);functionPadRight=this.createPadFunction(padRight);createPadFunction(padFn){return resolvedArgs=>{const subject=resolvedArgs[0];const width=resolvedArgs[1];const padding=resolvedArgs.length>2?resolvedArgs[2]:void 0;return padFn(subject,width,padding)}}functionReplace=resolvedArgs=>{const subject=resolvedArgs[0];const string=resolvedArgs[1];const by=resolvedArgs[2];return replace(subject,string,by,resolvedArgs.length>3?resolvedArgs[3]:void 0)};functionSplit=resolvedArgs=>{
74
- const subject=resolvedArgs[0];const search2=resolvedArgs[1];return split(subject,search2,resolvedArgs.length>2?resolvedArgs[2]:void 0)};functionReverse=([inputValue])=>{const typeName=this.getTypeName(inputValue);if(typeName===2){return new Text(inputValue).reverse()}const reversedArray=[...inputValue];reversedArray.reverse();return reversedArray};functionSort=([inputValue])=>{if(inputValue.length<=1){return inputValue}if(typeof inputValue[0]==="string"){return[...inputValue].sort(Text.comparer)}
75
- return[...inputValue].sort()};functionSortBy=resolvedArgs=>{const sortedArray=[...resolvedArgs[0]];if(sortedArray.length<=1){return sortedArray}const interpreter=this._interpreter;const exprefNode=resolvedArgs[1];const requiredType=this.getTypeName(interpreter.visit(exprefNode,sortedArray[0]));if(requiredType!==void 0&&![0,2].includes(requiredType)){throw new Error(`Invalid type: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`)}function throwInvalidTypeError(rt,item){throw new Error(`In\
76
- valid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`)}return sortedArray.sort((a,b)=>{const exprA=interpreter.visit(exprefNode,a);const exprB=interpreter.visit(exprefNode,b);if(this.getTypeName(exprA)!==requiredType){throwInvalidTypeError(this,exprA)}else if(this.getTypeName(exprB)!==requiredType){throwInvalidTypeError(this,exprB)}if(requiredType===2){return Text.comparer(exprA,exprB)}return exprA-exprB})};functionStartsWith=([searchable,
77
- searchStr])=>{return searchable.startsWith(searchStr)};functionSum=([inputValue])=>{return inputValue.reduce((x,y)=>x+y,0)};functionToArray=([inputValue])=>{return Array.isArray(inputValue)?inputValue:[inputValue]};functionToNumber=([inputValue])=>{const typeName=this.getTypeName(inputValue);let convertedValue;if(typeName===0){return inputValue}if(typeName===2){convertedValue=+inputValue;if(!isNaN(convertedValue)){return convertedValue}}return null};functionToString=([inputValue])=>{return typeof inputValue===
78
- "string"?inputValue:JSON.stringify(inputValue)};functionTrim=this.createTrimFunction(trim);functionTrimLeft=this.createTrimFunction(trimLeft);functionTrimRight=this.createTrimFunction(trimRight);createTrimFunction(trimFn){return resolvedArgs=>{const subject=resolvedArgs[0];const chars=resolvedArgs.length>1?resolvedArgs[1]:void 0;return trimFn(subject,chars)}}functionType=([inputValue])=>{const type=this.getTypeName(inputValue);const name=type!==void 0?this.TYPE_NAME_TABLE[type]:void 0;if(!name){
79
- throw new Error("invalid-type")}return name};functionZip=array=>{const length=Math.min(...array.map(arr=>arr.length));return Array.from({length},(_,index)=>array.map(arr=>arr[index]))}};var ScopeChain=class _ScopeChain{inner=void 0;data={};get currentScopeData(){return this.data}withScope(data){const outer=new _ScopeChain;outer.inner=this;outer.data=data;return outer}getValue(identifier){if(Object.prototype.hasOwnProperty.call(this.data,identifier)){return this.data[identifier]}if(this.inner){return this.
80
- inner.getValue(identifier)}return null}};var emptyScopeChain=new ScopeChain;var TreeInterpreter=class _TreeInterpreter{runtime;_rootValue=null;_scope;_options;_depth=0;_deadline=0;constructor(options){this.runtime=new Runtime(this);this._scope=new ScopeChain;if(options){this._options=options;this._deadline=options.timeoutMs!==void 0?Date.now()+options.timeoutMs:0}}withScope(scope){const interpreter=new _TreeInterpreter(this._options);interpreter.runtime._functionTable=this.runtime._functionTable;
81
- interpreter._rootValue=this._rootValue;interpreter._scope=this._scope.withScope(scope);interpreter._depth=this._depth;interpreter._deadline=this._deadline;return interpreter}search(node,value,options){if(options?.maxNodes!==void 0&&countNodes(node)>options.maxNodes){throw new Error(`Expression exceeds maximum allowed node count of ${options.maxNodes}`)}this._rootValue=value;this._scope=emptyScopeChain;this._options=options;this._depth=0;this._deadline=options?.timeoutMs!==void 0?Date.now()+options.
82
- timeoutMs:0;const result=this.visit(node,value);this.checkOutputSize(result);return result}checkOutputSize(val){const max=this._options?.maxOutputSize;if(max===void 0||val==null){return}const size=Array.isArray(val)||typeof val==="string"?val.length:typeof val==="object"?Object.keys(val).length:0;if(size>max){throw new Error(`Output size exceeds maximum allowed size of ${max}`)}}collect(target,item){target.push(item);if(this._options?.maxOutputSize!==void 0&&target.length>this._options.maxOutputSize){
83
- throw new Error(`Output size exceeds maximum allowed size of ${this._options.maxOutputSize}`)}}evaluateProjectionItems(items,right){const collected=[];if(right.type==="Field"){const key=right.name;for(let i=0;i<items.length;i++){if(this._deadline>0&&Date.now()>=this._deadline){throw new Error(`Query execution timed out after ${this._options?.timeoutMs}ms`)}const elem=items[i];if(!elem||typeof elem!=="object"||Array.isArray(elem)){continue}const val=elem[key];if(val!==void 0&&val!==null){this.collect(
84
- collected,val)}}return collected}if(right.type==="Identity"){for(let i=0;i<items.length;i++){const elem=items[i];if(elem!==null){this.collect(collected,elem)}}return collected}for(const elem of items){const current=this.visit(right,elem);if(current!==null){this.collect(collected,current)}}return collected}visit(node,value){if(this._options){if(this._options.maxDepth!==void 0&&this._depth>=this._options.maxDepth){throw new Error(`Evaluation exceeds maximum allowed depth of ${this._options.maxDepth}`)}
85
- if(this._deadline>0&&Date.now()>=this._deadline){throw new Error(`Query execution timed out after ${this._options.timeoutMs}ms`)}}this._depth+=1;try{return this.evaluateNode(node,value)}finally{this._depth-=1}}evaluateNode(node,value){switch(node.type){case"Ternary":{const condition=this.visit(node.condition,value);if(!isFalse(condition)){return this.visit(node.trueExpr,value)}return this.visit(node.falseExpr,value)}case"Field":const identifier=node.name;if(value===null||typeof value!=="object"||
86
- Array.isArray(value)){return null}return value[identifier]??null;case"LetExpression":{const scope={};for(const binding of node.bindings){Object.assign(scope,this.visit(binding,value))}return this.withScope(scope).visit(node.expression,value)}case"Binding":{const{variable,reference}=node;const result=this.visit(reference,value);return{[variable]:result}}case"Variable":{const variable=node.name;if(!this._scope.getValue(variable)&&!Object.prototype.hasOwnProperty.call(this._scope.currentScopeData,variable)){
87
- throw new Error(`Error referencing undefined variable ${variable}`)}return this._scope.getValue(variable)}case"IndexExpression":return this.visit(node.right,this.visit(node.left,value));case"Subexpression":{const result=this.visit(node.left,value);return result!=null?this.visit(node.right,result)??null:null}case"Index":{if(!Array.isArray(value)){return null}const index=node.value<0?value.length+node.value:node.value;return value[index]??null}case"Slice":{if(!Array.isArray(value)&&typeof value!==
88
- "string"){return null}const{start,stop,step}=this.computeSliceParams(value.length,node);const target=typeof value==="string"?[...value]:value;const sliced=this.slice(target,start,stop,step);const res=typeof value==="string"?sliced.join(""):sliced;this.checkOutputSize(res);return res}case"Projection":{const{left,right}=node;const allowString=left.type==="IndexExpression"&&left.right.type==="Slice";const base=this.visit(left,value);if(allowString&&typeof base==="string"){return this.visit(right,base)}
89
- return Array.isArray(base)?this.evaluateProjectionItems(base,right):null}case"ValueProjection":{const base=this.visit(node.left,value);if(base===null||typeof base!=="object"||Array.isArray(base)){return null}return this.evaluateProjectionItems(Object.values(base),node.right)}case"FilterProjection":{const{left,right,condition}=node;const base=this.visit(left,value);if(!Array.isArray(base)){return null}const results=[];if(right.type==="Field"){const key=right.name;for(let i=0;i<base.length;i++){const elem=base[i];
90
- if(isFalse(this.visit(condition,elem))){continue}if(!elem||typeof elem!=="object"||Array.isArray(elem)){continue}const val=elem[key];if(val!==void 0&&val!==null){this.collect(results,val)}}return results}if(right.type==="Identity"){for(let i=0;i<base.length;i++){const elem=base[i];if(isFalse(this.visit(condition,elem))){continue}if(elem!==null){this.collect(results,elem)}}return results}for(const elem of base){if(isFalse(this.visit(condition,elem))){continue}const result=this.visit(right,elem);if(result!==
91
- null){this.collect(results,result)}}return results}case"Arithmetic":{const first=this.visit(node.left,value);const second=this.visit(node.right,value);switch(node.operator){case"Plus":return add(first,second);case"Minus":return sub(first,second);case"Multiply":case"Star":return mul(first,second);case"Divide":return divide(first,second);case"Modulo":return mod(first,second);case"Div":return div(first,second);default:throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`)}}case"\
92
- Unary":{const operand=this.visit(node.operand,value);switch(node.operator){case"Plus":ensureNumbers(operand);return operand;case"Minus":ensureNumbers(operand);return-operand;default:throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`)}}case"Comparator":{const first=this.visit(node.left,value);const second=this.visit(node.right,value);switch(node.name){case"EQ":return strictDeepEqual(first,second);case"NE":return!strictDeepEqual(first,second)}if(typeof first!=="number"||
93
- typeof second!=="number"){return null}switch(node.name){case"GT":return first>second;case"GTE":return first>=second;case"LT":return first<second;case"LTE":return first<=second}}case"Flatten":{const original=this.visit(node.child,value);const res=Array.isArray(original)?original.flat():null;this.checkOutputSize(res);return res}case"Root":return this._rootValue;case"MultiSelectList":{const collected=[];for(const child of node.children){collected.push(this.visit(child,value))}this.checkOutputSize(collected);
94
- return collected}case"MultiSelectHash":{const collected={};for(const child of node.children){collected[child.name]=this.visit(child.value,value)}this.checkOutputSize(collected);return collected}case"OrExpression":{const result=this.visit(node.left,value);if(isFalse(result)){return this.visit(node.right,value)}return result}case"AndExpression":{const result=this.visit(node.left,value);if(isFalse(result)){return result}return this.visit(node.right,value)}case"NotExpression":return isFalse(this.visit(
95
- node.child,value));case"Literal":return node.value;case"Pipe":return this.visit(node.right,this.visit(node.left,value));case"Function":{if(this._options?.allowedFunctions&&!this._options.allowedFunctions.includes(node.name)){throw new Error(`Function '${node.name}' is not allowed`)}if(this._options?.disallowedFunctions&&this._options.disallowedFunctions.includes(node.name)){throw new Error(`Function '${node.name}' is disallowed`)}const args=[];for(const child of node.children){args.push(this.visit(
96
- child,value))}const res=this.runtime.callFunction(node.name,args);this.checkOutputSize(res);return res}case"ExpressionReference":return{expref:true,...node.child};case"Current":case"Identity":return value}}computeSliceParams(arrayLength,sliceNode){let{start,stop,step}=sliceNode;if(step===null){step=1}else if(step===0){const error=new Error("Invalid value: slice step cannot be 0");error.name="RuntimeError";throw error}start=start===null?step<0?arrayLength-1:0:this.capSliceRange(arrayLength,start,
97
- step);stop=stop===null?step<0?-1:arrayLength:this.capSliceRange(arrayLength,stop,step);return{start,stop,step}}capSliceRange(arrayLength,actualValue,step){let nextActualValue=actualValue;if(nextActualValue<0){nextActualValue+=arrayLength;if(nextActualValue<0){nextActualValue=step<0?-1:0}}else if(nextActualValue>=arrayLength){nextActualValue=step<0?arrayLength-1:arrayLength}return nextActualValue}slice(collection,start,end,step){if(step===1){return collection.slice(start,end)}const len=Math.max(0,
98
- Math.ceil((end-start)/step));const result=new Array(len);let idx=0;if(step>0){for(let i=start;i<end;i+=step){result[idx++]=collection[i]}}else{for(let i=start;i>end;i+=step){result[idx++]=collection[i]}}return result}};var TreeInterpreterInstance=new TreeInterpreter;var TreeInterpreter_default=TreeInterpreterInstance;async function*toAsyncIterable(source){if(source==null){return}if(typeof source!=="object"&&typeof source!=="function"){throw new TypeError("Invalid stream source: expected AsyncIte\
99
- rable, Iterable, or ReadableStream")}if(Symbol.asyncIterator in source){for await(const chunk of source){yield chunk}return}if(typeof source.getReader==="function"){const reader=source.getReader();try{while(true){const{done,value}=await reader.read();if(done){break}yield value}}finally{reader.releaseLock()}return}if(Symbol.iterator in source){for(const chunk of source){yield chunk}return}throw new TypeError("Invalid stream source: expected AsyncIterable, Iterable, or ReadableStream")}function parseItem(str,parseJson){
100
- if(parseJson===true){return JSON.parse(str)}if(parseJson==="auto"){try{return JSON.parse(str)}catch{return str}}return str}async function*normalizeSource(source,options){const parseJson=options?.parseJson??"auto";const flatten=options?.flattenChunks??true;let buffer="";const textDecoder=typeof TextDecoder!=="undefined"?new TextDecoder:null;for await(const chunk of toAsyncIterable(source)){if(chunk instanceof Uint8Array&&textDecoder){buffer+=textDecoder.decode(chunk,{stream:true});if(buffer.includes(
101
- "\n")){const lines=buffer.split("\n");buffer=lines.pop()??"";for(const line of lines){const trimmed=line.trim();if(trimmed){yield parseItem(trimmed,parseJson)}}}}else if(typeof chunk==="string"){if(parseJson===false){yield chunk}else{buffer+=chunk;if(buffer.includes("\n")){const lines=buffer.split("\n");buffer=lines.pop()??"";for(const line of lines){const trimmed=line.trim();if(trimmed){yield parseItem(trimmed,parseJson)}}}}}else if(flatten&&Array.isArray(chunk)){if(buffer.trim()){yield parseItem(
102
- buffer.trim(),parseJson);buffer=""}for(let i=0;i<chunk.length;i++){yield chunk[i]}}else{if(buffer.trim()){yield parseItem(buffer.trim(),parseJson);buffer=""}yield chunk}}if(textDecoder&&buffer){buffer+=textDecoder.decode()}if(buffer.trim()){yield parseItem(buffer.trim(),parseJson)}}function isStreamableNode(node){switch(node.type){case"Projection":if(node.left.type==="Identity"||node.left.type==="Current"){return true}if(node.left.type==="IndexExpression"&&node.left.right.type==="Slice"){const slice=node.
103
- left.right;return(slice.start===null||slice.start>=0)&&(slice.stop===null||slice.stop>=0)&&(slice.step===null||slice.step>0)}return false;case"FilterProjection":return node.left.type==="Identity"||node.left.type==="Current";case"IndexExpression":if(node.right.type==="Slice"&&(node.left.type==="Identity"||node.left.type==="Current")){const slice=node.right;return(slice.start===null||slice.start>=0)&&(slice.stop===null||slice.stop>=0)&&(slice.step===null||slice.step>0)}return true;case"Field":case"\
104
- Identity":case"Current":case"Subexpression":case"MultiSelectHash":case"MultiSelectList":case"Ternary":case"Comparator":case"Arithmetic":case"NotExpression":return true;case"Pipe":return isStreamableNode(node.left)&&isStreamableNode(node.right);default:return false}}async function*evaluateStreamNode(source,node,interpreter,options){const deadline=options?.timeoutMs!==void 0?Date.now()+options.timeoutMs:0;function checkDeadline(){if(deadline>0&&Date.now()>=deadline){throw new Error(`Query executio\
105
- n timed out after ${options?.timeoutMs}ms`)}}switch(node.type){case"Projection":{const{left,right}=node;let streamSource=source;if(left.type==="IndexExpression"&&left.right.type==="Slice"){streamSource=evaluateStreamNode(source,left,interpreter,options)}if(right.type==="Identity"||right.type==="Current"){for await(const item of streamSource){checkDeadline();if(item!==null&&item!==void 0){yield item}}return}if(right.type==="Field"){const key=right.name;for await(const item of streamSource){checkDeadline();
106
- if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==null){yield val}}}return}for await(const item of streamSource){checkDeadline();const res=interpreter.visit(right,item);if(res!==null&&res!==void 0){yield res}}return}case"IndexExpression":{if(node.right.type==="Slice"&&(node.left.type==="Identity"||node.left.type==="Current")){const slice=node.right;const start=slice.start??0;const stop=slice.stop??Infinity;const step=slice.step??1;if(start>=0&&stop>=
107
- 0&&step>0){let index=0;for await(const item of source){checkDeadline();if(index>=stop){break}if(index>=start&&(index-start)%step===0){yield item}index++;if(index>=stop){break}}return}const collected=[];for await(const item of source){checkDeadline();collected.push(item);if(options?.maxOutputSize!==void 0&&collected.length>options.maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${options.maxOutputSize}`)}}const result=interpreter.search(node,collected,options);if(Array.
108
- isArray(result)){for(const item of result){yield item}}return}for await(const item of source){checkDeadline();const res=interpreter.visit(node,item);if(res!==null&&res!==void 0){yield res}}return}case"FilterProjection":{const{condition,right}=node;if(right.type==="Identity"||right.type==="Current"){for await(const item of source){checkDeadline();if(!isFalse(interpreter.visit(condition,item))){yield item}}return}if(right.type==="Field"){const key=right.name;for await(const item of source){checkDeadline();
109
- if(!isFalse(interpreter.visit(condition,item))){if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==null){yield val}}}}return}for await(const item of source){checkDeadline();if(!isFalse(interpreter.visit(condition,item))){const res=interpreter.visit(right,item);if(res!==null&&res!==void 0){yield res}}}return}case"Pipe":{const leftStream=evaluateStreamNode(source,node.left,interpreter,options);if(isStreamableNode(node.right)){for await(const res of evaluateStreamNode(
110
- leftStream,node.right,interpreter,options)){yield res}}else{const collected=[];for await(const item of leftStream){checkDeadline();collected.push(item);if(options?.maxOutputSize!==void 0&&collected.length>options.maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${options.maxOutputSize}`)}}const result=interpreter.search(node.right,collected,options);if(result!==null&&result!==void 0){yield result}}return}case"Identity":case"Current":{for await(const item of source){checkDeadline();
111
- yield item}return}case"Field":{const key=node.name;for await(const item of source){checkDeadline();if(item&&typeof item==="object"&&!Array.isArray(item)){const val=item[key];if(val!==void 0&&val!==null){yield val}}}return}default:{if(isStreamableNode(node)){for await(const item of source){checkDeadline();const res=interpreter.visit(node,item);if(res!==null&&res!==void 0){yield res}}return}const collected=[];for await(const item of source){checkDeadline();collected.push(item);if(options?.maxOutputSize!==
112
- void 0&&collected.length>options.maxOutputSize){throw new Error(`Output size exceeds maximum allowed size of ${options.maxOutputSize}`)}}const result=interpreter.search(node,collected,options);if(result!==null&&result!==void 0){yield result}return}}}function isExpressionNode(val){return typeof val==="object"&&val!==null&&"type"in val&&typeof val.type==="string"&&!(Symbol.iterator in val)&&!(Symbol.asyncIterator in val)}async function*searchStream(sourceOrExpression,expressionOrSource,options){let expression;
113
- let source;if(typeof sourceOrExpression==="string"||isExpressionNode(sourceOrExpression)){expression=sourceOrExpression;source=expressionOrSource}else{source=sourceOrExpression;expression=expressionOrSource}if(typeof expression!=="string"&&!isExpressionNode(expression)){throw new TypeError("Expression must be a string or AST ExpressionNode")}const ast=typeof expression==="string"?Parser_default.parse(expression,options):expression;if(options){const fnError=findDisallowedFunction(ast,options);if(fnError){
114
- throw new Error(fnError)}}const interpreter=new TreeInterpreter(options);interpreter.runtime._functionTable=TreeInterpreterInstance.runtime._functionTable;const items=normalizeSource(source,options);const results=evaluateStreamNode(items,ast,interpreter,options);const limit=options?.limit;const maxOutputSize=options?.maxOutputSize;let count=0;for await(const result of results){yield result;count++;if(limit!==void 0&&count>=limit){break}if(maxOutputSize!==void 0&&count>maxOutputSize){throw new Error(
115
- `Output size exceeds maximum allowed size of ${maxOutputSize}`)}}}var TYPE_ANY=1;var TYPE_ARRAY=3;var TYPE_ARRAY_ARRAY=11;var TYPE_ARRAY_NUMBER=8;var TYPE_ARRAY_OBJECT=10;var TYPE_ARRAY_STRING=9;var TYPE_BOOLEAN=5;var TYPE_EXPREF=6;var TYPE_NULL=7;var TYPE_NUMBER=0;var TYPE_OBJECT=4;var TYPE_STRING=2;function compile(expression,options){return Parser_default.parse(expression,options)}function compileQuery(expression,options){const nodeTree=Parser_default.parse(expression,options);const fn=function(data){
116
- return TreeInterpreter_default.search(nodeTree,data,options)};fn.search=data=>TreeInterpreter_default.search(nodeTree,data,options);fn.searchStream=(source,streamOptions)=>searchStream(source,nodeTree,{...options,...streamOptions});fn.ast=nodeTree;return fn}function validate(expression,options){if(typeof expression!=="string"){return{valid:false,error:"Expression must be a string"}}try{const ast=Parser_default.parse(expression,options);if(options){const fnError=findDisallowedFunction(ast,options);
117
- if(fnError){return{valid:false,error:fnError}}}return{valid:true,ast}}catch(err){return{valid:false,error:err instanceof Error?err.message:String(err)}}}function tokenize(expression,options){return Lexer_default.tokenize(expression,options)}var registerFunction=(functionName,customFunction,signature,options)=>{TreeInterpreter_default.runtime.registerFunction(functionName,customFunction,signature,options)};var register=(name,customFunction,signature,options)=>{return TreeInterpreter_default.runtime.
118
- register(name,customFunction,signature,options)};var unregisterFunction=name=>{return TreeInterpreter_default.runtime.unregister(name)};var isRegistered=name=>{return TreeInterpreter_default.runtime.isRegistered(name)};var getRegisteredFunctions=()=>{return TreeInterpreter_default.runtime.getRegistered()};var getCustomFunctions=()=>{return TreeInterpreter_default.runtime.getCustomFunctions()};var clearCustomFunctions=()=>{TreeInterpreter_default.runtime.clearCustomFunctions()};var MAX_CACHE_SIZE=1e3;
119
- var astCache=new Map;function search(data,expression,options){let nodeTree;if(!options){nodeTree=astCache.get(expression);if(!nodeTree){nodeTree=Parser_default.parse(expression);if(astCache.size>=MAX_CACHE_SIZE){const firstKey=astCache.keys().next().value;if(firstKey!==void 0){astCache.delete(firstKey)}}astCache.set(expression,nodeTree)}}else{nodeTree=Parser_default.parse(expression,options)}return TreeInterpreter_default.search(nodeTree,data,options)}function Scope(){return new ScopeChain}var TreeInterpreter2=TreeInterpreter_default;
120
- var jmespath={compile,compileQuery,searchStream,validate,registerFunction,register,unregisterFunction,isRegistered,getRegisteredFunctions,getCustomFunctions,clearCustomFunctions,search,tokenize,TreeInterpreter:TreeInterpreter2,TYPE_ANY,TYPE_ARRAY_NUMBER,TYPE_ARRAY_STRING,TYPE_ARRAY,TYPE_BOOLEAN,TYPE_EXPREF,TYPE_NULL,TYPE_NUMBER,TYPE_OBJECT,TYPE_STRING,TYPE_ARRAY_ARRAY,TYPE_ARRAY_OBJECT,Scope};var index_default=jmespath;export{Scope,TYPE_ANY,TYPE_ARRAY,TYPE_ARRAY_ARRAY,TYPE_ARRAY_NUMBER,TYPE_ARRAY_OBJECT,TYPE_ARRAY_STRING,TYPE_BOOLEAN,TYPE_EXPREF,TYPE_NULL,TYPE_NUMBER,TYPE_OBJECT,TYPE_STRING,TreeInterpreter2 as TreeInterpreter,clearCustomFunctions,compile,compileQuery,index_default as default,getCustomFunctions,getRegisteredFunctions,isRegistered,jmespath,register,registerFunction,search,searchStream,tokenize,unregisterFunction,validate};