@tocca-systems/twp-cli 0.158.1 → 0.158.3

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 (45) hide show
  1. package/CHANGELOG.public.md +14 -0
  2. package/README.md +9 -0
  3. package/dist/{agent-VRFUCPH5.js → agent-I6MKKNYP.js} +2 -2
  4. package/dist/{api-command-2Z2H462U.js → api-command-76N52GZT.js} +2 -2
  5. package/dist/{app-UVBHL2L2.js → app-QWNCGPEZ.js} +4 -4
  6. package/dist/{auto-update-worker-VB2VIC2C.js → auto-update-worker-4GIMV7EV.js} +1 -1
  7. package/dist/{brief-JKHTU72A.js → brief-OW5YOYT5.js} +3 -3
  8. package/dist/{chunk-FQAOA2D6.js → chunk-2D7O2P5K.js} +1 -1
  9. package/dist/chunk-3APVCE7V.js +20 -0
  10. package/dist/{chunk-EX3K3K5L.js → chunk-42SA4SIR.js} +1 -1
  11. package/dist/{chunk-63HAA5LI.js → chunk-6M5N6VII.js} +1 -1
  12. package/dist/chunk-B5DMHZQH.js +11 -0
  13. package/dist/{chunk-SGED65UG.js → chunk-H2GCFUO7.js} +1 -1
  14. package/dist/{chunk-PQPDNZF2.js → chunk-IZ4KKMN4.js} +1 -1
  15. package/dist/{chunk-X7I2MXZE.js → chunk-JJJQF2FO.js} +60 -49
  16. package/dist/{chunk-V66R2IQU.js → chunk-NDPCXHJM.js} +1 -1
  17. package/dist/{chunk-E7TTXK27.js → chunk-SKML23XJ.js} +10 -10
  18. package/dist/{chunk-N4M7KM6M.js → chunk-TFLRZ77K.js} +2 -2
  19. package/dist/{chunk-4XPLEU5I.js → chunk-U3YHZSQW.js} +1 -1
  20. package/dist/cli.js +11 -11
  21. package/dist/{commands-AJGBNBFE.js → commands-EDVCRMHB.js} +1 -1
  22. package/dist/{commands-P62VLORG.js → commands-HKXCJ65Y.js} +8 -7
  23. package/dist/{commands-YTWSEJPL.js → commands-OO3G4X5Z.js} +1 -1
  24. package/dist/{company-HM3T6GMR.js → company-PANBAKRG.js} +2 -2
  25. package/dist/{contract-VNEESYMW.js → contract-UIBOJSJ2.js} +2 -2
  26. package/dist/{corporate-EJDTWEZF.js → corporate-FWRVJBTO.js} +2 -2
  27. package/dist/{estimate-MIBZGO55.js → estimate-ISQCRNGD.js} +2 -2
  28. package/dist/{github-CXZYWXX6.js → github-DA6HOV2E.js} +3 -3
  29. package/dist/{github-git-RJSZNVGE.js → github-git-YXJWAEGL.js} +2 -2
  30. package/dist/{invoice-Y4BQYBFW.js → invoice-RVQLQFR4.js} +2 -2
  31. package/dist/{leave-VMCCIHXZ.js → leave-BSEAFJU7.js} +2 -2
  32. package/dist/{media-H3N6OUL3.js → media-ZDYJBVWV.js} +2 -2
  33. package/dist/{oneshot-LZHXHAQM.js → oneshot-NJJBZEZE.js} +32 -26
  34. package/dist/{purchase-5IX7APWV.js → purchase-CNJFOSL7.js} +2 -2
  35. package/dist/{registry-HDW7TOLI.js → registry-JI4WVZZE.js} +1 -1
  36. package/dist/{run-XYRBN4AI.js → run-XZGIUI4U.js} +2 -2
  37. package/dist/{sales-ai-review-C4PP5AWL.js → sales-ai-review-PFBHUVWK.js} +2 -2
  38. package/dist/{sales-master-HWVXQCCO.js → sales-master-PLO2P7DW.js} +1 -1
  39. package/dist/{update-FUV5EYJO.js → update-2FUSEDQT.js} +1 -1
  40. package/dist/{user-JPZRQCZK.js → user-ECK4PTMM.js} +1 -1
  41. package/dist/{worker-agent-Y2P4UY6R.js → worker-agent-ZOJBMEKE.js} +2 -2
  42. package/dist/{workflow-2GFDILZH.js → workflow-TFNZMBOH.js} +2 -2
  43. package/package.json +1 -1
  44. package/dist/chunk-3CQP4TW4.js +0 -19
  45. package/dist/chunk-3WPPJAUV.js +0 -11
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{applyConditionLabel,applyInstancePlan,createInstancePlan,describeBlockedReason,formColumns,parseInstanceContent,workflowDomain,writtenInstance}from"./chunk-PQPDNZF2.js";import"./chunk-FQAOA2D6.js";import"./chunk-OZHZGZRR.js";import"./chunk-E3JTMC3K.js";import"./chunk-CHT6EP5C.js";import"./chunk-V5WDGX4S.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-6NHLWYI2.js";import"./chunk-WGBSVOTQ.js";import"./chunk-3CEGTEI3.js";
4
- import"./chunk-CJFIIGSH.js";import"./chunk-HVZUXLQ4.js";import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import"./chunk-TDO6V3ZW.js";import"./chunk-7DCWZ2NF.js";import"./chunk-HCTPCUST.js";import"./chunk-STILP3Z6.js";import"./chunk-3WPPJAUV.js";import"./chunk-GWVREACM.js";import"./chunk-J7QYPKVK.js";import"./chunk-YMM2AVTL.js";import"./chunk-RZVI6PMW.js";import"./chunk-OKATZ4SN.js";import"./chunk-NHYMHCAT.js";
3
+ import{applyConditionLabel,applyInstancePlan,createInstancePlan,describeBlockedReason,formColumns,parseInstanceContent,workflowDomain,writtenInstance}from"./chunk-IZ4KKMN4.js";import"./chunk-2D7O2P5K.js";import"./chunk-OZHZGZRR.js";import"./chunk-E3JTMC3K.js";import"./chunk-CHT6EP5C.js";import"./chunk-V5WDGX4S.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-6NHLWYI2.js";import"./chunk-WGBSVOTQ.js";import"./chunk-3CEGTEI3.js";
4
+ import"./chunk-CJFIIGSH.js";import"./chunk-HVZUXLQ4.js";import"./chunk-YJP4FUY4.js";import"./chunk-SBRTBKEZ.js";import"./chunk-TDO6V3ZW.js";import"./chunk-7DCWZ2NF.js";import"./chunk-HCTPCUST.js";import"./chunk-STILP3Z6.js";import"./chunk-B5DMHZQH.js";import"./chunk-GWVREACM.js";import"./chunk-J7QYPKVK.js";import"./chunk-YMM2AVTL.js";import"./chunk-RZVI6PMW.js";import"./chunk-OKATZ4SN.js";import"./chunk-NHYMHCAT.js";
5
5
  import"./chunk-VSJBJXZO.js";export{applyConditionLabel,applyInstancePlan,createInstancePlan,describeBlockedReason,formColumns,parseInstanceContent,workflowDomain,writtenInstance};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tocca-systems/twp-cli",
3
- "version": "0.158.1",
3
+ "version": "0.158.3",
4
4
  "description": "TWP CLI — Tocca Working Platform の CLI 型統合インターフェース(AIエージェントハーネス)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,19 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{configReadDirs}from"./chunk-RZVI6PMW.js";import{constants as fsConstants,lstatSync,readlinkSync,realpathSync,statSync}from"fs";import{open}from"fs/promises";import{homedir}from"os";import{pathToFileURL}from"url";import{dirname,isAbsolute,relative,resolve,sep}from"path";var PathDeniedError=class extends Error{constructor(message){super(message);this.name="PathDeniedError"}};function resolveToolPath(input,cwd,home=homedir()){if(typeof input!=="string"||input.trim()===""){throw new PathDeniedError("path must be a non-empty string")}const expanded=expandHome(input,home);const abs=isAbsolute(expanded)?resolve(expanded):resolve(cwd,expanded);const root=realOrSelf(resolve(cwd));assertInside(abs,resolve(cwd),input);assertNotSecret(abs,home,process.env,input);assertNotGitMetadata(
4
- abs,resolve(cwd),input);const real=realOrSelf(abs);if(real!==abs){assertInside(real,root,input);assertNotSecret(real,home,process.env,input);assertNotGitMetadata(real,root,input)}assertPlainEntry(real,input);return abs}function realToolPath(input,cwd,home=homedir()){return realOrSelf(resolveToolPath(input,cwd,home))}function assertInside(target,root,reported){const rel=relative(root,target);const outside=rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel);if(outside){throw new PathDeniedError(
5
- `path escapes the working directory (${reported}). Only paths under the working directory can be accessed.`)}}function gitMetadataReason(absPath,root){const rel=relative(root,absPath);if(rel===""||rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel))return null;return rel.split(sep).some(seg=>isGitSegment(seg))?"git metadata (.git) is denied; use the git tool to inspect history":null}function windowsCanonicalSegment(segment){return(segment.split(":")[0]??"").toLowerCase().replace(/[. ]+$/,"")}
6
- function windowsSegments(absPath){return absPath.split(sep).map((seg,i)=>i===0?seg.toLowerCase():windowsCanonicalSegment(seg))}var SHORT_NAME=/^([^.~ ]{1,7})~(\d{1,6})(?:\.[^. ]{1,3})?$/;function mayBeShortNameOf(segment,longName,family=false){const m=SHORT_NAME.exec(windowsCanonicalSegment(segment));if(!m)return false;const prefix=m[1]??"";const digits=(m[2]??"").length;const stem=longName.toLowerCase().replace(/^\.+/,"");const lastDot=family?-1:stem.lastIndexOf(".");const basis=(lastDot>0?stem.
7
- slice(0,lastDot):stem).replace(/[. ]/g,"");if(basis==="")return false;if(prefix.length<Math.min(basis.length,6)-(digits-1))return false;if(basis.startsWith(prefix))return true;if(family&&prefix.startsWith(basis))return true;return/^.{2}[0-9a-f]{4}$/.test(prefix)&&prefix.slice(0,2)===basis.slice(0,2)}function isWindowsAliasOf(segment,name,family=false){const canonical=windowsCanonicalSegment(segment);if(canonical===name||family&&canonical.startsWith(`${name}.`))return true;return mayBeShortNameOf(
8
- segment,name,family)}function isGitSegment(segment){return isWindowsAliasOf(segment,".git")}function assertNotGitMetadata(absPath,root,reported){const reason=gitMetadataReason(absPath,root);if(reason!==null)throw new PathDeniedError(`refusing to access ${reported}: ${reason}`)}function assertPlainEntry(real,reported){let info;try{info=statSync(real)}catch{return}const reason=plainEntryReason(info);if(reason!==null)throw new PathDeniedError(`refusing to access ${reported}: ${reason}`)}function plainEntryReason(info){
9
- if(info.isDirectory())return null;if(!info.isFile())return"not a regular file (FIFO, socket and device files are denied)";if(info.nlink>1)return"hard links are denied (the file has another name that may be outside the working directory)";return null}var O_NONBLOCK=fsConstants.O_NONBLOCK??0;async function openPlainFile(absPath,reported,mode){const flags=mode==="write"?fsConstants.O_RDWR|fsConstants.O_CREAT|O_NONBLOCK:mode==="update"?fsConstants.O_RDWR|O_NONBLOCK:fsConstants.O_RDONLY|O_NONBLOCK;let handle;
10
- try{handle=await open(absPath,flags,438)}catch(err){if(err.code==="ENOENT"&&mode!=="write")return null;throw err}try{const info=await handle.stat();if(info.isDirectory())throw Object.assign(new Error(`${reported} is a directory`),{code:"EISDIR"});const reason=plainEntryReason(info);if(reason!==null)throw new PathDeniedError(`refusing to access ${reported}: ${reason}`)}catch(err){await handle.close();throw err}return handle}async function replaceContent(handle,text){const buf=Buffer.from(text,"ut\
11
- f8");await handle.truncate(0);let offset=0;while(offset<buf.length){const{bytesWritten}=await handle.write(buf,offset,buf.length-offset,offset);offset+=bytesWritten}}function isGitMetadata(abs,cwd){const root=resolve(cwd);return gitMetadataReason(abs,root)!==null||gitMetadataReason(realOrSelf(abs),realOrSelf(root))!==null}function redactPaths(text,cwd,home=homedir()){const roots=[];for(const dir of new Set([resolve(cwd),realOrSelf(resolve(cwd))]))roots.push([dir,"."]);if(home!==""&&home!==sep){for(const dir of new Set(
12
- [resolve(home),realOrSelf(resolve(home))]))roots.push([dir,"~"])}roots.sort((a,b)=>b[0].length-a[0].length);let out=text;for(const[dir,label]of roots){if(dir===sep)continue;const sepClass=sep==="\\"?"[\\\\/]":"/";const escaped=dir.split(sep).map(part=>part.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(sepClass);out=out.replace(new RegExp(`(?:file:\\/\\/\\/?|(?<![\\w./\\\\-]))${escaped}(?=${sepClass}|$|[^\\w.-]|\\.(?![\\w-]))`,sep==="\\"?"gi":"g"),label);const href=pathToFileURL(dir).href;if(href!==
13
- `file://${dir}`&&href!==`file:///${dir.split(sep).join("/")}`){const escapedHref=href.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");out=out.replace(new RegExp(`${escapedHref}(?=/|$|[^\\w.%-]|\\.(?![\\w-]))`,sep==="\\"?"gi":"g"),label)}}return out}function realOrSelf(target){let current=target;const rest=[];let hops=0;for(;;){try{const real=realpathSync(current);return rest.length===0?real:resolve(real,...rest.reverse())}catch{let link=null;try{if(lstatSync(current).isSymbolicLink())link=readlinkSync(current)}catch{
14
- link=null}if(link!==null&&hops<40){hops+=1;current=resolve(dirname(current),link);continue}const parent=dirname(current);if(parent===current)return target;rest.push(current.slice(parent.length+1));current=parent}}}function assertNotSecret(absPath,home=homedir(),env=process.env,reported=absPath){const reason=secretReason(absPath,home,env);if(reason!==null)throw new PathDeniedError(`refusing to access ${reported}: ${reason}`)}function secretReason(absPath,_home=homedir(),env=process.env){const lower=absPath.
15
- toLowerCase();const segments=windowsSegments(absPath);const canonicalPath=segments.join(sep);const raw=absPath.split(sep);const base=segments[segments.length-1]??"";const rawBase=raw[raw.length-1]??"";const rawParent=raw[raw.length-2]??"";if(isWindowsAliasOf(rawBase,".env",true))return".env files are denied (design \xA77)";if(raw.slice(1).some(seg=>isWindowsAliasOf(seg,".ssh")))return"SSH key material is denied (design \xA77)";if(isGitSegment(rawParent)&&base==="config"){return".git/config is de\
16
- nied (it can hold a GitHub token in the remote URL)"}if([".netrc","_netrc",".npmrc"].some(name=>isWindowsAliasOf(rawBase,name))){return"credential files are denied"}if(isWindowsAliasOf(rawParent,".aws")&&(isWindowsAliasOf(rawBase,"credentials")||base==="config")){return"AWS credentials are denied"}const isCredentialsJson=isWindowsAliasOf(rawBase,"credentials.json");for(const dir of configReadDirs(env)){const target=resolve(dir,"credentials.json").toLowerCase();if(lower===target||canonicalPath===
17
- target)return"TWP credentials are denied (design \xA77)";if(isCredentialsJson&&dirname(canonicalPath)===resolve(dir).toLowerCase()){return"TWP credentials are denied (design \xA77)"}}if(isWindowsAliasOf(rawParent,".twp")&&isCredentialsJson)return"TWP credentials are denied (design \xA77)";const isSessionLog=base.startsWith("session-")&&base.endsWith(".jsonl")||mayBeShortNameOf(rawBase,"session",true);if(isWindowsAliasOf(rawParent,"logs")&&isSessionLog){const rawGrandparent=raw[raw.length-3]??"";
18
- if(isWindowsAliasOf(rawGrandparent,".twp"))return"TWP audit logs are denied (design \xA77)";for(const dir of configReadDirs(env)){const logs=resolve(dir,"logs").toLowerCase()+sep;if(lower.startsWith(logs)||canonicalPath.startsWith(logs)){return"TWP audit logs are denied (design \xA77)"}}}return null}function toolRelative(cwd,absPath){const rel=relative(cwd,absPath);return sep==="\\"?rel.split("\\").join("/"):rel}function isInsideCwd(absPath,cwd){const root=resolve(cwd);if(!withinLexically(absPath,
19
- root))return false;const real=realOrSelf(absPath);return real===absPath||withinLexically(real,realOrSelf(root))}function withinLexically(target,root){const rel=relative(root,target);return!(rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel))}function expandHome(input,home){if(input==="~")return home;if(input.startsWith("~/")||input.startsWith(`~${sep}`))return resolve(home,input.slice(2));return input}export{PathDeniedError,resolveToolPath,realToolPath,windowsCanonicalSegment,isWindowsAliasOf,openPlainFile,replaceContent,isGitMetadata,redactPaths,realOrSelf,secretReason,toolRelative,isInsideCwd};
@@ -1,11 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{loadCredentials,saveCredentialsUnlocked,withCredentialsLock}from"./chunk-GWVREACM.js";import{httpFetch}from"./chunk-J7QYPKVK.js";var NotLoggedInError=class extends Error{constructor(profile){super(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u300C${profile}\u300D\u306F\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u307E\u305B\u3093\u3002twp login \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}};var SessionExpiredError=class extends Error{constructor(profile){super(`\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u300C${profile}\u300D\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u304C\u5931\u52B9\u3057\u307E\u3057\u305F\uFF08refresh token \u304C\u7121\u52B9\uFF09\u3002twp login \u3067\u30ED\u30B0\u30A4\u30F3\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}};
4
- var DelegatedTokenRejectedError=class extends SessionExpiredError{constructor(profile){super(profile);this.message="\u59D4\u4EFB\u30C8\u30FC\u30AF\u30F3\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08\u5931\u52B9\u307E\u305F\u306F\u671F\u9650\u5207\u308C\uFF09\u3002stream-json \u5165\u529B\u306E auth \u884C\u3067\u65B0\u3057\u3044\u30C8\u30FC\u30AF\u30F3\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}};var DELEGATED_TOKEN_ENV="TWP_DELEGATED_TOKEN";function isValidDelegatedToken(token){
5
- return/^[\x21-\x7e]+$/.test(token)}var EXPIRY_MARGIN_MS=6e4;var AuthSession=class{constructor(profile,apiUrl,env=process.env,fetchImpl=httpFetch,now=Date.now){this.profile=profile;this.apiUrl=apiUrl;this.env=env;this.fetchImpl=fetchImpl;this.now=now}profile;apiUrl;env;fetchImpl;now;refreshInFlight=null;delegatedToken=null;useDelegatedToken(token){const t=token.trim();if(!isValidDelegatedToken(t))throw new Error("\u59D4\u4EFB\u30C8\u30FC\u30AF\u30F3\u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059\uFF08\u7A7A\u30FB\u7A7A\u767D\u30FB\u5236\u5FA1\u6587\u5B57\u30FB\u975EASCII\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF09");
6
- this.delegatedToken=t}get isDelegated(){return this.delegatedToken!==null}loadOrThrow(){if(this.delegatedToken!==null)throw new NotLoggedInError(this.profile);const creds=loadCredentials(this.profile,this.env);if(!creds)throw new NotLoggedInError(this.profile);return creds}async getAccessToken(){if(this.delegatedToken!==null)return this.delegatedToken;const creds=this.loadOrThrow();if(!this.isExpiring(creds))return creds.token;if(!creds.refresh_token){if(this.isExpired(creds))throw new SessionExpiredError(
7
- this.profile);return creds.token}return this.refresh(creds.token)}refresh(usedToken){if(this.delegatedToken!==null){return this.delegatedToken!==usedToken?Promise.resolve(this.delegatedToken):Promise.reject(new DelegatedTokenRejectedError(this.profile))}if(this.refreshInFlight)return this.refreshInFlight;this.refreshInFlight=this.refreshLocked(usedToken).finally(()=>{this.refreshInFlight=null});return this.refreshInFlight}async refreshLocked(usedToken){return withCredentialsLock(this.env,async()=>{
8
- const onDisk=this.loadOrThrow();if(onDisk.token!==usedToken&&!this.isExpiring(onDisk))return onDisk.token;if(!onDisk.refresh_token)throw new SessionExpiredError(this.profile);const result=await this.callRefreshApi(onDisk.refresh_token);if(result.ok){this.persist(onDisk,result.body);return result.body.token}const reread=this.loadOrThrow();if(reread.refresh_token&&reread.refresh_token!==onDisk.refresh_token){const retry=await this.callRefreshApi(reread.refresh_token);if(retry.ok){this.persist(reread,
9
- retry.body);return retry.body.token}}throw new SessionExpiredError(this.profile)})}async callRefreshApi(refreshToken){const res=await this.fetchImpl(`${this.apiUrl}/api/v2/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({refresh_token:refreshToken})});const body=await res.json().then(parsed=>parsed,()=>null);if(res.ok&&body?.result&&typeof body.token==="string"){return{ok:true,body}}return{ok:false}}persist(prev,body){saveCredentialsUnlocked(
10
- this.profile,{...prev,token:body.token,token_expires_at:body.token_expires_at??null,refresh_token:body.refresh_token??prev.refresh_token,refresh_token_expires_at:body.refresh_token_expires_at??prev.refresh_token_expires_at,user:body.user??prev.user,saved_at:new Date(this.now()).toISOString()},this.env)}isExpiring(creds){if(!creds.token_expires_at)return false;const at=Date.parse(creds.token_expires_at);return Number.isFinite(at)&&at-this.now()<EXPIRY_MARGIN_MS}isExpired(creds){if(!creds.token_expires_at)
11
- return false;const at=Date.parse(creds.token_expires_at);return Number.isFinite(at)&&at<=this.now()}};export{NotLoggedInError,SessionExpiredError,DELEGATED_TOKEN_ENV,isValidDelegatedToken,AuthSession};